Skip to content

Commit

Permalink
Move salt-related constants and functions together.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed May 8, 2024
1 parent 427d830 commit a0d7c88
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/crypto-primitives/src/Cryptography/Cipher/AES256CBC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ encrypt mode keyBytes ivBytes saltM msg
WithoutPadding -> id
WithPadding -> PKCS7.pad

saltLengthBytes :: Int
saltLengthBytes = 8

saltPrefix :: ByteString
saltPrefix = "Salted__"

-- | Decrypt using AES256 using CBC mode.
decrypt
:: CipherMode
Expand Down Expand Up @@ -169,6 +163,12 @@ decrypt mode key iv msg = do
WithoutPadding -> Right p
WithPadding -> maybeToEither EmptyPayload (PKCS7.unpad p)

saltLengthBytes :: Int
saltLengthBytes = 8

saltPrefix :: ByteString
saltPrefix = "Salted__"

getSaltFromEncrypted :: ByteString -> Maybe ByteString
getSaltFromEncrypted msg
| BS.length msg < 32 = Nothing
Expand Down

0 comments on commit a0d7c88

Please sign in to comment.