diff --git a/Crypto/Cipher/AES/Primitive.hs b/Crypto/Cipher/AES/Primitive.hs index 5038fbe..c0a5795 100644 --- a/Crypto/Cipher/AES/Primitive.hs +++ b/Crypto/Cipher/AES/Primitive.hs @@ -166,7 +166,7 @@ withOCBKeyAndCopySt aes (AESOCB gcmSt) f = -- | Initialize a new context with a key -- --- Key need to be of length 16, 24 or 32 bytes. any other values will cause undefined behavior +-- Key needs to be of length 16, 24 or 32 bytes. Any other values will return failure initAES :: ByteArrayAccess key => key -> CryptoFailable AES initAES k | len == 16 = CryptoPassed $ initWithRounds 10 @@ -418,7 +418,7 @@ gcmInit ctx iv = unsafeDoIO $ do c_aes_gcm_init (castPtr gcmStPtr) k v (fromIntegral $ B.length iv) return $ AESGCM sm --- | append data which is going to just be authentified to the GCM context. +-- | append data which is only going to be authenticated to the GCM context. -- -- need to happen after initialization and before appending encryption/decryption data. {-# NOINLINE gcmAppendAAD #-} @@ -489,7 +489,7 @@ ocbInit ctx iv = unsafeDoIO $ do c_aes_ocb_init (castPtr ocbStPtr) k v (fromIntegral $ B.length iv) return $ AESOCB sm --- | append data which is going to just be authentified to the OCB context. +-- | append data which is going to just be authenticated to the OCB context. -- -- need to happen after initialization and before appending encryption/decryption data. {-# NOINLINE ocbAppendAAD #-} diff --git a/Crypto/Cipher/Types/AEAD.hs b/Crypto/Cipher/Types/AEAD.hs index 6555fe7..4a4f613 100644 --- a/Crypto/Cipher/Types/AEAD.hs +++ b/Crypto/Cipher/Types/AEAD.hs @@ -49,10 +49,10 @@ aeadFinalize (AEAD impl st) n = (aeadImplFinalize impl) st n -- | Simple AEAD encryption aeadSimpleEncrypt :: (ByteArrayAccess aad, ByteArray ba) => AEAD a -- ^ A new AEAD Context - -> aad -- ^ Optional Authentified Header + -> aad -- ^ Optional Authentication data header -> ba -- ^ Optional Plaintext -> Int -- ^ Tag length - -> (AuthTag, ba) -- ^ Authentification tag and ciphertext + -> (AuthTag, ba) -- ^ Authentication tag and ciphertext aeadSimpleEncrypt aeadIni header input taglen = (tag, output) where aead = aeadAppendHeader aeadIni header (output, aeadFinal) = aeadEncrypt aead input @@ -61,9 +61,9 @@ aeadSimpleEncrypt aeadIni header input taglen = (tag, output) -- | Simple AEAD decryption aeadSimpleDecrypt :: (ByteArrayAccess aad, ByteArray ba) => AEAD a -- ^ A new AEAD Context - -> aad -- ^ Optional Authentified Header - -> ba -- ^ Optional Plaintext - -> AuthTag -- ^ Tag length + -> aad -- ^ Optional Authentication data header + -> ba -- ^ Ciphertext + -> AuthTag -- ^ The authentication tag -> Maybe ba -- ^ Plaintext aeadSimpleDecrypt aeadIni header input authTag | tag == authTag = Just output diff --git a/Crypto/Cipher/Types/Base.hs b/Crypto/Cipher/Types/Base.hs index 4b758dd..ef1a4a6 100644 --- a/Crypto/Cipher/Types/Base.hs +++ b/Crypto/Cipher/Types/Base.hs @@ -32,7 +32,7 @@ data KeySizeSpecifier = -- | Offset inside an XTS data unit, measured in block size. type DataUnitOffset = Word32 --- | Authentification Tag for AE cipher mode +-- | Authentication Tag for AE cipher mode newtype AuthTag = AuthTag { unAuthTag :: Bytes } deriving (Show, ByteArrayAccess) diff --git a/Crypto/PubKey/RSA/PKCS15.hs b/Crypto/PubKey/RSA/PKCS15.hs index e5e9e2d..65351a1 100644 --- a/Crypto/PubKey/RSA/PKCS15.hs +++ b/Crypto/PubKey/RSA/PKCS15.hs @@ -100,9 +100,9 @@ decryptSafer pk b = do blinder <- generateBlinder (private_n pk) return (decrypt (Just blinder) pk b) --- | encrypt a bytestring using the public key and a CPRG random generator. +-- | encrypt a bytestring using the public key. -- --- the message need to be smaller than the key size - 11 +-- the message needs to be smaller than the key size - 11 encrypt :: MonadRandom m => PublicKey -> ByteString -> m (Either Error ByteString) encrypt pk m = do r <- pad (public_size pk) m diff --git a/tests/BlockCipher.hs b/tests/BlockCipher.hs index 65590a0..8d0d020 100644 --- a/tests/BlockCipher.hs +++ b/tests/BlockCipher.hs @@ -75,7 +75,7 @@ data KAT_AEAD = KAT_AEAD { aeadMode :: AEADMode , aeadKey :: ByteString -- ^ Key , aeadIV :: ByteString -- ^ IV for initialization - , aeadHeader :: ByteString -- ^ Authentificated Header + , aeadHeader :: ByteString -- ^ Authenticated Header , aeadPlaintext :: ByteString -- ^ Plaintext , aeadCiphertext :: ByteString -- ^ Ciphertext , aeadTaglen :: Int -- ^ aead tag len @@ -104,7 +104,7 @@ testECB (_, _, cipherInit) ecbEncrypt ecbDecrypt kats = ] where ctx = cipherInit (ecbKey d) --propTest = testProperty "decrypt.encrypt" (ECBUnit key plaintext) = - + --testProperty_ECB (ECBUnit (cipherInit -> ctx) (toBytes -> plaintext)) = -- plaintext `assertEq` ecbDecrypt ctx (ecbEncrypt ctx plaintext)