Use pattern matching
This commit is contained in:
parent
4926cbb143
commit
325c87febf
@ -494,12 +494,16 @@ ccmGetL l = case l of
|
|||||||
-- | initialize a ccm context
|
-- | initialize a ccm context
|
||||||
{-# NOINLINE ccmInit #-}
|
{-# NOINLINE ccmInit #-}
|
||||||
ccmInit :: ByteArrayAccess iv => AES -> iv -> Int -> CCM_M -> CCM_L -> CryptoFailable AESCCM
|
ccmInit :: ByteArrayAccess iv => AES -> iv -> Int -> CCM_M -> CCM_L -> CryptoFailable AESCCM
|
||||||
ccmInit ctx iv n m l = if 15 - ccmGetL l /= B.length iv then CryptoFailed CryptoError_IvSizeInvalid
|
ccmInit ctx iv n m l
|
||||||
else unsafeDoIO $ do
|
| 15 - li /= B.length iv = CryptoFailed CryptoError_IvSizeInvalid
|
||||||
sm <- B.alloc sizeCCM $ \ccmStPtr ->
|
| otherwise = unsafeDoIO $ do
|
||||||
withKeyAndIV ctx iv $ \k v ->
|
sm <- B.alloc sizeCCM $ \ccmStPtr ->
|
||||||
c_aes_ccm_init (castPtr ccmStPtr) k v (fromIntegral $ B.length iv) (fromIntegral n) (fromIntegral (ccmGetM m)) (fromIntegral (ccmGetL l))
|
withKeyAndIV ctx iv $ \k v ->
|
||||||
return $ CryptoPassed (AESCCM sm)
|
c_aes_ccm_init (castPtr ccmStPtr) k v (fromIntegral $ B.length iv) (fromIntegral n) (fromIntegral mi) (fromIntegral li)
|
||||||
|
return $ CryptoPassed (AESCCM sm)
|
||||||
|
where
|
||||||
|
mi = ccmGetM m
|
||||||
|
li = ccmGetL l
|
||||||
|
|
||||||
-- | append data which is only going to be authenticated to the CCM context.
|
-- | append data which is only going to be authenticated to the CCM context.
|
||||||
--
|
--
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user