[aes] fast track length == 0 with ECB encryption/decryption
This commit is contained in:
parent
c7068873c5
commit
be75de64e1
@ -351,11 +351,13 @@ doECB :: ByteArray ba
|
|||||||
=> (Ptr b -> Ptr AES -> CString -> CUInt -> IO ())
|
=> (Ptr b -> Ptr AES -> CString -> CUInt -> IO ())
|
||||||
-> AES -> ba -> ba
|
-> AES -> ba -> ba
|
||||||
doECB f ctx input
|
doECB f ctx input
|
||||||
| r /= 0 = error $ "Encryption error: input length must be a multiple of block size (16). Its length is: " ++ (show len)
|
| len == 0 = B.empty
|
||||||
| otherwise = B.allocAndFreeze len $ \o ->
|
| r /= 0 = error $ "Encryption error: input length must be a multiple of block size (16). Its length is: " ++ (show len)
|
||||||
keyToPtr ctx $ \k ->
|
| otherwise =
|
||||||
withByteArray input $ \i ->
|
B.allocAndFreeze len $ \o ->
|
||||||
f (castPtr o) k i (fromIntegral nbBlocks)
|
keyToPtr ctx $ \k ->
|
||||||
|
withByteArray input $ \i ->
|
||||||
|
f (castPtr o) k i (fromIntegral nbBlocks)
|
||||||
where (nbBlocks, r) = len `quotRem` 16
|
where (nbBlocks, r) = len `quotRem` 16
|
||||||
len = B.length input
|
len = B.length input
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user