7 Commits
0.1.1 ... 0.2

Author SHA1 Message Date
Jonathan Lamothe
412c8312b0 version 0.2 2019-01-01 23:03:09 -05:00
Jonathan Lamothe
012486c045 handle empty input string in mkPass 2019-01-01 22:50:16 -05:00
Jonathan Lamothe
cdff8c8917 refactored mkHash 2019-01-01 22:45:03 -05:00
Jonathan Lamothe
f305822ae1 whitespace fix 2019-01-01 22:25:25 -05:00
Jonathan Lamothe
7cf0b34078 warn when changing master password 2019-01-01 21:15:09 -05:00
Jonathan Lamothe
191be38fbe implemented manual saving 2019-01-01 21:02:52 -05:00
Jonathan Lamothe
f2ae7bca76 fixed changelog 2019-01-01 04:57:24 -05:00
4 changed files with 26 additions and 15 deletions

View File

@@ -1,6 +1,12 @@
# Changelog for passman # Changelog for passman
## Unreleased changes ## 0.2
- implemented manual saving
- added a warning when changing master password
- some code cleanup as suggested by [Stephen Paul Weber](https://github.com/singpolyma)
## 0.1.1
- corrected a bug that was causing the pwGenerate function to hang occasionally. - corrected a bug that was causing the pwGenerate function to hang occasionally.
- this may cause some passwords to be generated differently - this may cause some passwords to be generated differently

View File

@@ -63,6 +63,7 @@ mainMenu =
[ ( "add a password", addPassword ) [ ( "add a password", addPassword )
, ( "view/edit a password", viewEditMenu ) , ( "view/edit a password", viewEditMenu )
, ( "change master password", changeMasterPass ) , ( "change master password", changeMasterPass )
, ( "save manually", save >> mainMenu )
, ( "lock session", lockSession ) , ( "lock session", lockSession )
, ( "quit", quit ) , ( "quit", quit )
] ]
@@ -93,9 +94,13 @@ viewEditMenu = menu "View/Edit Password"
changeMasterPass :: S.StateT Status IO () changeMasterPass :: S.StateT Status IO ()
changeMasterPass = do changeMasterPass = do
req (confirm $
"\nWARNING: Changing your master password will change all of your saved passwords.\n" ++
"Are you sure you would like to proceed?") >>= flip when
(do
oldP <- S.gets $ view masterPass oldP <- S.gets $ view masterPass
newP <- req $ reqDefault getMasterPass oldP newP <- req $ reqDefault getMasterPass oldP
S.modify $ set masterPass newP S.modify $ set masterPass newP)
mainMenu mainMenu
lockSession :: S.StateT Status IO () lockSession :: S.StateT Status IO ()

View File

@@ -1,5 +1,5 @@
name: passman name: passman
version: 0.1.1 version: 0.2
github: "jlamothe/passman" github: "jlamothe/passman"
license: LGPL-3 license: LGPL-3
author: "Jonathan Lamothe" author: "Jonathan Lamothe"
@@ -30,6 +30,7 @@ dependencies:
library: library:
source-dirs: src source-dirs: src
dependencies: dependencies:
- base16-bytestring
- base64-bytestring - base64-bytestring
- SHA - SHA
- text - text

View File

@@ -59,6 +59,7 @@ import Data.Aeson
, (.=) , (.=)
) )
import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Base16.Lazy as B16
import qualified Data.ByteString.Base64.Lazy as B64 import qualified Data.ByteString.Base64.Lazy as B64
import Data.Char (isUpper, isLower, isDigit, isAlphaNum, toLower) import Data.Char (isUpper, isLower, isDigit, isAlphaNum, toLower)
import Data.Digest.Pure.SHA import Data.Digest.Pure.SHA
@@ -322,10 +323,11 @@ isSpecial :: Char -> Bool
isSpecial = not . isAlphaNum isSpecial = not . isAlphaNum
mkPass :: String -> PWPolicy -> String mkPass :: String -> PWPolicy -> String
mkPass (x:xs) p = let p' = nextPolicy x p in mkPass [] _ = "" -- this should never happen
if p^.pwLength <= 0 mkPass (x:xs) p = if p^.pwLength <= 0
then "" then ""
else if validatePWPolicy p' else let p' = nextPolicy x p in
if validatePWPolicy p'
then x : mkPass xs p' then x : mkPass xs p'
else mkPass xs p else mkPass xs p
@@ -338,10 +340,7 @@ mkSeed :: String -> PWData -> B.ByteString
mkSeed pw d = toUTF8 pw `B.append` (d^.pwSalt) mkSeed pw d = toUTF8 pw `B.append` (d^.pwSalt)
mkHash :: B.ByteString -> B.ByteString mkHash :: B.ByteString -> B.ByteString
mkHash = raw . show . sha256 where mkHash = fst . B16.decode . encodeUtf8 . T.pack . show . sha256
raw (x:y:xs) = read ("0x" ++ [x] ++ [y]) `B.cons` raw xs
raw [_] = error "odd number of hex digits in hash"
raw "" = B.empty
nextPolicy :: Char -> PWPolicy -> PWPolicy nextPolicy :: Char -> PWPolicy -> PWPolicy
nextPolicy x p = over pwLength pred $ nextPolicy x p = over pwLength pred $