Skip to content

Commit

Permalink
Switch to verification for EncryptWithScrypt using cryptonite
Browse files Browse the repository at this point in the history
  • Loading branch information
HeinrichApfelmus committed Feb 14, 2024
1 parent 9c9f63d commit 8a7bca2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lib/secrets/src/Cardano/Wallet/Primitive/Passphrase.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ checkPassphrase
-> Either ErrWrongPassphrase ()
checkPassphrase scheme received stored = case scheme of
EncryptWithPBKDF2 -> PBKDF2.checkPassphrase prepared stored
EncryptWithScrypt -> case Scrypt.checkPassphrase prepared stored of
Just True -> Right ()
Just False -> Left ErrWrongPassphrase
Nothing -> Left (ErrPassphraseSchemeUnsupported scheme)
EncryptWithScrypt ->
if Scrypt.checkPassphrase prepared stored
then Right ()
else Left ErrWrongPassphrase
where
prepared = preparePassphrase scheme received

Expand Down
9 changes: 2 additions & 7 deletions lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Legacy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,8 @@ hashed passphrases that were created with `scrypt`.
------------------------------------------------------------------------------}
-- | Verify a wallet spending password using the legacy Byron scrypt encryption
-- scheme.
checkPassphrase :: Passphrase "encryption" -> PassphraseHash -> Maybe Bool
#if HAVE_SCRYPT
checkPassphrase pwd stored = Just $ checkPassphraseScrypt pwd stored
#else
-- Stub function for when compiled without @scrypt@.
checkPassphrase _ _ = Nothing
#endif
checkPassphrase :: Passphrase "encryption" -> PassphraseHash -> Bool
checkPassphrase = checkPassphraseCryptonite

-- | Encrypt a wallet spending password using
-- the legacy Byron scrypt encryption scheme.
Expand Down

0 comments on commit 8a7bca2

Please sign in to comment.