Skip to content

Commit

Permalink
Rename {iv,key} parameters of encrypt.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Apr 10, 2024
1 parent 1f2709e commit ed08b6e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/crypto-primitives/src/Cryptography/Cipher/AES256CBC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ encrypt
-> ByteString
-- ^ Payload: must be a multiple of a block size, ie., 16 bytes.
-> Either CipherError ByteString
encrypt mode key iv saltM msg
encrypt mode keyBytes ivBytes saltM msg
| any ((/= 8) . BS.length) saltM =
Left WrongSaltSize
| mode == WithoutPadding && BS.length msg `mod` 16 /= 0 =
Left WrongPayloadSize
| BS.null msg =
Left EmptyPayload
| otherwise = do
initedIV <- first FromCryptonite (createIV iv)
cypher <- first FromCryptonite (initCipher key)
pure $ maybeAddSalt $ cbcEncrypt cypher initedIV $ maybePad msg
iv <- first FromCryptonite (createIV ivBytes)
cypher <- first FromCryptonite (initCipher keyBytes)
pure $ maybeAddSalt $ cbcEncrypt cypher iv $ maybePad msg
where
maybeAddSalt :: ByteString -> ByteString
maybeAddSalt =
Expand Down

0 comments on commit ed08b6e

Please sign in to comment.