cipher-aes128 0.3 → 0.3.1
raw patch · 3 files changed
+10/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
Crypto/Cipher/AES128.hs view
@@ -30,7 +30,7 @@ instance BlockCipher AESKey where blockSize = Tagged 128 keyLength = Tagged 128- buildKey bs + buildKey bs | B.length bs >= 16 = unsafePerformIO $ B.unsafeUseAsCString bs $ \ptr -> do k <- generateKey (castPtr ptr)
Crypto/Cipher/AES128/Internal.hs view
@@ -79,15 +79,16 @@ generateKey :: Ptr Word64 -- ^ Buffer of 16 bytes of key material -> IO AESKey generateKey keyPtr = do- k <- c_allocate_key128- c_generate_key128 k (castPtr keyPtr) raw <- do a <- peekLE (castPtr keyPtr) let keyPtr2 = (castPtr keyPtr) `plusPtr` sizeOf a b <- peekLE keyPtr2- return (RKey a b)+ return (RKey b a)+ k <- c_allocate_key128+ c_generate_key128 k (castPtr keyPtr) fmap (AESKey raw) (newForeignPtr c_free_key128 k) where+ peekLE :: Ptr Word8 -> IO Word64 peekLE p = do a1 <- peekElemOff p 0 a2 <- peekElemOff p 1@@ -97,9 +98,10 @@ a6 <- peekElemOff p 5 a7 <- peekElemOff p 6 a8 <- peekElemOff p 7- let a = (a1 `shiftL` 56) .|. (a2 `shiftL` 48) .|. (a3 `shiftL` 40) .|.- (a4 `shiftL` 32) .|. (a5 `shiftL` 24) .|. (a6 `shiftL` 16) .|.- (a7 `shiftL` 8) .|. a8+ let f n s = fromIntegral n `shiftL` s+ let a = (f a1 56) .|. (f a2 48) .|. (f a3 40) .|.+ (f a4 32) .|. (f a5 24) .|. (f a6 16) .|.+ (f a7 8) .|. fromIntegral a8 return a {-# INLINE generateKey #-}
cipher-aes128.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: cipher-aes128-version: 0.3+version: 0.3.1 synopsis: AES128 using AES-NI when available. description: AES128 with crypto-api instances and a trampoline between Vincent Hanquez's C-based and x86 NI-based AES. Patches welcome to add additional high-performance backends (ARM?) license: BSD3