diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,89 @@
+# CHANGELOG for crypton
+
+## 1.1.4
+
+* Generic instance for RSA PublicKey and PrivateKey
+
+## 1.1.3
+
+* Ensure that `pointAdd` in `PubKey.ECC.P256` treats the point at infinity as the additive identity.
+  [#73](https://github.com/kazu-yamamoto/crypton/pull/73)
+
+## 1.1.2
+
+* Preparing `ram` v0.22.
+* Generalizing RSA encrypt/decrypt to manipulate ScrubbedBytes directly.
+
+## 1.1.1
+
+* On iOS, ScrubbedBytes based hashing is used for seedNew. On other
+  plateforms, entropy is used directly as used to be.
+  [#71](https://github.com/kazu-yamamoto/crypton/pull/71)
+
+## 1.1.0
+
+* Removing "basement" and "memory".
+  [#67](https://github.com/kazu-yamamoto/crypton/pull/67)
+
+
+## 1.0.7
+
+* Stop depending on basement, use upstream dependencies instead
+* Stop transitively depending on basement by depending on ram.
+
+## 1.0.6
+
+* Fix test failures on less common 64-bit arches.
+  [#65](https://github.com/kazu-yamamoto/crypton/pull/65)
+
+## 1.0.5
+
+* Setter/Getter for ChaCha counter.
+  [#63](https://github.com/kazu-yamamoto/crypton/pull/63)
+* Add simple interface to generate full blocks
+  [#60](https://github.com/kazu-yamamoto/crypton/pull/60)
+* Avoid `ghc-prim` dependency.
+  [#61](https://github.com/kazu-yamamoto/crypton/pull/61)
+
+## 1.0.4
+
+* Ed448.sign: avoid extra re-derive of public key.
+  [#48](https://github.com/kazu-yamamoto/crypton/pull/48)
+
+## 1.0.3
+
+* Make sign of Ed25519/Ed448 safer. The public key parameter is
+  ignored and its public key is generated from the secret key
+  parameter to prevent Double Public Key Signing Function Oracle
+  Attack.
+  [#47](https://github.com/kazu-yamamoto/crypton/pull/47)
+
+## 1.0.2
+
+* Deterministic Nonce Generation for ECDSA
+  [#46](https://github.com/kazu-yamamoto/crypton/pull/46)
+* ECDSA Signature Normalization.
+  [#45](https://github.com/kazu-yamamoto/crypton/pull/45)
+* Add Full Test Suite from RFC 6979.
+  [#44](https://github.com/kazu-yamamoto/crypton/pull/44)
+* ECDSA with Public Key Recovery.
+  [#43](https://github.com/kazu-yamamoto/crypton/pull/43)
+* Providing necessary features for HPKE.
+  [#42](https://github.com/kazu-yamamoto/crypton/pull/42)
+
+## 1.0.1
+
+* Update decaf library.
+  [#38](https://github.com/kazu-yamamoto/crypton/pull/38)
+* Add TypeOperators language extension to EdDSA.hs.
+  [#36](https://github.com/kazu-yamamoto/crypton/pull/36)
+
+## 1.0.0
+
+* Versions follow the standard version policy.
+* Removing pthread stuff.
+  [#32](https://github.com/kazu-yamamoto/crypton/pull/32)
+
 ## 0.34
 
 * Hashing getRandomBytes before using as Seed for ChaChaDRG
diff --git a/Crypto/Cipher/AES.hs b/Crypto/Cipher/AES.hs
--- a/Crypto/Cipher/AES.hs
+++ b/Crypto/Cipher/AES.hs
@@ -1,22 +1,23 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.Cipher.AES
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : stable
 -- Portability : good
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.Cipher.AES
-    ( AES128
-    , AES192
-    , AES256
-    ) where
+module Crypto.Cipher.AES (
+    AES128,
+    AES192,
+    AES256,
+) where
 
-import Crypto.Error
+import Crypto.Cipher.AES.Primitive
 import Crypto.Cipher.Types
-import Crypto.Cipher.Utils
 import Crypto.Cipher.Types.Block
-import Crypto.Cipher.AES.Primitive
+import Crypto.Cipher.Utils
+import Crypto.Error
 import Crypto.Internal.Imports
 
 -- | AES with 128 bit key
@@ -32,20 +33,19 @@
     deriving (NFData)
 
 instance Cipher AES128 where
-    cipherName    _ = "AES128"
+    cipherName _ = "AES128"
     cipherKeySize _ = KeySizeFixed 16
-    cipherInit k    = AES128 <$> (initAES =<< validateKeySize (undefined :: AES128) k)
+    cipherInit k = AES128 <$> (initAES =<< validateKeySize (undefined :: AES128) k)
 
 instance Cipher AES192 where
-    cipherName    _ = "AES192"
+    cipherName _ = "AES192"
     cipherKeySize _ = KeySizeFixed 24
-    cipherInit k    = AES192 <$> (initAES =<< validateKeySize (undefined :: AES192) k)
+    cipherInit k = AES192 <$> (initAES =<< validateKeySize (undefined :: AES192) k)
 
 instance Cipher AES256 where
-    cipherName    _ = "AES256"
+    cipherName _ = "AES256"
     cipherKeySize _ = KeySizeFixed 32
-    cipherInit k    = AES256 <$> (initAES =<< validateKeySize (undefined :: AES256) k)
-
+    cipherInit k = AES256 <$> (initAES =<< validateKeySize (undefined :: AES256) k)
 
 #define INSTANCE_BLOCKCIPHER(CSTR) \
 instance BlockCipher CSTR where \
diff --git a/Crypto/Cipher/AES/Primitive.hs b/Crypto/Cipher/AES/Primitive.hs
--- a/Crypto/Cipher/AES/Primitive.hs
+++ b/Crypto/Cipher/AES/Primitive.hs
@@ -1,75 +1,79 @@
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE ViewPatterns #-}
 {-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE ViewPatterns #-}
+
 -- |
 -- Module      : Crypto.Cipher.AES.Primitive
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : stable
 -- Portability : good
---
-module Crypto.Cipher.AES.Primitive
-    (
+module Crypto.Cipher.AES.Primitive (
     -- * Block cipher data types
-      AES
+    AES,
 
     -- * Authenticated encryption block cipher types
-    , AESGCM
-    , AESOCB
+    AESGCM,
+    AESOCB,
 
     -- * Creation
-    , initAES
+    initAES,
 
     -- * Miscellanea
-    , genCTR
-    , genCounter
+    genCTR,
+    genCounter,
 
     -- * Encryption
-    , encryptECB
-    , encryptCBC
-    , encryptCTR
-    , encryptXTS
+    encryptECB,
+    encryptCBC,
+    encryptCTR,
+    encryptXTS,
 
     -- * Decryption
-    , decryptECB
-    , decryptCBC
-    , decryptCTR
-    , decryptXTS
+    decryptECB,
+    decryptCBC,
+    decryptCTR,
+    decryptXTS,
 
     -- * CTR with 32-bit wrapping
-    , combineC32
+    combineC32,
 
     -- * Incremental GCM
-    , gcmMode
-    , gcmInit
+    gcmMode,
+    gcmInit,
 
     -- * Incremental OCB
-    , ocbMode
-    , ocbInit
+    ocbMode,
+    ocbInit,
 
     -- * CCM
-    , ccmMode
-    , ccmInit
-    ) where
+    ccmMode,
+    ccmInit,
+) where
 
-import           Data.Word
-import           Foreign.Ptr
-import           Foreign.C.Types
-import           Foreign.C.String
+import Data.Word
+import Foreign.C.String
+import Foreign.C.Types
+import Foreign.Ptr
 
-import           Crypto.Error
-import           Crypto.Cipher.Types
-import           Crypto.Cipher.Types.Block (IV(..))
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, ScrubbedBytes, withByteArray)
+import Crypto.Cipher.Types
+import Crypto.Cipher.Types.Block (IV (..))
+import Crypto.Error
+import Crypto.Internal.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    ScrubbedBytes,
+    withByteArray,
+ )
 import qualified Crypto.Internal.ByteArray as B
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
 
 instance Cipher AES where
-    cipherName    _ = "AES"
-    cipherKeySize _ = KeySizeEnum [16,24,32]
-    cipherInit k    = initAES k
+    cipherName _ = "AES"
+    cipherKeySize _ = KeySizeEnum [16, 24, 32]
+    cipherInit k = initAES k
 
 instance BlockCipher AES where
     blockSize _ = 16
@@ -81,38 +85,40 @@
     aeadInit AEAD_GCM aes iv = CryptoPassed $ AEAD (gcmMode aes) (gcmInit aes iv)
     aeadInit AEAD_OCB aes iv = CryptoPassed $ AEAD (ocbMode aes) (ocbInit aes iv)
     aeadInit (AEAD_CCM n m l) aes iv = AEAD (ccmMode aes) <$> ccmInit aes iv n m l
-    aeadInit _        _   _  = CryptoFailed CryptoError_AEADModeNotSupported
+    aeadInit _ _ _ = CryptoFailed CryptoError_AEADModeNotSupported
 instance BlockCipher128 AES where
     xtsEncrypt = encryptXTS
     xtsDecrypt = decryptXTS
 
 -- | Create an AES AEAD implementation for GCM
 gcmMode :: AES -> AEADModeImpl AESGCM
-gcmMode aes = AEADModeImpl
-    { aeadImplAppendHeader = gcmAppendAAD
-    , aeadImplEncrypt      = gcmAppendEncrypt aes
-    , aeadImplDecrypt      = gcmAppendDecrypt aes
-    , aeadImplFinalize     = gcmFinish aes
-    }
+gcmMode aes =
+    AEADModeImpl
+        { aeadImplAppendHeader = gcmAppendAAD
+        , aeadImplEncrypt = gcmAppendEncrypt aes
+        , aeadImplDecrypt = gcmAppendDecrypt aes
+        , aeadImplFinalize = gcmFinish aes
+        }
 
 -- | Create an AES AEAD implementation for OCB
 ocbMode :: AES -> AEADModeImpl AESOCB
-ocbMode aes = AEADModeImpl
-    { aeadImplAppendHeader = ocbAppendAAD aes
-    , aeadImplEncrypt      = ocbAppendEncrypt aes
-    , aeadImplDecrypt      = ocbAppendDecrypt aes
-    , aeadImplFinalize     = ocbFinish aes
-    }
+ocbMode aes =
+    AEADModeImpl
+        { aeadImplAppendHeader = ocbAppendAAD aes
+        , aeadImplEncrypt = ocbAppendEncrypt aes
+        , aeadImplDecrypt = ocbAppendDecrypt aes
+        , aeadImplFinalize = ocbFinish aes
+        }
 
 -- | Create an AES AEAD implementation for CCM
 ccmMode :: AES -> AEADModeImpl AESCCM
-ccmMode aes = AEADModeImpl
-    { aeadImplAppendHeader = ccmAppendAAD aes
-    , aeadImplEncrypt      = ccmEncrypt aes
-    , aeadImplDecrypt      = ccmDecrypt aes
-    , aeadImplFinalize     = ccmFinish aes
-    }
-
+ccmMode aes =
+    AEADModeImpl
+        { aeadImplAppendHeader = ccmAppendAAD aes
+        , aeadImplEncrypt = ccmEncrypt aes
+        , aeadImplDecrypt = ccmDecrypt aes
+        , aeadImplFinalize = ccmFinish aes
+        }
 
 -- | AES Context (pre-processed key)
 newtype AES = AES ScrubbedBytes
@@ -145,42 +151,47 @@
 ivToPtr :: ByteArrayAccess iv => iv -> (Ptr Word8 -> IO a) -> IO a
 ivToPtr iv f = withByteArray iv (f . castPtr)
 
-
 ivCopyPtr :: IV AES -> (Ptr Word8 -> IO a) -> IO (a, IV AES)
-ivCopyPtr (IV iv) f = (\(x,y) -> (x, IV y)) `fmap` copyAndModify iv f
+ivCopyPtr (IV iv) f = (\(x, y) -> (x, IV y)) `fmap` copyAndModify iv f
   where
     copyAndModify :: ByteArray ba => ba -> (Ptr Word8 -> IO a) -> IO (a, ba)
     copyAndModify ba f' = B.copyRet ba f'
 
-withKeyAndIV :: ByteArrayAccess iv => AES -> iv -> (Ptr AES -> Ptr Word8 -> IO a) -> IO a
+withKeyAndIV
+    :: ByteArrayAccess iv => AES -> iv -> (Ptr AES -> Ptr Word8 -> IO a) -> IO a
 withKeyAndIV ctx iv f = keyToPtr ctx $ \kptr -> ivToPtr iv $ \ivp -> f kptr ivp
 
-withKey2AndIV :: ByteArrayAccess iv => AES -> AES -> iv -> (Ptr AES -> Ptr AES -> Ptr Word8 -> IO a) -> IO a
+withKey2AndIV
+    :: ByteArrayAccess iv
+    => AES -> AES -> iv -> (Ptr AES -> Ptr AES -> Ptr Word8 -> IO a) -> IO a
 withKey2AndIV key1 key2 iv f =
     keyToPtr key1 $ \kptr1 -> keyToPtr key2 $ \kptr2 -> ivToPtr iv $ \ivp -> f kptr1 kptr2 ivp
 
-withGCMKeyAndCopySt :: AES -> AESGCM -> (Ptr AESGCM -> Ptr AES -> IO a) -> IO (a, AESGCM)
+withGCMKeyAndCopySt
+    :: AES -> AESGCM -> (Ptr AESGCM -> Ptr AES -> IO a) -> IO (a, AESGCM)
 withGCMKeyAndCopySt aes (AESGCM gcmSt) f =
     keyToPtr aes $ \aesPtr -> do
         newSt <- B.copy gcmSt (\_ -> return ())
-        a     <- withByteArray newSt $ \gcmStPtr -> f (castPtr gcmStPtr) aesPtr
+        a <- withByteArray newSt $ \gcmStPtr -> f (castPtr gcmStPtr) aesPtr
         return (a, AESGCM newSt)
 
 withNewGCMSt :: AESGCM -> (Ptr AESGCM -> IO ()) -> IO AESGCM
 withNewGCMSt (AESGCM gcmSt) f = B.copy gcmSt (f . castPtr) >>= \sm2 -> return (AESGCM sm2)
 
-withOCBKeyAndCopySt :: AES -> AESOCB -> (Ptr AESOCB -> Ptr AES -> IO a) -> IO (a, AESOCB)
+withOCBKeyAndCopySt
+    :: AES -> AESOCB -> (Ptr AESOCB -> Ptr AES -> IO a) -> IO (a, AESOCB)
 withOCBKeyAndCopySt aes (AESOCB gcmSt) f =
     keyToPtr aes $ \aesPtr -> do
         newSt <- B.copy gcmSt (\_ -> return ())
-        a     <- withByteArray newSt $ \gcmStPtr -> f (castPtr gcmStPtr) aesPtr
+        a <- withByteArray newSt $ \gcmStPtr -> f (castPtr gcmStPtr) aesPtr
         return (a, AESOCB newSt)
 
-withCCMKeyAndCopySt :: AES -> AESCCM -> (Ptr AESCCM -> Ptr AES -> IO a) -> IO (a, AESCCM)
+withCCMKeyAndCopySt
+    :: AES -> AESCCM -> (Ptr AESCCM -> Ptr AES -> IO a) -> IO (a, AESCCM)
 withCCMKeyAndCopySt aes (AESCCM ccmSt) f =
     keyToPtr aes $ \aesPtr -> do
         newSt <- B.copy ccmSt (\_ -> return ())
-        a     <- withByteArray newSt $ \ccmStPtr -> f (castPtr ccmStPtr) aesPtr
+        a <- withByteArray newSt $ \ccmStPtr -> f (castPtr ccmStPtr) aesPtr
         return (a, AESCCM newSt)
 
 -- | Initialize a new context with a key
@@ -192,10 +203,11 @@
     | len == 24 = CryptoPassed $ initWithRounds 12
     | len == 32 = CryptoPassed $ initWithRounds 14
     | otherwise = CryptoFailed CryptoError_KeySizeInvalid
-  where len = B.length k
-        initWithRounds nbR = AES $ B.allocAndFreeze (16+2*2*16*nbR) aesInit
-        aesInit ptr = withByteArray k $ \ikey ->
-            c_aes_init (castPtr ptr) (castPtr ikey) (fromIntegral len)
+  where
+    len = B.length k
+    initWithRounds nbR = AES $ B.allocAndFreeze (16 + 2 * 2 * 16 * nbR) aesInit
+    aesInit ptr = withByteArray k $ \ikey ->
+        c_aes_init (castPtr ptr) (castPtr ikey) (fromIntegral len)
 
 -- | encrypt using Electronic Code Book (ECB)
 {-# NOINLINE encryptECB #-}
@@ -204,11 +216,16 @@
 
 -- | encrypt using Cipher Block Chaining (CBC)
 {-# NOINLINE encryptCBC #-}
-encryptCBC :: ByteArray ba
-           => AES        -- ^ AES Context
-           -> IV AES     -- ^ Initial vector of AES block size
-           -> ba         -- ^ plaintext
-           -> ba         -- ^ ciphertext
+encryptCBC
+    :: ByteArray ba
+    => AES
+    -- ^ AES Context
+    -> IV AES
+    -- ^ Initial vector of AES block size
+    -> ba
+    -- ^ plaintext
+    -> ba
+    -- ^ ciphertext
 encryptCBC = doCBC c_aes_encrypt_cbc
 
 -- | generate a counter mode pad. this is generally xor-ed to an input
@@ -218,17 +235,22 @@
 -- more data will be returned, so that the returned bytearray is
 -- a multiple of the block cipher size.
 {-# NOINLINE genCTR #-}
-genCTR :: ByteArray ba
-       => AES    -- ^ Cipher Key.
-       -> IV AES -- ^ usually a 128 bit integer.
-       -> Int    -- ^ length of bytes required.
-       -> ba
+genCTR
+    :: ByteArray ba
+    => AES
+    -- ^ Cipher Key.
+    -> IV AES
+    -- ^ usually a 128 bit integer.
+    -> Int
+    -- ^ length of bytes required.
+    -> ba
 genCTR ctx (IV iv) len
-    | len <= 0  = B.empty
+    | len <= 0 = B.empty
     | otherwise = B.allocAndFreeze (nbBlocks * 16) generate
-  where generate o = withKeyAndIV ctx iv $ \k i -> c_aes_gen_ctr (castPtr o) k i (fromIntegral nbBlocks)
-        (nbBlocks',r) = len `quotRem` 16
-        nbBlocks = if r == 0 then nbBlocks' else nbBlocks' + 1
+  where
+    generate o = withKeyAndIV ctx iv $ \k i -> c_aes_gen_ctr (castPtr o) k i (fromIntegral nbBlocks)
+    (nbBlocks', r) = len `quotRem` 16
+    nbBlocks = if r == 0 then nbBlocks' else nbBlocks' + 1
 
 -- | generate a counter mode pad. this is generally xor-ed to an input
 -- to make the standard counter mode block operations.
@@ -239,22 +261,23 @@
 --
 -- Similiar to 'genCTR' but also return the next IV for continuation
 {-# NOINLINE genCounter #-}
-genCounter :: ByteArray ba
-           => AES
-           -> IV AES
-           -> Int
-           -> (ba, IV AES)
+genCounter
+    :: ByteArray ba
+    => AES
+    -> IV AES
+    -> Int
+    -> (ba, IV AES)
 genCounter ctx iv len
-    | len <= 0  = (B.empty, iv)
+    | len <= 0 = (B.empty, iv)
     | otherwise = unsafeDoIO $
         keyToPtr ctx $ \k ->
-        ivCopyPtr iv $ \i ->
-        B.alloc outputLength $ \o -> do
-            c_aes_gen_ctr_cont (castPtr o) k i (fromIntegral nbBlocks)
+            ivCopyPtr iv $ \i ->
+                B.alloc outputLength $ \o -> do
+                    c_aes_gen_ctr_cont (castPtr o) k i (fromIntegral nbBlocks)
   where
-        (nbBlocks',r) = len `quotRem` 16
-        nbBlocks = if r == 0 then nbBlocks' else nbBlocks' + 1
-        outputLength = nbBlocks * 16
+    (nbBlocks', r) = len `quotRem` 16
+    nbBlocks = if r == 0 then nbBlocks' else nbBlocks' + 1
+    outputLength = nbBlocks * 16
 
 {- TODO: when genCTR has same AESIV requirements for IV, add the following rules:
  - RULES "snd . genCounter" forall ctx iv len .  snd (genCounter ctx iv len) = genCTR ctx iv len
@@ -264,30 +287,45 @@
 --
 -- in CTR mode encryption and decryption is the same operation.
 {-# NOINLINE encryptCTR #-}
-encryptCTR :: ByteArray ba
-           => AES        -- ^ AES Context
-           -> IV AES     -- ^ initial vector of AES block size (usually representing a 128 bit integer)
-           -> ba         -- ^ plaintext input
-           -> ba         -- ^ ciphertext output
+encryptCTR
+    :: ByteArray ba
+    => AES
+    -- ^ AES Context
+    -> IV AES
+    -- ^ initial vector of AES block size (usually representing a 128 bit integer)
+    -> ba
+    -- ^ plaintext input
+    -> ba
+    -- ^ ciphertext output
 encryptCTR ctx iv input
-    | len <= 0          = B.empty
-    | B.length iv /= 16 = error $ "AES error: IV length must be block size (16). Its length is: " ++ (show $ B.length iv)
+    | len <= 0 = B.empty
+    | B.length iv /= 16 =
+        error $
+            "AES error: IV length must be block size (16). Its length is: "
+                ++ (show $ B.length iv)
     | otherwise = B.allocAndFreeze len doEncrypt
-  where doEncrypt o = withKeyAndIV ctx iv $ \k v -> withByteArray input $ \i ->
-                      c_aes_encrypt_ctr (castPtr o) k v i (fromIntegral len)
-        len = B.length input
+  where
+    doEncrypt o = withKeyAndIV ctx iv $ \k v -> withByteArray input $ \i ->
+        c_aes_encrypt_ctr (castPtr o) k v i (fromIntegral len)
+    len = B.length input
 
 -- | encrypt using XTS
 --
 -- the first key is the normal block encryption key
 -- the second key is used for the initial block tweak
 {-# NOINLINE encryptXTS #-}
-encryptXTS :: ByteArray ba
-           => (AES,AES)  -- ^ AES cipher and tweak context
-           -> IV AES     -- ^ a 128 bits IV, typically a sector or a block offset in XTS
-           -> Word32     -- ^ number of rounds to skip, also seen a 16 byte offset in the sector or block.
-           -> ba         -- ^ input to encrypt
-           -> ba         -- ^ output encrypted
+encryptXTS
+    :: ByteArray ba
+    => (AES, AES)
+    -- ^ AES cipher and tweak context
+    -> IV AES
+    -- ^ a 128 bits IV, typically a sector or a block offset in XTS
+    -> Word32
+    -- ^ number of rounds to skip, also seen a 16 byte offset in the sector or block.
+    -> ba
+    -- ^ input to encrypt
+    -> ba
+    -- ^ output encrypted
 encryptXTS = doXTS c_aes_encrypt_xts
 
 -- | decrypt using Electronic Code Book (ECB)
@@ -303,82 +341,122 @@
 -- | decrypt using Counter mode (CTR).
 --
 -- in CTR mode encryption and decryption is the same operation.
-decryptCTR :: ByteArray ba
-           => AES        -- ^ AES Context
-           -> IV AES     -- ^ initial vector, usually representing a 128 bit integer
-           -> ba         -- ^ ciphertext input
-           -> ba         -- ^ plaintext output
+decryptCTR
+    :: ByteArray ba
+    => AES
+    -- ^ AES Context
+    -> IV AES
+    -- ^ initial vector, usually representing a 128 bit integer
+    -> ba
+    -- ^ ciphertext input
+    -> ba
+    -- ^ plaintext output
 decryptCTR = encryptCTR
 
 -- | decrypt using XTS
 {-# NOINLINE decryptXTS #-}
-decryptXTS :: ByteArray ba
-           => (AES,AES)  -- ^ AES cipher and tweak context
-           -> IV AES     -- ^ a 128 bits IV, typically a sector or a block offset in XTS
-           -> Word32     -- ^ number of rounds to skip, also seen a 16 byte offset in the sector or block.
-           -> ba         -- ^ input to decrypt
-           -> ba         -- ^ output decrypted
+decryptXTS
+    :: ByteArray ba
+    => (AES, AES)
+    -- ^ AES cipher and tweak context
+    -> IV AES
+    -- ^ a 128 bits IV, typically a sector or a block offset in XTS
+    -> Word32
+    -- ^ number of rounds to skip, also seen a 16 byte offset in the sector or block.
+    -> ba
+    -- ^ input to decrypt
+    -> ba
+    -- ^ output decrypted
 decryptXTS = doXTS c_aes_decrypt_xts
 
 -- | encrypt/decrypt using Counter mode (32-bit wrapping used in AES-GCM-SIV)
 {-# NOINLINE combineC32 #-}
-combineC32 :: ByteArray ba
-           => AES        -- ^ AES Context
-           -> IV AES     -- ^ initial vector of AES block size (usually representing a 128 bit integer)
-           -> ba         -- ^ plaintext input
-           -> ba         -- ^ ciphertext output
+combineC32
+    :: ByteArray ba
+    => AES
+    -- ^ AES Context
+    -> IV AES
+    -- ^ initial vector of AES block size (usually representing a 128 bit integer)
+    -> ba
+    -- ^ plaintext input
+    -> ba
+    -- ^ ciphertext output
 combineC32 ctx iv input
-    | len <= 0          = B.empty
-    | B.length iv /= 16 = error $ "AES error: IV length must be block size (16). Its length is: " ++ show (B.length iv)
+    | len <= 0 = B.empty
+    | B.length iv /= 16 =
+        error $
+            "AES error: IV length must be block size (16). Its length is: "
+                ++ show (B.length iv)
     | otherwise = B.allocAndFreeze len doEncrypt
-  where doEncrypt o = withKeyAndIV ctx iv $ \k v -> withByteArray input $ \i ->
-                      c_aes_encrypt_c32 (castPtr o) k v i (fromIntegral len)
-        len = B.length input
+  where
+    doEncrypt o = withKeyAndIV ctx iv $ \k v -> withByteArray input $ \i ->
+        c_aes_encrypt_c32 (castPtr o) k v i (fromIntegral len)
+    len = B.length input
 
 {-# INLINE doECB #-}
-doECB :: ByteArray ba
-      => (Ptr b -> Ptr AES -> CString -> CUInt -> IO ())
-      -> AES -> ba -> ba
+doECB
+    :: ByteArray ba
+    => (Ptr b -> Ptr AES -> CString -> CUInt -> IO ())
+    -> AES
+    -> ba
+    -> ba
 doECB f ctx input
-    | len == 0     = B.empty
-    | r /= 0       = error $ "Encryption error: input length must be a multiple of block size (16). Its length is: " ++ (show len)
-    | otherwise    =
+    | len == 0 = B.empty
+    | r /= 0 =
+        error $
+            "Encryption error: input length must be a multiple of block size (16). Its length is: "
+                ++ (show len)
+    | otherwise =
         B.allocAndFreeze len $ \o ->
-        keyToPtr ctx         $ \k ->
-        withByteArray input  $ \i ->
-            f (castPtr o) k i (fromIntegral nbBlocks)
-  where (nbBlocks, r) = len `quotRem` 16
-        len           = B.length input
+            keyToPtr ctx $ \k ->
+                withByteArray input $ \i ->
+                    f (castPtr o) k i (fromIntegral nbBlocks)
+  where
+    (nbBlocks, r) = len `quotRem` 16
+    len = B.length input
 
 {-# INLINE doCBC #-}
-doCBC :: ByteArray ba
-      => (Ptr b -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ())
-      -> AES -> IV AES -> ba -> ba
+doCBC
+    :: ByteArray ba
+    => (Ptr b -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ())
+    -> AES
+    -> IV AES
+    -> ba
+    -> ba
 doCBC f ctx (IV iv) input
-    | len == 0  = B.empty
-    | r /= 0    = error $ "Encryption error: input length must be a multiple of block size (16). Its length is: " ++ (show len)
+    | len == 0 = B.empty
+    | r /= 0 =
+        error $
+            "Encryption error: input length must be a multiple of block size (16). Its length is: "
+                ++ (show len)
     | otherwise = B.allocAndFreeze len $ \o ->
-                  withKeyAndIV ctx iv $ \k v ->
-                  withByteArray input $ \i ->
-                  f (castPtr o) k v i (fromIntegral nbBlocks)
-  where (nbBlocks, r) = len `quotRem` 16
-        len           = B.length input
+        withKeyAndIV ctx iv $ \k v ->
+            withByteArray input $ \i ->
+                f (castPtr o) k v i (fromIntegral nbBlocks)
+  where
+    (nbBlocks, r) = len `quotRem` 16
+    len = B.length input
 
 {-# INLINE doXTS #-}
-doXTS :: ByteArray ba
-      => (Ptr b -> Ptr AES -> Ptr AES -> Ptr Word8 -> CUInt -> CString -> CUInt -> IO ())
-      -> (AES, AES)
-      -> IV AES
-      -> Word32
-      -> ba
-      -> ba
-doXTS f (key1,key2) iv spoint input
-    | len == 0  = B.empty
-    | r /= 0    = error $ "Encryption error: input length must be a multiple of block size (16) for now. Its length is: " ++ (show len)
+doXTS
+    :: ByteArray ba
+    => (Ptr b -> Ptr AES -> Ptr AES -> Ptr Word8 -> CUInt -> CString -> CUInt -> IO ())
+    -> (AES, AES)
+    -> IV AES
+    -> Word32
+    -> ba
+    -> ba
+doXTS f (key1, key2) iv spoint input
+    | len == 0 = B.empty
+    | r /= 0 =
+        error $
+            "Encryption error: input length must be a multiple of block size (16) for now. Its length is: "
+                ++ (show len)
     | otherwise = B.allocAndFreeze len $ \o -> withKey2AndIV key1 key2 iv $ \k1 k2 v -> withByteArray input $ \i ->
-            f (castPtr o) k1 k2 v (fromIntegral spoint) i (fromIntegral nbBlocks)
-  where (nbBlocks, r) = len `quotRem` 16
-        len           = B.length input
+        f (castPtr o) k1 k2 v (fromIntegral spoint) i (fromIntegral nbBlocks)
+  where
+    (nbBlocks, r) = len `quotRem` 16
+    len = B.length input
 
 ------------------------------------------------------------------------
 -- GCM
@@ -389,7 +467,7 @@
 gcmInit :: ByteArrayAccess iv => AES -> iv -> AESGCM
 gcmInit ctx iv = unsafeDoIO $ do
     sm <- B.alloc sizeGCM $ \gcmStPtr ->
-            withKeyAndIV ctx iv $ \k v ->
+        withKeyAndIV ctx iv $ \k v ->
             c_aes_gcm_init (castPtr gcmStPtr) k v (fromIntegral $ B.length iv)
     return $ AESGCM sm
 
@@ -399,10 +477,11 @@
 {-# NOINLINE gcmAppendAAD #-}
 gcmAppendAAD :: ByteArrayAccess aad => AESGCM -> aad -> AESGCM
 gcmAppendAAD gcmSt input = unsafeDoIO doAppend
-  where doAppend =
-            withNewGCMSt gcmSt $ \gcmStPtr ->
+  where
+    doAppend =
+        withNewGCMSt gcmSt $ \gcmStPtr ->
             withByteArray input $ \i ->
-            c_aes_gcm_aad gcmStPtr i (fromIntegral $ B.length input)
+                c_aes_gcm_aad gcmStPtr i (fromIntegral $ B.length input)
 
 -- | append data to encrypt and append to the GCM context
 --
@@ -411,11 +490,12 @@
 {-# NOINLINE gcmAppendEncrypt #-}
 gcmAppendEncrypt :: ByteArray ba => AES -> AESGCM -> ba -> (ba, AESGCM)
 gcmAppendEncrypt ctx gcm input = unsafeDoIO $ withGCMKeyAndCopySt ctx gcm doEnc
-  where len = B.length input
-        doEnc gcmStPtr aesPtr =
-            B.alloc len $ \o ->
+  where
+    len = B.length input
+    doEnc gcmStPtr aesPtr =
+        B.alloc len $ \o ->
             withByteArray input $ \i ->
-            c_aes_gcm_encrypt (castPtr o) gcmStPtr aesPtr i (fromIntegral len)
+                c_aes_gcm_encrypt (castPtr o) gcmStPtr aesPtr i (fromIntegral len)
 
 -- | append data to decrypt and append to the GCM context
 --
@@ -424,18 +504,20 @@
 {-# NOINLINE gcmAppendDecrypt #-}
 gcmAppendDecrypt :: ByteArray ba => AES -> AESGCM -> ba -> (ba, AESGCM)
 gcmAppendDecrypt ctx gcm input = unsafeDoIO $ withGCMKeyAndCopySt ctx gcm doDec
-  where len = B.length input
-        doDec gcmStPtr aesPtr =
-            B.alloc len $ \o ->
+  where
+    len = B.length input
+    doDec gcmStPtr aesPtr =
+        B.alloc len $ \o ->
             withByteArray input $ \i ->
-            c_aes_gcm_decrypt (castPtr o) gcmStPtr aesPtr i (fromIntegral len)
+                c_aes_gcm_decrypt (castPtr o) gcmStPtr aesPtr i (fromIntegral len)
 
 -- | Generate the Tag from GCM context
 {-# NOINLINE gcmFinish #-}
 gcmFinish :: AES -> AESGCM -> Int -> AuthTag
 gcmFinish ctx gcm taglen = AuthTag $ B.take taglen computeTag
-  where computeTag = B.allocAndFreeze 16 $ \t ->
-                        withGCMKeyAndCopySt ctx gcm (c_aes_gcm_finish (castPtr t)) >> return ()
+  where
+    computeTag = B.allocAndFreeze 16 $ \t ->
+        withGCMKeyAndCopySt ctx gcm (c_aes_gcm_finish (castPtr t)) >> return ()
 
 ------------------------------------------------------------------------
 -- OCB v3
@@ -446,7 +528,7 @@
 ocbInit :: ByteArrayAccess iv => AES -> iv -> AESOCB
 ocbInit ctx iv = unsafeDoIO $ do
     sm <- B.alloc sizeOCB $ \ocbStPtr ->
-            withKeyAndIV ctx iv $ \k v ->
+        withKeyAndIV ctx iv $ \k v ->
             c_aes_ocb_init (castPtr ocbStPtr) k v (fromIntegral $ B.length iv)
     return $ AESOCB sm
 
@@ -456,8 +538,9 @@
 {-# NOINLINE ocbAppendAAD #-}
 ocbAppendAAD :: ByteArrayAccess aad => AES -> AESOCB -> aad -> AESOCB
 ocbAppendAAD ctx ocb input = unsafeDoIO (snd `fmap` withOCBKeyAndCopySt ctx ocb doAppend)
-  where doAppend ocbStPtr aesPtr =
-            withByteArray input $ \i ->
+  where
+    doAppend ocbStPtr aesPtr =
+        withByteArray input $ \i ->
             c_aes_ocb_aad ocbStPtr aesPtr i (fromIntegral $ B.length input)
 
 -- | append data to encrypt and append to the OCB context
@@ -467,11 +550,12 @@
 {-# NOINLINE ocbAppendEncrypt #-}
 ocbAppendEncrypt :: ByteArray ba => AES -> AESOCB -> ba -> (ba, AESOCB)
 ocbAppendEncrypt ctx ocb input = unsafeDoIO $ withOCBKeyAndCopySt ctx ocb doEnc
-  where len = B.length input
-        doEnc ocbStPtr aesPtr =
-            B.alloc len $ \o ->
+  where
+    len = B.length input
+    doEnc ocbStPtr aesPtr =
+        B.alloc len $ \o ->
             withByteArray input $ \i ->
-            c_aes_ocb_encrypt (castPtr o) ocbStPtr aesPtr i (fromIntegral len)
+                c_aes_ocb_encrypt (castPtr o) ocbStPtr aesPtr i (fromIntegral len)
 
 -- | append data to decrypt and append to the OCB context
 --
@@ -480,45 +564,56 @@
 {-# NOINLINE ocbAppendDecrypt #-}
 ocbAppendDecrypt :: ByteArray ba => AES -> AESOCB -> ba -> (ba, AESOCB)
 ocbAppendDecrypt ctx ocb input = unsafeDoIO $ withOCBKeyAndCopySt ctx ocb doDec
-  where len = B.length input
-        doDec ocbStPtr aesPtr =
-            B.alloc len $ \o ->
+  where
+    len = B.length input
+    doDec ocbStPtr aesPtr =
+        B.alloc len $ \o ->
             withByteArray input $ \i ->
-            c_aes_ocb_decrypt (castPtr o) ocbStPtr aesPtr i (fromIntegral len)
+                c_aes_ocb_decrypt (castPtr o) ocbStPtr aesPtr i (fromIntegral len)
 
 -- | Generate the Tag from OCB context
 {-# NOINLINE ocbFinish #-}
 ocbFinish :: AES -> AESOCB -> Int -> AuthTag
 ocbFinish ctx ocb taglen = AuthTag $ B.take taglen computeTag
-  where computeTag = B.allocAndFreeze 16 $ \t ->
-                        withOCBKeyAndCopySt ctx ocb (c_aes_ocb_finish (castPtr t)) >> return ()
+  where
+    computeTag = B.allocAndFreeze 16 $ \t ->
+        withOCBKeyAndCopySt ctx ocb (c_aes_ocb_finish (castPtr t)) >> return ()
 
 ccmGetM :: CCM_M -> Int
 ccmGetL :: CCM_L -> Int
 ccmGetM m = case m of
-  CCM_M4 -> 4
-  CCM_M6 -> 6
-  CCM_M8 -> 8
-  CCM_M10 -> 10
-  CCM_M12 -> 12
-  CCM_M14 -> 14
-  CCM_M16 -> 16
+    CCM_M4 -> 4
+    CCM_M6 -> 6
+    CCM_M8 -> 8
+    CCM_M10 -> 10
+    CCM_M12 -> 12
+    CCM_M14 -> 14
+    CCM_M16 -> 16
 
 ccmGetL l = case l of
-  CCM_L2 -> 2
-  CCM_L3 -> 3
-  CCM_L4 -> 4
+    CCM_L2 -> 2
+    CCM_L3 -> 3
+    CCM_L4 -> 4
 
 -- | initialize a ccm context
 {-# 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
     | 15 - li /= B.length iv = CryptoFailed CryptoError_IvSizeInvalid
     | otherwise = unsafeDoIO $ do
-          sm <- B.alloc sizeCCM $ \ccmStPtr ->
+        sm <- B.alloc sizeCCM $ \ccmStPtr ->
             withKeyAndIV ctx iv $ \k v ->
-            c_aes_ccm_init (castPtr ccmStPtr) k v (fromIntegral $ B.length iv) (fromIntegral n) (fromIntegral mi) (fromIntegral li)
-          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
@@ -529,8 +624,9 @@
 {-# NOINLINE ccmAppendAAD #-}
 ccmAppendAAD :: ByteArrayAccess aad => AES -> AESCCM -> aad -> AESCCM
 ccmAppendAAD ctx ccm input = unsafeDoIO $ snd <$> withCCMKeyAndCopySt ctx ccm doAppend
-  where doAppend ccmStPtr aesPtr =
-            withByteArray input $ \i -> c_aes_ccm_aad ccmStPtr aesPtr i (fromIntegral $ B.length input)
+  where
+    doAppend ccmStPtr aesPtr =
+        withByteArray input $ \i -> c_aes_ccm_aad ccmStPtr aesPtr i (fromIntegral $ B.length input)
 
 -- | append data to encrypt and append to the CCM context
 --
@@ -539,11 +635,12 @@
 {-# NOINLINE ccmEncrypt #-}
 ccmEncrypt :: ByteArray ba => AES -> AESCCM -> ba -> (ba, AESCCM)
 ccmEncrypt ctx ccm input = unsafeDoIO $ withCCMKeyAndCopySt ctx ccm cbcmacAndIv
-  where len = B.length input
-        cbcmacAndIv ccmStPtr aesPtr =
-            B.alloc len $ \o ->
+  where
+    len = B.length input
+    cbcmacAndIv ccmStPtr aesPtr =
+        B.alloc len $ \o ->
             withByteArray input $ \i ->
-            c_aes_ccm_encrypt (castPtr o) ccmStPtr aesPtr i (fromIntegral len)
+                c_aes_ccm_encrypt (castPtr o) ccmStPtr aesPtr i (fromIntegral len)
 
 -- | append data to decrypt and append to the CCM context
 --
@@ -552,18 +649,20 @@
 {-# NOINLINE ccmDecrypt #-}
 ccmDecrypt :: ByteArray ba => AES -> AESCCM -> ba -> (ba, AESCCM)
 ccmDecrypt ctx ccm input = unsafeDoIO $ withCCMKeyAndCopySt ctx ccm cbcmacAndIv
-  where len = B.length input
-        cbcmacAndIv ccmStPtr aesPtr =
-            B.alloc len $ \o ->
+  where
+    len = B.length input
+    cbcmacAndIv ccmStPtr aesPtr =
+        B.alloc len $ \o ->
             withByteArray input $ \i ->
-            c_aes_ccm_decrypt (castPtr o) ccmStPtr aesPtr i (fromIntegral len)
+                c_aes_ccm_decrypt (castPtr o) ccmStPtr aesPtr i (fromIntegral len)
 
 -- | Generate the Tag from CCM context
 {-# NOINLINE ccmFinish #-}
 ccmFinish :: AES -> AESCCM -> Int -> AuthTag
 ccmFinish ctx ccm taglen = AuthTag $ B.take taglen computeTag
-  where computeTag = B.allocAndFreeze 16 $ \t ->
-                        withCCMKeyAndCopySt ctx ccm (c_aes_ccm_finish (castPtr t)) >> return ()
+  where
+    computeTag = B.allocAndFreeze 16 $ \t ->
+        withCCMKeyAndCopySt ctx ccm (c_aes_ccm_finish (castPtr t)) >> return ()
 
 ------------------------------------------------------------------------
 foreign import ccall "crypton_aes.h crypton_aes_initkey"
@@ -576,16 +675,20 @@
     c_aes_decrypt_ecb :: CString -> Ptr AES -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_encrypt_cbc"
-    c_aes_encrypt_cbc :: CString -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ()
+    c_aes_encrypt_cbc
+        :: CString -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_decrypt_cbc"
-    c_aes_decrypt_cbc :: CString -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ()
+    c_aes_decrypt_cbc
+        :: CString -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_encrypt_xts"
-    c_aes_encrypt_xts :: CString -> Ptr AES -> Ptr AES -> Ptr Word8 -> CUInt -> CString -> CUInt -> IO ()
+    c_aes_encrypt_xts
+        :: CString -> Ptr AES -> Ptr AES -> Ptr Word8 -> CUInt -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_decrypt_xts"
-    c_aes_decrypt_xts :: CString -> Ptr AES -> Ptr AES -> Ptr Word8 -> CUInt -> CString -> CUInt -> IO ()
+    c_aes_decrypt_xts
+        :: CString -> Ptr AES -> Ptr AES -> Ptr Word8 -> CUInt -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_gen_ctr"
     c_aes_gen_ctr :: CString -> Ptr AES -> Ptr Word8 -> CUInt -> IO ()
@@ -594,10 +697,12 @@
     c_aes_gen_ctr_cont :: CString -> Ptr AES -> Ptr Word8 -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_encrypt_ctr"
-    c_aes_encrypt_ctr :: CString -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ()
+    c_aes_encrypt_ctr
+        :: CString -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_encrypt_c32"
-    c_aes_encrypt_c32 :: CString -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ()
+    c_aes_encrypt_c32
+        :: CString -> Ptr AES -> Ptr Word8 -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_gcm_init"
     c_aes_gcm_init :: Ptr AESGCM -> Ptr AES -> Ptr Word8 -> CUInt -> IO ()
@@ -606,10 +711,12 @@
     c_aes_gcm_aad :: Ptr AESGCM -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_gcm_encrypt"
-    c_aes_gcm_encrypt :: CString -> Ptr AESGCM -> Ptr AES -> CString -> CUInt -> IO ()
+    c_aes_gcm_encrypt
+        :: CString -> Ptr AESGCM -> Ptr AES -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_gcm_decrypt"
-    c_aes_gcm_decrypt :: CString -> Ptr AESGCM -> Ptr AES -> CString -> CUInt -> IO ()
+    c_aes_gcm_decrypt
+        :: CString -> Ptr AESGCM -> Ptr AES -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_gcm_finish"
     c_aes_gcm_finish :: CString -> Ptr AESGCM -> Ptr AES -> IO ()
@@ -621,25 +728,30 @@
     c_aes_ocb_aad :: Ptr AESOCB -> Ptr AES -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_ocb_encrypt"
-    c_aes_ocb_encrypt :: CString -> Ptr AESOCB -> Ptr AES -> CString -> CUInt -> IO ()
+    c_aes_ocb_encrypt
+        :: CString -> Ptr AESOCB -> Ptr AES -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_ocb_decrypt"
-    c_aes_ocb_decrypt :: CString -> Ptr AESOCB -> Ptr AES -> CString -> CUInt -> IO ()
+    c_aes_ocb_decrypt
+        :: CString -> Ptr AESOCB -> Ptr AES -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_ocb_finish"
     c_aes_ocb_finish :: CString -> Ptr AESOCB -> Ptr AES -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_ccm_init"
-    c_aes_ccm_init :: Ptr AESCCM -> Ptr AES -> Ptr Word8 -> CUInt -> CUInt -> CInt -> CInt -> IO ()
+    c_aes_ccm_init
+        :: Ptr AESCCM -> Ptr AES -> Ptr Word8 -> CUInt -> CUInt -> CInt -> CInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_ccm_aad"
     c_aes_ccm_aad :: Ptr AESCCM -> Ptr AES -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_ccm_encrypt"
-    c_aes_ccm_encrypt :: CString -> Ptr AESCCM -> Ptr AES -> CString -> CUInt -> IO ()
+    c_aes_ccm_encrypt
+        :: CString -> Ptr AESCCM -> Ptr AES -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_ccm_decrypt"
-    c_aes_ccm_decrypt :: CString -> Ptr AESCCM -> Ptr AES -> CString -> CUInt -> IO ()
+    c_aes_ccm_decrypt
+        :: CString -> Ptr AESCCM -> Ptr AES -> CString -> CUInt -> IO ()
 
 foreign import ccall "crypton_aes.h crypton_aes_ccm_finish"
     c_aes_ccm_finish :: CString -> Ptr AESCCM -> Ptr AES -> IO ()
diff --git a/Crypto/Cipher/AESGCMSIV.hs b/Crypto/Cipher/AESGCMSIV.hs
--- a/Crypto/Cipher/AESGCMSIV.hs
+++ b/Crypto/Cipher/AESGCMSIV.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.Cipher.AESGCMSIV
 -- License     : BSD-style
@@ -16,28 +19,27 @@
 --
 -- The specification allows inputs up to 2^36 bytes but this implementation
 -- requires AAD and plaintext/ciphertext to be both smaller than 2^32 bytes.
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.Cipher.AESGCMSIV
-    ( Nonce
-    , nonce
-    , generateNonce
-    , encrypt
-    , decrypt
-    ) where
+module Crypto.Cipher.AESGCMSIV (
+    Nonce,
+    nonce,
+    generateNonce,
+    encrypt,
+    decrypt,
+) where
 
 import Data.Bits
+import Data.Maybe
 import Data.Word
 
-import Foreign.C.Types
 import Foreign.C.String
+import Foreign.C.Types
 import Foreign.Ptr (Ptr, plusPtr)
 import Foreign.Storable (peekElemOff, poke, pokeElemOff)
 
-import           Data.ByteArray
+import Data.ByteArray (ByteArray, ByteArrayAccess, Bytes, ScrubbedBytes)
 import qualified Data.ByteArray as B
-import           Data.Memory.Endian (toLE)
-import           Data.Memory.PtrMethods (memXor)
+import Data.Memory.Endian (toLE)
+import Data.Memory.PtrMethods (memXor)
 
 import Crypto.Cipher.AES.Primitive
 import Crypto.Cipher.Types
@@ -45,7 +47,6 @@
 import Crypto.Internal.Compat (unsafeDoIO)
 import Crypto.Random
 
-
 -- 12-byte nonces
 
 -- | Nonce value for AES-GCM-SIV, always 12 bytes.
@@ -55,26 +56,27 @@
 nonce :: ByteArrayAccess iv => iv -> CryptoFailable Nonce
 nonce iv
     | B.length iv == 12 = CryptoPassed (Nonce $ B.convert iv)
-    | otherwise         = CryptoFailed CryptoError_IvSizeInvalid
+    | otherwise = CryptoFailed CryptoError_IvSizeInvalid
 
 -- | Generate a random nonce for use with AES-GCM-SIV.
 generateNonce :: MonadRandom m => m Nonce
 generateNonce = Nonce <$> getRandomBytes 12
 
-
 -- POLYVAL (mutable context)
 
 newtype Polyval = Polyval Bytes
 
 polyvalInit :: ScrubbedBytes -> IO Polyval
 polyvalInit h = Polyval <$> doInit
-  where doInit = B.alloc 272 $ \pctx -> B.withByteArray h $ \ph ->
-            c_aes_polyval_init pctx ph
+  where
+    doInit = B.alloc 272 $ \pctx -> B.withByteArray h $ \ph ->
+        c_aes_polyval_init pctx ph
 
 polyvalUpdate :: ByteArrayAccess ba => Polyval -> ba -> IO ()
 polyvalUpdate (Polyval ctx) bs = B.withByteArray ctx $ \pctx ->
     B.withByteArray bs $ \pbs -> c_aes_polyval_update pctx pbs sz
-  where sz = fromIntegral (B.length bs)
+  where
+    sz = fromIntegral (B.length bs)
 
 polyvalFinalize :: Polyval -> IO ScrubbedBytes
 polyvalFinalize (Polyval ctx) = B.alloc 16 $ \dst ->
@@ -89,35 +91,35 @@
 foreign import ccall unsafe "crypton_aes.h crypton_aes_polyval_finalize"
     c_aes_polyval_finalize :: Ptr Polyval -> CString -> IO ()
 
-
 -- Key Generation
 
 le32iv :: Word32 -> Nonce -> Bytes
 le32iv n (Nonce iv) = B.allocAndFreeze 16 $ \ptr -> do
     poke ptr (toLE n)
-    copyByteArrayToPtr iv (ptr `plusPtr` 4)
+    B.copyByteArrayToPtr iv (ptr `plusPtr` 4)
 
 deriveKeys :: BlockCipher128 aes => aes -> Nonce -> (ScrubbedBytes, AES)
 deriveKeys aes iv =
     case cipherKeySize aes of
-        KeySizeFixed sz | sz `mod` 8 == 0 ->
-            let mak = buildKey [0 .. 1]
-                key = buildKey [2 .. fromIntegral (sz `div` 8) + 1]
-                mek = throwCryptoError (cipherInit key)
-             in (mak, mek)
+        KeySizeFixed sz
+            | sz `mod` 8 == 0 ->
+                let mak = buildKey [0 .. 1]
+                    key = buildKey [2 .. fromIntegral (sz `div` 8) + 1]
+                    mek = throwCryptoError (cipherInit key)
+                 in (mak, mek)
         _ -> error "AESGCMSIV: invalid cipher"
   where
-    idx n = ecbEncrypt aes (le32iv n iv) `takeView` 8
+    idx n = ecbEncrypt aes (le32iv n iv) `B.takeView` 8
     buildKey = B.concat . map idx
 
-
 -- Encryption and decryption
 
 lengthInvalid :: ByteArrayAccess ba => ba -> Bool
 lengthInvalid bs
     | finiteBitSize len > 32 = len >= 1 `unsafeShiftL` 32
-    | otherwise              = False
-  where len = B.length bs
+    | otherwise = False
+  where
+    len = B.length bs
 
 -- | AEAD encryption with the specified key and nonce.  The key must be given
 -- as an initialized 'Crypto.Cipher.AES.AES128' or 'Crypto.Cipher.AES.AES256'
@@ -125,8 +127,9 @@
 --
 -- Lengths of additional data and plaintext must be less than 2^32 bytes,
 -- otherwise an exception is thrown.
-encrypt :: (BlockCipher128 aes, ByteArrayAccess aad, ByteArray ba)
-        => aes -> Nonce -> aad -> ba -> (AuthTag, ba)
+encrypt
+    :: (BlockCipher128 aes, ByteArrayAccess aad, ByteArray ba)
+    => aes -> Nonce -> aad -> ba -> (AuthTag, ba)
 encrypt aes iv aad plaintext
     | lengthInvalid aad = error "AESGCMSIV: aad is too large"
     | lengthInvalid plaintext = error "AESGCMSIV: plaintext is too large"
@@ -143,12 +146,13 @@
 --
 -- Lengths of additional data and ciphertext must be less than 2^32 bytes,
 -- otherwise an exception is thrown.
-decrypt :: (BlockCipher128 aes, ByteArrayAccess aad, ByteArray ba)
-        => aes -> Nonce -> aad -> ba -> AuthTag -> Maybe ba
+decrypt
+    :: (BlockCipher128 aes, ByteArrayAccess aad, ByteArray ba)
+    => aes -> Nonce -> aad -> ba -> AuthTag -> Maybe ba
 decrypt aes iv aad ciphertext (AuthTag tag)
     | lengthInvalid aad = error "AESGCMSIV: aad is too large"
     | lengthInvalid ciphertext = error "AESGCMSIV: ciphertext is too large"
-    | tag `constEq` buildTag mek ss iv = Just plaintext
+    | tag `B.constEq` buildTag mek ss iv = Just plaintext
     | otherwise = Nothing
   where
     (mak, mek) = deriveKeys aes iv
@@ -156,18 +160,19 @@
     plaintext = combineC32 mek (transformTag tag) ciphertext
 
 -- Calculate S_s = POLYVAL(mak, X_1, X_2, ...).
-getSs :: (ByteArrayAccess aad, ByteArrayAccess ba)
-      => ScrubbedBytes -> aad -> ba -> ScrubbedBytes
+getSs
+    :: (ByteArrayAccess aad, ByteArrayAccess ba)
+    => ScrubbedBytes -> aad -> ba -> ScrubbedBytes
 getSs mak aad plaintext = unsafeDoIO $ do
     ctx <- polyvalInit mak
     polyvalUpdate ctx aad
     polyvalUpdate ctx plaintext
-    polyvalUpdate ctx (lb :: Bytes)  -- the "length block"
+    polyvalUpdate ctx (lb :: Bytes) -- the "length block"
     polyvalFinalize ctx
   where
     lb = B.allocAndFreeze 16 $ \ptr -> do
-            pokeElemOff ptr 0 (toLE64 $ B.length aad)
-            pokeElemOff ptr 1 (toLE64 $ B.length plaintext)
+        pokeElemOff ptr 0 (toLE64 $ B.length aad)
+        pokeElemOff ptr 1 (toLE64 $ B.length plaintext)
     toLE64 x = toLE (fromIntegral x * 8 :: Word64)
 
 -- XOR the first 12 bytes of S_s with the nonce and clear the most significant
@@ -175,10 +180,10 @@
 tagInput :: ScrubbedBytes -> Nonce -> Bytes
 tagInput ss (Nonce iv) =
     B.copyAndFreeze ss $ \ptr ->
-    B.withByteArray iv $ \ivPtr -> do
-        memXor ptr ptr ivPtr 12
-        b <- peekElemOff ptr 15
-        pokeElemOff ptr 15 (b .&. (0x7f :: Word8))
+        B.withByteArray iv $ \ivPtr -> do
+            memXor ptr ptr ivPtr 12
+            b <- peekElemOff ptr 15
+            pokeElemOff ptr 15 (b .&. (0x7f :: Word8))
 
 -- Encrypt the result with AES using the message-encryption key to produce the
 -- tag.
@@ -190,4 +195,5 @@
 transformTag :: Bytes -> IV AES
 transformTag tag = toIV $ B.copyAndFreeze tag $ \ptr ->
     peekElemOff ptr 15 >>= pokeElemOff ptr 15 . (.|. (0x80 :: Word8))
-  where toIV bs = let Just iv = makeIV (bs :: Bytes) in iv
+  where
+    toIV bs = fromJust $ makeIV (bs :: Bytes)
diff --git a/Crypto/Cipher/Blowfish.hs b/Crypto/Cipher/Blowfish.hs
--- a/Crypto/Cipher/Blowfish.hs
+++ b/Crypto/Cipher/Blowfish.hs
@@ -1,23 +1,23 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.Cipher.Blowfish
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : stable
 -- Portability : good
---
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.Cipher.Blowfish
-    ( Blowfish
-    , Blowfish64
-    , Blowfish128
-    , Blowfish256
-    , Blowfish448
-    ) where
+module Crypto.Cipher.Blowfish (
+    Blowfish,
+    Blowfish64,
+    Blowfish128,
+    Blowfish256,
+    Blowfish448,
+) where
 
-import Crypto.Internal.Imports
-import Crypto.Cipher.Types
 import Crypto.Cipher.Blowfish.Primitive
+import Crypto.Cipher.Types
+import Crypto.Internal.Imports
 
 -- | variable keyed blowfish state
 newtype Blowfish = Blowfish Context
@@ -40,9 +40,9 @@
     deriving (NFData)
 
 instance Cipher Blowfish where
-    cipherName _    = "blowfish"
+    cipherName _ = "blowfish"
     cipherKeySize _ = KeySizeRange 6 56
-    cipherInit k    = Blowfish `fmap` initBlowfish k
+    cipherInit k = Blowfish `fmap` initBlowfish k
 
 instance BlockCipher Blowfish where
     blockSize _ = 8
diff --git a/Crypto/Cipher/Blowfish/Box.hs b/Crypto/Cipher/Blowfish/Box.hs
--- a/Crypto/Cipher/Blowfish/Box.hs
+++ b/Crypto/Cipher/Blowfish/Box.hs
@@ -1,19 +1,22 @@
+{-# LANGUAGE MagicHash #-}
+
 -- |
 -- Module      : Crypto.Cipher.Blowfish.Box
 -- License     : BSD-style
 -- Stability   : experimental
 -- Portability : Good
-{-# LANGUAGE MagicHash #-}
-module Crypto.Cipher.Blowfish.Box
-    (   KeySchedule(..)
-    ,   createKeySchedule
-    ,   copyKeySchedule
-    ) where
+module Crypto.Cipher.Blowfish.Box (
+    KeySchedule (..),
+    createKeySchedule,
+    copyKeySchedule,
+) where
 
-import           Crypto.Internal.WordArray (MutableArray32,
-                                            mutableArray32FromAddrBE,
-                                            mutableArrayRead32,
-                                            mutableArrayWrite32)
+import Crypto.Internal.WordArray (
+    MutableArray32,
+    mutableArray32FromAddrBE,
+    mutableArrayRead32,
+    mutableArrayWrite32,
+ )
 
 newtype KeySchedule = KeySchedule MutableArray32
 
@@ -23,274 +26,278 @@
 copyKeySchedule (KeySchedule dst) (KeySchedule src) = loop 0
   where
     loop 1042 = return ()
-    loop i    = do
-        w32 <-mutableArrayRead32 src i
+    loop i = do
+        w32 <- mutableArrayRead32 src i
         mutableArrayWrite32 dst i w32
         loop (i + 1)
 
 -- | Create a key schedule mutable array of the pbox followed by
 -- all the sboxes.
 createKeySchedule :: IO KeySchedule
-createKeySchedule = KeySchedule `fmap` mutableArray32FromAddrBE 1042 "\
-    \\x24\x3f\x6a\x88\x85\xa3\x08\xd3\x13\x19\x8a\x2e\x03\x70\x73\x44\
-    \\xa4\x09\x38\x22\x29\x9f\x31\xd0\x08\x2e\xfa\x98\xec\x4e\x6c\x89\
-    \\x45\x28\x21\xe6\x38\xd0\x13\x77\xbe\x54\x66\xcf\x34\xe9\x0c\x6c\
-    \\xc0\xac\x29\xb7\xc9\x7c\x50\xdd\x3f\x84\xd5\xb5\xb5\x47\x09\x17\
-    \\x92\x16\xd5\xd9\x89\x79\xfb\x1b\
-    \\xd1\x31\x0b\xa6\x98\xdf\xb5\xac\x2f\xfd\x72\xdb\xd0\x1a\xdf\xb7\
-    \\xb8\xe1\xaf\xed\x6a\x26\x7e\x96\xba\x7c\x90\x45\xf1\x2c\x7f\x99\
-    \\x24\xa1\x99\x47\xb3\x91\x6c\xf7\x08\x01\xf2\xe2\x85\x8e\xfc\x16\
-    \\x63\x69\x20\xd8\x71\x57\x4e\x69\xa4\x58\xfe\xa3\xf4\x93\x3d\x7e\
-    \\x0d\x95\x74\x8f\x72\x8e\xb6\x58\x71\x8b\xcd\x58\x82\x15\x4a\xee\
-    \\x7b\x54\xa4\x1d\xc2\x5a\x59\xb5\x9c\x30\xd5\x39\x2a\xf2\x60\x13\
-    \\xc5\xd1\xb0\x23\x28\x60\x85\xf0\xca\x41\x79\x18\xb8\xdb\x38\xef\
-    \\x8e\x79\xdc\xb0\x60\x3a\x18\x0e\x6c\x9e\x0e\x8b\xb0\x1e\x8a\x3e\
-    \\xd7\x15\x77\xc1\xbd\x31\x4b\x27\x78\xaf\x2f\xda\x55\x60\x5c\x60\
-    \\xe6\x55\x25\xf3\xaa\x55\xab\x94\x57\x48\x98\x62\x63\xe8\x14\x40\
-    \\x55\xca\x39\x6a\x2a\xab\x10\xb6\xb4\xcc\x5c\x34\x11\x41\xe8\xce\
-    \\xa1\x54\x86\xaf\x7c\x72\xe9\x93\xb3\xee\x14\x11\x63\x6f\xbc\x2a\
-    \\x2b\xa9\xc5\x5d\x74\x18\x31\xf6\xce\x5c\x3e\x16\x9b\x87\x93\x1e\
-    \\xaf\xd6\xba\x33\x6c\x24\xcf\x5c\x7a\x32\x53\x81\x28\x95\x86\x77\
-    \\x3b\x8f\x48\x98\x6b\x4b\xb9\xaf\xc4\xbf\xe8\x1b\x66\x28\x21\x93\
-    \\x61\xd8\x09\xcc\xfb\x21\xa9\x91\x48\x7c\xac\x60\x5d\xec\x80\x32\
-    \\xef\x84\x5d\x5d\xe9\x85\x75\xb1\xdc\x26\x23\x02\xeb\x65\x1b\x88\
-    \\x23\x89\x3e\x81\xd3\x96\xac\xc5\x0f\x6d\x6f\xf3\x83\xf4\x42\x39\
-    \\x2e\x0b\x44\x82\xa4\x84\x20\x04\x69\xc8\xf0\x4a\x9e\x1f\x9b\x5e\
-    \\x21\xc6\x68\x42\xf6\xe9\x6c\x9a\x67\x0c\x9c\x61\xab\xd3\x88\xf0\
-    \\x6a\x51\xa0\xd2\xd8\x54\x2f\x68\x96\x0f\xa7\x28\xab\x51\x33\xa3\
-    \\x6e\xef\x0b\x6c\x13\x7a\x3b\xe4\xba\x3b\xf0\x50\x7e\xfb\x2a\x98\
-    \\xa1\xf1\x65\x1d\x39\xaf\x01\x76\x66\xca\x59\x3e\x82\x43\x0e\x88\
-    \\x8c\xee\x86\x19\x45\x6f\x9f\xb4\x7d\x84\xa5\xc3\x3b\x8b\x5e\xbe\
-    \\xe0\x6f\x75\xd8\x85\xc1\x20\x73\x40\x1a\x44\x9f\x56\xc1\x6a\xa6\
-    \\x4e\xd3\xaa\x62\x36\x3f\x77\x06\x1b\xfe\xdf\x72\x42\x9b\x02\x3d\
-    \\x37\xd0\xd7\x24\xd0\x0a\x12\x48\xdb\x0f\xea\xd3\x49\xf1\xc0\x9b\
-    \\x07\x53\x72\xc9\x80\x99\x1b\x7b\x25\xd4\x79\xd8\xf6\xe8\xde\xf7\
-    \\xe3\xfe\x50\x1a\xb6\x79\x4c\x3b\x97\x6c\xe0\xbd\x04\xc0\x06\xba\
-    \\xc1\xa9\x4f\xb6\x40\x9f\x60\xc4\x5e\x5c\x9e\xc2\x19\x6a\x24\x63\
-    \\x68\xfb\x6f\xaf\x3e\x6c\x53\xb5\x13\x39\xb2\xeb\x3b\x52\xec\x6f\
-    \\x6d\xfc\x51\x1f\x9b\x30\x95\x2c\xcc\x81\x45\x44\xaf\x5e\xbd\x09\
-    \\xbe\xe3\xd0\x04\xde\x33\x4a\xfd\x66\x0f\x28\x07\x19\x2e\x4b\xb3\
-    \\xc0\xcb\xa8\x57\x45\xc8\x74\x0f\xd2\x0b\x5f\x39\xb9\xd3\xfb\xdb\
-    \\x55\x79\xc0\xbd\x1a\x60\x32\x0a\xd6\xa1\x00\xc6\x40\x2c\x72\x79\
-    \\x67\x9f\x25\xfe\xfb\x1f\xa3\xcc\x8e\xa5\xe9\xf8\xdb\x32\x22\xf8\
-    \\x3c\x75\x16\xdf\xfd\x61\x6b\x15\x2f\x50\x1e\xc8\xad\x05\x52\xab\
-    \\x32\x3d\xb5\xfa\xfd\x23\x87\x60\x53\x31\x7b\x48\x3e\x00\xdf\x82\
-    \\x9e\x5c\x57\xbb\xca\x6f\x8c\xa0\x1a\x87\x56\x2e\xdf\x17\x69\xdb\
-    \\xd5\x42\xa8\xf6\x28\x7e\xff\xc3\xac\x67\x32\xc6\x8c\x4f\x55\x73\
-    \\x69\x5b\x27\xb0\xbb\xca\x58\xc8\xe1\xff\xa3\x5d\xb8\xf0\x11\xa0\
-    \\x10\xfa\x3d\x98\xfd\x21\x83\xb8\x4a\xfc\xb5\x6c\x2d\xd1\xd3\x5b\
-    \\x9a\x53\xe4\x79\xb6\xf8\x45\x65\xd2\x8e\x49\xbc\x4b\xfb\x97\x90\
-    \\xe1\xdd\xf2\xda\xa4\xcb\x7e\x33\x62\xfb\x13\x41\xce\xe4\xc6\xe8\
-    \\xef\x20\xca\xda\x36\x77\x4c\x01\xd0\x7e\x9e\xfe\x2b\xf1\x1f\xb4\
-    \\x95\xdb\xda\x4d\xae\x90\x91\x98\xea\xad\x8e\x71\x6b\x93\xd5\xa0\
-    \\xd0\x8e\xd1\xd0\xaf\xc7\x25\xe0\x8e\x3c\x5b\x2f\x8e\x75\x94\xb7\
-    \\x8f\xf6\xe2\xfb\xf2\x12\x2b\x64\x88\x88\xb8\x12\x90\x0d\xf0\x1c\
-    \\x4f\xad\x5e\xa0\x68\x8f\xc3\x1c\xd1\xcf\xf1\x91\xb3\xa8\xc1\xad\
-    \\x2f\x2f\x22\x18\xbe\x0e\x17\x77\xea\x75\x2d\xfe\x8b\x02\x1f\xa1\
-    \\xe5\xa0\xcc\x0f\xb5\x6f\x74\xe8\x18\xac\xf3\xd6\xce\x89\xe2\x99\
-    \\xb4\xa8\x4f\xe0\xfd\x13\xe0\xb7\x7c\xc4\x3b\x81\xd2\xad\xa8\xd9\
-    \\x16\x5f\xa2\x66\x80\x95\x77\x05\x93\xcc\x73\x14\x21\x1a\x14\x77\
-    \\xe6\xad\x20\x65\x77\xb5\xfa\x86\xc7\x54\x42\xf5\xfb\x9d\x35\xcf\
-    \\xeb\xcd\xaf\x0c\x7b\x3e\x89\xa0\xd6\x41\x1b\xd3\xae\x1e\x7e\x49\
-    \\x00\x25\x0e\x2d\x20\x71\xb3\x5e\x22\x68\x00\xbb\x57\xb8\xe0\xaf\
-    \\x24\x64\x36\x9b\xf0\x09\xb9\x1e\x55\x63\x91\x1d\x59\xdf\xa6\xaa\
-    \\x78\xc1\x43\x89\xd9\x5a\x53\x7f\x20\x7d\x5b\xa2\x02\xe5\xb9\xc5\
-    \\x83\x26\x03\x76\x62\x95\xcf\xa9\x11\xc8\x19\x68\x4e\x73\x4a\x41\
-    \\xb3\x47\x2d\xca\x7b\x14\xa9\x4a\x1b\x51\x00\x52\x9a\x53\x29\x15\
-    \\xd6\x0f\x57\x3f\xbc\x9b\xc6\xe4\x2b\x60\xa4\x76\x81\xe6\x74\x00\
-    \\x08\xba\x6f\xb5\x57\x1b\xe9\x1f\xf2\x96\xec\x6b\x2a\x0d\xd9\x15\
-    \\xb6\x63\x65\x21\xe7\xb9\xf9\xb6\xff\x34\x05\x2e\xc5\x85\x56\x64\
-    \\x53\xb0\x2d\x5d\xa9\x9f\x8f\xa1\x08\xba\x47\x99\x6e\x85\x07\x6a\
-    \\x4b\x7a\x70\xe9\xb5\xb3\x29\x44\xdb\x75\x09\x2e\xc4\x19\x26\x23\
-    \\xad\x6e\xa6\xb0\x49\xa7\xdf\x7d\x9c\xee\x60\xb8\x8f\xed\xb2\x66\
-    \\xec\xaa\x8c\x71\x69\x9a\x17\xff\x56\x64\x52\x6c\xc2\xb1\x9e\xe1\
-    \\x19\x36\x02\xa5\x75\x09\x4c\x29\xa0\x59\x13\x40\xe4\x18\x3a\x3e\
-    \\x3f\x54\x98\x9a\x5b\x42\x9d\x65\x6b\x8f\xe4\xd6\x99\xf7\x3f\xd6\
-    \\xa1\xd2\x9c\x07\xef\xe8\x30\xf5\x4d\x2d\x38\xe6\xf0\x25\x5d\xc1\
-    \\x4c\xdd\x20\x86\x84\x70\xeb\x26\x63\x82\xe9\xc6\x02\x1e\xcc\x5e\
-    \\x09\x68\x6b\x3f\x3e\xba\xef\xc9\x3c\x97\x18\x14\x6b\x6a\x70\xa1\
-    \\x68\x7f\x35\x84\x52\xa0\xe2\x86\xb7\x9c\x53\x05\xaa\x50\x07\x37\
-    \\x3e\x07\x84\x1c\x7f\xde\xae\x5c\x8e\x7d\x44\xec\x57\x16\xf2\xb8\
-    \\xb0\x3a\xda\x37\xf0\x50\x0c\x0d\xf0\x1c\x1f\x04\x02\x00\xb3\xff\
-    \\xae\x0c\xf5\x1a\x3c\xb5\x74\xb2\x25\x83\x7a\x58\xdc\x09\x21\xbd\
-    \\xd1\x91\x13\xf9\x7c\xa9\x2f\xf6\x94\x32\x47\x73\x22\xf5\x47\x01\
-    \\x3a\xe5\xe5\x81\x37\xc2\xda\xdc\xc8\xb5\x76\x34\x9a\xf3\xdd\xa7\
-    \\xa9\x44\x61\x46\x0f\xd0\x03\x0e\xec\xc8\xc7\x3e\xa4\x75\x1e\x41\
-    \\xe2\x38\xcd\x99\x3b\xea\x0e\x2f\x32\x80\xbb\xa1\x18\x3e\xb3\x31\
-    \\x4e\x54\x8b\x38\x4f\x6d\xb9\x08\x6f\x42\x0d\x03\xf6\x0a\x04\xbf\
-    \\x2c\xb8\x12\x90\x24\x97\x7c\x79\x56\x79\xb0\x72\xbc\xaf\x89\xaf\
-    \\xde\x9a\x77\x1f\xd9\x93\x08\x10\xb3\x8b\xae\x12\xdc\xcf\x3f\x2e\
-    \\x55\x12\x72\x1f\x2e\x6b\x71\x24\x50\x1a\xdd\xe6\x9f\x84\xcd\x87\
-    \\x7a\x58\x47\x18\x74\x08\xda\x17\xbc\x9f\x9a\xbc\xe9\x4b\x7d\x8c\
-    \\xec\x7a\xec\x3a\xdb\x85\x1d\xfa\x63\x09\x43\x66\xc4\x64\xc3\xd2\
-    \\xef\x1c\x18\x47\x32\x15\xd9\x08\xdd\x43\x3b\x37\x24\xc2\xba\x16\
-    \\x12\xa1\x4d\x43\x2a\x65\xc4\x51\x50\x94\x00\x02\x13\x3a\xe4\xdd\
-    \\x71\xdf\xf8\x9e\x10\x31\x4e\x55\x81\xac\x77\xd6\x5f\x11\x19\x9b\
-    \\x04\x35\x56\xf1\xd7\xa3\xc7\x6b\x3c\x11\x18\x3b\x59\x24\xa5\x09\
-    \\xf2\x8f\xe6\xed\x97\xf1\xfb\xfa\x9e\xba\xbf\x2c\x1e\x15\x3c\x6e\
-    \\x86\xe3\x45\x70\xea\xe9\x6f\xb1\x86\x0e\x5e\x0a\x5a\x3e\x2a\xb3\
-    \\x77\x1f\xe7\x1c\x4e\x3d\x06\xfa\x29\x65\xdc\xb9\x99\xe7\x1d\x0f\
-    \\x80\x3e\x89\xd6\x52\x66\xc8\x25\x2e\x4c\xc9\x78\x9c\x10\xb3\x6a\
-    \\xc6\x15\x0e\xba\x94\xe2\xea\x78\xa5\xfc\x3c\x53\x1e\x0a\x2d\xf4\
-    \\xf2\xf7\x4e\xa7\x36\x1d\x2b\x3d\x19\x39\x26\x0f\x19\xc2\x79\x60\
-    \\x52\x23\xa7\x08\xf7\x13\x12\xb6\xeb\xad\xfe\x6e\xea\xc3\x1f\x66\
-    \\xe3\xbc\x45\x95\xa6\x7b\xc8\x83\xb1\x7f\x37\xd1\x01\x8c\xff\x28\
-    \\xc3\x32\xdd\xef\xbe\x6c\x5a\xa5\x65\x58\x21\x85\x68\xab\x98\x02\
-    \\xee\xce\xa5\x0f\xdb\x2f\x95\x3b\x2a\xef\x7d\xad\x5b\x6e\x2f\x84\
-    \\x15\x21\xb6\x28\x29\x07\x61\x70\xec\xdd\x47\x75\x61\x9f\x15\x10\
-    \\x13\xcc\xa8\x30\xeb\x61\xbd\x96\x03\x34\xfe\x1e\xaa\x03\x63\xcf\
-    \\xb5\x73\x5c\x90\x4c\x70\xa2\x39\xd5\x9e\x9e\x0b\xcb\xaa\xde\x14\
-    \\xee\xcc\x86\xbc\x60\x62\x2c\xa7\x9c\xab\x5c\xab\xb2\xf3\x84\x6e\
-    \\x64\x8b\x1e\xaf\x19\xbd\xf0\xca\xa0\x23\x69\xb9\x65\x5a\xbb\x50\
-    \\x40\x68\x5a\x32\x3c\x2a\xb4\xb3\x31\x9e\xe9\xd5\xc0\x21\xb8\xf7\
-    \\x9b\x54\x0b\x19\x87\x5f\xa0\x99\x95\xf7\x99\x7e\x62\x3d\x7d\xa8\
-    \\xf8\x37\x88\x9a\x97\xe3\x2d\x77\x11\xed\x93\x5f\x16\x68\x12\x81\
-    \\x0e\x35\x88\x29\xc7\xe6\x1f\xd6\x96\xde\xdf\xa1\x78\x58\xba\x99\
-    \\x57\xf5\x84\xa5\x1b\x22\x72\x63\x9b\x83\xc3\xff\x1a\xc2\x46\x96\
-    \\xcd\xb3\x0a\xeb\x53\x2e\x30\x54\x8f\xd9\x48\xe4\x6d\xbc\x31\x28\
-    \\x58\xeb\xf2\xef\x34\xc6\xff\xea\xfe\x28\xed\x61\xee\x7c\x3c\x73\
-    \\x5d\x4a\x14\xd9\xe8\x64\xb7\xe3\x42\x10\x5d\x14\x20\x3e\x13\xe0\
-    \\x45\xee\xe2\xb6\xa3\xaa\xab\xea\xdb\x6c\x4f\x15\xfa\xcb\x4f\xd0\
-    \\xc7\x42\xf4\x42\xef\x6a\xbb\xb5\x65\x4f\x3b\x1d\x41\xcd\x21\x05\
-    \\xd8\x1e\x79\x9e\x86\x85\x4d\xc7\xe4\x4b\x47\x6a\x3d\x81\x62\x50\
-    \\xcf\x62\xa1\xf2\x5b\x8d\x26\x46\xfc\x88\x83\xa0\xc1\xc7\xb6\xa3\
-    \\x7f\x15\x24\xc3\x69\xcb\x74\x92\x47\x84\x8a\x0b\x56\x92\xb2\x85\
-    \\x09\x5b\xbf\x00\xad\x19\x48\x9d\x14\x62\xb1\x74\x23\x82\x0e\x00\
-    \\x58\x42\x8d\x2a\x0c\x55\xf5\xea\x1d\xad\xf4\x3e\x23\x3f\x70\x61\
-    \\x33\x72\xf0\x92\x8d\x93\x7e\x41\xd6\x5f\xec\xf1\x6c\x22\x3b\xdb\
-    \\x7c\xde\x37\x59\xcb\xee\x74\x60\x40\x85\xf2\xa7\xce\x77\x32\x6e\
-    \\xa6\x07\x80\x84\x19\xf8\x50\x9e\xe8\xef\xd8\x55\x61\xd9\x97\x35\
-    \\xa9\x69\xa7\xaa\xc5\x0c\x06\xc2\x5a\x04\xab\xfc\x80\x0b\xca\xdc\
-    \\x9e\x44\x7a\x2e\xc3\x45\x34\x84\xfd\xd5\x67\x05\x0e\x1e\x9e\xc9\
-    \\xdb\x73\xdb\xd3\x10\x55\x88\xcd\x67\x5f\xda\x79\xe3\x67\x43\x40\
-    \\xc5\xc4\x34\x65\x71\x3e\x38\xd8\x3d\x28\xf8\x9e\xf1\x6d\xff\x20\
-    \\x15\x3e\x21\xe7\x8f\xb0\x3d\x4a\xe6\xe3\x9f\x2b\xdb\x83\xad\xf7\
-    \\xe9\x3d\x5a\x68\x94\x81\x40\xf7\xf6\x4c\x26\x1c\x94\x69\x29\x34\
-    \\x41\x15\x20\xf7\x76\x02\xd4\xf7\xbc\xf4\x6b\x2e\xd4\xa2\x00\x68\
-    \\xd4\x08\x24\x71\x33\x20\xf4\x6a\x43\xb7\xd4\xb7\x50\x00\x61\xaf\
-    \\x1e\x39\xf6\x2e\x97\x24\x45\x46\x14\x21\x4f\x74\xbf\x8b\x88\x40\
-    \\x4d\x95\xfc\x1d\x96\xb5\x91\xaf\x70\xf4\xdd\xd3\x66\xa0\x2f\x45\
-    \\xbf\xbc\x09\xec\x03\xbd\x97\x85\x7f\xac\x6d\xd0\x31\xcb\x85\x04\
-    \\x96\xeb\x27\xb3\x55\xfd\x39\x41\xda\x25\x47\xe6\xab\xca\x0a\x9a\
-    \\x28\x50\x78\x25\x53\x04\x29\xf4\x0a\x2c\x86\xda\xe9\xb6\x6d\xfb\
-    \\x68\xdc\x14\x62\xd7\x48\x69\x00\x68\x0e\xc0\xa4\x27\xa1\x8d\xee\
-    \\x4f\x3f\xfe\xa2\xe8\x87\xad\x8c\xb5\x8c\xe0\x06\x7a\xf4\xd6\xb6\
-    \\xaa\xce\x1e\x7c\xd3\x37\x5f\xec\xce\x78\xa3\x99\x40\x6b\x2a\x42\
-    \\x20\xfe\x9e\x35\xd9\xf3\x85\xb9\xee\x39\xd7\xab\x3b\x12\x4e\x8b\
-    \\x1d\xc9\xfa\xf7\x4b\x6d\x18\x56\x26\xa3\x66\x31\xea\xe3\x97\xb2\
-    \\x3a\x6e\xfa\x74\xdd\x5b\x43\x32\x68\x41\xe7\xf7\xca\x78\x20\xfb\
-    \\xfb\x0a\xf5\x4e\xd8\xfe\xb3\x97\x45\x40\x56\xac\xba\x48\x95\x27\
-    \\x55\x53\x3a\x3a\x20\x83\x8d\x87\xfe\x6b\xa9\xb7\xd0\x96\x95\x4b\
-    \\x55\xa8\x67\xbc\xa1\x15\x9a\x58\xcc\xa9\x29\x63\x99\xe1\xdb\x33\
-    \\xa6\x2a\x4a\x56\x3f\x31\x25\xf9\x5e\xf4\x7e\x1c\x90\x29\x31\x7c\
-    \\xfd\xf8\xe8\x02\x04\x27\x2f\x70\x80\xbb\x15\x5c\x05\x28\x2c\xe3\
-    \\x95\xc1\x15\x48\xe4\xc6\x6d\x22\x48\xc1\x13\x3f\xc7\x0f\x86\xdc\
-    \\x07\xf9\xc9\xee\x41\x04\x1f\x0f\x40\x47\x79\xa4\x5d\x88\x6e\x17\
-    \\x32\x5f\x51\xeb\xd5\x9b\xc0\xd1\xf2\xbc\xc1\x8f\x41\x11\x35\x64\
-    \\x25\x7b\x78\x34\x60\x2a\x9c\x60\xdf\xf8\xe8\xa3\x1f\x63\x6c\x1b\
-    \\x0e\x12\xb4\xc2\x02\xe1\x32\x9e\xaf\x66\x4f\xd1\xca\xd1\x81\x15\
-    \\x6b\x23\x95\xe0\x33\x3e\x92\xe1\x3b\x24\x0b\x62\xee\xbe\xb9\x22\
-    \\x85\xb2\xa2\x0e\xe6\xba\x0d\x99\xde\x72\x0c\x8c\x2d\xa2\xf7\x28\
-    \\xd0\x12\x78\x45\x95\xb7\x94\xfd\x64\x7d\x08\x62\xe7\xcc\xf5\xf0\
-    \\x54\x49\xa3\x6f\x87\x7d\x48\xfa\xc3\x9d\xfd\x27\xf3\x3e\x8d\x1e\
-    \\x0a\x47\x63\x41\x99\x2e\xff\x74\x3a\x6f\x6e\xab\xf4\xf8\xfd\x37\
-    \\xa8\x12\xdc\x60\xa1\xeb\xdd\xf8\x99\x1b\xe1\x4c\xdb\x6e\x6b\x0d\
-    \\xc6\x7b\x55\x10\x6d\x67\x2c\x37\x27\x65\xd4\x3b\xdc\xd0\xe8\x04\
-    \\xf1\x29\x0d\xc7\xcc\x00\xff\xa3\xb5\x39\x0f\x92\x69\x0f\xed\x0b\
-    \\x66\x7b\x9f\xfb\xce\xdb\x7d\x9c\xa0\x91\xcf\x0b\xd9\x15\x5e\xa3\
-    \\xbb\x13\x2f\x88\x51\x5b\xad\x24\x7b\x94\x79\xbf\x76\x3b\xd6\xeb\
-    \\x37\x39\x2e\xb3\xcc\x11\x59\x79\x80\x26\xe2\x97\xf4\x2e\x31\x2d\
-    \\x68\x42\xad\xa7\xc6\x6a\x2b\x3b\x12\x75\x4c\xcc\x78\x2e\xf1\x1c\
-    \\x6a\x12\x42\x37\xb7\x92\x51\xe7\x06\xa1\xbb\xe6\x4b\xfb\x63\x50\
-    \\x1a\x6b\x10\x18\x11\xca\xed\xfa\x3d\x25\xbd\xd8\xe2\xe1\xc3\xc9\
-    \\x44\x42\x16\x59\x0a\x12\x13\x86\xd9\x0c\xec\x6e\xd5\xab\xea\x2a\
-    \\x64\xaf\x67\x4e\xda\x86\xa8\x5f\xbe\xbf\xe9\x88\x64\xe4\xc3\xfe\
-    \\x9d\xbc\x80\x57\xf0\xf7\xc0\x86\x60\x78\x7b\xf8\x60\x03\x60\x4d\
-    \\xd1\xfd\x83\x46\xf6\x38\x1f\xb0\x77\x45\xae\x04\xd7\x36\xfc\xcc\
-    \\x83\x42\x6b\x33\xf0\x1e\xab\x71\xb0\x80\x41\x87\x3c\x00\x5e\x5f\
-    \\x77\xa0\x57\xbe\xbd\xe8\xae\x24\x55\x46\x42\x99\xbf\x58\x2e\x61\
-    \\x4e\x58\xf4\x8f\xf2\xdd\xfd\xa2\xf4\x74\xef\x38\x87\x89\xbd\xc2\
-    \\x53\x66\xf9\xc3\xc8\xb3\x8e\x74\xb4\x75\xf2\x55\x46\xfc\xd9\xb9\
-    \\x7a\xeb\x26\x61\x8b\x1d\xdf\x84\x84\x6a\x0e\x79\x91\x5f\x95\xe2\
-    \\x46\x6e\x59\x8e\x20\xb4\x57\x70\x8c\xd5\x55\x91\xc9\x02\xde\x4c\
-    \\xb9\x0b\xac\xe1\xbb\x82\x05\xd0\x11\xa8\x62\x48\x75\x74\xa9\x9e\
-    \\xb7\x7f\x19\xb6\xe0\xa9\xdc\x09\x66\x2d\x09\xa1\xc4\x32\x46\x33\
-    \\xe8\x5a\x1f\x02\x09\xf0\xbe\x8c\x4a\x99\xa0\x25\x1d\x6e\xfe\x10\
-    \\x1a\xb9\x3d\x1d\x0b\xa5\xa4\xdf\xa1\x86\xf2\x0f\x28\x68\xf1\x69\
-    \\xdc\xb7\xda\x83\x57\x39\x06\xfe\xa1\xe2\xce\x9b\x4f\xcd\x7f\x52\
-    \\x50\x11\x5e\x01\xa7\x06\x83\xfa\xa0\x02\xb5\xc4\x0d\xe6\xd0\x27\
-    \\x9a\xf8\x8c\x27\x77\x3f\x86\x41\xc3\x60\x4c\x06\x61\xa8\x06\xb5\
-    \\xf0\x17\x7a\x28\xc0\xf5\x86\xe0\x00\x60\x58\xaa\x30\xdc\x7d\x62\
-    \\x11\xe6\x9e\xd7\x23\x38\xea\x63\x53\xc2\xdd\x94\xc2\xc2\x16\x34\
-    \\xbb\xcb\xee\x56\x90\xbc\xb6\xde\xeb\xfc\x7d\xa1\xce\x59\x1d\x76\
-    \\x6f\x05\xe4\x09\x4b\x7c\x01\x88\x39\x72\x0a\x3d\x7c\x92\x7c\x24\
-    \\x86\xe3\x72\x5f\x72\x4d\x9d\xb9\x1a\xc1\x5b\xb4\xd3\x9e\xb8\xfc\
-    \\xed\x54\x55\x78\x08\xfc\xa5\xb5\xd8\x3d\x7c\xd3\x4d\xad\x0f\xc4\
-    \\x1e\x50\xef\x5e\xb1\x61\xe6\xf8\xa2\x85\x14\xd9\x6c\x51\x13\x3c\
-    \\x6f\xd5\xc7\xe7\x56\xe1\x4e\xc4\x36\x2a\xbf\xce\xdd\xc6\xc8\x37\
-    \\xd7\x9a\x32\x34\x92\x63\x82\x12\x67\x0e\xfa\x8e\x40\x60\x00\xe0\
-    \\x3a\x39\xce\x37\xd3\xfa\xf5\xcf\xab\xc2\x77\x37\x5a\xc5\x2d\x1b\
-    \\x5c\xb0\x67\x9e\x4f\xa3\x37\x42\xd3\x82\x27\x40\x99\xbc\x9b\xbe\
-    \\xd5\x11\x8e\x9d\xbf\x0f\x73\x15\xd6\x2d\x1c\x7e\xc7\x00\xc4\x7b\
-    \\xb7\x8c\x1b\x6b\x21\xa1\x90\x45\xb2\x6e\xb1\xbe\x6a\x36\x6e\xb4\
-    \\x57\x48\xab\x2f\xbc\x94\x6e\x79\xc6\xa3\x76\xd2\x65\x49\xc2\xc8\
-    \\x53\x0f\xf8\xee\x46\x8d\xde\x7d\xd5\x73\x0a\x1d\x4c\xd0\x4d\xc6\
-    \\x29\x39\xbb\xdb\xa9\xba\x46\x50\xac\x95\x26\xe8\xbe\x5e\xe3\x04\
-    \\xa1\xfa\xd5\xf0\x6a\x2d\x51\x9a\x63\xef\x8c\xe2\x9a\x86\xee\x22\
-    \\xc0\x89\xc2\xb8\x43\x24\x2e\xf6\xa5\x1e\x03\xaa\x9c\xf2\xd0\xa4\
-    \\x83\xc0\x61\xba\x9b\xe9\x6a\x4d\x8f\xe5\x15\x50\xba\x64\x5b\xd6\
-    \\x28\x26\xa2\xf9\xa7\x3a\x3a\xe1\x4b\xa9\x95\x86\xef\x55\x62\xe9\
-    \\xc7\x2f\xef\xd3\xf7\x52\xf7\xda\x3f\x04\x6f\x69\x77\xfa\x0a\x59\
-    \\x80\xe4\xa9\x15\x87\xb0\x86\x01\x9b\x09\xe6\xad\x3b\x3e\xe5\x93\
-    \\xe9\x90\xfd\x5a\x9e\x34\xd7\x97\x2c\xf0\xb7\xd9\x02\x2b\x8b\x51\
-    \\x96\xd5\xac\x3a\x01\x7d\xa6\x7d\xd1\xcf\x3e\xd6\x7c\x7d\x2d\x28\
-    \\x1f\x9f\x25\xcf\xad\xf2\xb8\x9b\x5a\xd6\xb4\x72\x5a\x88\xf5\x4c\
-    \\xe0\x29\xac\x71\xe0\x19\xa5\xe6\x47\xb0\xac\xfd\xed\x93\xfa\x9b\
-    \\xe8\xd3\xc4\x8d\x28\x3b\x57\xcc\xf8\xd5\x66\x29\x79\x13\x2e\x28\
-    \\x78\x5f\x01\x91\xed\x75\x60\x55\xf7\x96\x0e\x44\xe3\xd3\x5e\x8c\
-    \\x15\x05\x6d\xd4\x88\xf4\x6d\xba\x03\xa1\x61\x25\x05\x64\xf0\xbd\
-    \\xc3\xeb\x9e\x15\x3c\x90\x57\xa2\x97\x27\x1a\xec\xa9\x3a\x07\x2a\
-    \\x1b\x3f\x6d\x9b\x1e\x63\x21\xf5\xf5\x9c\x66\xfb\x26\xdc\xf3\x19\
-    \\x75\x33\xd9\x28\xb1\x55\xfd\xf5\x03\x56\x34\x82\x8a\xba\x3c\xbb\
-    \\x28\x51\x77\x11\xc2\x0a\xd9\xf8\xab\xcc\x51\x67\xcc\xad\x92\x5f\
-    \\x4d\xe8\x17\x51\x38\x30\xdc\x8e\x37\x9d\x58\x62\x93\x20\xf9\x91\
-    \\xea\x7a\x90\xc2\xfb\x3e\x7b\xce\x51\x21\xce\x64\x77\x4f\xbe\x32\
-    \\xa8\xb6\xe3\x7e\xc3\x29\x3d\x46\x48\xde\x53\x69\x64\x13\xe6\x80\
-    \\xa2\xae\x08\x10\xdd\x6d\xb2\x24\x69\x85\x2d\xfd\x09\x07\x21\x66\
-    \\xb3\x9a\x46\x0a\x64\x45\xc0\xdd\x58\x6c\xde\xcf\x1c\x20\xc8\xae\
-    \\x5b\xbe\xf7\xdd\x1b\x58\x8d\x40\xcc\xd2\x01\x7f\x6b\xb4\xe3\xbb\
-    \\xdd\xa2\x6a\x7e\x3a\x59\xff\x45\x3e\x35\x0a\x44\xbc\xb4\xcd\xd5\
-    \\x72\xea\xce\xa8\xfa\x64\x84\xbb\x8d\x66\x12\xae\xbf\x3c\x6f\x47\
-    \\xd2\x9b\xe4\x63\x54\x2f\x5d\x9e\xae\xc2\x77\x1b\xf6\x4e\x63\x70\
-    \\x74\x0e\x0d\x8d\xe7\x5b\x13\x57\xf8\x72\x16\x71\xaf\x53\x7d\x5d\
-    \\x40\x40\xcb\x08\x4e\xb4\xe2\xcc\x34\xd2\x46\x6a\x01\x15\xaf\x84\
-    \\xe1\xb0\x04\x28\x95\x98\x3a\x1d\x06\xb8\x9f\xb4\xce\x6e\xa0\x48\
-    \\x6f\x3f\x3b\x82\x35\x20\xab\x82\x01\x1a\x1d\x4b\x27\x72\x27\xf8\
-    \\x61\x15\x60\xb1\xe7\x93\x3f\xdc\xbb\x3a\x79\x2b\x34\x45\x25\xbd\
-    \\xa0\x88\x39\xe1\x51\xce\x79\x4b\x2f\x32\xc9\xb7\xa0\x1f\xba\xc9\
-    \\xe0\x1c\xc8\x7e\xbc\xc7\xd1\xf6\xcf\x01\x11\xc3\xa1\xe8\xaa\xc7\
-    \\x1a\x90\x87\x49\xd4\x4f\xbd\x9a\xd0\xda\xde\xcb\xd5\x0a\xda\x38\
-    \\x03\x39\xc3\x2a\xc6\x91\x36\x67\x8d\xf9\x31\x7c\xe0\xb1\x2b\x4f\
-    \\xf7\x9e\x59\xb7\x43\xf5\xbb\x3a\xf2\xd5\x19\xff\x27\xd9\x45\x9c\
-    \\xbf\x97\x22\x2c\x15\xe6\xfc\x2a\x0f\x91\xfc\x71\x9b\x94\x15\x25\
-    \\xfa\xe5\x93\x61\xce\xb6\x9c\xeb\xc2\xa8\x64\x59\x12\xba\xa8\xd1\
-    \\xb6\xc1\x07\x5e\xe3\x05\x6a\x0c\x10\xd2\x50\x65\xcb\x03\xa4\x42\
-    \\xe0\xec\x6e\x0e\x16\x98\xdb\x3b\x4c\x98\xa0\xbe\x32\x78\xe9\x64\
-    \\x9f\x1f\x95\x32\xe0\xd3\x92\xdf\xd3\xa0\x34\x2b\x89\x71\xf2\x1e\
-    \\x1b\x0a\x74\x41\x4b\xa3\x34\x8c\xc5\xbe\x71\x20\xc3\x76\x32\xd8\
-    \\xdf\x35\x9f\x8d\x9b\x99\x2f\x2e\xe6\x0b\x6f\x47\x0f\xe3\xf1\x1d\
-    \\xe5\x4c\xda\x54\x1e\xda\xd8\x91\xce\x62\x79\xcf\xcd\x3e\x7e\x6f\
-    \\x16\x18\xb1\x66\xfd\x2c\x1d\x05\x84\x8f\xd2\xc5\xf6\xfb\x22\x99\
-    \\xf5\x23\xf3\x57\xa6\x32\x76\x23\x93\xa8\x35\x31\x56\xcc\xcd\x02\
-    \\xac\xf0\x81\x62\x5a\x75\xeb\xb5\x6e\x16\x36\x97\x88\xd2\x73\xcc\
-    \\xde\x96\x62\x92\x81\xb9\x49\xd0\x4c\x50\x90\x1b\x71\xc6\x56\x14\
-    \\xe6\xc6\xc7\xbd\x32\x7a\x14\x0a\x45\xe1\xd0\x06\xc3\xf2\x7b\x9a\
-    \\xc9\xaa\x53\xfd\x62\xa8\x0f\x00\xbb\x25\xbf\xe2\x35\xbd\xd2\xf6\
-    \\x71\x12\x69\x05\xb2\x04\x02\x22\xb6\xcb\xcf\x7c\xcd\x76\x9c\x2b\
-    \\x53\x11\x3e\xc0\x16\x40\xe3\xd3\x38\xab\xbd\x60\x25\x47\xad\xf0\
-    \\xba\x38\x20\x9c\xf7\x46\xce\x76\x77\xaf\xa1\xc5\x20\x75\x60\x60\
-    \\x85\xcb\xfe\x4e\x8a\xe8\x8d\xd8\x7a\xaa\xf9\xb0\x4c\xf9\xaa\x7e\
-    \\x19\x48\xc2\x5c\x02\xfb\x8a\x8c\x01\xc3\x6a\xe4\xd6\xeb\xe1\xf9\
-    \\x90\xd4\xf8\x69\xa6\x5c\xde\xa0\x3f\x09\x25\x2d\xc2\x08\xe6\x9f\
-    \\xb7\x4e\x61\x32\xce\x77\xe2\x5b\x57\x8f\xdf\xe3\x3a\xc3\x72\xe6\
-    \"#
+createKeySchedule =
+    KeySchedule
+        `fmap` mutableArray32FromAddrBE
+            1042
+            "\
+            \\x24\x3f\x6a\x88\x85\xa3\x08\xd3\x13\x19\x8a\x2e\x03\x70\x73\x44\
+            \\xa4\x09\x38\x22\x29\x9f\x31\xd0\x08\x2e\xfa\x98\xec\x4e\x6c\x89\
+            \\x45\x28\x21\xe6\x38\xd0\x13\x77\xbe\x54\x66\xcf\x34\xe9\x0c\x6c\
+            \\xc0\xac\x29\xb7\xc9\x7c\x50\xdd\x3f\x84\xd5\xb5\xb5\x47\x09\x17\
+            \\x92\x16\xd5\xd9\x89\x79\xfb\x1b\
+            \\xd1\x31\x0b\xa6\x98\xdf\xb5\xac\x2f\xfd\x72\xdb\xd0\x1a\xdf\xb7\
+            \\xb8\xe1\xaf\xed\x6a\x26\x7e\x96\xba\x7c\x90\x45\xf1\x2c\x7f\x99\
+            \\x24\xa1\x99\x47\xb3\x91\x6c\xf7\x08\x01\xf2\xe2\x85\x8e\xfc\x16\
+            \\x63\x69\x20\xd8\x71\x57\x4e\x69\xa4\x58\xfe\xa3\xf4\x93\x3d\x7e\
+            \\x0d\x95\x74\x8f\x72\x8e\xb6\x58\x71\x8b\xcd\x58\x82\x15\x4a\xee\
+            \\x7b\x54\xa4\x1d\xc2\x5a\x59\xb5\x9c\x30\xd5\x39\x2a\xf2\x60\x13\
+            \\xc5\xd1\xb0\x23\x28\x60\x85\xf0\xca\x41\x79\x18\xb8\xdb\x38\xef\
+            \\x8e\x79\xdc\xb0\x60\x3a\x18\x0e\x6c\x9e\x0e\x8b\xb0\x1e\x8a\x3e\
+            \\xd7\x15\x77\xc1\xbd\x31\x4b\x27\x78\xaf\x2f\xda\x55\x60\x5c\x60\
+            \\xe6\x55\x25\xf3\xaa\x55\xab\x94\x57\x48\x98\x62\x63\xe8\x14\x40\
+            \\x55\xca\x39\x6a\x2a\xab\x10\xb6\xb4\xcc\x5c\x34\x11\x41\xe8\xce\
+            \\xa1\x54\x86\xaf\x7c\x72\xe9\x93\xb3\xee\x14\x11\x63\x6f\xbc\x2a\
+            \\x2b\xa9\xc5\x5d\x74\x18\x31\xf6\xce\x5c\x3e\x16\x9b\x87\x93\x1e\
+            \\xaf\xd6\xba\x33\x6c\x24\xcf\x5c\x7a\x32\x53\x81\x28\x95\x86\x77\
+            \\x3b\x8f\x48\x98\x6b\x4b\xb9\xaf\xc4\xbf\xe8\x1b\x66\x28\x21\x93\
+            \\x61\xd8\x09\xcc\xfb\x21\xa9\x91\x48\x7c\xac\x60\x5d\xec\x80\x32\
+            \\xef\x84\x5d\x5d\xe9\x85\x75\xb1\xdc\x26\x23\x02\xeb\x65\x1b\x88\
+            \\x23\x89\x3e\x81\xd3\x96\xac\xc5\x0f\x6d\x6f\xf3\x83\xf4\x42\x39\
+            \\x2e\x0b\x44\x82\xa4\x84\x20\x04\x69\xc8\xf0\x4a\x9e\x1f\x9b\x5e\
+            \\x21\xc6\x68\x42\xf6\xe9\x6c\x9a\x67\x0c\x9c\x61\xab\xd3\x88\xf0\
+            \\x6a\x51\xa0\xd2\xd8\x54\x2f\x68\x96\x0f\xa7\x28\xab\x51\x33\xa3\
+            \\x6e\xef\x0b\x6c\x13\x7a\x3b\xe4\xba\x3b\xf0\x50\x7e\xfb\x2a\x98\
+            \\xa1\xf1\x65\x1d\x39\xaf\x01\x76\x66\xca\x59\x3e\x82\x43\x0e\x88\
+            \\x8c\xee\x86\x19\x45\x6f\x9f\xb4\x7d\x84\xa5\xc3\x3b\x8b\x5e\xbe\
+            \\xe0\x6f\x75\xd8\x85\xc1\x20\x73\x40\x1a\x44\x9f\x56\xc1\x6a\xa6\
+            \\x4e\xd3\xaa\x62\x36\x3f\x77\x06\x1b\xfe\xdf\x72\x42\x9b\x02\x3d\
+            \\x37\xd0\xd7\x24\xd0\x0a\x12\x48\xdb\x0f\xea\xd3\x49\xf1\xc0\x9b\
+            \\x07\x53\x72\xc9\x80\x99\x1b\x7b\x25\xd4\x79\xd8\xf6\xe8\xde\xf7\
+            \\xe3\xfe\x50\x1a\xb6\x79\x4c\x3b\x97\x6c\xe0\xbd\x04\xc0\x06\xba\
+            \\xc1\xa9\x4f\xb6\x40\x9f\x60\xc4\x5e\x5c\x9e\xc2\x19\x6a\x24\x63\
+            \\x68\xfb\x6f\xaf\x3e\x6c\x53\xb5\x13\x39\xb2\xeb\x3b\x52\xec\x6f\
+            \\x6d\xfc\x51\x1f\x9b\x30\x95\x2c\xcc\x81\x45\x44\xaf\x5e\xbd\x09\
+            \\xbe\xe3\xd0\x04\xde\x33\x4a\xfd\x66\x0f\x28\x07\x19\x2e\x4b\xb3\
+            \\xc0\xcb\xa8\x57\x45\xc8\x74\x0f\xd2\x0b\x5f\x39\xb9\xd3\xfb\xdb\
+            \\x55\x79\xc0\xbd\x1a\x60\x32\x0a\xd6\xa1\x00\xc6\x40\x2c\x72\x79\
+            \\x67\x9f\x25\xfe\xfb\x1f\xa3\xcc\x8e\xa5\xe9\xf8\xdb\x32\x22\xf8\
+            \\x3c\x75\x16\xdf\xfd\x61\x6b\x15\x2f\x50\x1e\xc8\xad\x05\x52\xab\
+            \\x32\x3d\xb5\xfa\xfd\x23\x87\x60\x53\x31\x7b\x48\x3e\x00\xdf\x82\
+            \\x9e\x5c\x57\xbb\xca\x6f\x8c\xa0\x1a\x87\x56\x2e\xdf\x17\x69\xdb\
+            \\xd5\x42\xa8\xf6\x28\x7e\xff\xc3\xac\x67\x32\xc6\x8c\x4f\x55\x73\
+            \\x69\x5b\x27\xb0\xbb\xca\x58\xc8\xe1\xff\xa3\x5d\xb8\xf0\x11\xa0\
+            \\x10\xfa\x3d\x98\xfd\x21\x83\xb8\x4a\xfc\xb5\x6c\x2d\xd1\xd3\x5b\
+            \\x9a\x53\xe4\x79\xb6\xf8\x45\x65\xd2\x8e\x49\xbc\x4b\xfb\x97\x90\
+            \\xe1\xdd\xf2\xda\xa4\xcb\x7e\x33\x62\xfb\x13\x41\xce\xe4\xc6\xe8\
+            \\xef\x20\xca\xda\x36\x77\x4c\x01\xd0\x7e\x9e\xfe\x2b\xf1\x1f\xb4\
+            \\x95\xdb\xda\x4d\xae\x90\x91\x98\xea\xad\x8e\x71\x6b\x93\xd5\xa0\
+            \\xd0\x8e\xd1\xd0\xaf\xc7\x25\xe0\x8e\x3c\x5b\x2f\x8e\x75\x94\xb7\
+            \\x8f\xf6\xe2\xfb\xf2\x12\x2b\x64\x88\x88\xb8\x12\x90\x0d\xf0\x1c\
+            \\x4f\xad\x5e\xa0\x68\x8f\xc3\x1c\xd1\xcf\xf1\x91\xb3\xa8\xc1\xad\
+            \\x2f\x2f\x22\x18\xbe\x0e\x17\x77\xea\x75\x2d\xfe\x8b\x02\x1f\xa1\
+            \\xe5\xa0\xcc\x0f\xb5\x6f\x74\xe8\x18\xac\xf3\xd6\xce\x89\xe2\x99\
+            \\xb4\xa8\x4f\xe0\xfd\x13\xe0\xb7\x7c\xc4\x3b\x81\xd2\xad\xa8\xd9\
+            \\x16\x5f\xa2\x66\x80\x95\x77\x05\x93\xcc\x73\x14\x21\x1a\x14\x77\
+            \\xe6\xad\x20\x65\x77\xb5\xfa\x86\xc7\x54\x42\xf5\xfb\x9d\x35\xcf\
+            \\xeb\xcd\xaf\x0c\x7b\x3e\x89\xa0\xd6\x41\x1b\xd3\xae\x1e\x7e\x49\
+            \\x00\x25\x0e\x2d\x20\x71\xb3\x5e\x22\x68\x00\xbb\x57\xb8\xe0\xaf\
+            \\x24\x64\x36\x9b\xf0\x09\xb9\x1e\x55\x63\x91\x1d\x59\xdf\xa6\xaa\
+            \\x78\xc1\x43\x89\xd9\x5a\x53\x7f\x20\x7d\x5b\xa2\x02\xe5\xb9\xc5\
+            \\x83\x26\x03\x76\x62\x95\xcf\xa9\x11\xc8\x19\x68\x4e\x73\x4a\x41\
+            \\xb3\x47\x2d\xca\x7b\x14\xa9\x4a\x1b\x51\x00\x52\x9a\x53\x29\x15\
+            \\xd6\x0f\x57\x3f\xbc\x9b\xc6\xe4\x2b\x60\xa4\x76\x81\xe6\x74\x00\
+            \\x08\xba\x6f\xb5\x57\x1b\xe9\x1f\xf2\x96\xec\x6b\x2a\x0d\xd9\x15\
+            \\xb6\x63\x65\x21\xe7\xb9\xf9\xb6\xff\x34\x05\x2e\xc5\x85\x56\x64\
+            \\x53\xb0\x2d\x5d\xa9\x9f\x8f\xa1\x08\xba\x47\x99\x6e\x85\x07\x6a\
+            \\x4b\x7a\x70\xe9\xb5\xb3\x29\x44\xdb\x75\x09\x2e\xc4\x19\x26\x23\
+            \\xad\x6e\xa6\xb0\x49\xa7\xdf\x7d\x9c\xee\x60\xb8\x8f\xed\xb2\x66\
+            \\xec\xaa\x8c\x71\x69\x9a\x17\xff\x56\x64\x52\x6c\xc2\xb1\x9e\xe1\
+            \\x19\x36\x02\xa5\x75\x09\x4c\x29\xa0\x59\x13\x40\xe4\x18\x3a\x3e\
+            \\x3f\x54\x98\x9a\x5b\x42\x9d\x65\x6b\x8f\xe4\xd6\x99\xf7\x3f\xd6\
+            \\xa1\xd2\x9c\x07\xef\xe8\x30\xf5\x4d\x2d\x38\xe6\xf0\x25\x5d\xc1\
+            \\x4c\xdd\x20\x86\x84\x70\xeb\x26\x63\x82\xe9\xc6\x02\x1e\xcc\x5e\
+            \\x09\x68\x6b\x3f\x3e\xba\xef\xc9\x3c\x97\x18\x14\x6b\x6a\x70\xa1\
+            \\x68\x7f\x35\x84\x52\xa0\xe2\x86\xb7\x9c\x53\x05\xaa\x50\x07\x37\
+            \\x3e\x07\x84\x1c\x7f\xde\xae\x5c\x8e\x7d\x44\xec\x57\x16\xf2\xb8\
+            \\xb0\x3a\xda\x37\xf0\x50\x0c\x0d\xf0\x1c\x1f\x04\x02\x00\xb3\xff\
+            \\xae\x0c\xf5\x1a\x3c\xb5\x74\xb2\x25\x83\x7a\x58\xdc\x09\x21\xbd\
+            \\xd1\x91\x13\xf9\x7c\xa9\x2f\xf6\x94\x32\x47\x73\x22\xf5\x47\x01\
+            \\x3a\xe5\xe5\x81\x37\xc2\xda\xdc\xc8\xb5\x76\x34\x9a\xf3\xdd\xa7\
+            \\xa9\x44\x61\x46\x0f\xd0\x03\x0e\xec\xc8\xc7\x3e\xa4\x75\x1e\x41\
+            \\xe2\x38\xcd\x99\x3b\xea\x0e\x2f\x32\x80\xbb\xa1\x18\x3e\xb3\x31\
+            \\x4e\x54\x8b\x38\x4f\x6d\xb9\x08\x6f\x42\x0d\x03\xf6\x0a\x04\xbf\
+            \\x2c\xb8\x12\x90\x24\x97\x7c\x79\x56\x79\xb0\x72\xbc\xaf\x89\xaf\
+            \\xde\x9a\x77\x1f\xd9\x93\x08\x10\xb3\x8b\xae\x12\xdc\xcf\x3f\x2e\
+            \\x55\x12\x72\x1f\x2e\x6b\x71\x24\x50\x1a\xdd\xe6\x9f\x84\xcd\x87\
+            \\x7a\x58\x47\x18\x74\x08\xda\x17\xbc\x9f\x9a\xbc\xe9\x4b\x7d\x8c\
+            \\xec\x7a\xec\x3a\xdb\x85\x1d\xfa\x63\x09\x43\x66\xc4\x64\xc3\xd2\
+            \\xef\x1c\x18\x47\x32\x15\xd9\x08\xdd\x43\x3b\x37\x24\xc2\xba\x16\
+            \\x12\xa1\x4d\x43\x2a\x65\xc4\x51\x50\x94\x00\x02\x13\x3a\xe4\xdd\
+            \\x71\xdf\xf8\x9e\x10\x31\x4e\x55\x81\xac\x77\xd6\x5f\x11\x19\x9b\
+            \\x04\x35\x56\xf1\xd7\xa3\xc7\x6b\x3c\x11\x18\x3b\x59\x24\xa5\x09\
+            \\xf2\x8f\xe6\xed\x97\xf1\xfb\xfa\x9e\xba\xbf\x2c\x1e\x15\x3c\x6e\
+            \\x86\xe3\x45\x70\xea\xe9\x6f\xb1\x86\x0e\x5e\x0a\x5a\x3e\x2a\xb3\
+            \\x77\x1f\xe7\x1c\x4e\x3d\x06\xfa\x29\x65\xdc\xb9\x99\xe7\x1d\x0f\
+            \\x80\x3e\x89\xd6\x52\x66\xc8\x25\x2e\x4c\xc9\x78\x9c\x10\xb3\x6a\
+            \\xc6\x15\x0e\xba\x94\xe2\xea\x78\xa5\xfc\x3c\x53\x1e\x0a\x2d\xf4\
+            \\xf2\xf7\x4e\xa7\x36\x1d\x2b\x3d\x19\x39\x26\x0f\x19\xc2\x79\x60\
+            \\x52\x23\xa7\x08\xf7\x13\x12\xb6\xeb\xad\xfe\x6e\xea\xc3\x1f\x66\
+            \\xe3\xbc\x45\x95\xa6\x7b\xc8\x83\xb1\x7f\x37\xd1\x01\x8c\xff\x28\
+            \\xc3\x32\xdd\xef\xbe\x6c\x5a\xa5\x65\x58\x21\x85\x68\xab\x98\x02\
+            \\xee\xce\xa5\x0f\xdb\x2f\x95\x3b\x2a\xef\x7d\xad\x5b\x6e\x2f\x84\
+            \\x15\x21\xb6\x28\x29\x07\x61\x70\xec\xdd\x47\x75\x61\x9f\x15\x10\
+            \\x13\xcc\xa8\x30\xeb\x61\xbd\x96\x03\x34\xfe\x1e\xaa\x03\x63\xcf\
+            \\xb5\x73\x5c\x90\x4c\x70\xa2\x39\xd5\x9e\x9e\x0b\xcb\xaa\xde\x14\
+            \\xee\xcc\x86\xbc\x60\x62\x2c\xa7\x9c\xab\x5c\xab\xb2\xf3\x84\x6e\
+            \\x64\x8b\x1e\xaf\x19\xbd\xf0\xca\xa0\x23\x69\xb9\x65\x5a\xbb\x50\
+            \\x40\x68\x5a\x32\x3c\x2a\xb4\xb3\x31\x9e\xe9\xd5\xc0\x21\xb8\xf7\
+            \\x9b\x54\x0b\x19\x87\x5f\xa0\x99\x95\xf7\x99\x7e\x62\x3d\x7d\xa8\
+            \\xf8\x37\x88\x9a\x97\xe3\x2d\x77\x11\xed\x93\x5f\x16\x68\x12\x81\
+            \\x0e\x35\x88\x29\xc7\xe6\x1f\xd6\x96\xde\xdf\xa1\x78\x58\xba\x99\
+            \\x57\xf5\x84\xa5\x1b\x22\x72\x63\x9b\x83\xc3\xff\x1a\xc2\x46\x96\
+            \\xcd\xb3\x0a\xeb\x53\x2e\x30\x54\x8f\xd9\x48\xe4\x6d\xbc\x31\x28\
+            \\x58\xeb\xf2\xef\x34\xc6\xff\xea\xfe\x28\xed\x61\xee\x7c\x3c\x73\
+            \\x5d\x4a\x14\xd9\xe8\x64\xb7\xe3\x42\x10\x5d\x14\x20\x3e\x13\xe0\
+            \\x45\xee\xe2\xb6\xa3\xaa\xab\xea\xdb\x6c\x4f\x15\xfa\xcb\x4f\xd0\
+            \\xc7\x42\xf4\x42\xef\x6a\xbb\xb5\x65\x4f\x3b\x1d\x41\xcd\x21\x05\
+            \\xd8\x1e\x79\x9e\x86\x85\x4d\xc7\xe4\x4b\x47\x6a\x3d\x81\x62\x50\
+            \\xcf\x62\xa1\xf2\x5b\x8d\x26\x46\xfc\x88\x83\xa0\xc1\xc7\xb6\xa3\
+            \\x7f\x15\x24\xc3\x69\xcb\x74\x92\x47\x84\x8a\x0b\x56\x92\xb2\x85\
+            \\x09\x5b\xbf\x00\xad\x19\x48\x9d\x14\x62\xb1\x74\x23\x82\x0e\x00\
+            \\x58\x42\x8d\x2a\x0c\x55\xf5\xea\x1d\xad\xf4\x3e\x23\x3f\x70\x61\
+            \\x33\x72\xf0\x92\x8d\x93\x7e\x41\xd6\x5f\xec\xf1\x6c\x22\x3b\xdb\
+            \\x7c\xde\x37\x59\xcb\xee\x74\x60\x40\x85\xf2\xa7\xce\x77\x32\x6e\
+            \\xa6\x07\x80\x84\x19\xf8\x50\x9e\xe8\xef\xd8\x55\x61\xd9\x97\x35\
+            \\xa9\x69\xa7\xaa\xc5\x0c\x06\xc2\x5a\x04\xab\xfc\x80\x0b\xca\xdc\
+            \\x9e\x44\x7a\x2e\xc3\x45\x34\x84\xfd\xd5\x67\x05\x0e\x1e\x9e\xc9\
+            \\xdb\x73\xdb\xd3\x10\x55\x88\xcd\x67\x5f\xda\x79\xe3\x67\x43\x40\
+            \\xc5\xc4\x34\x65\x71\x3e\x38\xd8\x3d\x28\xf8\x9e\xf1\x6d\xff\x20\
+            \\x15\x3e\x21\xe7\x8f\xb0\x3d\x4a\xe6\xe3\x9f\x2b\xdb\x83\xad\xf7\
+            \\xe9\x3d\x5a\x68\x94\x81\x40\xf7\xf6\x4c\x26\x1c\x94\x69\x29\x34\
+            \\x41\x15\x20\xf7\x76\x02\xd4\xf7\xbc\xf4\x6b\x2e\xd4\xa2\x00\x68\
+            \\xd4\x08\x24\x71\x33\x20\xf4\x6a\x43\xb7\xd4\xb7\x50\x00\x61\xaf\
+            \\x1e\x39\xf6\x2e\x97\x24\x45\x46\x14\x21\x4f\x74\xbf\x8b\x88\x40\
+            \\x4d\x95\xfc\x1d\x96\xb5\x91\xaf\x70\xf4\xdd\xd3\x66\xa0\x2f\x45\
+            \\xbf\xbc\x09\xec\x03\xbd\x97\x85\x7f\xac\x6d\xd0\x31\xcb\x85\x04\
+            \\x96\xeb\x27\xb3\x55\xfd\x39\x41\xda\x25\x47\xe6\xab\xca\x0a\x9a\
+            \\x28\x50\x78\x25\x53\x04\x29\xf4\x0a\x2c\x86\xda\xe9\xb6\x6d\xfb\
+            \\x68\xdc\x14\x62\xd7\x48\x69\x00\x68\x0e\xc0\xa4\x27\xa1\x8d\xee\
+            \\x4f\x3f\xfe\xa2\xe8\x87\xad\x8c\xb5\x8c\xe0\x06\x7a\xf4\xd6\xb6\
+            \\xaa\xce\x1e\x7c\xd3\x37\x5f\xec\xce\x78\xa3\x99\x40\x6b\x2a\x42\
+            \\x20\xfe\x9e\x35\xd9\xf3\x85\xb9\xee\x39\xd7\xab\x3b\x12\x4e\x8b\
+            \\x1d\xc9\xfa\xf7\x4b\x6d\x18\x56\x26\xa3\x66\x31\xea\xe3\x97\xb2\
+            \\x3a\x6e\xfa\x74\xdd\x5b\x43\x32\x68\x41\xe7\xf7\xca\x78\x20\xfb\
+            \\xfb\x0a\xf5\x4e\xd8\xfe\xb3\x97\x45\x40\x56\xac\xba\x48\x95\x27\
+            \\x55\x53\x3a\x3a\x20\x83\x8d\x87\xfe\x6b\xa9\xb7\xd0\x96\x95\x4b\
+            \\x55\xa8\x67\xbc\xa1\x15\x9a\x58\xcc\xa9\x29\x63\x99\xe1\xdb\x33\
+            \\xa6\x2a\x4a\x56\x3f\x31\x25\xf9\x5e\xf4\x7e\x1c\x90\x29\x31\x7c\
+            \\xfd\xf8\xe8\x02\x04\x27\x2f\x70\x80\xbb\x15\x5c\x05\x28\x2c\xe3\
+            \\x95\xc1\x15\x48\xe4\xc6\x6d\x22\x48\xc1\x13\x3f\xc7\x0f\x86\xdc\
+            \\x07\xf9\xc9\xee\x41\x04\x1f\x0f\x40\x47\x79\xa4\x5d\x88\x6e\x17\
+            \\x32\x5f\x51\xeb\xd5\x9b\xc0\xd1\xf2\xbc\xc1\x8f\x41\x11\x35\x64\
+            \\x25\x7b\x78\x34\x60\x2a\x9c\x60\xdf\xf8\xe8\xa3\x1f\x63\x6c\x1b\
+            \\x0e\x12\xb4\xc2\x02\xe1\x32\x9e\xaf\x66\x4f\xd1\xca\xd1\x81\x15\
+            \\x6b\x23\x95\xe0\x33\x3e\x92\xe1\x3b\x24\x0b\x62\xee\xbe\xb9\x22\
+            \\x85\xb2\xa2\x0e\xe6\xba\x0d\x99\xde\x72\x0c\x8c\x2d\xa2\xf7\x28\
+            \\xd0\x12\x78\x45\x95\xb7\x94\xfd\x64\x7d\x08\x62\xe7\xcc\xf5\xf0\
+            \\x54\x49\xa3\x6f\x87\x7d\x48\xfa\xc3\x9d\xfd\x27\xf3\x3e\x8d\x1e\
+            \\x0a\x47\x63\x41\x99\x2e\xff\x74\x3a\x6f\x6e\xab\xf4\xf8\xfd\x37\
+            \\xa8\x12\xdc\x60\xa1\xeb\xdd\xf8\x99\x1b\xe1\x4c\xdb\x6e\x6b\x0d\
+            \\xc6\x7b\x55\x10\x6d\x67\x2c\x37\x27\x65\xd4\x3b\xdc\xd0\xe8\x04\
+            \\xf1\x29\x0d\xc7\xcc\x00\xff\xa3\xb5\x39\x0f\x92\x69\x0f\xed\x0b\
+            \\x66\x7b\x9f\xfb\xce\xdb\x7d\x9c\xa0\x91\xcf\x0b\xd9\x15\x5e\xa3\
+            \\xbb\x13\x2f\x88\x51\x5b\xad\x24\x7b\x94\x79\xbf\x76\x3b\xd6\xeb\
+            \\x37\x39\x2e\xb3\xcc\x11\x59\x79\x80\x26\xe2\x97\xf4\x2e\x31\x2d\
+            \\x68\x42\xad\xa7\xc6\x6a\x2b\x3b\x12\x75\x4c\xcc\x78\x2e\xf1\x1c\
+            \\x6a\x12\x42\x37\xb7\x92\x51\xe7\x06\xa1\xbb\xe6\x4b\xfb\x63\x50\
+            \\x1a\x6b\x10\x18\x11\xca\xed\xfa\x3d\x25\xbd\xd8\xe2\xe1\xc3\xc9\
+            \\x44\x42\x16\x59\x0a\x12\x13\x86\xd9\x0c\xec\x6e\xd5\xab\xea\x2a\
+            \\x64\xaf\x67\x4e\xda\x86\xa8\x5f\xbe\xbf\xe9\x88\x64\xe4\xc3\xfe\
+            \\x9d\xbc\x80\x57\xf0\xf7\xc0\x86\x60\x78\x7b\xf8\x60\x03\x60\x4d\
+            \\xd1\xfd\x83\x46\xf6\x38\x1f\xb0\x77\x45\xae\x04\xd7\x36\xfc\xcc\
+            \\x83\x42\x6b\x33\xf0\x1e\xab\x71\xb0\x80\x41\x87\x3c\x00\x5e\x5f\
+            \\x77\xa0\x57\xbe\xbd\xe8\xae\x24\x55\x46\x42\x99\xbf\x58\x2e\x61\
+            \\x4e\x58\xf4\x8f\xf2\xdd\xfd\xa2\xf4\x74\xef\x38\x87\x89\xbd\xc2\
+            \\x53\x66\xf9\xc3\xc8\xb3\x8e\x74\xb4\x75\xf2\x55\x46\xfc\xd9\xb9\
+            \\x7a\xeb\x26\x61\x8b\x1d\xdf\x84\x84\x6a\x0e\x79\x91\x5f\x95\xe2\
+            \\x46\x6e\x59\x8e\x20\xb4\x57\x70\x8c\xd5\x55\x91\xc9\x02\xde\x4c\
+            \\xb9\x0b\xac\xe1\xbb\x82\x05\xd0\x11\xa8\x62\x48\x75\x74\xa9\x9e\
+            \\xb7\x7f\x19\xb6\xe0\xa9\xdc\x09\x66\x2d\x09\xa1\xc4\x32\x46\x33\
+            \\xe8\x5a\x1f\x02\x09\xf0\xbe\x8c\x4a\x99\xa0\x25\x1d\x6e\xfe\x10\
+            \\x1a\xb9\x3d\x1d\x0b\xa5\xa4\xdf\xa1\x86\xf2\x0f\x28\x68\xf1\x69\
+            \\xdc\xb7\xda\x83\x57\x39\x06\xfe\xa1\xe2\xce\x9b\x4f\xcd\x7f\x52\
+            \\x50\x11\x5e\x01\xa7\x06\x83\xfa\xa0\x02\xb5\xc4\x0d\xe6\xd0\x27\
+            \\x9a\xf8\x8c\x27\x77\x3f\x86\x41\xc3\x60\x4c\x06\x61\xa8\x06\xb5\
+            \\xf0\x17\x7a\x28\xc0\xf5\x86\xe0\x00\x60\x58\xaa\x30\xdc\x7d\x62\
+            \\x11\xe6\x9e\xd7\x23\x38\xea\x63\x53\xc2\xdd\x94\xc2\xc2\x16\x34\
+            \\xbb\xcb\xee\x56\x90\xbc\xb6\xde\xeb\xfc\x7d\xa1\xce\x59\x1d\x76\
+            \\x6f\x05\xe4\x09\x4b\x7c\x01\x88\x39\x72\x0a\x3d\x7c\x92\x7c\x24\
+            \\x86\xe3\x72\x5f\x72\x4d\x9d\xb9\x1a\xc1\x5b\xb4\xd3\x9e\xb8\xfc\
+            \\xed\x54\x55\x78\x08\xfc\xa5\xb5\xd8\x3d\x7c\xd3\x4d\xad\x0f\xc4\
+            \\x1e\x50\xef\x5e\xb1\x61\xe6\xf8\xa2\x85\x14\xd9\x6c\x51\x13\x3c\
+            \\x6f\xd5\xc7\xe7\x56\xe1\x4e\xc4\x36\x2a\xbf\xce\xdd\xc6\xc8\x37\
+            \\xd7\x9a\x32\x34\x92\x63\x82\x12\x67\x0e\xfa\x8e\x40\x60\x00\xe0\
+            \\x3a\x39\xce\x37\xd3\xfa\xf5\xcf\xab\xc2\x77\x37\x5a\xc5\x2d\x1b\
+            \\x5c\xb0\x67\x9e\x4f\xa3\x37\x42\xd3\x82\x27\x40\x99\xbc\x9b\xbe\
+            \\xd5\x11\x8e\x9d\xbf\x0f\x73\x15\xd6\x2d\x1c\x7e\xc7\x00\xc4\x7b\
+            \\xb7\x8c\x1b\x6b\x21\xa1\x90\x45\xb2\x6e\xb1\xbe\x6a\x36\x6e\xb4\
+            \\x57\x48\xab\x2f\xbc\x94\x6e\x79\xc6\xa3\x76\xd2\x65\x49\xc2\xc8\
+            \\x53\x0f\xf8\xee\x46\x8d\xde\x7d\xd5\x73\x0a\x1d\x4c\xd0\x4d\xc6\
+            \\x29\x39\xbb\xdb\xa9\xba\x46\x50\xac\x95\x26\xe8\xbe\x5e\xe3\x04\
+            \\xa1\xfa\xd5\xf0\x6a\x2d\x51\x9a\x63\xef\x8c\xe2\x9a\x86\xee\x22\
+            \\xc0\x89\xc2\xb8\x43\x24\x2e\xf6\xa5\x1e\x03\xaa\x9c\xf2\xd0\xa4\
+            \\x83\xc0\x61\xba\x9b\xe9\x6a\x4d\x8f\xe5\x15\x50\xba\x64\x5b\xd6\
+            \\x28\x26\xa2\xf9\xa7\x3a\x3a\xe1\x4b\xa9\x95\x86\xef\x55\x62\xe9\
+            \\xc7\x2f\xef\xd3\xf7\x52\xf7\xda\x3f\x04\x6f\x69\x77\xfa\x0a\x59\
+            \\x80\xe4\xa9\x15\x87\xb0\x86\x01\x9b\x09\xe6\xad\x3b\x3e\xe5\x93\
+            \\xe9\x90\xfd\x5a\x9e\x34\xd7\x97\x2c\xf0\xb7\xd9\x02\x2b\x8b\x51\
+            \\x96\xd5\xac\x3a\x01\x7d\xa6\x7d\xd1\xcf\x3e\xd6\x7c\x7d\x2d\x28\
+            \\x1f\x9f\x25\xcf\xad\xf2\xb8\x9b\x5a\xd6\xb4\x72\x5a\x88\xf5\x4c\
+            \\xe0\x29\xac\x71\xe0\x19\xa5\xe6\x47\xb0\xac\xfd\xed\x93\xfa\x9b\
+            \\xe8\xd3\xc4\x8d\x28\x3b\x57\xcc\xf8\xd5\x66\x29\x79\x13\x2e\x28\
+            \\x78\x5f\x01\x91\xed\x75\x60\x55\xf7\x96\x0e\x44\xe3\xd3\x5e\x8c\
+            \\x15\x05\x6d\xd4\x88\xf4\x6d\xba\x03\xa1\x61\x25\x05\x64\xf0\xbd\
+            \\xc3\xeb\x9e\x15\x3c\x90\x57\xa2\x97\x27\x1a\xec\xa9\x3a\x07\x2a\
+            \\x1b\x3f\x6d\x9b\x1e\x63\x21\xf5\xf5\x9c\x66\xfb\x26\xdc\xf3\x19\
+            \\x75\x33\xd9\x28\xb1\x55\xfd\xf5\x03\x56\x34\x82\x8a\xba\x3c\xbb\
+            \\x28\x51\x77\x11\xc2\x0a\xd9\xf8\xab\xcc\x51\x67\xcc\xad\x92\x5f\
+            \\x4d\xe8\x17\x51\x38\x30\xdc\x8e\x37\x9d\x58\x62\x93\x20\xf9\x91\
+            \\xea\x7a\x90\xc2\xfb\x3e\x7b\xce\x51\x21\xce\x64\x77\x4f\xbe\x32\
+            \\xa8\xb6\xe3\x7e\xc3\x29\x3d\x46\x48\xde\x53\x69\x64\x13\xe6\x80\
+            \\xa2\xae\x08\x10\xdd\x6d\xb2\x24\x69\x85\x2d\xfd\x09\x07\x21\x66\
+            \\xb3\x9a\x46\x0a\x64\x45\xc0\xdd\x58\x6c\xde\xcf\x1c\x20\xc8\xae\
+            \\x5b\xbe\xf7\xdd\x1b\x58\x8d\x40\xcc\xd2\x01\x7f\x6b\xb4\xe3\xbb\
+            \\xdd\xa2\x6a\x7e\x3a\x59\xff\x45\x3e\x35\x0a\x44\xbc\xb4\xcd\xd5\
+            \\x72\xea\xce\xa8\xfa\x64\x84\xbb\x8d\x66\x12\xae\xbf\x3c\x6f\x47\
+            \\xd2\x9b\xe4\x63\x54\x2f\x5d\x9e\xae\xc2\x77\x1b\xf6\x4e\x63\x70\
+            \\x74\x0e\x0d\x8d\xe7\x5b\x13\x57\xf8\x72\x16\x71\xaf\x53\x7d\x5d\
+            \\x40\x40\xcb\x08\x4e\xb4\xe2\xcc\x34\xd2\x46\x6a\x01\x15\xaf\x84\
+            \\xe1\xb0\x04\x28\x95\x98\x3a\x1d\x06\xb8\x9f\xb4\xce\x6e\xa0\x48\
+            \\x6f\x3f\x3b\x82\x35\x20\xab\x82\x01\x1a\x1d\x4b\x27\x72\x27\xf8\
+            \\x61\x15\x60\xb1\xe7\x93\x3f\xdc\xbb\x3a\x79\x2b\x34\x45\x25\xbd\
+            \\xa0\x88\x39\xe1\x51\xce\x79\x4b\x2f\x32\xc9\xb7\xa0\x1f\xba\xc9\
+            \\xe0\x1c\xc8\x7e\xbc\xc7\xd1\xf6\xcf\x01\x11\xc3\xa1\xe8\xaa\xc7\
+            \\x1a\x90\x87\x49\xd4\x4f\xbd\x9a\xd0\xda\xde\xcb\xd5\x0a\xda\x38\
+            \\x03\x39\xc3\x2a\xc6\x91\x36\x67\x8d\xf9\x31\x7c\xe0\xb1\x2b\x4f\
+            \\xf7\x9e\x59\xb7\x43\xf5\xbb\x3a\xf2\xd5\x19\xff\x27\xd9\x45\x9c\
+            \\xbf\x97\x22\x2c\x15\xe6\xfc\x2a\x0f\x91\xfc\x71\x9b\x94\x15\x25\
+            \\xfa\xe5\x93\x61\xce\xb6\x9c\xeb\xc2\xa8\x64\x59\x12\xba\xa8\xd1\
+            \\xb6\xc1\x07\x5e\xe3\x05\x6a\x0c\x10\xd2\x50\x65\xcb\x03\xa4\x42\
+            \\xe0\xec\x6e\x0e\x16\x98\xdb\x3b\x4c\x98\xa0\xbe\x32\x78\xe9\x64\
+            \\x9f\x1f\x95\x32\xe0\xd3\x92\xdf\xd3\xa0\x34\x2b\x89\x71\xf2\x1e\
+            \\x1b\x0a\x74\x41\x4b\xa3\x34\x8c\xc5\xbe\x71\x20\xc3\x76\x32\xd8\
+            \\xdf\x35\x9f\x8d\x9b\x99\x2f\x2e\xe6\x0b\x6f\x47\x0f\xe3\xf1\x1d\
+            \\xe5\x4c\xda\x54\x1e\xda\xd8\x91\xce\x62\x79\xcf\xcd\x3e\x7e\x6f\
+            \\x16\x18\xb1\x66\xfd\x2c\x1d\x05\x84\x8f\xd2\xc5\xf6\xfb\x22\x99\
+            \\xf5\x23\xf3\x57\xa6\x32\x76\x23\x93\xa8\x35\x31\x56\xcc\xcd\x02\
+            \\xac\xf0\x81\x62\x5a\x75\xeb\xb5\x6e\x16\x36\x97\x88\xd2\x73\xcc\
+            \\xde\x96\x62\x92\x81\xb9\x49\xd0\x4c\x50\x90\x1b\x71\xc6\x56\x14\
+            \\xe6\xc6\xc7\xbd\x32\x7a\x14\x0a\x45\xe1\xd0\x06\xc3\xf2\x7b\x9a\
+            \\xc9\xaa\x53\xfd\x62\xa8\x0f\x00\xbb\x25\xbf\xe2\x35\xbd\xd2\xf6\
+            \\x71\x12\x69\x05\xb2\x04\x02\x22\xb6\xcb\xcf\x7c\xcd\x76\x9c\x2b\
+            \\x53\x11\x3e\xc0\x16\x40\xe3\xd3\x38\xab\xbd\x60\x25\x47\xad\xf0\
+            \\xba\x38\x20\x9c\xf7\x46\xce\x76\x77\xaf\xa1\xc5\x20\x75\x60\x60\
+            \\x85\xcb\xfe\x4e\x8a\xe8\x8d\xd8\x7a\xaa\xf9\xb0\x4c\xf9\xaa\x7e\
+            \\x19\x48\xc2\x5c\x02\xfb\x8a\x8c\x01\xc3\x6a\xe4\xd6\xeb\xe1\xf9\
+            \\x90\xd4\xf8\x69\xa6\x5c\xde\xa0\x3f\x09\x25\x2d\xc2\x08\xe6\x9f\
+            \\xb7\x4e\x61\x32\xce\x77\xe2\x5b\x57\x8f\xdf\xe3\x3a\xc3\x72\xe6\
+            \"#
diff --git a/Crypto/Cipher/Blowfish/Primitive.hs b/Crypto/Cipher/Blowfish/Primitive.hs
--- a/Crypto/Cipher/Blowfish/Primitive.hs
+++ b/Crypto/Cipher/Blowfish/Primitive.hs
@@ -1,9 +1,3 @@
--- |
--- Module      : Crypto.Cipher.Blowfish.Primitive
--- License     : BSD-style
--- Stability   : experimental
--- Portability : Good
-
 -- Rewritten by Vincent Hanquez (c) 2015
 --              Lars Petersen (c) 2018
 --
@@ -12,32 +6,38 @@
 --      based on: BlowfishAux.hs (C) 2002 HardCore SoftWare, Doug Hoyte
 --           (as found in Crypto-4.2.4)
 {-# LANGUAGE BangPatterns #-}
-module Crypto.Cipher.Blowfish.Primitive
-    ( Context
-    , initBlowfish
-    , encrypt
-    , decrypt
-    , KeySchedule
-    , createKeySchedule
-    , freezeKeySchedule
-    , expandKey
-    , expandKeyWithSalt
-    , cipherBlockMutable
-    ) where
 
-import           Control.Monad              (when)
-import           Data.Bits
-import           Data.Memory.Endian
-import           Data.Word
+-- |
+-- Module      : Crypto.Cipher.Blowfish.Primitive
+-- License     : BSD-style
+-- Stability   : experimental
+-- Portability : Good
+module Crypto.Cipher.Blowfish.Primitive (
+    Context,
+    initBlowfish,
+    encrypt,
+    decrypt,
+    KeySchedule,
+    createKeySchedule,
+    freezeKeySchedule,
+    expandKey,
+    expandKeyWithSalt,
+    cipherBlockMutable,
+) where
 
-import           Crypto.Cipher.Blowfish.Box
-import           Crypto.Error
-import           Crypto.Internal.ByteArray  (ByteArray, ByteArrayAccess)
-import qualified Crypto.Internal.ByteArray  as B
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Crypto.Internal.WordArray
+import Control.Monad (when)
+import Data.Bits
+import Data.Memory.Endian
+import Data.Word
 
+import Crypto.Cipher.Blowfish.Box
+import Crypto.Error
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
+import qualified Crypto.Internal.ByteArray as B
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Crypto.Internal.WordArray
+
 newtype Context = Context Array32
 
 instance NFData Context where
@@ -49,7 +49,7 @@
 initBlowfish :: ByteArrayAccess key => key -> CryptoFailable Context
 initBlowfish key
     | B.length key > (448 `div` 8) = CryptoFailed CryptoError_KeySizeInvalid
-    | otherwise                    = CryptoPassed $ unsafeDoIO $ do
+    | otherwise = CryptoPassed $ unsafeDoIO $ do
         ks <- createKeySchedule
         expandKey ks key
         freezeKeySchedule ks
@@ -58,43 +58,53 @@
 freezeKeySchedule :: KeySchedule -> IO Context
 freezeKeySchedule (KeySchedule ma) = Context `fmap` mutableArray32Freeze ma
 
-expandKey :: (ByteArrayAccess key) => KeySchedule -> key -> IO ()
+expandKey :: ByteArrayAccess key => KeySchedule -> key -> IO ()
 expandKey ks@(KeySchedule ma) key = do
-    when (B.length key > 0) $ iterKeyStream key 0 0 $ \i l r a0 a1 cont-> do
+    when (B.length key > 0) $ iterKeyStream key 0 0 $ \i l r a0 a1 cont -> do
         mutableArrayWriteXor32 ma i l
         mutableArrayWriteXor32 ma (i + 1) r
         when (i + 2 < 18) (cont a0 a1)
     loop 0 0 0
-    where
-        loop i l r = do
-            n <- cipherBlockMutable ks (fromIntegral l `shiftL` 32 .|. fromIntegral r)
-            let nl = fromIntegral (n `shiftR` 32)
-                nr = fromIntegral (n .&. 0xffffffff)
-            mutableArrayWrite32 ma i nl
-            mutableArrayWrite32 ma (i + 1) nr
-            when (i < 18 + 1024) (loop (i + 2) nl nr)
+  where
+    loop i l r = do
+        n <- cipherBlockMutable ks (fromIntegral l `shiftL` 32 .|. fromIntegral r)
+        let nl = fromIntegral (n `shiftR` 32)
+            nr = fromIntegral (n .&. 0xffffffff)
+        mutableArrayWrite32 ma i nl
+        mutableArrayWrite32 ma (i + 1) nr
+        when (i < 18 + 1024) (loop (i + 2) nl nr)
 
-expandKeyWithSalt :: (ByteArrayAccess key, ByteArrayAccess salt)
+expandKeyWithSalt
+    :: (ByteArrayAccess key, ByteArrayAccess salt)
     => KeySchedule
     -> key
     -> salt
     -> IO ()
 expandKeyWithSalt ks key salt
-    | B.length salt == 16 = expandKeyWithSalt128 ks key (fromBE $ B.toW64BE salt 0) (fromBE $ B.toW64BE salt 8)
-    | otherwise           = expandKeyWithSaltAny ks key salt
+    | B.length salt == 16 =
+        expandKeyWithSalt128
+            ks
+            key
+            (fromBE $ B.toW64BE salt 0)
+            (fromBE $ B.toW64BE salt 8)
+    | otherwise = expandKeyWithSaltAny ks key salt
 
-expandKeyWithSaltAny :: (ByteArrayAccess key, ByteArrayAccess salt)
-    => KeySchedule         -- ^ The key schedule
-    -> key                 -- ^ The key
-    -> salt                -- ^ The salt
+expandKeyWithSaltAny
+    :: (ByteArrayAccess key, ByteArrayAccess salt)
+    => KeySchedule
+    -- ^ The key schedule
+    -> key
+    -- ^ The key
+    -> salt
+    -- ^ The salt
     -> IO ()
 expandKeyWithSaltAny ks@(KeySchedule ma) key salt = do
-    when (B.length key > 0) $ iterKeyStream key 0 0 $ \i l r a0 a1 cont-> do
+    when (B.length key > 0) $ iterKeyStream key 0 0 $ \i l r a0 a1 cont -> do
         mutableArrayWriteXor32 ma i l
         mutableArrayWriteXor32 ma (i + 1) r
         when (i + 2 < 18) (cont a0 a1)
     -- Go through the entire key schedule overwriting the P-Array and S-Boxes
-    when (B.length salt > 0) $ iterKeyStream salt 0 0 $ \i l r a0 a1 cont-> do
+    when (B.length salt > 0) $ iterKeyStream salt 0 0 $ \i l r a0 a1 cont -> do
         let l' = xor l a0
         let r' = xor r a1
         n <- cipherBlockMutable ks (fromIntegral l' `shiftL` 32 .|. fromIntegral r')
@@ -104,112 +114,119 @@
         mutableArrayWrite32 ma (i + 1) nr
         when (i + 2 < 18 + 1024) (cont nl nr)
 
-expandKeyWithSalt128 :: ByteArrayAccess ba
-    => KeySchedule         -- ^ The key schedule
-    -> ba                  -- ^ The key
-    -> Word64              -- ^ First word of the salt
-    -> Word64              -- ^ Second word of the salt
+expandKeyWithSalt128
+    :: ByteArrayAccess ba
+    => KeySchedule
+    -- ^ The key schedule
+    -> ba
+    -- ^ The key
+    -> Word64
+    -- ^ First word of the salt
+    -> Word64
+    -- ^ Second word of the salt
     -> IO ()
 expandKeyWithSalt128 ks@(KeySchedule ma) key salt1 salt2 = do
-    when (B.length key > 0) $ iterKeyStream key 0 0 $ \i l r a0 a1 cont-> do
+    when (B.length key > 0) $ iterKeyStream key 0 0 $ \i l r a0 a1 cont -> do
         mutableArrayWriteXor32 ma i l
         mutableArrayWriteXor32 ma (i + 1) r
         when (i + 2 < 18) (cont a0 a1)
     -- Go through the entire key schedule overwriting the P-Array and S-Boxes
     loop 0 salt1 salt1 salt2
-    where
-        loop i input slt1 slt2
-            | i == 1042   = return ()
-            | otherwise = do
-                n <- cipherBlockMutable ks input
-                let nl = fromIntegral (n `shiftR` 32)
-                    nr = fromIntegral (n .&. 0xffffffff)
-                mutableArrayWrite32 ma i     nl
-                mutableArrayWrite32 ma (i+1) nr
-                loop (i+2) (n `xor` slt2) slt2 slt1
+  where
+    loop i input slt1 slt2
+        | i == 1042 = return ()
+        | otherwise = do
+            n <- cipherBlockMutable ks input
+            let nl = fromIntegral (n `shiftR` 32)
+                nr = fromIntegral (n .&. 0xffffffff)
+            mutableArrayWrite32 ma i nl
+            mutableArrayWrite32 ma (i + 1) nr
+            loop (i + 2) (n `xor` slt2) slt2 slt1
 
 -- | Encrypt blocks
 --
 -- Input need to be a multiple of 8 bytes
 encrypt :: ByteArray ba => Context -> ba -> ba
 encrypt ctx ba
-    | B.length ba == 0         = B.empty
+    | B.length ba == 0 = B.empty
     | B.length ba `mod` 8 /= 0 = error "invalid data length"
-    | otherwise                = B.mapAsWord64 (cipherBlock ctx False) ba
+    | otherwise = B.mapAsWord64 (cipherBlock ctx False) ba
 
 -- | Decrypt blocks
 --
 -- Input need to be a multiple of 8 bytes
 decrypt :: ByteArray ba => Context -> ba -> ba
 decrypt ctx ba
-    | B.length ba == 0         = B.empty
+    | B.length ba == 0 = B.empty
     | B.length ba `mod` 8 /= 0 = error "invalid data length"
-    | otherwise                = B.mapAsWord64 (cipherBlock ctx True) ba
+    | otherwise = B.mapAsWord64 (cipherBlock ctx True) ba
 
 -- | Encrypt or decrypt a single block of 64 bits.
 --
 -- The inverse argument decides whether to encrypt or decrypt.
 cipherBlock :: Context -> Bool -> Word64 -> Word64
 cipherBlock (Context ar) inverse input = doRound input 0
-    where
-    -- | Transform the input over 16 rounds
+  where
+    -- \| Transform the input over 16 rounds
     doRound :: Word64 -> Int -> Word64
     doRound !i roundIndex
         | roundIndex == 16 =
             let final = (fromIntegral (p 16) `shiftL` 32) .|. fromIntegral (p 17)
              in rotateL (i `xor` final) 32
-        | otherwise     =
+        | otherwise =
             let newr = fromIntegral (i `shiftR` 32) `xor` p roundIndex
                 newi = ((i `shiftL` 32) `xor` f newr) .|. fromIntegral newr
-             in doRound newi (roundIndex+1)
+             in doRound newi (roundIndex + 1)
 
-    -- | The Blowfish Feistel function F
-    f   :: Word32 -> Word64
-    f t = let a = s0 (0xff .&. (t `shiftR` 24))
-              b = s1 (0xff .&. (t `shiftR` 16))
-              c = s2 (0xff .&. (t `shiftR` 8))
-              d = s3 (0xff .&.  t)
-           in fromIntegral (((a + b) `xor` c) + d) `shiftL` 32
+    -- \| The Blowfish Feistel function F
+    f :: Word32 -> Word64
+    f t =
+        let a = s0 (0xff .&. (t `shiftR` 24))
+            b = s1 (0xff .&. (t `shiftR` 16))
+            c = s2 (0xff .&. (t `shiftR` 8))
+            d = s3 (0xff .&. t)
+         in fromIntegral (((a + b) `xor` c) + d) `shiftL` 32
 
-    -- | S-Box arrays, each containing 256 32-bit words
+    -- \| S-Box arrays, each containing 256 32-bit words
     --   The first 18 words contain the P-Array of subkeys
     s0, s1, s2, s3 :: Word32 -> Word32
-    s0 i            = arrayRead32 ar (fromIntegral i + 18)
-    s1 i            = arrayRead32 ar (fromIntegral i + 274)
-    s2 i            = arrayRead32 ar (fromIntegral i + 530)
-    s3 i            = arrayRead32 ar (fromIntegral i + 786)
-    p              :: Int -> Word32
-    p i | inverse   = arrayRead32 ar (17 - i)
+    s0 i = arrayRead32 ar (fromIntegral i + 18)
+    s1 i = arrayRead32 ar (fromIntegral i + 274)
+    s2 i = arrayRead32 ar (fromIntegral i + 530)
+    s3 i = arrayRead32 ar (fromIntegral i + 786)
+    p :: Int -> Word32
+    p i
+        | inverse = arrayRead32 ar (17 - i)
         | otherwise = arrayRead32 ar i
 
 -- | Blowfish encrypt a Word using the current state of the key schedule
 cipherBlockMutable :: KeySchedule -> Word64 -> IO Word64
 cipherBlockMutable (KeySchedule ma) input = doRound input 0
-    where
-    -- | Transform the input over 16 rounds
+  where
+    -- \| Transform the input over 16 rounds
     doRound !i roundIndex
         | roundIndex == 16 = do
             pVal1 <- mutableArrayRead32 ma 16
             pVal2 <- mutableArrayRead32 ma 17
             let final = (fromIntegral pVal1 `shiftL` 32) .|. fromIntegral pVal2
             return $ rotateL (i `xor` final) 32
-        | otherwise     = do
+        | otherwise = do
             pVal <- mutableArrayRead32 ma roundIndex
             let newr = fromIntegral (i `shiftR` 32) `xor` pVal
             newr' <- f newr
             let newi = ((i `shiftL` 32) `xor` newr') .|. fromIntegral newr
-            doRound newi (roundIndex+1)
+            doRound newi (roundIndex + 1)
 
-    -- | The Blowfish Feistel function F
-    f   :: Word32 -> IO Word64
+    -- \| The Blowfish Feistel function F
+    f :: Word32 -> IO Word64
     f t = do
         a <- s0 (0xff .&. (t `shiftR` 24))
         b <- s1 (0xff .&. (t `shiftR` 16))
         c <- s2 (0xff .&. (t `shiftR` 8))
-        d <- s3 (0xff .&.  t)
+        d <- s3 (0xff .&. t)
         return (fromIntegral (((a + b) `xor` c) + d) `shiftL` 32)
 
-    -- | S-Box arrays, each containing 256 32-bit words
+    -- \| S-Box arrays, each containing 256 32-bit words
     --   The first 18 words contain the P-Array of subkeys
     s0, s1, s2, s3 :: Word32 -> IO Word32
     s0 i = mutableArrayRead32 ma (fromIntegral i + 18)
@@ -217,41 +234,50 @@
     s2 i = mutableArrayRead32 ma (fromIntegral i + 530)
     s3 i = mutableArrayRead32 ma (fromIntegral i + 786)
 
-iterKeyStream :: (ByteArrayAccess x)
+iterKeyStream
+    :: ByteArrayAccess x
     => x
     -> Word32
     -> Word32
-    -> (Int -> Word32 -> Word32 -> Word32 -> Word32 -> (Word32 -> Word32 -> IO ()) -> IO ())
+    -> ( Int
+         -> Word32
+         -> Word32
+         -> Word32
+         -> Word32
+         -> (Word32 -> Word32 -> IO ())
+         -> IO ()
+       )
     -> IO ()
 iterKeyStream x a0 a1 g = f 0 0 a0 a1
-    where
-        len          = B.length x
-        -- Avoiding the modulo operation when interating over the ring
-        -- buffer is assumed to be more efficient here. All other
-        -- implementations do this, too. The branch prediction shall prefer
-        -- the branch with the increment.
-        n j          = if j + 1 >= len then 0 else j + 1
-        f i j0 b0 b1 = g i l r b0 b1 (f (i + 2) j8)
-            where
-                j1 = n j0
-                j2 = n j1
-                j3 = n j2
-                j4 = n j3
-                j5 = n j4
-                j6 = n j5
-                j7 = n j6
-                j8 = n j7
-                x0 = fromIntegral (B.index x j0)
-                x1 = fromIntegral (B.index x j1)
-                x2 = fromIntegral (B.index x j2)
-                x3 = fromIntegral (B.index x j3)
-                x4 = fromIntegral (B.index x j4)
-                x5 = fromIntegral (B.index x j5)
-                x6 = fromIntegral (B.index x j6)
-                x7 = fromIntegral (B.index x j7)
-                l  = shiftL x0 24 .|. shiftL x1 16 .|. shiftL x2 8 .|. x3
-                r  = shiftL x4 24 .|. shiftL x5 16 .|. shiftL x6 8 .|. x7
+  where
+    len = B.length x
+    -- Avoiding the modulo operation when interating over the ring
+    -- buffer is assumed to be more efficient here. All other
+    -- implementations do this, too. The branch prediction shall prefer
+    -- the branch with the increment.
+    n j = if j + 1 >= len then 0 else j + 1
+    f i j0 b0 b1 = g i l r b0 b1 (f (i + 2) j8)
+      where
+        j1 = n j0
+        j2 = n j1
+        j3 = n j2
+        j4 = n j3
+        j5 = n j4
+        j6 = n j5
+        j7 = n j6
+        j8 = n j7
+        x0 = fromIntegral (B.index x j0)
+        x1 = fromIntegral (B.index x j1)
+        x2 = fromIntegral (B.index x j2)
+        x3 = fromIntegral (B.index x j3)
+        x4 = fromIntegral (B.index x j4)
+        x5 = fromIntegral (B.index x j5)
+        x6 = fromIntegral (B.index x j6)
+        x7 = fromIntegral (B.index x j7)
+        l = shiftL x0 24 .|. shiftL x1 16 .|. shiftL x2 8 .|. x3
+        r = shiftL x4 24 .|. shiftL x5 16 .|. shiftL x6 8 .|. x7
 {-# INLINE iterKeyStream #-}
+
 -- Benchmarking shows that GHC considers this function too big to inline
 -- although forcing inlining causes an actual improvement.
 -- It is assumed that all function calls (especially the continuation)
diff --git a/Crypto/Cipher/CAST5.hs b/Crypto/Cipher/CAST5.hs
--- a/Crypto/Cipher/CAST5.hs
+++ b/Crypto/Cipher/CAST5.hs
@@ -4,15 +4,14 @@
 -- Maintainer  : Olivier Chéron <olivier.cheron@gmail.com>
 -- Stability   : stable
 -- Portability : good
---
-module Crypto.Cipher.CAST5
-    ( CAST5
-    ) where
+module Crypto.Cipher.CAST5 (
+    CAST5,
+) where
 
-import           Crypto.Error
-import           Crypto.Cipher.Types
-import           Crypto.Cipher.CAST5.Primitive
-import           Crypto.Internal.ByteArray (ByteArrayAccess)
+import Crypto.Cipher.CAST5.Primitive
+import Crypto.Cipher.Types
+import Crypto.Error
+import Crypto.Internal.ByteArray (ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B
 
 -- | CAST5 block cipher (also known as CAST-128).  Key is between
@@ -20,9 +19,9 @@
 newtype CAST5 = CAST5 Key
 
 instance Cipher CAST5 where
-    cipherName    _ = "CAST5"
+    cipherName _ = "CAST5"
     cipherKeySize _ = KeySizeRange 5 16
-    cipherInit      = initCAST5
+    cipherInit = initCAST5
 
 instance BlockCipher CAST5 where
     blockSize _ = 8
@@ -31,12 +30,12 @@
 
 initCAST5 :: ByteArrayAccess key => key -> CryptoFailable CAST5
 initCAST5 bs
-    | len <   5 = CryptoFailed CryptoError_KeySizeInvalid
-    | len <  16 = CryptoPassed (CAST5 $ buildKey short padded)
+    | len < 5 = CryptoFailed CryptoError_KeySizeInvalid
+    | len < 16 = CryptoPassed (CAST5 $ buildKey short padded)
     | len == 16 = CryptoPassed (CAST5 $ buildKey False bs)
     | otherwise = CryptoFailed CryptoError_KeySizeInvalid
   where
-    len   = B.length bs
+    len = B.length bs
     short = len <= 10
 
     padded :: B.Bytes
diff --git a/Crypto/Cipher/CAST5/Primitive.hs b/Crypto/Cipher/CAST5/Primitive.hs
--- a/Crypto/Cipher/CAST5/Primitive.hs
+++ b/Crypto/Cipher/CAST5/Primitive.hs
@@ -1,21 +1,20 @@
 {-# LANGUAGE MagicHash #-}
 
 -----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
 -- |
 -- Module      :  Crypto.Cipher.CAST5.Primitive
 -- License     :  BSD-style
 --
 -- Haskell implementation of the CAST-128 Encryption Algorithm
---
------------------------------------------------------------------------------
-
-
-module Crypto.Cipher.CAST5.Primitive
-    ( encrypt
-    , decrypt
-    , Key()
-    , buildKey
-    ) where
+module Crypto.Cipher.CAST5.Primitive (
+    encrypt,
+    decrypt,
+    Key (),
+    buildKey,
+) where
 
 import Control.Monad (void, (>=>))
 
@@ -23,23 +22,28 @@
 import Data.Memory.Endian
 import Data.Word
 
-import           Crypto.Internal.ByteArray (ByteArrayAccess)
+import Crypto.Internal.ByteArray (ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.WordArray
-
+import Crypto.Internal.WordArray
 
 -- Data Types
 
-data P = P {-# UNPACK #-} !Word32 -- left word
-           {-# UNPACK #-} !Word32 -- right word
+data P
+    = P
+        {-# UNPACK #-} !Word32 -- left word
+        {-# UNPACK #-} !Word32 -- right word
 
-data Q = Q {-# UNPACK #-} !Word32 {-# UNPACK #-} !Word32
-           {-# UNPACK #-} !Word32 {-# UNPACK #-} !Word32
+data Q
+    = Q
+        {-# UNPACK #-} !Word32
+        {-# UNPACK #-} !Word32
+        {-# UNPACK #-} !Word32
+        {-# UNPACK #-} !Word32
 
 -- | All subkeys for 12 or 16 rounds
-data Key = K12 {-# UNPACK #-} !Array32 -- [ km1, kr1, km2, kr2, ..., km12, kr12 ]
-         | K16 {-# UNPACK #-} !Array32 -- [ km1, kr1, km2, kr2, ..., km16, kr16 ]
-
+data Key
+    = K12 {-# UNPACK #-} !Array32 -- [ km1, kr1, km2, kr2, ..., km12, kr12 ]
+    | K16 {-# UNPACK #-} !Array32 -- [ km1, kr1, km2, kr2, ..., km16, kr16 ]
 
 -- Big-endian Transformations
 
@@ -53,10 +57,9 @@
 decomp32 x =
     let a = fromIntegral (x `shiftR` 24)
         b = fromIntegral (x `shiftR` 16)
-        c = fromIntegral (x `shiftR`  8)
+        c = fromIntegral (x `shiftR` 8)
         d = fromIntegral x
-    in (a, b, c, d)
-
+     in (a, b, c, d)
 
 -- Encryption
 
@@ -67,19 +70,18 @@
 cast_enc :: Key -> P -> P
 cast_enc (K12 a) (P l0 r0) = P r12 r11
   where
-    r1  = type1 a 0  l0  r0
-    r2  = type2 a 2  r0  r1
-    r3  = type3 a 4  r1  r2
-    r4  = type1 a 6  r2  r3
-    r5  = type2 a 8  r3  r4
-    r6  = type3 a 10 r4  r5
-    r7  = type1 a 12 r5  r6
-    r8  = type2 a 14 r6  r7
-    r9  = type3 a 16 r7  r8
-    r10 = type1 a 18 r8  r9
-    r11 = type2 a 20 r9  r10
+    r1 = type1 a 0 l0 r0
+    r2 = type2 a 2 r0 r1
+    r3 = type3 a 4 r1 r2
+    r4 = type1 a 6 r2 r3
+    r5 = type2 a 8 r3 r4
+    r6 = type3 a 10 r4 r5
+    r7 = type1 a 12 r5 r6
+    r8 = type2 a 14 r6 r7
+    r9 = type3 a 16 r7 r8
+    r10 = type1 a 18 r8 r9
+    r11 = type2 a 20 r9 r10
     r12 = type3 a 22 r10 r11
-
 cast_enc (K16 a) p = P r16 r15
   where
     P r12 r11 = cast_enc (K12 a) p
@@ -99,18 +101,17 @@
 cast_dec (K12 a) (P r12 r11) = P l0 r0
   where
     r10 = type3 a 22 r12 r11
-    r9  = type2 a 20 r11 r10
-    r8  = type1 a 18 r10 r9
-    r7  = type3 a 16 r9  r8
-    r6  = type2 a 14 r8  r7
-    r5  = type1 a 12 r7  r6
-    r4  = type3 a 10 r6  r5
-    r3  = type2 a 8  r5  r4
-    r2  = type1 a 6  r4  r3
-    r1  = type3 a 4  r3  r2
-    r0  = type2 a 2  r2  r1
-    l0  = type1 a 0  r1  r0
-
+    r9 = type2 a 20 r11 r10
+    r8 = type1 a 18 r10 r9
+    r7 = type3 a 16 r9 r8
+    r6 = type2 a 14 r8 r7
+    r5 = type1 a 12 r7 r6
+    r4 = type3 a 10 r6 r5
+    r3 = type2 a 8 r5 r4
+    r2 = type1 a 6 r4 r3
+    r1 = type3 a 4 r3 r2
+    r0 = type2 a 2 r2 r1
+    l0 = type1 a 0 r1 r0
 cast_dec (K16 a) (P r16 r15) = cast_dec (K12 a) (P r12 r11)
   where
     r14 = type1 a 30 r16 r15
@@ -118,7 +119,6 @@
     r12 = type2 a 26 r14 r13
     r11 = type1 a 24 r13 r12
 
-
 -- Non-Identical Rounds
 
 type1 :: Array32 -> Int -> Word32 -> Word32 -> Word32
@@ -145,14 +145,17 @@
         (ja, jb, jc, jd) = decomp32 j
      in l `xor` (((sbox_s1 ja + sbox_s2 jb) `xor` sbox_s3 jc) - sbox_s4 jd)
 
-
 -- Key Schedule
 
 -- | Precompute "masking" and "rotation" subkeys
-buildKey :: ByteArrayAccess key
-         => Bool -- ^ @True@ for short keys that only need 12 rounds
-         -> key  -- ^ Input key padded to 16 bytes
-         -> Key  -- ^ Output data structure
+buildKey
+    :: ByteArrayAccess key
+    => Bool
+    -- ^ @True@ for short keys that only need 12 rounds
+    -> key
+    -- ^ Input key padded to 16 bytes
+    -> Key
+    -- ^ Output data structure
 buildKey isShort key =
     let P x0123 x4567 = decomp64 (fromBE $ B.toW64BE key 0)
         P x89AB xCDEF = decomp64 (fromBE $ B.toW64BE key 8)
@@ -160,12 +163,10 @@
 
 keySchedule :: Bool -> Q -> Key
 keySchedule isShort x
-    | isShort   = K12 $ allocArray32AndFreeze 24 $ \ma ->
+    | isShort = K12 $ allocArray32AndFreeze 24 $ \ma ->
         void (steps123 ma 0 x >>= skip4 >>= steps123 ma 1)
-
     | otherwise = K16 $ allocArray32AndFreeze 32 $ \ma ->
         void (steps123 ma 0 x >>= step4 ma 24 >>= steps123 ma 1 >>= step4 ma 25)
-
   where
     sbox_s56785 a b c d e = sbox_s5 a `xor` sbox_s6 b `xor` sbox_s7 c `xor` sbox_s8 d `xor` sbox_s5 e
     sbox_s56786 a b c d e = sbox_s5 a `xor` sbox_s6 b `xor` sbox_s7 c `xor` sbox_s8 d `xor` sbox_s6 e
@@ -279,7 +280,9 @@
 sbox_s1 :: Word8 -> Word32
 sbox_s1 i = arrayRead32 t (fromIntegral i)
   where
-    t = array32FromAddrBE 256
+    t =
+        array32FromAddrBE
+            256
             "\x30\xfb\x40\xd4\x9f\xa0\xff\x0b\x6b\xec\xcd\x2f\x3f\x25\x8c\x7a\x1e\x21\x3f\x2f\x9c\x00\x4d\xd3\x60\x03\xe5\x40\xcf\x9f\xc9\x49\
             \\xbf\xd4\xaf\x27\x88\xbb\xbd\xb5\xe2\x03\x40\x90\x98\xd0\x96\x75\x6e\x63\xa0\xe0\x15\xc3\x61\xd2\xc2\xe7\x66\x1d\x22\xd4\xff\x8e\
             \\x28\x68\x3b\x6f\xc0\x7f\xd0\x59\xff\x23\x79\xc8\x77\x5f\x50\xe2\x43\xc3\x40\xd3\xdf\x2f\x86\x56\x88\x7c\xa4\x1a\xa2\xd2\xbd\x2d\
@@ -316,7 +319,9 @@
 sbox_s2 :: Word8 -> Word32
 sbox_s2 i = arrayRead32 t (fromIntegral i)
   where
-    t = array32FromAddrBE 256
+    t =
+        array32FromAddrBE
+            256
             "\x1f\x20\x10\x94\xef\x0b\xa7\x5b\x69\xe3\xcf\x7e\x39\x3f\x43\x80\xfe\x61\xcf\x7a\xee\xc5\x20\x7a\x55\x88\x9c\x94\x72\xfc\x06\x51\
             \\xad\xa7\xef\x79\x4e\x1d\x72\x35\xd5\x5a\x63\xce\xde\x04\x36\xba\x99\xc4\x30\xef\x5f\x0c\x07\x94\x18\xdc\xdb\x7d\xa1\xd6\xef\xf3\
             \\xa0\xb5\x2f\x7b\x59\xe8\x36\x05\xee\x15\xb0\x94\xe9\xff\xd9\x09\xdc\x44\x00\x86\xef\x94\x44\x59\xba\x83\xcc\xb3\xe0\xc3\xcd\xfb\
@@ -353,7 +358,9 @@
 sbox_s3 :: Word8 -> Word32
 sbox_s3 i = arrayRead32 t (fromIntegral i)
   where
-    t = array32FromAddrBE 256
+    t =
+        array32FromAddrBE
+            256
             "\x8d\xef\xc2\x40\x25\xfa\x5d\x9f\xeb\x90\x3d\xbf\xe8\x10\xc9\x07\x47\x60\x7f\xff\x36\x9f\xe4\x4b\x8c\x1f\xc6\x44\xae\xce\xca\x90\
             \\xbe\xb1\xf9\xbf\xee\xfb\xca\xea\xe8\xcf\x19\x50\x51\xdf\x07\xae\x92\x0e\x88\x06\xf0\xad\x05\x48\xe1\x3c\x8d\x83\x92\x70\x10\xd5\
             \\x11\x10\x7d\x9f\x07\x64\x7d\xb9\xb2\xe3\xe4\xd4\x3d\x4f\x28\x5e\xb9\xaf\xa8\x20\xfa\xde\x82\xe0\xa0\x67\x26\x8b\x82\x72\x79\x2e\
@@ -390,7 +397,9 @@
 sbox_s4 :: Word8 -> Word32
 sbox_s4 i = arrayRead32 t (fromIntegral i)
   where
-    t = array32FromAddrBE 256
+    t =
+        array32FromAddrBE
+            256
             "\x9d\xb3\x04\x20\x1f\xb6\xe9\xde\xa7\xbe\x7b\xef\xd2\x73\xa2\x98\x4a\x4f\x7b\xdb\x64\xad\x8c\x57\x85\x51\x04\x43\xfa\x02\x0e\xd1\
             \\x7e\x28\x7a\xff\xe6\x0f\xb6\x63\x09\x5f\x35\xa1\x79\xeb\xf1\x20\xfd\x05\x9d\x43\x64\x97\xb7\xb1\xf3\x64\x1f\x63\x24\x1e\x4a\xdf\
             \\x28\x14\x7f\x5f\x4f\xa2\xb8\xcd\xc9\x43\x00\x40\x0c\xc3\x22\x20\xfd\xd3\x0b\x30\xc0\xa5\x37\x4f\x1d\x2d\x00\xd9\x24\x14\x7b\x15\
@@ -427,7 +436,9 @@
 sbox_s5 :: Word8 -> Word32
 sbox_s5 i = arrayRead32 t (fromIntegral i)
   where
-    t = array32FromAddrBE 256
+    t =
+        array32FromAddrBE
+            256
             "\x7e\xc9\x0c\x04\x2c\x6e\x74\xb9\x9b\x0e\x66\xdf\xa6\x33\x79\x11\xb8\x6a\x7f\xff\x1d\xd3\x58\xf5\x44\xdd\x9d\x44\x17\x31\x16\x7f\
             \\x08\xfb\xf1\xfa\xe7\xf5\x11\xcc\xd2\x05\x1b\x00\x73\x5a\xba\x00\x2a\xb7\x22\xd8\x38\x63\x81\xcb\xac\xf6\x24\x3a\x69\xbe\xfd\x7a\
             \\xe6\xa2\xe7\x7f\xf0\xc7\x20\xcd\xc4\x49\x48\x16\xcc\xf5\xc1\x80\x38\x85\x16\x40\x15\xb0\xa8\x48\xe6\x8b\x18\xcb\x4c\xaa\xde\xff\
@@ -464,7 +475,9 @@
 sbox_s6 :: Word8 -> Word32
 sbox_s6 i = arrayRead32 t (fromIntegral i)
   where
-    t = array32FromAddrBE 256
+    t =
+        array32FromAddrBE
+            256
             "\xf6\xfa\x8f\x9d\x2c\xac\x6c\xe1\x4c\xa3\x48\x67\xe2\x33\x7f\x7c\x95\xdb\x08\xe7\x01\x68\x43\xb4\xec\xed\x5c\xbc\x32\x55\x53\xac\
             \\xbf\x9f\x09\x60\xdf\xa1\xe2\xed\x83\xf0\x57\x9d\x63\xed\x86\xb9\x1a\xb6\xa6\xb8\xde\x5e\xbe\x39\xf3\x8f\xf7\x32\x89\x89\xb1\x38\
             \\x33\xf1\x49\x61\xc0\x19\x37\xbd\xf5\x06\xc6\xda\xe4\x62\x5e\x7e\xa3\x08\xea\x99\x4e\x23\xe3\x3c\x79\xcb\xd7\xcc\x48\xa1\x43\x67\
@@ -501,7 +514,9 @@
 sbox_s7 :: Word8 -> Word32
 sbox_s7 i = arrayRead32 t (fromIntegral i)
   where
-    t = array32FromAddrBE 256
+    t =
+        array32FromAddrBE
+            256
             "\x85\xe0\x40\x19\x33\x2b\xf5\x67\x66\x2d\xbf\xff\xcf\xc6\x56\x93\x2a\x8d\x7f\x6f\xab\x9b\xc9\x12\xde\x60\x08\xa1\x20\x28\xda\x1f\
             \\x02\x27\xbc\xe7\x4d\x64\x29\x16\x18\xfa\xc3\x00\x50\xf1\x8b\x82\x2c\xb2\xcb\x11\xb2\x32\xe7\x5c\x4b\x36\x95\xf2\xb2\x87\x07\xde\
             \\xa0\x5f\xbc\xf6\xcd\x41\x81\xe9\xe1\x50\x21\x0c\xe2\x4e\xf1\xbd\xb1\x68\xc3\x81\xfd\xe4\xe7\x89\x5c\x79\xb0\xd8\x1e\x8b\xfd\x43\
@@ -538,7 +553,9 @@
 sbox_s8 :: Word8 -> Word32
 sbox_s8 i = arrayRead32 t (fromIntegral i)
   where
-    t = array32FromAddrBE 256
+    t =
+        array32FromAddrBE
+            256
             "\xe2\x16\x30\x0d\xbb\xdd\xff\xfc\xa7\xeb\xda\xbd\x35\x64\x80\x95\x77\x89\xf8\xb7\xe6\xc1\x12\x1b\x0e\x24\x16\x00\x05\x2c\xe8\xb5\
             \\x11\xa9\xcf\xb0\xe5\x95\x2f\x11\xec\xe7\x99\x0a\x93\x86\xd1\x74\x2a\x42\x93\x1c\x76\xe3\x81\x11\xb1\x2d\xef\x3a\x37\xdd\xdd\xfc\
             \\xde\x9a\xde\xb1\x0a\x0c\xc3\x2c\xbe\x19\x70\x29\x84\xa0\x09\x40\xbb\x24\x3a\x0f\xb4\xd1\x37\xcf\xb4\x4e\x79\xf0\x04\x9e\xed\xfd\
diff --git a/Crypto/Cipher/Camellia.hs b/Crypto/Cipher/Camellia.hs
--- a/Crypto/Cipher/Camellia.hs
+++ b/Crypto/Cipher/Camellia.hs
@@ -6,10 +6,9 @@
 -- Portability : Good
 --
 -- Camellia support. only 128 bit variant available for now.
-
-module Crypto.Cipher.Camellia
-    ( Camellia128
-    ) where
+module Crypto.Cipher.Camellia (
+    Camellia128,
+) where
 
 import Crypto.Cipher.Camellia.Primitive
 import Crypto.Cipher.Types
@@ -18,9 +17,9 @@
 newtype Camellia128 = Camellia128 Camellia
 
 instance Cipher Camellia128 where
-    cipherName    _ = "Camellia128"
+    cipherName _ = "Camellia128"
     cipherKeySize _ = KeySizeFixed 16
-    cipherInit k    = Camellia128 `fmap` initCamellia k
+    cipherInit k = Camellia128 `fmap` initCamellia k
 
 instance BlockCipher Camellia128 where
     blockSize _ = 16
diff --git a/Crypto/Cipher/Camellia/Primitive.hs b/Crypto/Cipher/Camellia/Primitive.hs
--- a/Crypto/Cipher/Camellia/Primitive.hs
+++ b/Crypto/Cipher/Camellia/Primitive.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE MagicHash #-}
 
 -- |
 -- Module      : Crypto.Cipher.Camellia.Primitive
@@ -8,23 +9,22 @@
 --
 -- This only cover Camellia 128 bits for now. The API will change once
 -- 192 and 256 mode are implemented too.
-{-# LANGUAGE MagicHash #-}
-module Crypto.Cipher.Camellia.Primitive
-    ( Camellia
-    , initCamellia
-    , encrypt
-    , decrypt
-    ) where
+module Crypto.Cipher.Camellia.Primitive (
+    Camellia,
+    initCamellia,
+    encrypt,
+    decrypt,
+) where
 
-import           Data.Word
-import           Data.Bits
+import Data.Bits
+import Data.Word
 
-import           Crypto.Error
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray)
+import Crypto.Error
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.Words
-import           Crypto.Internal.WordArray
-import           Data.Memory.Endian
+import Crypto.Internal.WordArray
+import Crypto.Internal.Words
+import Data.Memory.Endian
 
 data Mode = Decrypt | Encrypt
 
@@ -33,30 +33,32 @@
 
 w64tow8 :: Word64 -> (Word8, Word8, Word8, Word8, Word8, Word8, Word8, Word8)
 w64tow8 x = (t1, t2, t3, t4, t5, t6, t7, t8)
-    where
-        t1 = fromIntegral (x `shiftR` 56)
-        t2 = fromIntegral (x `shiftR` 48)
-        t3 = fromIntegral (x `shiftR` 40)
-        t4 = fromIntegral (x `shiftR` 32)
-        t5 = fromIntegral (x `shiftR` 24)
-        t6 = fromIntegral (x `shiftR` 16)
-        t7 = fromIntegral (x `shiftR` 8)
-        t8 = fromIntegral (x)
+  where
+    t1 = fromIntegral (x `shiftR` 56)
+    t2 = fromIntegral (x `shiftR` 48)
+    t3 = fromIntegral (x `shiftR` 40)
+    t4 = fromIntegral (x `shiftR` 32)
+    t5 = fromIntegral (x `shiftR` 24)
+    t6 = fromIntegral (x `shiftR` 16)
+    t7 = fromIntegral (x `shiftR` 8)
+    t8 = fromIntegral (x)
 
 w8tow64 :: (Word8, Word8, Word8, Word8, Word8, Word8, Word8, Word8) -> Word64
-w8tow64 (t1,t2,t3,t4,t5,t6,t7,t8) =
-    (fromIntegral t1 `shiftL` 56) .|.
-    (fromIntegral t2 `shiftL` 48) .|.
-    (fromIntegral t3 `shiftL` 40) .|.
-    (fromIntegral t4 `shiftL` 32) .|.
-    (fromIntegral t5 `shiftL` 24) .|.
-    (fromIntegral t6 `shiftL` 16) .|.
-    (fromIntegral t7 `shiftL` 8)  .|.
-    (fromIntegral t8)
+w8tow64 (t1, t2, t3, t4, t5, t6, t7, t8) =
+    (fromIntegral t1 `shiftL` 56)
+        .|. (fromIntegral t2 `shiftL` 48)
+        .|. (fromIntegral t3 `shiftL` 40)
+        .|. (fromIntegral t4 `shiftL` 32)
+        .|. (fromIntegral t5 `shiftL` 24)
+        .|. (fromIntegral t6 `shiftL` 16)
+        .|. (fromIntegral t7 `shiftL` 8)
+        .|. (fromIntegral t8)
 
 sbox :: Int -> Word8
 sbox = arrayRead8 t
-  where t = array8
+  where
+    t =
+        array8
             "\x70\x82\x2c\xec\xb3\x27\xc0\xe5\xe4\x85\x57\x35\xea\x0c\xae\x41\
             \\x23\xef\x6b\x93\x45\x19\xa5\x21\xed\x0e\x4f\x4e\x1d\x65\x92\xbd\
             \\x86\xb8\xaf\x8f\x7c\xeb\x1f\xce\x3e\x30\xdc\x5f\x5e\xc5\x0b\x1a\
@@ -95,116 +97,142 @@
 sigma6 = 0xB05688C2B3E6C1FD
 
 rotl128 :: Word128 -> Int -> Word128
-rotl128 v               0  = v
+rotl128 v 0 = v
 rotl128 (Word128 x1 x2) 64 = Word128 x2 x1
-
 rotl128 v@(Word128 x1 x2) w
-    | w > 64    = (v `rotl128` 64) `rotl128` (w - 64)
+    | w > 64 = (v `rotl128` 64) `rotl128` (w - 64)
     | otherwise = Word128 (x1high .|. x2low) (x2high .|. x1low)
-        where
-            splitBits i = (i .&. complement x, i .&. x)
-                where x = 2 ^ w - 1
-            (x1high, x1low) = splitBits (x1 `rotateL` w)
-            (x2high, x2low) = splitBits (x2 `rotateL` w)
+  where
+    splitBits i = (i .&. complement x, i .&. x)
+      where
+        x = 2 ^ w - 1
+    (x1high, x1low) = splitBits (x1 `rotateL` w)
+    (x2high, x2low) = splitBits (x2 `rotateL` w)
 
 -- | Camellia context
 data Camellia = Camellia
-    { k  :: Array64
+    { k :: Array64
     , kw :: Array64
     , ke :: Array64
     }
 
-setKeyInterim :: ByteArrayAccess key => key -> (Word128, Word128, Word128, Word128)
+setKeyInterim
+    :: ByteArrayAccess key => key -> (Word128, Word128, Word128, Word128)
 setKeyInterim keyseed = (w64tow128 kL, w64tow128 kR, w64tow128 kA, w64tow128 kB)
-  where kL = (fromBE $ B.toW64BE keyseed 0, fromBE $ B.toW64BE keyseed 8)
-        kR = (0, 0)
+  where
+    kL = (fromBE $ B.toW64BE keyseed 0, fromBE $ B.toW64BE keyseed 8)
+    kR = (0, 0)
 
-        kA = let d1 = (fst kL `xor` fst kR)
-                 d2 = (snd kL `xor` snd kR)
-                 d3 = d2 `xor` feistel d1 sigma1
-                 d4 = d1 `xor` feistel d3 sigma2
-                 d5 = d4 `xor` (fst kL)
-                 d6 = d3 `xor` (snd kL)
-                 d7 = d6 `xor` feistel d5 sigma3
-                 d8 = d5 `xor` feistel d7 sigma4
-              in (d8, d7)
+    kA =
+        let d1 = (fst kL `xor` fst kR)
+            d2 = (snd kL `xor` snd kR)
+            d3 = d2 `xor` feistel d1 sigma1
+            d4 = d1 `xor` feistel d3 sigma2
+            d5 = d4 `xor` (fst kL)
+            d6 = d3 `xor` (snd kL)
+            d7 = d6 `xor` feistel d5 sigma3
+            d8 = d5 `xor` feistel d7 sigma4
+         in (d8, d7)
 
-        kB = let d1 = (fst kA `xor` fst kR)
-                 d2 = (snd kA `xor` snd kR)
-                 d3 = d2 `xor` feistel d1 sigma5
-                 d4 = d1 `xor` feistel d3 sigma6
-              in (d4, d3)
+    kB =
+        let d1 = (fst kA `xor` fst kR)
+            d2 = (snd kA `xor` snd kR)
+            d3 = d2 `xor` feistel d1 sigma5
+            d4 = d1 `xor` feistel d3 sigma6
+         in (d4, d3)
 
 -- | Initialize a 128-bit key
 --
--- Return the initialized key or a error message if the given 
+-- Return the initialized key or a error message if the given
 -- keyseed was not 16-bytes in length.
-initCamellia :: ByteArray key
-             => key -- ^ The key to create the camellia context
-             -> CryptoFailable Camellia
+initCamellia
+    :: ByteArray key
+    => key
+    -- ^ The key to create the camellia context
+    -> CryptoFailable Camellia
 initCamellia key
     | B.length key /= 16 = CryptoFailed $ CryptoError_KeySizeInvalid
-    | otherwise          =
-        let (kL, _, kA, _) = setKeyInterim key in
-
-        let (Word128 kw1 kw2) = (kL `rotl128` 0) in
-        let (Word128 k1 k2)   = (kA `rotl128` 0) in
-        let (Word128 k3 k4)   = (kL `rotl128` 15) in
-        let (Word128 k5 k6)   = (kA `rotl128` 15) in
-        let (Word128 ke1 ke2) = (kA `rotl128` 30) in --ke1 = (KA <<<  30) >> 64; ke2 = (KA <<<  30) & MASK64;
-        let (Word128 k7 k8)   = (kL `rotl128` 45) in --k7  = (KL <<<  45) >> 64; k8  = (KL <<<  45) & MASK64;
-        let (Word128 k9 _)    = (kA `rotl128` 45) in --k9  = (KA <<<  45) >> 64;
-        let (Word128 _ k10)   = (kL `rotl128` 60) in
-        let (Word128 k11 k12) = (kA `rotl128` 60) in
-        let (Word128 ke3 ke4) = (kL `rotl128` 77) in
-        let (Word128 k13 k14) = (kL `rotl128` 94) in
-        let (Word128 k15 k16) = (kA `rotl128` 94) in
-        let (Word128 k17 k18) = (kL `rotl128` 111) in
-        let (Word128 kw3 kw4) = (kA `rotl128` 111) in
-
-        CryptoPassed $ Camellia
-            { kw = array64 4 [ kw1, kw2, kw3, kw4 ]
-            , ke = array64 4 [ ke1, ke2, ke3, ke4 ]
-            , k  = array64 18 [ k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12, k13, k14, k15, k16, k17, k18 ]
-            }
+    | otherwise =
+        let (kL, _, kA, _) = setKeyInterim key
+         in let (Word128 kw1 kw2) = (kL `rotl128` 0)
+             in let (Word128 k1 k2) = (kA `rotl128` 0)
+                 in let (Word128 k3 k4) = (kL `rotl128` 15)
+                     in let (Word128 k5 k6) = (kA `rotl128` 15)
+                         in let (Word128 ke1 ke2) = (kA `rotl128` 30) -- ke1 = (KA <<<  30) >> 64; ke2 = (KA <<<  30) & MASK64;
+                             in let (Word128 k7 k8) = (kL `rotl128` 45) -- k7  = (KL <<<  45) >> 64; k8  = (KL <<<  45) & MASK64;
+                                 in let (Word128 k9 _) = (kA `rotl128` 45) -- k9  = (KA <<<  45) >> 64;
+                                     in let (Word128 _ k10) = (kL `rotl128` 60)
+                                         in let (Word128 k11 k12) = (kA `rotl128` 60)
+                                             in let (Word128 ke3 ke4) = (kL `rotl128` 77)
+                                                 in let (Word128 k13 k14) = (kL `rotl128` 94)
+                                                     in let (Word128 k15 k16) = (kA `rotl128` 94)
+                                                         in let (Word128 k17 k18) = (kL `rotl128` 111)
+                                                             in let (Word128 kw3 kw4) = (kA `rotl128` 111)
+                                                                 in CryptoPassed $
+                                                                        Camellia
+                                                                            { kw = array64 4 [kw1, kw2, kw3, kw4]
+                                                                            , ke = array64 4 [ke1, ke2, ke3, ke4]
+                                                                            , k =
+                                                                                array64
+                                                                                    18
+                                                                                    [ k1
+                                                                                    , k2
+                                                                                    , k3
+                                                                                    , k4
+                                                                                    , k5
+                                                                                    , k6
+                                                                                    , k7
+                                                                                    , k8
+                                                                                    , k9
+                                                                                    , k10
+                                                                                    , k11
+                                                                                    , k12
+                                                                                    , k13
+                                                                                    , k14
+                                                                                    , k15
+                                                                                    , k16
+                                                                                    , k17
+                                                                                    , k18
+                                                                                    ]
+                                                                            }
 
 feistel :: Word64 -> Word64 -> Word64
-feistel fin sk = 
-    let x = fin `xor` sk in
-    let (t1, t2, t3, t4, t5, t6, t7, t8) = w64tow8 x in
-    let t1' = sbox1 t1 in
-    let t2' = sbox2 t2 in
-    let t3' = sbox3 t3 in
-    let t4' = sbox4 t4 in
-    let t5' = sbox2 t5 in
-    let t6' = sbox3 t6 in
-    let t7' = sbox4 t7 in
-    let t8' = sbox1 t8 in
-    let y1 = t1' `xor` t3' `xor` t4' `xor` t6' `xor` t7' `xor` t8' in
-    let y2 = t1' `xor` t2' `xor` t4' `xor` t5' `xor` t7' `xor` t8' in
-    let y3 = t1' `xor` t2' `xor` t3' `xor` t5' `xor` t6' `xor` t8' in
-    let y4 = t2' `xor` t3' `xor` t4' `xor` t5' `xor` t6' `xor` t7' in
-    let y5 = t1' `xor` t2' `xor` t6' `xor` t7' `xor` t8' in
-    let y6 = t2' `xor` t3' `xor` t5' `xor` t7' `xor` t8' in
-    let y7 = t3' `xor` t4' `xor` t5' `xor` t6' `xor` t8' in
-    let y8 = t1' `xor` t4' `xor` t5' `xor` t6' `xor` t7' in
-    w8tow64 (y1, y2, y3, y4, y5, y6, y7, y8)
+feistel fin sk =
+    let x = fin `xor` sk
+     in let (t1, t2, t3, t4, t5, t6, t7, t8) = w64tow8 x
+         in let t1' = sbox1 t1
+             in let t2' = sbox2 t2
+                 in let t3' = sbox3 t3
+                     in let t4' = sbox4 t4
+                         in let t5' = sbox2 t5
+                             in let t6' = sbox3 t6
+                                 in let t7' = sbox4 t7
+                                     in let t8' = sbox1 t8
+                                         in let y1 = t1' `xor` t3' `xor` t4' `xor` t6' `xor` t7' `xor` t8'
+                                             in let y2 = t1' `xor` t2' `xor` t4' `xor` t5' `xor` t7' `xor` t8'
+                                                 in let y3 = t1' `xor` t2' `xor` t3' `xor` t5' `xor` t6' `xor` t8'
+                                                     in let y4 = t2' `xor` t3' `xor` t4' `xor` t5' `xor` t6' `xor` t7'
+                                                         in let y5 = t1' `xor` t2' `xor` t6' `xor` t7' `xor` t8'
+                                                             in let y6 = t2' `xor` t3' `xor` t5' `xor` t7' `xor` t8'
+                                                                 in let y7 = t3' `xor` t4' `xor` t5' `xor` t6' `xor` t8'
+                                                                     in let y8 = t1' `xor` t4' `xor` t5' `xor` t6' `xor` t7'
+                                                                         in w8tow64 (y1, y2, y3, y4, y5, y6, y7, y8)
 
 fl :: Word64 -> Word64 -> Word64
 fl fin sk =
-    let (x1, x2) = w64to32 fin in
-    let (k1, k2) = w64to32 sk in
-    let y2 = x2 `xor` ((x1 .&. k1) `rotateL` 1) in
-    let y1 = x1 `xor` (y2 .|. k2) in
-    w32to64 (y1, y2)
+    let (x1, x2) = w64to32 fin
+     in let (k1, k2) = w64to32 sk
+         in let y2 = x2 `xor` ((x1 .&. k1) `rotateL` 1)
+             in let y1 = x1 `xor` (y2 .|. k2)
+                 in w32to64 (y1, y2)
 
 flinv :: Word64 -> Word64 -> Word64
 flinv fin sk =
-    let (y1, y2) = w64to32 fin in
-    let (k1, k2) = w64to32 sk in
-    let x1 = y1 `xor` (y2 .|. k2) in
-    let x2 = y2 `xor` ((x1 .&. k1) `rotateL` 1) in
-    w32to64 (x1, x2)
+    let (y1, y2) = w64to32 fin
+     in let (k1, k2) = w64to32 sk
+         in let x1 = y1 `xor` (y2 .|. k2)
+             in let x2 = y2 `xor` ((x1 .&. k1) `rotateL` 1)
+                 in w32to64 (x1, x2)
 
 {- in decrypt mode 0->17 1->16 ... -}
 getKeyK :: Mode -> Camellia -> Int -> Word64
@@ -231,34 +259,28 @@
  -}
 doBlockRound :: Mode -> Camellia -> Word64 -> Word64 -> Int -> (Word64, Word64)
 doBlockRound mode key d1 d2 i =
-    let r1 = d2 `xor` feistel d1 (getKeyK mode key (0+i)) in     {- Round 1+i -}
-    let r2 = d1 `xor` feistel r1 (getKeyK mode key (1+i)) in     {- Round 2+i -}
-    let r3 = r1 `xor` feistel r2 (getKeyK mode key (2+i)) in     {- Round 3+i -}
-    let r4 = r2 `xor` feistel r3 (getKeyK mode key (3+i)) in     {- Round 4+i -}
-    let r5 = r3 `xor` feistel r4 (getKeyK mode key (4+i)) in     {- Round 5+i -}
-    let r6 = r4 `xor` feistel r5 (getKeyK mode key (5+i)) in     {- Round 6+i -}
-    (r6, r5)
+    let r1 = d2 `xor` feistel d1 (getKeyK mode key (0 + i {- Round 1+i -}))
+     in let r2 = d1 `xor` feistel r1 (getKeyK mode key (1 + i {- Round 2+i -}))
+         in let r3 = r1 `xor` feistel r2 (getKeyK mode key (2 + i {- Round 3+i -}))
+             in let r4 = r2 `xor` feistel r3 (getKeyK mode key (3 + i {- Round 4+i -}))
+                 in let r5 = r3 `xor` feistel r4 (getKeyK mode key (4 + i {- Round 5+i -}))
+                     in let r6 = r4 `xor` feistel r5 (getKeyK mode key (5 + i {- Round 6+i -}))
+                         in (r6, r5)
 
 doBlock :: Mode -> Camellia -> Word128 -> Word128
 doBlock mode key (Word128 d1 d2) =
-    let d1a = d1 `xor` (getKeyKw mode key 0) in {- Prewhitening -}
-    let d2a = d2 `xor` (getKeyKw mode key 1) in
-
-    let (d1b, d2b) = doBlockRound mode key d1a d2a 0 in
-
-    let d1c = fl    d1b (getKeyKe mode key 0) in {- FL -}
-    let d2c = flinv d2b (getKeyKe mode key 1) in {- FLINV -}
-
-    let (d1d, d2d) = doBlockRound mode key d1c d2c 6 in
-
-    let d1e = fl    d1d (getKeyKe mode key 2) in {- FL -}
-    let d2e = flinv d2d (getKeyKe mode key 3) in {- FLINV -}
-
-    let (d1f, d2f) = doBlockRound mode key d1e d2e 12 in
-
-    let d2g = d2f `xor` (getKeyKw mode key 2) in {- Postwhitening -}
-    let d1g = d1f `xor` (getKeyKw mode key 3) in
-    w64tow128 (d2g, d1g)
+    let d1a = d1 `xor` (getKeyKw mode key 0 {- Prewhitening -})
+     in let d2a = d2 `xor` (getKeyKw mode key 1)
+         in let (d1b, d2b) = doBlockRound mode key d1a d2a 0
+             in let d1c = fl d1b (getKeyKe mode key 0 {- FL -})
+                 in let d2c = flinv d2b (getKeyKe mode key 1 {- FLINV -})
+                     in let (d1d, d2d) = doBlockRound mode key d1c d2c 6
+                         in let d1e = fl d1d (getKeyKe mode key 2 {- FL -})
+                             in let d2e = flinv d2d (getKeyKe mode key 3 {- FLINV -})
+                                 in let (d1f, d2f) = doBlockRound mode key d1e d2e 12
+                                     in let d2g = d2f `xor` (getKeyKw mode key 2 {- Postwhitening -})
+                                         in let d1g = d1f `xor` (getKeyKw mode key 3)
+                                             in w64tow128 (d2g, d1g)
 
 {- encryption for 128 bits blocks -}
 encryptBlock :: Camellia -> Word128 -> Word128
@@ -269,15 +291,21 @@
 decryptBlock = doBlock Decrypt
 
 -- | Encrypts the given ByteString using the given Key
-encrypt :: ByteArray ba
-        => Camellia     -- ^ The key to use
-        -> ba           -- ^ The data to encrypt
-        -> ba
+encrypt
+    :: ByteArray ba
+    => Camellia
+    -- ^ The key to use
+    -> ba
+    -- ^ The data to encrypt
+    -> ba
 encrypt key = B.mapAsWord128 (encryptBlock key)
 
 -- | Decrypts the given ByteString using the given Key
-decrypt :: ByteArray ba
-        => Camellia     -- ^ The key to use
-        -> ba           -- ^ The data to decrypt
-        -> ba
+decrypt
+    :: ByteArray ba
+    => Camellia
+    -- ^ The key to use
+    -> ba
+    -- ^ The data to decrypt
+    -> ba
 decrypt key = B.mapAsWord128 (decryptBlock key)
diff --git a/Crypto/Cipher/ChaCha.hs b/Crypto/Cipher/ChaCha.hs
--- a/Crypto/Cipher/ChaCha.hs
+++ b/Crypto/Cipher/ChaCha.hs
@@ -1,30 +1,40 @@
+{-# LANGUAGE CApiFFI #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.Cipher.ChaCha
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : stable
 -- Portability : good
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.Cipher.ChaCha
-    ( initialize
-    , initializeX
-    , combine
-    , generate
-    , State
+module Crypto.Cipher.ChaCha (
+    initialize,
+    initializeX,
+    combine,
+    generate,
+    State,
+
     -- * Simple interface for DRG purpose
-    , initializeSimple
-    , generateSimple
-    , StateSimple
-    ) where
+    initializeSimple,
+    generateSimple,
+    StateSimple,
 
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray, ScrubbedBytes)
+    -- * Seeking and cursor for DRG purposes
+    generateSimpleBlock,
+    ChaChaState (..),
+) where
+
+import Crypto.Internal.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    ScrubbedBytes,
+ )
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Foreign.Ptr
-import           Foreign.C.Types
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Foreign.C.Types
+import Foreign.Ptr
 
 -- | ChaCha context
 newtype State = State ScrubbedBytes
@@ -34,86 +44,160 @@
 newtype StateSimple = StateSimple ScrubbedBytes -- just ChaCha's state
     deriving (NFData)
 
+class ChaChaState a where
+    getCounter64 :: a -> Word64
+    setCounter64 :: Word64 -> a -> a
+    getCounter32 :: a -> Word32
+    setCounter32 :: Word32 -> a -> a
+
+instance ChaChaState State where
+    getCounter64 (State st) = getCounter64' st ccrypton_chacha_get_state
+    setCounter64 n (State st) = State $ setCounter64' n st ccrypton_chacha_get_state
+    getCounter32 (State st) = getCounter32' st ccrypton_chacha_get_state
+    setCounter32 n (State st) = State $ setCounter32' n st ccrypton_chacha_get_state
+
+instance ChaChaState StateSimple where
+    getCounter64 (StateSimple st) = getCounter64' st id
+    setCounter64 n (StateSimple st) = StateSimple $ setCounter64' n st id
+    getCounter32 (StateSimple st) = getCounter32' st id
+    setCounter32 n (StateSimple st) = StateSimple $ setCounter32' n st id
+
+getCounter64' :: ScrubbedBytes -> (Ptr a -> Ptr StateSimple) -> Word64
+getCounter64' currSt conv =
+    unsafeDoIO $ do
+        B.withByteArray currSt $ \stPtr ->
+            ccrypton_chacha_counter64 $ conv stPtr
+
+getCounter32' :: ScrubbedBytes -> (Ptr a -> Ptr StateSimple) -> Word32
+getCounter32' currSt conv =
+    unsafeDoIO $ do
+        B.withByteArray currSt $ \stPtr ->
+            ccrypton_chacha_counter32 $ conv stPtr
+
+setCounter64'
+    :: Word64 -> ScrubbedBytes -> (Ptr a -> Ptr StateSimple) -> ScrubbedBytes
+setCounter64' newCounter prevSt conv =
+    unsafeDoIO $ do
+        newSt <- B.copy prevSt (\_ -> return ())
+        B.withByteArray newSt $ \stPtr ->
+            ccrypton_chacha_set_counter64 (conv stPtr) newCounter
+        return newSt
+
+setCounter32'
+    :: Word32 -> ScrubbedBytes -> (Ptr a -> Ptr StateSimple) -> ScrubbedBytes
+setCounter32' newCounter prevSt conv =
+    unsafeDoIO $ do
+        newSt <- B.copy prevSt (\_ -> return ())
+        B.withByteArray newSt $ \stPtr ->
+            ccrypton_chacha_set_counter32 (conv stPtr) newCounter
+        return newSt
+
 -- | Initialize a new ChaCha context with the number of rounds,
 -- the key and the nonce associated.
-initialize :: (ByteArrayAccess key, ByteArrayAccess nonce)
-           => Int   -- ^ number of rounds (8,12,20)
-           -> key   -- ^ the key (128 or 256 bits)
-           -> nonce -- ^ the nonce (64 or 96 bits)
-           -> State -- ^ the initial ChaCha state
+-- To use ChaCha20 defined in RFC 8439, 20, 256bits-key and 96-bits nonce must be used.
+initialize
+    :: (ByteArrayAccess key, ByteArrayAccess nonce)
+    => Int
+    -- ^ number of rounds (8,12,20)
+    -> key
+    -- ^ the key (128 or 256 bits)
+    -> nonce
+    -- ^ the nonce (64 or 96 bits)
+    -> State
+    -- ^ the initial ChaCha state
 initialize nbRounds key nonce
-    | kLen `notElem` [16,32]          = error "ChaCha: key length should be 128 or 256 bits"
-    | nonceLen `notElem` [8,12]       = error "ChaCha: nonce length should be 64 or 96 bits"
-    | nbRounds `notElem` [8,12,20]    = error "ChaCha: rounds should be 8, 12 or 20"
-    | otherwise                       = unsafeDoIO $ do
+    | kLen `notElem` [16, 32] =
+        error "ChaCha: key length should be 128 or 256 bits"
+    | nonceLen `notElem` [8, 12] =
+        error "ChaCha: nonce length should be 64 or 96 bits"
+    | nbRounds `notElem` [8, 12, 20] = error "ChaCha: rounds should be 8, 12 or 20"
+    | otherwise = unsafeDoIO $ do
         stPtr <- B.alloc 132 $ \stPtr ->
-            B.withByteArray nonce $ \noncePtr  ->
-            B.withByteArray key   $ \keyPtr ->
-                ccrypton_chacha_init stPtr  nbRounds kLen keyPtr nonceLen noncePtr
+            B.withByteArray nonce $ \noncePtr ->
+                B.withByteArray key $ \keyPtr ->
+                    ccrypton_chacha_init stPtr nbRounds kLen keyPtr nonceLen noncePtr
         return $ State stPtr
-  where kLen     = B.length key
-        nonceLen = B.length nonce
+  where
+    kLen = B.length key
+    nonceLen = B.length nonce
 
 -- | Initialize a new XChaCha context with the number of rounds,
 -- the key and the nonce associated.
 --
 -- An XChaCha state can be used like a regular ChaCha state after initialisation.
-initializeX :: (ByteArrayAccess key, ByteArrayAccess nonce)
-            => Int   -- ^ number of rounds (8,12,20)
-            -> key   -- ^ the key (256 bits)
-            -> nonce -- ^ the nonce (192 bits)
-            -> State -- ^ the initial ChaCha state
+initializeX
+    :: (ByteArrayAccess key, ByteArrayAccess nonce)
+    => Int
+    -- ^ number of rounds (8,12,20)
+    -> key
+    -- ^ the key (256 bits)
+    -> nonce
+    -- ^ the nonce (192 bits)
+    -> State
+    -- ^ the initial ChaCha state
 initializeX nbRounds key nonce
-    | kLen /= 32                      = error "XChaCha: key length should be 256 bits"
-    | nonceLen /= 24                  = error "XChaCha: nonce length should be 192 bits"
-    | nbRounds `notElem` [8,12,20]    = error "XChaCha: rounds should be 8, 12 or 20"
-    | otherwise                       = unsafeDoIO $ do
+    | kLen /= 32 =
+        error "XChaCha: key length should be 256 bits"
+    | nonceLen /= 24 =
+        error "XChaCha: nonce length should be 192 bits"
+    | nbRounds `notElem` [8, 12, 20] =
+        error "XChaCha: rounds should be 8, 12 or 20"
+    | otherwise = unsafeDoIO $ do
         stPtr <- B.alloc 132 $ \stPtr ->
-            B.withByteArray nonce $ \noncePtr  ->
-            B.withByteArray key   $ \keyPtr ->
-                ccrypton_xchacha_init stPtr nbRounds keyPtr noncePtr
+            B.withByteArray nonce $ \noncePtr ->
+                B.withByteArray key $ \keyPtr ->
+                    ccrypton_xchacha_init stPtr nbRounds keyPtr noncePtr
         return $ State stPtr
-  where kLen     = B.length key
-        nonceLen = B.length nonce
+  where
+    kLen = B.length key
+    nonceLen = B.length nonce
 
 -- | Initialize simple ChaCha State
 --
 -- The seed need to be at least 40 bytes long
-initializeSimple :: ByteArrayAccess seed
-                 => seed -- ^ a 40 bytes long seed
-                 -> StateSimple
+initializeSimple
+    :: ByteArrayAccess seed
+    => seed
+    -- ^ a 40 bytes long seed
+    -> StateSimple
 initializeSimple seed
     | sLen < 40 = error "ChaCha Random: seed length should be 40 bytes"
     | otherwise = unsafeDoIO $ do
         stPtr <- B.alloc 64 $ \stPtr ->
-                    B.withByteArray seed $ \seedPtr ->
-                        ccrypton_chacha_init_core stPtr 32 seedPtr 8 (seedPtr `plusPtr` 32)
+            B.withByteArray seed $ \seedPtr ->
+                ccrypton_chacha_init_core stPtr 32 seedPtr 8 (seedPtr `plusPtr` 32)
         return $ StateSimple stPtr
   where
     sLen = B.length seed
 
 -- | Combine the chacha output and an arbitrary message with a xor,
 -- and return the combined output and the new state.
-combine :: ByteArray ba
-        => State       -- ^ the current ChaCha state
-        -> ba          -- ^ the source to xor with the generator
-        -> (ba, State)
+combine
+    :: ByteArray ba
+    => State
+    -- ^ the current ChaCha state
+    -> ba
+    -- ^ the source to xor with the generator
+    -> (ba, State)
 combine prevSt@(State prevStMem) src
     | B.null src = (B.empty, prevSt)
-    | otherwise  = unsafeDoIO $ do
+    | otherwise = unsafeDoIO $ do
         (out, st) <- B.copyRet prevStMem $ \ctx ->
             B.alloc (B.length src) $ \dstPtr ->
-            B.withByteArray src    $ \srcPtr ->
-                ccrypton_chacha_combine dstPtr ctx srcPtr (fromIntegral $ B.length src)
+                B.withByteArray src $ \srcPtr ->
+                    ccrypton_chacha_combine dstPtr ctx srcPtr (fromIntegral $ B.length src)
         return (out, State st)
 
 -- | Generate a number of bytes from the ChaCha output directly
-generate :: ByteArray ba
-         => State -- ^ the current ChaCha state
-         -> Int   -- ^ the length of data to generate
-         -> (ba, State)
+generate
+    :: ByteArray ba
+    => State
+    -- ^ the current ChaCha state
+    -> Int
+    -- ^ the length of data to generate
+    -> (ba, State)
 generate prevSt@(State prevStMem) len
-    | len <= 0  = (B.empty, prevSt)
+    | len <= 0 = (B.empty, prevSt)
     | otherwise = unsafeDoIO $ do
         (out, st) <- B.copyRet prevStMem $ \ctx ->
             B.alloc len $ \dstPtr ->
@@ -121,24 +205,43 @@
         return (out, State st)
 
 -- | similar to 'generate' but assume certains values
-generateSimple :: ByteArray ba
-               => StateSimple
-               -> Int
-               -> (ba, StateSimple)
+generateSimple
+    :: ByteArray ba
+    => StateSimple
+    -> Int
+    -> (ba, StateSimple)
 generateSimple (StateSimple prevSt) nbBytes = unsafeDoIO $ do
-    newSt  <- B.copy prevSt (\_ -> return ())
+    newSt <- B.copy prevSt (\_ -> return ())
     output <- B.alloc nbBytes $ \dstPtr ->
         B.withByteArray newSt $ \stPtr ->
             ccrypton_chacha_random 8 dstPtr stPtr (fromIntegral nbBytes)
     return (output, StateSimple newSt)
 
-foreign import ccall "crypton_chacha_init_core"
-    ccrypton_chacha_init_core :: Ptr StateSimple -> Int -> Ptr Word8 -> Int -> Ptr Word8 -> IO ()
+-- | similar to 'generate' but accepts a number of rounds, and always generates
+--   64 bytes (a single block)
+generateSimpleBlock
+    :: ByteArray ba
+    => Word8
+    -> StateSimple
+    -> (ba, StateSimple)
+generateSimpleBlock nbRounds (StateSimple prevSt)
+    | nbRounds `notElem` [8, 12, 20] = error "ChaCha: rounds should be 8, 12 or 20"
+    | otherwise = unsafeDoIO $ do
+        newSt <- B.copy prevSt (\_ -> return ())
+        output <- B.alloc 64 $ \dstPtr ->
+            B.withByteArray newSt $ \stPtr ->
+                ccrypton_chacha_generate_simple_block dstPtr stPtr nbRounds
+        return (output, StateSimple newSt)
 
-foreign import ccall "crypton_chacha_init"
-    ccrypton_chacha_init :: Ptr State -> Int -> Int -> Ptr Word8 -> Int -> Ptr Word8 -> IO ()
+foreign import ccall unsafe "crypton_chacha_init_core"
+    ccrypton_chacha_init_core
+        :: Ptr StateSimple -> Int -> Ptr Word8 -> Int -> Ptr Word8 -> IO ()
 
-foreign import ccall "crypton_xchacha_init"
+foreign import ccall unsafe "crypton_chacha_init"
+    ccrypton_chacha_init
+        :: Ptr State -> Int -> Int -> Ptr Word8 -> Int -> Ptr Word8 -> IO ()
+
+foreign import ccall unsafe "crypton_xchacha_init"
     ccrypton_xchacha_init :: Ptr State -> Int -> Ptr Word8 -> Ptr Word8 -> IO ()
 
 foreign import ccall "crypton_chacha_combine"
@@ -150,3 +253,21 @@
 foreign import ccall "crypton_chacha_random"
     ccrypton_chacha_random :: Int -> Ptr Word8 -> Ptr StateSimple -> CUInt -> IO ()
 
+foreign import ccall unsafe "crypton_chacha_counter64"
+    ccrypton_chacha_counter64 :: Ptr StateSimple -> IO Word64
+
+foreign import ccall unsafe "crypton_chacha_set_counter64"
+    ccrypton_chacha_set_counter64 :: Ptr StateSimple -> Word64 -> IO ()
+
+foreign import ccall unsafe "crypton_chacha_counter32"
+    ccrypton_chacha_counter32 :: Ptr StateSimple -> IO Word32
+
+foreign import ccall unsafe "crypton_chacha_set_counter32"
+    ccrypton_chacha_set_counter32 :: Ptr StateSimple -> Word32 -> IO ()
+
+foreign import ccall unsafe "crypton_chacha_generate_simple_block"
+    ccrypton_chacha_generate_simple_block
+        :: Ptr Word8 -> Ptr StateSimple -> Word8 -> IO ()
+
+foreign import capi unsafe "crypton_chacha.h crypton_chacha_get_state"
+    ccrypton_chacha_get_state :: Ptr State -> Ptr StateSimple
diff --git a/Crypto/Cipher/ChaChaPoly1305.hs b/Crypto/Cipher/ChaChaPoly1305.hs
--- a/Crypto/Cipher/ChaChaPoly1305.hs
+++ b/Crypto/Cipher/ChaChaPoly1305.hs
@@ -6,7 +6,7 @@
 -- Portability : good
 --
 -- A simple AEAD scheme using ChaCha20 and Poly1305. See
--- <https://tools.ietf.org/html/rfc7539 RFC 7539>.
+-- <https://tools.ietf.org/html/rfc8439 RFC 8439>.
 --
 -- The State is not modified in place, so each function changing the State,
 -- returns a new State.
@@ -34,63 +34,77 @@
 -- >        (out, st3) = C.encrypt plaintext st2
 -- >        auth = C.finalize st3
 -- >    return $ out `B.append` Data.ByteArray.convert auth
---
-module Crypto.Cipher.ChaChaPoly1305
-    ( State
-    , Nonce
-    , XNonce
-    , nonce12
-    , nonce8
-    , nonce24
-    , incrementNonce
-    , initialize
-    , initializeX
-    , appendAAD
-    , finalizeAAD
-    , encrypt
-    , decrypt
-    , finalize
-    ) where
+module Crypto.Cipher.ChaChaPoly1305 (
+    -- * AEAD
+    ChaCha20Poly1305,
+    aeadChacha20poly1305Init,
 
-import           Control.Monad             (when)
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray, Bytes, ScrubbedBytes)
-import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.Imports
-import           Crypto.Error
+    -- * Low level
+    State,
+    Nonce,
+    XNonce,
+    nonce12,
+    nonce8,
+    nonce24,
+    incrementNonce,
+    initialize,
+    initializeX,
+    appendAAD,
+    finalizeAAD,
+    encrypt,
+    decrypt,
+    finalize,
+) where
+
+import Control.Monad (when)
 import qualified Crypto.Cipher.ChaCha as ChaCha
-import qualified Crypto.MAC.Poly1305  as Poly1305
-import           Data.Memory.Endian
+import Crypto.Cipher.Types
+import Crypto.Error
+import Crypto.Internal.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    Bytes,
+    ScrubbedBytes,
+ )
+import qualified Crypto.Internal.ByteArray as B
+import Crypto.Internal.Imports
+import qualified Crypto.MAC.Poly1305 as Poly1305
 import qualified Data.ByteArray.Pack as P
-import           Foreign.Ptr
-import           Foreign.Storable
+import Data.Memory.Endian
+import Foreign.Ptr
+import Foreign.Storable
 
 -- | A ChaChaPoly1305 State.
 --
 -- The state is immutable, and only new state can be created
-data State = State !ChaCha.State
-                   !Poly1305.State
-                   !Word64 -- AAD length
-                   !Word64 -- ciphertext length
+data State
+    = State
+        !ChaCha.State
+        !Poly1305.State
+        !Word64 -- AAD length
+        !Word64 -- ciphertext length
 
+-- | A ChaChaPoly1305 State.
+type ChaCha20Poly1305 = State
+
 -- | Valid Nonce for ChaChaPoly1305.
 --
 -- It can be created with 'nonce8' or 'nonce12'
 data Nonce = Nonce8 Bytes | Nonce12 Bytes
 
 instance ByteArrayAccess Nonce where
-  length (Nonce8  n) = B.length n
-  length (Nonce12 n) = B.length n
+    length (Nonce8 n) = B.length n
+    length (Nonce12 n) = B.length n
 
-  withByteArray (Nonce8  n) = B.withByteArray n
-  withByteArray (Nonce12 n) = B.withByteArray n
+    withByteArray (Nonce8 n) = B.withByteArray n
+    withByteArray (Nonce12 n) = B.withByteArray n
 
 -- | Extended nonce for XChaChaPoly1305.
 newtype XNonce = Nonce24 Bytes
 
 instance ByteArrayAccess XNonce where
-  length (Nonce24 n) = B.length n
-  withByteArray (Nonce24 n) = B.withByteArray n
-
+    length (Nonce24 n) = B.length n
+    withByteArray (Nonce24 n) = B.withByteArray n
 
 -- Based on the following pseudo code:
 --
@@ -108,7 +122,7 @@
 pad16 :: Word64 -> Bytes
 pad16 n
     | modLen == 0 = B.empty
-    | otherwise   = B.replicate (16 - modLen) 0
+    | otherwise = B.replicate (16 - modLen) 0
   where
     modLen = fromIntegral (n `mod` 16)
 
@@ -116,78 +130,84 @@
 nonce12 :: ByteArrayAccess iv => iv -> CryptoFailable Nonce
 nonce12 iv
     | B.length iv /= 12 = CryptoFailed CryptoError_IvSizeInvalid
-    | otherwise         = CryptoPassed . Nonce12 . B.convert $ iv
+    | otherwise = CryptoPassed . Nonce12 . B.convert $ iv
 
 -- | 8 bytes IV, nonce constructor
-nonce8 :: ByteArrayAccess ba
-       => ba -- ^ 4 bytes constant
-       -> ba -- ^ 8 bytes IV
-       -> CryptoFailable Nonce
+nonce8
+    :: ByteArrayAccess ba
+    => ba
+    -- ^ 4 bytes constant
+    -> ba
+    -- ^ 8 bytes IV
+    -> CryptoFailable Nonce
 nonce8 constant iv
     | B.length constant /= 4 = CryptoFailed CryptoError_IvSizeInvalid
-    | B.length iv       /= 8 = CryptoFailed CryptoError_IvSizeInvalid
-    | otherwise              = CryptoPassed . Nonce8 . B.concat $ [constant, iv]
+    | B.length iv /= 8 = CryptoFailed CryptoError_IvSizeInvalid
+    | otherwise = CryptoPassed . Nonce8 . B.concat $ [constant, iv]
 
 -- | 24 bytes IV, extended nonce constructor
-nonce24 :: ByteArrayAccess ba
-        => ba -> CryptoFailable XNonce
+nonce24
+    :: ByteArrayAccess ba
+    => ba -> CryptoFailable XNonce
 nonce24 iv
     | B.length iv /= 24 = CryptoFailed CryptoError_IvSizeInvalid
-    | otherwise         = CryptoPassed . Nonce24 . B.convert $ iv
+    | otherwise = CryptoPassed . Nonce24 . B.convert $ iv
 
 -- | Increment a nonce
 incrementNonce :: Nonce -> Nonce
-incrementNonce (Nonce8  n) = Nonce8  $ incrementNonce' n 4
+incrementNonce (Nonce8 n) = Nonce8 $ incrementNonce' n 4
 incrementNonce (Nonce12 n) = Nonce12 $ incrementNonce' n 0
 
 incrementNonce' :: Bytes -> Int -> Bytes
 incrementNonce' b offset = B.copyAndFreeze b $ \s ->
     loop s (s `plusPtr` offset)
-    where
-      loop :: Ptr Word8 -> Ptr Word8 -> IO ()
-      loop s p
-          | s == (p `plusPtr` (B.length b - offset - 1)) = peek s >>= poke s . (+) 1
-          | otherwise = do
-              r <- (+) 1 <$> peek p
-              poke p r
-              when (r == 0) $ loop s (p `plusPtr` 1)
+  where
+    loop :: Ptr Word8 -> Ptr Word8 -> IO ()
+    loop s p
+        | s == (p `plusPtr` (B.length b - offset - 1)) = peek s >>= poke s . (+) 1
+        | otherwise = do
+            r <- (+) 1 <$> peek p
+            poke p r
+            when (r == 0) $ loop s (p `plusPtr` 1)
 
 -- | Initialize a new ChaChaPoly1305 State
 --
 -- The key length need to be 256 bits, and the nonce
 -- procured using either `nonce8` or `nonce12`
-initialize :: ByteArrayAccess key
-           => key -> Nonce -> CryptoFailable State
-initialize key (Nonce8  nonce) = initialize' key nonce
+initialize
+    :: ByteArrayAccess key
+    => key -> Nonce -> CryptoFailable State
+initialize key (Nonce8 nonce) = initialize' key nonce
 initialize key (Nonce12 nonce) = initialize' key nonce
 
-
-initialize' :: ByteArrayAccess key
-            => key -> Bytes -> CryptoFailable State
+initialize'
+    :: ByteArrayAccess key
+    => key -> Bytes -> CryptoFailable State
 initialize' key nonce
     | B.length key /= 32 = CryptoFailed CryptoError_KeySizeInvalid
-    | otherwise          = CryptoPassed $ initFromRootState rootState
-  where rootState = ChaCha.initialize 20 key nonce
-
+    | otherwise = CryptoPassed $ initFromRootState rootState
+  where
+    rootState = ChaCha.initialize 20 key nonce
 
 initFromRootState :: ChaCha.State -> State
 initFromRootState rootState = State encState polyState 0 0
   where
     (polyKey, encState) = ChaCha.generate rootState 64
-    polyState           = throwCryptoError $ Poly1305.initialize (B.take 32 polyKey :: ScrubbedBytes)
-
+    polyState =
+        throwCryptoError $ Poly1305.initialize (B.take 32 polyKey :: ScrubbedBytes)
 
 -- | Initialize a new XChaChaPoly1305 State
 --
 -- The key length needs to be 256 bits, and the nonce
 -- procured using `nonce24`.
-initializeX :: ByteArrayAccess key
-            => key -> XNonce -> CryptoFailable State
+initializeX
+    :: ByteArrayAccess key
+    => key -> XNonce -> CryptoFailable State
 initializeX key (Nonce24 nonce)
     | B.length key /= 32 = CryptoFailed CryptoError_KeySizeInvalid
-    | otherwise          = CryptoPassed $ initFromRootState rootState
-  where rootState = ChaCha.initializeX 20 key nonce
-
+    | otherwise = CryptoPassed $ initFromRootState rootState
+  where
+    rootState = ChaCha.initializeX 20 key nonce
 
 -- | Append Authenticated Data to the State and return
 -- the new modified State.
@@ -199,7 +219,7 @@
     State encState newMacState newLength plainLength
   where
     newMacState = Poly1305.update macState ba
-    newLength   = aadLength + fromIntegral (B.length ba)
+    newLength = aadLength + fromIntegral (B.length ba)
 
 -- | Finalize the Authenticated Data and return the finalized State
 finalizeAAD :: State -> State
@@ -215,8 +235,8 @@
     (output, State newEncState newMacState aadLength newPlainLength)
   where
     (output, newEncState) = ChaCha.combine encState input
-    newMacState           = Poly1305.update macState output
-    newPlainLength        = plainLength + fromIntegral (B.length input)
+    newMacState = Poly1305.update macState output
+    newPlainLength = plainLength + fromIntegral (B.length input)
 
 -- | Decrypt a piece of data and returns the decrypted Data and the
 -- updated State.
@@ -225,13 +245,32 @@
     (output, State newEncState newMacState aadLength newPlainLength)
   where
     (output, newEncState) = ChaCha.combine encState input
-    newMacState           = Poly1305.update macState input
-    newPlainLength        = plainLength + fromIntegral (B.length input)
+    newMacState = Poly1305.update macState input
+    newPlainLength = plainLength + fromIntegral (B.length input)
 
 -- | Generate an authentication tag from the State.
 finalize :: State -> Poly1305.Auth
 finalize (State _ macState aadLength plainLength) =
-    Poly1305.finalize $ Poly1305.updates macState
-        [ pad16 plainLength
-        , either (error "finalize: internal error") id $ P.fill 16 (P.putStorable (toLE aadLength) >> P.putStorable (toLE plainLength))
-        ]
+    Poly1305.finalize $
+        Poly1305.updates
+            macState
+            [ pad16 plainLength
+            , either (error "finalize: internal error") id $
+                P.fill 16 (P.putStorable (toLE aadLength) >> P.putStorable (toLE plainLength))
+            ]
+
+-- | Setting up AEAD for ChaCha20Poly1305.
+aeadChacha20poly1305Init
+    :: (ByteArrayAccess k, ByteArrayAccess n)
+    => k -> n -> CryptoFailable (AEAD ChaCha20Poly1305)
+aeadChacha20poly1305Init key nonce = do
+    st0 <- nonce12 nonce >>= initialize key
+    return $ AEAD model st0
+  where
+    model =
+        AEADModeImpl
+            { aeadImplAppendHeader = \st aad -> finalizeAAD $ appendAAD aad st
+            , aeadImplEncrypt = \st plain -> encrypt plain st
+            , aeadImplDecrypt = \st cipher -> decrypt cipher st
+            , aeadImplFinalize = \st _ -> let Poly1305.Auth tag = finalize st in AuthTag tag
+            }
diff --git a/Crypto/Cipher/DES.hs b/Crypto/Cipher/DES.hs
--- a/Crypto/Cipher/DES.hs
+++ b/Crypto/Cipher/DES.hs
@@ -4,27 +4,26 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : stable
 -- Portability : good
---
-module Crypto.Cipher.DES
-    ( DES
-    ) where
+module Crypto.Cipher.DES (
+    DES,
+) where
 
-import           Data.Word
-import           Crypto.Error
-import           Crypto.Cipher.Types
-import           Crypto.Cipher.DES.Primitive
-import           Crypto.Internal.ByteArray (ByteArrayAccess)
+import Crypto.Cipher.DES.Primitive
+import Crypto.Cipher.Types
+import Crypto.Error
+import Crypto.Internal.ByteArray (ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B
-import           Data.Memory.Endian
+import Data.Memory.Endian
+import Data.Word
 
 -- | DES Context
 data DES = DES Word64
     deriving (Eq)
 
 instance Cipher DES where
-    cipherName    _ = "DES"
+    cipherName _ = "DES"
     cipherKeySize _ = KeySizeFixed 8
-    cipherInit k    = initDES k
+    cipherInit k = initDES k
 
 instance BlockCipher DES where
     blockSize _ = 8
@@ -33,7 +32,8 @@
 
 initDES :: ByteArrayAccess key => key -> CryptoFailable DES
 initDES k
-    | len == 8  = CryptoPassed $ DES key
+    | len == 8 = CryptoPassed $ DES key
     | otherwise = CryptoFailed $ CryptoError_KeySizeInvalid
-  where len = B.length k
-        key = fromBE $ B.toW64BE k 0
+  where
+    len = B.length k
+    key = fromBE $ B.toW64BE k 0
diff --git a/Crypto/Cipher/DES/Primitive.hs b/Crypto/Cipher/DES/Primitive.hs
--- a/Crypto/Cipher/DES/Primitive.hs
+++ b/Crypto/Cipher/DES/Primitive.hs
@@ -1,33 +1,32 @@
 {-# LANGUAGE FlexibleInstances #-}
 
 -----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+
 -- |
 -- Module      :  Crypto.Cipher.DES.Primitive
 -- License     :  BSD-style
 --
 -- This module is copy of DES module from Crypto package.
 -- http://hackage.haskell.org/package/Crypto
---
------------------------------------------------------------------------------
-
-
-module Crypto.Cipher.DES.Primitive
-    ( encrypt
-    , decrypt
-    , Block(..)
-    ) where
+module Crypto.Cipher.DES.Primitive (
+    encrypt,
+    decrypt,
+    Block (..),
+) where
 
-import Data.Word
 import Data.Bits
+import Data.Word
 
 -- | a DES block (64 bits)
-newtype Block = Block { unBlock :: Word64 }
+newtype Block = Block {unBlock :: Word64}
 
 type Rotation = Int
-type Key     = Word64
+type Key = Word64
 
-type Bits4  = [Bool]
-type Bits6  = [Bool]
+type Bits4 = [Bool]
+type Bits6 = [Bool]
 type Bits32 = [Bool]
 type Bits48 = [Bool]
 type Bits56 = [Bool]
@@ -38,20 +37,84 @@
 
 desRotate :: [Bool] -> Int -> [Bool]
 desRotate bits rot = drop rot' bits ++ take rot' bits
-  where rot' = rot `mod` length bits
+  where
+    rot' = rot `mod` length bits
 
 bitify :: Word64 -> Bits64
-bitify w = map (\b -> w .&. (shiftL 1 b) /= 0) [63,62..0]
+bitify w = map (\b -> w .&. (shiftL 1 b) /= 0) [63, 62 .. 0]
 
 unbitify :: Bits64 -> Word64
 unbitify bs = foldl (\i b -> if b then 1 + shiftL i 1 else shiftL i 1) 0 bs
 
 initial_permutation :: Bits64 -> Bits64
 initial_permutation mb = map ((!!) mb) i
- where i = [57, 49, 41, 33, 25, 17,  9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
-            61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7,
-            56, 48, 40, 32, 24, 16,  8, 0, 58, 50, 42, 34, 26, 18, 10, 2,
-            60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6]
+  where
+    i =
+        [ 57
+        , 49
+        , 41
+        , 33
+        , 25
+        , 17
+        , 9
+        , 1
+        , 59
+        , 51
+        , 43
+        , 35
+        , 27
+        , 19
+        , 11
+        , 3
+        , 61
+        , 53
+        , 45
+        , 37
+        , 29
+        , 21
+        , 13
+        , 5
+        , 63
+        , 55
+        , 47
+        , 39
+        , 31
+        , 23
+        , 15
+        , 7
+        , 56
+        , 48
+        , 40
+        , 32
+        , 24
+        , 16
+        , 8
+        , 0
+        , 58
+        , 50
+        , 42
+        , 34
+        , 26
+        , 18
+        , 10
+        , 2
+        , 60
+        , 52
+        , 44
+        , 36
+        , 28
+        , 20
+        , 12
+        , 4
+        , 62
+        , 54
+        , 46
+        , 38
+        , 30
+        , 22
+        , 14
+        , 6
+        ]
 
 {-
 "\x39\x31\x29\x21\x19\x11\x09\x01\x3b\x33\x2b\x23\x1b\x13\
@@ -63,10 +126,66 @@
 
 key_transformation :: Bits64 -> Bits56
 key_transformation kb = map ((!!) kb) i
- where i = [56, 48, 40, 32, 24, 16,  8,  0, 57, 49, 41, 33, 25, 17,
-             9,  1, 58, 50, 42, 34, 26, 18, 10,  2, 59, 51, 43, 35,
-            62, 54, 46, 38, 30, 22, 14,  6, 61, 53, 45, 37, 29, 21,
-            13,  5, 60, 52, 44, 36, 28, 20, 12,  4, 27, 19, 11,  3]
+  where
+    i =
+        [ 56
+        , 48
+        , 40
+        , 32
+        , 24
+        , 16
+        , 8
+        , 0
+        , 57
+        , 49
+        , 41
+        , 33
+        , 25
+        , 17
+        , 9
+        , 1
+        , 58
+        , 50
+        , 42
+        , 34
+        , 26
+        , 18
+        , 10
+        , 2
+        , 59
+        , 51
+        , 43
+        , 35
+        , 62
+        , 54
+        , 46
+        , 38
+        , 30
+        , 22
+        , 14
+        , 6
+        , 61
+        , 53
+        , 45
+        , 37
+        , 29
+        , 21
+        , 13
+        , 5
+        , 60
+        , 52
+        , 44
+        , 36
+        , 28
+        , 20
+        , 12
+        , 4
+        , 27
+        , 19
+        , 11
+        , 3
+        ]
+
 {-
 "\x38\x30\x28\x20\x18\x10\x08\x00\x39\x31\x29\x21\x19\x11\
 \\x09\x01\x3a\x32\x2a\x22\x1a\x12\x0a\x02\x3b\x33\x2b\x23\
@@ -74,143 +193,371 @@
 \\x0d\x05\x3c\x34\x2c\x24\x1c\x14\x0c\x04\x1b\x13\x0b\x03"
 -}
 
-
 des_enc :: Block -> Key -> Block
-des_enc = do_des [1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28]
+des_enc = do_des [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28]
 
 des_dec :: Block -> Key -> Block
-des_dec = do_des [28,27,25,23,21,19,17,15,14,12,10,8,6,4,2,1]
+des_dec = do_des [28, 27, 25, 23, 21, 19, 17, 15, 14, 12, 10, 8, 6, 4, 2, 1]
 
 do_des :: [Rotation] -> Block -> Key -> Block
 do_des rots (Block m) k = Block $ des_work rots (takeDrop 32 mb) kb
- where kb = key_transformation $ bitify k
-       mb = initial_permutation $ bitify m
+  where
+    kb = key_transformation $ bitify k
+    mb = initial_permutation $ bitify m
 
 des_work :: [Rotation] -> (Bits32, Bits32) -> Bits56 -> Word64
 des_work [] (ml, mr) _ = unbitify $ final_perm $ (mr ++ ml)
-des_work (r:rs) mb kb = des_work rs mb' kb
- where mb' = do_round r mb kb
+des_work (r : rs) mb kb = des_work rs mb' kb
+  where
+    mb' = do_round r mb kb
 
 do_round :: Rotation -> (Bits32, Bits32) -> Bits56 -> (Bits32, Bits32)
 do_round r (ml, mr) kb = (mr, m')
- where kb' = get_key kb r
-       comp_kb = compression_permutation kb'
-       expa_mr = expansion_permutation mr
-       res = comp_kb `desXor` expa_mr
-       res' = tail $ iterate (trans 6) ([], res)
-       trans n (_, b) = (take n b, drop n b)
-       res_s = concat $ zipWith (\f (x,_) -> f x) [s_box_1, s_box_2,
-                                                   s_box_3, s_box_4,
-                                                   s_box_5, s_box_6,
-                                                   s_box_7, s_box_8] res'
-       res_p = p_box res_s
-       m' = res_p `desXor` ml
+  where
+    kb' = get_key kb r
+    comp_kb = compression_permutation kb'
+    expa_mr = expansion_permutation mr
+    res = comp_kb `desXor` expa_mr
+    res' = drop 1 $ iterate (trans 6) ([], res)
+    trans n (_, b) = (take n b, drop n b)
+    res_s =
+        concat $
+            zipWith
+                (\f (x, _) -> f x)
+                [ s_box_1
+                , s_box_2
+                , s_box_3
+                , s_box_4
+                , s_box_5
+                , s_box_6
+                , s_box_7
+                , s_box_8
+                ]
+                res'
+    res_p = p_box res_s
+    m' = res_p `desXor` ml
 
 get_key :: Bits56 -> Rotation -> Bits56
 get_key kb r = kb'
- where (kl, kr) = takeDrop 28 kb
-       kb' = desRotate kl r ++ desRotate kr r
+  where
+    (kl, kr) = takeDrop 28 kb
+    kb' = desRotate kl r ++ desRotate kr r
 
 compression_permutation :: Bits56 -> Bits48
 compression_permutation kb = map ((!!) kb) i
- where i = [13, 16, 10, 23,  0,  4,  2, 27, 14,  5, 20,  9,
-            22, 18, 11,  3, 25,  7, 15,  6, 26, 19, 12,  1,
-            40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
-            43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31]
+  where
+    i =
+        [ 13
+        , 16
+        , 10
+        , 23
+        , 0
+        , 4
+        , 2
+        , 27
+        , 14
+        , 5
+        , 20
+        , 9
+        , 22
+        , 18
+        , 11
+        , 3
+        , 25
+        , 7
+        , 15
+        , 6
+        , 26
+        , 19
+        , 12
+        , 1
+        , 40
+        , 51
+        , 30
+        , 36
+        , 46
+        , 54
+        , 29
+        , 39
+        , 50
+        , 44
+        , 32
+        , 47
+        , 43
+        , 48
+        , 38
+        , 55
+        , 33
+        , 52
+        , 45
+        , 41
+        , 49
+        , 35
+        , 28
+        , 31
+        ]
 
 expansion_permutation :: Bits32 -> Bits48
 expansion_permutation mb = map ((!!) mb) i
- where i = [31,  0,  1,  2,  3,  4,  3,  4,  5,  6,  7,  8,
-             7,  8,  9, 10, 11, 12, 11, 12, 13, 14, 15, 16,
-            15, 16, 17, 18, 19, 20, 19, 20, 21, 22, 23, 24,
-            23, 24, 25, 26, 27, 28, 27, 28, 29, 30, 31,  0]
+  where
+    i =
+        [ 31
+        , 0
+        , 1
+        , 2
+        , 3
+        , 4
+        , 3
+        , 4
+        , 5
+        , 6
+        , 7
+        , 8
+        , 7
+        , 8
+        , 9
+        , 10
+        , 11
+        , 12
+        , 11
+        , 12
+        , 13
+        , 14
+        , 15
+        , 16
+        , 15
+        , 16
+        , 17
+        , 18
+        , 19
+        , 20
+        , 19
+        , 20
+        , 21
+        , 22
+        , 23
+        , 24
+        , 23
+        , 24
+        , 25
+        , 26
+        , 27
+        , 28
+        , 27
+        , 28
+        , 29
+        , 30
+        , 31
+        , 0
+        ]
 
 s_box :: [[Word8]] -> Bits6 -> Bits4
-s_box s [a,b,c,d,e,f] = to_bool 4 $ (s !! row) !! col
- where row = sum $ zipWith numericise [a,f]     [1, 0]
-       col = sum $ zipWith numericise [b,c,d,e] [3, 2, 1, 0]
-       numericise :: Bool -> Int -> Int
-       numericise = (\x y -> if x then 2^y else 0)
+s_box s [a, b, c, d, e, f] = to_bool 4 $ (s !! row) !! col
+  where
+    row = sum $ zipWith numericise [a, f] [1, 0]
+    col = sum $ zipWith numericise [b, c, d, e] [3, 2, 1, 0]
+    numericise :: Bool -> Int -> Int
+    numericise = (\x y -> if x then 2 ^ y else 0)
 
-       to_bool :: Int -> Word8 -> [Bool]
-       to_bool 0 _ = []
-       to_bool n i = ((i .&. 8) == 8):to_bool (n-1) (shiftL i 1)
-s_box _ _             = error "DES: internal error bits6 more than 6 elements"
+    to_bool :: Int -> Word8 -> [Bool]
+    to_bool 0 _ = []
+    to_bool n i = ((i .&. 8) == 8) : to_bool (n - 1) (shiftL i 1)
+s_box _ _ = error "DES: internal error bits6 more than 6 elements"
 
 s_box_1 :: Bits6 -> Bits4
 s_box_1 = s_box i
- where i = [[14,  4, 13,  1,  2, 15, 11,  8,  3, 10,  6, 12,  5,  9,  0,  7],
-            [ 0, 15,  7,  4, 14,  2, 13,  1, 10,  6, 12, 11,  9,  5,  3,  8],
-            [ 4,  1, 14,  8, 13,  6,  2, 11, 15, 12,  9,  7,  3, 10,  5,  0],
-            [15, 12,  8,  2,  4,  9,  1,  7,  5, 11,  3, 14, 10,  0,  6, 13]]
+  where
+    i =
+        [ [14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7]
+        , [0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8]
+        , [4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0]
+        , [15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13]
+        ]
 
 s_box_2 :: Bits6 -> Bits4
 s_box_2 = s_box i
- where i = [[15,  1,  8, 14,  6, 11,  3,  4,  9,  7,  2, 13, 12,  0,  5, 10],
-            [3,  13,  4,  7, 15,  2,  8, 14, 12,  0,  1, 10,  6,  9,  11, 5],
-            [0,  14,  7, 11, 10,  4, 13,  1,  5,  8, 12,  6,  9,  3,  2, 15],
-            [13,  8, 10,  1,  3, 15,  4,  2, 11,  6,  7, 12,  0,  5,  14, 9]]
+  where
+    i =
+        [ [15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10]
+        , [3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5]
+        , [0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15]
+        , [13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9]
+        ]
 
 s_box_3 :: Bits6 -> Bits4
 s_box_3 = s_box i
- where i = [[10,  0,  9, 14 , 6,  3, 15,  5,  1, 13, 12,  7, 11,  4,  2,  8],
-            [13,  7,  0,  9,  3,  4,  6, 10,  2,  8,  5, 14, 12, 11, 15,  1],
-            [13,  6,  4,  9,  8, 15,  3,  0, 11,  1,  2, 12,  5, 10, 14,  7],
-            [1,  10, 13,  0,  6,  9,  8,  7,  4, 15, 14,  3, 11,  5,  2, 12]]
+  where
+    i =
+        [ [10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8]
+        , [13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1]
+        , [13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7]
+        , [1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12]
+        ]
 
 s_box_4 :: Bits6 -> Bits4
 s_box_4 = s_box i
- where i = [[7,  13, 14,  3,  0,  6,  9, 10,  1,  2,  8,  5, 11, 12,  4, 15],
-            [13,  8, 11,  5,  6, 15,  0,  3,  4,  7,  2, 12,  1, 10, 14,  9],
-            [10,  6,  9,  0, 12, 11,  7, 13, 15,  1,  3, 14,  5,  2,  8,  4],
-            [3,  15,  0,  6, 10,  1, 13,  8,  9,  4,  5, 11, 12,  7,  2, 14]]
+  where
+    i =
+        [ [7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15]
+        , [13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9]
+        , [10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4]
+        , [3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14]
+        ]
 
 s_box_5 :: Bits6 -> Bits4
 s_box_5 = s_box i
- where i = [[2,  12,  4,  1,  7, 10, 11,  6,  8,  5,  3, 15, 13,  0, 14,  9],
-            [14, 11,  2, 12,  4,  7, 13,  1,  5,  0, 15, 10,  3,  9,  8,  6],
-            [4,   2,  1, 11, 10, 13,  7,  8, 15,  9, 12,  5,  6,  3,  0, 14],
-            [11,  8, 12,  7,  1, 14,  2, 13,  6, 15,  0,  9, 10,  4,  5,  3]]
+  where
+    i =
+        [ [2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9]
+        , [14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6]
+        , [4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14]
+        , [11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3]
+        ]
 
 s_box_6 :: Bits6 -> Bits4
 s_box_6 = s_box i
- where i = [[12,  1, 10, 15,  9,  2,  6,  8,  0, 13,  3,  4, 14,  7,  5, 11],
-            [10, 15,  4,  2,  7, 12,  9,  5,  6,  1, 13, 14,  0, 11,  3,  8],
-            [9,  14, 15,  5,  2,  8, 12,  3,  7,  0,  4, 10,  1, 13, 11,  6],
-            [4,  3,   2, 12,  9,  5, 15, 10, 11, 14,  1,  7,  6,  0,  8, 13]]
+  where
+    i =
+        [ [12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11]
+        , [10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8]
+        , [9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6]
+        , [4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13]
+        ]
 
 s_box_7 :: Bits6 -> Bits4
 s_box_7 = s_box i
- where i = [[4,  11,  2, 14, 15,  0,  8, 13,  3, 12,  9,  7,  5, 10,  6,  1],
-            [13, 0,  11,  7,  4,  9,  1, 10, 14,  3,  5, 12,  2, 15,  8,  6],
-            [1,  4,  11, 13, 12,  3,  7, 14, 10, 15,  6,  8,  0,  5,  9,  2],
-            [6,  11, 13,  8,  1,  4, 10,  7,  9,  5,  0, 15, 14,  2,  3, 12]]
+  where
+    i =
+        [ [4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1]
+        , [13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6]
+        , [1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2]
+        , [6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12]
+        ]
 
 s_box_8 :: Bits6 -> Bits4
 s_box_8 = s_box i
- where i = [[13,  2,  8,  4,  6, 15, 11,  1, 10,  9,  3, 14,  5,  0, 12,  7],
-            [1,  15, 13,  8, 10,  3,  7,  4, 12,  5,  6, 11,  0, 14,  9,  2],
-            [7,  11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8],
-            [2,   1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11]]
+  where
+    i =
+        [ [13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7]
+        , [1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2]
+        , [7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8]
+        , [2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11]
+        ]
 
 p_box :: Bits32 -> Bits32
 p_box kb = map ((!!) kb) i
- where i = [15, 6, 19, 20, 28, 11, 27, 16,  0, 14, 22, 25,  4, 17, 30,  9,
-             1, 7, 23, 13, 31, 26,  2,  8, 18, 12, 29,  5, 21, 10,  3, 24]
+  where
+    i =
+        [ 15
+        , 6
+        , 19
+        , 20
+        , 28
+        , 11
+        , 27
+        , 16
+        , 0
+        , 14
+        , 22
+        , 25
+        , 4
+        , 17
+        , 30
+        , 9
+        , 1
+        , 7
+        , 23
+        , 13
+        , 31
+        , 26
+        , 2
+        , 8
+        , 18
+        , 12
+        , 29
+        , 5
+        , 21
+        , 10
+        , 3
+        , 24
+        ]
 
 final_perm :: Bits64 -> Bits64
 final_perm kb = map ((!!) kb) i
- where i = [39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30,
-            37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28,
-            35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26,
-            33, 1, 41,  9, 49, 17, 57, 25, 32, 0, 40 , 8, 48, 16, 56, 24]
+  where
+    i =
+        [ 39
+        , 7
+        , 47
+        , 15
+        , 55
+        , 23
+        , 63
+        , 31
+        , 38
+        , 6
+        , 46
+        , 14
+        , 54
+        , 22
+        , 62
+        , 30
+        , 37
+        , 5
+        , 45
+        , 13
+        , 53
+        , 21
+        , 61
+        , 29
+        , 36
+        , 4
+        , 44
+        , 12
+        , 52
+        , 20
+        , 60
+        , 28
+        , 35
+        , 3
+        , 43
+        , 11
+        , 51
+        , 19
+        , 59
+        , 27
+        , 34
+        , 2
+        , 42
+        , 10
+        , 50
+        , 18
+        , 58
+        , 26
+        , 33
+        , 1
+        , 41
+        , 9
+        , 49
+        , 17
+        , 57
+        , 25
+        , 32
+        , 0
+        , 40
+        , 8
+        , 48
+        , 16
+        , 56
+        , 24
+        ]
 
 takeDrop :: Int -> [a] -> ([a], [a])
 takeDrop _ [] = ([], [])
 takeDrop 0 xs = ([], xs)
-takeDrop n (x:xs) = (x:ys, zs)
- where (ys, zs) = takeDrop (n-1) xs
-
+takeDrop n (x : xs) = (x : ys, zs)
+  where
+    (ys, zs) = takeDrop (n - 1) xs
 
 -- | Basic DES encryption which takes a key and a block of plaintext
 -- and returns the encrypted block of ciphertext according to the standard.
diff --git a/Crypto/Cipher/RC4.hs b/Crypto/Cipher/RC4.hs
--- a/Crypto/Cipher/RC4.hs
+++ b/Crypto/Cipher/RC4.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.Cipher.RC4
 -- License     : BSD-style
@@ -11,23 +14,24 @@
 -- Initial FFI implementation by Peter White <peter@janrain.com>
 --
 -- Reorganized and simplified to have an opaque context.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.Cipher.RC4
-    ( initialize
-    , combine
-    , generate
-    , State
-    ) where
+module Crypto.Cipher.RC4 (
+    initialize,
+    combine,
+    generate,
+    State,
+) where
 
-import           Data.Word
-import           Foreign.Ptr
-import           Crypto.Internal.ByteArray (ScrubbedBytes, ByteArray, ByteArrayAccess)
+import Crypto.Internal.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    ScrubbedBytes,
+ )
 import qualified Crypto.Internal.ByteArray as B
+import Data.Word
+import Foreign.Ptr
 
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
 
 -- | The encryption state for RC4
 --
@@ -36,29 +40,41 @@
 -- and change in future versions.  The bytearray should not be used as input to
 -- cryptographic algorithms.
 newtype State = State ScrubbedBytes
-    deriving (ByteArrayAccess,NFData)
+    deriving (ByteArrayAccess, NFData)
 
 -- | C Call for initializing the encryptor
 foreign import ccall unsafe "crypton_rc4.h crypton_rc4_init"
-    c_rc4_init :: Ptr Word8 -- ^ The rc4 key
-               -> Word32    -- ^ The key length
-               -> Ptr State -- ^ The context
-               -> IO ()
+    c_rc4_init
+        :: Ptr Word8
+        -- ^ The rc4 key
+        -> Word32
+        -- ^ The key length
+        -> Ptr State
+        -- ^ The context
+        -> IO ()
 
 foreign import ccall unsafe "crypton_rc4.h crypton_rc4_combine"
-    c_rc4_combine :: Ptr State        -- ^ Pointer to the permutation
-                  -> Ptr Word8      -- ^ Pointer to the clear text
-                  -> Word32         -- ^ Length of the clear text
-                  -> Ptr Word8      -- ^ Output buffer
-                  -> IO ()
+    c_rc4_combine
+        :: Ptr State
+        -- ^ Pointer to the permutation
+        -> Ptr Word8
+        -- ^ Pointer to the clear text
+        -> Word32
+        -- ^ Length of the clear text
+        -> Ptr Word8
+        -- ^ Output buffer
+        -> IO ()
 
 -- | RC4 context initialization.
 --
 -- seed the context with an initial key. the key size need to be
 -- adequate otherwise security takes a hit.
-initialize :: ByteArrayAccess key
-           => key   -- ^ The key
-           -> State -- ^ The RC4 context with the key mixed in
+initialize
+    :: ByteArrayAccess key
+    => key
+    -- ^ The key
+    -> State
+    -- ^ The RC4 context with the key mixed in
 initialize key = unsafeDoIO $ do
     st <- B.alloc 264 $ \stPtr ->
         B.withByteArray key $ \keyPtr -> c_rc4_init keyPtr (fromIntegral $ B.length key) (castPtr stPtr)
@@ -70,15 +86,20 @@
 generate ctx len = combine ctx (B.zero len)
 
 -- | RC4 xor combination of the rc4 stream with an input
-combine :: ByteArray ba
-        => State               -- ^ rc4 context
-        -> ba                  -- ^ input
-        -> (State, ba)         -- ^ new rc4 context, and the output
+combine
+    :: ByteArray ba
+    => State
+    -- ^ rc4 context
+    -> ba
+    -- ^ input
+    -> (State, ba)
+    -- ^ new rc4 context, and the output
 combine (State prevSt) clearText = unsafeDoIO $
-    B.allocRet len            $ \outptr ->
-    B.withByteArray clearText $ \clearPtr -> do
-        st <- B.copy prevSt $ \stPtr ->
+    B.allocRet len $ \outptr ->
+        B.withByteArray clearText $ \clearPtr -> do
+            st <- B.copy prevSt $ \stPtr ->
                 c_rc4_combine (castPtr stPtr) clearPtr (fromIntegral len) outptr
-        return $! State st
-    --return $! (State st, B.PS outfptr 0 len)
-  where len = B.length clearText
+            return $! State st
+  where
+    -- return $! (State st, B.PS outfptr 0 len)
+    len = B.length clearText
diff --git a/Crypto/Cipher/Salsa.hs b/Crypto/Cipher/Salsa.hs
--- a/Crypto/Cipher/Salsa.hs
+++ b/Crypto/Cipher/Salsa.hs
@@ -1,25 +1,29 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.Cipher.Salsa
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : stable
 -- Portability : good
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.Cipher.Salsa
-    ( initialize
-    , combine
-    , generate
-    , State(..)
-    ) where
+module Crypto.Cipher.Salsa (
+    initialize,
+    combine,
+    generate,
+    State (..),
+) where
 
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray, ScrubbedBytes)
+import Crypto.Internal.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    ScrubbedBytes,
+ )
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Foreign.Ptr
-import           Foreign.C.Types
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Foreign.C.Types
+import Foreign.Ptr
 
 -- | Salsa context
 newtype State = State ScrubbedBytes
@@ -27,46 +31,60 @@
 
 -- | Initialize a new Salsa context with the number of rounds,
 -- the key and the nonce associated.
-initialize :: (ByteArrayAccess key, ByteArrayAccess nonce)
-           => Int    -- ^ number of rounds (8,12,20)
-           -> key    -- ^ the key (128 or 256 bits)
-           -> nonce  -- ^ the nonce (64 or 96 bits)
-           -> State  -- ^ the initial Salsa state
+initialize
+    :: (ByteArrayAccess key, ByteArrayAccess nonce)
+    => Int
+    -- ^ number of rounds (8,12,20)
+    -> key
+    -- ^ the key (128 or 256 bits)
+    -> nonce
+    -- ^ the nonce (64 or 96 bits)
+    -> State
+    -- ^ the initial Salsa state
 initialize nbRounds key nonce
-    | kLen `notElem` [16,32]          = error "Salsa: key length should be 128 or 256 bits"
-    | nonceLen `notElem` [8,12]       = error "Salsa: nonce length should be 64 or 96 bits"
-    | nbRounds `notElem` [8,12,20]    = error "Salsa: rounds should be 8, 12 or 20"
+    | kLen `notElem` [16, 32] =
+        error "Salsa: key length should be 128 or 256 bits"
+    | nonceLen `notElem` [8, 12] =
+        error "Salsa: nonce length should be 64 or 96 bits"
+    | nbRounds `notElem` [8, 12, 20] = error "Salsa: rounds should be 8, 12 or 20"
     | otherwise = unsafeDoIO $ do
         stPtr <- B.alloc 132 $ \stPtr ->
-            B.withByteArray nonce $ \noncePtr  ->
-            B.withByteArray key   $ \keyPtr ->
-                ccrypton_salsa_init stPtr nbRounds kLen keyPtr nonceLen noncePtr
+            B.withByteArray nonce $ \noncePtr ->
+                B.withByteArray key $ \keyPtr ->
+                    ccrypton_salsa_init stPtr nbRounds kLen keyPtr nonceLen noncePtr
         return $ State stPtr
-  where kLen     = B.length key
-        nonceLen = B.length nonce
+  where
+    kLen = B.length key
+    nonceLen = B.length nonce
 
 -- | Combine the salsa output and an arbitrary message with a xor,
 -- and return the combined output and the new state.
-combine :: ByteArray ba
-        => State      -- ^ the current Salsa state
-        -> ba         -- ^ the source to xor with the generator
-        -> (ba, State)
+combine
+    :: ByteArray ba
+    => State
+    -- ^ the current Salsa state
+    -> ba
+    -- ^ the source to xor with the generator
+    -> (ba, State)
 combine prevSt@(State prevStMem) src
     | B.null src = (B.empty, prevSt)
-    | otherwise  = unsafeDoIO $ do
+    | otherwise = unsafeDoIO $ do
         (out, st) <- B.copyRet prevStMem $ \ctx ->
             B.alloc (B.length src) $ \dstPtr ->
-            B.withByteArray src    $ \srcPtr -> do
-                ccrypton_salsa_combine dstPtr ctx srcPtr (fromIntegral $ B.length src)
+                B.withByteArray src $ \srcPtr -> do
+                    ccrypton_salsa_combine dstPtr ctx srcPtr (fromIntegral $ B.length src)
         return (out, State st)
 
 -- | Generate a number of bytes from the Salsa output directly
-generate :: ByteArray ba
-         => State -- ^ the current Salsa state
-         -> Int   -- ^ the length of data to generate
-         -> (ba, State)
+generate
+    :: ByteArray ba
+    => State
+    -- ^ the current Salsa state
+    -> Int
+    -- ^ the length of data to generate
+    -> (ba, State)
 generate prevSt@(State prevStMem) len
-    | len <= 0  = (B.empty, prevSt)
+    | len <= 0 = (B.empty, prevSt)
     | otherwise = unsafeDoIO $ do
         (out, st) <- B.copyRet prevStMem $ \ctx ->
             B.alloc len $ \dstPtr ->
@@ -74,7 +92,8 @@
         return (out, State st)
 
 foreign import ccall "crypton_salsa_init"
-    ccrypton_salsa_init :: Ptr State -> Int -> Int -> Ptr Word8 -> Int -> Ptr Word8 -> IO ()
+    ccrypton_salsa_init
+        :: Ptr State -> Int -> Int -> Ptr Word8 -> Int -> Ptr Word8 -> IO ()
 
 foreign import ccall "crypton_salsa_combine"
     ccrypton_salsa_combine :: Ptr Word8 -> Ptr State -> Ptr Word8 -> CUInt -> IO ()
diff --git a/Crypto/Cipher/TripleDES.hs b/Crypto/Cipher/TripleDES.hs
--- a/Crypto/Cipher/TripleDES.hs
+++ b/Crypto/Cipher/TripleDES.hs
@@ -3,28 +3,27 @@
 -- License     : BSD-style
 -- Stability   : experimental
 -- Portability : ???
-
-module Crypto.Cipher.TripleDES
-    ( DES_EEE3
-    , DES_EDE3
-    , DES_EEE2
-    , DES_EDE2
-    ) where
+module Crypto.Cipher.TripleDES (
+    DES_EEE3,
+    DES_EDE3,
+    DES_EEE2,
+    DES_EDE2,
+) where
 
-import           Data.Word
-import           Crypto.Error
-import           Crypto.Cipher.Types
-import           Crypto.Cipher.DES.Primitive
-import           Crypto.Internal.ByteArray (ByteArrayAccess)
+import Crypto.Cipher.DES.Primitive
+import Crypto.Cipher.Types
+import Crypto.Error
+import Crypto.Internal.ByteArray (ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B
-import           Data.Memory.Endian
+import Data.Memory.Endian
+import Data.Word
 
 -- | 3DES with 3 different keys used all in the same direction
 data DES_EEE3 = DES_EEE3 Word64 Word64 Word64
     deriving (Eq)
 
 -- | 3DES with 3 different keys used in alternative direction
-data DES_EDE3 = DES_EDE3 Word64 Word64 Word64 
+data DES_EDE3 = DES_EDE3 Word64 Word64 Word64
     deriving (Eq)
 
 -- | 3DES where the first and third keys are equal, used in the same direction
@@ -36,24 +35,24 @@
     deriving (Eq)
 
 instance Cipher DES_EEE3 where
-    cipherName    _ = "3DES_EEE"
+    cipherName _ = "3DES_EEE"
     cipherKeySize _ = KeySizeFixed 24
-    cipherInit k    = init3DES DES_EEE3 k
+    cipherInit k = init3DES DES_EEE3 k
 
 instance Cipher DES_EDE3 where
-    cipherName    _ = "3DES_EDE"
+    cipherName _ = "3DES_EDE"
     cipherKeySize _ = KeySizeFixed 24
-    cipherInit k    = init3DES DES_EDE3 k
+    cipherInit k = init3DES DES_EDE3 k
 
 instance Cipher DES_EDE2 where
-    cipherName    _ = "2DES_EDE"
+    cipherName _ = "2DES_EDE"
     cipherKeySize _ = KeySizeFixed 16
-    cipherInit k    = init2DES DES_EDE2 k
+    cipherInit k = init2DES DES_EDE2 k
 
 instance Cipher DES_EEE2 where
-    cipherName    _ = "2DES_EEE"
+    cipherName _ = "2DES_EEE"
     cipherKeySize _ = KeySizeFixed 16
-    cipherInit k    = init2DES DES_EEE2 k
+    cipherInit k = init2DES DES_EEE2 k
 
 instance BlockCipher DES_EEE3 where
     blockSize _ = 8
@@ -75,16 +74,21 @@
     ecbEncrypt (DES_EDE2 k1 k2) = B.mapAsWord64 (unBlock . (encrypt k1 . decrypt k2 . encrypt k1) . Block)
     ecbDecrypt (DES_EDE2 k1 k2) = B.mapAsWord64 (unBlock . (decrypt k1 . encrypt k2 . decrypt k1) . Block)
 
-init3DES :: ByteArrayAccess key => (Word64 -> Word64 -> Word64 -> a) -> key -> CryptoFailable a
+init3DES
+    :: ByteArrayAccess key
+    => (Word64 -> Word64 -> Word64 -> a) -> key -> CryptoFailable a
 init3DES constr k
     | len == 24 = CryptoPassed $ constr k1 k2 k3
     | otherwise = CryptoFailed CryptoError_KeySizeInvalid
-  where len = B.length k
-        (k1, k2, k3) = (fromBE $ B.toW64BE k 0, fromBE $ B.toW64BE k 8, fromBE $ B.toW64BE k 16)
+  where
+    len = B.length k
+    (k1, k2, k3) = (fromBE $ B.toW64BE k 0, fromBE $ B.toW64BE k 8, fromBE $ B.toW64BE k 16)
 
-init2DES :: ByteArrayAccess key => (Word64 -> Word64 -> a) -> key -> CryptoFailable a
+init2DES
+    :: ByteArrayAccess key => (Word64 -> Word64 -> a) -> key -> CryptoFailable a
 init2DES constr k
     | len == 16 = CryptoPassed $ constr k1 k2
     | otherwise = CryptoFailed CryptoError_KeySizeInvalid
-  where len = B.length k
-        (k1, k2) = (fromBE $ B.toW64BE k 0, fromBE $ B.toW64BE k 8)
+  where
+    len = B.length k
+    (k1, k2) = (fromBE $ B.toW64BE k 0, fromBE $ B.toW64BE k 8)
diff --git a/Crypto/Cipher/Twofish.hs b/Crypto/Cipher/Twofish.hs
--- a/Crypto/Cipher/Twofish.hs
+++ b/Crypto/Cipher/Twofish.hs
@@ -1,8 +1,8 @@
-module Crypto.Cipher.Twofish
-    ( Twofish128
-    , Twofish192
-    , Twofish256
-    ) where
+module Crypto.Cipher.Twofish (
+    Twofish128,
+    Twofish192,
+    Twofish256,
+) where
 
 import Crypto.Cipher.Twofish.Primitive
 import Crypto.Cipher.Types
@@ -11,35 +11,38 @@
 newtype Twofish128 = Twofish128 Twofish
 
 instance Cipher Twofish128 where
-    cipherName    _ = "Twofish128"
+    cipherName _ = "Twofish128"
     cipherKeySize _ = KeySizeFixed 16
-    cipherInit key  = Twofish128 <$> (initTwofish =<< validateKeySize (undefined :: Twofish128) key)
+    cipherInit key =
+        Twofish128 <$> (initTwofish =<< validateKeySize (undefined :: Twofish128) key)
 
 instance BlockCipher Twofish128 where
-    blockSize                 _ = 16
+    blockSize _ = 16
     ecbEncrypt (Twofish128 key) = encrypt key
     ecbDecrypt (Twofish128 key) = decrypt key
 
 newtype Twofish192 = Twofish192 Twofish
 
 instance Cipher Twofish192 where
-    cipherName    _ = "Twofish192"
+    cipherName _ = "Twofish192"
     cipherKeySize _ = KeySizeFixed 24
-    cipherInit key  = Twofish192 <$> (initTwofish =<< validateKeySize (undefined :: Twofish192) key)
+    cipherInit key =
+        Twofish192 <$> (initTwofish =<< validateKeySize (undefined :: Twofish192) key)
 
 instance BlockCipher Twofish192 where
-    blockSize                 _ = 16
+    blockSize _ = 16
     ecbEncrypt (Twofish192 key) = encrypt key
     ecbDecrypt (Twofish192 key) = decrypt key
 
 newtype Twofish256 = Twofish256 Twofish
 
 instance Cipher Twofish256 where
-    cipherName    _ = "Twofish256"
+    cipherName _ = "Twofish256"
     cipherKeySize _ = KeySizeFixed 32
-    cipherInit key  = Twofish256 <$> (initTwofish =<< validateKeySize (undefined :: Twofish256) key)
+    cipherInit key =
+        Twofish256 <$> (initTwofish =<< validateKeySize (undefined :: Twofish256) key)
 
 instance BlockCipher Twofish256 where
-    blockSize                 _ = 16
+    blockSize _ = 16
     ecbEncrypt (Twofish256 key) = encrypt key
     ecbDecrypt (Twofish256 key) = decrypt key
diff --git a/Crypto/Cipher/Twofish/Primitive.hs b/Crypto/Cipher/Twofish/Primitive.hs
--- a/Crypto/Cipher/Twofish/Primitive.hs
+++ b/Crypto/Cipher/Twofish/Primitive.hs
@@ -1,39 +1,45 @@
-{-# LANGUAGE MagicHash #-}
 {-# LANGUAGE BangPatterns #-}
-module Crypto.Cipher.Twofish.Primitive
-    ( Twofish
-    , initTwofish
-    , encrypt
-    , decrypt
-    ) where
+{-# LANGUAGE MagicHash #-}
+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
 
-import           Crypto.Error
-import           Crypto.Internal.ByteArray (ByteArray)
+module Crypto.Cipher.Twofish.Primitive (
+    Twofish,
+    initTwofish,
+    encrypt,
+    decrypt,
+) where
+
+import Crypto.Error
+import Crypto.Internal.ByteArray (ByteArray)
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.WordArray
-import           Data.Word
-import           Data.Bits
-import           Data.List
+import Crypto.Internal.WordArray
+import Data.Bits
+import Data.List (foldl')
+import Data.Word
+import Prelude hiding (foldl')
 
 -- Based on the Golang referance implementation
 -- https://github.com/golang/crypto/blob/master/twofish/twofish.go
 
-
 -- BlockSize is the constant block size of Twofish.
 blockSize :: Int
 blockSize = 16
 
 mdsPolynomial, rsPolynomial :: Word32
 mdsPolynomial = 0x169 -- x^8 + x^6 + x^5 + x^3 + 1, see [TWOFISH] 4.2
-rsPolynomial = 0x14d  -- x^8 + x^6 + x^3 + x^2 + 1, see [TWOFISH] 4.3
+rsPolynomial = 0x14d -- x^8 + x^6 + x^3 + x^2 + 1, see [TWOFISH] 4.3
 
-data Twofish = Twofish { s :: (Array32, Array32, Array32, Array32)
-                       , k :: Array32 }
+data Twofish = Twofish
+    { s :: (Array32, Array32, Array32, Array32)
+    , k :: Array32
+    }
 
 data ByteSize = Bytes16 | Bytes24 | Bytes32 deriving (Eq)
 
-data KeyPackage ba = KeyPackage { rawKeyBytes :: ba
-                                , byteSize :: ByteSize }
+data KeyPackage ba = KeyPackage
+    { rawKeyBytes :: ba
+    , byteSize :: ByteSize
+    }
 
 buildPackage :: ByteArray ba => ba -> Maybe (KeyPackage ba)
 buildPackage key
@@ -46,89 +52,159 @@
 --
 -- Return the initialized key or a error message if the given
 -- keyseed was not 16-bytes in length.
-initTwofish :: ByteArray key
-            => key -- ^ The key to create the twofish context
-            -> CryptoFailable Twofish
+initTwofish
+    :: ByteArray key
+    => key
+    -- ^ The key to create the twofish context
+    -> CryptoFailable Twofish
 initTwofish key =
-    case buildPackage key of Nothing -> CryptoFailed CryptoError_KeySizeInvalid
-                             Just keyPackage -> CryptoPassed Twofish { k = generatedK, s = generatedS }
-                                  where generatedK = array32 40 $ genK keyPackage
-                                        generatedS = genSboxes keyPackage $ sWords key
+    case buildPackage key of
+        Nothing -> CryptoFailed CryptoError_KeySizeInvalid
+        Just keyPackage -> CryptoPassed Twofish{k = generatedK, s = generatedS}
+          where
+            generatedK = array32 40 $ genK keyPackage
+            generatedS = genSboxes keyPackage $ sWords key
 
 mapBlocks :: ByteArray ba => (ba -> ba) -> ba -> ba
 mapBlocks operation input
     | B.null rest = blockOutput
     | otherwise = blockOutput `B.append` mapBlocks operation rest
-        where (block, rest) = B.splitAt blockSize input
-              blockOutput = operation block
+  where
+    (block, rest) = B.splitAt blockSize input
+    blockOutput = operation block
 
 -- | Encrypts the given ByteString using the given Key
-encrypt :: ByteArray ba
-        => Twofish     -- ^ The key to use
-        -> ba           -- ^ The data to encrypt
-        -> ba
+encrypt
+    :: ByteArray ba
+    => Twofish
+    -- ^ The key to use
+    -> ba
+    -- ^ The data to encrypt
+    -> ba
 encrypt cipher = mapBlocks (encryptBlock cipher)
 
 encryptBlock :: ByteArray ba => Twofish -> ba -> ba
-encryptBlock Twofish { s = (s1, s2, s3, s4), k = ks } message = store32ls ts
-    where (a, b, c, d) = load32ls message
-          a' = a `xor` arrayRead32 ks 0
-          b' = b `xor` arrayRead32 ks 1
-          c' = c `xor` arrayRead32 ks 2
-          d' = d `xor` arrayRead32 ks 3
-          (!a'', !b'', !c'', !d'') = foldl' shuffle (a', b', c', d') [0..7]
-          ts = (c'' `xor` arrayRead32 ks 4, d'' `xor` arrayRead32 ks 5, a'' `xor` arrayRead32 ks 6, b'' `xor` arrayRead32 ks 7)
+encryptBlock Twofish{s = (s1, s2, s3, s4), k = ks} message = store32ls ts
+  where
+    (a, b, c, d) = load32ls message
+    a' = a `xor` arrayRead32 ks 0
+    b' = b `xor` arrayRead32 ks 1
+    c' = c `xor` arrayRead32 ks 2
+    d' = d `xor` arrayRead32 ks 3
+    (!a'', !b'', !c'', !d'') = foldl' shuffle (a', b', c', d') [0 .. 7]
+    ts =
+        ( c'' `xor` arrayRead32 ks 4
+        , d'' `xor` arrayRead32 ks 5
+        , a'' `xor` arrayRead32 ks 6
+        , b'' `xor` arrayRead32 ks 7
+        )
 
-          shuffle :: (Word32, Word32, Word32, Word32) -> Int -> (Word32, Word32, Word32, Word32)
-          shuffle (!retA, !retB, !retC, !retD) ind = (retA', retB', retC', retD')
-            where [k0, k1, k2, k3] = fmap (\offset -> arrayRead32 ks $ (8 + 4 * ind) + offset) [0..3]
-                  t2 = byteIndex s2 retB `xor` byteIndex s3 (shiftR retB 8) `xor` byteIndex s4 (shiftR retB 16) `xor` byteIndex s1 (shiftR retB 24)
-                  t1 = (byteIndex s1 retA `xor` byteIndex s2 (shiftR retA 8) `xor` byteIndex s3 (shiftR retA 16) `xor` byteIndex s4 (shiftR retA 24)) + t2
-                  retC' = rotateR (retC `xor` (t1 + k0)) 1
-                  retD' = rotateL retD 1 `xor` (t1 + t2 + k1)
-                  t2' = byteIndex s2 retD' `xor` byteIndex s3 (shiftR retD' 8) `xor` byteIndex s4 (shiftR retD' 16) `xor` byteIndex s1 (shiftR retD' 24)
-                  t1' = (byteIndex s1 retC' `xor` byteIndex s2 (shiftR retC' 8) `xor` byteIndex s3 (shiftR retC' 16) `xor` byteIndex s4 (shiftR retC' 24)) + t2'
-                  retA' = rotateR (retA `xor` (t1' + k2)) 1
-                  retB' = rotateL retB 1 `xor` (t1' + t2' + k3)
+    shuffle
+        :: (Word32, Word32, Word32, Word32) -> Int -> (Word32, Word32, Word32, Word32)
+    shuffle (!retA, !retB, !retC, !retD) ind = (retA', retB', retC', retD')
+      where
+        [k0, k1, k2, k3] = fmap (\offset -> arrayRead32 ks $ (8 + 4 * ind) + offset) [0 .. 3]
+        t2 =
+            byteIndex s2 retB
+                `xor` byteIndex s3 (shiftR retB 8)
+                `xor` byteIndex s4 (shiftR retB 16)
+                `xor` byteIndex s1 (shiftR retB 24)
+        t1 =
+            ( byteIndex s1 retA
+                `xor` byteIndex s2 (shiftR retA 8)
+                `xor` byteIndex s3 (shiftR retA 16)
+                `xor` byteIndex s4 (shiftR retA 24)
+            )
+                + t2
+        retC' = rotateR (retC `xor` (t1 + k0)) 1
+        retD' = rotateL retD 1 `xor` (t1 + t2 + k1)
+        t2' =
+            byteIndex s2 retD'
+                `xor` byteIndex s3 (shiftR retD' 8)
+                `xor` byteIndex s4 (shiftR retD' 16)
+                `xor` byteIndex s1 (shiftR retD' 24)
+        t1' =
+            ( byteIndex s1 retC'
+                `xor` byteIndex s2 (shiftR retC' 8)
+                `xor` byteIndex s3 (shiftR retC' 16)
+                `xor` byteIndex s4 (shiftR retC' 24)
+            )
+                + t2'
+        retA' = rotateR (retA `xor` (t1' + k2)) 1
+        retB' = rotateL retB 1 `xor` (t1' + t2' + k3)
 
 -- Unsafe, no bounds checking
 byteIndex :: Array32 -> Word32 -> Word32
-byteIndex xs ind  = arrayRead32 xs $ fromIntegral byte
-    where byte = ind `mod` 256
+byteIndex xs ind = arrayRead32 xs $ fromIntegral byte
+  where
+    byte = ind `mod` 256
 
 -- | Decrypts the given ByteString using the given Key
-decrypt :: ByteArray ba
-        => Twofish     -- ^ The key to use
-        -> ba           -- ^ The data to decrypt
-        -> ba
+decrypt
+    :: ByteArray ba
+    => Twofish
+    -- ^ The key to use
+    -> ba
+    -- ^ The data to decrypt
+    -> ba
 decrypt cipher = mapBlocks (decryptBlock cipher)
 
 {- decryption for 128 bits blocks -}
 decryptBlock :: ByteArray ba => Twofish -> ba -> ba
-decryptBlock Twofish { s = (s1, s2, s3, s4), k = ks } message = store32ls ixs
-    where (a, b, c, d) = load32ls message
-          a' = c `xor` arrayRead32 ks 6
-          b' = d `xor` arrayRead32 ks 7
-          c' = a `xor` arrayRead32 ks 4
-          d' = b `xor` arrayRead32 ks 5
-          (!a'', !b'', !c'', !d'') = foldl' unshuffle (a', b', c', d') [8, 7..1]
-          ixs = (a'' `xor` arrayRead32 ks 0, b'' `xor` arrayRead32 ks 1, c'' `xor` arrayRead32 ks 2, d'' `xor` arrayRead32 ks 3)
+decryptBlock Twofish{s = (s1, s2, s3, s4), k = ks} message = store32ls ixs
+  where
+    (a, b, c, d) = load32ls message
+    a' = c `xor` arrayRead32 ks 6
+    b' = d `xor` arrayRead32 ks 7
+    c' = a `xor` arrayRead32 ks 4
+    d' = b `xor` arrayRead32 ks 5
+    (!a'', !b'', !c'', !d'') = foldl' unshuffle (a', b', c', d') [8, 7 .. 1]
+    ixs =
+        ( a'' `xor` arrayRead32 ks 0
+        , b'' `xor` arrayRead32 ks 1
+        , c'' `xor` arrayRead32 ks 2
+        , d'' `xor` arrayRead32 ks 3
+        )
 
-          unshuffle :: (Word32, Word32, Word32, Word32) -> Int -> (Word32, Word32, Word32, Word32)
-          unshuffle (!retA, !retB, !retC, !retD) ind = (retA', retB', retC', retD')
-            where [k0, k1, k2, k3] = fmap (\offset -> arrayRead32 ks $ (4 + 4 * ind) + offset) [0..3]
-                  t2 = byteIndex s2 retD `xor` byteIndex s3 (shiftR retD 8) `xor` byteIndex s4 (shiftR retD 16) `xor` byteIndex s1 (shiftR retD 24)
-                  t1 = (byteIndex s1 retC `xor` byteIndex s2 (shiftR retC 8) `xor` byteIndex s3 (shiftR retC 16) `xor` byteIndex s4 (shiftR retC 24)) + t2
-                  retA' = rotateL retA 1 `xor` (t1 + k2)
-                  retB' = rotateR (retB `xor` (t2 + t1 + k3)) 1
-                  t2' = byteIndex s2 retB' `xor` byteIndex s3 (shiftR retB' 8) `xor` byteIndex s4 (shiftR retB' 16) `xor` byteIndex s1 (shiftR retB' 24)
-                  t1' = (byteIndex s1 retA' `xor` byteIndex s2 (shiftR retA' 8) `xor` byteIndex s3 (shiftR retA' 16) `xor` byteIndex s4 (shiftR retA' 24)) + t2'
-                  retC' = rotateL retC 1 `xor` (t1' + k0)
-                  retD' = rotateR (retD `xor` (t2' + t1' + k1)) 1
+    unshuffle
+        :: (Word32, Word32, Word32, Word32) -> Int -> (Word32, Word32, Word32, Word32)
+    unshuffle (!retA, !retB, !retC, !retD) ind = (retA', retB', retC', retD')
+      where
+        [k0, k1, k2, k3] = fmap (\offset -> arrayRead32 ks $ (4 + 4 * ind) + offset) [0 .. 3]
+        t2 =
+            byteIndex s2 retD
+                `xor` byteIndex s3 (shiftR retD 8)
+                `xor` byteIndex s4 (shiftR retD 16)
+                `xor` byteIndex s1 (shiftR retD 24)
+        t1 =
+            ( byteIndex s1 retC
+                `xor` byteIndex s2 (shiftR retC 8)
+                `xor` byteIndex s3 (shiftR retC 16)
+                `xor` byteIndex s4 (shiftR retC 24)
+            )
+                + t2
+        retA' = rotateL retA 1 `xor` (t1 + k2)
+        retB' = rotateR (retB `xor` (t2 + t1 + k3)) 1
+        t2' =
+            byteIndex s2 retB'
+                `xor` byteIndex s3 (shiftR retB' 8)
+                `xor` byteIndex s4 (shiftR retB' 16)
+                `xor` byteIndex s1 (shiftR retB' 24)
+        t1' =
+            ( byteIndex s1 retA'
+                `xor` byteIndex s2 (shiftR retA' 8)
+                `xor` byteIndex s3 (shiftR retA' 16)
+                `xor` byteIndex s4 (shiftR retA' 24)
+            )
+                + t2'
+        retC' = rotateL retC 1 `xor` (t1' + k0)
+        retD' = rotateR (retD `xor` (t2' + t1' + k1)) 1
 
 sbox0 :: Int -> Word8
 sbox0 = arrayRead8 t
-    where t = array8
+  where
+    t =
+        array8
             "\xa9\x67\xb3\xe8\x04\xfd\xa3\x76\x9a\x92\x80\x78\xe4\xdd\xd1\x38\
             \\x0d\xc6\x35\x98\x18\xf7\xec\x6c\x43\x75\x37\x26\xfa\x13\x94\x48\
             \\xf2\xd0\x8b\x30\x84\x54\xdf\x23\x19\x5b\x3d\x59\xf3\xae\xa2\x82\
@@ -148,7 +224,9 @@
 
 sbox1 :: Int -> Word8
 sbox1 = arrayRead8 t
-    where t = array8
+  where
+    t =
+        array8
             "\x75\xf3\xc6\xf4\xdb\x7b\xfb\xc8\x4a\xd3\xe6\x6b\x45\x7d\xe8\x4b\
             \\xd6\x32\xd8\xfd\x37\x71\xf1\xe1\x30\x0f\xf8\x1b\x87\xfa\x06\x3f\
             \\x5e\xba\xae\x5b\x8a\x00\xbc\x9d\x6d\xc1\xb1\x0e\x80\x5d\xd2\xd5\
@@ -167,145 +245,281 @@
             \\xd7\x61\x1e\xb4\x50\x04\xf6\xc2\x16\x25\x86\x56\x55\x09\xbe\x91"#
 
 rs :: [[Word8]]
-rs = [ [0x01, 0xA4, 0x55, 0x87, 0x5A, 0x58, 0xDB, 0x9E]
-     , [0xA4, 0x56, 0x82, 0xF3, 0x1E, 0xC6, 0x68, 0xE5]
-     , [0x02, 0xA1, 0xFC, 0xC1, 0x47, 0xAE, 0x3D, 0x19]
-     , [0xA4, 0x55, 0x87, 0x5A, 0x58, 0xDB, 0x9E, 0x03] ]
-
-
+rs =
+    [ [0x01, 0xA4, 0x55, 0x87, 0x5A, 0x58, 0xDB, 0x9E]
+    , [0xA4, 0x56, 0x82, 0xF3, 0x1E, 0xC6, 0x68, 0xE5]
+    , [0x02, 0xA1, 0xFC, 0xC1, 0x47, 0xAE, 0x3D, 0x19]
+    , [0xA4, 0x55, 0x87, 0x5A, 0x58, 0xDB, 0x9E, 0x03]
+    ]
 
 load32ls :: ByteArray ba => ba -> (Word32, Word32, Word32, Word32)
 load32ls message = (intify q1, intify q2, intify q3, intify q4)
-    where (half1, half2) = B.splitAt 8 message
-          (q1, q2) = B.splitAt 4 half1
-          (q3, q4) = B.splitAt 4 half2
+  where
+    (half1, half2) = B.splitAt 8 message
+    (q1, q2) = B.splitAt 4 half1
+    (q3, q4) = B.splitAt 4 half2
 
-          intify :: ByteArray ba => ba -> Word32
-          intify bytes = foldl' (\int (!word, !ind) -> int .|. shiftL (fromIntegral word) (ind * 8) ) 0 (zip (B.unpack bytes) [0..])
+    intify :: ByteArray ba => ba -> Word32
+    intify bytes =
+        foldl'
+            (\int (!word, !ind) -> int .|. shiftL (fromIntegral word) (ind * 8))
+            0
+            (zip (B.unpack bytes) [0 ..])
 
 store32ls :: ByteArray ba => (Word32, Word32, Word32, Word32) -> ba
 store32ls (a, b, c, d) = B.pack $ concatMap splitWordl [a, b, c, d]
-    where splitWordl :: Word32 -> [Word8]
-          splitWordl w = fmap (\ind -> fromIntegral $ shiftR w (8 * ind)) [0..3]
-
+  where
+    splitWordl :: Word32 -> [Word8]
+    splitWordl w = fmap (\ind -> fromIntegral $ shiftR w (8 * ind)) [0 .. 3]
 
 -- Create S words
 sWords :: ByteArray ba => ba -> [Word8]
 sWords key = sWord
-    where word64Count = B.length key `div` 2
-          sWord = concatMap (\wordIndex ->
-                        map (\rsRow ->
-                            foldl' (\acc (!rsVal, !colIndex) ->
+  where
+    word64Count = B.length key `div` 2
+    sWord =
+        concatMap
+            ( \wordIndex ->
+                map
+                    ( \rsRow ->
+                        foldl'
+                            ( \acc (!rsVal, !colIndex) ->
                                 acc `xor` gfMult rsPolynomial (B.index key $ 8 * wordIndex + colIndex) rsVal
-                                ) 0 (zip rsRow [0..])
-                            ) rs
-                    ) [0..word64Count - 1]
+                            )
+                            0
+                            (zip rsRow [0 ..])
+                    )
+                    rs
+            )
+            [0 .. word64Count - 1]
 
 data Column = Zero | One | Two | Three deriving (Show, Eq, Enum, Bounded)
 
 genSboxes :: KeyPackage ba -> [Word8] -> (Array32, Array32, Array32, Array32)
 genSboxes keyPackage ws = (mkArray b0', mkArray b1', mkArray b2', mkArray b3')
-    where range = [0..255]
-          mkArray = array32 256
-          [w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15] = take 16 ws
-          (b0', b1', b2', b3') = sboxBySize $ byteSize keyPackage
-
-          sboxBySize :: ByteSize -> ([Word32], [Word32], [Word32], [Word32])
-          sboxBySize Bytes16 = (b0, b1, b2, b3)
-            where !b0 = fmap mapper range
-                    where mapper :: Int -> Word32
-                          mapper byte = mdsColumnMult ((sbox1 . fromIntegral) ((sbox0 . fromIntegral $ sbox0 byte `xor` w0) `xor` w4)) Zero
-                  !b1 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox0 . fromIntegral) ((sbox0 . fromIntegral $ sbox1 byte `xor` w1) `xor` w5)) One
-                  !b2 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox1 . fromIntegral) ((sbox1 . fromIntegral $ sbox0 byte `xor` w2) `xor` w6)) Two
-                  !b3 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox0 . fromIntegral) ((sbox1 . fromIntegral $ sbox1 byte `xor` w3) `xor` w7)) Three
-
-          sboxBySize Bytes24 = (b0, b1, b2, b3)
-            where !b0 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox1 . fromIntegral) ((sbox0 . fromIntegral) ((sbox0 . fromIntegral $ sbox1 byte `xor` w0) `xor` w4) `xor` w8)) Zero
-                  !b1 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox0 . fromIntegral) ((sbox0 . fromIntegral) ((sbox1 . fromIntegral $ sbox1 byte `xor` w1) `xor` w5) `xor` w9)) One
-                  !b2 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox1 . fromIntegral) ((sbox1 . fromIntegral) ((sbox0 . fromIntegral $ sbox0 byte `xor` w2) `xor` w6) `xor` w10)) Two
-                  !b3 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox0 . fromIntegral) ((sbox1 . fromIntegral) ((sbox1 . fromIntegral $ sbox0 byte `xor` w3) `xor` w7) `xor` w11)) Three
-
-          sboxBySize Bytes32 = (b0, b1, b2, b3)
-            where !b0 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox1 . fromIntegral) ((sbox0 . fromIntegral) ((sbox0 . fromIntegral) ((sbox1 . fromIntegral $ sbox1 byte `xor` w0) `xor` w4) `xor` w8) `xor` w12)) Zero
-                  !b1 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox0 . fromIntegral) ((sbox0 . fromIntegral) ((sbox1 . fromIntegral) ((sbox1 . fromIntegral $ sbox0 byte `xor` w1) `xor` w5) `xor` w9) `xor` w13)) One
-                  !b2 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox1 . fromIntegral) ((sbox1 . fromIntegral) ((sbox0 . fromIntegral) ((sbox0 . fromIntegral $ sbox0 byte `xor` w2) `xor` w6) `xor` w10) `xor` w14)) Two
-                  !b3 = fmap mapper range
-                    where mapper byte = mdsColumnMult ((sbox0 . fromIntegral) ((sbox1 . fromIntegral) ((sbox1 . fromIntegral) ((sbox0 . fromIntegral $ sbox1 byte `xor` w3) `xor` w7) `xor` w11) `xor` w15)) Three
-
-genK :: (ByteArray ba) => KeyPackage ba -> [Word32]
-genK keyPackage = concatMap makeTuple [0..19]
-    where makeTuple :: Word8 -> [Word32]
-          makeTuple idx = [a + b', rotateL (2 * b' + a) 9]
-            where tmp1 = replicate 4 $ 2 * idx
-                  tmp2 = fmap (+1) tmp1
-                  a = h tmp1 keyPackage 0
-                  b = h tmp2 keyPackage 1
-                  b' = rotateL b 8
+  where
+    range = [0 .. 255]
+    mkArray = array32 256
+    [w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15] = take 16 ws
+    (b0', b1', b2', b3') = sboxBySize $ byteSize keyPackage
 
-h :: (ByteArray ba) => [Word8] -> KeyPackage ba -> Int -> Word32
-h input keyPackage offset =  foldl' xorMdsColMult 0 $ zip [y0f, y1f, y2f, y3f] $ enumFrom Zero
-    where key = rawKeyBytes keyPackage
-          [y0, y1, y2, y3] = take 4 input
-          (!y0f, !y1f, !y2f, !y3f) = run (y0, y1, y2, y3) $ byteSize keyPackage
+    sboxBySize :: ByteSize -> ([Word32], [Word32], [Word32], [Word32])
+    sboxBySize Bytes16 = (b0, b1, b2, b3)
+      where
+        !b0 = fmap mapper range
+          where
+            mapper :: Int -> Word32
+            mapper byte =
+                mdsColumnMult
+                    ((sbox1 . fromIntegral) ((sbox0 . fromIntegral $ sbox0 byte `xor` w0) `xor` w4))
+                    Zero
+        !b1 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ((sbox0 . fromIntegral) ((sbox0 . fromIntegral $ sbox1 byte `xor` w1) `xor` w5))
+                    One
+        !b2 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ((sbox1 . fromIntegral) ((sbox1 . fromIntegral $ sbox0 byte `xor` w2) `xor` w6))
+                    Two
+        !b3 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ((sbox0 . fromIntegral) ((sbox1 . fromIntegral $ sbox1 byte `xor` w3) `xor` w7))
+                    Three
+    sboxBySize Bytes24 = (b0, b1, b2, b3)
+      where
+        !b0 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ( (sbox1 . fromIntegral)
+                        ( (sbox0 . fromIntegral) ((sbox0 . fromIntegral $ sbox1 byte `xor` w0) `xor` w4)
+                            `xor` w8
+                        )
+                    )
+                    Zero
+        !b1 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ( (sbox0 . fromIntegral)
+                        ( (sbox0 . fromIntegral) ((sbox1 . fromIntegral $ sbox1 byte `xor` w1) `xor` w5)
+                            `xor` w9
+                        )
+                    )
+                    One
+        !b2 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ( (sbox1 . fromIntegral)
+                        ( (sbox1 . fromIntegral) ((sbox0 . fromIntegral $ sbox0 byte `xor` w2) `xor` w6)
+                            `xor` w10
+                        )
+                    )
+                    Two
+        !b3 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ( (sbox0 . fromIntegral)
+                        ( (sbox1 . fromIntegral) ((sbox1 . fromIntegral $ sbox0 byte `xor` w3) `xor` w7)
+                            `xor` w11
+                        )
+                    )
+                    Three
+    sboxBySize Bytes32 = (b0, b1, b2, b3)
+      where
+        !b0 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ( (sbox1 . fromIntegral)
+                        ( (sbox0 . fromIntegral)
+                            ( (sbox0 . fromIntegral) ((sbox1 . fromIntegral $ sbox1 byte `xor` w0) `xor` w4)
+                                `xor` w8
+                            )
+                            `xor` w12
+                        )
+                    )
+                    Zero
+        !b1 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ( (sbox0 . fromIntegral)
+                        ( (sbox0 . fromIntegral)
+                            ( (sbox1 . fromIntegral) ((sbox1 . fromIntegral $ sbox0 byte `xor` w1) `xor` w5)
+                                `xor` w9
+                            )
+                            `xor` w13
+                        )
+                    )
+                    One
+        !b2 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ( (sbox1 . fromIntegral)
+                        ( (sbox1 . fromIntegral)
+                            ( (sbox0 . fromIntegral) ((sbox0 . fromIntegral $ sbox0 byte `xor` w2) `xor` w6)
+                                `xor` w10
+                            )
+                            `xor` w14
+                        )
+                    )
+                    Two
+        !b3 = fmap mapper range
+          where
+            mapper byte =
+                mdsColumnMult
+                    ( (sbox0 . fromIntegral)
+                        ( (sbox1 . fromIntegral)
+                            ( (sbox1 . fromIntegral) ((sbox0 . fromIntegral $ sbox1 byte `xor` w3) `xor` w7)
+                                `xor` w11
+                            )
+                            `xor` w15
+                        )
+                    )
+                    Three
 
-          run :: (Word8, Word8, Word8, Word8) -> ByteSize -> (Word8, Word8, Word8, Word8)
-          run (!y0'', !y1'', !y2'', !y3'') Bytes32 = run (y0', y1', y2', y3') Bytes24
-            where y0' = sbox1 (fromIntegral y0'') `xor` B.index key (4 * (6 + offset) + 0)
-                  y1' = sbox0 (fromIntegral y1'') `xor` B.index key (4 * (6 + offset) + 1)
-                  y2' = sbox0 (fromIntegral y2'') `xor` B.index key (4 * (6 + offset) + 2)
-                  y3' = sbox1 (fromIntegral y3'') `xor` B.index key (4 * (6 + offset) + 3)
+genK :: ByteArray ba => KeyPackage ba -> [Word32]
+genK keyPackage = concatMap makeTuple [0 .. 19]
+  where
+    makeTuple :: Word8 -> [Word32]
+    makeTuple idx = [a + b', rotateL (2 * b' + a) 9]
+      where
+        tmp1 = replicate 4 $ 2 * idx
+        tmp2 = fmap (+ 1) tmp1
+        a = h tmp1 keyPackage 0
+        b = h tmp2 keyPackage 1
+        b' = rotateL b 8
 
-          run (!y0'', !y1'', !y2'', !y3'') Bytes24 = run (y0', y1', y2', y3') Bytes16
-            where y0' = sbox1 (fromIntegral y0'') `xor` B.index key (4 * (4 + offset) + 0)
-                  y1' = sbox1 (fromIntegral y1'') `xor` B.index key (4 * (4 + offset) + 1)
-                  y2' = sbox0 (fromIntegral y2'') `xor` B.index key (4 * (4 + offset) + 2)
-                  y3' = sbox0 (fromIntegral y3'') `xor` B.index key (4 * (4 + offset) + 3)
+h :: ByteArray ba => [Word8] -> KeyPackage ba -> Int -> Word32
+h input keyPackage offset = foldl' xorMdsColMult 0 $ zip [y0f, y1f, y2f, y3f] $ enumFrom Zero
+  where
+    key = rawKeyBytes keyPackage
+    [y0, y1, y2, y3] = take 4 input
+    (!y0f, !y1f, !y2f, !y3f) = run (y0, y1, y2, y3) $ byteSize keyPackage
 
-          run (!y0'', !y1'', !y2'', !y3'') Bytes16 = (y0', y1', y2', y3')
-            where y0' = sbox1 . fromIntegral $ (sbox0 . fromIntegral $ (sbox0 (fromIntegral y0'') `xor` B.index key (4 * (2 + offset) + 0))) `xor` B.index key (4 * (0 + offset) + 0)
-                  y1' = sbox0 . fromIntegral $ (sbox0 . fromIntegral $ (sbox1 (fromIntegral y1'') `xor` B.index key (4 * (2 + offset) + 1))) `xor` B.index key (4 * (0 + offset) + 1)
-                  y2' = sbox1 . fromIntegral $ (sbox1 . fromIntegral $ (sbox0 (fromIntegral y2'') `xor` B.index key (4 * (2 + offset) + 2))) `xor` B.index key (4 * (0 + offset) + 2)
-                  y3' = sbox0 . fromIntegral $ (sbox1 . fromIntegral $ (sbox1 (fromIntegral y3'') `xor` B.index key (4 * (2 + offset) + 3))) `xor` B.index key (4 * (0 + offset) + 3)
+    run :: (Word8, Word8, Word8, Word8) -> ByteSize -> (Word8, Word8, Word8, Word8)
+    run (!y0'', !y1'', !y2'', !y3'') Bytes32 = run (y0', y1', y2', y3') Bytes24
+      where
+        y0' = sbox1 (fromIntegral y0'') `xor` B.index key (4 * (6 + offset) + 0)
+        y1' = sbox0 (fromIntegral y1'') `xor` B.index key (4 * (6 + offset) + 1)
+        y2' = sbox0 (fromIntegral y2'') `xor` B.index key (4 * (6 + offset) + 2)
+        y3' = sbox1 (fromIntegral y3'') `xor` B.index key (4 * (6 + offset) + 3)
+    run (!y0'', !y1'', !y2'', !y3'') Bytes24 = run (y0', y1', y2', y3') Bytes16
+      where
+        y0' = sbox1 (fromIntegral y0'') `xor` B.index key (4 * (4 + offset) + 0)
+        y1' = sbox1 (fromIntegral y1'') `xor` B.index key (4 * (4 + offset) + 1)
+        y2' = sbox0 (fromIntegral y2'') `xor` B.index key (4 * (4 + offset) + 2)
+        y3' = sbox0 (fromIntegral y3'') `xor` B.index key (4 * (4 + offset) + 3)
+    run (!y0'', !y1'', !y2'', !y3'') Bytes16 = (y0', y1', y2', y3')
+      where
+        y0' =
+            sbox1 . fromIntegral $
+                ( sbox0 . fromIntegral $
+                    (sbox0 (fromIntegral y0'') `xor` B.index key (4 * (2 + offset) + 0))
+                )
+                    `xor` B.index key (4 * (0 + offset) + 0)
+        y1' =
+            sbox0 . fromIntegral $
+                ( sbox0 . fromIntegral $
+                    (sbox1 (fromIntegral y1'') `xor` B.index key (4 * (2 + offset) + 1))
+                )
+                    `xor` B.index key (4 * (0 + offset) + 1)
+        y2' =
+            sbox1 . fromIntegral $
+                ( sbox1 . fromIntegral $
+                    (sbox0 (fromIntegral y2'') `xor` B.index key (4 * (2 + offset) + 2))
+                )
+                    `xor` B.index key (4 * (0 + offset) + 2)
+        y3' =
+            sbox0 . fromIntegral $
+                ( sbox1 . fromIntegral $
+                    (sbox1 (fromIntegral y3'') `xor` B.index key (4 * (2 + offset) + 3))
+                )
+                    `xor` B.index key (4 * (0 + offset) + 3)
 
-          xorMdsColMult :: Word32 -> (Word8, Column) -> Word32
-          xorMdsColMult acc wordAndIndex = acc `xor` uncurry mdsColumnMult wordAndIndex
+    xorMdsColMult :: Word32 -> (Word8, Column) -> Word32
+    xorMdsColMult acc wordAndIndex = acc `xor` uncurry mdsColumnMult wordAndIndex
 
 mdsColumnMult :: Word8 -> Column -> Word32
 mdsColumnMult !byte !col =
-    case col of Zero  -> input .|. rotateL mul5B 8 .|. rotateL mulEF 16 .|. rotateL mulEF 24
-                One   -> mulEF .|. rotateL mulEF 8 .|. rotateL mul5B 16 .|. rotateL input 24
-                Two   -> mul5B .|. rotateL mulEF 8 .|. rotateL input 16 .|. rotateL mulEF 24
-                Three -> mul5B .|. rotateL input 8 .|. rotateL mulEF 16 .|. rotateL mul5B 24
-        where input = fromIntegral byte
-              mul5B = fromIntegral $ gfMult mdsPolynomial byte 0x5B
-              mulEF = fromIntegral $ gfMult mdsPolynomial byte 0xEF
+    case col of
+        Zero -> input .|. rotateL mul5B 8 .|. rotateL mulEF 16 .|. rotateL mulEF 24
+        One -> mulEF .|. rotateL mulEF 8 .|. rotateL mul5B 16 .|. rotateL input 24
+        Two -> mul5B .|. rotateL mulEF 8 .|. rotateL input 16 .|. rotateL mulEF 24
+        Three -> mul5B .|. rotateL input 8 .|. rotateL mulEF 16 .|. rotateL mul5B 24
+  where
+    input = fromIntegral byte
+    mul5B = fromIntegral $ gfMult mdsPolynomial byte 0x5B
+    mulEF = fromIntegral $ gfMult mdsPolynomial byte 0xEF
 
-tupInd :: (Bits b) => b -> (a, a) -> a
+tupInd :: Bits b => b -> (a, a) -> a
 tupInd b
     | testBit b 0 = snd
     | otherwise = fst
 
 gfMult :: Word32 -> Word8 -> Word8 -> Word8
 gfMult p a b = fromIntegral $ run a b' p' result 0
-    where b' = (0, fromIntegral b)
-          p' = (0, p)
-          result = 0
+  where
+    b' = (0, fromIntegral b)
+    p' = (0, p)
+    result = 0
 
-          run :: Word8 -> (Word32, Word32) -> (Word32, Word32) -> Word32 -> Int -> Word32
-          run a' b'' p'' result' count =
-            if count == 7
+    run :: Word8 -> (Word32, Word32) -> (Word32, Word32) -> Word32 -> Int -> Word32
+    run a' b'' p'' result' count =
+        if count == 7
             then result''
             else run a'' b''' p'' result'' (count + 1)
-                where result'' = result' `xor` tupInd (a' .&. 1) b''
-                      a'' = shiftR a' 1
-                      b''' = (fst b'', tupInd (shiftR (snd b'') 7) p'' `xor` shiftL (snd b'') 1)
+      where
+        result'' = result' `xor` tupInd (a' .&. 1) b''
+        a'' = shiftR a' 1
+        b''' = (fst b'', tupInd (shiftR (snd b'') 7) p'' `xor` shiftL (snd b'') 1)
diff --git a/Crypto/Cipher/Types.hs b/Crypto/Cipher/Types.hs
--- a/Crypto/Cipher/Types.hs
+++ b/Crypto/Cipher/Types.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+
 -- |
 -- Module      : Crypto.Cipher.Types
 -- License     : BSD-style
@@ -6,34 +8,34 @@
 -- Portability : Excellent
 --
 -- Symmetric cipher basic types
---
-{-# LANGUAGE DeriveDataTypeable #-}
-module Crypto.Cipher.Types
-    (
+module Crypto.Cipher.Types (
     -- * Cipher classes
-      Cipher(..)
-    , BlockCipher(..)
-    , BlockCipher128(..)
-    , StreamCipher(..)
-    , DataUnitOffset
-    , KeySizeSpecifier(..)
+    Cipher (..),
+    BlockCipher (..),
+    BlockCipher128 (..),
+    StreamCipher (..),
+    DataUnitOffset,
+    KeySizeSpecifier (..),
     -- , cfb8Encrypt
     -- , cfb8Decrypt
+
     -- * AEAD functions
-    , AEADMode(..)
-    , CCM_M(..)
-    , CCM_L(..)
-    , module Crypto.Cipher.Types.AEAD
+    AEADMode (..),
+    CCM_M (..),
+    CCM_L (..),
+    module Crypto.Cipher.Types.AEAD,
+
     -- * Initial Vector type and constructor
-    , IV
-    , makeIV
-    , nullIV
-    , ivAdd
+    IV,
+    makeIV,
+    nullIV,
+    ivAdd,
+
     -- * Authentification Tag
-    , AuthTag(..)
-    ) where
+    AuthTag (..),
+) where
 
+import Crypto.Cipher.Types.AEAD
 import Crypto.Cipher.Types.Base
 import Crypto.Cipher.Types.Block
 import Crypto.Cipher.Types.Stream
-import Crypto.Cipher.Types.AEAD
diff --git a/Crypto/Cipher/Types/AEAD.hs b/Crypto/Cipher/Types/AEAD.hs
--- a/Crypto/Cipher/Types/AEAD.hs
+++ b/Crypto/Cipher/Types/AEAD.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE Rank2Types #-}
+
 -- |
 -- Module      : Crypto.Cipher.Types.AEAD
 -- License     : BSD-style
@@ -6,69 +9,83 @@
 -- Portability : Excellent
 --
 -- AEAD cipher basic types
---
-{-# LANGUAGE ExistentialQuantification #-}
-{-# LANGUAGE Rank2Types #-}
 module Crypto.Cipher.Types.AEAD where
 
-import           Crypto.Cipher.Types.Base
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray)
+import Crypto.Cipher.Types.Base
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.Imports
+import Crypto.Internal.Imports
 
 -- | AEAD Implementation
 data AEADModeImpl st = AEADModeImpl
-    { aeadImplAppendHeader :: forall ba . ByteArrayAccess ba => st -> ba -> st
-    , aeadImplEncrypt      :: forall ba . ByteArray ba => st -> ba -> (ba, st)
-    , aeadImplDecrypt      :: forall ba . ByteArray ba => st -> ba -> (ba, st)
-    , aeadImplFinalize     :: st -> Int -> AuthTag
+    { aeadImplAppendHeader :: forall ba. ByteArrayAccess ba => st -> ba -> st
+    -- ^ Adding associated\/additional data to the AEAD context.
+    , aeadImplEncrypt :: forall ba. ByteArray ba => st -> ba -> (ba, st)
+    -- ^ Encrypiting plaintext and update the AEAD context.
+    , aeadImplDecrypt :: forall ba. ByteArray ba => st -> ba -> (ba, st)
+    -- ^ Decrypting ciphertext and update the AEAD context.
+    , aeadImplFinalize :: st -> Int -> AuthTag
+    -- ^ Finalizing the AEAD context and returning the authentication tag.
     }
 
--- | Authenticated Encryption with Associated Data algorithms
-data AEAD cipher = forall st . AEAD
+-- | Algorithm and context for AEAD(Authenticated Encryption with Associated\/Additional Data)
+data AEAD cipher = forall st. AEAD
     { aeadModeImpl :: AEADModeImpl st
-    , aeadState    :: !st
+    , aeadState :: !st
     }
 
--- | Append some header information to an AEAD context
+-- | Adding associated\/additional data to the AEAD context.
 aeadAppendHeader :: ByteArrayAccess aad => AEAD cipher -> aad -> AEAD cipher
 aeadAppendHeader (AEAD impl st) aad = AEAD impl $ aeadImplAppendHeader impl st aad
 
--- | Encrypt some data and update the AEAD context
+-- | Encrypting plaintext  and update the AEAD context.
 aeadEncrypt :: ByteArray ba => AEAD cipher -> ba -> (ba, AEAD cipher)
 aeadEncrypt (AEAD impl st) ba = second (AEAD impl) $ aeadImplEncrypt impl st ba
 
--- | Decrypt some data and update the AEAD context
+-- | Decrypting ciphertext and update the AEAD context.
 aeadDecrypt :: ByteArray ba => AEAD cipher -> ba -> (ba, AEAD cipher)
 aeadDecrypt (AEAD impl st) ba = second (AEAD impl) $ aeadImplDecrypt impl st ba
 
--- | Finalize the AEAD context and return the authentication tag
+-- | Finalizing the AEAD context and returning the authentication tag.
 aeadFinalize :: AEAD cipher -> Int -> AuthTag
 aeadFinalize (AEAD impl st) = aeadImplFinalize impl st
 
--- | Simple AEAD encryption
-aeadSimpleEncrypt :: (ByteArrayAccess aad, ByteArray ba)
-                  => AEAD a        -- ^ A new AEAD Context
-                  -> aad           -- ^ Optional Authentication data header
-                  -> ba            -- ^ Optional Plaintext
-                  -> Int           -- ^ Tag length
-                  -> (AuthTag, ba) -- ^ Authentication tag and ciphertext
+-- | Simple AEAD encryption.
+aeadSimpleEncrypt
+    :: (ByteArrayAccess aad, ByteArray ba)
+    => AEAD a
+    -- ^ An AEAD Context
+    -> aad
+    -- ^ Associated\/additional data
+    -> ba
+    -- ^ Plaintext
+    -> Int
+    -- ^ Tag length
+    -> (AuthTag, ba)
+    -- ^ Authentication tag and ciphertext
 aeadSimpleEncrypt aeadIni header input taglen = (tag, output)
-  where aead                = aeadAppendHeader aeadIni header
-        (output, aeadFinal) = aeadEncrypt aead input
-        tag                 = aeadFinalize aeadFinal taglen
+  where
+    aead = aeadAppendHeader aeadIni header
+    (output, aeadFinal) = aeadEncrypt aead input
+    tag = aeadFinalize aeadFinal taglen
 
--- | Simple AEAD decryption
-aeadSimpleDecrypt :: (ByteArrayAccess aad, ByteArray ba)
-                  => AEAD a        -- ^ A new AEAD Context
-                  -> aad           -- ^ Optional Authentication data header
-                  -> ba            -- ^ Ciphertext
-                  -> AuthTag       -- ^ The authentication tag
-                  -> Maybe ba      -- ^ Plaintext
+-- | Simple AEAD decryptio.
+aeadSimpleDecrypt
+    :: (ByteArrayAccess aad, ByteArray ba)
+    => AEAD a
+    -- ^ An AEAD Context
+    -> aad
+    -- ^ Associated\/additional data
+    -> ba
+    -- ^ Ciphertext
+    -> AuthTag
+    -- ^ The authentication tag
+    -> Maybe ba
+    -- ^ Plaintext
 aeadSimpleDecrypt aeadIni header input authTag
     | tag == authTag = Just output
-    | otherwise      = Nothing
-  where aead                = aeadAppendHeader aeadIni header
-        (output, aeadFinal) = aeadDecrypt aead input
-        tag                 = aeadFinalize aeadFinal (B.length authTag)
-
+    | otherwise = Nothing
+  where
+    aead = aeadAppendHeader aeadIni header
+    (output, aeadFinal) = aeadDecrypt aead input
+    tag = aeadFinalize aeadFinal (B.length authTag)
diff --git a/Crypto/Cipher/Types/Base.hs b/Crypto/Cipher/Types/Base.hs
--- a/Crypto/Cipher/Types/Base.hs
+++ b/Crypto/Cipher/Types/Base.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.Cipher.Types.Base
 -- License     : BSD-style
@@ -6,60 +9,63 @@
 -- Portability : Excellent
 --
 -- Symmetric cipher basic types
---
-{-# LANGUAGE ExistentialQuantification #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.Cipher.Types.Base
-    ( KeySizeSpecifier(..)
-    , Cipher(..)
-    , AuthTag(..)
-    , AEADMode(..)
-    , CCM_M(..)
-    , CCM_L(..)
-    , DataUnitOffset
-    ) where
+module Crypto.Cipher.Types.Base (
+    KeySizeSpecifier (..),
+    Cipher (..),
+    AuthTag (..),
+    AEADMode (..),
+    CCM_M (..),
+    CCM_L (..),
+    DataUnitOffset,
+) where
 
-import           Data.Word
-import           Crypto.Internal.ByteArray (Bytes, ByteArrayAccess, ByteArray)
+import Crypto.Error
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, Bytes)
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.DeepSeq
-import           Crypto.Error
+import Crypto.Internal.DeepSeq
+import Data.Word
 
 -- | Different specifier for key size in bytes
-data KeySizeSpecifier =
-      KeySizeRange Int Int -- ^ in the range [min,max]
-    | KeySizeEnum  [Int]   -- ^ one of the specified values
-    | KeySizeFixed Int     -- ^ a specific size
-    deriving (Show,Eq)
+data KeySizeSpecifier
+    = -- | in the range [min,max]
+      KeySizeRange Int Int
+    | -- | one of the specified values
+      KeySizeEnum [Int]
+    | -- | a specific size
+      KeySizeFixed Int
+    deriving (Show, Eq)
 
 -- | Offset inside an XTS data unit, measured in block size.
 type DataUnitOffset = Word32
 
 -- | Authentication Tag for AE cipher mode
-newtype AuthTag = AuthTag { unAuthTag :: Bytes }
+newtype AuthTag = AuthTag {unAuthTag :: Bytes}
     deriving (Show, ByteArrayAccess, NFData)
 
 instance Eq AuthTag where
     (AuthTag a) == (AuthTag b) = B.constEq a b
 
-data CCM_M = CCM_M4 | CCM_M6 | CCM_M8 | CCM_M10 | CCM_M12 | CCM_M14 | CCM_M16 deriving (Show, Eq)
+data CCM_M = CCM_M4 | CCM_M6 | CCM_M8 | CCM_M10 | CCM_M12 | CCM_M14 | CCM_M16
+    deriving (Show, Eq)
 data CCM_L = CCM_L2 | CCM_L3 | CCM_L4 deriving (Show, Eq)
 
 -- | AEAD Mode
-data AEADMode =
-      AEAD_OCB -- OCB3
+data AEADMode
+    = AEAD_OCB -- OCB3
     | AEAD_CCM Int CCM_M CCM_L
     | AEAD_EAX
     | AEAD_CWC
     | AEAD_GCM
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 -- | Symmetric cipher class.
 class Cipher cipher where
     -- | Initialize a cipher context from a key
-    cipherInit    :: ByteArray key => key -> CryptoFailable cipher
+    cipherInit :: ByteArray key => key -> CryptoFailable cipher
+
     -- | Cipher name
-    cipherName    :: cipher -> String
+    cipherName :: cipher -> String
+
     -- | return the size of the key required for this cipher.
     -- Some cipher accept any size for key
     cipherKeySize :: cipher -> KeySizeSpecifier
diff --git a/Crypto/Cipher/Types/Block.hs b/Crypto/Cipher/Types/Block.hs
--- a/Crypto/Cipher/Types/Block.hs
+++ b/Crypto/Cipher/Types/Block.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE Rank2Types #-}
+{-# LANGUAGE ViewPatterns #-}
+
 -- |
 -- Module      : Crypto.Cipher.Types.Block
 -- License     : BSD-style
@@ -6,51 +11,55 @@
 -- Portability : Excellent
 --
 -- Block cipher basic types
---
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE ExistentialQuantification #-}
-{-# LANGUAGE ViewPatterns #-}
-{-# LANGUAGE Rank2Types #-}
-module Crypto.Cipher.Types.Block
-    (
+module Crypto.Cipher.Types.Block (
     -- * BlockCipher
-      BlockCipher(..)
-    , BlockCipher128(..)
+    BlockCipher (..),
+    BlockCipher128 (..),
+
     -- * Initialization vector (IV)
-    , IV(..)
-    , makeIV
-    , nullIV
-    , ivAdd
+    IV (..),
+    makeIV,
+    nullIV,
+    ivAdd,
+
     -- * XTS
-    , XTS
+    XTS,
+
     -- * AEAD
-    , AEAD(..)
+    AEAD (..),
     -- , AEADState(..)
-    , AEADModeImpl(..)
-    , aeadAppendHeader
-    , aeadEncrypt
-    , aeadDecrypt
-    , aeadFinalize
+    AEADModeImpl (..),
+    aeadAppendHeader,
+    aeadEncrypt,
+    aeadDecrypt,
+    aeadFinalize,
+
     -- * CFB 8 bits
-    --, cfb8Encrypt
-    --, cfb8Decrypt
-    ) where
+) where
 
-import           Data.Word
-import           Crypto.Error
-import           Crypto.Cipher.Types.Base
-import           Crypto.Cipher.Types.GF
-import           Crypto.Cipher.Types.AEAD
-import           Crypto.Cipher.Types.Utils
+-- , cfb8Encrypt
+-- , cfb8Decrypt
 
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray, withByteArray, Bytes)
+import Crypto.Cipher.Types.AEAD
+import Crypto.Cipher.Types.Base
+import Crypto.Cipher.Types.GF
+import Crypto.Cipher.Types.Utils
+import Crypto.Error
+import Data.Word
+
+import Crypto.Internal.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    Bytes,
+    withByteArray,
+ )
 import qualified Crypto.Internal.ByteArray as B
 
-import           Foreign.Ptr
-import           Foreign.Storable
+import Foreign.Ptr
+import Foreign.Storable
 
 -- | an IV parametrized by the cipher
-data IV c = forall byteArray . ByteArray byteArray => IV !byteArray
+data IV c = forall byteArray. ByteArray byteArray => IV !byteArray
 
 instance BlockCipher c => ByteArrayAccess (IV c) where
     withByteArray (IV z) f = withByteArray z f
@@ -59,16 +68,21 @@
     (IV a) == (IV b) = B.eq a b
 
 -- | XTS callback
-type XTS ba cipher = (cipher, cipher)
-                  -> IV cipher        -- ^ Usually represent the Data Unit (e.g. disk sector)
-                  -> DataUnitOffset   -- ^ Offset in the data unit in number of blocks
-                  -> ba               -- ^ Data
-                  -> ba               -- ^ Processed Data
+type XTS ba cipher =
+    (cipher, cipher)
+    -> IV cipher
+    -- ^ Usually represent the Data Unit (e.g. disk sector)
+    -> DataUnitOffset
+    -- ^ Offset in the data unit in number of blocks
+    -> ba
+    -- ^ Data
+    -> ba
+    -- ^ Processed Data
 
 -- | Symmetric block cipher class
 class Cipher cipher => BlockCipher cipher where
     -- | Return the size of block required for this block cipher
-    blockSize    :: cipher -> Int
+    blockSize :: cipher -> Int
 
     -- | Encrypt blocks
     --
@@ -85,6 +99,7 @@
     -- input need to be a multiple of the blocksize
     cbcEncrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba
     cbcEncrypt = cbcEncryptGeneric
+
     -- | decrypt using the CBC mode.
     --
     -- input need to be a multiple of the blocksize
@@ -96,6 +111,7 @@
     -- input need to be a multiple of the blocksize
     cfbEncrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba
     cfbEncrypt = cfbEncryptGeneric
+
     -- | decrypt using the CFB mode.
     --
     -- input need to be a multiple of the blocksize
@@ -116,7 +132,8 @@
     -- | Initialize a new AEAD State
     --
     -- When Nothing is returns, it means the mode is not handled.
-    aeadInit :: ByteArrayAccess iv => AEADMode -> cipher -> iv -> CryptoFailable (AEAD cipher)
+    aeadInit
+        :: ByteArrayAccess iv => AEADMode -> cipher -> iv -> CryptoFailable (AEAD cipher)
     aeadInit _ _ _ = CryptoFailed CryptoError_AEADModeNotSupported
 
 -- | class of block cipher with a 128 bits block size
@@ -125,96 +142,117 @@
     --
     -- input need to be a multiple of the blocksize, and the cipher
     -- need to process 128 bits block only
-    xtsEncrypt :: ByteArray ba
-               => (cipher, cipher)
-               -> IV cipher        -- ^ Usually represent the Data Unit (e.g. disk sector)
-               -> DataUnitOffset   -- ^ Offset in the data unit in number of blocks
-               -> ba               -- ^ Plaintext
-               -> ba               -- ^ Ciphertext
+    xtsEncrypt
+        :: ByteArray ba
+        => (cipher, cipher)
+        -> IV cipher
+        -- ^ Usually represent the Data Unit (e.g. disk sector)
+        -> DataUnitOffset
+        -- ^ Offset in the data unit in number of blocks
+        -> ba
+        -- ^ Plaintext
+        -> ba
+        -- ^ Ciphertext
     xtsEncrypt = xtsEncryptGeneric
 
     -- | decrypt using the XTS mode.
     --
     -- input need to be a multiple of the blocksize, and the cipher
     -- need to process 128 bits block only
-    xtsDecrypt :: ByteArray ba
-               => (cipher, cipher)
-               -> IV cipher        -- ^ Usually represent the Data Unit (e.g. disk sector)
-               -> DataUnitOffset   -- ^ Offset in the data unit in number of blocks
-               -> ba               -- ^ Ciphertext
-               -> ba               -- ^ Plaintext
+    xtsDecrypt
+        :: ByteArray ba
+        => (cipher, cipher)
+        -> IV cipher
+        -- ^ Usually represent the Data Unit (e.g. disk sector)
+        -> DataUnitOffset
+        -- ^ Offset in the data unit in number of blocks
+        -> ba
+        -- ^ Ciphertext
+        -> ba
+        -- ^ Plaintext
     xtsDecrypt = xtsDecryptGeneric
 
 -- | Create an IV for a specified block cipher
 makeIV :: (ByteArrayAccess b, BlockCipher c) => b -> Maybe (IV c)
 makeIV b = toIV undefined
-  where toIV :: BlockCipher c => c -> Maybe (IV c)
-        toIV cipher
-          | B.length b == sz = Just $ IV (B.convert b :: Bytes)
-          | otherwise        = Nothing
-          where sz = blockSize cipher
+  where
+    toIV :: BlockCipher c => c -> Maybe (IV c)
+    toIV cipher
+        | B.length b == sz = Just $ IV (B.convert b :: Bytes)
+        | otherwise = Nothing
+      where
+        sz = blockSize cipher
 
 -- | Create an IV that is effectively representing the number 0
 nullIV :: BlockCipher c => IV c
 nullIV = toIV undefined
-  where toIV :: BlockCipher c => c -> IV c
-        toIV cipher = IV (B.zero (blockSize cipher) :: Bytes)
+  where
+    toIV :: BlockCipher c => c -> IV c
+    toIV cipher = IV (B.zero (blockSize cipher) :: Bytes)
 
 -- | Increment an IV by a number.
 --
 -- Assume the IV is in Big Endian format.
 ivAdd :: IV c -> Int -> IV c
 ivAdd (IV b) i = IV $ copy b
-  where copy :: ByteArray bs => bs -> bs
-        copy bs = B.copyAndFreeze bs $ loop i (B.length bs - 1)
+  where
+    copy :: ByteArray bs => bs -> bs
+    copy bs = B.copyAndFreeze bs $ loop i (B.length bs - 1)
 
-        loop :: Int -> Int -> Ptr Word8 -> IO ()
-        loop acc ofs p
-            | ofs < 0   = return ()
-            | otherwise = do
-                v <- peek (p `plusPtr` ofs) :: IO Word8
-                let accv    = acc + fromIntegral v
-                    (hi,lo) = accv `divMod` 256
-                poke (p `plusPtr` ofs) (fromIntegral lo :: Word8)
-                loop hi (ofs - 1) p
+    loop :: Int -> Int -> Ptr Word8 -> IO ()
+    loop acc ofs p
+        | ofs < 0 = return ()
+        | otherwise = do
+            v <- peek (p `plusPtr` ofs) :: IO Word8
+            let accv = acc + fromIntegral v
+                (hi, lo) = accv `divMod` 256
+            poke (p `plusPtr` ofs) (fromIntegral lo :: Word8)
+            loop hi (ofs - 1) p
 
-cbcEncryptGeneric :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
+cbcEncryptGeneric
+    :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
 cbcEncryptGeneric cipher ivini input = mconcat $ doEnc ivini $ chunk (blockSize cipher) input
-  where doEnc _  []     = []
-        doEnc iv (i:is) =
-            let o = ecbEncrypt cipher $ B.xor iv i
-             in o : doEnc (IV o) is
+  where
+    doEnc _ [] = []
+    doEnc iv (i : is) =
+        let o = ecbEncrypt cipher $ B.xor iv i
+         in o : doEnc (IV o) is
 
-cbcDecryptGeneric :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
+cbcDecryptGeneric
+    :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
 cbcDecryptGeneric cipher ivini input = mconcat $ doDec ivini $ chunk (blockSize cipher) input
   where
-        doDec _  []     = []
-        doDec iv (i:is) =
-            let o = B.xor iv $ ecbDecrypt cipher i
-             in o : doDec (IV i) is
+    doDec _ [] = []
+    doDec iv (i : is) =
+        let o = B.xor iv $ ecbDecrypt cipher i
+         in o : doDec (IV i) is
 
-cfbEncryptGeneric :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
+cfbEncryptGeneric
+    :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
 cfbEncryptGeneric cipher ivini input = mconcat $ doEnc ivini $ chunk (blockSize cipher) input
   where
-        doEnc _  []     = []
-        doEnc (IV iv) (i:is) =
-            let o = B.xor i $ ecbEncrypt cipher iv
-             in o : doEnc (IV o) is
+    doEnc _ [] = []
+    doEnc (IV iv) (i : is) =
+        let o = B.xor i $ ecbEncrypt cipher iv
+         in o : doEnc (IV o) is
 
-cfbDecryptGeneric :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
+cfbDecryptGeneric
+    :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
 cfbDecryptGeneric cipher ivini input = mconcat $ doDec ivini $ chunk (blockSize cipher) input
   where
-        doDec _  []     = []
-        doDec (IV iv) (i:is) =
-            let o = B.xor i $ ecbEncrypt cipher iv
-             in o : doDec (IV i) is
+    doDec _ [] = []
+    doDec (IV iv) (i : is) =
+        let o = B.xor i $ ecbEncrypt cipher iv
+         in o : doDec (IV i) is
 
-ctrCombineGeneric :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
+ctrCombineGeneric
+    :: (ByteArray ba, BlockCipher cipher) => cipher -> IV cipher -> ba -> ba
 ctrCombineGeneric cipher ivini input = mconcat $ doCnt ivini $ chunk (blockSize cipher) input
-  where doCnt _  [] = []
-        doCnt iv@(IV ivd) (i:is) =
-            let ivEnc = ecbEncrypt cipher ivd
-             in B.xor i ivEnc : doCnt (ivAdd iv 1) is
+  where
+    doCnt _ [] = []
+    doCnt iv@(IV ivd) (i : is) =
+        let ivEnc = ecbEncrypt cipher ivd
+         in B.xor i ivEnc : doCnt (ivAdd iv 1) is
 
 xtsEncryptGeneric :: (ByteArray ba, BlockCipher128 cipher) => XTS ba cipher
 xtsEncryptGeneric = xtsGeneric ecbEncrypt
@@ -222,21 +260,23 @@
 xtsDecryptGeneric :: (ByteArray ba, BlockCipher128 cipher) => XTS ba cipher
 xtsDecryptGeneric = xtsGeneric ecbDecrypt
 
-xtsGeneric :: (ByteArray ba, BlockCipher128 cipher)
-           => (cipher -> ba -> ba)
-           -> (cipher, cipher)
-           -> IV cipher
-           -> DataUnitOffset
-           -> ba
-           -> ba
+xtsGeneric
+    :: (ByteArray ba, BlockCipher128 cipher)
+    => (cipher -> ba -> ba)
+    -> (cipher, cipher)
+    -> IV cipher
+    -> DataUnitOffset
+    -> ba
+    -> ba
 xtsGeneric f (cipher, tweakCipher) (IV iv) sPoint input =
     mconcat $ doXts iniTweak $ chunk (blockSize cipher) input
-  where encTweak = ecbEncrypt tweakCipher iv
-        iniTweak = iterate xtsGFMul encTweak !! fromIntegral sPoint
-        doXts _     []     = []
-        doXts tweak (i:is) =
-            let o = B.xor (f cipher $ B.xor i tweak) tweak
-             in o : doXts (xtsGFMul tweak) is
+  where
+    encTweak = ecbEncrypt tweakCipher iv
+    iniTweak = iterate xtsGFMul encTweak !! fromIntegral sPoint
+    doXts _ [] = []
+    doXts tweak (i : is) =
+        let o = B.xor (f cipher $ B.xor i tweak) tweak
+         in o : doXts (xtsGFMul tweak) is
 
 {-
 -- | Encrypt using CFB mode in 8 bit output
diff --git a/Crypto/Cipher/Types/GF.hs b/Crypto/Cipher/Types/GF.hs
--- a/Crypto/Cipher/Types/GF.hs
+++ b/Crypto/Cipher/Types/GF.hs
@@ -6,19 +6,17 @@
 -- Portability : Excellent
 --
 -- Slow Galois Field arithmetic for generic XTS and GCM implementation
---
-module Crypto.Cipher.Types.GF
-    (
+module Crypto.Cipher.Types.GF (
     -- * XTS support
-      xtsGFMul
-    ) where
+    xtsGFMul,
+) where
 
-import           Crypto.Internal.Imports
-import           Crypto.Internal.ByteArray (ByteArray, withByteArray)
+import Crypto.Internal.ByteArray (ByteArray, withByteArray)
 import qualified Crypto.Internal.ByteArray as B
-import           Foreign.Storable
-import           Foreign.Ptr
-import           Data.Bits
+import Crypto.Internal.Imports
+import Data.Bits
+import Foreign.Ptr
+import Foreign.Storable
 
 -- | Compute the gfmul with the XTS polynomial
 --
@@ -29,19 +27,22 @@
 xtsGFMul b
     | len == 16 =
         B.allocAndFreeze len $ \dst ->
-        withByteArray b      $ \src -> do
-            (hi,lo) <- gf <$> peek (castPtr src) <*> peek (castPtr src `plusPtr` 8)
-            poke (castPtr dst) lo
-            poke (castPtr dst `plusPtr` 8) hi
+            withByteArray b $ \src -> do
+                (hi, lo) <- gf <$> peek (castPtr src) <*> peek (castPtr src `plusPtr` 8)
+                poke (castPtr dst) lo
+                poke (castPtr dst `plusPtr` 8) hi
     | otherwise = error "unsupported block size in GF"
-  where gf :: Word64 -> Word64 -> (Word64, Word64)
-        gf srcLo srcHi =
-            ((if carryLo then (.|. 1) else id) (srcHi `shiftL` 1)
-            ,(if carryHi then xor 0x87 else id) $ (srcLo `shiftL` 1)
-            )
-          where carryHi = srcHi `testBit` 63 
-                carryLo = srcLo `testBit` 63
-        len = B.length b
+  where
+    gf :: Word64 -> Word64 -> (Word64, Word64)
+    gf srcLo srcHi =
+        ( (if carryLo then (.|. 1) else id) (srcHi `shiftL` 1)
+        , (if carryHi then xor 0x87 else id) $ (srcLo `shiftL` 1)
+        )
+      where
+        carryHi = srcHi `testBit` 63
+        carryLo = srcLo `testBit` 63
+    len = B.length b
+
 {-
 	const uint64_t gf_mask = cpu_to_le64(0x8000000000000000ULL);
 	uint64_t r = ((a->q[1] & gf_mask) ? cpu_to_le64(0x87) : 0);
diff --git a/Crypto/Cipher/Types/Stream.hs b/Crypto/Cipher/Types/Stream.hs
--- a/Crypto/Cipher/Types/Stream.hs
+++ b/Crypto/Cipher/Types/Stream.hs
@@ -6,10 +6,9 @@
 -- Portability : Excellent
 --
 -- Stream cipher basic types
---
-module Crypto.Cipher.Types.Stream
-    ( StreamCipher(..)
-    ) where
+module Crypto.Cipher.Types.Stream (
+    StreamCipher (..),
+) where
 
 import Crypto.Cipher.Types.Base
 import Crypto.Internal.ByteArray (ByteArray)
diff --git a/Crypto/Cipher/Types/Utils.hs b/Crypto/Cipher/Types/Utils.hs
--- a/Crypto/Cipher/Types/Utils.hs
+++ b/Crypto/Cipher/Types/Utils.hs
@@ -6,16 +6,17 @@
 -- Portability : Excellent
 --
 -- Basic utility for cipher related stuff
---
 module Crypto.Cipher.Types.Utils where
 
-import           Crypto.Internal.ByteArray (ByteArray)
+import Crypto.Internal.ByteArray (ByteArray)
 import qualified Crypto.Internal.ByteArray as B
 
 -- | Chunk some input byte array into @sz byte list of byte array.
 chunk :: ByteArray b => Int -> b -> [b]
 chunk sz bs = split bs
-  where split b | B.length b <= sz = [b]
-                | otherwise        =
-                        let (b1, b2) = B.splitAt sz b
-                         in b1 : split b2
+  where
+    split b
+        | B.length b <= sz = [b]
+        | otherwise =
+            let (b1, b2) = B.splitAt sz b
+             in b1 : split b2
diff --git a/Crypto/Cipher/Utils.hs b/Crypto/Cipher/Utils.hs
--- a/Crypto/Cipher/Utils.hs
+++ b/Crypto/Cipher/Utils.hs
@@ -1,18 +1,21 @@
-module Crypto.Cipher.Utils
-    ( validateKeySize
-    ) where
+module Crypto.Cipher.Utils (
+    validateKeySize,
+) where
 
-import Crypto.Error
 import Crypto.Cipher.Types
+import Crypto.Error
 
 import Data.ByteArray as BA
 
-validateKeySize :: (ByteArrayAccess key, Cipher cipher) => cipher -> key -> CryptoFailable key
-validateKeySize c k = if validKeyLength
-                      then CryptoPassed k
-                      else CryptoFailed CryptoError_KeySizeInvalid
-  where keyLength = BA.length k
-        validKeyLength = case cipherKeySize c of
-          KeySizeRange low high -> keyLength >= low && keyLength <= high
-          KeySizeEnum lengths -> keyLength `elem` lengths
-          KeySizeFixed s -> keyLength == s
+validateKeySize
+    :: (ByteArrayAccess key, Cipher cipher) => cipher -> key -> CryptoFailable key
+validateKeySize c k =
+    if validKeyLength
+        then CryptoPassed k
+        else CryptoFailed CryptoError_KeySizeInvalid
+  where
+    keyLength = BA.length k
+    validKeyLength = case cipherKeySize c of
+        KeySizeRange low high -> keyLength >= low && keyLength <= high
+        KeySizeEnum lengths -> keyLength `elem` lengths
+        KeySizeFixed s -> keyLength == s
diff --git a/Crypto/Cipher/XSalsa.hs b/Crypto/Cipher/XSalsa.hs
--- a/Crypto/Cipher/XSalsa.hs
+++ b/Crypto/Cipher/XSalsa.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+
 -- |
 -- Module      : Crypto.Cipher.XSalsa
 -- License     : BSD-style
@@ -8,42 +10,48 @@
 -- Implementation of XSalsa20 algorithm
 -- <https://cr.yp.to/snuffle/xsalsa-20081128.pdf>
 -- Based on the Salsa20 algorithm with 256 bit key extended with 192 bit nonce
-
-{-# LANGUAGE ForeignFunctionInterface #-}
-module Crypto.Cipher.XSalsa
-    ( initialize
-    , derive
-    , combine
-    , generate
-    , State
-    ) where
+module Crypto.Cipher.XSalsa (
+    initialize,
+    derive,
+    combine,
+    generate,
+    State,
+) where
 
-import           Crypto.Internal.ByteArray (ByteArrayAccess)
+import Crypto.Cipher.Salsa hiding (initialize)
+import Crypto.Internal.ByteArray (ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Foreign.Ptr
-import           Crypto.Cipher.Salsa hiding (initialize)
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Foreign.Ptr
 
 -- | Initialize a new XSalsa context with the number of rounds,
 -- the key and the nonce associated.
-initialize :: (ByteArrayAccess key, ByteArrayAccess nonce)
-           => Int    -- ^ number of rounds (8,12,20)
-           -> key    -- ^ the key (256 bits)
-           -> nonce  -- ^ the nonce (192 bits)
-           -> State  -- ^ the initial XSalsa state
+initialize
+    :: (ByteArrayAccess key, ByteArrayAccess nonce)
+    => Int
+    -- ^ number of rounds (8,12,20)
+    -> key
+    -- ^ the key (256 bits)
+    -> nonce
+    -- ^ the nonce (192 bits)
+    -> State
+    -- ^ the initial XSalsa state
 initialize nbRounds key nonce
-    | kLen /= 32                      = error "XSalsa: key length should be 256 bits"
-    | nonceLen /= 24                  = error "XSalsa: nonce length should be 192 bits"
-    | nbRounds `notElem` [8,12,20]    = error "XSalsa: rounds should be 8, 12 or 20"
+    | kLen /= 32 =
+        error "XSalsa: key length should be 256 bits"
+    | nonceLen /= 24 =
+        error "XSalsa: nonce length should be 192 bits"
+    | nbRounds `notElem` [8, 12, 20] = error "XSalsa: rounds should be 8, 12 or 20"
     | otherwise = unsafeDoIO $ do
         stPtr <- B.alloc 132 $ \stPtr ->
-            B.withByteArray nonce $ \noncePtr  ->
-            B.withByteArray key   $ \keyPtr ->
-                ccrypton_xsalsa_init stPtr nbRounds kLen keyPtr nonceLen noncePtr
+            B.withByteArray nonce $ \noncePtr ->
+                B.withByteArray key $ \keyPtr ->
+                    ccrypton_xsalsa_init stPtr nbRounds kLen keyPtr nonceLen noncePtr
         return $ State stPtr
-  where kLen     = B.length key
-        nonceLen = B.length nonce
+  where
+    kLen = B.length key
+    nonceLen = B.length nonce
 
 -- | Use an already initialized context and new nonce material to derive another
 -- XSalsa context.
@@ -55,21 +63,27 @@
 --
 -- The output context always uses the same number of rounds as the input
 -- context.
-derive :: ByteArrayAccess nonce
-       => State  -- ^ base XSalsa state
-       -> nonce  -- ^ the remainder nonce (128 bits)
-       -> State  -- ^ the new XSalsa state
+derive
+    :: ByteArrayAccess nonce
+    => State
+    -- ^ base XSalsa state
+    -> nonce
+    -- ^ the remainder nonce (128 bits)
+    -> State
+    -- ^ the new XSalsa state
 derive (State stPtr') nonce
     | nonceLen /= 16 = error "XSalsa: nonce length should be 128 bits"
     | otherwise = unsafeDoIO $ do
         stPtr <- B.copy stPtr' $ \stPtr ->
-            B.withByteArray nonce $ \noncePtr  ->
+            B.withByteArray nonce $ \noncePtr ->
                 ccrypton_xsalsa_derive stPtr nonceLen noncePtr
         return $ State stPtr
-  where nonceLen = B.length nonce
+  where
+    nonceLen = B.length nonce
 
 foreign import ccall "crypton_xsalsa_init"
-    ccrypton_xsalsa_init :: Ptr State -> Int -> Int -> Ptr Word8 -> Int -> Ptr Word8 -> IO ()
+    ccrypton_xsalsa_init
+        :: Ptr State -> Int -> Int -> Ptr Word8 -> Int -> Ptr Word8 -> IO ()
 
 foreign import ccall "crypton_xsalsa_derive"
     ccrypton_xsalsa_derive :: Ptr State -> Int -> Ptr Word8 -> IO ()
diff --git a/Crypto/ConstructHash/MiyaguchiPreneel.hs b/Crypto/ConstructHash/MiyaguchiPreneel.hs
--- a/Crypto/ConstructHash/MiyaguchiPreneel.hs
+++ b/Crypto/ConstructHash/MiyaguchiPreneel.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.ConstructHash.MiyaguchiPreneel
 -- License     : BSD-style
@@ -7,40 +9,43 @@
 --
 -- Provide the hash function construction method from block cipher
 -- <https://en.wikipedia.org/wiki/One-way_compression_function>
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.ConstructHash.MiyaguchiPreneel
-       ( compute, compute'
-       , MiyaguchiPreneel
-       ) where
+module Crypto.ConstructHash.MiyaguchiPreneel (
+    compute,
+    compute',
+    MiyaguchiPreneel,
+) where
 
-import           Data.List (foldl')
+import Data.List (foldl')
+import Prelude hiding (foldl')
 
-import           Crypto.Data.Padding (pad, Format (ZERO))
-import           Crypto.Cipher.Types
-import           Crypto.Error (throwCryptoError)
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray, Bytes)
+import Crypto.Cipher.Types
+import Crypto.Data.Padding (Format (ZERO), pad)
+import Crypto.Error (throwCryptoError)
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, Bytes)
 import qualified Crypto.Internal.ByteArray as B
 
-
 newtype MiyaguchiPreneel a = MP Bytes
     deriving (ByteArrayAccess)
 
 instance Eq (MiyaguchiPreneel a) where
-    MP b1 == MP b2  =  B.constEq b1 b2
-
+    MP b1 == MP b2 = B.constEq b1 b2
 
 -- | Compute Miyaguchi-Preneel one way compress using the supplied block cipher.
-compute' :: (ByteArrayAccess bin, BlockCipher cipher)
-         => (Bytes -> cipher)       -- ^ key build function to compute Miyaguchi-Preneel. care about block-size and key-size
-         -> bin                     -- ^ input message
-         -> MiyaguchiPreneel cipher -- ^ output tag
-compute' g = MP . foldl' (step $ g) (B.replicate bsz 0) . chunks . pad (ZERO bsz) . B.convert
+compute'
+    :: (ByteArrayAccess bin, BlockCipher cipher)
+    => (Bytes -> cipher)
+    -- ^ key build function to compute Miyaguchi-Preneel. care about block-size and key-size
+    -> bin
+    -- ^ input message
+    -> MiyaguchiPreneel cipher
+    -- ^ output tag
+compute' g =
+    MP . foldl' (step $ g) (B.replicate bsz 0) . chunks . pad (ZERO bsz) . B.convert
   where
-    bsz = blockSize ( g B.empty {- dummy to get block size -} )
+    bsz = blockSize (g B.empty {- dummy to get block size -})
     chunks msg
-      | B.null msg  =  []
-      | otherwise  =   (hd :: Bytes) : chunks tl
+        | B.null msg = []
+        | otherwise = (hd :: Bytes) : chunks tl
       where
         (hd, tl) = B.splitAt bsz msg
 
@@ -48,17 +53,21 @@
 --   Only safe when KEY-SIZE equals to BLOCK-SIZE.
 --
 --   Simple usage /mp' msg :: MiyaguchiPreneel AES128/
-compute :: (ByteArrayAccess bin, BlockCipher cipher)
-        => bin                     -- ^ input message
-        -> MiyaguchiPreneel cipher -- ^ output tag
+compute
+    :: (ByteArrayAccess bin, BlockCipher cipher)
+    => bin
+    -- ^ input message
+    -> MiyaguchiPreneel cipher
+    -- ^ output tag
 compute = compute' $ throwCryptoError . cipherInit
 
 -- | computation step of Miyaguchi-Preneel
-step :: (ByteArray ba, BlockCipher k)
-     => (ba -> k)
-     -> ba
-     -> ba
-     -> ba
+step
+    :: (ByteArray ba, BlockCipher k)
+    => (ba -> k)
+    -> ba
+    -> ba
+    -> ba
 step g iv msg =
     ecbEncrypt k msg `bxor` iv `bxor` msg
   where
diff --git a/Crypto/Data/AFIS.hs b/Crypto/Data/AFIS.hs
--- a/Crypto/Data/AFIS.hs
+++ b/Crypto/Data/AFIS.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- |
 -- Module      : Crypto.Data.AFIS
 -- License     : BSD-style
@@ -11,26 +13,24 @@
 -- The algorithm bloats an arbitrary secret with many bits that are necessary for
 -- the recovery of the key (merge), and allow greater way to permanently
 -- destroy a key stored on disk.
---
-{-# LANGUAGE ScopedTypeVariables #-}
-module Crypto.Data.AFIS
-    ( split
-    , merge
-    ) where
+module Crypto.Data.AFIS (
+    split,
+    merge,
+) where
 
-import           Crypto.Hash
-import           Crypto.Random.Types
-import           Crypto.Internal.Compat
-import           Control.Monad (forM_, foldM)
-import           Data.Word
-import           Data.Bits
-import           Foreign.Storable
-import           Foreign.Ptr
+import Control.Monad (foldM, forM_)
+import Crypto.Hash
+import Crypto.Internal.Compat
+import Crypto.Random.Types
+import Data.Bits
+import Data.Word
+import Foreign.Ptr
+import Foreign.Storable
 
-import           Crypto.Internal.ByteArray (ByteArray, Bytes, MemView(..))
+import Crypto.Internal.ByteArray (ByteArray, Bytes, MemView (..))
 import qualified Crypto.Internal.ByteArray as B
 
-import           Data.Memory.PtrMethods (memSet, memCopy)
+import Data.Memory.PtrMethods (memCopy, memSet)
 
 -- | Split data to diffused data, using a random generator and
 -- an hash algorithm.
@@ -49,57 +49,69 @@
 --
 -- where acc is :
 --   acc(n+1) = hash (n ++ rand(n)) ^ acc(n)
---
-split :: (ByteArray ba, HashAlgorithm hash, DRG rng)
-      => hash  -- ^ Hash algorithm to use as diffuser
-      -> rng   -- ^ Random generator to use
-      -> Int   -- ^ Number of times to diffuse the data.
-      -> ba    -- ^ original data to diffuse.
-      -> (ba, rng)         -- ^ The diffused data
+split
+    :: (ByteArray ba, HashAlgorithm hash, DRG rng)
+    => hash
+    -- ^ Hash algorithm to use as diffuser
+    -> rng
+    -- ^ Random generator to use
+    -> Int
+    -- ^ Number of times to diffuse the data.
+    -> ba
+    -- ^ original data to diffuse.
+    -> (ba, rng)
+    -- ^ The diffused data
 {-# NOINLINE split #-}
 split hashAlg rng expandTimes src
     | expandTimes <= 1 = error "invalid expandTimes value"
-    | otherwise        = unsafeDoIO $ do
+    | otherwise = unsafeDoIO $ do
         (rng', bs) <- B.allocRet diffusedLen runOp
         return (bs, rng')
-  where diffusedLen = blockSize * expandTimes
-        blockSize   = B.length src
-        runOp dstPtr = do
-            let lastBlock = dstPtr `plusPtr` (blockSize * (expandTimes-1))
-            memSet lastBlock 0 blockSize
-            let randomBlockPtrs = map (plusPtr dstPtr . (*) blockSize) [0..(expandTimes-2)]
-            rng' <- foldM fillRandomBlock rng randomBlockPtrs
-            mapM_ (addRandomBlock lastBlock) randomBlockPtrs
-            B.withByteArray src $ \srcPtr -> xorMem srcPtr lastBlock blockSize
-            return rng'
-        addRandomBlock lastBlock blockPtr = do
-            xorMem blockPtr lastBlock blockSize
-            diffuse hashAlg lastBlock blockSize
-        fillRandomBlock g blockPtr = do
-            let (rand :: Bytes, g') = randomBytesGenerate blockSize g
-            B.withByteArray rand $ \randPtr -> memCopy blockPtr randPtr blockSize
-            return g'
+  where
+    diffusedLen = blockSize * expandTimes
+    blockSize = B.length src
+    runOp dstPtr = do
+        let lastBlock = dstPtr `plusPtr` (blockSize * (expandTimes - 1))
+        memSet lastBlock 0 blockSize
+        let randomBlockPtrs = map (plusPtr dstPtr . (*) blockSize) [0 .. (expandTimes - 2)]
+        rng' <- foldM fillRandomBlock rng randomBlockPtrs
+        mapM_ (addRandomBlock lastBlock) randomBlockPtrs
+        B.withByteArray src $ \srcPtr -> xorMem srcPtr lastBlock blockSize
+        return rng'
+    addRandomBlock lastBlock blockPtr = do
+        xorMem blockPtr lastBlock blockSize
+        diffuse hashAlg lastBlock blockSize
+    fillRandomBlock g blockPtr = do
+        let (rand :: Bytes, g') = randomBytesGenerate blockSize g
+        B.withByteArray rand $ \randPtr -> memCopy blockPtr randPtr blockSize
+        return g'
 
 -- | Merge previously diffused data back to the original data.
-merge :: (ByteArray ba, HashAlgorithm hash)
-      => hash  -- ^ Hash algorithm used as diffuser
-      -> Int   -- ^ Number of times to un-diffuse the data
-      -> ba    -- ^ Diffused data
-      -> ba    -- ^ Original data
+merge
+    :: (ByteArray ba, HashAlgorithm hash)
+    => hash
+    -- ^ Hash algorithm used as diffuser
+    -> Int
+    -- ^ Number of times to un-diffuse the data
+    -> ba
+    -- ^ Diffused data
+    -> ba
+    -- ^ Original data
 {-# NOINLINE merge #-}
 merge hashAlg expandTimes bs
-    | r /= 0            = error "diffused data not a multiple of expandTimes"
+    | r /= 0 = error "diffused data not a multiple of expandTimes"
     | originalSize <= 0 = error "diffused data null"
-    | otherwise         = B.allocAndFreeze originalSize $ \dstPtr ->
+    | otherwise = B.allocAndFreeze originalSize $ \dstPtr ->
         B.withByteArray bs $ \srcPtr -> do
             memSet dstPtr 0 originalSize
-            forM_ [0..(expandTimes-2)] $ \i -> do
+            forM_ [0 .. (expandTimes - 2)] $ \i -> do
                 xorMem (srcPtr `plusPtr` (i * originalSize)) dstPtr originalSize
                 diffuse hashAlg dstPtr originalSize
-            xorMem (srcPtr `plusPtr` ((expandTimes-1) * originalSize)) dstPtr originalSize
+            xorMem (srcPtr `plusPtr` ((expandTimes - 1) * originalSize)) dstPtr originalSize
             return ()
-  where (originalSize,r) = len `quotRem` expandTimes
-        len              = B.length bs
+  where
+    (originalSize, r) = len `quotRem` expandTimes
+    len = B.length bs
 
 -- | inplace Xor with an input
 -- dst = src `xor` dst
@@ -107,42 +119,51 @@
 xorMem src dst sz
     | sz `mod` 64 == 0 = loop 8 (castPtr src :: Ptr Word64) (castPtr dst) sz
     | sz `mod` 32 == 0 = loop 4 (castPtr src :: Ptr Word32) (castPtr dst) sz
-    | otherwise        = loop 1 (src :: Ptr Word8) dst sz
-  where loop _    _ _ 0 = return ()
-        loop incr s d n = do a <- peek s
-                             b <- peek d
-                             poke d (a `xor` b)
-                             loop incr (s `plusPtr` incr) (d `plusPtr` incr) (n-incr)
+    | otherwise = loop 1 (src :: Ptr Word8) dst sz
+  where
+    loop _ _ _ 0 = return ()
+    loop incr s d n = do
+        a <- peek s
+        b <- peek d
+        poke d (a `xor` b)
+        loop incr (s `plusPtr` incr) (d `plusPtr` incr) (n - incr)
 
-diffuse :: HashAlgorithm hash
-        => hash      -- ^ Hash function to use as diffuser
-        -> Ptr Word8 -- ^ buffer to diffuse, modify in place
-        -> Int       -- ^ length of buffer to diffuse
-        -> IO ()
+diffuse
+    :: HashAlgorithm hash
+    => hash
+    -- ^ Hash function to use as diffuser
+    -> Ptr Word8
+    -- ^ buffer to diffuse, modify in place
+    -> Int
+    -- ^ length of buffer to diffuse
+    -> IO ()
 diffuse hashAlg src sz = loop src 0
-  where (full,pad) = sz `quotRem` digestSize 
-        loop s i
-            | i < full = do h <- hashBlock i s digestSize
-                            B.withByteArray h $ \hPtr -> memCopy s hPtr digestSize
-                            loop (s `plusPtr` digestSize) (i+1)
-            | pad /= 0 = do h <- hashBlock i s pad
-                            B.withByteArray h $ \hPtr -> memCopy s hPtr pad
-                            return ()
-            | otherwise = return ()
+  where
+    (full, pad) = sz `quotRem` digestSize
+    loop s i
+        | i < full = do
+            h <- hashBlock i s digestSize
+            B.withByteArray h $ \hPtr -> memCopy s hPtr digestSize
+            loop (s `plusPtr` digestSize) (i + 1)
+        | pad /= 0 = do
+            h <- hashBlock i s pad
+            B.withByteArray h $ \hPtr -> memCopy s hPtr pad
+            return ()
+        | otherwise = return ()
 
-        digestSize = hashDigestSize hashAlg
+    digestSize = hashDigestSize hashAlg
 
-        -- Hash [ BE32(n), (p .. p+hashSz) ]
-        hashBlock n p hashSz = do
-            let ctx = hashInitWith hashAlg
-            return $! hashFinalize $ hashUpdate (hashUpdate ctx (be32 n)) (MemView p hashSz)
+    -- Hash [ BE32(n), (p .. p+hashSz) ]
+    hashBlock n p hashSz = do
+        let ctx = hashInitWith hashAlg
+        return $! hashFinalize $ hashUpdate (hashUpdate ctx (be32 n)) (MemView p hashSz)
 
-        be32 :: Int -> Bytes
-        be32 n = B.allocAndFreeze 4 $ \ptr -> do
-            poke ptr               (f8 (n `shiftR` 24))
-            poke (ptr `plusPtr` 1) (f8 (n `shiftR` 16))
-            poke (ptr `plusPtr` 2) (f8 (n `shiftR` 8))
-            poke (ptr `plusPtr` 3) (f8 n)
-          where
-                f8 :: Int -> Word8
-                f8 = fromIntegral
+    be32 :: Int -> Bytes
+    be32 n = B.allocAndFreeze 4 $ \ptr -> do
+        poke ptr (f8 (n `shiftR` 24))
+        poke (ptr `plusPtr` 1) (f8 (n `shiftR` 16))
+        poke (ptr `plusPtr` 2) (f8 (n `shiftR` 8))
+        poke (ptr `plusPtr` 3) (f8 n)
+      where
+        f8 :: Int -> Word8
+        f8 = fromIntegral
diff --git a/Crypto/Data/Padding.hs b/Crypto/Data/Padding.hs
--- a/Crypto/Data/Padding.hs
+++ b/Crypto/Data/Padding.hs
@@ -7,59 +7,61 @@
 --
 -- Various cryptographic padding commonly used for block ciphers
 -- or asymmetric systems.
---
-module Crypto.Data.Padding
-    ( Format(..)
-    , pad
-    , unpad
-    ) where
+module Crypto.Data.Padding (
+    Format (..),
+    pad,
+    unpad,
+) where
 
-import           Data.ByteArray (ByteArray, Bytes)
+import Data.ByteArray (ByteArray, Bytes)
 import qualified Data.ByteArray as B
 
 -- | Format of padding
-data Format =
-      PKCS5     -- ^ PKCS5: PKCS7 with hardcoded size of 8
-    | PKCS7 Int -- ^ PKCS7 with padding size between 1 and 255
-    | ZERO Int  -- ^ zero padding with block size
+data Format
+    = -- | PKCS5: PKCS7 with hardcoded size of 8
+      PKCS5
+    | -- | PKCS7 with padding size between 1 and 255
+      PKCS7 Int
+    | -- | zero padding with block size
+      ZERO Int
     deriving (Show, Eq)
 
 -- | Apply some pad to a bytearray
 pad :: ByteArray byteArray => Format -> byteArray -> byteArray
-pad  PKCS5     bin = pad (PKCS7 8) bin
+pad PKCS5 bin = pad (PKCS7 8) bin
 pad (PKCS7 sz) bin = bin `B.append` paddingString
   where
     paddingString = B.replicate paddingByte (fromIntegral paddingByte)
-    paddingByte   = sz - (B.length bin `mod` sz)
-pad (ZERO sz)  bin = bin `B.append` paddingString
+    paddingByte = sz - (B.length bin `mod` sz)
+pad (ZERO sz) bin = bin `B.append` paddingString
   where
     paddingString = B.replicate paddingSz 0
     paddingSz
-      | len == 0   =  sz
-      | m == 0     =  0
-      | otherwise  =  sz - m
+        | len == 0 = sz
+        | m == 0 = 0
+        | otherwise = sz - m
     m = len `mod` sz
     len = B.length bin
 
 -- | Try to remove some padding from a bytearray.
 unpad :: ByteArray byteArray => Format -> byteArray -> Maybe byteArray
-unpad  PKCS5     bin = unpad (PKCS7 8) bin
+unpad PKCS5 bin = unpad (PKCS7 8) bin
 unpad (PKCS7 sz) bin
-    | len == 0                           = Nothing
-    | (len `mod` sz) /= 0                = Nothing
-    | paddingSz < 1 || paddingSz > len   = Nothing
+    | len == 0 = Nothing
+    | (len `mod` sz) /= 0 = Nothing
+    | paddingSz < 1 || paddingSz > len = Nothing
     | paddingWitness `B.constEq` padding = Just content
-    | otherwise                          = Nothing
+    | otherwise = Nothing
   where
-    len         = B.length bin
+    len = B.length bin
     paddingByte = B.index bin (len - 1)
-    paddingSz   = fromIntegral paddingByte
+    paddingSz = fromIntegral paddingByte
     (content, padding) = B.splitAt (len - paddingSz) bin
-    paddingWitness     = B.replicate paddingSz paddingByte :: Bytes
-unpad (ZERO sz)  bin
-    | len == 0                           = Nothing
-    | (len `mod` sz) /= 0                = Nothing
-    | B.index bin (len - 1) /= 0         = Just bin
-    | otherwise                          = Nothing
+    paddingWitness = B.replicate paddingSz paddingByte :: Bytes
+unpad (ZERO sz) bin
+    | len == 0 = Nothing
+    | (len `mod` sz) /= 0 = Nothing
+    | B.index bin (len - 1) /= 0 = Just bin
+    | otherwise = Nothing
   where
-    len         = B.length bin
+    len = B.length bin
diff --git a/Crypto/ECC.hs b/Crypto/ECC.hs
--- a/Crypto/ECC.hs
+++ b/Crypto/ECC.hs
@@ -1,3 +1,9 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.ECC
 -- License     : BSD-style
@@ -6,69 +12,76 @@
 -- Portability : unknown
 --
 -- Elliptic Curve Cryptography
---
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE TypeFamilies #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-module Crypto.ECC
-    ( Curve_P256R1(..)
-    , Curve_P384R1(..)
-    , Curve_P521R1(..)
-    , Curve_X25519(..)
-    , Curve_X448(..)
-    , Curve_Edwards25519(..)
-    , EllipticCurve(..)
-    , EllipticCurveDH(..)
-    , EllipticCurveArith(..)
-    , EllipticCurveBasepointArith(..)
-    , KeyPair(..)
-    , SharedSecret(..)
-    ) where
+module Crypto.ECC (
+    Curve_P256R1 (..),
+    Curve_P384R1 (..),
+    Curve_P521R1 (..),
+    Curve_X25519 (..),
+    Curve_X448 (..),
+    Curve_Edwards25519 (..),
+    EllipticCurve (..),
+    EllipticCurveDH (..),
+    EllipticCurveArith (..),
+    EllipticCurveBasepointArith (..),
+    KeyPair (..),
+    SharedSecret (..),
+) where
 
-import qualified Crypto.PubKey.ECC.P256 as P256
 import qualified Crypto.ECC.Edwards25519 as Edwards25519
-import qualified Crypto.ECC.Simple.Types as Simple
 import qualified Crypto.ECC.Simple.Prim as Simple
-import           Crypto.Random
-import           Crypto.Error
-import           Crypto.Internal.Imports
-import           Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, ScrubbedBytes)
+import qualified Crypto.ECC.Simple.Types as Simple
+import Crypto.Error
+import Crypto.Internal.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    ScrubbedBytes,
+ )
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Number.Basic (numBits)
-import           Crypto.Number.Serialize (i2ospOf_, os2ip)
+import Crypto.Internal.Imports
+import Crypto.Number.Basic (numBits)
+import Crypto.Number.Serialize (i2ospOf_, os2ip)
 import qualified Crypto.Number.Serialize.LE as LE
 import qualified Crypto.PubKey.Curve25519 as X25519
 import qualified Crypto.PubKey.Curve448 as X448
-import           Data.ByteArray (convert)
-import           Data.Data (Data())
-import           Data.Kind (Type)
-import           Data.Proxy
+import qualified Crypto.PubKey.ECC.P256 as P256
+import Crypto.Random
+import Data.ByteArray (convert)
+import Data.Data (Data ())
+import Data.Kind (Type)
+import Data.Proxy
 
 -- | An elliptic curve key pair composed of the private part (a scalar), and
 -- the associated point.
 data KeyPair curve = KeyPair
-    { keypairGetPublic  :: !(Point curve)
+    { keypairGetPublic :: !(Point curve)
     , keypairGetPrivate :: !(Scalar curve)
     }
 
+-- | Secret shared via key exchange
 newtype SharedSecret = SharedSecret ScrubbedBytes
     deriving (Eq, ByteArrayAccess, NFData)
 
+instance Semigroup SharedSecret where
+    SharedSecret x <> SharedSecret y = SharedSecret (x <> y)
+
+instance Monoid SharedSecret where
+    mempty = SharedSecret mempty
+
 class EllipticCurve curve where
     -- | Point on an Elliptic Curve
-    type Point curve  :: Type
+    type Point curve :: Type
 
     -- | Scalar in the Elliptic Curve domain
     type Scalar curve :: Type
 
     -- | Generate a new random scalar on the curve.
     -- The scalar will represent a number between 1 and the order of the curve non included
-    curveGenerateScalar :: MonadRandom randomly => proxy curve -> randomly (Scalar curve)
+    curveGenerateScalar
+        :: MonadRandom randomly => proxy curve -> randomly (Scalar curve)
 
     -- | Generate a new random keypair
-    curveGenerateKeyPair :: MonadRandom randomly => proxy curve -> randomly (KeyPair curve)
+    curveGenerateKeyPair
+        :: MonadRandom randomly => proxy curve -> randomly (KeyPair curve)
 
     -- | Get the curve size in bits
     curveSizeBits :: proxy curve -> Int
@@ -79,6 +92,15 @@
     -- | Try to decode the binary form of an elliptic curve point
     decodePoint :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Point curve)
 
+    -- | Encode an elliptic curve scalar into big-endian form
+    encodeScalar :: ByteArray bs => proxy curve -> Scalar curve -> bs
+
+    -- | Try to decode the big-endian form of an elliptic curve scalar
+    decodeScalar
+        :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Scalar curve)
+
+    scalarToPoint :: proxy curve -> Scalar curve -> Point curve
+
 class EllipticCurve curve => EllipticCurveDH curve where
     -- | Generate a Diffie hellman secret value.
     --
@@ -100,7 +122,8 @@
     -- This additional test avoids risks existing with function 'ecdhRaw'.
     -- Implementations always return a 'CryptoError' instead of a special
     -- value or an exception.
-    ecdh :: proxy curve -> Scalar curve -> Point curve -> CryptoFailable SharedSecret
+    ecdh
+        :: proxy curve -> Scalar curve -> Point curve -> CryptoFailable SharedSecret
 
 class (EllipticCurve curve, Eq (Point curve)) => EllipticCurveArith curve where
     -- | Add points on a curve
@@ -115,7 +138,10 @@
 --   -- | Scalar Inverse
 --   scalarInverse :: Scalar curve -> Scalar curve
 
-class (EllipticCurveArith curve, Eq (Scalar curve)) => EllipticCurveBasepointArith curve where
+class
+    (EllipticCurveArith curve, Eq (Scalar curve)) =>
+    EllipticCurveBasepointArith curve
+    where
     -- | Get the curve order size in bits
     curveOrderBits :: proxy curve -> Int
 
@@ -123,15 +149,10 @@
     pointBaseSmul :: proxy curve -> Scalar curve -> Point curve
 
     -- | Multiply the point @p@ with @s2@ and add a lifted to curve value @s1@
-    pointsSmulVarTime :: proxy curve -> Scalar curve -> Scalar curve -> Point curve -> Point curve
+    pointsSmulVarTime
+        :: proxy curve -> Scalar curve -> Scalar curve -> Point curve -> Point curve
     pointsSmulVarTime prx s1 s2 p = pointAdd prx (pointBaseSmul prx s1) (pointSmul prx s2 p)
 
-    -- | Encode an elliptic curve scalar into big-endian form
-    encodeScalar :: ByteArray bs => proxy curve -> Scalar curve -> bs
-
-    -- | Try to decode the big-endian form of an elliptic curve scalar
-    decodeScalar :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Scalar curve)
-
     -- | Convert an elliptic curve scalar to an integer
     scalarToInteger :: proxy curve -> Scalar curve -> Integer
 
@@ -148,7 +169,7 @@
 --
 -- also known as P256
 data Curve_P256R1 = Curve_P256R1
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance EllipticCurve Curve_P256R1 where
     type Point Curve_P256R1 = P256.Point
@@ -156,7 +177,8 @@
     curveSizeBits _ = 256
     curveGenerateScalar _ = P256.scalarGenerate
     curveGenerateKeyPair _ = toKeyPair <$> P256.scalarGenerate
-      where toKeyPair scalar = KeyPair (P256.toPoint scalar) scalar
+      where
+        toKeyPair scalar = KeyPair (P256.toPoint scalar) scalar
     encodePoint _ p = mxy
       where
         mxy :: forall bs. ByteArray bs => bs
@@ -167,33 +189,34 @@
             xy = P256.pointToBinary p
     decodePoint _ mxy = case B.uncons mxy of
         Nothing -> CryptoFailed CryptoError_PointSizeInvalid
-        Just (m,xy)
+        Just (m, xy)
             -- uncompressed
             | m == 4 -> P256.pointFromBinary xy
             | otherwise -> CryptoFailed CryptoError_PointFormatInvalid
+    encodeScalar _ = P256.scalarToBinary
+    decodeScalar _ = P256.scalarFromBinary
+    scalarToPoint _ = P256.toPoint
 
 instance EllipticCurveArith Curve_P256R1 where
-    pointAdd  _ a b = P256.pointAdd a b
+    pointAdd _ a b = P256.pointAdd a b
     pointNegate _ p = P256.pointNegate p
     pointSmul _ s p = P256.pointMul s p
 
 instance EllipticCurveDH Curve_P256R1 where
     ecdhRaw _ s p = SharedSecret $ P256.pointDh s p
-    ecdh  prx s p = checkNonZeroDH (ecdhRaw prx s p)
+    ecdh prx s p = checkNonZeroDH (ecdhRaw prx s p)
 
 instance EllipticCurveBasepointArith Curve_P256R1 where
     curveOrderBits _ = 256
     pointBaseSmul _ = P256.toPoint
     pointsSmulVarTime _ = P256.pointsMulVarTime
-    encodeScalar _ = P256.scalarToBinary
-    decodeScalar _ = P256.scalarFromBinary
     scalarToInteger _ = P256.scalarToInteger
     scalarFromInteger _ = P256.scalarFromInteger
     scalarAdd _ = P256.scalarAdd
     scalarMul _ = P256.scalarMul
 
 data Curve_P384R1 = Curve_P384R1
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance EllipticCurve Curve_P384R1 where
     type Point Curve_P384R1 = Simple.Point Simple.SEC_p384r1
@@ -201,9 +224,13 @@
     curveSizeBits _ = 384
     curveGenerateScalar _ = Simple.scalarGenerate
     curveGenerateKeyPair _ = toKeyPair <$> Simple.scalarGenerate
-      where toKeyPair scalar = KeyPair (Simple.pointBaseMul scalar) scalar
+      where
+        toKeyPair scalar = KeyPair (Simple.pointBaseMul scalar) scalar
     encodePoint _ point = encodeECPoint point
     decodePoint _ bs = decodeECPoint bs
+    encodeScalar _ = ecScalarToBinary
+    decodeScalar _ = ecScalarFromBinary
+    scalarToPoint _ = Simple.pointBaseMul
 
 instance EllipticCurveArith Curve_P384R1 where
     pointAdd _ a b = Simple.pointAdd a b
@@ -219,15 +246,13 @@
     curveOrderBits _ = 384
     pointBaseSmul _ = Simple.pointBaseMul
     pointsSmulVarTime _ = ecPointsMulVarTime
-    encodeScalar _ = ecScalarToBinary
-    decodeScalar _ = ecScalarFromBinary
     scalarToInteger _ = ecScalarToInteger
     scalarFromInteger _ = ecScalarFromInteger
     scalarAdd _ = ecScalarAdd
     scalarMul _ = ecScalarMul
 
 data Curve_P521R1 = Curve_P521R1
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance EllipticCurve Curve_P521R1 where
     type Point Curve_P521R1 = Simple.Point Simple.SEC_p521r1
@@ -235,9 +260,13 @@
     curveSizeBits _ = 521
     curveGenerateScalar _ = Simple.scalarGenerate
     curveGenerateKeyPair _ = toKeyPair <$> Simple.scalarGenerate
-      where toKeyPair scalar = KeyPair (Simple.pointBaseMul scalar) scalar
+      where
+        toKeyPair scalar = KeyPair (Simple.pointBaseMul scalar) scalar
     encodePoint _ point = encodeECPoint point
     decodePoint _ bs = decodeECPoint bs
+    encodeScalar _ = ecScalarToBinary
+    decodeScalar _ = ecScalarFromBinary
+    scalarToPoint _ = Simple.pointBaseMul
 
 instance EllipticCurveArith Curve_P521R1 where
     pointAdd _ a b = Simple.pointAdd a b
@@ -253,15 +282,13 @@
     curveOrderBits _ = 521
     pointBaseSmul _ = Simple.pointBaseMul
     pointsSmulVarTime _ = ecPointsMulVarTime
-    encodeScalar _ = ecScalarToBinary
-    decodeScalar _ = ecScalarFromBinary
     scalarToInteger _ = ecScalarToInteger
     scalarFromInteger _ = ecScalarFromInteger
     scalarAdd _ = ecScalarAdd
     scalarMul _ = ecScalarMul
 
 data Curve_X25519 = Curve_X25519
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance EllipticCurve Curve_X25519 where
     type Point Curve_X25519 = X25519.PublicKey
@@ -273,14 +300,18 @@
         return $ KeyPair (X25519.toPublic s) s
     encodePoint _ p = B.convert p
     decodePoint _ bs = X25519.publicKey bs
+    encodeScalar _ s = convert s
+    decodeScalar _ bs = X25519.secretKey bs
+    scalarToPoint _ s = X25519.toPublic s
 
 instance EllipticCurveDH Curve_X25519 where
     ecdhRaw _ s p = SharedSecret $ convert secret
-      where secret = X25519.dh p s
+      where
+        secret = X25519.dh p s
     ecdh prx s p = checkNonZeroDH (ecdhRaw prx s p)
 
 data Curve_X448 = Curve_X448
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance EllipticCurve Curve_X448 where
     type Point Curve_X448 = X448.PublicKey
@@ -292,14 +323,18 @@
         return $ KeyPair (X448.toPublic s) s
     encodePoint _ p = B.convert p
     decodePoint _ bs = X448.publicKey bs
+    encodeScalar _ s = convert s
+    decodeScalar _ bs = X448.secretKey bs
+    scalarToPoint _ s = X448.toPublic s
 
 instance EllipticCurveDH Curve_X448 where
     ecdhRaw _ s p = SharedSecret $ convert secret
-      where secret = X448.dh p s
+      where
+        secret = X448.dh p s
     ecdh prx s p = checkNonZeroDH (ecdhRaw prx s p)
 
 data Curve_Edwards25519 = Curve_Edwards25519
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance EllipticCurve Curve_Edwards25519 where
     type Point Curve_Edwards25519 = Edwards25519.Point
@@ -307,9 +342,15 @@
     curveSizeBits _ = 255
     curveGenerateScalar _ = Edwards25519.scalarGenerate
     curveGenerateKeyPair _ = toKeyPair <$> Edwards25519.scalarGenerate
-      where toKeyPair scalar = KeyPair (Edwards25519.toPoint scalar) scalar
+      where
+        toKeyPair scalar = KeyPair (Edwards25519.toPoint scalar) scalar
     encodePoint _ point = Edwards25519.pointEncode point
     decodePoint _ bs = Edwards25519.pointDecode bs
+    encodeScalar _ = B.reverse . Edwards25519.scalarEncode
+    decodeScalar _ bs
+        | B.length bs == 32 = Edwards25519.scalarDecodeLong (B.reverse bs)
+        | otherwise = CryptoFailed CryptoError_SecretKeySizeInvalid
+    scalarToPoint _ = Edwards25519.toPoint
 
 instance EllipticCurveArith Curve_Edwards25519 where
     pointAdd _ a b = Edwards25519.pointAdd a b
@@ -320,10 +361,6 @@
     curveOrderBits _ = 253
     pointBaseSmul _ = Edwards25519.toPoint
     pointsSmulVarTime _ = Edwards25519.pointsMulVarTime
-    encodeScalar _ = B.reverse . Edwards25519.scalarEncode
-    decodeScalar _ bs
-        | B.length bs == 32 = Edwards25519.scalarDecodeLong (B.reverse bs)
-        | otherwise         = CryptoFailed CryptoError_SecretKeySizeInvalid
     scalarToInteger _ s = LE.os2ip (Edwards25519.scalarEncode s :: B.Bytes)
     scalarFromInteger _ i =
         case LE.i2ospOf 32 i of
@@ -335,15 +372,18 @@
 checkNonZeroDH :: SharedSecret -> CryptoFailable SharedSecret
 checkNonZeroDH s@(SharedSecret b)
     | B.constAllZero b = CryptoFailed CryptoError_ScalarMultiplicationInvalid
-    | otherwise        = CryptoPassed s
+    | otherwise = CryptoPassed s
 
-encodeECShared :: Simple.Curve curve => Proxy curve -> Simple.Point curve -> CryptoFailable SharedSecret
-encodeECShared _   Simple.PointO      = CryptoFailed CryptoError_ScalarMultiplicationInvalid
+encodeECShared
+    :: Simple.Curve curve
+    => Proxy curve -> Simple.Point curve -> CryptoFailable SharedSecret
+encodeECShared _ Simple.PointO = CryptoFailed CryptoError_ScalarMultiplicationInvalid
 encodeECShared prx (Simple.Point x _) = CryptoPassed . SharedSecret $ i2ospOf_ (Simple.curveSizeBytes prx) x
 
-encodeECPoint :: forall curve bs . (Simple.Curve curve, ByteArray bs) => Simple.Point curve -> bs
-encodeECPoint Simple.PointO      = error "encodeECPoint: cannot serialize point at infinity"
-encodeECPoint (Simple.Point x y) = B.concat [uncompressed,xb,yb]
+encodeECPoint
+    :: forall curve bs. (Simple.Curve curve, ByteArray bs) => Simple.Point curve -> bs
+encodeECPoint Simple.PointO = error "encodeECPoint: cannot serialize point at infinity"
+encodeECPoint (Simple.Point x y) = B.concat [uncompressed, xb, yb]
   where
     size = Simple.curveSizeBytes (Proxy :: Proxy curve)
     uncompressed, xb, yb :: bs
@@ -351,58 +391,79 @@
     xb = i2ospOf_ size x
     yb = i2ospOf_ size y
 
-decodeECPoint :: (Simple.Curve curve, ByteArray bs) => bs -> CryptoFailable (Simple.Point curve)
+decodeECPoint
+    :: (Simple.Curve curve, ByteArray bs) => bs -> CryptoFailable (Simple.Point curve)
 decodeECPoint mxy = case B.uncons mxy of
-    Nothing     -> CryptoFailed CryptoError_PointSizeInvalid
-    Just (m,xy)
+    Nothing -> CryptoFailed CryptoError_PointSizeInvalid
+    Just (m, xy)
         -- uncompressed
         | m == 4 ->
             let siz = B.length xy `div` 2
-                (xb,yb) = B.splitAt siz xy
+                (xb, yb) = B.splitAt siz xy
                 x = os2ip xb
                 y = os2ip yb
-             in Simple.pointFromIntegers (x,y)
+             in Simple.pointFromIntegers (x, y)
         | otherwise -> CryptoFailed CryptoError_PointFormatInvalid
 
-ecPointsMulVarTime :: forall curve . Simple.Curve curve
-                   => Simple.Scalar curve
-                   -> Simple.Scalar curve -> Simple.Point curve
-                   -> Simple.Point curve
+ecPointsMulVarTime
+    :: forall curve
+     . Simple.Curve curve
+    => Simple.Scalar curve
+    -> Simple.Scalar curve
+    -> Simple.Point curve
+    -> Simple.Point curve
 ecPointsMulVarTime n1 = Simple.pointAddTwoMuls n1 g
-  where g = Simple.curveEccG $ Simple.curveParameters (Proxy :: Proxy curve)
+  where
+    g = Simple.curveEccG $ Simple.curveParameters (Proxy :: Proxy curve)
 
-ecScalarFromBinary :: forall curve bs . (Simple.Curve curve, ByteArrayAccess bs)
-                   => bs -> CryptoFailable (Simple.Scalar curve)
+ecScalarFromBinary
+    :: forall curve bs
+     . (Simple.Curve curve, ByteArrayAccess bs)
+    => bs -> CryptoFailable (Simple.Scalar curve)
 ecScalarFromBinary ba
     | B.length ba /= size = CryptoFailed CryptoError_SecretKeySizeInvalid
-    | otherwise           = CryptoPassed (Simple.Scalar $ os2ip ba)
-  where size = ecCurveOrderBytes (Proxy :: Proxy curve)
+    | otherwise = CryptoPassed (Simple.Scalar $ os2ip ba)
+  where
+    size = ecCurveOrderBytes (Proxy :: Proxy curve)
 
-ecScalarToBinary :: forall curve bs . (Simple.Curve curve, ByteArray bs)
-                 => Simple.Scalar curve -> bs
+ecScalarToBinary
+    :: forall curve bs
+     . (Simple.Curve curve, ByteArray bs)
+    => Simple.Scalar curve -> bs
 ecScalarToBinary (Simple.Scalar s) = i2ospOf_ size s
-  where size = ecCurveOrderBytes (Proxy :: Proxy curve)
+  where
+    size = ecCurveOrderBytes (Proxy :: Proxy curve)
 
-ecScalarFromInteger :: forall curve . Simple.Curve curve
-                    => Integer -> CryptoFailable (Simple.Scalar curve)
+ecScalarFromInteger
+    :: forall curve
+     . Simple.Curve curve
+    => Integer -> CryptoFailable (Simple.Scalar curve)
 ecScalarFromInteger s
     | numBits s > nb = CryptoFailed CryptoError_SecretKeySizeInvalid
-    | otherwise      = CryptoPassed (Simple.Scalar s)
-  where nb = 8 * ecCurveOrderBytes (Proxy :: Proxy curve)
+    | otherwise = CryptoPassed (Simple.Scalar s)
+  where
+    nb = 8 * ecCurveOrderBytes (Proxy :: Proxy curve)
 
 ecScalarToInteger :: Simple.Scalar curve -> Integer
 ecScalarToInteger (Simple.Scalar s) = s
 
 ecCurveOrderBytes :: Simple.Curve c => proxy c -> Int
 ecCurveOrderBytes prx = (numBits n + 7) `div` 8
-  where n = Simple.curveEccN $ Simple.curveParameters prx
+  where
+    n = Simple.curveEccN $ Simple.curveParameters prx
 
-ecScalarAdd :: forall curve . Simple.Curve curve
-            => Simple.Scalar curve -> Simple.Scalar curve -> Simple.Scalar curve
+ecScalarAdd
+    :: forall curve
+     . Simple.Curve curve
+    => Simple.Scalar curve -> Simple.Scalar curve -> Simple.Scalar curve
 ecScalarAdd (Simple.Scalar a) (Simple.Scalar b) = Simple.Scalar ((a + b) `mod` n)
-  where n = Simple.curveEccN $ Simple.curveParameters (Proxy :: Proxy curve)
+  where
+    n = Simple.curveEccN $ Simple.curveParameters (Proxy :: Proxy curve)
 
-ecScalarMul :: forall curve . Simple.Curve curve
-            => Simple.Scalar curve -> Simple.Scalar curve -> Simple.Scalar curve
+ecScalarMul
+    :: forall curve
+     . Simple.Curve curve
+    => Simple.Scalar curve -> Simple.Scalar curve -> Simple.Scalar curve
 ecScalarMul (Simple.Scalar a) (Simple.Scalar b) = Simple.Scalar ((a * b) `mod` n)
-  where n = Simple.curveEccN $ Simple.curveParameters (Proxy :: Proxy curve)
+  where
+    n = Simple.curveEccN $ Simple.curveParameters (Proxy :: Proxy curve)
diff --git a/Crypto/ECC/Edwards25519.hs b/Crypto/ECC/Edwards25519.hs
--- a/Crypto/ECC/Edwards25519.hs
+++ b/Crypto/ECC/Edwards25519.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.ECC.Edwards25519
 -- License     : BSD-style
@@ -48,55 +50,55 @@
 -- 3. Because of modular reduction in this implementation it is not
 -- possible to multiply points directly by scalars like 8.s or L.
 -- This has to be decomposed into several steps.
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.ECC.Edwards25519
-    ( Scalar
-    , Point
+module Crypto.ECC.Edwards25519 (
+    Scalar,
+    Point,
+
     -- * Scalars
-    , scalarGenerate
-    , scalarDecodeLong
-    , scalarEncode
+    scalarGenerate,
+    scalarDecodeLong,
+    scalarEncode,
+
     -- * Points
-    , pointDecode
-    , pointEncode
-    , pointHasPrimeOrder
+    pointDecode,
+    pointEncode,
+    pointHasPrimeOrder,
+
     -- * Arithmetic functions
-    , toPoint
-    , scalarAdd
-    , scalarMul
-    , pointNegate
-    , pointAdd
-    , pointDouble
-    , pointMul
-    , pointMulByCofactor
-    , pointsMulVarTime
-    ) where
+    toPoint,
+    scalarAdd,
+    scalarMul,
+    pointNegate,
+    pointAdd,
+    pointDouble,
+    pointMul,
+    pointMulByCofactor,
+    pointsMulVarTime,
+) where
 
-import           Data.Word
-import           Foreign.C.Types
-import           Foreign.Ptr
+import Data.Word
+import Foreign.C.Types
+import Foreign.Ptr
 
-import           Crypto.Error
-import           Crypto.Internal.ByteArray (Bytes, ScrubbedBytes, withByteArray)
+import Crypto.Error
+import Crypto.Internal.ByteArray (Bytes, ScrubbedBytes, withByteArray)
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Crypto.Random
-
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Crypto.Random
 
 scalarArraySize :: Int
 scalarArraySize = 40 -- maximum [9 * 4 {- 32 bits -}, 5 * 8 {- 64 bits -}]
 
 -- | A scalar modulo prime order of curve edwards25519.
 newtype Scalar = Scalar ScrubbedBytes
-    deriving (Show,NFData)
+    deriving (Show, NFData)
 
 instance Eq Scalar where
     (Scalar s1) == (Scalar s2) = unsafeDoIO $
         withByteArray s1 $ \ps1 ->
-        withByteArray s2 $ \ps2 ->
-            fmap (/= 0) (ed25519_scalar_eq ps1 ps2)
+            withByteArray s2 $ \ps2 ->
+                fmap (/= 0) (ed25519_scalar_eq ps1 ps2)
     {-# NOINLINE (==) #-}
 
 pointArraySize :: Int
@@ -104,19 +106,20 @@
 
 -- | A point on curve edwards25519.
 newtype Point = Point Bytes
-    deriving NFData
+    deriving (NFData)
 
 instance Show Point where
     showsPrec d p =
         let bs = pointEncode p :: Bytes
-         in showParen (d > 10) $ showString "Point "
-                               . shows (B.convertToBase B.Base16 bs :: Bytes)
+         in showParen (d > 10) $
+                showString "Point "
+                    . shows (B.convertToBase B.Base16 bs :: Bytes)
 
 instance Eq Point where
     (Point p1) == (Point p2) = unsafeDoIO $
         withByteArray p1 $ \pp1 ->
-        withByteArray p2 $ \pp2 ->
-            fmap (/= 0) (ed25519_point_eq pp1 pp2)
+            withByteArray p2 $ \pp2 ->
+                fmap (/= 0) (ed25519_point_eq pp1 pp2)
     {-# NOINLINE (==) #-}
 
 -- | Generate a random scalar.
@@ -148,12 +151,12 @@
 scalarDecodeLong :: B.ByteArrayAccess bs => bs -> CryptoFailable Scalar
 scalarDecodeLong bs
     | B.length bs > 64 = CryptoFailed CryptoError_EcScalarOutOfBounds
-    | otherwise        = unsafeDoIO $ withByteArray bs initialize
+    | otherwise = unsafeDoIO $ withByteArray bs initialize
   where
     len = fromIntegral $ B.length bs
     initialize inp = do
         s <- B.alloc scalarArraySize $ \ps ->
-                 ed25519_scalar_decode_long ps inp len
+            ed25519_scalar_decode_long ps inp len
         return $ CryptoPassed (Scalar s)
 {-# NOINLINE scalarDecodeLong #-}
 
@@ -162,16 +165,16 @@
 scalarAdd (Scalar a) (Scalar b) =
     Scalar $ B.allocAndFreeze scalarArraySize $ \out ->
         withByteArray a $ \pa ->
-        withByteArray b $ \pb ->
-             ed25519_scalar_add out pa pb
+            withByteArray b $ \pb ->
+                ed25519_scalar_add out pa pb
 
 -- | Multiply two scalars.
 scalarMul :: Scalar -> Scalar -> Scalar
 scalarMul (Scalar a) (Scalar b) =
     Scalar $ B.allocAndFreeze scalarArraySize $ \out ->
         withByteArray a $ \pa ->
-        withByteArray b $ \pb ->
-             ed25519_scalar_mul out pa pb
+            withByteArray b $ \pb ->
+                ed25519_scalar_mul out pa pb
 
 -- | Multiplies a scalar with the curve base point.
 toPoint :: Scalar -> Point
@@ -188,7 +191,7 @@
 pointEncode (Point p) =
     B.allocAndFreeze 32 $ \out ->
         withByteArray p $ \pp ->
-             ed25519_point_encode out pp
+            ed25519_point_encode out pp
 
 -- | Deserialize a 32-byte array as a point, ensuring the point is
 -- valid on edwards25519.
@@ -197,13 +200,14 @@
 pointDecode :: B.ByteArrayAccess bs => bs -> CryptoFailable Point
 pointDecode bs
     | B.length bs == 32 = unsafeDoIO $ withByteArray bs initialize
-    | otherwise         = CryptoFailed CryptoError_PointSizeInvalid
+    | otherwise = CryptoFailed CryptoError_PointSizeInvalid
   where
     initialize inp = do
         (res, p) <- B.allocRet pointArraySize $ \pp ->
-                        ed25519_point_decode_vartime pp inp
-        if res == 0 then return $ CryptoFailed CryptoError_PointCoordinatesInvalid
-                    else return $ CryptoPassed (Point p)
+            ed25519_point_decode_vartime pp inp
+        if res == 0
+            then return $ CryptoFailed CryptoError_PointCoordinatesInvalid
+            else return $ CryptoPassed (Point p)
 {-# NOINLINE pointDecode #-}
 
 -- | Test whether a point belongs to the prime-order subgroup
@@ -224,15 +228,15 @@
 pointNegate (Point a) =
     Point $ B.allocAndFreeze pointArraySize $ \out ->
         withByteArray a $ \pa ->
-             ed25519_point_negate out pa
+            ed25519_point_negate out pa
 
 -- | Add two points.
 pointAdd :: Point -> Point -> Point
 pointAdd (Point a) (Point b) =
     Point $ B.allocAndFreeze pointArraySize $ \out ->
         withByteArray a $ \pa ->
-        withByteArray b $ \pb ->
-             ed25519_point_add out pa pb
+            withByteArray b $ \pb ->
+                ed25519_point_add out pa pb
 
 -- | Add a point to itself.
 --
@@ -243,7 +247,7 @@
 pointDouble (Point a) =
     Point $ B.allocAndFreeze pointArraySize $ \out ->
         withByteArray a $ \pa ->
-             ed25519_point_double out pa
+            ed25519_point_double out pa
 
 -- | Multiply a point by h = 8.
 --
@@ -254,7 +258,7 @@
 pointMulByCofactor (Point a) =
     Point $ B.allocAndFreeze pointArraySize $ \out ->
         withByteArray a $ \pa ->
-             ed25519_point_mul_by_cofactor out pa
+            ed25519_point_mul_by_cofactor out pa
 
 -- | Scalar multiplication over curve edwards25519.
 --
@@ -265,8 +269,8 @@
 pointMul (Scalar scalar) (Point base) =
     Point $ B.allocAndFreeze pointArraySize $ \out ->
         withByteArray scalar $ \pscalar ->
-        withByteArray base   $ \pbase   ->
-             ed25519_point_scalarmul out pbase pscalar
+            withByteArray base $ \pbase ->
+                ed25519_point_scalarmul out pbase pscalar
 
 -- | Multiply the point @p@ with @s2@ and add a lifted to curve value @s1@.
 --
@@ -279,92 +283,108 @@
 pointsMulVarTime (Scalar s1) (Scalar s2) (Point p) =
     Point $ B.allocAndFreeze pointArraySize $ \out ->
         withByteArray s1 $ \ps1 ->
-        withByteArray s2 $ \ps2 ->
-        withByteArray p  $ \pp  ->
-             ed25519_base_double_scalarmul_vartime out ps1 pp ps2
+            withByteArray s2 $ \ps2 ->
+                withByteArray p $ \pp ->
+                    ed25519_base_double_scalarmul_vartime out ps1 pp ps2
 
 foreign import ccall unsafe "crypton_ed25519_scalar_eq"
-    ed25519_scalar_eq :: Ptr Scalar
-                      -> Ptr Scalar
-                      -> IO CInt
+    ed25519_scalar_eq
+        :: Ptr Scalar
+        -> Ptr Scalar
+        -> IO CInt
 
 foreign import ccall unsafe "crypton_ed25519_scalar_encode"
-    ed25519_scalar_encode :: Ptr Word8
-                          -> Ptr Scalar
-                          -> IO ()
+    ed25519_scalar_encode
+        :: Ptr Word8
+        -> Ptr Scalar
+        -> IO ()
 
 foreign import ccall unsafe "crypton_ed25519_scalar_decode_long"
-    ed25519_scalar_decode_long :: Ptr Scalar
-                               -> Ptr Word8
-                               -> CSize
-                               -> IO ()
+    ed25519_scalar_decode_long
+        :: Ptr Scalar
+        -> Ptr Word8
+        -> CSize
+        -> IO ()
 
 foreign import ccall unsafe "crypton_ed25519_scalar_add"
-    ed25519_scalar_add :: Ptr Scalar -- sum
-                       -> Ptr Scalar -- a
-                       -> Ptr Scalar -- b
-                       -> IO ()
+    ed25519_scalar_add
+        :: Ptr Scalar -- sum
+        -> Ptr Scalar -- a
+        -> Ptr Scalar -- b
+        -> IO ()
 
 foreign import ccall unsafe "crypton_ed25519_scalar_mul"
-    ed25519_scalar_mul :: Ptr Scalar -- out
-                       -> Ptr Scalar -- a
-                       -> Ptr Scalar -- b
-                       -> IO ()
+    ed25519_scalar_mul
+        :: Ptr Scalar -- out
+        -> Ptr Scalar -- a
+        -> Ptr Scalar -- b
+        -> IO ()
 
 foreign import ccall unsafe "crypton_ed25519_point_encode"
-    ed25519_point_encode :: Ptr Word8
-                         -> Ptr Point
-                         -> IO ()
+    ed25519_point_encode
+        :: Ptr Word8
+        -> Ptr Point
+        -> IO ()
 
 foreign import ccall unsafe "crypton_ed25519_point_decode_vartime"
-    ed25519_point_decode_vartime :: Ptr Point
-                                 -> Ptr Word8
-                                 -> IO CInt
+    ed25519_point_decode_vartime
+        :: Ptr Point
+        -> Ptr Word8
+        -> IO CInt
 
 foreign import ccall unsafe "crypton_ed25519_point_eq"
-    ed25519_point_eq :: Ptr Point
-                     -> Ptr Point
-                     -> IO CInt
+    ed25519_point_eq
+        :: Ptr Point
+        -> Ptr Point
+        -> IO CInt
 
 foreign import ccall "crypton_ed25519_point_has_prime_order"
-    ed25519_point_has_prime_order :: Ptr Point
-                                  -> IO CInt
+    ed25519_point_has_prime_order
+        :: Ptr Point
+        -> IO CInt
 
 foreign import ccall unsafe "crypton_ed25519_point_negate"
-    ed25519_point_negate :: Ptr Point -- minus_a
-                         -> Ptr Point -- a
-                         -> IO ()
+    ed25519_point_negate
+        :: Ptr Point -- minus_a
+        -> Ptr Point -- a
+        -> IO ()
 
 foreign import ccall unsafe "crypton_ed25519_point_add"
-    ed25519_point_add :: Ptr Point -- sum
-                      -> Ptr Point -- a
-                      -> Ptr Point -- b
-                      -> IO ()
+    ed25519_point_add
+        :: Ptr Point -- sum
+        -> Ptr Point -- a
+        -> Ptr Point -- b
+        -> IO ()
 
 foreign import ccall unsafe "crypton_ed25519_point_double"
-    ed25519_point_double :: Ptr Point -- two_a
-                         -> Ptr Point -- a
-                         -> IO ()
+    ed25519_point_double
+        :: Ptr Point -- two_a
+        -> Ptr Point -- a
+        -> IO ()
 
 foreign import ccall unsafe "crypton_ed25519_point_mul_by_cofactor"
-    ed25519_point_mul_by_cofactor :: Ptr Point -- eight_a
-                                  -> Ptr Point -- a
-                                  -> IO ()
+    ed25519_point_mul_by_cofactor
+        :: Ptr Point -- eight_a
+        -> Ptr Point -- a
+        -> IO ()
 
 foreign import ccall "crypton_ed25519_point_base_scalarmul"
-    ed25519_point_base_scalarmul :: Ptr Point  -- scaled
-                                 -> Ptr Scalar -- scalar
-                                 -> IO ()
+    ed25519_point_base_scalarmul
+        :: Ptr Point -- scaled
+        -> Ptr Scalar -- scalar
+        -> IO ()
 
 foreign import ccall "crypton_ed25519_point_scalarmul"
-    ed25519_point_scalarmul :: Ptr Point  -- scaled
-                            -> Ptr Point  -- base
-                            -> Ptr Scalar -- scalar
-                            -> IO ()
+    ed25519_point_scalarmul
+        :: Ptr Point -- scaled
+        -> Ptr Point -- base
+        -> Ptr Scalar -- scalar
+        -> IO ()
 
 foreign import ccall "crypton_ed25519_base_double_scalarmul_vartime"
-    ed25519_base_double_scalarmul_vartime :: Ptr Point  -- combo
-                                          -> Ptr Scalar -- scalar1
-                                          -> Ptr Point  -- base2
-                                          -> Ptr Scalar -- scalar2
-                                          -> IO ()
+    ed25519_base_double_scalarmul_vartime
+        :: Ptr Point -- combo
+        -> Ptr Scalar -- scalar1
+        -> Ptr Point -- base2
+        -> Ptr Scalar -- scalar2
+        -> IO ()
diff --git a/Crypto/ECC/Simple/Prim.hs b/Crypto/ECC/Simple/Prim.hs
--- a/Crypto/ECC/Simple/Prim.hs
+++ b/Crypto/ECC/Simple/Prim.hs
@@ -1,56 +1,60 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- | Elliptic Curve Arithmetic.
 --
 -- /WARNING:/ These functions are vulnerable to timing attacks.
-{-# LANGUAGE ScopedTypeVariables #-}
-module Crypto.ECC.Simple.Prim
-    ( scalarGenerate
-    , scalarFromInteger
-    , pointAdd
-    , pointNegate
-    , pointDouble
-    , pointBaseMul
-    , pointMul
-    , pointAddTwoMuls
-    , pointFromIntegers
-    , isPointAtInfinity
-    , isPointValid
-    ) where
+module Crypto.ECC.Simple.Prim (
+    scalarGenerate,
+    scalarFromInteger,
+    pointAdd,
+    pointNegate,
+    pointDouble,
+    pointBaseMul,
+    pointMul,
+    pointAddTwoMuls,
+    pointFromIntegers,
+    isPointAtInfinity,
+    isPointValid,
+) where
 
-import Data.Maybe
-import Data.Proxy
-import Crypto.Number.ModArithmetic
-import Crypto.Number.F2m
-import Crypto.Number.Generate (generateBetween)
 import Crypto.ECC.Simple.Types
 import Crypto.Error
+import Crypto.Number.F2m
+import Crypto.Number.Generate (generateBetween)
+import Crypto.Number.ModArithmetic
 import Crypto.Random
+import Data.Maybe
+import Data.Proxy
 
 -- | Generate a valid scalar for a specific Curve
-scalarGenerate :: forall randomly curve . (MonadRandom randomly, Curve curve) => randomly (Scalar curve)
+scalarGenerate
+    :: forall randomly curve
+     . (MonadRandom randomly, Curve curve) => randomly (Scalar curve)
 scalarGenerate =
     Scalar <$> generateBetween 1 (n - 1)
   where
     n = curveEccN $ curveParameters (Proxy :: Proxy curve)
 
-scalarFromInteger :: forall curve . Curve curve => Integer -> CryptoFailable (Scalar curve)
+scalarFromInteger
+    :: forall curve. Curve curve => Integer -> CryptoFailable (Scalar curve)
 scalarFromInteger n
-    | n < 0  || n >= mx = CryptoFailed $ CryptoError_EcScalarOutOfBounds
-    | otherwise         = CryptoPassed $ Scalar n
+    | n < 0 || n >= mx = CryptoFailed $ CryptoError_EcScalarOutOfBounds
+    | otherwise = CryptoPassed $ Scalar n
   where
     mx = case curveType (Proxy :: Proxy curve) of
-            CurveBinary (CurveBinaryParam b) -> b
-            CurvePrime (CurvePrimeParam p)   -> p
+        CurveBinary (CurveBinaryParam b) -> b
+        CurvePrime (CurvePrimeParam p) -> p
 
---TODO: Extract helper function for `fromMaybe PointO...`
+-- TODO: Extract helper function for `fromMaybe PointO...`
 
 -- | Elliptic Curve point negation:
 -- @pointNegate p@ returns point @q@ such that @pointAdd p q == PointO@.
 pointNegate :: Curve curve => Point curve -> Point curve
-pointNegate        PointO     = PointO
+pointNegate PointO = PointO
 pointNegate point@(Point x y) =
     case curveType point of
         CurvePrime (CurvePrimeParam p) -> Point x (p - y)
-        CurveBinary {} -> Point x (x `addF2m` y)
+        CurveBinary{} -> Point x (x `addF2m` y)
 
 -- | Elliptic Curve point addition.
 --
@@ -60,13 +64,13 @@
 pointAdd PointO q = q
 pointAdd p PointO = p
 pointAdd p q
-  | p == q             = pointDouble p
-  | p == pointNegate q = PointO
+    | p == q = pointDouble p
+    | p == pointNegate q = PointO
 pointAdd point@(Point xp yp) (Point xq yq) =
     case ty of
         CurvePrime (CurvePrimeParam pr) -> fromMaybe PointO $ do
             s <- divmod (yp - yq) (xp - xq) pr
-            let xr = (s ^ (2::Int) - xp - xq) `mod` pr
+            let xr = (s ^ (2 :: Int) - xp - xq) `mod` pr
                 yr = (s * (xp - xr) - yp) `mod` pr
             return $ Point xr yr
         CurveBinary (CurveBinaryParam fx) -> fromMaybe PointO $ do
@@ -77,7 +81,7 @@
   where
     ty = curveType point
     cc = curveParameters point
-    a  = curveEccA cc
+    a = curveEccA cc
 
 -- | Elliptic Curve point doubling.
 --
@@ -94,19 +98,18 @@
 -- >    s = xp + (yp / xp)
 -- >    xr = s ^ 2 + s + a
 -- >    yr = xp ^ 2 + (s+1) * xr
---
 pointDouble :: Curve curve => Point curve -> Point curve
 pointDouble PointO = PointO
 pointDouble point@(Point xp yp) =
     case ty of
         CurvePrime (CurvePrimeParam pr) -> fromMaybe PointO $ do
-            lambda <- divmod (3 * xp ^ (2::Int) + a) (2 * yp) pr
-            let xr = (lambda ^ (2::Int) - 2 * xp) `mod` pr
+            lambda <- divmod (3 * xp ^ (2 :: Int) + a) (2 * yp) pr
+            let xr = (lambda ^ (2 :: Int) - 2 * xp) `mod` pr
                 yr = (lambda * (xp - xr) - yp) `mod` pr
             return $ Point xr yr
         CurveBinary (CurveBinaryParam fx)
-            | xp == 0    -> PointO
-            | otherwise  -> fromMaybe PointO $ do
+            | xp == 0 -> PointO
+            | otherwise -> fromMaybe PointO $ do
                 s <- return . addF2m xp =<< divF2m fx yp xp
                 let xr = mulF2m fx s s `addF2m` s `addF2m` a
                     yr = mulF2m fx xp xp `addF2m` mulF2m fx xr (s `addF2m` 1)
@@ -114,7 +117,7 @@
   where
     ty = curveType point
     cc = curveParameters point
-    a  = curveEccA cc
+    a = curveEccA cc
 
 -- | Elliptic curve point multiplication using the base
 --
@@ -128,9 +131,9 @@
 pointMul :: Curve curve => Scalar curve -> Point curve -> Point curve
 pointMul _ PointO = PointO
 pointMul (Scalar n) p
-    | n == 0    = PointO
-    | n == 1    = p
-    | odd n     = pointAdd p (pointMul (Scalar (n - 1)) p)
+    | n == 0 = PointO
+    | n == 1 = p
+    | odd n = pointAdd p (pointMul (Scalar (n - 1)) p)
     | otherwise = pointMul (Scalar (n `div` 2)) (pointDouble p)
 
 -- | Elliptic curve double-scalar multiplication (uses Shamir's trick).
@@ -139,36 +142,40 @@
 -- >                                         (pointMul n2 p2)
 --
 -- /WARNING:/ Vulnerable to timing attacks.
-pointAddTwoMuls :: Curve curve => Scalar curve -> Point curve -> Scalar curve -> Point curve -> Point curve
-pointAddTwoMuls _  PointO _  PointO = PointO
-pointAddTwoMuls _  PointO n2 p2     = pointMul n2 p2
-pointAddTwoMuls n1 p1     _  PointO = pointMul n1 p1
+pointAddTwoMuls
+    :: Curve curve
+    => Scalar curve -> Point curve -> Scalar curve -> Point curve -> Point curve
+pointAddTwoMuls _ PointO _ PointO = PointO
+pointAddTwoMuls _ PointO n2 p2 = pointMul n2 p2
+pointAddTwoMuls n1 p1 _ PointO = pointMul n1 p1
 pointAddTwoMuls (Scalar n1) p1 (Scalar n2) p2 = go (n1, n2)
   where
     p0 = pointAdd p1 p2
 
-    go (0,  0 ) = PointO
+    go (0, 0) = PointO
     go (k1, k2) =
         let q = pointDouble $ go (k1 `div` 2, k2 `div` 2)
-        in case (odd k1, odd k2) of
-            (True  , True  ) -> pointAdd p0 q
-            (True  , False ) -> pointAdd p1 q
-            (False , True  ) -> pointAdd p2 q
-            (False , False ) -> q
+         in case (odd k1, odd k2) of
+                (True, True) -> pointAdd p0 q
+                (True, False) -> pointAdd p1 q
+                (False, True) -> pointAdd p2 q
+                (False, False) -> q
 
 -- | Check if a point is the point at infinity.
 isPointAtInfinity :: Point curve -> Bool
 isPointAtInfinity PointO = True
-isPointAtInfinity _      = False
+isPointAtInfinity _ = False
 
 -- | Make a point on a curve from integer (x,y) coordinate
 --
 -- if the point is not valid related to the curve then an error is
 -- returned instead of a point
-pointFromIntegers :: forall curve . Curve curve => (Integer, Integer) -> CryptoFailable (Point curve)
-pointFromIntegers (x,y)
+pointFromIntegers
+    :: forall curve. Curve curve => (Integer, Integer) -> CryptoFailable (Point curve)
+pointFromIntegers (x, y)
     | isPointValid (Proxy :: Proxy curve) x y = CryptoPassed $ Point x y
-    | otherwise                               = CryptoFailed $ CryptoError_PointCoordinatesInvalid
+    | otherwise =
+        CryptoFailed $ CryptoError_PointCoordinatesInvalid
 
 -- | check if a point is on specific curve
 --
@@ -181,18 +188,19 @@
 isPointValid proxy x y =
     case ty of
         CurvePrime (CurvePrimeParam p) ->
-            let a  = curveEccA cc
-                b  = curveEccB cc
+            let a = curveEccA cc
+                b = curveEccB cc
                 eqModP z1 z2 = (z1 `mod` p) == (z2 `mod` p)
                 isValid e = e >= 0 && e < p
              in isValid x && isValid y && (y ^ (2 :: Int)) `eqModP` (x ^ (3 :: Int) + a * x + b)
         CurveBinary (CurveBinaryParam fx) ->
-            let a  = curveEccA cc
-                b  = curveEccB cc
+            let a = curveEccA cc
+                b = curveEccB cc
                 add = addF2m
                 mul = mulF2m fx
                 isValid e = modF2m fx e == e
-             in and [ isValid x
+             in and
+                    [ isValid x
                     , isValid y
                     , ((((x `add` a) `mul` x `add` y) `mul` x) `add` b `add` (squareF2m fx y)) == 0
                     ]
diff --git a/Crypto/ECC/Simple/Types.hs b/Crypto/ECC/Simple/Types.hs
--- a/Crypto/ECC/Simple/Types.hs
+++ b/Crypto/ECC/Simple/Types.hs
@@ -1,5 +1,7 @@
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
+
 -- |
 -- Module      : Crypto.ECC.Simple.Types
 -- License     : BSD-style
@@ -9,57 +11,56 @@
 --
 -- References:
 --   <https://tools.ietf.org/html/rfc5915>
---
-{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
-module Crypto.ECC.Simple.Types
-    ( Curve(..)
-    , Point(..)
-    , Scalar(..)
-    , CurveType(..)
-    , CurveBinaryParam(..)
-    , CurvePrimeParam(..)
-    , curveSizeBits
-    , curveSizeBytes
-    , CurveParameters(..)
+module Crypto.ECC.Simple.Types (
+    Curve (..),
+    Point (..),
+    Scalar (..),
+    CurveType (..),
+    CurveBinaryParam (..),
+    CurvePrimeParam (..),
+    curveSizeBits,
+    curveSizeBytes,
+    CurveParameters (..),
+
     -- * Specific curves definition
-    , SEC_p112r1(..)
-    , SEC_p112r2(..)
-    , SEC_p128r1(..)
-    , SEC_p128r2(..)
-    , SEC_p160k1(..)
-    , SEC_p160r1(..)
-    , SEC_p160r2(..)
-    , SEC_p192k1(..)
-    , SEC_p192r1(..) -- aka prime192v1
-    , SEC_p224k1(..)
-    , SEC_p224r1(..)
-    , SEC_p256k1(..)
-    , SEC_p256r1(..) -- aka prime256v1
-    , SEC_p384r1(..)
-    , SEC_p521r1(..)
-    , SEC_t113r1(..)
-    , SEC_t113r2(..)
-    , SEC_t131r1(..)
-    , SEC_t131r2(..)
-    , SEC_t163k1(..)
-    , SEC_t163r1(..)
-    , SEC_t163r2(..)
-    , SEC_t193r1(..)
-    , SEC_t193r2(..)
-    , SEC_t233k1(..) -- aka NIST K-233
-    , SEC_t233r1(..)
-    , SEC_t239k1(..)
-    , SEC_t283k1(..)
-    , SEC_t283r1(..)
-    , SEC_t409k1(..)
-    , SEC_t409r1(..)
-    , SEC_t571k1(..)
-    , SEC_t571r1(..)
-    ) where
+    SEC_p112r1 (..),
+    SEC_p112r2 (..),
+    SEC_p128r1 (..),
+    SEC_p128r2 (..),
+    SEC_p160k1 (..),
+    SEC_p160r1 (..),
+    SEC_p160r2 (..),
+    SEC_p192k1 (..),
+    SEC_p192r1 (..), -- aka prime192v1
+    SEC_p224k1 (..),
+    SEC_p224r1 (..),
+    SEC_p256k1 (..),
+    SEC_p256r1 (..), -- aka prime256v1
+    SEC_p384r1 (..),
+    SEC_p521r1 (..),
+    SEC_t113r1 (..),
+    SEC_t113r2 (..),
+    SEC_t131r1 (..),
+    SEC_t131r2 (..),
+    SEC_t163k1 (..),
+    SEC_t163r1 (..),
+    SEC_t163r2 (..),
+    SEC_t193r1 (..),
+    SEC_t193r2 (..),
+    SEC_t233k1 (..), -- aka NIST K-233
+    SEC_t233r1 (..),
+    SEC_t239k1 (..),
+    SEC_t283k1 (..),
+    SEC_t283r1 (..),
+    SEC_t409k1 (..),
+    SEC_t409r1 (..),
+    SEC_t571k1 (..),
+    SEC_t571r1 (..),
+) where
 
-import           Data.Data
-import           Crypto.Internal.Imports
-import           Crypto.Number.Basic (numBits)
+import Crypto.Internal.Imports
+import Crypto.Number.Basic (numBits)
+import Data.Data
 
 class Curve curve where
     curveParameters :: proxy curve -> CurveParameters curve
@@ -69,7 +70,7 @@
 curveSizeBits :: Curve curve => proxy curve -> Int
 curveSizeBits proxy =
     case curveType proxy of
-        CurvePrime (CurvePrimeParam p)   -> numBits p
+        CurvePrime (CurvePrimeParam p) -> numBits p
         CurveBinary (CurveBinaryParam c) -> numBits c - 1
 
 -- | get the size of the curve in bytes
@@ -79,71 +80,78 @@
 -- | Define common parameters in a curve definition
 -- of the form: y^2 = x^3 + ax + b.
 data CurveParameters curve = CurveParameters
-    { curveEccA :: Integer     -- ^ curve parameter a
-    , curveEccB :: Integer     -- ^ curve parameter b
-    , curveEccG :: Point curve -- ^ base point
-    , curveEccN :: Integer     -- ^ order of G
-    , curveEccH :: Integer     -- ^ cofactor
-    } deriving (Show,Eq,Data)
+    { curveEccA :: Integer
+    -- ^ curve parameter a
+    , curveEccB :: Integer
+    -- ^ curve parameter b
+    , curveEccG :: Point curve
+    -- ^ base point
+    , curveEccN :: Integer
+    -- ^ order of G
+    , curveEccH :: Integer
+    -- ^ cofactor
+    }
+    deriving (Show, Eq, Data)
 
 newtype CurveBinaryParam = CurveBinaryParam Integer
-    deriving (Show,Read,Eq,Data)
+    deriving (Show, Read, Eq, Data)
 
 newtype CurvePrimeParam = CurvePrimeParam Integer
-    deriving (Show,Read,Eq,Data)
+    deriving (Show, Read, Eq, Data)
 
-data CurveType =
-      CurveBinary CurveBinaryParam
+data CurveType
+    = CurveBinary CurveBinaryParam
     | CurvePrime CurvePrimeParam
-    deriving (Show,Read,Eq,Data)
+    deriving (Show, Read, Eq, Data)
 
 -- | ECC Private Number
 newtype Scalar curve = Scalar Integer
-    deriving (Show,Read,Eq,Data,NFData)
+    deriving (Show, Read, Eq, Data, NFData)
 
 -- | Define a point on a curve.
-data Point curve =
-      Point Integer Integer
-    | PointO -- ^ Point at Infinity
-    deriving (Show,Read,Eq,Data)
+data Point curve
+    = Point Integer Integer
+    | -- | Point at Infinity
+      PointO
+    deriving (Show, Read, Eq, Data)
 
 instance NFData (Point curve) where
     rnf (Point x y) = x `seq` y `seq` ()
     rnf PointO = ()
 
-data SEC_p112r1 = SEC_p112r1 deriving (Show,Read,Eq)
-data SEC_p112r2 = SEC_p112r2 deriving (Show,Read,Eq)
-data SEC_p128r1 = SEC_p128r1 deriving (Show,Read,Eq)
-data SEC_p128r2 = SEC_p128r2 deriving (Show,Read,Eq)
-data SEC_p160k1 = SEC_p160k1 deriving (Show,Read,Eq)
-data SEC_p160r1 = SEC_p160r1 deriving (Show,Read,Eq)
-data SEC_p160r2 = SEC_p160r2 deriving (Show,Read,Eq)
-data SEC_p192k1 = SEC_p192k1 deriving (Show,Read,Eq)
-data SEC_p192r1 = SEC_p192r1 deriving (Show,Read,Eq)
-data SEC_p224k1 = SEC_p224k1 deriving (Show,Read,Eq)
-data SEC_p224r1 = SEC_p224r1 deriving (Show,Read,Eq)
-data SEC_p256k1 = SEC_p256k1 deriving (Show,Read,Eq)
-data SEC_p256r1 = SEC_p256r1 deriving (Show,Read,Eq)
-data SEC_p384r1 = SEC_p384r1 deriving (Show,Read,Eq)
-data SEC_p521r1 = SEC_p521r1 deriving (Show,Read,Eq)
-data SEC_t113r1 = SEC_t113r1 deriving (Show,Read,Eq)
-data SEC_t113r2 = SEC_t113r2 deriving (Show,Read,Eq)
-data SEC_t131r1 = SEC_t131r1 deriving (Show,Read,Eq)
-data SEC_t131r2 = SEC_t131r2 deriving (Show,Read,Eq)
-data SEC_t163k1 = SEC_t163k1 deriving (Show,Read,Eq)
-data SEC_t163r1 = SEC_t163r1 deriving (Show,Read,Eq)
-data SEC_t163r2 = SEC_t163r2 deriving (Show,Read,Eq)
-data SEC_t193r1 = SEC_t193r1 deriving (Show,Read,Eq)
-data SEC_t193r2 = SEC_t193r2 deriving (Show,Read,Eq)
-data SEC_t233k1 = SEC_t233k1 deriving (Show,Read,Eq)
-data SEC_t233r1 = SEC_t233r1 deriving (Show,Read,Eq)
-data SEC_t239k1 = SEC_t239k1 deriving (Show,Read,Eq)
-data SEC_t283k1 = SEC_t283k1 deriving (Show,Read,Eq)
-data SEC_t283r1 = SEC_t283r1 deriving (Show,Read,Eq)
-data SEC_t409k1 = SEC_t409k1 deriving (Show,Read,Eq)
-data SEC_t409r1 = SEC_t409r1 deriving (Show,Read,Eq)
-data SEC_t571k1 = SEC_t571k1 deriving (Show,Read,Eq)
-data SEC_t571r1 = SEC_t571r1 deriving (Show,Read,Eq)
+data SEC_p112r1 = SEC_p112r1 deriving (Show, Read, Eq)
+data SEC_p112r2 = SEC_p112r2 deriving (Show, Read, Eq)
+data SEC_p128r1 = SEC_p128r1 deriving (Show, Read, Eq)
+data SEC_p128r2 = SEC_p128r2 deriving (Show, Read, Eq)
+data SEC_p160k1 = SEC_p160k1 deriving (Show, Read, Eq)
+data SEC_p160r1 = SEC_p160r1 deriving (Show, Read, Eq)
+data SEC_p160r2 = SEC_p160r2 deriving (Show, Read, Eq)
+data SEC_p192k1 = SEC_p192k1 deriving (Show, Read, Eq)
+data SEC_p192r1 = SEC_p192r1 deriving (Show, Read, Eq)
+data SEC_p224k1 = SEC_p224k1 deriving (Show, Read, Eq)
+data SEC_p224r1 = SEC_p224r1 deriving (Show, Read, Eq)
+data SEC_p256k1 = SEC_p256k1 deriving (Show, Read, Eq)
+data SEC_p256r1 = SEC_p256r1 deriving (Show, Read, Eq)
+data SEC_p384r1 = SEC_p384r1 deriving (Show, Read, Eq)
+data SEC_p521r1 = SEC_p521r1 deriving (Show, Read, Eq)
+data SEC_t113r1 = SEC_t113r1 deriving (Show, Read, Eq)
+data SEC_t113r2 = SEC_t113r2 deriving (Show, Read, Eq)
+data SEC_t131r1 = SEC_t131r1 deriving (Show, Read, Eq)
+data SEC_t131r2 = SEC_t131r2 deriving (Show, Read, Eq)
+data SEC_t163k1 = SEC_t163k1 deriving (Show, Read, Eq)
+data SEC_t163r1 = SEC_t163r1 deriving (Show, Read, Eq)
+data SEC_t163r2 = SEC_t163r2 deriving (Show, Read, Eq)
+data SEC_t193r1 = SEC_t193r1 deriving (Show, Read, Eq)
+data SEC_t193r2 = SEC_t193r2 deriving (Show, Read, Eq)
+data SEC_t233k1 = SEC_t233k1 deriving (Show, Read, Eq)
+data SEC_t233r1 = SEC_t233r1 deriving (Show, Read, Eq)
+data SEC_t239k1 = SEC_t239k1 deriving (Show, Read, Eq)
+data SEC_t283k1 = SEC_t283k1 deriving (Show, Read, Eq)
+data SEC_t283r1 = SEC_t283r1 deriving (Show, Read, Eq)
+data SEC_t409k1 = SEC_t409k1 deriving (Show, Read, Eq)
+data SEC_t409r1 = SEC_t409r1 deriving (Show, Read, Eq)
+data SEC_t571k1 = SEC_t571k1 deriving (Show, Read, Eq)
+data SEC_t571r1 = SEC_t571r1 deriving (Show, Read, Eq)
 
 -- | Define names for known recommended curves.
 instance Curve SEC_p112r1 where
@@ -318,299 +326,468 @@
 -}
 
 typeSEC_p112r1 = CurvePrime $ CurvePrimeParam 0xdb7c2abf62e35e668076bead208b
-paramSEC_p112r1 = CurveParameters
-    { curveEccA = 0xdb7c2abf62e35e668076bead2088
-    , curveEccB = 0x659ef8ba043916eede8911702b22
-    , curveEccG = Point 0x09487239995a5ee76b55f9c2f098
-                    0xa89ce5af8724c0a23e0e0ff77500
-    , curveEccN = 0xdb7c2abf62e35e7628dfac6561c5
-    , curveEccH = 1
-    }
+paramSEC_p112r1 =
+    CurveParameters
+        { curveEccA = 0xdb7c2abf62e35e668076bead2088
+        , curveEccB = 0x659ef8ba043916eede8911702b22
+        , curveEccG =
+            Point
+                0x09487239995a5ee76b55f9c2f098
+                0xa89ce5af8724c0a23e0e0ff77500
+        , curveEccN = 0xdb7c2abf62e35e7628dfac6561c5
+        , curveEccH = 1
+        }
 typeSEC_p112r2 = CurvePrime $ CurvePrimeParam 0xdb7c2abf62e35e668076bead208b
-paramSEC_p112r2 = CurveParameters
-    { curveEccA = 0x6127c24c05f38a0aaaf65c0ef02c
-    , curveEccB = 0x51def1815db5ed74fcc34c85d709
-    , curveEccG = Point 0x4ba30ab5e892b4e1649dd0928643
-                    0xadcd46f5882e3747def36e956e97
-    , curveEccN = 0x36df0aafd8b8d7597ca10520d04b
-    , curveEccH = 4
-    }
+paramSEC_p112r2 =
+    CurveParameters
+        { curveEccA = 0x6127c24c05f38a0aaaf65c0ef02c
+        , curveEccB = 0x51def1815db5ed74fcc34c85d709
+        , curveEccG =
+            Point
+                0x4ba30ab5e892b4e1649dd0928643
+                0xadcd46f5882e3747def36e956e97
+        , curveEccN = 0x36df0aafd8b8d7597ca10520d04b
+        , curveEccH = 4
+        }
 typeSEC_p128r1 = CurvePrime $ CurvePrimeParam 0xfffffffdffffffffffffffffffffffff
-paramSEC_p128r1 = CurveParameters
-    { curveEccA = 0xfffffffdfffffffffffffffffffffffc
-    , curveEccB = 0xe87579c11079f43dd824993c2cee5ed3
-    , curveEccG = Point 0x161ff7528b899b2d0c28607ca52c5b86
-                    0xcf5ac8395bafeb13c02da292dded7a83
-    , curveEccN = 0xfffffffe0000000075a30d1b9038a115
-    , curveEccH = 1
-    }
+paramSEC_p128r1 =
+    CurveParameters
+        { curveEccA = 0xfffffffdfffffffffffffffffffffffc
+        , curveEccB = 0xe87579c11079f43dd824993c2cee5ed3
+        , curveEccG =
+            Point
+                0x161ff7528b899b2d0c28607ca52c5b86
+                0xcf5ac8395bafeb13c02da292dded7a83
+        , curveEccN = 0xfffffffe0000000075a30d1b9038a115
+        , curveEccH = 1
+        }
 typeSEC_p128r2 = CurvePrime $ CurvePrimeParam 0xfffffffdffffffffffffffffffffffff
-paramSEC_p128r2 = CurveParameters
-    { curveEccA = 0xd6031998d1b3bbfebf59cc9bbff9aee1
-    , curveEccB = 0x5eeefca380d02919dc2c6558bb6d8a5d
-    , curveEccG = Point 0x7b6aa5d85e572983e6fb32a7cdebc140
-                    0x27b6916a894d3aee7106fe805fc34b44
-    , curveEccN = 0x3fffffff7fffffffbe0024720613b5a3
-    , curveEccH = 4
-    }
+paramSEC_p128r2 =
+    CurveParameters
+        { curveEccA = 0xd6031998d1b3bbfebf59cc9bbff9aee1
+        , curveEccB = 0x5eeefca380d02919dc2c6558bb6d8a5d
+        , curveEccG =
+            Point
+                0x7b6aa5d85e572983e6fb32a7cdebc140
+                0x27b6916a894d3aee7106fe805fc34b44
+        , curveEccN = 0x3fffffff7fffffffbe0024720613b5a3
+        , curveEccH = 4
+        }
 typeSEC_p160k1 = CurvePrime $ CurvePrimeParam 0x00fffffffffffffffffffffffffffffffeffffac73
-paramSEC_p160k1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000000
-    , curveEccB = 0x000000000000000000000000000000000000000007
-    , curveEccG = Point 0x003b4c382ce37aa192a4019e763036f4f5dd4d7ebb
-                    0x00938cf935318fdced6bc28286531733c3f03c4fee
-    , curveEccN = 0x0100000000000000000001b8fa16dfab9aca16b6b3
-    , curveEccH = 1
-    }
+paramSEC_p160k1 =
+    CurveParameters
+        { curveEccA = 0x000000000000000000000000000000000000000000
+        , curveEccB = 0x000000000000000000000000000000000000000007
+        , curveEccG =
+            Point
+                0x003b4c382ce37aa192a4019e763036f4f5dd4d7ebb
+                0x00938cf935318fdced6bc28286531733c3f03c4fee
+        , curveEccN = 0x0100000000000000000001b8fa16dfab9aca16b6b3
+        , curveEccH = 1
+        }
 typeSEC_p160r1 = CurvePrime $ CurvePrimeParam 0x00ffffffffffffffffffffffffffffffff7fffffff
-paramSEC_p160r1 = CurveParameters
-    { curveEccA = 0x00ffffffffffffffffffffffffffffffff7ffffffc
-    , curveEccB = 0x001c97befc54bd7a8b65acf89f81d4d4adc565fa45
-    , curveEccG = Point 0x004a96b5688ef573284664698968c38bb913cbfc82
-                    0x0023a628553168947d59dcc912042351377ac5fb32
-    , curveEccN = 0x0100000000000000000001f4c8f927aed3ca752257
-    , curveEccH = 1
-    }
+paramSEC_p160r1 =
+    CurveParameters
+        { curveEccA = 0x00ffffffffffffffffffffffffffffffff7ffffffc
+        , curveEccB = 0x001c97befc54bd7a8b65acf89f81d4d4adc565fa45
+        , curveEccG =
+            Point
+                0x004a96b5688ef573284664698968c38bb913cbfc82
+                0x0023a628553168947d59dcc912042351377ac5fb32
+        , curveEccN = 0x0100000000000000000001f4c8f927aed3ca752257
+        , curveEccH = 1
+        }
 typeSEC_p160r2 = CurvePrime $ CurvePrimeParam 0x00fffffffffffffffffffffffffffffffeffffac73
-paramSEC_p160r2 = CurveParameters
-    { curveEccA = 0x00fffffffffffffffffffffffffffffffeffffac70
-    , curveEccB = 0x00b4e134d3fb59eb8bab57274904664d5af50388ba
-    , curveEccG = Point 0x0052dcb034293a117e1f4ff11b30f7199d3144ce6d
-                    0x00feaffef2e331f296e071fa0df9982cfea7d43f2e
-    , curveEccN = 0x0100000000000000000000351ee786a818f3a1a16b
-    , curveEccH = 1
-    }
-typeSEC_p192k1 = CurvePrime $ CurvePrimeParam 0xfffffffffffffffffffffffffffffffffffffffeffffee37
-paramSEC_p192k1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000000000000
-    , curveEccB = 0x000000000000000000000000000000000000000000000003
-    , curveEccG = Point 0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d
-                    0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d
-    , curveEccN = 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d
-    , curveEccH = 1
-    }
-typeSEC_p192r1 = CurvePrime $ CurvePrimeParam 0xfffffffffffffffffffffffffffffffeffffffffffffffff
-paramSEC_p192r1 = CurveParameters
-    { curveEccA = 0xfffffffffffffffffffffffffffffffefffffffffffffffc
-    , curveEccB = 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1
-    , curveEccG = Point 0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012
-                    0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811
-    , curveEccN = 0xffffffffffffffffffffffff99def836146bc9b1b4d22831
-    , curveEccH = 1
-    }
-typeSEC_p224k1 = CurvePrime $ CurvePrimeParam 0x00fffffffffffffffffffffffffffffffffffffffffffffffeffffe56d
-paramSEC_p224k1 = CurveParameters
-    { curveEccA = 0x0000000000000000000000000000000000000000000000000000000000
-    , curveEccB = 0x0000000000000000000000000000000000000000000000000000000005
-    , curveEccG = Point 0x00a1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c
-                    0x007e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5
-    , curveEccN = 0x010000000000000000000000000001dce8d2ec6184caf0a971769fb1f7
-    , curveEccH = 1
-    }
-typeSEC_p224r1 = CurvePrime $ CurvePrimeParam 0xffffffffffffffffffffffffffffffff000000000000000000000001
-paramSEC_p224r1 = CurveParameters
-    { curveEccA = 0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe
-    , curveEccB = 0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4
-    , curveEccG = Point 0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21
-                    0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34
-    , curveEccN = 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d
-    , curveEccH = 1
-    }
-typeSEC_p256k1 = CurvePrime $ CurvePrimeParam 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
-paramSEC_p256k1 = CurveParameters
-    { curveEccA = 0x0000000000000000000000000000000000000000000000000000000000000000
-    , curveEccB = 0x0000000000000000000000000000000000000000000000000000000000000007
-    , curveEccG = Point 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
-                    0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
-    , curveEccN = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
-    , curveEccH = 1
-    }
-typeSEC_p256r1 = CurvePrime $ CurvePrimeParam 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
-paramSEC_p256r1 = CurveParameters
-    { curveEccA = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
-    , curveEccB = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
-    , curveEccG = Point 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296
-                    0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5
-    , curveEccN = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
-    , curveEccH = 1
-    }
-typeSEC_p384r1 = CurvePrime $ CurvePrimeParam 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff
-paramSEC_p384r1 = CurveParameters
-    { curveEccA = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc
-    , curveEccB = 0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef
-    , curveEccG = Point 0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7
-                    0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f
-    , curveEccN = 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973
-    , curveEccH = 1
-    }
-typeSEC_p521r1 = CurvePrime $ CurvePrimeParam 0x01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-paramSEC_p521r1 = CurveParameters
-    { curveEccA = 0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc
-    , curveEccB = 0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00
-    , curveEccG = Point 0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66
-                    0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650
-    , curveEccN = 0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409
-    , curveEccH = 1
-    }
+paramSEC_p160r2 =
+    CurveParameters
+        { curveEccA = 0x00fffffffffffffffffffffffffffffffeffffac70
+        , curveEccB = 0x00b4e134d3fb59eb8bab57274904664d5af50388ba
+        , curveEccG =
+            Point
+                0x0052dcb034293a117e1f4ff11b30f7199d3144ce6d
+                0x00feaffef2e331f296e071fa0df9982cfea7d43f2e
+        , curveEccN = 0x0100000000000000000000351ee786a818f3a1a16b
+        , curveEccH = 1
+        }
+typeSEC_p192k1 =
+    CurvePrime $ CurvePrimeParam 0xfffffffffffffffffffffffffffffffffffffffeffffee37
+paramSEC_p192k1 =
+    CurveParameters
+        { curveEccA = 0x000000000000000000000000000000000000000000000000
+        , curveEccB = 0x000000000000000000000000000000000000000000000003
+        , curveEccG =
+            Point
+                0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d
+                0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d
+        , curveEccN = 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d
+        , curveEccH = 1
+        }
+typeSEC_p192r1 =
+    CurvePrime $ CurvePrimeParam 0xfffffffffffffffffffffffffffffffeffffffffffffffff
+paramSEC_p192r1 =
+    CurveParameters
+        { curveEccA = 0xfffffffffffffffffffffffffffffffefffffffffffffffc
+        , curveEccB = 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1
+        , curveEccG =
+            Point
+                0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012
+                0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811
+        , curveEccN = 0xffffffffffffffffffffffff99def836146bc9b1b4d22831
+        , curveEccH = 1
+        }
+typeSEC_p224k1 =
+    CurvePrime $
+        CurvePrimeParam 0x00fffffffffffffffffffffffffffffffffffffffffffffffeffffe56d
+paramSEC_p224k1 =
+    CurveParameters
+        { curveEccA = 0x0000000000000000000000000000000000000000000000000000000000
+        , curveEccB = 0x0000000000000000000000000000000000000000000000000000000005
+        , curveEccG =
+            Point
+                0x00a1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c
+                0x007e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5
+        , curveEccN = 0x010000000000000000000000000001dce8d2ec6184caf0a971769fb1f7
+        , curveEccH = 1
+        }
+typeSEC_p224r1 =
+    CurvePrime $
+        CurvePrimeParam 0xffffffffffffffffffffffffffffffff000000000000000000000001
+paramSEC_p224r1 =
+    CurveParameters
+        { curveEccA = 0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe
+        , curveEccB = 0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4
+        , curveEccG =
+            Point
+                0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21
+                0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34
+        , curveEccN = 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d
+        , curveEccH = 1
+        }
+typeSEC_p256k1 =
+    CurvePrime $
+        CurvePrimeParam
+            0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
+paramSEC_p256k1 =
+    CurveParameters
+        { curveEccA = 0x0000000000000000000000000000000000000000000000000000000000000000
+        , curveEccB = 0x0000000000000000000000000000000000000000000000000000000000000007
+        , curveEccG =
+            Point
+                0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
+                0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
+        , curveEccN = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
+        , curveEccH = 1
+        }
+typeSEC_p256r1 =
+    CurvePrime $
+        CurvePrimeParam
+            0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
+paramSEC_p256r1 =
+    CurveParameters
+        { curveEccA = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
+        , curveEccB = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
+        , curveEccG =
+            Point
+                0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296
+                0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5
+        , curveEccN = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
+        , curveEccH = 1
+        }
+typeSEC_p384r1 =
+    CurvePrime $
+        CurvePrimeParam
+            0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff
+paramSEC_p384r1 =
+    CurveParameters
+        { curveEccA =
+            0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc
+        , curveEccB =
+            0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef
+        , curveEccG =
+            Point
+                0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7
+                0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f
+        , curveEccN =
+            0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973
+        , curveEccH = 1
+        }
+typeSEC_p521r1 =
+    CurvePrime $
+        CurvePrimeParam
+            0x01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+paramSEC_p521r1 =
+    CurveParameters
+        { curveEccA =
+            0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc
+        , curveEccB =
+            0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00
+        , curveEccG =
+            Point
+                0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66
+                0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650
+        , curveEccN =
+            0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409
+        , curveEccH = 1
+        }
 typeSEC_t113r1 = CurveBinary $ CurveBinaryParam 0x020000000000000000000000000201
-paramSEC_t113r1 = CurveParameters
-    { curveEccA = 0x003088250ca6e7c7fe649ce85820f7
-    , curveEccB = 0x00e8bee4d3e2260744188be0e9c723
-    , curveEccG = Point 0x009d73616f35f4ab1407d73562c10f
-                    0x00a52830277958ee84d1315ed31886
-    , curveEccN = 0x0100000000000000d9ccec8a39e56f
-    , curveEccH = 2
-    }
+paramSEC_t113r1 =
+    CurveParameters
+        { curveEccA = 0x003088250ca6e7c7fe649ce85820f7
+        , curveEccB = 0x00e8bee4d3e2260744188be0e9c723
+        , curveEccG =
+            Point
+                0x009d73616f35f4ab1407d73562c10f
+                0x00a52830277958ee84d1315ed31886
+        , curveEccN = 0x0100000000000000d9ccec8a39e56f
+        , curveEccH = 2
+        }
 typeSEC_t113r2 = CurveBinary $ CurveBinaryParam 0x020000000000000000000000000201
-paramSEC_t113r2 = CurveParameters
-    { curveEccA = 0x00689918dbec7e5a0dd6dfc0aa55c7
-    , curveEccB = 0x0095e9a9ec9b297bd4bf36e059184f
-    , curveEccG = Point 0x01a57a6a7b26ca5ef52fcdb8164797
-                    0x00b3adc94ed1fe674c06e695baba1d
-    , curveEccN = 0x010000000000000108789b2496af93
-    , curveEccH = 2
-    }
+paramSEC_t113r2 =
+    CurveParameters
+        { curveEccA = 0x00689918dbec7e5a0dd6dfc0aa55c7
+        , curveEccB = 0x0095e9a9ec9b297bd4bf36e059184f
+        , curveEccG =
+            Point
+                0x01a57a6a7b26ca5ef52fcdb8164797
+                0x00b3adc94ed1fe674c06e695baba1d
+        , curveEccN = 0x010000000000000108789b2496af93
+        , curveEccH = 2
+        }
 typeSEC_t131r1 = CurveBinary $ CurveBinaryParam 0x080000000000000000000000000000010d
-paramSEC_t131r1 = CurveParameters
-    { curveEccA = 0x07a11b09a76b562144418ff3ff8c2570b8
-    , curveEccB = 0x0217c05610884b63b9c6c7291678f9d341
-    , curveEccG = Point 0x0081baf91fdf9833c40f9c181343638399
-                    0x078c6e7ea38c001f73c8134b1b4ef9e150
-    , curveEccN = 0x0400000000000000023123953a9464b54d
-    , curveEccH = 2
-    }
+paramSEC_t131r1 =
+    CurveParameters
+        { curveEccA = 0x07a11b09a76b562144418ff3ff8c2570b8
+        , curveEccB = 0x0217c05610884b63b9c6c7291678f9d341
+        , curveEccG =
+            Point
+                0x0081baf91fdf9833c40f9c181343638399
+                0x078c6e7ea38c001f73c8134b1b4ef9e150
+        , curveEccN = 0x0400000000000000023123953a9464b54d
+        , curveEccH = 2
+        }
 typeSEC_t131r2 = CurveBinary $ CurveBinaryParam 0x080000000000000000000000000000010d
-paramSEC_t131r2 = CurveParameters
-    { curveEccA = 0x03e5a88919d7cafcbf415f07c2176573b2
-    , curveEccB = 0x04b8266a46c55657ac734ce38f018f2192
-    , curveEccG = Point 0x0356dcd8f2f95031ad652d23951bb366a8
-                    0x0648f06d867940a5366d9e265de9eb240f
-    , curveEccN = 0x0400000000000000016954a233049ba98f
-    , curveEccH = 2
-    }
+paramSEC_t131r2 =
+    CurveParameters
+        { curveEccA = 0x03e5a88919d7cafcbf415f07c2176573b2
+        , curveEccB = 0x04b8266a46c55657ac734ce38f018f2192
+        , curveEccG =
+            Point
+                0x0356dcd8f2f95031ad652d23951bb366a8
+                0x0648f06d867940a5366d9e265de9eb240f
+        , curveEccN = 0x0400000000000000016954a233049ba98f
+        , curveEccH = 2
+        }
 typeSEC_t163k1 = CurveBinary $ CurveBinaryParam 0x0800000000000000000000000000000000000000c9
-paramSEC_t163k1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000001
-    , curveEccB = 0x000000000000000000000000000000000000000001
-    , curveEccG = Point 0x02fe13c0537bbc11acaa07d793de4e6d5e5c94eee8
-                    0x0289070fb05d38ff58321f2e800536d538ccdaa3d9
-    , curveEccN = 0x04000000000000000000020108a2e0cc0d99f8a5ef
-    , curveEccH = 2
-    }
+paramSEC_t163k1 =
+    CurveParameters
+        { curveEccA = 0x000000000000000000000000000000000000000001
+        , curveEccB = 0x000000000000000000000000000000000000000001
+        , curveEccG =
+            Point
+                0x02fe13c0537bbc11acaa07d793de4e6d5e5c94eee8
+                0x0289070fb05d38ff58321f2e800536d538ccdaa3d9
+        , curveEccN = 0x04000000000000000000020108a2e0cc0d99f8a5ef
+        , curveEccH = 2
+        }
 typeSEC_t163r1 = CurveBinary $ CurveBinaryParam 0x0800000000000000000000000000000000000000c9
-paramSEC_t163r1 = CurveParameters
-    { curveEccA = 0x07b6882caaefa84f9554ff8428bd88e246d2782ae2
-    , curveEccB = 0x0713612dcddcb40aab946bda29ca91f73af958afd9
-    , curveEccG = Point 0x0369979697ab43897789566789567f787a7876a654
-                    0x00435edb42efafb2989d51fefce3c80988f41ff883
-    , curveEccN = 0x03ffffffffffffffffffff48aab689c29ca710279b
-    , curveEccH = 2
-    }
+paramSEC_t163r1 =
+    CurveParameters
+        { curveEccA = 0x07b6882caaefa84f9554ff8428bd88e246d2782ae2
+        , curveEccB = 0x0713612dcddcb40aab946bda29ca91f73af958afd9
+        , curveEccG =
+            Point
+                0x0369979697ab43897789566789567f787a7876a654
+                0x00435edb42efafb2989d51fefce3c80988f41ff883
+        , curveEccN = 0x03ffffffffffffffffffff48aab689c29ca710279b
+        , curveEccH = 2
+        }
 typeSEC_t163r2 = CurveBinary $ CurveBinaryParam 0x0800000000000000000000000000000000000000c9
-paramSEC_t163r2 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000001
-    , curveEccB = 0x020a601907b8c953ca1481eb10512f78744a3205fd
-    , curveEccG = Point 0x03f0eba16286a2d57ea0991168d4994637e8343e36
-                    0x00d51fbc6c71a0094fa2cdd545b11c5c0c797324f1
-    , curveEccN = 0x040000000000000000000292fe77e70c12a4234c33
-    , curveEccH = 2
-    }
-typeSEC_t193r1 = CurveBinary $ CurveBinaryParam 0x02000000000000000000000000000000000000000000008001
-paramSEC_t193r1 = CurveParameters
-    { curveEccA = 0x0017858feb7a98975169e171f77b4087de098ac8a911df7b01
-    , curveEccB = 0x00fdfb49bfe6c3a89facadaa7a1e5bbc7cc1c2e5d831478814
-    , curveEccG = Point 0x01f481bc5f0ff84a74ad6cdf6fdef4bf6179625372d8c0c5e1
-                    0x0025e399f2903712ccf3ea9e3a1ad17fb0b3201b6af7ce1b05
-    , curveEccN = 0x01000000000000000000000000c7f34a778f443acc920eba49
-    , curveEccH = 2
-    }
-typeSEC_t193r2 = CurveBinary $ CurveBinaryParam 0x02000000000000000000000000000000000000000000008001
-paramSEC_t193r2 = CurveParameters
-    { curveEccA = 0x0163f35a5137c2ce3ea6ed8667190b0bc43ecd69977702709b
-    , curveEccB = 0x00c9bb9e8927d4d64c377e2ab2856a5b16e3efb7f61d4316ae
-    , curveEccG = Point 0x00d9b67d192e0367c803f39e1a7e82ca14a651350aae617e8f
-                    0x01ce94335607c304ac29e7defbd9ca01f596f927224cdecf6c
-    , curveEccN = 0x010000000000000000000000015aab561b005413ccd4ee99d5
-    , curveEccH = 2
-    }
-typeSEC_t233k1 = CurveBinary $ CurveBinaryParam 0x020000000000000000000000000000000000000004000000000000000001
-paramSEC_t233k1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000000000000000000000000
-    , curveEccB = 0x000000000000000000000000000000000000000000000000000000000001
-    , curveEccG = Point 0x017232ba853a7e731af129f22ff4149563a419c26bf50a4c9d6eefad6126
-                    0x01db537dece819b7f70f555a67c427a8cd9bf18aeb9b56e0c11056fae6a3
-    , curveEccN = 0x008000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf
-    , curveEccH = 4
-    }
-typeSEC_t233r1 = CurveBinary $ CurveBinaryParam 0x020000000000000000000000000000000000000004000000000000000001
-paramSEC_t233r1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000000000000000000000001
-    , curveEccB = 0x0066647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad
-    , curveEccG = Point 0x00fac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b
-                    0x01006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052
-    , curveEccN = 0x01000000000000000000000000000013e974e72f8a6922031d2603cfe0d7
-    , curveEccH = 2
-    }
-typeSEC_t239k1 = CurveBinary $ CurveBinaryParam 0x800000000000000000004000000000000000000000000000000000000001
-paramSEC_t239k1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000000000000000000000000
-    , curveEccB = 0x000000000000000000000000000000000000000000000000000000000001
-    , curveEccG = Point 0x29a0b6a887a983e9730988a68727a8b2d126c44cc2cc7b2a6555193035dc
-                    0x76310804f12e549bdb011c103089e73510acb275fc312a5dc6b76553f0ca
-    , curveEccN = 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5
-    , curveEccH = 4
-    }
-typeSEC_t283k1 = CurveBinary $ CurveBinaryParam 0x0800000000000000000000000000000000000000000000000000000000000000000010a1
-paramSEC_t283k1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000000000000000000000000000000000000
-    , curveEccB = 0x000000000000000000000000000000000000000000000000000000000000000000000001
-    , curveEccG = Point 0x0503213f78ca44883f1a3b8162f188e553cd265f23c1567a16876913b0c2ac2458492836
-                    0x01ccda380f1c9e318d90f95d07e5426fe87e45c0e8184698e45962364e34116177dd2259
-    , curveEccN = 0x01ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61
-    , curveEccH = 4
-    }
-typeSEC_t283r1 = CurveBinary $ CurveBinaryParam 0x0800000000000000000000000000000000000000000000000000000000000000000010a1
-paramSEC_t283r1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000000000000000000000000000000000001
-    , curveEccB = 0x027b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5
-    , curveEccG = Point 0x05f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053
-                    0x03676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4
-    , curveEccN = 0x03ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307
-    , curveEccH = 2
-    }
-typeSEC_t409k1 = CurveBinary $ CurveBinaryParam 0x02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001
-paramSEC_t409k1 = CurveParameters
-    { curveEccA = 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-    , curveEccB = 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
-    , curveEccG = Point 0x0060f05f658f49c1ad3ab1890f7184210efd0987e307c84c27accfb8f9f67cc2c460189eb5aaaa62ee222eb1b35540cfe9023746
-                    0x01e369050b7c4e42acba1dacbf04299c3460782f918ea427e6325165e9ea10e3da5f6c42e9c55215aa9ca27a5863ec48d8e0286b
-    , curveEccN = 0x007ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf
-    , curveEccH = 4
-    }
-typeSEC_t409r1 = CurveBinary $ CurveBinaryParam 0x02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001
-paramSEC_t409r1 = CurveParameters
-    { curveEccA = 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
-    , curveEccB = 0x0021a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f
-    , curveEccG = Point 0x015d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7
-                    0x0061b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706
-    , curveEccN = 0x010000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173
-    , curveEccH = 2
-    }
-typeSEC_t571k1 = CurveBinary $ CurveBinaryParam 0x080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425
-paramSEC_t571k1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-    , curveEccB = 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
-    , curveEccG = Point 0x026eb7a859923fbc82189631f8103fe4ac9ca2970012d5d46024804801841ca44370958493b205e647da304db4ceb08cbbd1ba39494776fb988b47174dca88c7e2945283a01c8972
-                    0x0349dc807f4fbf374f4aeade3bca95314dd58cec9f307a54ffc61efc006d8a2c9d4979c0ac44aea74fbebbb9f772aedcb620b01a7ba7af1b320430c8591984f601cd4c143ef1c7a3
-    , curveEccN = 0x020000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001
-    , curveEccH = 4
-    }
-typeSEC_t571r1 = CurveBinary $ CurveBinaryParam 0x080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425
-paramSEC_t571r1 = CurveParameters
-    { curveEccA = 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
-    , curveEccB = 0x02f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a
-    , curveEccG = Point 0x0303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19
-                    0x037bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b
-    , curveEccN = 0x03ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47
-    , curveEccH = 2
-    }
+paramSEC_t163r2 =
+    CurveParameters
+        { curveEccA = 0x000000000000000000000000000000000000000001
+        , curveEccB = 0x020a601907b8c953ca1481eb10512f78744a3205fd
+        , curveEccG =
+            Point
+                0x03f0eba16286a2d57ea0991168d4994637e8343e36
+                0x00d51fbc6c71a0094fa2cdd545b11c5c0c797324f1
+        , curveEccN = 0x040000000000000000000292fe77e70c12a4234c33
+        , curveEccH = 2
+        }
+typeSEC_t193r1 =
+    CurveBinary $
+        CurveBinaryParam 0x02000000000000000000000000000000000000000000008001
+paramSEC_t193r1 =
+    CurveParameters
+        { curveEccA = 0x0017858feb7a98975169e171f77b4087de098ac8a911df7b01
+        , curveEccB = 0x00fdfb49bfe6c3a89facadaa7a1e5bbc7cc1c2e5d831478814
+        , curveEccG =
+            Point
+                0x01f481bc5f0ff84a74ad6cdf6fdef4bf6179625372d8c0c5e1
+                0x0025e399f2903712ccf3ea9e3a1ad17fb0b3201b6af7ce1b05
+        , curveEccN = 0x01000000000000000000000000c7f34a778f443acc920eba49
+        , curveEccH = 2
+        }
+typeSEC_t193r2 =
+    CurveBinary $
+        CurveBinaryParam 0x02000000000000000000000000000000000000000000008001
+paramSEC_t193r2 =
+    CurveParameters
+        { curveEccA = 0x0163f35a5137c2ce3ea6ed8667190b0bc43ecd69977702709b
+        , curveEccB = 0x00c9bb9e8927d4d64c377e2ab2856a5b16e3efb7f61d4316ae
+        , curveEccG =
+            Point
+                0x00d9b67d192e0367c803f39e1a7e82ca14a651350aae617e8f
+                0x01ce94335607c304ac29e7defbd9ca01f596f927224cdecf6c
+        , curveEccN = 0x010000000000000000000000015aab561b005413ccd4ee99d5
+        , curveEccH = 2
+        }
+typeSEC_t233k1 =
+    CurveBinary $
+        CurveBinaryParam 0x020000000000000000000000000000000000000004000000000000000001
+paramSEC_t233k1 =
+    CurveParameters
+        { curveEccA = 0x000000000000000000000000000000000000000000000000000000000000
+        , curveEccB = 0x000000000000000000000000000000000000000000000000000000000001
+        , curveEccG =
+            Point
+                0x017232ba853a7e731af129f22ff4149563a419c26bf50a4c9d6eefad6126
+                0x01db537dece819b7f70f555a67c427a8cd9bf18aeb9b56e0c11056fae6a3
+        , curveEccN = 0x008000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf
+        , curveEccH = 4
+        }
+typeSEC_t233r1 =
+    CurveBinary $
+        CurveBinaryParam 0x020000000000000000000000000000000000000004000000000000000001
+paramSEC_t233r1 =
+    CurveParameters
+        { curveEccA = 0x000000000000000000000000000000000000000000000000000000000001
+        , curveEccB = 0x0066647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad
+        , curveEccG =
+            Point
+                0x00fac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b
+                0x01006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052
+        , curveEccN = 0x01000000000000000000000000000013e974e72f8a6922031d2603cfe0d7
+        , curveEccH = 2
+        }
+typeSEC_t239k1 =
+    CurveBinary $
+        CurveBinaryParam 0x800000000000000000004000000000000000000000000000000000000001
+paramSEC_t239k1 =
+    CurveParameters
+        { curveEccA = 0x000000000000000000000000000000000000000000000000000000000000
+        , curveEccB = 0x000000000000000000000000000000000000000000000000000000000001
+        , curveEccG =
+            Point
+                0x29a0b6a887a983e9730988a68727a8b2d126c44cc2cc7b2a6555193035dc
+                0x76310804f12e549bdb011c103089e73510acb275fc312a5dc6b76553f0ca
+        , curveEccN = 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5
+        , curveEccH = 4
+        }
+typeSEC_t283k1 =
+    CurveBinary $
+        CurveBinaryParam
+            0x0800000000000000000000000000000000000000000000000000000000000000000010a1
+paramSEC_t283k1 =
+    CurveParameters
+        { curveEccA =
+            0x000000000000000000000000000000000000000000000000000000000000000000000000
+        , curveEccB =
+            0x000000000000000000000000000000000000000000000000000000000000000000000001
+        , curveEccG =
+            Point
+                0x0503213f78ca44883f1a3b8162f188e553cd265f23c1567a16876913b0c2ac2458492836
+                0x01ccda380f1c9e318d90f95d07e5426fe87e45c0e8184698e45962364e34116177dd2259
+        , curveEccN =
+            0x01ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61
+        , curveEccH = 4
+        }
+typeSEC_t283r1 =
+    CurveBinary $
+        CurveBinaryParam
+            0x0800000000000000000000000000000000000000000000000000000000000000000010a1
+paramSEC_t283r1 =
+    CurveParameters
+        { curveEccA =
+            0x000000000000000000000000000000000000000000000000000000000000000000000001
+        , curveEccB =
+            0x027b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5
+        , curveEccG =
+            Point
+                0x05f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053
+                0x03676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4
+        , curveEccN =
+            0x03ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307
+        , curveEccH = 2
+        }
+typeSEC_t409k1 =
+    CurveBinary $
+        CurveBinaryParam
+            0x02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001
+paramSEC_t409k1 =
+    CurveParameters
+        { curveEccA =
+            0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+        , curveEccB =
+            0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+        , curveEccG =
+            Point
+                0x0060f05f658f49c1ad3ab1890f7184210efd0987e307c84c27accfb8f9f67cc2c460189eb5aaaa62ee222eb1b35540cfe9023746
+                0x01e369050b7c4e42acba1dacbf04299c3460782f918ea427e6325165e9ea10e3da5f6c42e9c55215aa9ca27a5863ec48d8e0286b
+        , curveEccN =
+            0x007ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf
+        , curveEccH = 4
+        }
+typeSEC_t409r1 =
+    CurveBinary $
+        CurveBinaryParam
+            0x02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001
+paramSEC_t409r1 =
+    CurveParameters
+        { curveEccA =
+            0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+        , curveEccB =
+            0x0021a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f
+        , curveEccG =
+            Point
+                0x015d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7
+                0x0061b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706
+        , curveEccN =
+            0x010000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173
+        , curveEccH = 2
+        }
+typeSEC_t571k1 =
+    CurveBinary $
+        CurveBinaryParam
+            0x080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425
+paramSEC_t571k1 =
+    CurveParameters
+        { curveEccA =
+            0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+        , curveEccB =
+            0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+        , curveEccG =
+            Point
+                0x026eb7a859923fbc82189631f8103fe4ac9ca2970012d5d46024804801841ca44370958493b205e647da304db4ceb08cbbd1ba39494776fb988b47174dca88c7e2945283a01c8972
+                0x0349dc807f4fbf374f4aeade3bca95314dd58cec9f307a54ffc61efc006d8a2c9d4979c0ac44aea74fbebbb9f772aedcb620b01a7ba7af1b320430c8591984f601cd4c143ef1c7a3
+        , curveEccN =
+            0x020000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001
+        , curveEccH = 4
+        }
+typeSEC_t571r1 =
+    CurveBinary $
+        CurveBinaryParam
+            0x080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425
+paramSEC_t571r1 =
+    CurveParameters
+        { curveEccA =
+            0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+        , curveEccB =
+            0x02f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a
+        , curveEccG =
+            Point
+                0x0303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19
+                0x037bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b
+        , curveEccN =
+            0x03ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47
+        , curveEccH = 2
+        }
diff --git a/Crypto/Error.hs b/Crypto/Error.hs
--- a/Crypto/Error.hs
+++ b/Crypto/Error.hs
@@ -4,9 +4,8 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : Stable
 -- Portability : Excellent
---
-module Crypto.Error
-    ( module Crypto.Error.Types
-    ) where
+module Crypto.Error (
+    module Crypto.Error.Types,
+) where
 
 import Crypto.Error.Types
diff --git a/Crypto/Error/Types.hs b/Crypto/Error/Types.hs
--- a/Crypto/Error/Types.hs
+++ b/Crypto/Error/Types.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Error.Types
 -- License     : BSD-style
@@ -6,53 +9,48 @@
 -- Portability : Good
 --
 -- Cryptographic Error enumeration and handling
---
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE TypeFamilies       #-}
-module Crypto.Error.Types
-    ( CryptoError(..)
-    , CryptoFailable(..)
-    , throwCryptoErrorIO
-    , throwCryptoError
-    , onCryptoFailure
-    , eitherCryptoError
-    , maybeCryptoError
-    ) where
+module Crypto.Error.Types (
+    CryptoError (..),
+    CryptoFailable (..),
+    throwCryptoErrorIO,
+    throwCryptoError,
+    onCryptoFailure,
+    eitherCryptoError,
+    maybeCryptoError,
+) where
 
 import qualified Control.Exception as E
-import           Data.Data
-
-import           Basement.Monad (MonadFailure(..))
+import Data.Data
 
 -- | Enumeration of all possible errors that can be found in this library
-data CryptoError =
-    -- symmetric cipher errors
+data CryptoError
+    = -- symmetric cipher errors
       CryptoError_KeySizeInvalid
     | CryptoError_IvSizeInvalid
     | CryptoError_SeedSizeInvalid
     | CryptoError_AEADModeNotSupported
-    -- public key cryptography error
-    | CryptoError_SecretKeySizeInvalid
+    | -- public key cryptography error
+      CryptoError_SecretKeySizeInvalid
     | CryptoError_SecretKeyStructureInvalid
     | CryptoError_PublicKeySizeInvalid
     | CryptoError_SharedSecretSizeInvalid
-    -- elliptic cryptography error
-    | CryptoError_EcScalarOutOfBounds
+    | -- elliptic cryptography error
+      CryptoError_EcScalarOutOfBounds
     | CryptoError_PointSizeInvalid
     | CryptoError_PointFormatInvalid
     | CryptoError_PointFormatUnsupported
     | CryptoError_PointCoordinatesInvalid
     | CryptoError_ScalarMultiplicationInvalid
-    -- Message authentification error
-    | CryptoError_MacKeyInvalid
+    | -- Message authentification error
+      CryptoError_MacKeyInvalid
     | CryptoError_AuthenticationTagSizeInvalid
-    -- Prime generation error
-    | CryptoError_PrimeSizeInvalid
-    -- Parameter errors
-    | CryptoError_SaltTooSmall
+    | -- Prime generation error
+      CryptoError_PrimeSizeInvalid
+    | -- Parameter errors
+      CryptoError_SaltTooSmall
     | CryptoError_OutputLengthTooSmall
     | CryptoError_OutputLengthTooBig
-    deriving (Show,Eq,Enum,Data)
+    deriving (Show, Eq, Enum, Data)
 
 instance E.Exception CryptoError
 
@@ -63,23 +61,22 @@
 -- * 'CryptoPassed' : The computation succeeded, and contains the result of the computation
 --
 -- * 'CryptoFailed' : The computation failed, and contains the cryptographic error associated
---
-data CryptoFailable a =
-      CryptoPassed a
+data CryptoFailable a
+    = CryptoPassed a
     | CryptoFailed CryptoError
     deriving (Show)
 
 instance Eq a => Eq (CryptoFailable a) where
-    (==) (CryptoPassed a)  (CryptoPassed b)  = a == b
+    (==) (CryptoPassed a) (CryptoPassed b) = a == b
     (==) (CryptoFailed e1) (CryptoFailed e2) = e1 == e2
-    (==) _                 _                 = False
+    (==) _ _ = False
 
 instance Functor CryptoFailable where
     fmap f (CryptoPassed a) = CryptoPassed (f a)
     fmap _ (CryptoFailed r) = CryptoFailed r
 
 instance Applicative CryptoFailable where
-    pure a     = CryptoPassed a
+    pure a = CryptoPassed a
     (<*>) fm m = fm >>= \p -> m >>= \r2 -> return (p r2)
 instance Monad CryptoFailable where
     return = pure
@@ -88,10 +85,6 @@
             CryptoPassed a -> m2 a
             CryptoFailed e -> CryptoFailed e
 
-instance MonadFailure CryptoFailable where
-    type Failure CryptoFailable = CryptoError
-    mFail = CryptoFailed
-
 -- | Throw an CryptoError as exception on CryptoFailed result,
 -- otherwise return the computed value
 throwCryptoErrorIO :: CryptoFailable a -> IO a
@@ -105,8 +98,8 @@
 
 -- | Simple 'either' like combinator for CryptoFailable type
 onCryptoFailure :: (CryptoError -> r) -> (a -> r) -> CryptoFailable a -> r
-onCryptoFailure onError _         (CryptoFailed e) = onError e
-onCryptoFailure _       onSuccess (CryptoPassed r) = onSuccess r
+onCryptoFailure onError _ (CryptoFailed e) = onError e
+onCryptoFailure _ onSuccess (CryptoPassed r) = onSuccess r
 
 -- | Transform a CryptoFailable to an Either
 eitherCryptoError :: CryptoFailable a -> Either CryptoError a
diff --git a/Crypto/Hash.hs b/Crypto/Hash.hs
--- a/Crypto/Hash.hs
+++ b/Crypto/Hash.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- |
 -- Module      : Crypto.Hash
 -- License     : BSD-style
@@ -15,54 +18,51 @@
 -- >
 -- > hexSha3_512 :: ByteString -> String
 -- > hexSha3_512 bs = show (hash bs :: Digest SHA3_512)
---
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE BangPatterns        #-}
-module Crypto.Hash
-    (
+module Crypto.Hash (
     -- * Types
-      Context
-    , Digest
+    Context,
+    Digest,
+
     -- * Functions
-    , digestFromByteString
+    digestFromByteString,
+
     -- * Hash methods parametrized by algorithm
-    , hashInitWith
-    , hashWith
-    , hashPrefixWith
+    hashInitWith,
+    hashWith,
+    hashPrefixWith,
+
     -- * Hash methods
-    , hashInit
-    , hashUpdates
-    , hashUpdate
-    , hashFinalize
-    , hashFinalizePrefix
-    , hashBlockSize
-    , hashDigestSize
-    , hash
-    , hashPrefix
-    , hashlazy
+    hashInit,
+    hashUpdates,
+    hashUpdate,
+    hashFinalize,
+    hashFinalizePrefix,
+    hashBlockSize,
+    hashDigestSize,
+    hash,
+    hashPrefix,
+    hashlazy,
+
     -- * Hash algorithms
-    , module Crypto.Hash.Algorithms
-    ) where
+    module Crypto.Hash.Algorithms,
+) where
 
-import           Basement.Types.OffsetSize (CountOf (..))
-import           Basement.Block (Block, unsafeFreeze)
-import           Basement.Block.Mutable (copyFromPtr, new)
-import           Crypto.Internal.Compat (unsafeDoIO)
-import           Crypto.Hash.Types
-import           Crypto.Hash.Algorithms
-import           Foreign.Ptr (Ptr, plusPtr)
-import           Crypto.Internal.ByteArray (ByteArrayAccess)
+import Crypto.Hash.Algorithms
+import Crypto.Hash.Types
+import Crypto.Internal.ByteArray (ByteArrayAccess, allocAndFreezePrim)
 import qualified Crypto.Internal.ByteArray as B
 import qualified Data.ByteString.Lazy as L
-import           Data.Word (Word8)
-import           Data.Int (Int32)
+import Data.Int (Int32)
+import qualified Foreign.Marshal.Utils as FMU
+import Foreign.Ptr (Ptr, castPtr, plusPtr)
 
 -- | Hash a strict bytestring into a digest.
 hash :: (ByteArrayAccess ba, HashAlgorithm a) => ba -> Digest a
 hash bs = hashFinalize $ hashUpdate hashInit bs
 
 -- | Hash the first N bytes of a bytestring, with code path independent from N.
-hashPrefix :: (ByteArrayAccess ba, HashAlgorithmPrefix a) => ba -> Int -> Digest a
+hashPrefix
+    :: (ByteArrayAccess ba, HashAlgorithmPrefix a) => ba -> Int -> Digest a
 hashPrefix = hashFinalizePrefix hashInit
 
 -- | Hash a lazy bytestring into a digest.
@@ -70,24 +70,27 @@
 hashlazy lbs = hashFinalize $ hashUpdates hashInit (L.toChunks lbs)
 
 -- | Initialize a new context for this hash algorithm
-hashInit :: forall a . HashAlgorithm a => Context a
+hashInit :: forall a. HashAlgorithm a => Context a
 hashInit = Context $ B.allocAndFreeze (hashInternalContextSize (undefined :: a)) $ \(ptr :: Ptr (Context a)) ->
     hashInternalInit ptr
 
 -- | run hashUpdates on one single bytestring and return the updated context.
-hashUpdate :: (ByteArrayAccess ba, HashAlgorithm a) => Context a -> ba -> Context a
+hashUpdate
+    :: (ByteArrayAccess ba, HashAlgorithm a) => Context a -> ba -> Context a
 hashUpdate ctx b
-    | B.null b  = ctx
+    | B.null b = ctx
     | otherwise = hashUpdates ctx [b]
 
 -- | Update the context with a list of strict bytestring,
 -- and return a new context with the updates.
-hashUpdates :: forall a ba . (HashAlgorithm a, ByteArrayAccess ba)
-            => Context a
-            -> [ba]
-            -> Context a
+hashUpdates
+    :: forall a ba
+     . (HashAlgorithm a, ByteArrayAccess ba)
+    => Context a
+    -> [ba]
+    -> Context a
 hashUpdates c l
-    | null ls   = c
+    | null ls = c
     | otherwise = Context $ B.copyAndFreeze c $ \(ctx :: Ptr (Context a)) ->
         mapM_ (\b -> B.withByteArray b (processBlocks ctx (B.length b))) ls
   where
@@ -97,18 +100,24 @@
         | bytesLeft == 0 = return ()
         | otherwise = do
             hashInternalUpdate ctx dataPtr (fromIntegral actuallyProcessed)
-            processBlocks ctx (bytesLeft - actuallyProcessed) (dataPtr `plusPtr` actuallyProcessed)
-        where
-            actuallyProcessed = min bytesLeft (fromIntegral (maxBound :: Int32))
+            processBlocks
+                ctx
+                (bytesLeft - actuallyProcessed)
+                (dataPtr `plusPtr` actuallyProcessed)
+      where
+        actuallyProcessed = min bytesLeft (fromIntegral (maxBound :: Int32))
 
 -- | Finalize a context and return a digest.
-hashFinalize :: forall a . HashAlgorithm a
-             => Context a
-             -> Digest a
-hashFinalize !c =
-    Digest $ B.allocAndFreeze (hashDigestSize (undefined :: a)) $ \(dig :: Ptr (Digest a)) -> do
-        ((!_) :: B.Bytes) <- B.copy c $ \(ctx :: Ptr (Context a)) -> hashInternalFinalize ctx dig
-        return ()
+hashFinalize
+    :: forall a
+     . HashAlgorithm a
+    => Context a
+    -> Digest a
+hashFinalize !c = Digest $
+    allocAndFreezePrim (hashDigestSize (undefined :: a)) $
+        \(dig :: Ptr (Digest a)) -> do
+            ((!_) :: B.Bytes) <- B.copy c $ \(ctx :: Ptr (Context a)) -> hashInternalFinalize ctx dig
+            return ()
 
 -- | Update the context with the first N bytes of a bytestring and return the
 -- digest.  The code path is independent from N but much slower than a normal
@@ -116,17 +125,25 @@
 -- order to exclude a variable padding, without leaking the padding length.  The
 -- begining of the message, never impacted by the padding, should preferably go
 -- through 'hashUpdate' for better performance.
-hashFinalizePrefix :: forall a ba . (HashAlgorithmPrefix a, ByteArrayAccess ba)
-                   => Context a
-                   -> ba
-                   -> Int
-                   -> Digest a
-hashFinalizePrefix !c b len =
-    Digest $ B.allocAndFreeze (hashDigestSize (undefined :: a)) $ \(dig :: Ptr (Digest a)) -> do
-        ((!_) :: B.Bytes) <- B.copy c $ \(ctx :: Ptr (Context a)) ->
-            B.withByteArray b $ \d ->
-                hashInternalFinalizePrefix ctx d (fromIntegral $ B.length b) (fromIntegral len) dig
-        return ()
+hashFinalizePrefix
+    :: forall a ba
+     . (HashAlgorithmPrefix a, ByteArrayAccess ba)
+    => Context a
+    -> ba
+    -> Int
+    -> Digest a
+hashFinalizePrefix !c b len = Digest $
+    allocAndFreezePrim (hashDigestSize (undefined :: a)) $
+        \(dig :: Ptr (Digest a)) -> do
+            ((!_) :: B.Bytes) <- B.copy c $ \(ctx :: Ptr (Context a)) ->
+                B.withByteArray b $ \d ->
+                    hashInternalFinalizePrefix
+                        ctx
+                        d
+                        (fromIntegral $ B.length b)
+                        (fromIntegral len)
+                        dig
+            return ()
 
 -- | Initialize a new context for a specified hash algorithm
 hashInitWith :: HashAlgorithm alg => alg -> Context alg
@@ -137,25 +154,24 @@
 hashWith _ = hash
 
 -- | Run the 'hashPrefix' function but takes an explicit hash algorithm parameter
-hashPrefixWith :: (ByteArrayAccess ba, HashAlgorithmPrefix alg) => alg -> ba -> Int -> Digest alg
+hashPrefixWith
+    :: (ByteArrayAccess ba, HashAlgorithmPrefix alg) => alg -> ba -> Int -> Digest alg
 hashPrefixWith _ = hashPrefix
 
 -- | Try to transform a bytearray into a Digest of specific algorithm.
 --
 -- If the digest is not the right size for the algorithm specified, then
 -- Nothing is returned.
-digestFromByteString :: forall a ba . (HashAlgorithm a, ByteArrayAccess ba) => ba -> Maybe (Digest a)
+digestFromByteString
+    :: forall a ba. (HashAlgorithm a, ByteArrayAccess ba) => ba -> Maybe (Digest a)
 digestFromByteString = from undefined
   where
-        from :: a -> ba -> Maybe (Digest a)
-        from alg bs
-            | B.length bs == (hashDigestSize alg) = Just $ Digest $ unsafeDoIO $ copyBytes bs
-            | otherwise                           = Nothing
+    from :: a -> ba -> Maybe (Digest a)
+    from alg bs
+        | B.length bs == (hashDigestSize alg) =
+            Just $ Digest $ copyByteArray bs
+        | otherwise = Nothing
 
-        copyBytes :: ba -> IO (Block Word8)
-        copyBytes ba = do
-            muArray <- new count
-            B.withByteArray ba $ \ptr -> copyFromPtr ptr muArray 0 count
-            unsafeFreeze muArray
-          where
-            count = CountOf (B.length ba)
+    copyByteArray ba = allocAndFreezePrim (B.length ba) $ \dst ->
+        B.withByteArray ba $ \src ->
+            FMU.copyBytes dst (castPtr src) (B.length ba)
diff --git a/Crypto/Hash/Algorithms.hs b/Crypto/Hash/Algorithms.hs
--- a/Crypto/Hash/Algorithms.hs
+++ b/Crypto/Hash/Algorithms.hs
@@ -6,75 +6,77 @@
 -- Portability : unknown
 --
 -- Definitions of known hash algorithms
---
-module Crypto.Hash.Algorithms
-    ( HashAlgorithm
-    , HashAlgorithmPrefix
+module Crypto.Hash.Algorithms (
+    HashAlgorithm,
+    HashAlgorithmPrefix,
+
     -- * Hash algorithms
-    , Blake2s_160(..)
-    , Blake2s_224(..)
-    , Blake2s_256(..)
-    , Blake2sp_224(..)
-    , Blake2sp_256(..)
-    , Blake2b_160(..)
-    , Blake2b_224(..)
-    , Blake2b_256(..)
-    , Blake2b_384(..)
-    , Blake2b_512(..)
-    , Blake2bp_512(..)
-    , MD2(..)
-    , MD4(..)
-    , MD5(..)
-    , SHA1(..)
-    , SHA224(..)
-    , SHA256(..)
-    , SHA384(..)
-    , SHA512(..)
-    , SHA512t_224(..)
-    , SHA512t_256(..)
-    , RIPEMD160(..)
-    , Tiger(..)
-    , Keccak_224(..)
-    , Keccak_256(..)
-    , Keccak_384(..)
-    , Keccak_512(..)
-    , SHA3_224(..)
-    , SHA3_256(..)
-    , SHA3_384(..)
-    , SHA3_512(..)
-    , SHAKE128(..)
-    , SHAKE256(..)
-    , Blake2b(..), Blake2bp(..)
-    , Blake2s(..), Blake2sp(..)
-    , Skein256_224(..)
-    , Skein256_256(..)
-    , Skein512_224(..)
-    , Skein512_256(..)
-    , Skein512_384(..)
-    , Skein512_512(..)
-    , Whirlpool(..)
-    ) where
+    Blake2s_160 (..),
+    Blake2s_224 (..),
+    Blake2s_256 (..),
+    Blake2sp_224 (..),
+    Blake2sp_256 (..),
+    Blake2b_160 (..),
+    Blake2b_224 (..),
+    Blake2b_256 (..),
+    Blake2b_384 (..),
+    Blake2b_512 (..),
+    Blake2bp_512 (..),
+    MD2 (..),
+    MD4 (..),
+    MD5 (..),
+    SHA1 (..),
+    SHA224 (..),
+    SHA256 (..),
+    SHA384 (..),
+    SHA512 (..),
+    SHA512t_224 (..),
+    SHA512t_256 (..),
+    RIPEMD160 (..),
+    Tiger (..),
+    Keccak_224 (..),
+    Keccak_256 (..),
+    Keccak_384 (..),
+    Keccak_512 (..),
+    SHA3_224 (..),
+    SHA3_256 (..),
+    SHA3_384 (..),
+    SHA3_512 (..),
+    SHAKE128 (..),
+    SHAKE256 (..),
+    Blake2b (..),
+    Blake2bp (..),
+    Blake2s (..),
+    Blake2sp (..),
+    Skein256_224 (..),
+    Skein256_256 (..),
+    Skein512_224 (..),
+    Skein512_256 (..),
+    Skein512_384 (..),
+    Skein512_512 (..),
+    Whirlpool (..),
+) where
 
-import           Crypto.Hash.Types (HashAlgorithm, HashAlgorithmPrefix)
-import           Crypto.Hash.Blake2s
-import           Crypto.Hash.Blake2sp
-import           Crypto.Hash.Blake2b
-import           Crypto.Hash.Blake2bp
-import           Crypto.Hash.MD2
-import           Crypto.Hash.MD4
-import           Crypto.Hash.MD5
-import           Crypto.Hash.SHA1
-import           Crypto.Hash.SHA224
-import           Crypto.Hash.SHA256
-import           Crypto.Hash.SHA384
-import           Crypto.Hash.SHA512
-import           Crypto.Hash.SHA512t
-import           Crypto.Hash.SHA3
-import           Crypto.Hash.Keccak
-import           Crypto.Hash.RIPEMD160
-import           Crypto.Hash.Tiger
-import           Crypto.Hash.Skein256
-import           Crypto.Hash.Skein512
-import           Crypto.Hash.Whirlpool
-import           Crypto.Hash.SHAKE
-import           Crypto.Hash.Blake2
+import Crypto.Hash.Blake2
+import Crypto.Hash.Blake2b
+import Crypto.Hash.Blake2bp
+import Crypto.Hash.Blake2s
+import Crypto.Hash.Blake2sp
+import Crypto.Hash.Keccak
+import Crypto.Hash.MD2
+import Crypto.Hash.MD4
+import Crypto.Hash.MD5
+import Crypto.Hash.RIPEMD160
+import Crypto.Hash.SHA1
+import Crypto.Hash.SHA224
+import Crypto.Hash.SHA256
+import Crypto.Hash.SHA3
+import Crypto.Hash.SHA384
+import Crypto.Hash.SHA512
+import Crypto.Hash.SHA512t
+import Crypto.Hash.SHAKE
+import Crypto.Hash.Skein256
+import Crypto.Hash.Skein512
+import Crypto.Hash.Tiger
+import Crypto.Hash.Types (HashAlgorithm, HashAlgorithmPrefix)
+import Crypto.Hash.Whirlpool
diff --git a/Crypto/Hash/Blake2.hs b/Crypto/Hash/Blake2.hs
--- a/Crypto/Hash/Blake2.hs
+++ b/Crypto/Hash/Blake2.hs
@@ -1,3 +1,10 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE KindSignatures #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Blake2
 -- License     : BSD-style
@@ -25,31 +32,23 @@
 --      id-blake2s224 | 32-bit |   2**112  |         28  |
 --      id-blake2s256 | 32-bit |   2**128  |         32  |
 --     ---------------+--------+-----------+-------------+
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE KindSignatures #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Blake2
-    ( HashBlake2(..)
-    , Blake2s(..)
-    , Blake2sp(..)
-    , Blake2b(..)
-    , Blake2bp(..)
-    ) where
+module Crypto.Hash.Blake2 (
+    HashBlake2 (..),
+    Blake2s (..),
+    Blake2sp (..),
+    Blake2b (..),
+    Blake2bp (..),
+) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
-import           GHC.TypeLits (Nat, KnownNat)
-import           Crypto.Internal.Nat
+import Crypto.Hash.Types
+import Crypto.Internal.Nat
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
+import GHC.TypeLits (KnownNat, Nat)
 
 -- | Typeclass for the Blake2 family of digest functions.
 class HashAlgorithm a => HashBlake2 a where
-
     -- | Init Blake2 algorithm with the specified key of the specified length.
     -- The key length is specified in bytes.
     blake2InternalKeyedInit :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
@@ -63,28 +62,38 @@
 -- * Blake2s 160
 -- * Blake2s 224
 -- * Blake2s 256
---
 data Blake2s (bitlen :: Nat) = Blake2s
-    deriving (Show,Data)
+    deriving (Show, Data)
 
-instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256)
-      => HashAlgorithm (Blake2s bitlen)
-      where
-    type HashBlockSize           (Blake2s bitlen) = 64
-    type HashDigestSize          (Blake2s bitlen) = Div8 bitlen
+instance
+    ( IsDivisibleBy8 bitlen
+    , KnownNat bitlen
+    , IsAtLeast bitlen 8
+    , IsAtMost bitlen 256
+    )
+    => HashAlgorithm (Blake2s bitlen)
+    where
+    type HashBlockSize (Blake2s bitlen) = 64
+    type HashDigestSize (Blake2s bitlen) = Div8 bitlen
     type HashInternalContextSize (Blake2s bitlen) = 136
-    hashBlockSize  _          = 64
-    hashDigestSize _          = byteLen (Proxy :: Proxy bitlen)
+    hashBlockSize _ = 64
+    hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
     hashInternalContextSize _ = 136
-    hashInternalInit p        = c_blake2s_init p (integralNatVal (Proxy :: Proxy bitlen))
-    hashInternalUpdate        = c_blake2s_update
-    hashInternalFinalize p    = c_blake2s_finalize p (integralNatVal (Proxy :: Proxy bitlen))
+    hashInternalInit p = c_blake2s_init p (integralNatVal (Proxy :: Proxy bitlen))
+    hashInternalUpdate = c_blake2s_update
+    hashInternalFinalize p = c_blake2s_finalize p (integralNatVal (Proxy :: Proxy bitlen))
 
-instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256)
-      => HashBlake2 (Blake2s bitlen)
-      where
+instance
+    ( IsDivisibleBy8 bitlen
+    , KnownNat bitlen
+    , IsAtLeast bitlen 8
+    , IsAtMost bitlen 256
+    )
+    => HashBlake2 (Blake2s bitlen)
+    where
     blake2InternalKeyedInit p = c_blake2s_init_key p outLen
-        where outLen = integralNatVal (Proxy :: Proxy bitlen)
+      where
+        outLen = integralNatVal (Proxy :: Proxy bitlen)
 
 foreign import ccall unsafe "crypton_blake2s_init"
     c_blake2s_init :: Ptr (Context a) -> Word32 -> IO ()
@@ -106,28 +115,38 @@
 -- * Blake2b 256
 -- * Blake2b 384
 -- * Blake2b 512
---
 data Blake2b (bitlen :: Nat) = Blake2b
-    deriving (Show,Data)
+    deriving (Show, Data)
 
-instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512)
-      => HashAlgorithm (Blake2b bitlen)
-      where
-    type HashBlockSize           (Blake2b bitlen) = 128
-    type HashDigestSize          (Blake2b bitlen) = Div8 bitlen
+instance
+    ( IsDivisibleBy8 bitlen
+    , KnownNat bitlen
+    , IsAtLeast bitlen 8
+    , IsAtMost bitlen 512
+    )
+    => HashAlgorithm (Blake2b bitlen)
+    where
+    type HashBlockSize (Blake2b bitlen) = 128
+    type HashDigestSize (Blake2b bitlen) = Div8 bitlen
     type HashInternalContextSize (Blake2b bitlen) = 248
-    hashBlockSize  _          = 128
-    hashDigestSize _          = byteLen (Proxy :: Proxy bitlen)
+    hashBlockSize _ = 128
+    hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
     hashInternalContextSize _ = 248
-    hashInternalInit p        = c_blake2b_init p (integralNatVal (Proxy :: Proxy bitlen))
-    hashInternalUpdate        = c_blake2b_update
-    hashInternalFinalize p    = c_blake2b_finalize p (integralNatVal (Proxy :: Proxy bitlen))
+    hashInternalInit p = c_blake2b_init p (integralNatVal (Proxy :: Proxy bitlen))
+    hashInternalUpdate = c_blake2b_update
+    hashInternalFinalize p = c_blake2b_finalize p (integralNatVal (Proxy :: Proxy bitlen))
 
-instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512)
-      => HashBlake2 (Blake2b bitlen)
-      where
+instance
+    ( IsDivisibleBy8 bitlen
+    , KnownNat bitlen
+    , IsAtLeast bitlen 8
+    , IsAtMost bitlen 512
+    )
+    => HashBlake2 (Blake2b bitlen)
+    where
     blake2InternalKeyedInit p = c_blake2b_init_key p outLen
-        where outLen = integralNatVal (Proxy :: Proxy bitlen)
+      where
+        outLen = integralNatVal (Proxy :: Proxy bitlen)
 
 foreign import ccall unsafe "crypton_blake2b_init"
     c_blake2b_init :: Ptr (Context a) -> Word32 -> IO ()
@@ -139,26 +158,37 @@
     c_blake2b_finalize :: Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
 
 data Blake2sp (bitlen :: Nat) = Blake2sp
-    deriving (Show,Data)
+    deriving (Show, Data)
 
-instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256)
-      => HashAlgorithm (Blake2sp bitlen)
-      where
-    type HashBlockSize           (Blake2sp bitlen) = 64
-    type HashDigestSize          (Blake2sp bitlen) = Div8 bitlen
+instance
+    ( IsDivisibleBy8 bitlen
+    , KnownNat bitlen
+    , IsAtLeast bitlen 8
+    , IsAtMost bitlen 256
+    )
+    => HashAlgorithm (Blake2sp bitlen)
+    where
+    type HashBlockSize (Blake2sp bitlen) = 64
+    type HashDigestSize (Blake2sp bitlen) = Div8 bitlen
     type HashInternalContextSize (Blake2sp bitlen) = 2185
-    hashBlockSize  _          = 64
-    hashDigestSize _          = byteLen (Proxy :: Proxy bitlen)
+    hashBlockSize _ = 64
+    hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
     hashInternalContextSize _ = 2185
-    hashInternalInit p        = c_blake2sp_init p (integralNatVal (Proxy :: Proxy bitlen))
-    hashInternalUpdate        = c_blake2sp_update
-    hashInternalFinalize p    = c_blake2sp_finalize p (integralNatVal (Proxy :: Proxy bitlen))
+    hashInternalInit p = c_blake2sp_init p (integralNatVal (Proxy :: Proxy bitlen))
+    hashInternalUpdate = c_blake2sp_update
+    hashInternalFinalize p = c_blake2sp_finalize p (integralNatVal (Proxy :: Proxy bitlen))
 
-instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256)
-      => HashBlake2 (Blake2sp bitlen)
-      where
+instance
+    ( IsDivisibleBy8 bitlen
+    , KnownNat bitlen
+    , IsAtLeast bitlen 8
+    , IsAtMost bitlen 256
+    )
+    => HashBlake2 (Blake2sp bitlen)
+    where
     blake2InternalKeyedInit p = c_blake2sp_init_key p outLen
-        where outLen = integralNatVal (Proxy :: Proxy bitlen)
+      where
+        outLen = integralNatVal (Proxy :: Proxy bitlen)
 
 foreign import ccall unsafe "crypton_blake2sp_init"
     c_blake2sp_init :: Ptr (Context a) -> Word32 -> IO ()
@@ -170,26 +200,37 @@
     c_blake2sp_finalize :: Ptr (Context a) -> Word32 -> Ptr (Digest a) -> IO ()
 
 data Blake2bp (bitlen :: Nat) = Blake2bp
-    deriving (Show,Data)
+    deriving (Show, Data)
 
-instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512)
-      => HashAlgorithm (Blake2bp bitlen)
-      where
-    type HashBlockSize           (Blake2bp bitlen) = 128
-    type HashDigestSize          (Blake2bp bitlen) = Div8 bitlen
+instance
+    ( IsDivisibleBy8 bitlen
+    , KnownNat bitlen
+    , IsAtLeast bitlen 8
+    , IsAtMost bitlen 512
+    )
+    => HashAlgorithm (Blake2bp bitlen)
+    where
+    type HashBlockSize (Blake2bp bitlen) = 128
+    type HashDigestSize (Blake2bp bitlen) = Div8 bitlen
     type HashInternalContextSize (Blake2bp bitlen) = 2325
-    hashBlockSize  _          = 128
-    hashDigestSize _          = byteLen (Proxy :: Proxy bitlen)
+    hashBlockSize _ = 128
+    hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
     hashInternalContextSize _ = 2325
-    hashInternalInit p        = c_blake2bp_init p (integralNatVal (Proxy :: Proxy bitlen))
-    hashInternalUpdate        = c_blake2bp_update
-    hashInternalFinalize p    = c_blake2bp_finalize p (integralNatVal (Proxy :: Proxy bitlen))
+    hashInternalInit p = c_blake2bp_init p (integralNatVal (Proxy :: Proxy bitlen))
+    hashInternalUpdate = c_blake2bp_update
+    hashInternalFinalize p = c_blake2bp_finalize p (integralNatVal (Proxy :: Proxy bitlen))
 
-instance (IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512)
-      => HashBlake2 (Blake2bp bitlen)
-      where
+instance
+    ( IsDivisibleBy8 bitlen
+    , KnownNat bitlen
+    , IsAtLeast bitlen 8
+    , IsAtMost bitlen 512
+    )
+    => HashBlake2 (Blake2bp bitlen)
+    where
     blake2InternalKeyedInit p = c_blake2bp_init_key p outLen
-        where outLen = integralNatVal (Proxy :: Proxy bitlen)
+      where
+        outLen = integralNatVal (Proxy :: Proxy bitlen)
 
 foreign import ccall unsafe "crypton_blake2bp_init"
     c_blake2bp_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/Blake2b.hs b/Crypto/Hash/Blake2b.hs
--- a/Crypto/Hash/Blake2b.hs
+++ b/Crypto/Hash/Blake2b.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Blake2b
 -- License     : BSD-style
@@ -7,96 +12,93 @@
 --
 -- Module containing the binding functions to work with the
 -- Blake2b cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Blake2b
-    (  Blake2b_160 (..), Blake2b_224 (..), Blake2b_256 (..), Blake2b_384 (..), Blake2b_512 (..)
-    ) where
-
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+module Crypto.Hash.Blake2b (
+    Blake2b_160 (..),
+    Blake2b_224 (..),
+    Blake2b_256 (..),
+    Blake2b_384 (..),
+    Blake2b_512 (..),
+) where
 
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | Blake2b (160 bits) cryptographic hash algorithm
 data Blake2b_160 = Blake2b_160
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2b_160 where
-    type HashBlockSize           Blake2b_160 = 128
-    type HashDigestSize          Blake2b_160 = 20
+    type HashBlockSize Blake2b_160 = 128
+    type HashDigestSize Blake2b_160 = 20
     type HashInternalContextSize Blake2b_160 = 248
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 20
+    hashBlockSize _ = 128
+    hashDigestSize _ = 20
     hashInternalContextSize _ = 248
-    hashInternalInit p        = c_blake2b_init p 160
-    hashInternalUpdate        = c_blake2b_update
-    hashInternalFinalize p    = c_blake2b_finalize p 160
+    hashInternalInit p = c_blake2b_init p 160
+    hashInternalUpdate = c_blake2b_update
+    hashInternalFinalize p = c_blake2b_finalize p 160
 
 -- | Blake2b (224 bits) cryptographic hash algorithm
 data Blake2b_224 = Blake2b_224
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2b_224 where
-    type HashBlockSize           Blake2b_224 = 128
-    type HashDigestSize          Blake2b_224 = 28
+    type HashBlockSize Blake2b_224 = 128
+    type HashDigestSize Blake2b_224 = 28
     type HashInternalContextSize Blake2b_224 = 248
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 28
+    hashBlockSize _ = 128
+    hashDigestSize _ = 28
     hashInternalContextSize _ = 248
-    hashInternalInit p        = c_blake2b_init p 224
-    hashInternalUpdate        = c_blake2b_update
-    hashInternalFinalize p    = c_blake2b_finalize p 224
+    hashInternalInit p = c_blake2b_init p 224
+    hashInternalUpdate = c_blake2b_update
+    hashInternalFinalize p = c_blake2b_finalize p 224
 
 -- | Blake2b (256 bits) cryptographic hash algorithm
 data Blake2b_256 = Blake2b_256
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2b_256 where
-    type HashBlockSize           Blake2b_256 = 128
-    type HashDigestSize          Blake2b_256 = 32
+    type HashBlockSize Blake2b_256 = 128
+    type HashDigestSize Blake2b_256 = 32
     type HashInternalContextSize Blake2b_256 = 248
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 32
+    hashBlockSize _ = 128
+    hashDigestSize _ = 32
     hashInternalContextSize _ = 248
-    hashInternalInit p        = c_blake2b_init p 256
-    hashInternalUpdate        = c_blake2b_update
-    hashInternalFinalize p    = c_blake2b_finalize p 256
+    hashInternalInit p = c_blake2b_init p 256
+    hashInternalUpdate = c_blake2b_update
+    hashInternalFinalize p = c_blake2b_finalize p 256
 
 -- | Blake2b (384 bits) cryptographic hash algorithm
 data Blake2b_384 = Blake2b_384
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2b_384 where
-    type HashBlockSize           Blake2b_384 = 128
-    type HashDigestSize          Blake2b_384 = 48
+    type HashBlockSize Blake2b_384 = 128
+    type HashDigestSize Blake2b_384 = 48
     type HashInternalContextSize Blake2b_384 = 248
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 48
+    hashBlockSize _ = 128
+    hashDigestSize _ = 48
     hashInternalContextSize _ = 248
-    hashInternalInit p        = c_blake2b_init p 384
-    hashInternalUpdate        = c_blake2b_update
-    hashInternalFinalize p    = c_blake2b_finalize p 384
+    hashInternalInit p = c_blake2b_init p 384
+    hashInternalUpdate = c_blake2b_update
+    hashInternalFinalize p = c_blake2b_finalize p 384
 
 -- | Blake2b (512 bits) cryptographic hash algorithm
 data Blake2b_512 = Blake2b_512
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2b_512 where
-    type HashBlockSize           Blake2b_512 = 128
-    type HashDigestSize          Blake2b_512 = 64
+    type HashBlockSize Blake2b_512 = 128
+    type HashDigestSize Blake2b_512 = 64
     type HashInternalContextSize Blake2b_512 = 248
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 64
+    hashBlockSize _ = 128
+    hashDigestSize _ = 64
     hashInternalContextSize _ = 248
-    hashInternalInit p        = c_blake2b_init p 512
-    hashInternalUpdate        = c_blake2b_update
-    hashInternalFinalize p    = c_blake2b_finalize p 512
-
+    hashInternalInit p = c_blake2b_init p 512
+    hashInternalUpdate = c_blake2b_update
+    hashInternalFinalize p = c_blake2b_finalize p 512
 
 foreign import ccall unsafe "crypton_blake2b_init"
     c_blake2b_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/Blake2bp.hs b/Crypto/Hash/Blake2bp.hs
--- a/Crypto/Hash/Blake2bp.hs
+++ b/Crypto/Hash/Blake2bp.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Blake2bp
 -- License     : BSD-style
@@ -7,36 +12,29 @@
 --
 -- Module containing the binding functions to work with the
 -- Blake2bp cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Blake2bp
-    (  Blake2bp_512 (..)
-    ) where
-
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+module Crypto.Hash.Blake2bp (
+    Blake2bp_512 (..),
+) where
 
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | Blake2bp (512 bits) cryptographic hash algorithm
 data Blake2bp_512 = Blake2bp_512
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2bp_512 where
-    type HashBlockSize           Blake2bp_512 = 128
-    type HashDigestSize          Blake2bp_512 = 64
+    type HashBlockSize Blake2bp_512 = 128
+    type HashDigestSize Blake2bp_512 = 64
     type HashInternalContextSize Blake2bp_512 = 1768
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 64
+    hashBlockSize _ = 128
+    hashDigestSize _ = 64
     hashInternalContextSize _ = 1768
-    hashInternalInit p        = c_blake2bp_init p 512
-    hashInternalUpdate        = c_blake2bp_update
-    hashInternalFinalize p    = c_blake2bp_finalize p 512
-
+    hashInternalInit p = c_blake2bp_init p 512
+    hashInternalUpdate = c_blake2bp_update
+    hashInternalFinalize p = c_blake2bp_finalize p 512
 
 foreign import ccall unsafe "crypton_blake2bp_init"
     c_blake2bp_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/Blake2s.hs b/Crypto/Hash/Blake2s.hs
--- a/Crypto/Hash/Blake2s.hs
+++ b/Crypto/Hash/Blake2s.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Blake2s
 -- License     : BSD-style
@@ -7,66 +12,61 @@
 --
 -- Module containing the binding functions to work with the
 -- Blake2s cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Blake2s
-    (  Blake2s_160 (..), Blake2s_224 (..), Blake2s_256 (..)
-    ) where
-
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+module Crypto.Hash.Blake2s (
+    Blake2s_160 (..),
+    Blake2s_224 (..),
+    Blake2s_256 (..),
+) where
 
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | Blake2s (160 bits) cryptographic hash algorithm
 data Blake2s_160 = Blake2s_160
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2s_160 where
-    type HashBlockSize           Blake2s_160 = 64
-    type HashDigestSize          Blake2s_160 = 20
+    type HashBlockSize Blake2s_160 = 64
+    type HashDigestSize Blake2s_160 = 20
     type HashInternalContextSize Blake2s_160 = 136
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 20
+    hashBlockSize _ = 64
+    hashDigestSize _ = 20
     hashInternalContextSize _ = 136
-    hashInternalInit p        = c_blake2s_init p 160
-    hashInternalUpdate        = c_blake2s_update
-    hashInternalFinalize p    = c_blake2s_finalize p 160
+    hashInternalInit p = c_blake2s_init p 160
+    hashInternalUpdate = c_blake2s_update
+    hashInternalFinalize p = c_blake2s_finalize p 160
 
 -- | Blake2s (224 bits) cryptographic hash algorithm
 data Blake2s_224 = Blake2s_224
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2s_224 where
-    type HashBlockSize           Blake2s_224 = 64
-    type HashDigestSize          Blake2s_224 = 28
+    type HashBlockSize Blake2s_224 = 64
+    type HashDigestSize Blake2s_224 = 28
     type HashInternalContextSize Blake2s_224 = 136
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 28
+    hashBlockSize _ = 64
+    hashDigestSize _ = 28
     hashInternalContextSize _ = 136
-    hashInternalInit p        = c_blake2s_init p 224
-    hashInternalUpdate        = c_blake2s_update
-    hashInternalFinalize p    = c_blake2s_finalize p 224
+    hashInternalInit p = c_blake2s_init p 224
+    hashInternalUpdate = c_blake2s_update
+    hashInternalFinalize p = c_blake2s_finalize p 224
 
 -- | Blake2s (256 bits) cryptographic hash algorithm
 data Blake2s_256 = Blake2s_256
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2s_256 where
-    type HashBlockSize           Blake2s_256 = 64
-    type HashDigestSize          Blake2s_256 = 32
+    type HashBlockSize Blake2s_256 = 64
+    type HashDigestSize Blake2s_256 = 32
     type HashInternalContextSize Blake2s_256 = 136
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 32
+    hashBlockSize _ = 64
+    hashDigestSize _ = 32
     hashInternalContextSize _ = 136
-    hashInternalInit p        = c_blake2s_init p 256
-    hashInternalUpdate        = c_blake2s_update
-    hashInternalFinalize p    = c_blake2s_finalize p 256
-
+    hashInternalInit p = c_blake2s_init p 256
+    hashInternalUpdate = c_blake2s_update
+    hashInternalFinalize p = c_blake2s_finalize p 256
 
 foreign import ccall unsafe "crypton_blake2s_init"
     c_blake2s_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/Blake2sp.hs b/Crypto/Hash/Blake2sp.hs
--- a/Crypto/Hash/Blake2sp.hs
+++ b/Crypto/Hash/Blake2sp.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Blake2sp
 -- License     : BSD-style
@@ -7,51 +12,45 @@
 --
 -- Module containing the binding functions to work with the
 -- Blake2sp cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Blake2sp
-    (  Blake2sp_224 (..), Blake2sp_256 (..)
-    ) where
-
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+module Crypto.Hash.Blake2sp (
+    Blake2sp_224 (..),
+    Blake2sp_256 (..),
+) where
 
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | Blake2sp (224 bits) cryptographic hash algorithm
 data Blake2sp_224 = Blake2sp_224
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2sp_224 where
-    type HashBlockSize           Blake2sp_224 = 64
-    type HashDigestSize          Blake2sp_224 = 28
+    type HashBlockSize Blake2sp_224 = 64
+    type HashDigestSize Blake2sp_224 = 28
     type HashInternalContextSize Blake2sp_224 = 1752
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 28
+    hashBlockSize _ = 64
+    hashDigestSize _ = 28
     hashInternalContextSize _ = 1752
-    hashInternalInit p        = c_blake2sp_init p 224
-    hashInternalUpdate        = c_blake2sp_update
-    hashInternalFinalize p    = c_blake2sp_finalize p 224
+    hashInternalInit p = c_blake2sp_init p 224
+    hashInternalUpdate = c_blake2sp_update
+    hashInternalFinalize p = c_blake2sp_finalize p 224
 
 -- | Blake2sp (256 bits) cryptographic hash algorithm
 data Blake2sp_256 = Blake2sp_256
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Blake2sp_256 where
-    type HashBlockSize           Blake2sp_256 = 64
-    type HashDigestSize          Blake2sp_256 = 32
+    type HashBlockSize Blake2sp_256 = 64
+    type HashDigestSize Blake2sp_256 = 32
     type HashInternalContextSize Blake2sp_256 = 1752
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 32
+    hashBlockSize _ = 64
+    hashDigestSize _ = 32
     hashInternalContextSize _ = 1752
-    hashInternalInit p        = c_blake2sp_init p 256
-    hashInternalUpdate        = c_blake2sp_update
-    hashInternalFinalize p    = c_blake2sp_finalize p 256
-
+    hashInternalInit p = c_blake2sp_init p 256
+    hashInternalUpdate = c_blake2sp_update
+    hashInternalFinalize p = c_blake2sp_finalize p 256
 
 foreign import ccall unsafe "crypton_blake2sp_init"
     c_blake2sp_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/IO.hs b/Crypto/Hash/IO.hs
--- a/Crypto/Hash/IO.hs
+++ b/Crypto/Hash/IO.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- |
 -- Module      : Crypto.Hash.IO
 -- License     : BSD-style
@@ -6,22 +9,20 @@
 -- Portability : unknown
 --
 -- Generalized impure cryptographic hash interface
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE ScopedTypeVariables        #-}
-module Crypto.Hash.IO
-    ( HashAlgorithm(..)
-    , MutableContext
-    , hashMutableInit
-    , hashMutableInitWith
-    , hashMutableUpdate
-    , hashMutableFinalize
-    , hashMutableReset
-    ) where
+module Crypto.Hash.IO (
+    HashAlgorithm (..),
+    MutableContext,
+    hashMutableInit,
+    hashMutableInitWith,
+    hashMutableUpdate,
+    hashMutableFinalize,
+    hashMutableReset,
+) where
 
-import           Crypto.Hash.Types
+import Crypto.Hash.Types
+import Crypto.Internal.ByteArray (allocAndFreezePrimIO)
 import qualified Crypto.Internal.ByteArray as B
-import           Foreign.Ptr
+import Foreign.Ptr
 
 -- | A Mutable hash context
 --
@@ -38,8 +39,10 @@
 hashMutableInit :: HashAlgorithm alg => IO (MutableContext alg)
 hashMutableInit = doInit undefined B.alloc
   where
-        doInit :: HashAlgorithm a => a -> (Int -> (Ptr (Context a) -> IO ()) -> IO B.Bytes) -> IO (MutableContext a)
-        doInit alg alloc = MutableContext `fmap` alloc (hashInternalContextSize alg) hashInternalInit
+    doInit
+        :: HashAlgorithm a
+        => a -> (Int -> (Ptr (Context a) -> IO ()) -> IO B.Bytes) -> IO (MutableContext a)
+    doInit alg alloc = MutableContext `fmap` alloc (hashInternalContextSize alg) hashInternalInit
 
 -- | Create a new mutable hash context.
 --
@@ -48,23 +51,32 @@
 hashMutableInitWith _ = hashMutableInit
 
 -- | Update a mutable hash context in place
-hashMutableUpdate :: (B.ByteArrayAccess ba, HashAlgorithm a) => MutableContext a -> ba -> IO ()
+hashMutableUpdate
+    :: (B.ByteArrayAccess ba, HashAlgorithm a) => MutableContext a -> ba -> IO ()
 hashMutableUpdate mc dat = doUpdate mc (B.withByteArray mc)
-  where doUpdate :: HashAlgorithm a => MutableContext a -> ((Ptr (Context a) -> IO ()) -> IO ()) -> IO ()
-        doUpdate _ withCtx =
-            withCtx             $ \ctx ->
-            B.withByteArray dat $ \d   ->
+  where
+    doUpdate
+        :: HashAlgorithm a
+        => MutableContext a -> ((Ptr (Context a) -> IO ()) -> IO ()) -> IO ()
+    doUpdate _ withCtx =
+        withCtx $ \ctx ->
+            B.withByteArray dat $ \d ->
                 hashInternalUpdate ctx d (fromIntegral $ B.length dat)
 
 -- | Finalize a mutable hash context and compute a digest
-hashMutableFinalize :: forall a . HashAlgorithm a => MutableContext a -> IO (Digest a)
+hashMutableFinalize
+    :: forall a. HashAlgorithm a => MutableContext a -> IO (Digest a)
 hashMutableFinalize mc = do
-    b <- B.alloc (hashDigestSize (undefined :: a)) $ \dig -> B.withByteArray mc $ \(ctx :: Ptr (Context a)) -> hashInternalFinalize ctx dig
-    return $ Digest b
+    ba <- allocAndFreezePrimIO (hashDigestSize (undefined :: a)) $
+        \(dig :: Ptr (Digest a)) ->
+            B.withByteArray mc $ \(ctx :: Ptr (Context a)) -> hashInternalFinalize ctx dig
+    return (Digest ba)
 
 -- | Reset the mutable context to the initial state of the hash
 hashMutableReset :: HashAlgorithm a => MutableContext a -> IO ()
 hashMutableReset mc = doReset mc (B.withByteArray mc)
   where
-    doReset :: HashAlgorithm a => MutableContext a -> ((Ptr (Context a) -> IO ()) -> IO ()) -> IO ()
+    doReset
+        :: HashAlgorithm a
+        => MutableContext a -> ((Ptr (Context a) -> IO ()) -> IO ()) -> IO ()
     doReset _ withCtx = withCtx hashInternalInit
diff --git a/Crypto/Hash/Keccak.hs b/Crypto/Hash/Keccak.hs
--- a/Crypto/Hash/Keccak.hs
+++ b/Crypto/Hash/Keccak.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Keccak
 -- License     : BSD-style
@@ -7,81 +12,77 @@
 --
 -- Module containing the binding functions to work with the
 -- Keccak cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Keccak
-    (  Keccak_224 (..), Keccak_256 (..), Keccak_384 (..), Keccak_512 (..)
-    ) where
-
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+module Crypto.Hash.Keccak (
+    Keccak_224 (..),
+    Keccak_256 (..),
+    Keccak_384 (..),
+    Keccak_512 (..),
+) where
 
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | Keccak (224 bits) cryptographic hash algorithm
 data Keccak_224 = Keccak_224
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Keccak_224 where
-    type HashBlockSize           Keccak_224 = 144
-    type HashDigestSize          Keccak_224 = 28
+    type HashBlockSize Keccak_224 = 144
+    type HashDigestSize Keccak_224 = 28
     type HashInternalContextSize Keccak_224 = 352
-    hashBlockSize  _          = 144
-    hashDigestSize _          = 28
+    hashBlockSize _ = 144
+    hashDigestSize _ = 28
     hashInternalContextSize _ = 352
-    hashInternalInit p        = c_keccak_init p 224
-    hashInternalUpdate        = c_keccak_update
-    hashInternalFinalize p    = c_keccak_finalize p 224
+    hashInternalInit p = c_keccak_init p 224
+    hashInternalUpdate = c_keccak_update
+    hashInternalFinalize p = c_keccak_finalize p 224
 
 -- | Keccak (256 bits) cryptographic hash algorithm
 data Keccak_256 = Keccak_256
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Keccak_256 where
-    type HashBlockSize           Keccak_256 = 136
-    type HashDigestSize          Keccak_256 = 32
+    type HashBlockSize Keccak_256 = 136
+    type HashDigestSize Keccak_256 = 32
     type HashInternalContextSize Keccak_256 = 344
-    hashBlockSize  _          = 136
-    hashDigestSize _          = 32
+    hashBlockSize _ = 136
+    hashDigestSize _ = 32
     hashInternalContextSize _ = 344
-    hashInternalInit p        = c_keccak_init p 256
-    hashInternalUpdate        = c_keccak_update
-    hashInternalFinalize p    = c_keccak_finalize p 256
+    hashInternalInit p = c_keccak_init p 256
+    hashInternalUpdate = c_keccak_update
+    hashInternalFinalize p = c_keccak_finalize p 256
 
 -- | Keccak (384 bits) cryptographic hash algorithm
 data Keccak_384 = Keccak_384
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Keccak_384 where
-    type HashBlockSize           Keccak_384 = 104
-    type HashDigestSize          Keccak_384 = 48
+    type HashBlockSize Keccak_384 = 104
+    type HashDigestSize Keccak_384 = 48
     type HashInternalContextSize Keccak_384 = 312
-    hashBlockSize  _          = 104
-    hashDigestSize _          = 48
+    hashBlockSize _ = 104
+    hashDigestSize _ = 48
     hashInternalContextSize _ = 312
-    hashInternalInit p        = c_keccak_init p 384
-    hashInternalUpdate        = c_keccak_update
-    hashInternalFinalize p    = c_keccak_finalize p 384
+    hashInternalInit p = c_keccak_init p 384
+    hashInternalUpdate = c_keccak_update
+    hashInternalFinalize p = c_keccak_finalize p 384
 
 -- | Keccak (512 bits) cryptographic hash algorithm
 data Keccak_512 = Keccak_512
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Keccak_512 where
-    type HashBlockSize           Keccak_512 = 72
-    type HashDigestSize          Keccak_512 = 64
+    type HashBlockSize Keccak_512 = 72
+    type HashDigestSize Keccak_512 = 64
     type HashInternalContextSize Keccak_512 = 280
-    hashBlockSize  _          = 72
-    hashDigestSize _          = 64
+    hashBlockSize _ = 72
+    hashDigestSize _ = 64
     hashInternalContextSize _ = 280
-    hashInternalInit p        = c_keccak_init p 512
-    hashInternalUpdate        = c_keccak_update
-    hashInternalFinalize p    = c_keccak_finalize p 512
-
+    hashInternalInit p = c_keccak_init p 512
+    hashInternalUpdate = c_keccak_update
+    hashInternalFinalize p = c_keccak_finalize p 512
 
 foreign import ccall unsafe "crypton_keccak_init"
     c_keccak_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/MD2.hs b/Crypto/Hash/MD2.hs
--- a/Crypto/Hash/MD2.hs
+++ b/Crypto/Hash/MD2.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.MD2
 -- License     : BSD-style
@@ -7,35 +12,30 @@
 --
 -- Module containing the binding functions to work with the
 -- MD2 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.MD2 ( MD2 (..) ) where
+module Crypto.Hash.MD2 (MD2 (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | MD2 cryptographic hash algorithm
 data MD2 = MD2
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm MD2 where
-    type HashBlockSize           MD2 = 16
-    type HashDigestSize          MD2 = 16
+    type HashBlockSize MD2 = 16
+    type HashDigestSize MD2 = 16
     type HashInternalContextSize MD2 = 96
-    hashBlockSize  _          = 16
-    hashDigestSize _          = 16
+    hashBlockSize _ = 16
+    hashDigestSize _ = 16
     hashInternalContextSize _ = 96
-    hashInternalInit          = c_md2_init
-    hashInternalUpdate        = c_md2_update
-    hashInternalFinalize      = c_md2_finalize
+    hashInternalInit = c_md2_init
+    hashInternalUpdate = c_md2_update
+    hashInternalFinalize = c_md2_finalize
 
 foreign import ccall unsafe "crypton_md2_init"
-    c_md2_init :: Ptr (Context a)-> IO ()
+    c_md2_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_md2_update"
     c_md2_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
diff --git a/Crypto/Hash/MD4.hs b/Crypto/Hash/MD4.hs
--- a/Crypto/Hash/MD4.hs
+++ b/Crypto/Hash/MD4.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.MD4
 -- License     : BSD-style
@@ -7,35 +12,30 @@
 --
 -- Module containing the binding functions to work with the
 -- MD4 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.MD4 ( MD4 (..) ) where
+module Crypto.Hash.MD4 (MD4 (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | MD4 cryptographic hash algorithm
 data MD4 = MD4
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm MD4 where
-    type HashBlockSize           MD4 = 64
-    type HashDigestSize          MD4 = 16
+    type HashBlockSize MD4 = 64
+    type HashDigestSize MD4 = 16
     type HashInternalContextSize MD4 = 96
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 16
+    hashBlockSize _ = 64
+    hashDigestSize _ = 16
     hashInternalContextSize _ = 96
-    hashInternalInit          = c_md4_init
-    hashInternalUpdate        = c_md4_update
-    hashInternalFinalize      = c_md4_finalize
+    hashInternalInit = c_md4_init
+    hashInternalUpdate = c_md4_update
+    hashInternalFinalize = c_md4_finalize
 
 foreign import ccall unsafe "crypton_md4_init"
-    c_md4_init :: Ptr (Context a)-> IO ()
+    c_md4_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_md4_update"
     c_md4_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
diff --git a/Crypto/Hash/MD5.hs b/Crypto/Hash/MD5.hs
--- a/Crypto/Hash/MD5.hs
+++ b/Crypto/Hash/MD5.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.MD5
 -- License     : BSD-style
@@ -7,38 +12,33 @@
 --
 -- Module containing the binding functions to work with the
 -- MD5 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.MD5 ( MD5 (..) ) where
+module Crypto.Hash.MD5 (MD5 (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | MD5 cryptographic hash algorithm
 data MD5 = MD5
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm MD5 where
-    type HashBlockSize           MD5 = 64
-    type HashDigestSize          MD5 = 16
+    type HashBlockSize MD5 = 64
+    type HashDigestSize MD5 = 16
     type HashInternalContextSize MD5 = 96
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 16
+    hashBlockSize _ = 64
+    hashDigestSize _ = 16
     hashInternalContextSize _ = 96
-    hashInternalInit          = c_md5_init
-    hashInternalUpdate        = c_md5_update
-    hashInternalFinalize      = c_md5_finalize
+    hashInternalInit = c_md5_init
+    hashInternalUpdate = c_md5_update
+    hashInternalFinalize = c_md5_finalize
 
 instance HashAlgorithmPrefix MD5 where
     hashInternalFinalizePrefix = c_md5_finalize_prefix
 
 foreign import ccall unsafe "crypton_md5_init"
-    c_md5_init :: Ptr (Context a)-> IO ()
+    c_md5_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_md5_update"
     c_md5_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
@@ -47,4 +47,5 @@
     c_md5_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
 
 foreign import ccall "crypton_md5_finalize_prefix"
-    c_md5_finalize_prefix :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
+    c_md5_finalize_prefix
+        :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
diff --git a/Crypto/Hash/RIPEMD160.hs b/Crypto/Hash/RIPEMD160.hs
--- a/Crypto/Hash/RIPEMD160.hs
+++ b/Crypto/Hash/RIPEMD160.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.RIPEMD160
 -- License     : BSD-style
@@ -7,35 +12,30 @@
 --
 -- Module containing the binding functions to work with the
 -- RIPEMD160 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.RIPEMD160 ( RIPEMD160 (..) ) where
+module Crypto.Hash.RIPEMD160 (RIPEMD160 (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | RIPEMD160 cryptographic hash algorithm
 data RIPEMD160 = RIPEMD160
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm RIPEMD160 where
-    type HashBlockSize           RIPEMD160 = 64
-    type HashDigestSize          RIPEMD160 = 20
+    type HashBlockSize RIPEMD160 = 64
+    type HashDigestSize RIPEMD160 = 20
     type HashInternalContextSize RIPEMD160 = 128
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 20
+    hashBlockSize _ = 64
+    hashDigestSize _ = 20
     hashInternalContextSize _ = 128
-    hashInternalInit          = c_ripemd160_init
-    hashInternalUpdate        = c_ripemd160_update
-    hashInternalFinalize      = c_ripemd160_finalize
+    hashInternalInit = c_ripemd160_init
+    hashInternalUpdate = c_ripemd160_update
+    hashInternalFinalize = c_ripemd160_finalize
 
 foreign import ccall unsafe "crypton_ripemd160_init"
-    c_ripemd160_init :: Ptr (Context a)-> IO ()
+    c_ripemd160_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_ripemd160_update"
     c_ripemd160_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
diff --git a/Crypto/Hash/SHA1.hs b/Crypto/Hash/SHA1.hs
--- a/Crypto/Hash/SHA1.hs
+++ b/Crypto/Hash/SHA1.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.SHA1
 -- License     : BSD-style
@@ -7,38 +12,33 @@
 --
 -- Module containing the binding functions to work with the
 -- SHA1 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.SHA1 ( SHA1 (..) ) where
+module Crypto.Hash.SHA1 (SHA1 (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | SHA1 cryptographic hash algorithm
 data SHA1 = SHA1
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA1 where
-    type HashBlockSize           SHA1 = 64
-    type HashDigestSize          SHA1 = 20
+    type HashBlockSize SHA1 = 64
+    type HashDigestSize SHA1 = 20
     type HashInternalContextSize SHA1 = 96
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 20
+    hashBlockSize _ = 64
+    hashDigestSize _ = 20
     hashInternalContextSize _ = 96
-    hashInternalInit          = c_sha1_init
-    hashInternalUpdate        = c_sha1_update
-    hashInternalFinalize      = c_sha1_finalize
+    hashInternalInit = c_sha1_init
+    hashInternalUpdate = c_sha1_update
+    hashInternalFinalize = c_sha1_finalize
 
 instance HashAlgorithmPrefix SHA1 where
     hashInternalFinalizePrefix = c_sha1_finalize_prefix
 
 foreign import ccall unsafe "crypton_sha1_init"
-    c_sha1_init :: Ptr (Context a)-> IO ()
+    c_sha1_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_sha1_update"
     c_sha1_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
@@ -47,4 +47,5 @@
     c_sha1_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
 
 foreign import ccall "crypton_sha1_finalize_prefix"
-    c_sha1_finalize_prefix :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
+    c_sha1_finalize_prefix
+        :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
diff --git a/Crypto/Hash/SHA224.hs b/Crypto/Hash/SHA224.hs
--- a/Crypto/Hash/SHA224.hs
+++ b/Crypto/Hash/SHA224.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.SHA224
 -- License     : BSD-style
@@ -7,38 +12,33 @@
 --
 -- Module containing the binding functions to work with the
 -- SHA224 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.SHA224 ( SHA224 (..) ) where
+module Crypto.Hash.SHA224 (SHA224 (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | SHA224 cryptographic hash algorithm
 data SHA224 = SHA224
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA224 where
-    type HashBlockSize           SHA224 = 64
-    type HashDigestSize          SHA224 = 28
+    type HashBlockSize SHA224 = 64
+    type HashDigestSize SHA224 = 28
     type HashInternalContextSize SHA224 = 192
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 28
+    hashBlockSize _ = 64
+    hashDigestSize _ = 28
     hashInternalContextSize _ = 192
-    hashInternalInit          = c_sha224_init
-    hashInternalUpdate        = c_sha224_update
-    hashInternalFinalize      = c_sha224_finalize
+    hashInternalInit = c_sha224_init
+    hashInternalUpdate = c_sha224_update
+    hashInternalFinalize = c_sha224_finalize
 
 instance HashAlgorithmPrefix SHA224 where
     hashInternalFinalizePrefix = c_sha224_finalize_prefix
 
 foreign import ccall unsafe "crypton_sha224_init"
-    c_sha224_init :: Ptr (Context a)-> IO ()
+    c_sha224_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_sha224_update"
     c_sha224_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
@@ -47,4 +47,5 @@
     c_sha224_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
 
 foreign import ccall "crypton_sha224_finalize_prefix"
-    c_sha224_finalize_prefix :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
+    c_sha224_finalize_prefix
+        :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
diff --git a/Crypto/Hash/SHA256.hs b/Crypto/Hash/SHA256.hs
--- a/Crypto/Hash/SHA256.hs
+++ b/Crypto/Hash/SHA256.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.SHA256
 -- License     : BSD-style
@@ -7,38 +12,33 @@
 --
 -- Module containing the binding functions to work with the
 -- SHA256 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.SHA256 ( SHA256 (..) ) where
+module Crypto.Hash.SHA256 (SHA256 (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | SHA256 cryptographic hash algorithm
 data SHA256 = SHA256
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA256 where
-    type HashBlockSize           SHA256 = 64
-    type HashDigestSize          SHA256 = 32
+    type HashBlockSize SHA256 = 64
+    type HashDigestSize SHA256 = 32
     type HashInternalContextSize SHA256 = 192
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 32
+    hashBlockSize _ = 64
+    hashDigestSize _ = 32
     hashInternalContextSize _ = 192
-    hashInternalInit          = c_sha256_init
-    hashInternalUpdate        = c_sha256_update
-    hashInternalFinalize      = c_sha256_finalize
+    hashInternalInit = c_sha256_init
+    hashInternalUpdate = c_sha256_update
+    hashInternalFinalize = c_sha256_finalize
 
 instance HashAlgorithmPrefix SHA256 where
     hashInternalFinalizePrefix = c_sha256_finalize_prefix
 
 foreign import ccall unsafe "crypton_sha256_init"
-    c_sha256_init :: Ptr (Context a)-> IO ()
+    c_sha256_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_sha256_update"
     c_sha256_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
@@ -47,4 +47,5 @@
     c_sha256_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
 
 foreign import ccall "crypton_sha256_finalize_prefix"
-    c_sha256_finalize_prefix :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
+    c_sha256_finalize_prefix
+        :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
diff --git a/Crypto/Hash/SHA3.hs b/Crypto/Hash/SHA3.hs
--- a/Crypto/Hash/SHA3.hs
+++ b/Crypto/Hash/SHA3.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.SHA3
 -- License     : BSD-style
@@ -7,81 +12,77 @@
 --
 -- Module containing the binding functions to work with the
 -- SHA3 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.SHA3
-    (  SHA3_224 (..), SHA3_256 (..), SHA3_384 (..), SHA3_512 (..)
-    ) where
-
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+module Crypto.Hash.SHA3 (
+    SHA3_224 (..),
+    SHA3_256 (..),
+    SHA3_384 (..),
+    SHA3_512 (..),
+) where
 
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | SHA3 (224 bits) cryptographic hash algorithm
 data SHA3_224 = SHA3_224
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA3_224 where
-    type HashBlockSize           SHA3_224 = 144
-    type HashDigestSize          SHA3_224 = 28
+    type HashBlockSize SHA3_224 = 144
+    type HashDigestSize SHA3_224 = 28
     type HashInternalContextSize SHA3_224 = 352
-    hashBlockSize  _          = 144
-    hashDigestSize _          = 28
+    hashBlockSize _ = 144
+    hashDigestSize _ = 28
     hashInternalContextSize _ = 352
-    hashInternalInit p        = c_sha3_init p 224
-    hashInternalUpdate        = c_sha3_update
-    hashInternalFinalize p    = c_sha3_finalize p 224
+    hashInternalInit p = c_sha3_init p 224
+    hashInternalUpdate = c_sha3_update
+    hashInternalFinalize p = c_sha3_finalize p 224
 
 -- | SHA3 (256 bits) cryptographic hash algorithm
 data SHA3_256 = SHA3_256
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA3_256 where
-    type HashBlockSize           SHA3_256 = 136
-    type HashDigestSize          SHA3_256 = 32
+    type HashBlockSize SHA3_256 = 136
+    type HashDigestSize SHA3_256 = 32
     type HashInternalContextSize SHA3_256 = 344
-    hashBlockSize  _          = 136
-    hashDigestSize _          = 32
+    hashBlockSize _ = 136
+    hashDigestSize _ = 32
     hashInternalContextSize _ = 344
-    hashInternalInit p        = c_sha3_init p 256
-    hashInternalUpdate        = c_sha3_update
-    hashInternalFinalize p    = c_sha3_finalize p 256
+    hashInternalInit p = c_sha3_init p 256
+    hashInternalUpdate = c_sha3_update
+    hashInternalFinalize p = c_sha3_finalize p 256
 
 -- | SHA3 (384 bits) cryptographic hash algorithm
 data SHA3_384 = SHA3_384
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA3_384 where
-    type HashBlockSize           SHA3_384 = 104
-    type HashDigestSize          SHA3_384 = 48
+    type HashBlockSize SHA3_384 = 104
+    type HashDigestSize SHA3_384 = 48
     type HashInternalContextSize SHA3_384 = 312
-    hashBlockSize  _          = 104
-    hashDigestSize _          = 48
+    hashBlockSize _ = 104
+    hashDigestSize _ = 48
     hashInternalContextSize _ = 312
-    hashInternalInit p        = c_sha3_init p 384
-    hashInternalUpdate        = c_sha3_update
-    hashInternalFinalize p    = c_sha3_finalize p 384
+    hashInternalInit p = c_sha3_init p 384
+    hashInternalUpdate = c_sha3_update
+    hashInternalFinalize p = c_sha3_finalize p 384
 
 -- | SHA3 (512 bits) cryptographic hash algorithm
 data SHA3_512 = SHA3_512
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA3_512 where
-    type HashBlockSize           SHA3_512 = 72
-    type HashDigestSize          SHA3_512 = 64
+    type HashBlockSize SHA3_512 = 72
+    type HashDigestSize SHA3_512 = 64
     type HashInternalContextSize SHA3_512 = 280
-    hashBlockSize  _          = 72
-    hashDigestSize _          = 64
+    hashBlockSize _ = 72
+    hashDigestSize _ = 64
     hashInternalContextSize _ = 280
-    hashInternalInit p        = c_sha3_init p 512
-    hashInternalUpdate        = c_sha3_update
-    hashInternalFinalize p    = c_sha3_finalize p 512
-
+    hashInternalInit p = c_sha3_init p 512
+    hashInternalUpdate = c_sha3_update
+    hashInternalFinalize p = c_sha3_finalize p 512
 
 foreign import ccall unsafe "crypton_sha3_init"
     c_sha3_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/SHA384.hs b/Crypto/Hash/SHA384.hs
--- a/Crypto/Hash/SHA384.hs
+++ b/Crypto/Hash/SHA384.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.SHA384
 -- License     : BSD-style
@@ -7,38 +12,33 @@
 --
 -- Module containing the binding functions to work with the
 -- SHA384 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.SHA384 ( SHA384 (..) ) where
+module Crypto.Hash.SHA384 (SHA384 (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | SHA384 cryptographic hash algorithm
 data SHA384 = SHA384
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA384 where
-    type HashBlockSize           SHA384 = 128
-    type HashDigestSize          SHA384 = 48
+    type HashBlockSize SHA384 = 128
+    type HashDigestSize SHA384 = 48
     type HashInternalContextSize SHA384 = 256
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 48
+    hashBlockSize _ = 128
+    hashDigestSize _ = 48
     hashInternalContextSize _ = 256
-    hashInternalInit          = c_sha384_init
-    hashInternalUpdate        = c_sha384_update
-    hashInternalFinalize      = c_sha384_finalize
+    hashInternalInit = c_sha384_init
+    hashInternalUpdate = c_sha384_update
+    hashInternalFinalize = c_sha384_finalize
 
 instance HashAlgorithmPrefix SHA384 where
     hashInternalFinalizePrefix = c_sha384_finalize_prefix
 
 foreign import ccall unsafe "crypton_sha384_init"
-    c_sha384_init :: Ptr (Context a)-> IO ()
+    c_sha384_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_sha384_update"
     c_sha384_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
@@ -47,4 +47,5 @@
     c_sha384_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
 
 foreign import ccall "crypton_sha384_finalize_prefix"
-    c_sha384_finalize_prefix :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
+    c_sha384_finalize_prefix
+        :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
diff --git a/Crypto/Hash/SHA512.hs b/Crypto/Hash/SHA512.hs
--- a/Crypto/Hash/SHA512.hs
+++ b/Crypto/Hash/SHA512.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.SHA512
 -- License     : BSD-style
@@ -7,38 +12,33 @@
 --
 -- Module containing the binding functions to work with the
 -- SHA512 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.SHA512 ( SHA512 (..) ) where
+module Crypto.Hash.SHA512 (SHA512 (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | SHA512 cryptographic hash algorithm
 data SHA512 = SHA512
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA512 where
-    type HashBlockSize           SHA512 = 128
-    type HashDigestSize          SHA512 = 64
+    type HashBlockSize SHA512 = 128
+    type HashDigestSize SHA512 = 64
     type HashInternalContextSize SHA512 = 256
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 64
+    hashBlockSize _ = 128
+    hashDigestSize _ = 64
     hashInternalContextSize _ = 256
-    hashInternalInit          = c_sha512_init
-    hashInternalUpdate        = c_sha512_update
-    hashInternalFinalize      = c_sha512_finalize
+    hashInternalInit = c_sha512_init
+    hashInternalUpdate = c_sha512_update
+    hashInternalFinalize = c_sha512_finalize
 
 instance HashAlgorithmPrefix SHA512 where
     hashInternalFinalizePrefix = c_sha512_finalize_prefix
 
 foreign import ccall unsafe "crypton_sha512_init"
-    c_sha512_init :: Ptr (Context a)-> IO ()
+    c_sha512_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_sha512_update"
     c_sha512_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
@@ -47,4 +47,5 @@
     c_sha512_finalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
 
 foreign import ccall "crypton_sha512_finalize_prefix"
-    c_sha512_finalize_prefix :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
+    c_sha512_finalize_prefix
+        :: Ptr (Context a) -> Ptr Word8 -> Word32 -> Word32 -> Ptr (Digest a) -> IO ()
diff --git a/Crypto/Hash/SHA512t.hs b/Crypto/Hash/SHA512t.hs
--- a/Crypto/Hash/SHA512t.hs
+++ b/Crypto/Hash/SHA512t.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.SHA512t
 -- License     : BSD-style
@@ -7,51 +12,45 @@
 --
 -- Module containing the binding functions to work with the
 -- SHA512t cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.SHA512t
-    (  SHA512t_224 (..), SHA512t_256 (..)
-    ) where
-
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+module Crypto.Hash.SHA512t (
+    SHA512t_224 (..),
+    SHA512t_256 (..),
+) where
 
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | SHA512t (224 bits) cryptographic hash algorithm
 data SHA512t_224 = SHA512t_224
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA512t_224 where
-    type HashBlockSize           SHA512t_224 = 128
-    type HashDigestSize          SHA512t_224 = 28
+    type HashBlockSize SHA512t_224 = 128
+    type HashDigestSize SHA512t_224 = 28
     type HashInternalContextSize SHA512t_224 = 256
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 28
+    hashBlockSize _ = 128
+    hashDigestSize _ = 28
     hashInternalContextSize _ = 256
-    hashInternalInit p        = c_sha512t_init p 224
-    hashInternalUpdate        = c_sha512t_update
-    hashInternalFinalize p    = c_sha512t_finalize p 224
+    hashInternalInit p = c_sha512t_init p 224
+    hashInternalUpdate = c_sha512t_update
+    hashInternalFinalize p = c_sha512t_finalize p 224
 
 -- | SHA512t (256 bits) cryptographic hash algorithm
 data SHA512t_256 = SHA512t_256
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm SHA512t_256 where
-    type HashBlockSize           SHA512t_256 = 128
-    type HashDigestSize          SHA512t_256 = 32
+    type HashBlockSize SHA512t_256 = 128
+    type HashDigestSize SHA512t_256 = 32
     type HashInternalContextSize SHA512t_256 = 256
-    hashBlockSize  _          = 128
-    hashDigestSize _          = 32
+    hashBlockSize _ = 128
+    hashDigestSize _ = 32
     hashInternalContextSize _ = 256
-    hashInternalInit p        = c_sha512t_init p 256
-    hashInternalUpdate        = c_sha512t_update
-    hashInternalFinalize p    = c_sha512t_finalize p 256
-
+    hashInternalInit p = c_sha512t_init p 256
+    hashInternalUpdate = c_sha512t_update
+    hashInternalFinalize p = c_sha512t_finalize p 256
 
 foreign import ccall unsafe "crypton_sha512t_init"
     c_sha512t_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/SHAKE.hs b/Crypto/Hash/SHAKE.hs
--- a/Crypto/Hash/SHAKE.hs
+++ b/Crypto/Hash/SHAKE.hs
@@ -1,3 +1,12 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE KindSignatures #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE UndecidableInstances #-}
+
 -- |
 -- Module      : Crypto.Hash.SHAKE
 -- License     : BSD-style
@@ -7,34 +16,28 @@
 --
 -- Module containing the binding functions to work with the
 -- SHA3 extendable output functions (SHAKE).
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE KindSignatures #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TypeOperators #-}
-{-# LANGUAGE TypeFamilies #-}
-{-# LANGUAGE UndecidableInstances #-}
-module Crypto.Hash.SHAKE
-    (  SHAKE128 (..), SHAKE256 (..), HashSHAKE (..)
-    ) where
+module Crypto.Hash.SHAKE (
+    SHAKE128 (..),
+    SHAKE256 (..),
+    HashSHAKE (..),
+) where
 
-import           Control.Monad (when)
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr, castPtr)
-import           Foreign.Storable (Storable(..))
-import           Data.Bits
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Control.Monad (when)
+import Crypto.Hash.Types
+import Data.Bits
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr, castPtr)
+import Foreign.Storable (Storable (..))
 
-import           GHC.TypeLits (Nat, KnownNat, type (+))
-import           Crypto.Internal.Nat
+import Crypto.Internal.Nat
+import GHC.TypeLits (KnownNat, Nat, type (+))
 
 -- | Type class of SHAKE algorithms.
 class HashAlgorithm a => HashSHAKE a where
     -- | Alternate finalization needed for cSHAKE
     cshakeInternalFinalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
+
     -- | Get the digest bit length
     cshakeOutputLength :: a -> Int
 
@@ -48,15 +51,15 @@
     deriving (Show, Data)
 
 instance KnownNat bitlen => HashAlgorithm (SHAKE128 bitlen) where
-    type HashBlockSize           (SHAKE128 bitlen)  = 168
-    type HashDigestSize          (SHAKE128 bitlen) = Div8 (bitlen + 7)
+    type HashBlockSize (SHAKE128 bitlen) = 168
+    type HashDigestSize (SHAKE128 bitlen) = Div8 (bitlen + 7)
     type HashInternalContextSize (SHAKE128 bitlen) = 376
-    hashBlockSize  _          = 168
-    hashDigestSize _          = byteLen (Proxy :: Proxy bitlen)
+    hashBlockSize _ = 168
+    hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
     hashInternalContextSize _ = 376
-    hashInternalInit p        = c_sha3_init p 128
-    hashInternalUpdate        = c_sha3_update
-    hashInternalFinalize      = shakeFinalizeOutput (Proxy :: Proxy bitlen)
+    hashInternalInit p = c_sha3_init p 128
+    hashInternalUpdate = c_sha3_update
+    hashInternalFinalize = shakeFinalizeOutput (Proxy :: Proxy bitlen)
 
 instance KnownNat bitlen => HashSHAKE (SHAKE128 bitlen) where
     cshakeInternalFinalize = cshakeFinalizeOutput (Proxy :: Proxy bitlen)
@@ -72,35 +75,37 @@
     deriving (Show, Data)
 
 instance KnownNat bitlen => HashAlgorithm (SHAKE256 bitlen) where
-    type HashBlockSize           (SHAKE256 bitlen) = 136
-    type HashDigestSize          (SHAKE256 bitlen) = Div8 (bitlen + 7)
+    type HashBlockSize (SHAKE256 bitlen) = 136
+    type HashDigestSize (SHAKE256 bitlen) = Div8 (bitlen + 7)
     type HashInternalContextSize (SHAKE256 bitlen) = 344
-    hashBlockSize  _          = 136
-    hashDigestSize _          = byteLen (Proxy :: Proxy bitlen)
+    hashBlockSize _ = 136
+    hashDigestSize _ = byteLen (Proxy :: Proxy bitlen)
     hashInternalContextSize _ = 344
-    hashInternalInit p        = c_sha3_init p 256
-    hashInternalUpdate        = c_sha3_update
-    hashInternalFinalize      = shakeFinalizeOutput (Proxy :: Proxy bitlen)
+    hashInternalInit p = c_sha3_init p 256
+    hashInternalUpdate = c_sha3_update
+    hashInternalFinalize = shakeFinalizeOutput (Proxy :: Proxy bitlen)
 
 instance KnownNat bitlen => HashSHAKE (SHAKE256 bitlen) where
     cshakeInternalFinalize = cshakeFinalizeOutput (Proxy :: Proxy bitlen)
     cshakeOutputLength _ = integralNatVal (Proxy :: Proxy bitlen)
 
-shakeFinalizeOutput :: KnownNat bitlen
-                    => proxy bitlen
-                    -> Ptr (Context a)
-                    -> Ptr (Digest a)
-                    -> IO ()
+shakeFinalizeOutput
+    :: KnownNat bitlen
+    => proxy bitlen
+    -> Ptr (Context a)
+    -> Ptr (Digest a)
+    -> IO ()
 shakeFinalizeOutput d ctx dig = do
     c_sha3_finalize_shake ctx
     c_sha3_output ctx dig (byteLen d)
     shakeTruncate d (castPtr dig)
 
-cshakeFinalizeOutput :: KnownNat bitlen
-                     => proxy bitlen
-                     -> Ptr (Context a)
-                     -> Ptr (Digest a)
-                     -> IO ()
+cshakeFinalizeOutput
+    :: KnownNat bitlen
+    => proxy bitlen
+    -> Ptr (Context a)
+    -> Ptr (Digest a)
+    -> IO ()
 cshakeFinalizeOutput d ctx dig = do
     c_sha3_finalize_cshake ctx
     c_sha3_output ctx dig (byteLen d)
diff --git a/Crypto/Hash/Skein256.hs b/Crypto/Hash/Skein256.hs
--- a/Crypto/Hash/Skein256.hs
+++ b/Crypto/Hash/Skein256.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Skein256
 -- License     : BSD-style
@@ -7,51 +12,45 @@
 --
 -- Module containing the binding functions to work with the
 -- Skein256 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Skein256
-    (  Skein256_224 (..), Skein256_256 (..)
-    ) where
-
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+module Crypto.Hash.Skein256 (
+    Skein256_224 (..),
+    Skein256_256 (..),
+) where
 
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | Skein256 (224 bits) cryptographic hash algorithm
 data Skein256_224 = Skein256_224
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Skein256_224 where
-    type HashBlockSize           Skein256_224 = 32
-    type HashDigestSize          Skein256_224 = 28
+    type HashBlockSize Skein256_224 = 32
+    type HashDigestSize Skein256_224 = 28
     type HashInternalContextSize Skein256_224 = 96
-    hashBlockSize  _          = 32
-    hashDigestSize _          = 28
+    hashBlockSize _ = 32
+    hashDigestSize _ = 28
     hashInternalContextSize _ = 96
-    hashInternalInit p        = c_skein256_init p 224
-    hashInternalUpdate        = c_skein256_update
-    hashInternalFinalize p    = c_skein256_finalize p 224
+    hashInternalInit p = c_skein256_init p 224
+    hashInternalUpdate = c_skein256_update
+    hashInternalFinalize p = c_skein256_finalize p 224
 
 -- | Skein256 (256 bits) cryptographic hash algorithm
 data Skein256_256 = Skein256_256
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Skein256_256 where
-    type HashBlockSize           Skein256_256 = 32
-    type HashDigestSize          Skein256_256 = 32
+    type HashBlockSize Skein256_256 = 32
+    type HashDigestSize Skein256_256 = 32
     type HashInternalContextSize Skein256_256 = 96
-    hashBlockSize  _          = 32
-    hashDigestSize _          = 32
+    hashBlockSize _ = 32
+    hashDigestSize _ = 32
     hashInternalContextSize _ = 96
-    hashInternalInit p        = c_skein256_init p 256
-    hashInternalUpdate        = c_skein256_update
-    hashInternalFinalize p    = c_skein256_finalize p 256
-
+    hashInternalInit p = c_skein256_init p 256
+    hashInternalUpdate = c_skein256_update
+    hashInternalFinalize p = c_skein256_finalize p 256
 
 foreign import ccall unsafe "crypton_skein256_init"
     c_skein256_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/Skein512.hs b/Crypto/Hash/Skein512.hs
--- a/Crypto/Hash/Skein512.hs
+++ b/Crypto/Hash/Skein512.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Skein512
 -- License     : BSD-style
@@ -7,81 +12,77 @@
 --
 -- Module containing the binding functions to work with the
 -- Skein512 cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Skein512
-    (  Skein512_224 (..), Skein512_256 (..), Skein512_384 (..), Skein512_512 (..)
-    ) where
-
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+module Crypto.Hash.Skein512 (
+    Skein512_224 (..),
+    Skein512_256 (..),
+    Skein512_384 (..),
+    Skein512_512 (..),
+) where
 
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | Skein512 (224 bits) cryptographic hash algorithm
 data Skein512_224 = Skein512_224
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Skein512_224 where
-    type HashBlockSize           Skein512_224 = 64
-    type HashDigestSize          Skein512_224 = 28
+    type HashBlockSize Skein512_224 = 64
+    type HashDigestSize Skein512_224 = 28
     type HashInternalContextSize Skein512_224 = 160
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 28
+    hashBlockSize _ = 64
+    hashDigestSize _ = 28
     hashInternalContextSize _ = 160
-    hashInternalInit p        = c_skein512_init p 224
-    hashInternalUpdate        = c_skein512_update
-    hashInternalFinalize p    = c_skein512_finalize p 224
+    hashInternalInit p = c_skein512_init p 224
+    hashInternalUpdate = c_skein512_update
+    hashInternalFinalize p = c_skein512_finalize p 224
 
 -- | Skein512 (256 bits) cryptographic hash algorithm
 data Skein512_256 = Skein512_256
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Skein512_256 where
-    type HashBlockSize           Skein512_256 = 64
-    type HashDigestSize          Skein512_256 = 32
+    type HashBlockSize Skein512_256 = 64
+    type HashDigestSize Skein512_256 = 32
     type HashInternalContextSize Skein512_256 = 160
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 32
+    hashBlockSize _ = 64
+    hashDigestSize _ = 32
     hashInternalContextSize _ = 160
-    hashInternalInit p        = c_skein512_init p 256
-    hashInternalUpdate        = c_skein512_update
-    hashInternalFinalize p    = c_skein512_finalize p 256
+    hashInternalInit p = c_skein512_init p 256
+    hashInternalUpdate = c_skein512_update
+    hashInternalFinalize p = c_skein512_finalize p 256
 
 -- | Skein512 (384 bits) cryptographic hash algorithm
 data Skein512_384 = Skein512_384
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Skein512_384 where
-    type HashBlockSize           Skein512_384 = 64
-    type HashDigestSize          Skein512_384 = 48
+    type HashBlockSize Skein512_384 = 64
+    type HashDigestSize Skein512_384 = 48
     type HashInternalContextSize Skein512_384 = 160
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 48
+    hashBlockSize _ = 64
+    hashDigestSize _ = 48
     hashInternalContextSize _ = 160
-    hashInternalInit p        = c_skein512_init p 384
-    hashInternalUpdate        = c_skein512_update
-    hashInternalFinalize p    = c_skein512_finalize p 384
+    hashInternalInit p = c_skein512_init p 384
+    hashInternalUpdate = c_skein512_update
+    hashInternalFinalize p = c_skein512_finalize p 384
 
 -- | Skein512 (512 bits) cryptographic hash algorithm
 data Skein512_512 = Skein512_512
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Skein512_512 where
-    type HashBlockSize           Skein512_512 = 64
-    type HashDigestSize          Skein512_512 = 64
+    type HashBlockSize Skein512_512 = 64
+    type HashDigestSize Skein512_512 = 64
     type HashInternalContextSize Skein512_512 = 160
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 64
+    hashBlockSize _ = 64
+    hashDigestSize _ = 64
     hashInternalContextSize _ = 160
-    hashInternalInit p        = c_skein512_init p 512
-    hashInternalUpdate        = c_skein512_update
-    hashInternalFinalize p    = c_skein512_finalize p 512
-
+    hashInternalInit p = c_skein512_init p 512
+    hashInternalUpdate = c_skein512_update
+    hashInternalFinalize p = c_skein512_finalize p 512
 
 foreign import ccall unsafe "crypton_skein512_init"
     c_skein512_init :: Ptr (Context a) -> Word32 -> IO ()
diff --git a/Crypto/Hash/Tiger.hs b/Crypto/Hash/Tiger.hs
--- a/Crypto/Hash/Tiger.hs
+++ b/Crypto/Hash/Tiger.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Tiger
 -- License     : BSD-style
@@ -7,35 +12,30 @@
 --
 -- Module containing the binding functions to work with the
 -- Tiger cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Tiger ( Tiger (..) ) where
+module Crypto.Hash.Tiger (Tiger (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | Tiger cryptographic hash algorithm
 data Tiger = Tiger
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Tiger where
-    type HashBlockSize           Tiger = 64
-    type HashDigestSize          Tiger = 24
+    type HashBlockSize Tiger = 64
+    type HashDigestSize Tiger = 24
     type HashInternalContextSize Tiger = 96
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 24
+    hashBlockSize _ = 64
+    hashDigestSize _ = 24
     hashInternalContextSize _ = 96
-    hashInternalInit          = c_tiger_init
-    hashInternalUpdate        = c_tiger_update
-    hashInternalFinalize      = c_tiger_finalize
+    hashInternalInit = c_tiger_init
+    hashInternalUpdate = c_tiger_update
+    hashInternalFinalize = c_tiger_finalize
 
 foreign import ccall unsafe "crypton_tiger_init"
-    c_tiger_init :: Ptr (Context a)-> IO ()
+    c_tiger_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_tiger_update"
     c_tiger_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
diff --git a/Crypto/Hash/Types.hs b/Crypto/Hash/Types.hs
--- a/Crypto/Hash/Types.hs
+++ b/Crypto/Hash/Types.hs
@@ -1,3 +1,10 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE RoleAnnotations #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Types
 -- License     : BSD-style
@@ -6,31 +13,36 @@
 -- Portability : unknown
 --
 -- Crypto hash types definitions
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Types
-    ( HashAlgorithm(..)
-    , HashAlgorithmPrefix(..)
-    , Context(..)
-    , Digest(..)
-    ) where
+module Crypto.Hash.Types (
+    HashAlgorithm (..),
+    HashAlgorithmPrefix (..),
+    Context (..),
+    Digest (..),
+) where
 
-import           Crypto.Internal.Imports
-import           Crypto.Internal.ByteArray (ByteArrayAccess, Bytes)
+import Control.DeepSeq (deepseq)
+import Control.Monad.Primitive (PrimMonad (..))
+import Control.Monad.ST
+import Crypto.Internal.ByteArray (ByteArrayAccess (..), Bytes)
 import qualified Crypto.Internal.ByteArray as B
-import           Control.Monad.ST
-import           Data.Char (digitToInt, isHexDigit)
-import           Foreign.Ptr (Ptr)
-import           Basement.Block (Block, unsafeFreeze)
-import           Basement.Block.Mutable (MutableBlock, new, unsafeWrite)
-import           Basement.NormalForm (deepseq)
-import           Basement.Types.OffsetSize (CountOf(..), Offset(..))
-import           GHC.TypeLits (Nat)
-import           Data.Data (Data)
+import Crypto.Internal.Imports
+import Data.Base16.Types (extractBase16)
+import Data.ByteString (ByteString)
+import Data.ByteString.Base16 (encodeBase16)
+import Data.Char (digitToInt, isHexDigit)
+import Data.Data (Data)
+import Data.Primitive.ByteArray (
+    ByteArray,
+    MutableByteArray,
+    newPinnedByteArray,
+    sizeofByteArray,
+    unsafeFreezeByteArray,
+    withByteArrayContents,
+    writeByteArray,
+ )
+import qualified Data.Text as Text
+import Foreign.Ptr (Ptr, castPtr)
+import GHC.TypeLits (Nat)
 
 -- | Class representing hashing algorithms.
 --
@@ -40,23 +52,30 @@
 class HashAlgorithm a where
     -- | Associated type for the block size of the hash algorithm
     type HashBlockSize a :: Nat
+
     -- | Associated type for the digest size of the hash algorithm
     type HashDigestSize a :: Nat
+
     -- | Associated type for the internal context size of the hash algorithm
     type HashInternalContextSize a :: Nat
 
     -- | Get the block size of a hash algorithm
-    hashBlockSize           :: a -> Int
+    hashBlockSize :: a -> Int
+
     -- | Get the digest size of a hash algorithm
-    hashDigestSize          :: a -> Int
+    hashDigestSize :: a -> Int
+
     -- | Get the size of the context used for a hash algorithm
     hashInternalContextSize :: a -> Int
-    --hashAlgorithmFromProxy  :: Proxy a -> a
 
+    -- hashAlgorithmFromProxy  :: Proxy a -> a
+
     -- | Initialize a context pointer to the initial state of a hash algorithm
-    hashInternalInit     :: Ptr (Context a) -> IO ()
+    hashInternalInit :: Ptr (Context a) -> IO ()
+
     -- | Update the context with some raw data
-    hashInternalUpdate   :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
+    hashInternalUpdate :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
+
     -- | Finalize the context and set the digest raw memory to the right value
     hashInternalFinalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
 
@@ -65,11 +84,13 @@
     -- | Update the context with the first N bytes of a buffer and finalize this
     -- context.  The code path executed is independent from N and depends only
     -- on the complete buffer length.
-    hashInternalFinalizePrefix :: Ptr (Context a)
-                               -> Ptr Word8 -> Word32
-                               -> Word32
-                               -> Ptr (Digest a)
-                               -> IO ()
+    hashInternalFinalizePrefix
+        :: Ptr (Context a)
+        -> Ptr Word8
+        -> Word32
+        -> Word32
+        -> Ptr (Digest a)
+        -> IO ()
 
 {-
 hashContextGetAlgorithm :: HashAlgorithm a => Context a -> a
@@ -83,41 +104,54 @@
 -- and change in future versions.  The bytearray should not be used as input to
 -- cryptographic algorithms.
 newtype Context a = Context Bytes
-    deriving (ByteArrayAccess,NFData)
+    deriving (ByteArrayAccess, NFData)
 
 -- | Represent a digest for a given hash algorithm.
 --
 -- This type is an instance of 'ByteArrayAccess' from package
--- <https://hackage.haskell.org/package/memory memory>.
+-- <https://hackage.haskell.org/package/ram ram>.
 -- Module "Data.ByteArray" provides many primitives to work with those values
 -- including conversion to other types.
 --
 -- Creating a digest from a bytearray is also possible with function
 -- 'Crypto.Hash.digestFromByteString'.
-newtype Digest a = Digest (Block Word8)
-    deriving (Eq,Ord,ByteArrayAccess, Data)
+newtype Digest a = Digest ByteArray
+    deriving (Eq, Ord, Data)
 
+type role Digest nominal
+
 instance NFData (Digest a) where
     rnf (Digest u) = u `deepseq` ()
 
+instance ByteArrayAccess (Digest a) where
+    length (Digest ba) = sizeofByteArray ba
+    withByteArray (Digest ba) f = withByteArrayContents ba (f . castPtr)
+
 instance Show (Digest a) where
-    show (Digest bs) = map (toEnum . fromIntegral)
-                     $ B.unpack (B.convertToBase B.Base16 bs :: Bytes)
+    show d =
+        Text.unpack (extractBase16 $ encodeBase16 (B.convert d :: ByteString))
 
 instance HashAlgorithm a => Read (Digest a) where
-    readsPrec _ str = runST $ do mut <- new (CountOf len)
-                                 loop mut len str
+    readsPrec _ str = runST $ do
+        mut <- newPinnedByteArray len
+        loop len mut len str
       where
         len = hashDigestSize (undefined :: a)
 
-        loop :: MutableBlock Word8 s -> Int -> String -> ST s [(Digest a, String)]
-        loop mut 0   cs          = (\b -> [(Digest b, cs)]) <$> unsafeFreeze mut
-        loop _   _   []          = return []
-        loop _   _   [_]         = return []
-        loop mut n   (c:(d:ds))
-            | not (isHexDigit c) = return []
-            | not (isHexDigit d) = return []
-            | otherwise          = do
-                let w8 = fromIntegral $ digitToInt c * 16 + digitToInt d
-                unsafeWrite mut (Offset $ len - n) w8
-                loop mut (n - 1) ds
+loop
+    :: Int
+    -> MutableByteArray (PrimState (ST s))
+    -> Int
+    -> String
+    -> ST s [(Digest a, String)]
+loop _ mut 0 cs = (\b -> [(Digest b, cs)]) <$> unsafeFreezeByteArray mut
+loop _ _ _ [] = return []
+loop _ _ _ [_] = return []
+loop len mut n (c : (d : ds))
+    | not (isHexDigit c) = return []
+    | not (isHexDigit d) = return []
+    | otherwise = do
+        let w8 :: Word8
+            w8 = fromIntegral $ digitToInt c * 16 + digitToInt d
+        writeByteArray mut (len - n) w8
+        loop len mut (n - 1) ds
diff --git a/Crypto/Hash/Whirlpool.hs b/Crypto/Hash/Whirlpool.hs
--- a/Crypto/Hash/Whirlpool.hs
+++ b/Crypto/Hash/Whirlpool.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE TypeFamilies #-}
+
 -- |
 -- Module      : Crypto.Hash.Whirlpool
 -- License     : BSD-style
@@ -7,35 +12,30 @@
 --
 -- Module containing the binding functions to work with the
 -- Whirlpool cryptographic hash.
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-module Crypto.Hash.Whirlpool ( Whirlpool (..) ) where
+module Crypto.Hash.Whirlpool (Whirlpool (..)) where
 
-import           Crypto.Hash.Types
-import           Foreign.Ptr (Ptr)
-import           Data.Data
-import           Data.Word (Word8, Word32)
+import Crypto.Hash.Types
+import Data.Data
+import Data.Word (Word32, Word8)
+import Foreign.Ptr (Ptr)
 
 -- | Whirlpool cryptographic hash algorithm
 data Whirlpool = Whirlpool
-    deriving (Show,Data)
+    deriving (Show, Data)
 
 instance HashAlgorithm Whirlpool where
-    type HashBlockSize           Whirlpool = 64
-    type HashDigestSize          Whirlpool = 64
+    type HashBlockSize Whirlpool = 64
+    type HashDigestSize Whirlpool = 64
     type HashInternalContextSize Whirlpool = 168
-    hashBlockSize  _          = 64
-    hashDigestSize _          = 64
+    hashBlockSize _ = 64
+    hashDigestSize _ = 64
     hashInternalContextSize _ = 168
-    hashInternalInit          = c_whirlpool_init
-    hashInternalUpdate        = c_whirlpool_update
-    hashInternalFinalize      = c_whirlpool_finalize
+    hashInternalInit = c_whirlpool_init
+    hashInternalUpdate = c_whirlpool_update
+    hashInternalFinalize = c_whirlpool_finalize
 
 foreign import ccall unsafe "crypton_whirlpool_init"
-    c_whirlpool_init :: Ptr (Context a)-> IO ()
+    c_whirlpool_init :: Ptr (Context a) -> IO ()
 
 foreign import ccall "crypton_whirlpool_update"
     c_whirlpool_update :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
diff --git a/Crypto/Internal/Builder.hs b/Crypto/Internal/Builder.hs
--- a/Crypto/Internal/Builder.hs
+++ b/Crypto/Internal/Builder.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.Internal.Builder
 -- License     : BSD-style
@@ -8,31 +10,30 @@
 -- Delaying and merging ByteArray allocations.  This is similar to module
 -- "Data.ByteArray.Pack" except the total length is computed automatically based
 -- on what is appended.
---
-{-# LANGUAGE BangPatterns #-}
-module Crypto.Internal.Builder
-    ( Builder
-    , buildAndFreeze
-    , builderLength
-    , byte
-    , bytes
-    , zero
-    ) where
+module Crypto.Internal.Builder (
+    Builder,
+    buildAndFreeze,
+    builderLength,
+    byte,
+    bytes,
+    zero,
+) where
 
-import           Data.ByteArray (ByteArray, ByteArrayAccess)
+import Data.ByteArray (ByteArray, ByteArrayAccess)
 import qualified Data.ByteArray as B
-import           Data.Memory.PtrMethods (memSet)
+import Data.Memory.PtrMethods (memSet)
 
-import           Foreign.Ptr (Ptr, plusPtr)
-import           Foreign.Storable (poke)
+import Foreign.Ptr (Ptr, plusPtr)
+import Foreign.Storable (poke)
 
-import           Crypto.Internal.Imports hiding (empty)
+import Crypto.Internal.Imports hiding (empty)
 
-data Builder =  Builder !Int (Ptr Word8 -> IO ())  -- size and initializer
+data Builder = Builder !Int (Ptr Word8 -> IO ()) -- size and initializer
 
 instance Semigroup Builder where
     (Builder s1 f1) <> (Builder s2 f2) = Builder (s1 + s2) f
-      where f p = f1 p >> f2 (p `plusPtr` s1)
+      where
+        f p = f1 p >> f2 (p `plusPtr` s1)
 
 builderLength :: Builder -> Int
 builderLength (Builder s _) = s
diff --git a/Crypto/Internal/ByteArray.hs b/Crypto/Internal/ByteArray.hs
--- a/Crypto/Internal/ByteArray.hs
+++ b/Crypto/Internal/ByteArray.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE BangPatterns #-}
+{-# OPTIONS_HADDOCK hide #-}
+
 -- |
 -- Module      : Crypto.Internal.ByteArray
 -- License     : BSD-style
@@ -6,34 +9,48 @@
 -- Portability : Good
 --
 -- Simple and efficient byte array types
---
-{-# LANGUAGE BangPatterns #-}
-{-# OPTIONS_HADDOCK hide #-}
-module Crypto.Internal.ByteArray
-    ( module Data.ByteArray
-    , module Data.ByteArray.Mapping
-    , module Data.ByteArray.Encoding
-    , constAllZero
-    ) where
+module Crypto.Internal.ByteArray (
+    module Data.ByteArray,
+    module Data.ByteArray.Mapping,
+    module Data.ByteArray.Encoding,
+    constAllZero,
+    allocAndFreezePrimIO,
+    allocAndFreezePrim,
+) where
 
 import Data.ByteArray
-import Data.ByteArray.Mapping
 import Data.ByteArray.Encoding
+import Data.ByteArray.Mapping
 
 import Data.Bits ((.|.))
+import qualified Data.Primitive.ByteArray as Prim
 import Data.Word (Word8)
-import Foreign.Ptr (Ptr)
+import Foreign.Ptr (Ptr, castPtr)
 import Foreign.Storable (peekByteOff)
 
 import Crypto.Internal.Compat (unsafeDoIO)
 
+-- | Allocate a pinned 'Prim.ByteArray' of the given size, populate it via a
+-- 'Ptr', then freeze and return it.  The pointer must not be retained after
+-- the action returns.
+allocAndFreezePrimIO :: Int -> (Ptr p -> IO ()) -> IO Prim.ByteArray
+allocAndFreezePrimIO n f = do
+    mba <- Prim.newPinnedByteArray n
+    f (castPtr (Prim.mutableByteArrayContents mba))
+    Prim.unsafeFreezeByteArray mba
+
+-- | The allocation is strictly local,
+-- the computation is deterministic, and no IO effects escape.
+allocAndFreezePrim :: Int -> (Ptr p -> IO ()) -> Prim.ByteArray
+allocAndFreezePrim n = unsafeDoIO . allocAndFreezePrimIO n
+
 constAllZero :: ByteArrayAccess ba => ba -> Bool
 constAllZero b = unsafeDoIO $ withByteArray b $ \p -> loop p 0 0
   where
     loop :: Ptr b -> Int -> Word8 -> IO Bool
     loop p i !acc
-        | i == len  = return $! acc == 0
+        | i == len = return $! acc == 0
         | otherwise = do
             e <- peekByteOff p i
-            loop p (i+1) (acc .|. e)
+            loop p (i + 1) (acc .|. e)
     len = Data.ByteArray.length b
diff --git a/Crypto/Internal/Compat.hs b/Crypto/Internal/Compat.hs
--- a/Crypto/Internal/Compat.hs
+++ b/Crypto/Internal/Compat.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
 -- |
 -- Module      : Crypto.Internal.Compat
 -- License     : BSD-style
@@ -7,17 +9,15 @@
 --
 -- This module tries to keep all the difference between versions of base
 -- or other needed packages, so that modules don't need to use CPP.
---
-{-# LANGUAGE CPP #-}
-module Crypto.Internal.Compat
-    ( unsafeDoIO
-    , popCount
-    , byteSwap64
-    ) where
+module Crypto.Internal.Compat (
+    unsafeDoIO,
+    popCount,
+    byteSwap64,
+) where
 
-import System.IO.Unsafe
-import Data.Word
 import Data.Bits
+import Data.Word
+import System.IO.Unsafe
 
 -- | Perform io for hashes that do allocation and FFI.
 -- 'unsafeDupablePerformIO' is used when possible as the
diff --git a/Crypto/Internal/CompatPrim.hs b/Crypto/Internal/CompatPrim.hs
--- a/Crypto/Internal/CompatPrim.hs
+++ b/Crypto/Internal/CompatPrim.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE UnboxedTuples #-}
+
 -- |
 -- Module      : Crypto.Internal.CompatPrim
 -- License     : BSD-style
@@ -10,27 +15,22 @@
 --
 -- Note that MagicHash and CPP conflicts in places, making it "more interesting"
 -- to write compat code for primitives.
---
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE MagicHash #-}
-{-# LANGUAGE UnboxedTuples #-}
-module Crypto.Internal.CompatPrim
-    ( be32Prim
-    , le32Prim
-    , byteswap32Prim
-    , booleanPrim
-    , convert4To32
-    ) where
+module Crypto.Internal.CompatPrim (
+    be32Prim,
+    le32Prim,
+    byteswap32Prim,
+    booleanPrim,
+    convert4To32,
+) where
 
 #if !defined(ARCH_IS_LITTLE_ENDIAN) && !defined(ARCH_IS_BIG_ENDIAN)
 import Data.Memory.Endian (getSystemEndianness, Endianness(..))
 #endif
 
 #if __GLASGOW_HASKELL__ >= 902
-import GHC.Prim
+import GHC.Exts
 #else
-import GHC.Prim hiding (Word32#)
+import GHC.Exts hiding (Word32#)
 type Word32# = Word#
 #endif
 
@@ -68,8 +68,12 @@
 #endif
 
 -- | Combine 4 word8 [a,b,c,d] to a word32 representing [a,b,c,d]
-convert4To32 :: Word# -> Word# -> Word# -> Word#
-             -> Word#
+convert4To32
+    :: Word#
+    -> Word#
+    -> Word#
+    -> Word#
+    -> Word#
 convert4To32 a b c d = or# (or# c1 c2) (or# c3 c4)
   where
 #ifdef ARCH_IS_LITTLE_ENDIAN
diff --git a/Crypto/Internal/DeepSeq.hs b/Crypto/Internal/DeepSeq.hs
--- a/Crypto/Internal/DeepSeq.hs
+++ b/Crypto/Internal/DeepSeq.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
 -- |
 -- Module      : Crypto.Internal.DeepSeq
 -- License     : BSD-style
@@ -8,11 +10,9 @@
 -- Simple abstraction module to allow compilation without deepseq
 -- by defining our own NFData class if not compiling with deepseq
 -- support.
---
-{-# LANGUAGE CPP #-}
-module Crypto.Internal.DeepSeq
-    ( NFData(..)
-    ) where
+module Crypto.Internal.DeepSeq (
+    NFData (..),
+) where
 
 #ifdef WITH_DEEPSEQ_SUPPORT
 import Control.DeepSeq
diff --git a/Crypto/Internal/Endian.hs b/Crypto/Internal/Endian.hs
new file mode 100644
--- /dev/null
+++ b/Crypto/Internal/Endian.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE CPP #-}
+
+-- |
+-- Module      : Crypto.Internal.Endian
+-- License     : BSD-style
+-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
+-- Stability   : stable
+-- Portability : good
+module Crypto.Internal.Endian (
+    fromBE64,
+    toBE64,
+    fromLE64,
+    toLE64,
+) where
+
+import Crypto.Internal.Compat (byteSwap64)
+import Data.Word (Word64)
+
+#ifdef ARCH_IS_LITTLE_ENDIAN
+fromLE64 :: Word64 -> Word64
+fromLE64 = id
+
+toLE64 :: Word64 -> Word64
+toLE64 = id
+
+fromBE64 :: Word64 -> Word64
+fromBE64 = byteSwap64
+
+toBE64 :: Word64 -> Word64
+toBE64 = byteSwap64
+#else
+fromLE64 :: Word64 -> Word64
+fromLE64 = byteSwap64
+
+toLE64 :: Word64 -> Word64
+toLE64 = byteSwap64
+
+fromBE64 :: Word64 -> Word64
+fromBE64 = id
+
+toBE64 :: Word64 -> Word64
+toBE64 = id
+#endif
diff --git a/Crypto/Internal/Imports.hs b/Crypto/Internal/Imports.hs
--- a/Crypto/Internal/Imports.hs
+++ b/Crypto/Internal/Imports.hs
@@ -1,20 +1,20 @@
+{-# LANGUAGE CPP #-}
+
 -- |
 -- Module      : Crypto.Internal.Imports
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : unknown
---
-{-# LANGUAGE CPP #-}
-module Crypto.Internal.Imports
-    ( module X
-    ) where
+module Crypto.Internal.Imports (
+    module X,
+) where
 
-import Data.Word               as X
+import Data.Word as X
 #if !(MIN_VERSION_base(4,11,0))
 import Data.Semigroup          as X (Semigroup(..))
 #endif
-import Control.Applicative     as X
-import Control.Monad           as X (forM, forM_, void)
-import Control.Arrow           as X (first, second)
+import Control.Applicative as X
+import Control.Arrow as X (first, second)
+import Control.Monad as X (forM, forM_, void)
 import Crypto.Internal.DeepSeq as X
diff --git a/Crypto/Internal/WordArray.hs b/Crypto/Internal/WordArray.hs
--- a/Crypto/Internal/WordArray.hs
+++ b/Crypto/Internal/WordArray.hs
@@ -1,3 +1,7 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE UnboxedTuples #-}
+
 -- |
 -- Module      : Crypto.Internal.WordArray
 -- License     : BSD-style
@@ -9,37 +13,32 @@
 -- with limited safety for internal use.
 --
 -- The array produced should never be exposed to the user directly.
---
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE MagicHash #-}
-{-# LANGUAGE UnboxedTuples #-}
-module Crypto.Internal.WordArray
-    ( Array8
-    , Array32
-    , Array64
-    , MutableArray32
-    , array8
-    , array32
-    , array32FromAddrBE
-    , allocArray32AndFreeze
-    , mutableArray32
-    , array64
-    , arrayRead8
-    , arrayRead32
-    , arrayRead64
-    , mutableArrayRead32
-    , mutableArrayWrite32
-    , mutableArrayWriteXor32
-    , mutableArray32FromAddrBE
-    , mutableArray32Freeze
-    ) where
+module Crypto.Internal.WordArray (
+    Array8,
+    Array32,
+    Array64,
+    MutableArray32,
+    array8,
+    array32,
+    array32FromAddrBE,
+    allocArray32AndFreeze,
+    mutableArray32,
+    array64,
+    arrayRead8,
+    arrayRead32,
+    arrayRead64,
+    mutableArrayRead32,
+    mutableArrayWrite32,
+    mutableArrayWriteXor32,
+    mutableArray32FromAddrBE,
+    mutableArray32Freeze,
+) where
 
-import Data.Word
-import Data.Bits (xor)
 import Crypto.Internal.Compat
 import Crypto.Internal.CompatPrim
-import GHC.Prim
-import GHC.Types
+import Data.Bits (xor)
+import Data.Word
+import GHC.Base
 import GHC.Word
 
 -- | Array of Word8
@@ -81,15 +80,15 @@
     case newAlignedPinnedByteArray# (n *# 8#) 8# s of
         (# s', mbarr #) -> loop 0# s' mbarr l
   where
-        loop _ st mb [] = freezeArray mb st
-        loop i st mb ((W64# x):xs)
-            | booleanPrim (i ==# n) = freezeArray mb st
-            | otherwise =
-                let !st' = writeWord64Array# mb i x st
-                 in loop (i +# 1#) st' mb xs
-        freezeArray mb st =
-            case unsafeFreezeByteArray# mb st of
-                (# st', b #) -> (# st', Array64 b #)
+    loop _ st mb [] = freezeArray mb st
+    loop i st mb ((W64# x) : xs)
+        | booleanPrim (i ==# n) = freezeArray mb st
+        | otherwise =
+            let !st' = writeWord64Array# mb i x st
+             in loop (i +# 1#) st' mb xs
+    freezeArray mb st =
+        case unsafeFreezeByteArray# mb st of
+            (# st', b #) -> (# st', Array64 b #)
 {-# NOINLINE array64 #-}
 
 -- | Create a Mutable Array of Word32 of specific size from a list of Word32
@@ -98,12 +97,12 @@
     case newAlignedPinnedByteArray# (n *# 4#) 4# s of
         (# s', mbarr #) -> loop 0# s' mbarr l
   where
-        loop _ st mb [] = (# st, MutableArray32 mb #)
-        loop i st mb ((W32# x):xs)
-            | booleanPrim (i ==# n) = (# st, MutableArray32 mb #)
-            | otherwise =
-                let !st' = writeWord32Array# mb i x st
-                 in loop (i +# 1#) st' mb xs
+    loop _ st mb [] = (# st, MutableArray32 mb #)
+    loop i st mb ((W32# x) : xs)
+        | booleanPrim (i ==# n) = (# st, MutableArray32 mb #)
+        | otherwise =
+            let !st' = writeWord32Array# mb i x st
+             in loop (i +# 1#) st' mb xs
 
 -- | Create a Mutable Array of BE Word32 aliasing an Addr
 mutableArray32FromAddrBE :: Int -> Addr# -> IO MutableArray32
@@ -111,11 +110,11 @@
     case newAlignedPinnedByteArray# (n *# 4#) 4# s of
         (# s', mbarr #) -> loop 0# s' mbarr
   where
-        loop i st mb
-            | booleanPrim (i ==# n) = (# st, MutableArray32 mb #)
-            | otherwise             =
-                let !st' = writeWord32Array# mb i (be32Prim (indexWord32OffAddr# a i)) st
-                 in loop (i +# 1#) st' mb
+    loop i st mb
+        | booleanPrim (i ==# n) = (# st, MutableArray32 mb #)
+        | otherwise =
+            let !st' = writeWord32Array# mb i (be32Prim (indexWord32OffAddr# a i)) st
+             in loop (i +# 1#) st' mb
 
 -- | freeze a Mutable Array of Word32 into a immutable Array of Word32
 mutableArray32Freeze :: MutableArray32 -> IO Array32
diff --git a/Crypto/Internal/Words.hs b/Crypto/Internal/Words.hs
--- a/Crypto/Internal/Words.hs
+++ b/Crypto/Internal/Words.hs
@@ -6,16 +6,15 @@
 -- Portability : unknown
 --
 -- Extra Word size
---
-module Crypto.Internal.Words
-    ( Word128(..)
-    , w64to32
-    , w32to64
-    ) where
+module Crypto.Internal.Words (
+    Word128 (..),
+    w64to32,
+    w32to64,
+) where
 
-import Data.Word
 import Data.Bits
 import Data.Memory.ExtendedWords
+import Data.Word
 
 -- | Split a 'Word64' into the highest and lowest 'Word32'
 w64to32 :: Word64 -> (Word32, Word32)
diff --git a/Crypto/KDF/Argon2.hs b/Crypto/KDF/Argon2.hs
--- a/Crypto/KDF/Argon2.hs
+++ b/Crypto/KDF/Argon2.hs
@@ -11,47 +11,49 @@
 --
 -- File started from Argon2.hs, from Oliver Charles
 -- at https://github.com/ocharles/argon2
---
-module Crypto.KDF.Argon2
-    (
-      Options(..)
-    , TimeCost
-    , MemoryCost
-    , Parallelism
-    , Variant(..)
-    , Version(..)
-    , defaultOptions
+module Crypto.KDF.Argon2 (
+    Options (..),
+    TimeCost,
+    MemoryCost,
+    Parallelism,
+    Variant (..),
+    Version (..),
+    defaultOptions,
+
     -- * Hashing function
-    , hash
-    ) where
+    hash,
+) where
 
-import           Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
+import Control.Monad (when)
+import Crypto.Error
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Error
-import           Control.Monad (when)
-import           Data.Word
-import           Foreign.C
-import           Foreign.Ptr
+import Data.Word
+import Foreign.C
+import Foreign.Ptr
 
 -- | Which variant of Argon2 to use. You should choose the variant that is most
 -- applicable to your intention to hash inputs.
-data Variant =
-      Argon2d  -- ^ Argon2d is faster than Argon2i and uses data-depending memory access,
-               -- which makes it suitable for cryptocurrencies and applications with no
-               -- threats from side-channel timing attacks.
-    | Argon2i  -- ^ Argon2i uses data-independent memory access, which is preferred
-               -- for password hashing and password-based key derivation. Argon2i
-               -- is slower as it makes more passes over the memory to protect from
-               -- tradeoff attacks.
-    | Argon2id -- ^ Argon2id is a hybrid of Argon2i and Argon2d, using a combination
-               -- of data-depending and data-independent memory accesses, which gives
-               -- some of Argon2i's resistance to side-channel cache timing attacks
-               -- and much of Argon2d's resistance to GPU cracking attacks
-    deriving (Eq,Ord,Read,Show,Enum,Bounded)
+data Variant
+    = -- | Argon2d is faster than Argon2i and uses data-depending memory access,
+      -- which makes it suitable for cryptocurrencies and applications with no
+      -- threats from side-channel timing attacks.
+      Argon2d
+    | -- | Argon2i uses data-independent memory access, which is preferred
+      -- for password hashing and password-based key derivation. Argon2i
+      -- is slower as it makes more passes over the memory to protect from
+      -- tradeoff attacks.
+      Argon2i
+    | -- | Argon2id is a hybrid of Argon2i and Argon2d, using a combination
+      -- of data-depending and data-independent memory accesses, which gives
+      -- some of Argon2i's resistance to side-channel cache timing attacks
+      -- and much of Argon2d's resistance to GPU cracking attacks
+      Argon2id
+    deriving (Eq, Ord, Read, Show, Enum, Bounded)
 
 -- | Which version of Argon2 to use
 data Version = Version10 | Version13
-    deriving (Eq,Ord,Read,Show,Enum,Bounded)
+    deriving (Eq, Ord, Read, Show, Enum, Bounded)
 
 -- | The time cost, which defines the amount of computation realized and therefore the execution time, given in number of iterations.
 --
@@ -71,13 +73,15 @@
 -- | Parameters that can be adjusted to change the runtime performance of the
 -- hashing.
 data Options = Options
-    { iterations  :: !TimeCost
-    , memory      :: !MemoryCost
+    { iterations :: !TimeCost
+    , memory :: !MemoryCost
     , parallelism :: !Parallelism
-    , variant     :: !Variant     -- ^ Which variant of Argon2 to use.
-    , version     :: !Version     -- ^ Which version of Argon2 to use.
+    , variant :: !Variant
+    -- ^ Which variant of Argon2 to use.
+    , version :: !Version
+    -- ^ Which version of Argon2 to use.
     }
-    deriving (Eq,Ord,Read,Show)
+    deriving (Eq, Ord, Read, Show)
 
 saltMinLength :: Int
 saltMinLength = 8
@@ -92,37 +96,40 @@
 
 defaultOptions :: Options
 defaultOptions =
-    Options { iterations  = 1
-            , memory      = 2 ^ (17 :: Int)
-            , parallelism = 4
-            , variant     = Argon2i
-            , version     = Version13
-            }
+    Options
+        { iterations = 1
+        , memory = 2 ^ (17 :: Int)
+        , parallelism = 4
+        , variant = Argon2i
+        , version = Version13
+        }
 
-hash :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out)
-     => Options
-     -> password
-     -> salt
-     -> Int
-     -> CryptoFailable out
+hash
+    :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out)
+    => Options
+    -> password
+    -> salt
+    -> Int
+    -> CryptoFailable out
 hash options password salt outLen
-    | saltLen < saltMinLength  = CryptoFailed CryptoError_SaltTooSmall
+    | saltLen < saltMinLength = CryptoFailed CryptoError_SaltTooSmall
     | outLen < outputMinLength = CryptoFailed CryptoError_OutputLengthTooSmall
     | outLen > outputMaxLength = CryptoFailed CryptoError_OutputLengthTooBig
-    | otherwise                = CryptoPassed $ B.allocAndFreeze outLen $ \out -> do
+    | otherwise = CryptoPassed $ B.allocAndFreeze outLen $ \out -> do
         res <- B.withByteArray password $ \pPass ->
-               B.withByteArray salt     $ \pSalt ->
-                    argon2_hash (iterations options)
-                                (memory options)
-                                (parallelism options)
-                                pPass
-                                (csizeOfInt passwordLen)
-                                pSalt
-                                (csizeOfInt saltLen)
-                                out
-                                (csizeOfInt outLen)
-                                (cOfVariant $ variant options)
-                                (cOfVersion $ version options)
+            B.withByteArray salt $ \pSalt ->
+                argon2_hash
+                    (iterations options)
+                    (memory options)
+                    (parallelism options)
+                    pPass
+                    (csizeOfInt passwordLen)
+                    pSalt
+                    (csizeOfInt saltLen)
+                    out
+                    (csizeOfInt outLen)
+                    (cOfVariant $ variant options)
+                    (cOfVersion $ version options)
         when (res /= 0) $ error "argon2: hash: internal error"
   where
     saltLen = B.length salt
@@ -140,18 +147,24 @@
 cOfVersion Version13 = 0x13
 
 cOfVariant :: Variant -> CVariant
-cOfVariant Argon2d  = 0
-cOfVariant Argon2i  = 1
+cOfVariant Argon2d = 0
+cOfVariant Argon2i = 1
 cOfVariant Argon2id = 2
 
 csizeOfInt :: Int -> CSize
 csizeOfInt = fromIntegral
 
 foreign import ccall unsafe "crypton_argon2_hash"
-    argon2_hash :: Word32 -> Word32 -> Word32
-                -> Ptr Pass -> CSize
-                -> Ptr Salt -> CSize
-                -> Ptr HashOut -> CSize
-                -> CVariant
-                -> CVersion
-                -> IO CInt
+    argon2_hash
+        :: Word32
+        -> Word32
+        -> Word32
+        -> Ptr Pass
+        -> CSize
+        -> Ptr Salt
+        -> CSize
+        -> Ptr HashOut
+        -> CSize
+        -> CVariant
+        -> CVersion
+        -> IO CInt
diff --git a/Crypto/KDF/BCrypt.hs b/Crypto/KDF/BCrypt.hs
--- a/Crypto/KDF/BCrypt.hs
+++ b/Crypto/KDF/BCrypt.hs
@@ -1,4 +1,3 @@
-
 -- | Password encoding and validation using bcrypt.
 --
 -- Example usage:
@@ -43,27 +42,33 @@
 -- depending on your hardware. Choose the highest value you can without having
 -- an unacceptable impact on your users. The cost parameter can also be varied
 -- depending on the account, since it is unique to an individual hash.
-
-module Crypto.KDF.BCrypt
-    ( hashPassword
-    , validatePassword
-    , validatePasswordEither
-    , bcrypt
-    )
+module Crypto.KDF.BCrypt (
+    hashPassword,
+    validatePassword,
+    validatePasswordEither,
+    bcrypt,
+)
 where
 
-import           Control.Monad                    (forM_, unless, when)
-import           Crypto.Cipher.Blowfish.Primitive (Context, createKeySchedule,
-                                                   encrypt, expandKey,
-                                                   expandKeyWithSalt,
-                                                   freezeKeySchedule)
-import           Crypto.Internal.Compat
-import           Crypto.Random                    (MonadRandom, getRandomBytes)
-import           Data.ByteArray                   (ByteArray, ByteArrayAccess,
-                                                   Bytes)
-import qualified Data.ByteArray                   as B
-import           Data.ByteArray.Encoding
-import           Data.Char
+import Control.Monad (forM_, unless, when)
+import Crypto.Cipher.Blowfish.Primitive (
+    Context,
+    createKeySchedule,
+    encrypt,
+    expandKey,
+    expandKeyWithSalt,
+    freezeKeySchedule,
+ )
+import Crypto.Internal.Compat
+import Crypto.Random (MonadRandom, getRandomBytes)
+import Data.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    Bytes,
+ )
+import qualified Data.ByteArray as B
+import Data.ByteArray.Encoding
+import Data.Char
 
 data BCryptHash = BCH Char Int Bytes Bytes
 
@@ -73,14 +78,15 @@
 --
 -- Each increment of the cost approximately doubles the time taken.
 -- The 16 bytes of random salt will be generated internally.
-hashPassword :: (MonadRandom m, ByteArray password, ByteArray hash)
-             => Int
-             -- ^ The cost parameter. Should be between 4 and 31 (inclusive).
-             -- Values which lie outside this range will be adjusted accordingly.
-             -> password
-             -- ^ The password. Should be the UTF-8 encoded bytes of the password text.
-             -> m hash
-             -- ^ The bcrypt hash in standard format.
+hashPassword
+    :: (MonadRandom m, ByteArray password, ByteArray hash)
+    => Int
+    -- ^ The cost parameter. Should be between 4 and 31 (inclusive).
+    -- Values which lie outside this range will be adjusted accordingly.
+    -> password
+    -- ^ The password. Should be the UTF-8 encoded bytes of the password text.
+    -> m hash
+    -- ^ The bcrypt hash in standard format.
 hashPassword cost password = do
     salt <- getRandomBytes 16
     return $ bcrypt cost (salt :: Bytes) password
@@ -88,54 +94,63 @@
 -- | Create a bcrypt hash for a password with a provided cost value and salt.
 --
 -- Cost value under 4 will be automatically adjusted back to 10 for safety reason.
-bcrypt :: (ByteArray salt, ByteArray password, ByteArray output)
-       => Int
-       -- ^ The cost parameter. Should be between 4 and 31 (inclusive).
-       -- Values which lie outside this range will be adjusted accordingly.
-       -> salt
-       -- ^ The salt. Must be 16 bytes in length or an error will be raised.
-       -> password
-       -- ^ The password. Should be the UTF-8 encoded bytes of the password text.
-       -> output
-       -- ^ The bcrypt hash in standard format.
+bcrypt
+    :: (ByteArray salt, ByteArray password, ByteArray output)
+    => Int
+    -- ^ The cost parameter. Should be between 4 and 31 (inclusive).
+    -- Values which lie outside this range will be adjusted accordingly.
+    -> salt
+    -- ^ The salt. Must be 16 bytes in length or an error will be raised.
+    -> password
+    -- ^ The password. Should be the UTF-8 encoded bytes of the password text.
+    -> output
+    -- ^ The bcrypt hash in standard format.
 bcrypt cost salt password = B.concat [header, B.snoc costBytes dollar, b64 salt, b64 hash]
   where
-    hash   = rawHash 'b' realCost salt password
+    hash = rawHash 'b' realCost salt password
     header = B.pack [dollar, fromIntegral (ord '2'), fromIntegral (ord 'b'), dollar]
     dollar = fromIntegral (ord '$')
-    zero   = fromIntegral (ord '0')
-    costBytes  = B.pack [zero + fromIntegral (realCost `div` 10), zero + fromIntegral (realCost `mod` 10)]
+    zero = fromIntegral (ord '0')
+    costBytes =
+        B.pack
+            [ zero + fromIntegral (realCost `div` 10)
+            , zero + fromIntegral (realCost `mod` 10)
+            ]
     realCost
-        | cost < 4  = 10 -- 4 is virtually pointless so go for 10
+        | cost < 4 = 10 -- 4 is virtually pointless so go for 10
         | cost > 31 = 31
         | otherwise = cost
 
-    b64 :: (ByteArray ba) => ba -> ba
+    b64 :: ByteArray ba => ba -> ba
     b64 = convertToBase Base64OpenBSD
 
 -- | Check a password against a stored bcrypt hash when authenticating a user.
 --
 -- Returns @False@ if the password doesn't match the hash, or if the hash is
 -- invalid or an unsupported version.
-validatePassword :: (ByteArray password, ByteArray hash) => password -> hash -> Bool
+validatePassword
+    :: (ByteArray password, ByteArray hash) => password -> hash -> Bool
 validatePassword password bcHash = either (const False) id (validatePasswordEither password bcHash)
 
 -- | Check a password against a bcrypt hash
 --
 -- As for @validatePassword@ but will provide error information if the hash is invalid or
 -- an unsupported version.
-validatePasswordEither :: (ByteArray password, ByteArray hash) => password -> hash -> Either String Bool
+validatePasswordEither
+    :: (ByteArray password, ByteArray hash) => password -> hash -> Either String Bool
 validatePasswordEither password bcHash = do
     BCH version cost salt hash <- parseBCryptHash bcHash
     return $ (rawHash version cost salt password :: Bytes) `B.constEq` hash
 
-rawHash :: (ByteArrayAccess salt, ByteArray password, ByteArray output) => Char -> Int -> salt -> password -> output
+rawHash
+    :: (ByteArrayAccess salt, ByteArray password, ByteArray output)
+    => Char -> Int -> salt -> password -> output
 rawHash _ cost salt password = B.take 23 hash -- Another compatibility bug. Ignore last byte of hash
   where
     hash = loop (0 :: Int) orpheanBeholder
 
     loop i input
-        | i < 64    = loop (i+1) (encrypt ctx input)
+        | i < 64 = loop (i + 1) (encrypt ctx input)
         | otherwise = input
 
     -- Truncate the password if necessary and append a null byte for C compatibility
@@ -144,27 +159,58 @@
     ctx = expensiveBlowfishContext key salt cost
 
     -- The BCrypt plaintext: "OrpheanBeholderScryDoubt"
-    orpheanBeholder = B.pack [79,114,112,104,101,97,110,66,101,104,111,108,100,101,114,83,99,114,121,68,111,117,98,116]
+    orpheanBeholder =
+        B.pack
+            [ 79
+            , 114
+            , 112
+            , 104
+            , 101
+            , 97
+            , 110
+            , 66
+            , 101
+            , 104
+            , 111
+            , 108
+            , 100
+            , 101
+            , 114
+            , 83
+            , 99
+            , 114
+            , 121
+            , 68
+            , 111
+            , 117
+            , 98
+            , 116
+            ]
 
 -- "$2a$10$XajjQvNhvvRt5GSeFk1xFeyqRrsxkhBkUiQeg0dt.wU1qD4aFDcga"
-parseBCryptHash :: (ByteArray ba) => ba -> Either String BCryptHash
+parseBCryptHash :: ByteArray ba => ba -> Either String BCryptHash
 parseBCryptHash bc = do
-    unless (B.length bc == 60      &&
-            B.index bc 0 == dollar &&
-            B.index bc 1 == fromIntegral (ord '2') &&
-            B.index bc 3 == dollar &&
-            B.index bc 6 == dollar) (Left "Invalid hash format")
-    unless (version == 'b' || version == 'a' || version == 'y') (Left ("Unsupported minor version: " ++ [version]))
-    when (costTens > 3 || cost > 31 || cost < 4)  (Left "Invalid bcrypt cost")
+    unless
+        ( B.length bc == 60
+            && B.index bc 0 == dollar
+            && B.index bc 1 == fromIntegral (ord '2')
+            && B.index bc 3 == dollar
+            && B.index bc 6 == dollar
+        )
+        (Left "Invalid hash format")
+    unless
+        (version == 'b' || version == 'a' || version == 'y')
+        (Left ("Unsupported minor version: " ++ [version]))
+    when (costTens > 3 || cost > 31 || cost < 4) (Left "Invalid bcrypt cost")
     (salt, hash) <- decodeSaltHash (B.drop 7 bc)
     return (BCH version cost salt hash)
   where
-    dollar    = fromIntegral (ord '$')
-    zero      = ord '0'
-    costTens  = fromIntegral (B.index bc 4) - zero
+    dollar = fromIntegral (ord '$')
+    zero = ord '0'
+    costTens = fromIntegral (B.index bc 4) - zero
     costUnits = fromIntegral (B.index bc 5) - zero
-    version   = chr (fromIntegral (B.index bc 2))
-    cost      = costUnits + 10*costTens :: Int
+    version = chr (fromIntegral (B.index bc 2))
+    cost = costUnits + 10 * costTens :: Int
 
     decodeSaltHash saltHash = do
         let (s, h) = B.splitAt 22 saltHash
@@ -177,13 +223,14 @@
 -- Salt must be a 128-bit byte array.
 -- Cost must be between 4 and 31 inclusive
 -- See <https://www.usenix.org/conference/1999-usenix-annual-technical-conference/future-adaptable-password-scheme>
-expensiveBlowfishContext :: (ByteArrayAccess key, ByteArrayAccess salt) => key-> salt -> Int -> Context
+expensiveBlowfishContext
+    :: (ByteArrayAccess key, ByteArrayAccess salt) => key -> salt -> Int -> Context
 expensiveBlowfishContext keyBytes saltBytes cost
-  | B.length saltBytes /= 16 = error "bcrypt salt must be 16 bytes"
-  | otherwise = unsafeDoIO $ do
+    | B.length saltBytes /= 16 = error "bcrypt salt must be 16 bytes"
+    | otherwise = unsafeDoIO $ do
         ks <- createKeySchedule
         expandKeyWithSalt ks keyBytes saltBytes
-        forM_ [1..2^cost :: Int] $ \_ -> do
+        forM_ [1 .. 2 ^ cost :: Int] $ \_ -> do
             expandKey ks keyBytes
             expandKey ks saltBytes
         freezeKeySchedule ks
diff --git a/Crypto/KDF/BCryptPBKDF.hs b/Crypto/KDF/BCryptPBKDF.hs
--- a/Crypto/KDF/BCryptPBKDF.hs
+++ b/Crypto/KDF/BCryptPBKDF.hs
@@ -6,137 +6,143 @@
 --
 -- Port of the bcrypt_pbkdf key derivation function from OpenBSD
 -- as described at <http://man.openbsd.org/bcrypt_pbkdf.3>.
-module Crypto.KDF.BCryptPBKDF
-    ( Parameters (..)
-    , generate
-    , hashInternal
-    )
+module Crypto.KDF.BCryptPBKDF (
+    Parameters (..),
+    generate,
+    hashInternal,
+)
 where
 
-import           Basement.Block                   (MutableBlock)
-import qualified Basement.Block                   as Block
-import qualified Basement.Block.Mutable           as Block
-import           Basement.Monad                   (PrimState)
-import           Basement.Types.OffsetSize        (CountOf (..), Offset (..))
-import           Control.Exception                (finally)
-import           Control.Monad                    (when)
-import qualified Crypto.Cipher.Blowfish.Box       as Blowfish
+import Control.Exception (finally)
+import Control.Monad (when)
+import qualified Crypto.Cipher.Blowfish.Box as Blowfish
 import qualified Crypto.Cipher.Blowfish.Primitive as Blowfish
-import           Crypto.Hash.Algorithms           (SHA512 (..))
-import           Crypto.Hash.Types                (Context,
-                                                   hashDigestSize,
-                                                   hashInternalContextSize,
-                                                   hashInternalFinalize,
-                                                   hashInternalInit,
-                                                   hashInternalUpdate)
-import           Crypto.Internal.Compat           (unsafeDoIO)
-import           Data.Bits
-import qualified Data.ByteArray                   as B
-import           Data.Foldable                    (forM_)
-import           Data.Memory.PtrMethods           (memCopy, memSet, memXor)
-import           Data.Word
-import           Foreign.Ptr                      (Ptr, castPtr)
-import           Foreign.Storable                 (peekByteOff, pokeByteOff)
+import Crypto.Hash.Algorithms (SHA512 (..))
+import Crypto.Hash.Types (
+    Context,
+    hashDigestSize,
+    hashInternalContextSize,
+    hashInternalFinalize,
+    hashInternalInit,
+    hashInternalUpdate,
+ )
+import Crypto.Internal.Compat (unsafeDoIO)
+import Data.Bits
+import qualified Data.ByteArray as B
+import qualified Data.ByteString.Internal as BSI
+import Data.Foldable (forM_)
+import Data.Memory.PtrMethods (memCopy, memSet, memXor)
+import Data.Word
+import Foreign.ForeignPtr (ForeignPtr, mallocForeignPtrBytes, withForeignPtr)
+import Foreign.Ptr (Ptr, castPtr)
+import Foreign.Storable (peekByteOff, pokeByteOff)
 
 data Parameters = Parameters
-  { iterCounts   :: Int -- ^ The number of user-defined iterations for the algorithm
-                        --   (must be > 0)
-  , outputLength :: Int -- ^ The number of bytes to generate out of BCryptPBKDF
-                        --   (must be in 1..1024)
-  } deriving (Eq, Ord, Show)
+    { iterCounts :: Int
+    -- ^ The number of user-defined iterations for the algorithm
+    --   (must be > 0)
+    , outputLength :: Int
+    -- ^ The number of bytes to generate out of BCryptPBKDF
+    --   (must be in 1..1024)
+    }
+    deriving (Eq, Ord, Show)
 
 -- | Derive a key of specified length using the bcrypt_pbkdf algorithm.
-generate :: (B.ByteArray pass, B.ByteArray salt, B.ByteArray output)
-       => Parameters
-       -> pass
-       -> salt
-       -> output
+generate
+    :: (B.ByteArray pass, B.ByteArray salt, B.ByteArray output)
+    => Parameters
+    -> pass
+    -> salt
+    -> output
 generate params pass salt
-    | iterCounts params < 1       = error "BCryptPBKDF: iterCounts must be > 0"
-    | keyLen < 1 || keyLen > 1024 = error "BCryptPBKDF: outputLength must be in 1..1024"
-    | otherwise                   = B.unsafeCreate keyLen deriveKey
+    | iterCounts params < 1 = error "BCryptPBKDF: iterCounts must be > 0"
+    | keyLen < 1 || keyLen > 1024 =
+        error "BCryptPBKDF: outputLength must be in 1..1024"
+    | otherwise = B.unsafeCreate keyLen deriveKey
   where
     outLen, tmpLen, blkLen, keyLen, passLen, saltLen, ctxLen, hashLen, blocks :: Int
-    outLen  = 32
-    tmpLen  = 32
-    blkLen  = 4
+    outLen = 32
+    tmpLen = 32
+    blkLen = 4
     passLen = B.length pass
     saltLen = B.length salt
-    keyLen  = outputLength params
-    ctxLen  = hashInternalContextSize SHA512
+    keyLen = outputLength params
+    ctxLen = hashInternalContextSize SHA512
     hashLen = hashDigestSize SHA512 -- 64
-    blocks  = (keyLen + outLen - 1) `div` outLen
+    blocks = (keyLen + outLen - 1) `div` outLen
 
     deriveKey :: Ptr Word8 -> IO ()
     deriveKey keyPtr = do
-        -- Allocate all necessary memory. The algorihm shall not allocate
-        -- any more dynamic memory after this point. Blocks need to be pinned
-        -- as pointers to them are passed to the SHA512 implementation.
-        ksClean        <- Blowfish.createKeySchedule
-        ksDirty        <- Blowfish.createKeySchedule
-        ctxMBlock      <- Block.newPinned (CountOf ctxLen  :: CountOf Word8)
-        outMBlock      <- Block.newPinned (CountOf outLen  :: CountOf Word8)
-        tmpMBlock      <- Block.newPinned (CountOf tmpLen  :: CountOf Word8)
-        blkMBlock      <- Block.newPinned (CountOf blkLen  :: CountOf Word8)
-        passHashMBlock <- Block.newPinned (CountOf hashLen :: CountOf Word8)
-        saltHashMBlock <- Block.newPinned (CountOf hashLen :: CountOf Word8)
+        -- Allocate all necessary memory. The algorithm shall not allocate
+        -- any more dynamic memory after this point. ForeignPtrs allocate
+        -- pinned memory, so raw pointers to them are stable.
+        ksClean <- Blowfish.createKeySchedule
+        ksDirty <- Blowfish.createKeySchedule
+        ctxFP <- mallocForeignPtrBytes ctxLen :: IO (ForeignPtr Word8)
+        outFP <- mallocForeignPtrBytes outLen :: IO (ForeignPtr Word8)
+        tmpFP <- mallocForeignPtrBytes tmpLen :: IO (ForeignPtr Word8)
+        blkFP <- mallocForeignPtrBytes blkLen :: IO (ForeignPtr Word8)
+        passHashFP <- mallocForeignPtrBytes hashLen :: IO (ForeignPtr Word8)
+        saltHashFP <- mallocForeignPtrBytes hashLen :: IO (ForeignPtr Word8)
         -- Finally erase all memory areas that contain information from
         -- which the derived key could be reconstructed.
-        -- As all MutableBlocks are pinned it shall be guaranteed that
-        -- no temporary trampoline buffers are allocated.
-        finallyErase outMBlock $ finallyErase passHashMBlock $
-            B.withByteArray pass                $ \passPtr->
-            B.withByteArray salt                $ \saltPtr->
-            Block.withMutablePtr ctxMBlock      $ \ctxPtr->
-            Block.withMutablePtr outMBlock      $ \outPtr->
-            Block.withMutablePtr tmpMBlock      $ \tmpPtr->
-            Block.withMutablePtr blkMBlock      $ \blkPtr->
-            Block.withMutablePtr passHashMBlock $ \passHashPtr->
-            Block.withMutablePtr saltHashMBlock $ \saltHashPtr-> do
-                -- Hash the password.
-                let shaPtr = castPtr ctxPtr :: Ptr (Context SHA512)
-                hashInternalInit     shaPtr
-                hashInternalUpdate   shaPtr passPtr (fromIntegral passLen)
-                hashInternalFinalize shaPtr (castPtr passHashPtr)
-                passHashBlock <- Block.unsafeFreeze passHashMBlock
-                forM_ [1..blocks] $ \block-> do
-                    -- Poke the increased block counter.
-                    Block.unsafeWrite blkMBlock 0 (fromIntegral $ block `shiftR` 24)
-                    Block.unsafeWrite blkMBlock 1 (fromIntegral $ block `shiftR` 16)
-                    Block.unsafeWrite blkMBlock 2 (fromIntegral $ block `shiftR`  8)
-                    Block.unsafeWrite blkMBlock 3 (fromIntegral $ block `shiftR`  0)
-                    -- First round (slightly different).
-                    hashInternalInit     shaPtr
-                    hashInternalUpdate   shaPtr saltPtr (fromIntegral saltLen)
-                    hashInternalUpdate   shaPtr blkPtr  (fromIntegral blkLen)
-                    hashInternalFinalize shaPtr (castPtr saltHashPtr)
-                    Block.unsafeFreeze saltHashMBlock >>= \x-> do
-                        Blowfish.copyKeySchedule ksDirty ksClean
-                        hashInternalMutable ksDirty passHashBlock x tmpMBlock
-                    memCopy outPtr tmpPtr outLen
-                    -- Remaining rounds.
-                    forM_ [2..iterCounts params] $ const $ do
-                        hashInternalInit     shaPtr
-                        hashInternalUpdate   shaPtr tmpPtr (fromIntegral tmpLen)
-                        hashInternalFinalize shaPtr (castPtr saltHashPtr)
-                        Block.unsafeFreeze saltHashMBlock >>= \x-> do
-                            Blowfish.copyKeySchedule ksDirty ksClean
-                            hashInternalMutable ksDirty passHashBlock x tmpMBlock
-                        memXor outPtr outPtr tmpPtr outLen
-                    -- Spread the current out buffer evenly over the key buffer.
-                    -- After both loops have run every byte of the key buffer
-                    -- will have been written to exactly once and every byte
-                    -- of the output will have been used.
-                    forM_ [0..outLen - 1] $ \outIdx-> do
-                        let keyIdx = outIdx * blocks + block - 1
-                        when (keyIdx < keyLen) $ do
-                            w8 <- peekByteOff outPtr outIdx :: IO Word8
-                            pokeByteOff keyPtr keyIdx w8
+        finallyErase outFP outLen $
+            finallyErase passHashFP hashLen $
+                B.withByteArray pass $ \passPtr ->
+                    B.withByteArray salt $ \saltPtr ->
+                        withForeignPtr ctxFP $ \ctxPtr' ->
+                            withForeignPtr outFP $ \outPtr ->
+                                withForeignPtr tmpFP $ \tmpPtr ->
+                                    withForeignPtr blkFP $ \blkPtr ->
+                                        withForeignPtr passHashFP $ \passHashPtr ->
+                                            withForeignPtr saltHashFP $ \saltHashPtr -> do
+                                                -- Hash the password.
+                                                let shaPtr = castPtr ctxPtr' :: Ptr (Context SHA512)
+                                                hashInternalInit shaPtr
+                                                hashInternalUpdate shaPtr passPtr (fromIntegral passLen)
+                                                hashInternalFinalize shaPtr (castPtr passHashPtr)
+                                                -- Create a stable ByteString view of the password hash
+                                                -- (passHashFP is not modified after this point).
+                                                let passHashBS = BSI.fromForeignPtr passHashFP 0 hashLen
+                                                forM_ [1 .. blocks] $ \block -> do
+                                                    -- Poke the increased block counter.
+                                                    pokeByteOff blkPtr 0 (fromIntegral (block `shiftR` 24) :: Word8)
+                                                    pokeByteOff blkPtr 1 (fromIntegral (block `shiftR` 16) :: Word8)
+                                                    pokeByteOff blkPtr 2 (fromIntegral (block `shiftR` 8) :: Word8)
+                                                    pokeByteOff blkPtr 3 (fromIntegral (block `shiftR` 0 :: Int) :: Word8)
+                                                    -- First round (slightly different).
+                                                    hashInternalInit shaPtr
+                                                    hashInternalUpdate shaPtr saltPtr (fromIntegral saltLen)
+                                                    hashInternalUpdate shaPtr blkPtr (fromIntegral blkLen)
+                                                    hashInternalFinalize shaPtr (castPtr saltHashPtr)
+                                                    let saltHashBS = BSI.fromForeignPtr saltHashFP 0 hashLen
+                                                    Blowfish.copyKeySchedule ksDirty ksClean
+                                                    hashInternalMutable ksDirty passHashBS saltHashBS tmpPtr
+                                                    memCopy outPtr tmpPtr outLen
+                                                    -- Remaining rounds.
+                                                    forM_ [2 .. iterCounts params] $ const $ do
+                                                        hashInternalInit shaPtr
+                                                        hashInternalUpdate shaPtr tmpPtr (fromIntegral tmpLen)
+                                                        hashInternalFinalize shaPtr (castPtr saltHashPtr)
+                                                        let saltHashBS2 = BSI.fromForeignPtr saltHashFP 0 hashLen
+                                                        Blowfish.copyKeySchedule ksDirty ksClean
+                                                        hashInternalMutable ksDirty passHashBS saltHashBS2 tmpPtr
+                                                        memXor outPtr outPtr tmpPtr outLen
+                                                    -- Spread the current out buffer evenly over the key buffer.
+                                                    -- After both loops have run every byte of the key buffer
+                                                    -- will have been written to exactly once and every byte
+                                                    -- of the output will have been used.
+                                                    forM_ [0 .. outLen - 1] $ \outIdx -> do
+                                                        let keyIdx = outIdx * blocks + block - 1
+                                                        when (keyIdx < keyLen) $ do
+                                                            w8 <- peekByteOff outPtr outIdx :: IO Word8
+                                                            pokeByteOff keyPtr keyIdx w8
 
 -- | Internal hash function used by `generate`.
 --
 -- Normal users should not need this.
-hashInternal :: (B.ByteArrayAccess pass, B.ByteArrayAccess salt, B.ByteArray output)
+hashInternal
+    :: (B.ByteArrayAccess pass, B.ByteArrayAccess salt, B.ByteArray output)
     => pass
     -> salt
     -> output
@@ -145,43 +151,40 @@
     | B.length saltHash /= 64 = error "saltHash must be 512 bits"
     | otherwise = unsafeDoIO $ do
         ks0 <- Blowfish.createKeySchedule
-        outMBlock <- Block.newPinned 32
-        hashInternalMutable ks0 passHash saltHash outMBlock
-        B.convert `fmap` Block.freeze outMBlock
+        B.alloc 32 $ \outPtr -> hashInternalMutable ks0 passHash saltHash outPtr
 
-hashInternalMutable :: (B.ByteArrayAccess pass, B.ByteArrayAccess salt)
+hashInternalMutable
+    :: (B.ByteArrayAccess pass, B.ByteArrayAccess salt)
     => Blowfish.KeySchedule
     -> pass
     -> salt
-    -> MutableBlock Word8 (PrimState IO)
+    -> Ptr Word8
     -> IO ()
-hashInternalMutable bfks passHash saltHash outMBlock = do
+hashInternalMutable bfks passHash saltHash outPtr = do
     Blowfish.expandKeyWithSalt bfks passHash saltHash
-    forM_ [0..63 :: Int] $ const $ do
+    forM_ [0 .. 63 :: Int] $ const $ do
         Blowfish.expandKey bfks saltHash
         Blowfish.expandKey bfks passHash
     -- "OxychromaticBlowfishSwatDynamite" represented as 4 Word64 in big-endian.
-    store  0 =<< cipher 64 0x4f78796368726f6d
-    store  8 =<< cipher 64 0x61746963426c6f77
+    store 0 =<< cipher 64 0x4f78796368726f6d
+    store 8 =<< cipher 64 0x61746963426c6f77
     store 16 =<< cipher 64 0x6669736853776174
     store 24 =<< cipher 64 0x44796e616d697465
-    where
-        store :: Offset Word8 -> Word64 -> IO ()
-        store o w64 = do
-            Block.unsafeWrite outMBlock (o + 0) (fromIntegral $ w64 `shiftR` 32)
-            Block.unsafeWrite outMBlock (o + 1) (fromIntegral $ w64 `shiftR` 40)
-            Block.unsafeWrite outMBlock (o + 2) (fromIntegral $ w64 `shiftR` 48)
-            Block.unsafeWrite outMBlock (o + 3) (fromIntegral $ w64 `shiftR` 56)
-            Block.unsafeWrite outMBlock (o + 4) (fromIntegral $ w64 `shiftR`  0)
-            Block.unsafeWrite outMBlock (o + 5) (fromIntegral $ w64 `shiftR`  8)
-            Block.unsafeWrite outMBlock (o + 6) (fromIntegral $ w64 `shiftR` 16)
-            Block.unsafeWrite outMBlock (o + 7) (fromIntegral $ w64 `shiftR` 24)
-        cipher :: Int -> Word64 -> IO Word64
-        cipher 0 block = return block
-        cipher i block = Blowfish.cipherBlockMutable bfks block >>= cipher (i - 1)
+  where
+    store :: Int -> Word64 -> IO ()
+    store o w64 = do
+        pokeByteOff outPtr (o + 0) (fromIntegral (w64 `shiftR` 32) :: Word8)
+        pokeByteOff outPtr (o + 1) (fromIntegral (w64 `shiftR` 40) :: Word8)
+        pokeByteOff outPtr (o + 2) (fromIntegral (w64 `shiftR` 48) :: Word8)
+        pokeByteOff outPtr (o + 3) (fromIntegral (w64 `shiftR` 56) :: Word8)
+        pokeByteOff outPtr (o + 4) (fromIntegral (w64 `shiftR` 0) :: Word8)
+        pokeByteOff outPtr (o + 5) (fromIntegral (w64 `shiftR` 8) :: Word8)
+        pokeByteOff outPtr (o + 6) (fromIntegral (w64 `shiftR` 16) :: Word8)
+        pokeByteOff outPtr (o + 7) (fromIntegral (w64 `shiftR` 24) :: Word8)
+    cipher :: Int -> Word64 -> IO Word64
+    cipher 0 block = return block
+    cipher i block = Blowfish.cipherBlockMutable bfks block >>= cipher (i - 1)
 
-finallyErase :: MutableBlock Word8 (PrimState IO) -> IO () -> IO ()
-finallyErase mblock action =
-    action `finally` Block.withMutablePtr mblock (\ptr-> memSet ptr 0 len)
-    where
-        CountOf len = Block.mutableLengthBytes mblock
+finallyErase :: ForeignPtr Word8 -> Int -> IO () -> IO ()
+finallyErase fp len action =
+    action `finally` withForeignPtr fp (\ptr -> memSet ptr 0 len)
diff --git a/Crypto/KDF/HKDF.hs b/Crypto/KDF/HKDF.hs
--- a/Crypto/KDF/HKDF.hs
+++ b/Crypto/KDF/HKDF.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.KDF.HKDF
 -- License     : BSD-style
@@ -8,77 +10,96 @@
 -- Key Derivation Function based on HMAC
 --
 -- See RFC5869
---
-{-# LANGUAGE BangPatterns #-}
-module Crypto.KDF.HKDF
-    ( PRK
-    , extract
-    , extractSkip
-    , expand
-    ) where
+module Crypto.KDF.HKDF (
+    PRK,
+    extract,
+    extractSkip,
+    expand,
+    toPRK,
+) where
 
-import           Data.Word
-import           Crypto.Hash
-import           Crypto.MAC.HMAC
-import           Crypto.Internal.ByteArray (ScrubbedBytes, ByteArray, ByteArrayAccess)
+import Crypto.Hash
+import Crypto.Internal.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    ScrubbedBytes,
+ )
 import qualified Crypto.Internal.ByteArray as B
+import Crypto.MAC.HMAC
+import Data.Word
 
 -- | Pseudo Random Key
 data PRK a = PRK (HMAC a) | PRK_NoExpand ScrubbedBytes
     deriving (Eq)
 
 instance ByteArrayAccess (PRK a) where
-    length (PRK hm)          = B.length hm
+    length (PRK hm) = B.length hm
     length (PRK_NoExpand sb) = B.length sb
-    withByteArray (PRK hm)          = B.withByteArray hm
+    withByteArray (PRK hm) = B.withByteArray hm
     withByteArray (PRK_NoExpand sb) = B.withByteArray sb
 
 -- | Extract a Pseudo Random Key using the parameter and the underlaying hash mechanism
-extract :: (HashAlgorithm a, ByteArrayAccess salt, ByteArrayAccess ikm)
-        => salt  -- ^ Salt
-        -> ikm   -- ^ Input Keying Material
-        -> PRK a -- ^ Pseudo random key
+extract
+    :: (HashAlgorithm a, ByteArrayAccess salt, ByteArrayAccess ikm)
+    => salt
+    -- ^ Salt
+    -> ikm
+    -- ^ Input Keying Material
+    -> PRK a
+    -- ^ Pseudo random key
 extract salt ikm = PRK $ hmac salt ikm
 
 -- | Create a PRK directly from the input key material.
 --
 -- Only use when guaranteed to have a good quality and random data to use directly as key.
 -- This effectively skip a HMAC with key=salt and data=key.
-extractSkip :: ByteArrayAccess ikm
-            => ikm
-            -> PRK a
+extractSkip
+    :: ByteArrayAccess ikm
+    => ikm
+    -> PRK a
 extractSkip ikm = PRK_NoExpand $ B.convert ikm
 
 -- | Expand key material of specific length out of the parameters
-expand :: (HashAlgorithm a, ByteArrayAccess info, ByteArray out)
-       => PRK a      -- ^ Pseudo Random Key
-       -> info       -- ^ Optional context and application specific information
-       -> Int        -- ^ Output length in bytes
-       -> out        -- ^ Output data
+expand
+    :: (HashAlgorithm a, ByteArrayAccess info, ByteArray out)
+    => PRK a
+    -- ^ Pseudo Random Key
+    -> info
+    -- ^ Optional context and application specific information
+    -> Int
+    -- ^ Output length in bytes
+    -> out
+    -- ^ Output data
 expand prkAt infoAt outputLength =
     let hF = hFGet prkAt
      in B.concat $ loop hF B.empty outputLength 1
   where
     hFGet :: (HashAlgorithm a, ByteArrayAccess b) => PRK a -> (b -> HMAC a)
     hFGet prk = case prk of
-             PRK hmacKey      -> hmac hmacKey
-             PRK_NoExpand ikm -> hmac ikm
+        PRK hmacKey -> hmac hmacKey
+        PRK_NoExpand ikm -> hmac ikm
 
     info :: ScrubbedBytes
     info = B.convert infoAt
 
-    loop :: HashAlgorithm a
-         => (ScrubbedBytes -> HMAC a)
-         -> ScrubbedBytes
-         -> Int
-         -> Word8
-         -> [ScrubbedBytes]
+    loop
+        :: HashAlgorithm a
+        => (ScrubbedBytes -> HMAC a)
+        -> ScrubbedBytes
+        -> Int
+        -> Word8
+        -> [ScrubbedBytes]
     loop hF tim1 n i
-        | n <= 0    = []
+        | n <= 0 = []
         | otherwise =
-            let input   = B.concat [tim1,info,B.singleton i] :: ScrubbedBytes
-                ti      = B.convert $ hF input
+            let input = B.concat [tim1, info, B.singleton i] :: ScrubbedBytes
+                ti = B.convert $ hF input
                 hashLen = B.length ti
-                r       = n - hashLen
+                r = n - hashLen
              in (if n >= hashLen then ti else B.take n ti)
-              : loop hF ti r (i+1)
+                    : loop hF ti r (i + 1)
+
+toPRK :: (HashAlgorithm a, ByteArrayAccess ba) => ba -> Maybe (PRK a)
+toPRK bs = case digestFromByteString bs of
+    Nothing -> Nothing
+    Just digest -> Just $ PRK $ HMAC digest
diff --git a/Crypto/KDF/PBKDF2.hs b/Crypto/KDF/PBKDF2.hs
--- a/Crypto/KDF/PBKDF2.hs
+++ b/Crypto/KDF/PBKDF2.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+
 -- |
 -- Module      : Crypto.KDF.PBKDF2
 -- License     : BSD-style
@@ -6,67 +9,71 @@
 -- Portability : unknown
 --
 -- Password Based Key Derivation Function 2
---
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE ForeignFunctionInterface #-}
-
-module Crypto.KDF.PBKDF2
-    ( PRF
-    , prfHMAC
-    , Parameters(..)
-    , generate
-    , fastPBKDF2_SHA1
-    , fastPBKDF2_SHA256
-    , fastPBKDF2_SHA512
-    ) where
+module Crypto.KDF.PBKDF2 (
+    PRF,
+    prfHMAC,
+    Parameters (..),
+    generate,
+    fastPBKDF2_SHA1,
+    fastPBKDF2_SHA256,
+    fastPBKDF2_SHA512,
+) where
 
-import           Data.Word
-import           Data.Bits
-import           Foreign.Marshal.Alloc
-import           Foreign.Ptr (plusPtr, Ptr)
-import           Foreign.C.Types (CUInt(..), CSize(..))
+import Data.Bits
+import Data.Word
+import Foreign.C.Types (CSize (..), CUInt (..))
+import Foreign.Marshal.Alloc
+import Foreign.Ptr (Ptr, plusPtr)
 
-import           Crypto.Hash (HashAlgorithm)
+import Crypto.Hash (HashAlgorithm)
 import qualified Crypto.MAC.HMAC as HMAC
 
-import           Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, Bytes)
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, Bytes)
 import qualified Crypto.Internal.ByteArray as B
-import           Data.Memory.PtrMethods
+import Data.Memory.PtrMethods
 
 -- | The PRF used for PBKDF2
 type PRF password =
-       password -- ^ the password parameters
-    -> Bytes    -- ^ the content
-    -> Bytes    -- ^ prf(password,content)
+    password
+    -- ^ the password parameters
+    -> Bytes
+    -- ^ the content
+    -> Bytes
+    -- ^ prf(password,content)
 
 -- | PRF for PBKDF2 using HMAC with the hash algorithm as parameter
-prfHMAC :: (HashAlgorithm a, ByteArrayAccess password)
-        => a
-        -> PRF password
+prfHMAC
+    :: (HashAlgorithm a, ByteArrayAccess password)
+    => a
+    -> PRF password
 prfHMAC alg k = hmacIncr alg (HMAC.initialize k)
-  where hmacIncr :: HashAlgorithm a => a -> HMAC.Context a -> (Bytes -> Bytes)
-        hmacIncr _ !ctx = \b -> B.convert $ HMAC.finalize $ HMAC.update ctx b
+  where
+    hmacIncr :: HashAlgorithm a => a -> HMAC.Context a -> (Bytes -> Bytes)
+    hmacIncr _ !ctx = \b -> B.convert $ HMAC.finalize $ HMAC.update ctx b
 
 -- | Parameters for PBKDF2
 data Parameters = Parameters
-    { iterCounts   :: Int -- ^ the number of user-defined iterations for the algorithms. e.g. WPA2 uses 4000.
-    , outputLength :: Int -- ^ the number of bytes to generate out of PBKDF2
+    { iterCounts :: Int
+    -- ^ the number of user-defined iterations for the algorithms. e.g. WPA2 uses 4000.
+    , outputLength :: Int
+    -- ^ the number of bytes to generate out of PBKDF2
     }
 
 -- | generate the pbkdf2 key derivation function from the output
-generate :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray ba)
-         => PRF password
-         -> Parameters
-         -> password
-         -> salt
-         -> ba
+generate
+    :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray ba)
+    => PRF password
+    -> Parameters
+    -> password
+    -> salt
+    -> ba
 generate prf params password salt =
     B.allocAndFreeze (outputLength params) $ \p -> do
         memSet p 0 (outputLength params)
         loop 1 (outputLength params) p
   where
     !runPRF = prf password
-    !hLen   = B.length $ runPRF B.empty
+    !hLen = B.length $ runPRF B.empty
 
     -- run the following f function on each complete chunk.
     -- when having an incomplete chunk, we call partial.
@@ -76,100 +83,124 @@
     -- U1 = PRF(pass,salt || BE32(i))
     -- Uc = PRF(pass,Uc-1)
     loop iterNb len p
-        | len == 0   = return ()
+        | len == 0 = return ()
         | len < hLen = partial iterNb len p
-        | otherwise  = do
-            let applyMany 0 _     = return ()
+        | otherwise = do
+            let applyMany 0 _ = return ()
                 applyMany i uprev = do
                     let uData = runPRF uprev
                     B.withByteArray uData $ \u -> memXor p p u hLen
-                    applyMany (i-1) uData
+                    applyMany (i - 1) uData
             applyMany (iterCounts params) (B.convert salt `B.append` toBS iterNb)
-            loop (iterNb+1) (len - hLen) (p `plusPtr` hLen)
+            loop (iterNb + 1) (len - hLen) (p `plusPtr` hLen)
 
     partial iterNb len p = allocaBytesAligned hLen 8 $ \tmp -> do
         let applyMany :: Int -> Bytes -> IO ()
-            applyMany 0 _     = return ()
+            applyMany 0 _ = return ()
             applyMany i uprev = do
                 let uData = runPRF uprev
                 B.withByteArray uData $ \u -> memXor tmp tmp u hLen
-                applyMany (i-1) uData
+                applyMany (i - 1) uData
         memSet tmp 0 hLen
         applyMany (iterCounts params) (B.convert salt `B.append` toBS iterNb)
         memCopy p tmp len
 
     -- big endian encoding of Word32
     toBS :: ByteArray ba => Word32 -> ba
-    toBS w = B.pack [a,b,c,d]
-      where a = fromIntegral (w `shiftR` 24)
-            b = fromIntegral ((w `shiftR` 16) .&. 0xff)
-            c = fromIntegral ((w `shiftR` 8) .&. 0xff)
-            d = fromIntegral (w .&. 0xff)
+    toBS w = B.pack [a, b, c, d]
+      where
+        a = fromIntegral (w `shiftR` 24)
+        b = fromIntegral ((w `shiftR` 16) .&. 0xff)
+        c = fromIntegral ((w `shiftR` 8) .&. 0xff)
+        d = fromIntegral (w .&. 0xff)
 {-# NOINLINE generate #-}
 
-fastPBKDF2_SHA1 :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out)
-                => Parameters
-                -> password
-                -> salt
-                -> out
+fastPBKDF2_SHA1
+    :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out)
+    => Parameters
+    -> password
+    -> salt
+    -> out
 fastPBKDF2_SHA1 params password salt =
     B.allocAndFreeze (outputLength params) $ \outPtr ->
-    B.withByteArray password $ \passPtr ->
-    B.withByteArray salt $ \saltPtr ->
-        c_crypton_fastpbkdf2_hmac_sha1
-            passPtr (fromIntegral $ B.length password)
-            saltPtr (fromIntegral $ B.length salt)
-            (fromIntegral $ iterCounts params)
-            outPtr (fromIntegral $ outputLength params)
+        B.withByteArray password $ \passPtr ->
+            B.withByteArray salt $ \saltPtr ->
+                c_crypton_fastpbkdf2_hmac_sha1
+                    passPtr
+                    (fromIntegral $ B.length password)
+                    saltPtr
+                    (fromIntegral $ B.length salt)
+                    (fromIntegral $ iterCounts params)
+                    outPtr
+                    (fromIntegral $ outputLength params)
 
-fastPBKDF2_SHA256 :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out)
-                  => Parameters
-                  -> password
-                  -> salt
-                  -> out
+fastPBKDF2_SHA256
+    :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out)
+    => Parameters
+    -> password
+    -> salt
+    -> out
 fastPBKDF2_SHA256 params password salt =
     B.allocAndFreeze (outputLength params) $ \outPtr ->
-    B.withByteArray password $ \passPtr ->
-    B.withByteArray salt $ \saltPtr ->
-        c_crypton_fastpbkdf2_hmac_sha256
-            passPtr (fromIntegral $ B.length password)
-            saltPtr (fromIntegral $ B.length salt)
-            (fromIntegral $ iterCounts params)
-            outPtr (fromIntegral $ outputLength params)
+        B.withByteArray password $ \passPtr ->
+            B.withByteArray salt $ \saltPtr ->
+                c_crypton_fastpbkdf2_hmac_sha256
+                    passPtr
+                    (fromIntegral $ B.length password)
+                    saltPtr
+                    (fromIntegral $ B.length salt)
+                    (fromIntegral $ iterCounts params)
+                    outPtr
+                    (fromIntegral $ outputLength params)
 
-fastPBKDF2_SHA512 :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out)
-                  => Parameters
-                  -> password
-                  -> salt
-                  -> out
+fastPBKDF2_SHA512
+    :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out)
+    => Parameters
+    -> password
+    -> salt
+    -> out
 fastPBKDF2_SHA512 params password salt =
     B.allocAndFreeze (outputLength params) $ \outPtr ->
-    B.withByteArray password $ \passPtr ->
-    B.withByteArray salt $ \saltPtr ->
-        c_crypton_fastpbkdf2_hmac_sha512
-            passPtr (fromIntegral $ B.length password)
-            saltPtr (fromIntegral $ B.length salt)
-            (fromIntegral $ iterCounts params)
-            outPtr (fromIntegral $ outputLength params)
-
+        B.withByteArray password $ \passPtr ->
+            B.withByteArray salt $ \saltPtr ->
+                c_crypton_fastpbkdf2_hmac_sha512
+                    passPtr
+                    (fromIntegral $ B.length password)
+                    saltPtr
+                    (fromIntegral $ B.length salt)
+                    (fromIntegral $ iterCounts params)
+                    outPtr
+                    (fromIntegral $ outputLength params)
 
 foreign import ccall unsafe "crypton_pbkdf2.h crypton_fastpbkdf2_hmac_sha1"
-    c_crypton_fastpbkdf2_hmac_sha1 :: Ptr Word8 -> CSize
-                                      -> Ptr Word8 -> CSize
-                                      -> CUInt
-                                      -> Ptr Word8 -> CSize
-                                      -> IO ()
+    c_crypton_fastpbkdf2_hmac_sha1
+        :: Ptr Word8
+        -> CSize
+        -> Ptr Word8
+        -> CSize
+        -> CUInt
+        -> Ptr Word8
+        -> CSize
+        -> IO ()
 
 foreign import ccall unsafe "crypton_pbkdf2.h crypton_fastpbkdf2_hmac_sha256"
-    c_crypton_fastpbkdf2_hmac_sha256 :: Ptr Word8 -> CSize
-                                        -> Ptr Word8 -> CSize
-                                        -> CUInt
-                                        -> Ptr Word8 -> CSize
-                                        -> IO ()
+    c_crypton_fastpbkdf2_hmac_sha256
+        :: Ptr Word8
+        -> CSize
+        -> Ptr Word8
+        -> CSize
+        -> CUInt
+        -> Ptr Word8
+        -> CSize
+        -> IO ()
 
 foreign import ccall unsafe "crypton_pbkdf2.h crypton_fastpbkdf2_hmac_sha512"
-    c_crypton_fastpbkdf2_hmac_sha512 :: Ptr Word8 -> CSize
-                                        -> Ptr Word8 -> CSize
-                                        -> CUInt
-                                        -> Ptr Word8 -> CSize
-                                        -> IO ()
+    c_crypton_fastpbkdf2_hmac_sha512
+        :: Ptr Word8
+        -> CSize
+        -> Ptr Word8
+        -> CSize
+        -> CUInt
+        -> Ptr Word8
+        -> CSize
+        -> IO ()
diff --git a/Crypto/KDF/Scrypt.hs b/Crypto/KDF/Scrypt.hs
--- a/Crypto/KDF/Scrypt.hs
+++ b/Crypto/KDF/Scrypt.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+
 -- |
 -- Module      : Crypto.KDF.Scrypt
 -- License     : BSD-style
@@ -8,42 +11,45 @@
 -- Scrypt key derivation function as defined in Colin Percival's paper
 -- "Stronger Key Derivation via Sequential Memory-Hard Functions"
 -- <http://www.tarsnap.com/scrypt/scrypt.pdf>.
---
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE ForeignFunctionInterface #-}
-module Crypto.KDF.Scrypt
-    ( Parameters(..)
-    , generate
-    ) where
+module Crypto.KDF.Scrypt (
+    Parameters (..),
+    generate,
+) where
 
-import           Data.Word
-import           Foreign.Marshal.Alloc
-import           Foreign.Ptr (Ptr, plusPtr)
-import           Control.Monad (forM_)
+import Control.Monad (forM_)
+import Data.Word
+import Foreign.Marshal.Alloc
+import Foreign.Ptr (Ptr, plusPtr)
 
-import           Crypto.Hash (SHA256(..))
-import qualified Crypto.KDF.PBKDF2 as PBKDF2
-import           Crypto.Internal.Compat (popCount, unsafeDoIO)
-import           Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
+import Crypto.Hash (SHA256 (..))
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B
+import Crypto.Internal.Compat (popCount, unsafeDoIO)
+import qualified Crypto.KDF.PBKDF2 as PBKDF2
 
 -- | Parameters for Scrypt
 data Parameters = Parameters
-    { n            :: Word64 -- ^ Cpu/Memory cost ratio. must be a power of 2 greater than 1. also known as N.
-    , r            :: Int    -- ^ Must satisfy r * p < 2^30
-    , p            :: Int    -- ^ Must satisfy r * p < 2^30
-    , outputLength :: Int    -- ^ the number of bytes to generate out of Scrypt
+    { n :: Word64
+    -- ^ Cpu/Memory cost ratio. must be a power of 2 greater than 1. also known as N.
+    , r :: Int
+    -- ^ Must satisfy r * p < 2^30
+    , p :: Int
+    -- ^ Must satisfy r * p < 2^30
+    , outputLength :: Int
+    -- ^ the number of bytes to generate out of Scrypt
     }
 
 foreign import ccall "crypton_scrypt_smix"
-    ccrypton_scrypt_smix :: Ptr Word8 -> Word32 -> Word64 -> Ptr Word8 -> Ptr Word8 -> IO ()
+    ccrypton_scrypt_smix
+        :: Ptr Word8 -> Word32 -> Word64 -> Ptr Word8 -> Ptr Word8 -> IO ()
 
 -- | Generate the scrypt key derivation data
-generate :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray output)
-         => Parameters
-         -> password
-         -> salt
-         -> output
+generate
+    :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray output)
+    => Parameters
+    -> password
+    -> salt
+    -> output
 generate params password salt
     | r params * p params >= 0x40000000 =
         error "Scrypt: invalid parameters: r and p constraint"
@@ -52,13 +58,23 @@
     | otherwise = unsafeDoIO $ do
         let b = PBKDF2.generate prf (PBKDF2.Parameters 1 intLen) password salt :: B.Bytes
         newSalt <- B.copy b $ \bPtr ->
-            allocaBytesAligned (128*(fromIntegral $ n params)*(r params)) 8 $ \v ->
-            allocaBytesAligned (256*r params + 64) 8 $ \xy -> do
-                forM_ [0..(p params-1)] $ \i ->
-                    ccrypton_scrypt_smix (bPtr `plusPtr` (i * 128 * (r params)))
-                                            (fromIntegral $ r params) (n params) v xy
+            allocaBytesAligned (128 * (fromIntegral $ n params) * (r params)) 8 $ \v ->
+                allocaBytesAligned (256 * r params + 64) 8 $ \xy -> do
+                    forM_ [0 .. (p params - 1)] $ \i ->
+                        ccrypton_scrypt_smix
+                            (bPtr `plusPtr` (i * 128 * (r params)))
+                            (fromIntegral $ r params)
+                            (n params)
+                            v
+                            xy
 
-        return $ PBKDF2.generate prf (PBKDF2.Parameters 1 (outputLength params)) password (newSalt :: B.Bytes)
-  where prf    = PBKDF2.prfHMAC SHA256
-        intLen = p params * 128 * r params
+        return $
+            PBKDF2.generate
+                prf
+                (PBKDF2.Parameters 1 (outputLength params))
+                password
+                (newSalt :: B.Bytes)
+  where
+    prf = PBKDF2.prfHMAC SHA256
+    intLen = p params * 128 * r params
 {-# NOINLINE generate #-}
diff --git a/Crypto/MAC/CMAC.hs b/Crypto/MAC/CMAC.hs
--- a/Crypto/MAC/CMAC.hs
+++ b/Crypto/MAC/CMAC.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.MAC.CMAC
 -- License     : BSD-style
@@ -8,20 +10,19 @@
 -- Provide the CMAC (Cipher based Message Authentification Code) base algorithm.
 -- <http://en.wikipedia.org/wiki/CMAC>
 -- <http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf>
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.MAC.CMAC
-    ( cmac
-    , CMAC
-    , subKeys
-    ) where
+module Crypto.MAC.CMAC (
+    cmac,
+    CMAC,
+    subKeys,
+) where
 
-import           Data.Word
-import           Data.Bits (setBit, testBit, shiftL)
-import           Data.List (foldl')
+import Data.Bits (setBit, shiftL, testBit)
+import Data.List (foldl')
+import Data.Word
+import Prelude hiding (foldl')
 
-import           Crypto.Cipher.Types
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray, Bytes)
+import Crypto.Cipher.Types
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, Bytes)
 import qualified Crypto.Internal.ByteArray as B
 
 -- | Authentication code
@@ -29,13 +30,17 @@
     deriving (ByteArrayAccess)
 
 instance Eq (CMAC a) where
-  CMAC b1 == CMAC b2  =  B.constEq b1 b2
+    CMAC b1 == CMAC b2 = B.constEq b1 b2
 
 -- | compute a MAC using the supplied cipher
-cmac :: (ByteArrayAccess bin, BlockCipher cipher)
-     => cipher      -- ^ key to compute CMAC with
-     -> bin         -- ^ input message
-     -> CMAC cipher -- ^ output tag
+cmac
+    :: (ByteArrayAccess bin, BlockCipher cipher)
+    => cipher
+    -- ^ key to compute CMAC with
+    -> bin
+    -- ^ input message
+    -> CMAC cipher
+    -- ^ output tag
 cmac k msg =
     CMAC $ foldl' (\c m -> ecbEncrypt k $ bxor c m) zeroV ms
   where
@@ -45,54 +50,62 @@
     ms = cmacChunks k k1 k2 $ B.convert msg
 
 cmacChunks :: (BlockCipher k, ByteArray ba) => k -> ba -> ba -> ba -> [ba]
-cmacChunks k k1 k2  =  rec'  where
+cmacChunks k k1 k2 = rec'
+  where
     rec' msg
-      | B.null tl  =  if lack == 0
-                      then  [bxor k1 hd]
-                      else  [bxor k2 $ hd `B.append` B.pack (0x80 : replicate (lack - 1) 0)]
-      | otherwise  =        hd : rec' tl
+        | B.null tl =
+            if lack == 0
+                then [bxor k1 hd]
+                else [bxor k2 $ hd `B.append` B.pack (0x80 : replicate (lack - 1) 0)]
+        | otherwise = hd : rec' tl
       where
-          bytes = blockSize k
-          (hd, tl) = B.splitAt bytes msg
-          lack = bytes - B.length hd
+        bytes = blockSize k
+        (hd, tl) = B.splitAt bytes msg
+        lack = bytes - B.length hd
 
 -- | make sub-keys used in CMAC
-subKeys :: (BlockCipher k, ByteArray ba)
-        => k         -- ^ key to compute CMAC with
-        -> (ba, ba)  -- ^ sub-keys to compute CMAC
-subKeys k = (k1, k2)   where
+subKeys
+    :: (BlockCipher k, ByteArray ba)
+    => k
+    -- ^ key to compute CMAC with
+    -> (ba, ba)
+    -- ^ sub-keys to compute CMAC
+subKeys k = (k1, k2)
+  where
     ipt = cipherIPT k
     k0 = ecbEncrypt k $ B.replicate (blockSize k) 0
     k1 = subKey ipt k0
     k2 = subKey ipt k1
 
 -- polynomial multiply operation to culculate subkey
-subKey :: (ByteArray ba) => [Word8] -> ba -> ba
-subKey ipt ws  =  case B.unpack ws of
-    []                  ->  B.empty
-    w:_  | testBit w 7  ->  B.pack ipt `bxor` shiftL1 ws
-         | otherwise    ->  shiftL1 ws
+subKey :: ByteArray ba => [Word8] -> ba -> ba
+subKey ipt ws = case B.unpack ws of
+    [] -> B.empty
+    w : _
+        | testBit w 7 -> B.pack ipt `bxor` shiftL1 ws
+        | otherwise -> shiftL1 ws
 
-shiftL1 :: (ByteArray ba) => ba -> ba
+shiftL1 :: ByteArray ba => ba -> ba
 shiftL1 = B.pack . shiftL1W . B.unpack
 
 shiftL1W :: [Word8] -> [Word8]
-shiftL1W []         =  []
-shiftL1W ws@(_:ns)  =  rec' $ zip ws (ns ++ [0])   where
-    rec'  []         =  []
-    rec' ((x,y):ps)  =  w : rec' ps
+shiftL1W [] = []
+shiftL1W ws@(_ : ns) = rec' $ zip ws (ns ++ [0])
+  where
+    rec' [] = []
+    rec' ((x, y) : ps) = w : rec' ps
       where
-          w | testBit y 7  =  setBit sl1 0
-            | otherwise    =  sl1
-            where     sl1 = shiftL x 1
+        w
+            | testBit y 7 = setBit sl1 0
+            | otherwise = sl1
+          where
+            sl1 = shiftL x 1
 
 bxor :: ByteArray ba => ba -> ba -> ba
 bxor = B.xor
 
-
 -----
 
-
 cipherIPT :: BlockCipher k => k -> [Word8]
 cipherIPT = expandIPT . blockSize
 
@@ -104,29 +117,44 @@
 -- It represents that the smallest irreducible binary polynomial of degree 128
 -- is x^128 + x^7 + x^2 + x^1 + 1.
 data IPolynomial
-  = Q Int Int Int
+    = Q Int Int Int
+
 ---  | T Int
 
 iPolynomial :: Int -> Maybe IPolynomial
-iPolynomial = d  where
-    d   64  =  Just $ Q 4 3 1
-    d  128  =  Just $ Q 7 2 1
-    d    _  =  Nothing
+iPolynomial = d
+  where
+    d 64 = Just $ Q 4 3 1
+    d 128 = Just $ Q 7 2 1
+    d _ = Nothing
 
 -- Expand a tail bit pattern of irreducible binary polynomial
 expandIPT :: Int -> [Word8]
-expandIPT bytes = expandIPT' bytes ipt  where
-    ipt = maybe (error $ "Irreducible binary polynomial not defined against " ++ show nb ++ " bit") id
-          $ iPolynomial nb
+expandIPT bytes = expandIPT' bytes ipt
+  where
+    ipt =
+        maybe
+            ( error $
+                "Irreducible binary polynomial not defined against " ++ show nb ++ " bit"
+            )
+            id
+            $ iPolynomial nb
     nb = bytes * 8
 
 -- Expand a tail bit pattern of irreducible binary polynomial
-expandIPT' :: Int         -- ^ width in byte
-           -> IPolynomial -- ^ irreducible binary polynomial definition
-           -> [Word8]     -- ^ result bit pattern
+expandIPT'
+    :: Int
+    -- ^ width in byte
+    -> IPolynomial
+    -- ^ irreducible binary polynomial definition
+    -> [Word8]
+    -- ^ result bit pattern
 expandIPT' bytes (Q x y z) =
     reverse . setB x . setB y . setB z . setB 0 $ replicate bytes 0
   where
-    setB i ws =  hd ++ setBit (head tl) r : tail tl  where
+    setB i ws = case tl of
+        (a : as) -> hd ++ setBit a r : as
+        _ -> error "expandIPT'"
+      where
         (q, r) = i `quotRem` 8
         (hd, tl) = splitAt q ws
diff --git a/Crypto/MAC/HMAC.hs b/Crypto/MAC/HMAC.hs
--- a/Crypto/MAC/HMAC.hs
+++ b/Crypto/MAC/HMAC.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.MAC.HMAC
 -- License     : BSD-style
@@ -7,52 +10,56 @@
 --
 -- Provide the HMAC (Hash based Message Authentification Code) base algorithm.
 -- <http://en.wikipedia.org/wiki/HMAC>
---
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.MAC.HMAC
-    ( hmac
-    , hmacLazy
-    , HMAC(..)
+module Crypto.MAC.HMAC (
+    hmac,
+    hmacLazy,
+    HMAC (..),
+
     -- * Incremental
-    , Context(..)
-    , initialize
-    , update
-    , updates
-    , finalize
-    ) where
+    Context (..),
+    initialize,
+    update,
+    updates,
+    finalize,
+) where
 
-import           Crypto.Hash hiding (Context)
+import Crypto.Hash hiding (Context)
 import qualified Crypto.Hash as Hash (Context)
-import           Crypto.Hash.IO
-import           Crypto.Internal.ByteArray (ScrubbedBytes, ByteArrayAccess)
+import Crypto.Hash.IO
+import Crypto.Internal.ByteArray (ByteArrayAccess, ScrubbedBytes)
 import qualified Crypto.Internal.ByteArray as B
-import           Data.Memory.PtrMethods
-import           Crypto.Internal.Compat
+import Crypto.Internal.Compat
 import qualified Data.ByteString.Lazy as L
+import Data.Memory.PtrMethods
 
 -- | Represent an HMAC that is a phantom type with the hash used to produce the mac.
 --
 -- The Eq instance is constant time.  No Show instance is provided, to avoid
 -- printing by mistake.
-newtype HMAC a = HMAC { hmacGetDigest :: Digest a }
+newtype HMAC a = HMAC {hmacGetDigest :: Digest a}
     deriving (ByteArrayAccess)
 
 instance Eq (HMAC a) where
     (HMAC b1) == (HMAC b2) = B.constEq b1 b2
 
 -- | Compute a MAC using the supplied hashing function
-hmac :: (ByteArrayAccess key, ByteArrayAccess message, HashAlgorithm a)
-     => key     -- ^ Secret key
-     -> message -- ^ Message to MAC
-     -> HMAC a
+hmac
+    :: (ByteArrayAccess key, ByteArrayAccess message, HashAlgorithm a)
+    => key
+    -- ^ Secret key
+    -> message
+    -- ^ Message to MAC
+    -> HMAC a
 hmac secret msg = finalize $ updates (initialize secret) [msg]
 
 -- | Compute a MAC using the supplied hashing function, for a lazy input
-hmacLazy :: (ByteArrayAccess key, HashAlgorithm a)
-     => key     -- ^ Secret key
-     -> L.ByteString -- ^ Message to MAC
-     -> HMAC a
+hmacLazy
+    :: (ByteArrayAccess key, HashAlgorithm a)
+    => key
+    -- ^ Secret key
+    -> L.ByteString
+    -- ^ Message to MAC
+    -> HMAC a
 hmacLazy secret msg = finalize $ updates (initialize secret) (L.toChunks msg)
 
 -- | Represent an ongoing HMAC state, that can be appended with 'update'
@@ -60,64 +67,79 @@
 data Context hashalg = Context !(Hash.Context hashalg) !(Hash.Context hashalg)
 
 -- | Initialize a new incremental HMAC context
-initialize :: (ByteArrayAccess key, HashAlgorithm a)
-           => key       -- ^ Secret key
-           -> Context a
+initialize
+    :: (ByteArrayAccess key, HashAlgorithm a)
+    => key
+    -- ^ Secret key
+    -> Context a
 initialize secret = unsafeDoIO (doHashAlg undefined)
   where
-        doHashAlg :: HashAlgorithm a => a -> IO (Context a)
-        doHashAlg alg = do
-            !withKey <- case B.length secret `compare` blockSize of
-                            EQ -> return $ B.withByteArray secret
-                            LT -> do key <- B.alloc blockSize $ \k -> do
-                                        memSet k 0 blockSize
-                                        B.withByteArray secret $ \s -> memCopy k s (B.length secret)
-                                     return $ B.withByteArray (key :: ScrubbedBytes)
-                            GT -> do
-                                -- hash the secret key
-                                ctx <- hashMutableInitWith alg
-                                hashMutableUpdate ctx secret
-                                digest <- hashMutableFinalize ctx
-                                hashMutableReset ctx
-                                -- pad it if necessary
-                                if digestSize < blockSize
-                                    then do
-                                        key <- B.alloc blockSize $ \k -> do
-                                            memSet k 0 blockSize
-                                            B.withByteArray digest $ \s -> memCopy k s (B.length digest)
-                                        return $ B.withByteArray (key :: ScrubbedBytes)
-                                    else
-                                       return $ B.withByteArray digest
-            (inner, outer) <- withKey $ \keyPtr ->
-                (,) <$> B.alloc blockSize (\p -> memXorWith p 0x36 keyPtr blockSize)
-                    <*> B.alloc blockSize (\p -> memXorWith p 0x5c keyPtr blockSize)
-            return $ Context (hashUpdates initCtx [outer :: ScrubbedBytes])
-                             (hashUpdates initCtx [inner :: ScrubbedBytes])
-          where 
-                blockSize  = hashBlockSize alg
-                digestSize = hashDigestSize alg
-                initCtx    = hashInitWith alg
+    doHashAlg :: HashAlgorithm a => a -> IO (Context a)
+    doHashAlg alg = do
+        !withKey <- case B.length secret `compare` blockSize of
+            EQ -> return $ B.withByteArray secret
+            LT -> do
+                key <- B.alloc blockSize $ \k -> do
+                    memSet k 0 blockSize
+                    B.withByteArray secret $ \s -> memCopy k s (B.length secret)
+                return $ B.withByteArray (key :: ScrubbedBytes)
+            GT -> do
+                -- hash the secret key
+                ctx <- hashMutableInitWith alg
+                hashMutableUpdate ctx secret
+                digest <- hashMutableFinalize ctx
+                hashMutableReset ctx
+                -- pad it if necessary
+                if digestSize < blockSize
+                    then do
+                        key <- B.alloc blockSize $ \k -> do
+                            memSet k 0 blockSize
+                            B.withByteArray digest $ \s -> memCopy k s (B.length digest)
+                        return $ B.withByteArray (key :: ScrubbedBytes)
+                    else
+                        return $ B.withByteArray digest
+        (inner, outer) <- withKey $ \keyPtr ->
+            (,)
+                <$> B.alloc blockSize (\p -> memXorWith p 0x36 keyPtr blockSize)
+                <*> B.alloc blockSize (\p -> memXorWith p 0x5c keyPtr blockSize)
+        return $
+            Context
+                (hashUpdates initCtx [outer :: ScrubbedBytes])
+                (hashUpdates initCtx [inner :: ScrubbedBytes])
+      where
+        blockSize = hashBlockSize alg
+        digestSize = hashDigestSize alg
+        initCtx = hashInitWith alg
 {-# NOINLINE initialize #-}
 
 -- | Incrementally update a HMAC context
-update :: (ByteArrayAccess message, HashAlgorithm a)
-       => Context a  -- ^ Current HMAC context
-       -> message    -- ^ Message to append to the MAC
-       -> Context a  -- ^ Updated HMAC context
+update
+    :: (ByteArrayAccess message, HashAlgorithm a)
+    => Context a
+    -- ^ Current HMAC context
+    -> message
+    -- ^ Message to append to the MAC
+    -> Context a
+    -- ^ Updated HMAC context
 update (Context octx ictx) msg =
     Context octx (hashUpdate ictx msg)
 
 -- | Increamentally update a HMAC context with multiple inputs
-updates :: (ByteArrayAccess message, HashAlgorithm a)
-        => Context a -- ^ Current HMAC context
-        -> [message] -- ^ Messages to append to the MAC
-        -> Context a -- ^ Updated HMAC context
+updates
+    :: (ByteArrayAccess message, HashAlgorithm a)
+    => Context a
+    -- ^ Current HMAC context
+    -> [message]
+    -- ^ Messages to append to the MAC
+    -> Context a
+    -- ^ Updated HMAC context
 updates (Context octx ictx) msgs =
     Context octx (hashUpdates ictx msgs)
 
 -- | Finalize a HMAC context and return the HMAC.
-finalize :: HashAlgorithm a
-         => Context a
-         -> HMAC a
+finalize
+    :: HashAlgorithm a
+    => Context a
+    -> HMAC a
 finalize (Context octx ictx) =
     HMAC $ hashFinalize $ hashUpdates octx [hashFinalize ictx]
diff --git a/Crypto/MAC/KMAC.hs b/Crypto/MAC/KMAC.hs
--- a/Crypto/MAC/KMAC.hs
+++ b/Crypto/MAC/KMAC.hs
@@ -1,3 +1,7 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- |
 -- Module      : Crypto.MAC.KMAC
 -- License     : BSD-style
@@ -7,38 +11,41 @@
 --
 -- Provide the KMAC (Keccak Message Authentication Code) algorithm, derived from
 -- the SHA-3 base algorithm Keccak and defined in NIST SP800-185.
---
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-module Crypto.MAC.KMAC
-    ( HashSHAKE
-    , kmac
-    , KMAC(..)
+module Crypto.MAC.KMAC (
+    HashSHAKE,
+    kmac,
+    KMAC (..),
+
     -- * Incremental
-    , Context
-    , initialize
-    , update
-    , updates
-    , finalize
-    ) where
+    Context,
+    initialize,
+    update,
+    updates,
+    finalize,
+) where
 
 import qualified Crypto.Hash as H
-import           Crypto.Hash.SHAKE (HashSHAKE(..))
-import           Crypto.Hash.Types (HashAlgorithm(..), Digest(..))
+import Crypto.Hash.SHAKE (HashSHAKE (..))
+import Crypto.Hash.Types (Digest (..), HashAlgorithm (..))
 import qualified Crypto.Hash.Types as H
-import           Crypto.Internal.Builder
-import           Crypto.Internal.Imports
-import           Foreign.Ptr (Ptr)
-import           Data.Bits (shiftR)
-import           Data.ByteArray (ByteArrayAccess)
+import Crypto.Internal.Builder
+import Crypto.Internal.ByteArray (allocAndFreezePrim)
+import Crypto.Internal.Imports
+import Data.Bits (shiftR)
+import Data.ByteArray (ByteArrayAccess)
 import qualified Data.ByteArray as B
-
+import Foreign.Ptr (Ptr)
 
 -- cSHAKE
 
-cshakeInit :: forall a name string prefix . (HashSHAKE a, ByteArrayAccess name, ByteArrayAccess string, ByteArrayAccess prefix)
-           => name -> string -> prefix -> H.Context a
+cshakeInit
+    :: forall a name string prefix
+     . ( HashSHAKE a
+       , ByteArrayAccess name
+       , ByteArrayAccess string
+       , ByteArrayAccess prefix
+       )
+    => name -> string -> prefix -> H.Context a
 cshakeInit n s p = H.Context $ B.allocAndFreeze c $ \(ptr :: Ptr (H.Context a)) -> do
     hashInternalInit ptr
     B.withByteArray b $ \d -> hashInternalUpdate ptr d (fromIntegral $ B.length b)
@@ -49,24 +56,28 @@
     x = encodeString n <> encodeString s
     b = buildAndFreeze (bytepad x w) :: B.Bytes
 
-cshakeUpdate :: (HashSHAKE a, ByteArrayAccess ba)
-             => H.Context a -> ba -> H.Context a
+cshakeUpdate
+    :: (HashSHAKE a, ByteArrayAccess ba)
+    => H.Context a -> ba -> H.Context a
 cshakeUpdate = H.hashUpdate
 
-cshakeUpdates :: (HashSHAKE a, ByteArrayAccess ba)
-              => H.Context a -> [ba] -> H.Context a
+cshakeUpdates
+    :: (HashSHAKE a, ByteArrayAccess ba)
+    => H.Context a -> [ba] -> H.Context a
 cshakeUpdates = H.hashUpdates
 
-cshakeFinalize :: forall a suffix . (HashSHAKE a, ByteArrayAccess suffix)
-               => H.Context a -> suffix -> Digest a
-cshakeFinalize !c s =
-    Digest $ B.allocAndFreeze (hashDigestSize (undefined :: a)) $ \dig -> do
-        ((!_) :: B.Bytes) <- B.copy c $ \(ctx :: Ptr (H.Context a)) -> do
-            B.withByteArray s $ \d ->
-                hashInternalUpdate ctx d (fromIntegral $ B.length s)
-            cshakeInternalFinalize ctx dig
-        return ()
-
+cshakeFinalize
+    :: forall a suffix
+     . (HashSHAKE a, ByteArrayAccess suffix)
+    => H.Context a -> suffix -> Digest a
+cshakeFinalize !c s = Digest $
+    allocAndFreezePrim (hashDigestSize (undefined :: a)) $
+        \(dig :: Ptr (Digest a)) -> do
+            ((!_) :: B.Bytes) <- B.copy c $ \(ctx :: Ptr (H.Context a)) -> do
+                B.withByteArray s $ \d ->
+                    hashInternalUpdate ctx d (fromIntegral $ B.length s)
+                cshakeInternalFinalize ctx dig
+            return ()
 
 -- KMAC
 
@@ -75,15 +86,16 @@
 --
 -- The Eq instance is constant time.  No Show instance is provided, to avoid
 -- printing by mistake.
-newtype KMAC a = KMAC { kmacGetDigest :: Digest a }
-    deriving (ByteArrayAccess,NFData)
+newtype KMAC a = KMAC {kmacGetDigest :: Digest a}
+    deriving (ByteArrayAccess, NFData)
 
 instance Eq (KMAC a) where
     (KMAC b1) == (KMAC b2) = B.constEq b1 b2
 
 -- | Compute a KMAC using the supplied customization string and key.
-kmac :: (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key, ByteArrayAccess ba)
-     => string -> key -> ba -> KMAC a
+kmac
+    :: (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key, ByteArrayAccess ba)
+    => string -> key -> ba -> KMAC a
 kmac str key msg = finalize $ updates (initialize str key) [msg]
 
 -- | Represent an ongoing KMAC state, that can be appended with 'update' and
@@ -92,11 +104,13 @@
 
 -- | Initialize a new incremental KMAC context with the supplied customization
 -- string and key.
-initialize :: forall a string key . (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key)
-           => string -> key -> Context a
+initialize
+    :: forall a string key
+     . (HashSHAKE a, ByteArrayAccess string, ByteArrayAccess key)
+    => string -> key -> Context a
 initialize str key = Context $ cshakeInit n str p
   where
-    n = B.pack [75,77,65,67] :: B.Bytes  -- "KMAC"
+    n = B.pack [75, 77, 65, 67] :: B.Bytes -- "KMAC"
     w = hashBlockSize (undefined :: a)
     p = buildAndFreeze (bytepad (encodeString key) w) :: B.ScrubbedBytes
 
@@ -109,13 +123,12 @@
 updates (Context ctx) = Context . cshakeUpdates ctx
 
 -- | Finalize a KMAC context and return the KMAC.
-finalize :: forall a . HashSHAKE a => Context a -> KMAC a
+finalize :: forall a. HashSHAKE a => Context a -> KMAC a
 finalize (Context ctx) = KMAC $ cshakeFinalize ctx suffix
   where
     l = cshakeOutputLength (undefined :: a)
     suffix = buildAndFreeze (rightEncode l) :: B.Bytes
 
-
 -- Utilities
 
 bytepad :: Builder -> Int -> Builder
@@ -131,14 +144,15 @@
 leftEncode x = byte len <> digits
   where
     digits = i2osp x
-    len    = fromIntegral (builderLength digits)
+    len = fromIntegral (builderLength digits)
 
 rightEncode :: Int -> Builder
 rightEncode x = digits <> byte len
   where
     digits = i2osp x
-    len    = fromIntegral (builderLength digits)
+    len = fromIntegral (builderLength digits)
 
 i2osp :: Int -> Builder
-i2osp i | i >= 256  = i2osp (shiftR i 8) <> byte (fromIntegral i)
-        | otherwise = byte (fromIntegral i)
+i2osp i
+    | i >= 256 = i2osp (shiftR i 8) <> byte (fromIntegral i)
+    | otherwise = byte (fromIntegral i)
diff --git a/Crypto/MAC/KeyedBlake2.hs b/Crypto/MAC/KeyedBlake2.hs
--- a/Crypto/MAC/KeyedBlake2.hs
+++ b/Crypto/MAC/KeyedBlake2.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- |
 -- Module      : Crypto.MAC.KeyedBlake2
 -- License     : BSD-style
@@ -7,33 +10,29 @@
 --
 -- Expose a MAC interface to the keyed Blake2 algorithms
 -- defined in RFC 7693.
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE ScopedTypeVariables #-}
+module Crypto.MAC.KeyedBlake2 (
+    HashBlake2,
+    KeyedBlake2 (..),
+    keyedBlake2,
+    keyedBlake2Lazy,
 
-module Crypto.MAC.KeyedBlake2
-    ( HashBlake2
-    , KeyedBlake2(..)
-    , keyedBlake2
-    , keyedBlake2Lazy
     -- * Incremental
-    , Context
-    , initialize
-    , update
-    , updates
-    , finalize
-    ) where
+    Context,
+    initialize,
+    update,
+    updates,
+    finalize,
+) where
 
 import qualified Crypto.Hash as H
+import Crypto.Hash.Blake2
 import qualified Crypto.Hash.Types as H
-import           Crypto.Hash.Blake2
-import           Crypto.Internal.DeepSeq (NFData)
+import Crypto.Internal.DeepSeq (NFData)
+import Data.ByteArray (ByteArrayAccess)
 import qualified Data.ByteArray as B
-import           Data.ByteArray (ByteArrayAccess)
 import qualified Data.ByteString.Lazy as L
 
-import           Foreign.Ptr (Ptr)
-
+import Foreign.Ptr (Ptr)
 
 -- Keyed Blake2b
 
@@ -42,8 +41,8 @@
 --
 -- The Eq instance is constant time.  No Show instance is provided, to avoid
 -- printing by mistake.
-newtype KeyedBlake2 a = KeyedBlake2 { keyedBlake2GetDigest :: H.Digest a }
-    deriving (ByteArrayAccess,NFData)
+newtype KeyedBlake2 a = KeyedBlake2 {keyedBlake2GetDigest :: H.Digest a}
+    deriving (ByteArrayAccess, NFData)
 
 instance Eq (KeyedBlake2 a) where
     KeyedBlake2 x == KeyedBlake2 y = B.constEq x y
@@ -53,17 +52,20 @@
 newtype Context a = Context (H.Context a)
 
 -- | Initialize a new incremental keyed Blake2 context with the supplied key.
-initialize :: forall a key . (HashBlake2 a, ByteArrayAccess key)
-           => key -> Context a
+initialize
+    :: forall a key
+     . (HashBlake2 a, ByteArrayAccess key)
+    => key -> Context a
 initialize k = Context $ H.Context $ B.allocAndFreeze ctxSz performInit
-    where ctxSz = H.hashInternalContextSize (undefined :: a)
-          digestSz = H.hashDigestSize (undefined :: a)
-          -- cap the number of key bytes at digestSz,
-          -- since that's the maximal key size
-          keyByteLen = min (B.length k) digestSz
-          performInit :: Ptr (H.Context a) -> IO ()
-          performInit ptr = B.withByteArray k
-            $ \keyPtr -> blake2InternalKeyedInit ptr keyPtr (fromIntegral keyByteLen)
+  where
+    ctxSz = H.hashInternalContextSize (undefined :: a)
+    digestSz = H.hashDigestSize (undefined :: a)
+    -- cap the number of key bytes at digestSz,
+    -- since that's the maximal key size
+    keyByteLen = min (B.length k) digestSz
+    performInit :: Ptr (H.Context a) -> IO ()
+    performInit ptr = B.withByteArray k $
+        \keyPtr -> blake2InternalKeyedInit ptr keyPtr (fromIntegral keyByteLen)
 
 -- | Incrementally update a keyed Blake2 context.
 update :: (HashBlake2 a, ByteArrayAccess ba) => Context a -> ba -> Context a
@@ -78,11 +80,13 @@
 finalize (Context ctx) = KeyedBlake2 $ H.hashFinalize ctx
 
 -- | Compute a Blake2 MAC using the supplied key.
-keyedBlake2 :: (HashBlake2 a, ByteArrayAccess key, ByteArrayAccess ba)
-            => key -> ba -> KeyedBlake2 a
+keyedBlake2
+    :: (HashBlake2 a, ByteArrayAccess key, ByteArrayAccess ba)
+    => key -> ba -> KeyedBlake2 a
 keyedBlake2 key msg = finalize $ update (initialize key) msg
 
 -- | Compute a Blake2 MAC using the supplied key, for a lazy input.
-keyedBlake2Lazy :: (HashBlake2 a, ByteArrayAccess key)
-            => key -> L.ByteString -> KeyedBlake2 a
+keyedBlake2Lazy
+    :: (HashBlake2 a, ByteArrayAccess key)
+    => key -> L.ByteString -> KeyedBlake2 a
 keyedBlake2Lazy key msg = finalize $ updates (initialize key) (L.toChunks msg)
diff --git a/Crypto/MAC/Poly1305.hs b/Crypto/MAC/Poly1305.hs
--- a/Crypto/MAC/Poly1305.hs
+++ b/Crypto/MAC/Poly1305.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
 
 -- |
 -- Module      : Crypto.MAC.Poly1305
@@ -7,30 +9,33 @@
 -- Portability : unknown
 --
 -- Poly1305 implementation
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.MAC.Poly1305
-    ( Ctx
-    , State
-    , Auth(..)
-    , authTag
+module Crypto.MAC.Poly1305 (
+    Ctx,
+    State,
+    Auth (..),
+    authTag,
+
     -- * Incremental MAC Functions
-    , initialize -- :: State
-    , update     -- :: State -> ByteString -> State
-    , updates    -- :: State -> [ByteString] -> State
-    , finalize   -- :: State -> Auth
+    initialize, -- :: State
+    update, -- :: State -> ByteString -> State
+    updates, -- :: State -> [ByteString] -> State
+    finalize, -- :: State -> Auth
+
     -- * One-pass MAC function
-    , auth
-    ) where
+    auth,
+) where
 
-import           Foreign.Ptr
-import           Foreign.C.Types
-import           Data.Word
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ScrubbedBytes, Bytes)
+import Crypto.Error
+import Crypto.Internal.ByteArray (
+    ByteArrayAccess,
+    Bytes,
+    ScrubbedBytes,
+ )
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.DeepSeq
-import           Crypto.Error
+import Crypto.Internal.DeepSeq
+import Data.Word
+import Foreign.C.Types
+import Foreign.Ptr
 
 -- | Poly1305 State
 --
@@ -43,16 +48,17 @@
 
 -- | Poly1305 State. use State instead of Ctx
 type Ctx = State
+
 {-# DEPRECATED Ctx "use Poly1305 State instead" #-}
 
 -- | Poly1305 Auth
 newtype Auth = Auth Bytes
-    deriving (ByteArrayAccess,NFData)
+    deriving (ByteArrayAccess, NFData)
 
 authTag :: ByteArrayAccess b => b -> CryptoFailable Auth
 authTag b
     | B.length b /= 16 = CryptoFailed $ CryptoError_AuthenticationTagSizeInvalid
-    | otherwise        = CryptoPassed $ Auth $ B.convert b
+    | otherwise = CryptoPassed $ Auth $ B.convert b
 
 instance Eq Auth where
     (Auth a1) == (Auth a2) = B.constEq a1 a2
@@ -67,12 +73,13 @@
     c_poly1305_finalize :: Ptr Word8 -> Ptr State -> IO ()
 
 -- | initialize a Poly1305 context
-initialize :: ByteArrayAccess key
-           => key
-           -> CryptoFailable State
+initialize
+    :: ByteArrayAccess key
+    => key
+    -> CryptoFailable State
 initialize key
     | B.length key /= 32 = CryptoFailed $ CryptoError_MacKeyInvalid
-    | otherwise          = CryptoPassed $ State $ B.allocAndFreeze 84 $ \ctxPtr ->
+    | otherwise = CryptoPassed $ State $ B.allocAndFreeze 84 $ \ctxPtr ->
         B.withByteArray key $ \keyPtr ->
             c_poly1305_init (castPtr ctxPtr) keyPtr
 {-# NOINLINE initialize #-}
@@ -87,16 +94,19 @@
 -- | updates a context with multiples bytestring
 updates :: ByteArrayAccess ba => State -> [ba] -> State
 updates (State prevCtx) d = State $ B.copyAndFreeze prevCtx (loop d)
-  where loop []     _      = return ()
-        loop (x:xs) ctxPtr = do
-            B.withByteArray x $ \dataPtr -> c_poly1305_update ctxPtr dataPtr (fromIntegral $ B.length x)
-            loop xs ctxPtr
+  where
+    loop [] _ = return ()
+    loop (x : xs) ctxPtr = do
+        B.withByteArray x $ \dataPtr -> c_poly1305_update ctxPtr dataPtr (fromIntegral $ B.length x)
+        loop xs ctxPtr
 {-# NOINLINE updates #-}
 
 -- | finalize the context into a digest bytestring
 finalize :: State -> Auth
 finalize (State prevCtx) = Auth $ B.allocAndFreeze 16 $ \dst -> do
-    _ <- B.copy prevCtx (\ctxPtr -> c_poly1305_finalize dst (castPtr ctxPtr)) :: IO ScrubbedBytes
+    _ <-
+        B.copy prevCtx (\ctxPtr -> c_poly1305_finalize dst (castPtr ctxPtr))
+            :: IO ScrubbedBytes
     return ()
 {-# NOINLINE finalize #-}
 
@@ -104,13 +114,13 @@
 auth :: (ByteArrayAccess key, ByteArrayAccess ba) => key -> ba -> Auth
 auth key d
     | B.length key /= 32 = error "Poly1305: key length expected 32 bytes"
-    | otherwise          = Auth $ B.allocAndFreeze 16 $ \dst -> do
+    | otherwise = Auth $ B.allocAndFreeze 16 $ \dst -> do
         _ <- B.alloc 84 (onCtx dst) :: IO ScrubbedBytes
         return ()
   where
-        onCtx dst ctxPtr =
-            B.withByteArray key $ \keyPtr -> do
-                c_poly1305_init (castPtr ctxPtr) keyPtr
-                B.withByteArray d $ \dataPtr ->
-                    c_poly1305_update (castPtr ctxPtr) dataPtr (fromIntegral $ B.length d)
-                c_poly1305_finalize dst (castPtr ctxPtr)
+    onCtx dst ctxPtr =
+        B.withByteArray key $ \keyPtr -> do
+            c_poly1305_init (castPtr ctxPtr) keyPtr
+            B.withByteArray d $ \dataPtr ->
+                c_poly1305_update (castPtr ctxPtr) dataPtr (fromIntegral $ B.length d)
+            c_poly1305_finalize dst (castPtr ctxPtr)
diff --git a/Crypto/Number/Basic.hs b/Crypto/Number/Basic.hs
--- a/Crypto/Number/Basic.hs
+++ b/Crypto/Number/Basic.hs
@@ -1,20 +1,20 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.Number.Basic
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
-
-{-# LANGUAGE BangPatterns #-}
-module Crypto.Number.Basic
-    ( sqrti
-    , gcde
-    , areEven
-    , log2
-    , numBits
-    , numBytes
-    , asPowerOf2AndOdd
-    ) where
+module Crypto.Number.Basic (
+    sqrti,
+    gcde,
+    areEven,
+    log2,
+    numBits,
+    numBytes,
+    asPowerOf2AndOdd,
+) where
 
 import Data.Bits
 
@@ -25,46 +25,48 @@
 -- and use a dichotomy algorithm to compute the bound relatively efficiently.
 sqrti :: Integer -> (Integer, Integer)
 sqrti i
-    | i < 0     = error "cannot compute negative square root"
-    | i == 0    = (0,0)
-    | i == 1    = (1,1)
-    | i == 2    = (1,2)
+    | i < 0 = error "cannot compute negative square root"
+    | i == 0 = (0, 0)
+    | i == 1 = (1, 1)
+    | i == 2 = (1, 2)
     | otherwise = loop x0
-        where
-            nbdigits = length $ show i
-            x0n = (if even nbdigits then nbdigits - 2 else nbdigits - 1) `div` 2
-            x0  = if even nbdigits then 2 * 10 ^ x0n else 6 * 10 ^ x0n
-            loop x = case compare (sq x) i of
-                LT -> iterUp x
-                EQ -> (x, x)
-                GT -> iterDown x
-            iterUp lb = if sq ub >= i then iter lb ub else iterUp ub
-                where ub = lb * 2
-            iterDown ub = if sq lb >= i then iterDown lb else iter lb ub
-                where lb = ub `div` 2
-            iter lb ub
-                | lb == ub   = (lb, ub)
-                | lb+1 == ub = (lb, ub)
-                | otherwise  =
-                    let d = (ub - lb) `div` 2 in
-                    if sq (lb + d) >= i
-                        then iter lb (ub-d)
-                        else iter (lb+d) ub
-            sq a = a * a
+  where
+    nbdigits = length $ show i
+    x0n = (if even nbdigits then nbdigits - 2 else nbdigits - 1) `div` 2
+    x0 = if even nbdigits then 2 * 10 ^ x0n else 6 * 10 ^ x0n
+    loop x = case compare (sq x) i of
+        LT -> iterUp x
+        EQ -> (x, x)
+        GT -> iterDown x
+    iterUp lb = if sq ub >= i then iter lb ub else iterUp ub
+      where
+        ub = lb * 2
+    iterDown ub = if sq lb >= i then iterDown lb else iter lb ub
+      where
+        lb = ub `div` 2
+    iter lb ub
+        | lb == ub = (lb, ub)
+        | lb + 1 == ub = (lb, ub)
+        | otherwise =
+            let d = (ub - lb) `div` 2
+             in if sq (lb + d) >= i
+                    then iter lb (ub - d)
+                    else iter (lb + d) ub
+    sq a = a * a
 
 -- | Get the extended GCD of two integer using integer divMod
 --
 -- gcde 'a' 'b' find (x,y,gcd(a,b)) where ax + by = d
---
 gcde :: Integer -> Integer -> (Integer, Integer, Integer)
-gcde a b = onGmpUnsupported (gmpGcde a b) $
-    if d < 0 then (-x,-y,-d) else (x,y,d)
+gcde a b =
+    onGmpUnsupported (gmpGcde a b) $
+        if d < 0 then (-x, -y, -d) else (x, y, d)
   where
-    (d, x, y)                     = f (a,1,0) (b,0,1)
-    f t              (0, _, _)    = t
+    (d, x, y) = f (a, 1, 0) (b, 0, 1)
+    f t (0, _, _) = t
     f (a', sa, ta) t@(b', sb, tb) =
-        let (q, r) = a' `divMod` b' in
-        f t (r, sa - (q * sb), ta - (q * tb))
+        let (q, r) = a' `divMod` b'
+         in f t (r, sa - (q * sb), ta - (q * tb))
 
 -- | Check if a list of integer are all even
 areEven :: [Integer] -> Bool
@@ -75,7 +77,7 @@
 log2 n = onGmpUnsupported (gmpLog2 n) $ imLog 2 n
   where
     -- http://www.haskell.org/pipermail/haskell-cafe/2008-February/039465.html
-    imLog b x = if x < b then 0 else (x `div` b^l) `doDiv` l
+    imLog b x = if x < b then 0 else (x `div` b ^ l) `doDiv` l
       where
         l = 2 * imLog (b * b) x
         doDiv x' l' = if x' < b then l' else (x' `div` b) `doDiv` (l' + 1)
@@ -84,19 +86,36 @@
 -- | Compute the number of bits for an integer
 numBits :: Integer -> Int
 numBits n = gmpSizeInBits n `onGmpUnsupported` (if n == 0 then 1 else computeBits 0 n)
-  where computeBits !acc i
-            | q == 0 =
-                if r >= 0x80 then acc+8
-                else if r >= 0x40 then acc+7
-                else if r >= 0x20 then acc+6
-                else if r >= 0x10 then acc+5
-                else if r >= 0x08 then acc+4
-                else if r >= 0x04 then acc+3
-                else if r >= 0x02 then acc+2
-                else if r >= 0x01 then acc+1
-                else acc -- should be catch by previous loop
-            | otherwise = computeBits (acc+8) q
-          where (q,r) = i `divMod` 256
+  where
+    computeBits !acc i
+        | q == 0 =
+            if r >= 0x80
+                then acc + 8
+                else
+                    if r >= 0x40
+                        then acc + 7
+                        else
+                            if r >= 0x20
+                                then acc + 6
+                                else
+                                    if r >= 0x10
+                                        then acc + 5
+                                        else
+                                            if r >= 0x08
+                                                then acc + 4
+                                                else
+                                                    if r >= 0x04
+                                                        then acc + 3
+                                                        else
+                                                            if r >= 0x02
+                                                                then acc + 2
+                                                                else
+                                                                    if r >= 0x01
+                                                                        then acc + 1
+                                                                        else acc -- should be catch by previous loop
+        | otherwise = computeBits (acc + 8) q
+      where
+        (q, r) = i `divMod` 256
 
 -- | Compute the number of bytes for an integer
 numBytes :: Integer -> Int
@@ -105,12 +124,14 @@
 -- | Express an integer as an odd number and a power of 2
 asPowerOf2AndOdd :: Integer -> (Int, Integer)
 asPowerOf2AndOdd a
-    | a == 0       = (0, 0)
-    | odd a        = (0, a)
-    | a < 0        = let (e, a1) = asPowerOf2AndOdd $ abs a in (e, -a1)
+    | a == 0 = (0, 0)
+    | odd a = (0, a)
+    | a < 0 = let (e, a1) = asPowerOf2AndOdd $ abs a in (e, -a1)
     | isPowerOf2 a = (log2 a, 1)
-    | otherwise    = loop a 0
-        where      
-          isPowerOf2 n = (n /= 0) && ((n .&. (n - 1)) == 0)
-          loop n pw = if n `mod` 2 == 0 then loop (n `div` 2) (pw + 1)
-                      else (pw, n)
+    | otherwise = loop a 0
+  where
+    isPowerOf2 n = (n /= 0) && ((n .&. (n - 1)) == 0)
+    loop n pw =
+        if n `mod` 2 == 0
+            then loop (n `div` 2) (pw + 1)
+            else (pw, n)
diff --git a/Crypto/Number/Compat.hs b/Crypto/Number/Compat.hs
--- a/Crypto/Number/Compat.hs
+++ b/Crypto/Number/Compat.hs
@@ -1,31 +1,32 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE UnboxedTuples #-}
+{-# OPTIONS_GHC -Wno-deprecations #-}
+
 -- |
 -- Module      : Crypto.Number.Compat
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-{-# LANGUAGE CPP           #-}
-{-# LANGUAGE MagicHash     #-}
-{-# LANGUAGE BangPatterns  #-}
-{-# LANGUAGE UnboxedTuples #-}
-module Crypto.Number.Compat
-    ( GmpSupported(..)
-    , onGmpUnsupported
-    , gmpGcde
-    , gmpLog2
-    , gmpPowModSecInteger
-    , gmpPowModInteger
-    , gmpInverse
-    , gmpNextPrime
-    , gmpTestPrimeMillerRabin
-    , gmpSizeInBytes
-    , gmpSizeInBits
-    , gmpExportInteger
-    , gmpExportIntegerLE
-    , gmpImportInteger
-    , gmpImportIntegerLE
-    ) where
+module Crypto.Number.Compat (
+    GmpSupported (..),
+    onGmpUnsupported,
+    gmpGcde,
+    gmpLog2,
+    gmpPowModSecInteger,
+    gmpPowModInteger,
+    gmpInverse,
+    gmpNextPrime,
+    gmpTestPrimeMillerRabin,
+    gmpSizeInBytes,
+    gmpSizeInBits,
+    gmpExportInteger,
+    gmpExportIntegerLE,
+    gmpImportInteger,
+    gmpImportIntegerLE,
+) where
 
 #ifndef MIN_VERSION_integer_gmp
 #define MIN_VERSION_integer_gmp(a,b,c) 0
@@ -37,17 +38,18 @@
 import GHC.Integer.Logarithms (integerLog2#)
 #endif
 import Data.Word
-import GHC.Ptr (Ptr(..))
+import GHC.Ptr (Ptr (..))
 
 -- | GMP Supported / Unsupported
-data GmpSupported a = GmpSupported a
-                    | GmpUnsupported
-                    deriving (Show,Eq)
+data GmpSupported a
+    = GmpSupported a
+    | GmpUnsupported
+    deriving (Show, Eq)
 
 -- | Simple combinator in case the operation is not supported through GMP
 onGmpUnsupported :: GmpSupported a -> a -> a
 onGmpUnsupported (GmpSupported a) _ = a
-onGmpUnsupported GmpUnsupported   f = f
+onGmpUnsupported GmpUnsupported f = f
 
 -- | Compute the GCDE of a two integer through GMP
 gmpGcde :: Integer -> Integer -> GmpSupported (Integer, Integer, Integer)
diff --git a/Crypto/Number/F2m.hs b/Crypto/Number/F2m.hs
--- a/Crypto/Number/F2m.hs
+++ b/Crypto/Number/F2m.hs
@@ -9,31 +9,33 @@
 -- not optimal and it doesn't provide protection against timing
 -- attacks. The 'm' parameter is implicitly derived from the irreducible
 -- polynomial where applicable.
-
-module Crypto.Number.F2m
-    ( BinaryPolynomial
-    , addF2m
-    , mulF2m
-    , squareF2m'
-    , squareF2m
-    , powF2m
-    , modF2m
-    , sqrtF2m
-    , invF2m
-    , divF2m
-    ) where
+module Crypto.Number.F2m (
+    BinaryPolynomial,
+    addF2m,
+    mulF2m,
+    squareF2m',
+    squareF2m,
+    powF2m,
+    modF2m,
+    sqrtF2m,
+    invF2m,
+    divF2m,
+    quadraticF2m,
+) where
 
-import Data.Bits (xor, shift, testBit, setBit)
-import Data.List
 import Crypto.Number.Basic
+import Data.Bits (setBit, shift, testBit, unsafeShiftR, xor)
+import Data.List (foldl')
+import Prelude hiding (foldl')
 
 -- | Binary Polynomial represented by an integer
 type BinaryPolynomial = Integer
 
 -- | Addition over F₂m. This is just a synonym of 'xor'.
-addF2m :: Integer
-       -> Integer
-       -> Integer
+addF2m
+    :: Integer
+    -> Integer
+    -> Integer
 addF2m = xor
 {-# INLINE addF2m #-}
 
@@ -41,50 +43,62 @@
 --
 -- This function is undefined for negative arguments, because their bit
 -- representation is platform-dependent. Zero modulus is also prohibited.
-modF2m :: BinaryPolynomial -- ^ Modulus
-       -> Integer
-       -> Integer
+modF2m
+    :: BinaryPolynomial
+    -- ^ Modulus
+    -> Integer
+    -> Integer
 modF2m fx i
-    | fx < 0 || i < 0 = error "modF2m: negative number represent no binary polynomial"
-    | fx == 0         = error "modF2m: cannot divide by zero polynomial"
-    | fx == 1         = 0
-    | otherwise       = go i
+    | fx < 0 || i < 0 =
+        error "modF2m: negative number represent no binary polynomial"
+    | fx == 0 = error "modF2m: cannot divide by zero polynomial"
+    | fx == 1 = 0
+    | otherwise = go i
+  where
+    lfx = log2 fx
+    go n
+        | s == 0 = n `addF2m` fx
+        | s < 0 = n
+        | otherwise = go $ n `addF2m` shift fx s
       where
-        lfx = log2 fx
-        go n | s == 0    = n `addF2m` fx
-             | s < 0     = n
-             | otherwise = go $ n `addF2m` shift fx s
-                where s = log2 n - lfx
+        s = log2 n - lfx
 {-# INLINE modF2m #-}
 
 -- | Multiplication over F₂m.
 --
 -- This function is undefined for negative arguments, because their bit
 -- representation is platform-dependent. Zero modulus is also prohibited.
-mulF2m :: BinaryPolynomial -- ^ Modulus
-       -> Integer
-       -> Integer
-       -> Integer
+mulF2m
+    :: BinaryPolynomial
+    -- ^ Modulus
+    -> Integer
+    -> Integer
+    -> Integer
 mulF2m fx n1 n2
-    |    fx < 0
-      || n1 < 0
-      || n2 < 0 = error "mulF2m: negative number represent no binary polynomial"
-    | fx == 0   = error "mulF2m: cannot multiply modulo zero polynomial"
+    | fx < 0
+        || n1 < 0
+        || n2 < 0 =
+        error "mulF2m: negative number represent no binary polynomial"
+    | fx == 0 = error "mulF2m: cannot multiply modulo zero polynomial"
     | otherwise = modF2m fx $ go (if n2 `mod` 2 == 1 then n1 else 0) (log2 n2)
-      where
-        go n s | s == 0  = n
-               | otherwise = if testBit n2 s
-                                then go (n `addF2m` shift n1 s) (s - 1)
-                                else go n (s - 1)
-{-# INLINABLE mulF2m #-}
+  where
+    go n s
+        | s == 0 = n
+        | otherwise =
+            if testBit n2 s
+                then go (n `addF2m` shift n1 s) (s - 1)
+                else go n (s - 1)
+{-# INLINEABLE mulF2m #-}
 
 -- | Squaring over F₂m.
 --
 -- This function is undefined for negative arguments, because their bit
 -- representation is platform-dependent. Zero modulus is also prohibited.
-squareF2m :: BinaryPolynomial -- ^ Modulus
-          -> Integer
-          -> Integer
+squareF2m
+    :: BinaryPolynomial
+    -- ^ Modulus
+    -> Integer
+    -> Integer
 squareF2m fx = modF2m fx . squareF2m'
 {-# INLINE squareF2m #-}
 
@@ -95,75 +109,123 @@
 --
 -- This function is undefined for negative arguments, because their bit
 -- representation is platform-dependent.
-squareF2m' :: Integer
-           -> Integer
+squareF2m'
+    :: Integer
+    -> Integer
 squareF2m' n
-    | n < 0     = error "mulF2m: negative number represent no binary polynomial"
-    | otherwise = foldl' (\acc s -> if testBit n s then setBit acc (2 * s) else acc) 0 [0 .. log2 n]
+    | n < 0 = error "mulF2m: negative number represent no binary polynomial"
+    | otherwise =
+        foldl'
+            (\acc s -> if testBit n s then setBit acc (2 * s) else acc)
+            0
+            [0 .. log2 n]
 {-# INLINE squareF2m' #-}
 
 -- | Exponentiation in F₂m by computing @a^b mod fx@.
 --
 -- This implements an exponentiation by squaring based solution. It inherits the
 -- same restrictions as 'squareF2m'. Negative exponents are disallowed.
-powF2m :: BinaryPolynomial -- ^Modulus
-       -> Integer          -- ^a
-       -> Integer          -- ^b
-       -> Integer
+powF2m
+    :: BinaryPolynomial
+    -- ^ Modulus
+    -> Integer
+    -- ^ a
+    -> Integer
+    -- ^ b
+    -> Integer
 powF2m fx a b
-  | b < 0     = error "powF2m: negative exponents disallowed"
-  | b == 0    = if fx > 1 then 1 else 0
-  | even b    = squareF2m fx x
-  | otherwise = mulF2m fx a (squareF2m' x)
-  where x = powF2m fx a (b `div` 2)
+    | b < 0 = error "powF2m: negative exponents disallowed"
+    | b == 0 = if fx > 1 then 1 else 0
+    | even b = squareF2m fx x
+    | otherwise = mulF2m fx a (squareF2m' x)
+  where
+    x = powF2m fx a (b `div` 2)
 
 -- | Square rooot in F₂m.
 --
 -- We exploit the fact that @a^(2^m) = a@, or in particular, @a^(2^m - 1) = 1@
 -- from a classical result by Lagrange. Thus the square root is simply @a^(2^(m
 -- - 1))@.
-sqrtF2m :: BinaryPolynomial -- ^Modulus
-        -> Integer          -- ^a
-        -> Integer
+sqrtF2m
+    :: BinaryPolynomial
+    -- ^ Modulus
+    -> Integer
+    -- ^ a
+    -> Integer
 sqrtF2m fx a = go (log2 fx - 1) a
-  where go 0 x = x
-        go n x = go (n - 1) (squareF2m fx x)
+  where
+    go 0 x = x
+    go n x = go (n - 1) (squareF2m fx x)
 
 -- | Extended GCD algorithm for polynomials. For @a@ and @b@ returns @(g, u, v)@ such that @a * u + b * v == g@.
 --
 -- Reference: https://en.wikipedia.org/wiki/Polynomial_greatest_common_divisor#B.C3.A9zout.27s_identity_and_extended_GCD_algorithm
-gcdF2m :: Integer
-       -> Integer
-       -> (Integer, Integer, Integer)
+gcdF2m
+    :: Integer
+    -> Integer
+    -> (Integer, Integer, Integer)
 gcdF2m a b = go (a, b, 1, 0, 0, 1)
   where
-    go (g, 0, u, _, v, _)
-        = (g, u, v)
-    go (r0, r1, s0, s1, t0, t1)
-        = go (r1, r0 `addF2m` shift r1 j, s1, s0 `addF2m` shift s1 j, t1, t0 `addF2m` shift t1 j)
-            where j = max 0 (log2 r0 - log2 r1)
+    go (g, 0, u, _, v, _) =
+        (g, u, v)
+    go (r0, r1, s0, s1, t0, t1) =
+        go
+            ( r1
+            , r0 `addF2m` shift r1 j
+            , s1
+            , s0 `addF2m` shift s1 j
+            , t1
+            , t0 `addF2m` shift t1 j
+            )
+      where
+        j = max 0 (log2 r0 - log2 r1)
 
 -- | Modular inversion over F₂m.
 -- If @n@ doesn't have an inverse, 'Nothing' is returned.
 --
 -- This function is undefined for negative arguments, because their bit
 -- representation is platform-dependent. Zero modulus is also prohibited.
-invF2m :: BinaryPolynomial -- ^ Modulus
-       -> Integer
-       -> Maybe Integer
+invF2m
+    :: BinaryPolynomial
+    -- ^ Modulus
+    -> Integer
+    -> Maybe Integer
 invF2m fx n = if g == 1 then Just (modF2m fx u) else Nothing
   where
     (g, u, _) = gcdF2m n fx
-{-# INLINABLE invF2m #-}
+{-# INLINEABLE invF2m #-}
 
 -- | Division over F₂m. If the dividend doesn't have an inverse it returns
 -- 'Nothing'.
 --
 -- This function is undefined for negative arguments, because their bit
 -- representation is platform-dependent. Zero modulus is also prohibited.
-divF2m :: BinaryPolynomial -- ^ Modulus
-       -> Integer          -- ^ Dividend
-       -> Integer          -- ^ Divisor
-       -> Maybe Integer    -- ^ Quotient
+divF2m
+    :: BinaryPolynomial
+    -- ^ Modulus
+    -> Integer
+    -- ^ Dividend
+    -> Integer
+    -- ^ Divisor
+    -> Maybe Integer
+    -- ^ Quotient
 divF2m fx n1 n2 = mulF2m fx n1 <$> invF2m fx n2
 {-# INLINE divF2m #-}
+
+traceF2m :: BinaryPolynomial -> Integer -> Integer
+traceF2m fx = foldr addF2m 0 . take (log2 fx) . iterate (squareF2m fx)
+{-# INLINE traceF2m #-}
+
+halfTraceF2m :: BinaryPolynomial -> Integer -> Integer
+halfTraceF2m fx =
+    foldr addF2m 0
+        . take (1 + log2 fx `unsafeShiftR` 1)
+        . iterate (squareF2m fx . squareF2m fx)
+{-# INLINE halfTraceF2m #-}
+
+-- | Solve a quadratic equation of the form @x^2 + x = a@ in F₂m.
+quadraticF2m :: BinaryPolynomial -> Integer -> Maybe Integer
+quadraticF2m fx a
+    | traceF2m fx a == 0 = Just $ halfTraceF2m fx a
+    | otherwise = Nothing
+{-# INLINEABLE quadraticF2m #-}
diff --git a/Crypto/Number/Generate.hs b/Crypto/Number/Generate.hs
--- a/Crypto/Number/Generate.hs
+++ b/Crypto/Number/Generate.hs
@@ -4,31 +4,32 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
-
-module Crypto.Number.Generate
-    ( GenTopPolicy(..)
-    , generateParams
-    , generateMax
-    , generateBetween
-    ) where
+module Crypto.Number.Generate (
+    GenTopPolicy (..),
+    generateParams,
+    generatePrefix,
+    generateMax,
+    generateBetween,
+) where
 
-import           Crypto.Internal.Imports
-import           Crypto.Number.Basic
-import           Crypto.Number.Serialize
-import           Crypto.Random.Types
-import           Control.Monad (when)
-import           Foreign.Ptr
-import           Foreign.Storable
-import           Data.Bits ((.|.), (.&.), shiftL, complement, testBit)
-import           Crypto.Internal.ByteArray (ScrubbedBytes)
+import Control.Monad (when)
+import Crypto.Internal.ByteArray (ScrubbedBytes)
 import qualified Crypto.Internal.ByteArray as B
-
+import Crypto.Internal.Imports
+import Crypto.Number.Basic
+import Crypto.Number.Serialize
+import Crypto.Random.Types
+import Data.Bits (complement, shiftL, testBit, unsafeShiftR, (.&.), (.|.))
+import Foreign.Ptr
+import Foreign.Storable
 
 -- | Top bits policy when generating a number
-data GenTopPolicy =
-      SetHighest    -- ^ set the highest bit
-    | SetTwoHighest -- ^ set the two highest bit
-    deriving (Show,Eq)
+data GenTopPolicy
+    = -- | set the highest bit
+      SetHighest
+    | -- | set the two highest bit
+      SetTwoHighest
+    deriving (Show, Eq)
 
 -- | Generate a number for a specific size of bits,
 -- and optionaly set bottom and top bits
@@ -38,27 +39,31 @@
 --
 -- If @generateOdd is set to 'True', then the number generated
 -- is guaranteed to be odd. Otherwise it will be whatever is generated
---
-generateParams :: MonadRandom m
-               => Int                -- ^ number of bits
-               -> Maybe GenTopPolicy -- ^ top bit policy
-               -> Bool               -- ^ force the number to be odd
-               -> m Integer
+generateParams
+    :: MonadRandom m
+    => Int
+    -- ^ number of bits
+    -> Maybe GenTopPolicy
+    -- ^ top bit policy
+    -> Bool
+    -- ^ force the number to be odd
+    -> m Integer
 generateParams bits genTopPolicy generateOdd
     | bits <= 0 = return 0
     | otherwise = os2ip . tweak <$> getRandomBytes bytes
   where
     tweak :: ScrubbedBytes -> ScrubbedBytes
     tweak orig = B.copyAndFreeze orig $ \p0 -> do
-        let p1   = p0 `plusPtr` 1
+        let p1 = p0 `plusPtr` 1
             pEnd = p0 `plusPtr` (bytes - 1)
         case genTopPolicy of
-            Nothing             -> return ()
-            Just SetHighest     -> p0 |= (1 `shiftL` bit)
+            Nothing -> return ()
+            Just SetHighest -> p0 |= (1 `shiftL` bit)
             Just SetTwoHighest
-                | bit == 0      -> do p0 $= 0x1
-                                      p1 |= 0x80
-                | otherwise     -> p0 |= (0x3 `shiftL` (bit - 1))
+                | bit == 0 -> do
+                    p0 $= 0x1
+                    p1 |= 0x80
+                | otherwise -> p0 |= (0x3 `shiftL` (bit - 1))
         p0 &= (complement $ mask)
         when generateOdd (pEnd |= 0x1)
 
@@ -71,52 +76,81 @@
     (&=) :: Ptr Word8 -> Word8 -> IO ()
     (&=) p w = peek p >>= \v -> poke p (v .&. w)
 
-    bytes = (bits + 7) `div` 8;
-    bit   = (bits - 1) `mod` 8;
-    mask  = 0xff `shiftL` (bit + 1);
+    bytes = (bits + 7) `div` 8
+    bit = (bits - 1) `mod` 8
+    mask = 0xff `shiftL` (bit + 1)
 
+-- | Generate a number for a specific size of bits.
+--
+-- * @'generateParams' n Nothing False@ generates bytes and uses the suffix of @n@ bits
+-- * @'generatePrefix' n@ generates bytes and uses the prefix of @n@ bits
+generatePrefix :: MonadRandom m => Int -> m Integer
+generatePrefix bits
+    | bits <= 0 = return 0
+    | otherwise = do
+        let (count, offset) = (bits + 7) `divMod` 8
+        bytes <- getRandomBytes count
+        return $ os2ip (bytes :: ScrubbedBytes) `unsafeShiftR` (7 - offset)
+
 -- | Generate a positive integer x, s.t. 0 <= x < range
-generateMax :: MonadRandom m
-            => Integer  -- ^ range
-            -> m Integer
+generateMax
+    :: MonadRandom m
+    => Integer
+    -- ^ range
+    -> m Integer
 generateMax range
-    | range <= 1      = return 0
-    | range < 127     = generateSimple
+    | range <= 1 = return 0
+    | range < 127 = generateSimple
     | canOverGenerate = loopGenerateOver tries
-    | otherwise       = loopGenerate tries
+    | otherwise = loopGenerate tries
   where
-        -- this "generator" is mostly for quickcheck benefits. it'll be biased if
-        -- range is not a multiple of 2, but overall, no security should be
-        -- assumed for a number between 0 and 127.
-        generateSimple = flip mod range `fmap` generateParams bits Nothing False
+    -- this "generator" is mostly for quickcheck benefits. it'll be biased if
+    -- range is not a multiple of 2, but overall, no security should be
+    -- assumed for a number between 0 and 127.
+    generateSimple = flip mod range `fmap` generateParams bits Nothing False
 
-        loopGenerate count
-            | count == 0 = error $ "internal: generateMax(" ++ show range ++ " bits=" ++ show bits ++ ") (normal) doesn't seems to work properly"
-            | otherwise  = do
-                r <- generateParams bits Nothing False
-                if isValid r then return r else loopGenerate (count-1)
+    loopGenerate count
+        | count == 0 =
+            error $
+                "internal: generateMax("
+                    ++ show range
+                    ++ " bits="
+                    ++ show bits
+                    ++ ") (normal) doesn't seems to work properly"
+        | otherwise = do
+            r <- generateParams bits Nothing False
+            if isValid r then return r else loopGenerate (count - 1)
 
-        loopGenerateOver count
-            | count == 0 = error $ "internal: generateMax(" ++ show range ++ " bits=" ++ show bits ++ ") (over) doesn't seems to work properly"
-            | otherwise  = do
-                r <- generateParams (bits+1) Nothing False
-                let r2 = r - range
-                    r3 = r2 - range
-                if isValid r
-                    then return r
-                    else if isValid r2
+    loopGenerateOver count
+        | count == 0 =
+            error $
+                "internal: generateMax("
+                    ++ show range
+                    ++ " bits="
+                    ++ show bits
+                    ++ ") (over) doesn't seems to work properly"
+        | otherwise = do
+            r <- generateParams (bits + 1) Nothing False
+            let r2 = r - range
+                r3 = r2 - range
+            if isValid r
+                then return r
+                else
+                    if isValid r2
                         then return r2
-                        else if isValid r3
-                            then return r3
-                            else loopGenerateOver (count-1)
+                        else
+                            if isValid r3
+                                then return r3
+                                else loopGenerateOver (count - 1)
 
-        bits            = numBits range
-        canOverGenerate = bits > 3 && not (range `testBit` (bits-2)) && not (range `testBit` (bits-3))
+    bits = numBits range
+    canOverGenerate =
+        bits > 3 && not (range `testBit` (bits - 2)) && not (range `testBit` (bits - 3))
 
-        isValid n = n < range
+    isValid n = n < range
 
-        tries :: Int
-        tries = 100
+    tries :: Int
+    tries = 100
 
 -- | generate a number between the inclusive bound [low,high].
 generateBetween :: MonadRandom m => Integer -> Integer -> m Integer
diff --git a/Crypto/Number/ModArithmetic.hs b/Crypto/Number/ModArithmetic.hs
--- a/Crypto/Number/ModArithmetic.hs
+++ b/Crypto/Number/ModArithmetic.hs
@@ -1,26 +1,27 @@
 {-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.Number.ModArithmetic
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
-
-module Crypto.Number.ModArithmetic
-    (
+module Crypto.Number.ModArithmetic (
     -- * Exponentiation
-      expSafe
-    , expFast
+    expSafe,
+    expFast,
+
     -- * Inverse computing
-    , inverse
-    , inverseCoprimes
-    , inverseFermat
+    inverse,
+    inverseCoprimes,
+    inverseFermat,
+
     -- * Squares
-    , jacobi
-    , squareRoot
-    ) where
+    jacobi,
+    squareRoot,
+) where
 
-import Control.Exception (throw, Exception)
+import Control.Exception (Exception, throw)
 import Crypto.Number.Basic
 import Crypto.Number.Compat
 
@@ -42,16 +43,24 @@
 --
 -- Before GHC 8.4.2, powModSecInteger is missing from integer-gmp,
 -- so expSafe has the same security as expFast.
-expSafe :: Integer -- ^ base
-        -> Integer -- ^ exponent
-        -> Integer -- ^ modulo
-        -> Integer -- ^ result
+expSafe
+    :: Integer
+    -- ^ base
+    -> Integer
+    -- ^ exponent
+    -> Integer
+    -- ^ modulo
+    -> Integer
+    -- ^ result
 expSafe b e m
-    | odd m     = gmpPowModSecInteger b e m `onGmpUnsupported`
-                  (gmpPowModInteger b e m   `onGmpUnsupported`
-                  exponentiation b e m)
-    | otherwise = gmpPowModInteger b e m    `onGmpUnsupported`
-                  exponentiation b e m
+    | odd m =
+        gmpPowModSecInteger b e m
+            `onGmpUnsupported` ( gmpPowModInteger b e m
+                                    `onGmpUnsupported` exponentiation b e m
+                               )
+    | otherwise =
+        gmpPowModInteger b e m
+            `onGmpUnsupported` exponentiation b e m
 
 -- | Compute the modular exponentiation of base^exponent using
 -- the fastest algorithm without any consideration for
@@ -59,31 +68,37 @@
 --
 -- Use this function when all the parameters are public,
 -- otherwise 'expSafe' should be preferred.
-expFast :: Integer -- ^ base
-        -> Integer -- ^ exponent
-        -> Integer -- ^ modulo
-        -> Integer -- ^ result
+expFast
+    :: Integer
+    -- ^ base
+    -> Integer
+    -- ^ exponent
+    -> Integer
+    -- ^ modulo
+    -> Integer
+    -- ^ result
 expFast b e m = gmpPowModInteger b e m `onGmpUnsupported` exponentiation b e m
 
 -- | @exponentiation@ computes modular exponentiation as /b^e mod m/
 -- using repetitive squaring.
 exponentiation :: Integer -> Integer -> Integer -> Integer
 exponentiation b e m
-    | b == 1    = b
-    | e == 0    = 1
-    | e == 1    = b `mod` m
-    | even e    = let p = exponentiation b (e `div` 2) m `mod` m
-                   in (p^(2::Integer)) `mod` m
-    | otherwise = (b * exponentiation b (e-1) m) `mod` m
+    | b == 1 = b
+    | e == 0 = 1
+    | e == 1 = b `mod` m
+    | even e =
+        let p = exponentiation b (e `div` 2) m `mod` m
+         in (p ^ (2 :: Integer)) `mod` m
+    | otherwise = (b * exponentiation b (e - 1) m) `mod` m
 
 -- | @inverse@ computes the modular inverse as in /g^(-1) mod m/.
 inverse :: Integer -> Integer -> Maybe Integer
 inverse g m = gmpInverse g m `onGmpUnsupported` v
   where
     v
-        | d > 1     = Nothing
+        | d > 1 = Nothing
         | otherwise = Just (x `mod` m)
-    (x,_,d) = gcde g m
+    (x, _, d) = gcde g m
 
 -- | Compute the modular inverse of two coprime numbers.
 -- This is equivalent to inverse except that the result
@@ -95,7 +110,7 @@
 inverseCoprimes g m =
     case inverse g m of
         Nothing -> throw CoprimesAssertionError
-        Just i  -> i
+        Just i -> i
 
 -- | Computes the Jacobi symbol (a/n).
 -- 0 ≤ a < n; n ≥ 3 and odd.
@@ -106,22 +121,23 @@
 -- See algorithm 2.149 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
 jacobi :: Integer -> Integer -> Maybe Integer
 jacobi a n
-    | n < 3 || even n  = Nothing
+    | n < 3 || even n = Nothing
     | a == 0 || a == 1 = Just a
-    | n <= a           = jacobi (a `mod` n) n
-    | a < 0            =
-      let b = if n `mod` 4 == 1 then 1 else -1
-       in fmap (*b) (jacobi (-a) n)
-    | otherwise        =
-      let (e, a1) = asPowerOf2AndOdd a
-          nMod8   = n `mod` 8
-          nMod4   = n `mod` 4
-          a1Mod4  = a1 `mod` 4
-          s'      = if even e || nMod8 == 1 || nMod8 == 7 then 1 else -1
-          s       = if nMod4 == 3 && a1Mod4 == 3 then -s' else s'
-          n1      = n `mod` a1
-       in if a1 == 1 then Just s
-          else fmap (*s) (jacobi n1 a1)
+    | n <= a = jacobi (a `mod` n) n
+    | a < 0 =
+        let b = if n `mod` 4 == 1 then 1 else -1
+         in fmap (* b) (jacobi (-a) n)
+    | otherwise =
+        let (e, a1) = asPowerOf2AndOdd a
+            nMod8 = n `mod` 8
+            nMod4 = n `mod` 4
+            a1Mod4 = a1 `mod` 4
+            s' = if even e || nMod8 == 1 || nMod8 == 7 then 1 else -1
+            s = if nMod4 == 3 && a1Mod4 == 3 then -s' else s'
+            n1 = n `mod` a1
+         in if a1 == 1
+                then Just s
+                else fmap (* s) (jacobi n1 a1)
 
 -- | Modular inverse using Fermat's little theorem.  This works only when
 -- the modulus is prime but avoids side channels like in 'expSafe'.
@@ -143,21 +159,21 @@
 -- parameters only.
 squareRoot :: Integer -> Integer -> Maybe Integer
 squareRoot p
-    | p < 2     = throw ModulusAssertionError
+    | p < 2 = throw ModulusAssertionError
     | otherwise =
         case p `divMod` 8 of
-           (v, 3) -> method1 (2 * v + 1)
-           (v, 7) -> method1 (2 * v + 2)
-           (u, 5) -> method2 u
-           (_, 1) -> tonelliShanks p
-           (0, 2) -> \a -> Just (if even a then 0 else 1)
-           _      -> throw ModulusAssertionError
-
+            (v, 3) -> method1 (2 * v + 1)
+            (v, 7) -> method1 (2 * v + 2)
+            (u, 5) -> method2 u
+            (_, 1) -> tonelliShanks p
+            (0, 2) -> \a -> Just (if even a then 0 else 1)
+            _ -> throw ModulusAssertionError
   where
     x `eqMod` y = (x - y) `mod` p == 0
 
-    validate g y | (y * y) `eqMod` g = Just y
-                 | otherwise         = Nothing
+    validate g y
+        | (y * y) `eqMod` g = Just y
+        | otherwise = Nothing
 
     -- p == 4u + 3 and u' == u + 1
     method1 u' g =
@@ -174,20 +190,24 @@
 
 tonelliShanks :: Integer -> Integer -> Maybe Integer
 tonelliShanks p a
-    | aa == 0   = Just 0
+    | aa == 0 = Just 0
     | otherwise =
         case expFast aa p2 p of
-            b | b == p1   -> Nothing
-              | b == 1    -> Just $ go (expFast aa ((s + 1) `div` 2) p)
-                                       (expFast aa s p)
-                                       (expFast n  s p)
-                                       e
-              | otherwise -> throw ModulusAssertionError
+            b
+                | b == p1 -> Nothing
+                | b == 1 ->
+                    Just $
+                        go
+                            (expFast aa ((s + 1) `div` 2) p)
+                            (expFast aa s p)
+                            (expFast n s p)
+                            e
+                | otherwise -> throw ModulusAssertionError
   where
     aa = a `mod` p
     p1 = p - 1
     p2 = p1 `div` 2
-    n  = findN 2
+    n = findN 2
 
     x `mul` y = (x * y) `mod` p
 
@@ -199,15 +219,15 @@
     -- find a quadratic non-residue
     findN i
         | expFast i p2 p == p1 = i
-        | otherwise            = findN (i + 1)
+        | otherwise = findN (i + 1)
 
     -- find m such that b^(2^m) == 1 (mod p)
     findM b i
-        | b == 1    = i
+        | b == 1 = i
         | otherwise = findM (b `mul` b) (i + 1)
 
     go !x b g !r
-        | b == 1    = x
+        | b == 1 = x
         | otherwise =
             let r' = findM b 0
                 z = pow2m (r - r' - 1) g
diff --git a/Crypto/Number/Nat.hs b/Crypto/Number/Nat.hs
--- a/Crypto/Number/Nat.hs
+++ b/Crypto/Number/Nat.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE TypeOperators #-}
+
 -- |
 -- Module      : Crypto.Number.Nat
 -- License     : BSD-style
@@ -26,38 +29,39 @@
 --
 -- Function @withDivisibleBy8@ above returns 'Nothing' when the argument @len@
 -- is negative or not divisible by 8.
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeOperators #-}
-module Crypto.Number.Nat
-    ( type IsDivisibleBy8
-    , type IsAtMost, type IsAtLeast
-    , isDivisibleBy8
-    , isAtMost
-    , isAtLeast
-    ) where
+module Crypto.Number.Nat (
+    type IsDivisibleBy8,
+    type IsAtMost,
+    type IsAtLeast,
+    isDivisibleBy8,
+    isAtMost,
+    isAtLeast,
+) where
 
-import           Data.Type.Equality
-import           GHC.TypeLits
-import           Unsafe.Coerce (unsafeCoerce)
+import Data.Type.Equality
+import GHC.TypeLits
+import Unsafe.Coerce (unsafeCoerce)
 
-import           Crypto.Internal.Nat
+import Crypto.Internal.Nat
 
 -- | get a runtime proof that the constraint @'IsDivisibleBy8' n@ is satified
 isDivisibleBy8 :: KnownNat n => proxy n -> Maybe (IsDiv8 n n :~: 'True)
 isDivisibleBy8 n
     | mod (natVal n) 8 == 0 = Just (unsafeCoerce Refl)
-    | otherwise             = Nothing
+    | otherwise = Nothing
 
 -- | get a runtime proof that the constraint @'IsAtMost' value bound@ is
 -- satified
-isAtMost :: (KnownNat value, KnownNat bound)
-         => proxy value -> proxy' bound -> Maybe ((value <=? bound) :~: 'True)
+isAtMost
+    :: (KnownNat value, KnownNat bound)
+    => proxy value -> proxy' bound -> Maybe ((value <=? bound) :~: 'True)
 isAtMost x y
-    | natVal x <= natVal y  = Just (unsafeCoerce Refl)
-    | otherwise             = Nothing
+    | natVal x <= natVal y = Just (unsafeCoerce Refl)
+    | otherwise = Nothing
 
 -- | get a runtime proof that the constraint @'IsAtLeast' value bound@ is
 -- satified
-isAtLeast :: (KnownNat value, KnownNat bound)
-          => proxy value -> proxy' bound -> Maybe ((bound <=? value) :~: 'True)
+isAtLeast
+    :: (KnownNat value, KnownNat bound)
+    => proxy value -> proxy' bound -> Maybe ((bound <=? value) :~: 'True)
 isAtLeast = flip isAtMost
diff --git a/Crypto/Number/Prime.hs b/Crypto/Number/Prime.hs
--- a/Crypto/Number/Prime.hs
+++ b/Crypto/Number/Prime.hs
@@ -1,31 +1,30 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.Number.Prime
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
-
-{-# LANGUAGE BangPatterns #-}
-module Crypto.Number.Prime
-    (
-      generatePrime
-    , generateSafePrime
-    , isProbablyPrime
-    , findPrimeFrom
-    , findPrimeFromWith
-    , primalityTestMillerRabin
-    , primalityTestNaive
-    , primalityTestFermat
-    , isCoprime
-    ) where
+module Crypto.Number.Prime (
+    generatePrime,
+    generateSafePrime,
+    isProbablyPrime,
+    findPrimeFrom,
+    findPrimeFromWith,
+    primalityTestMillerRabin,
+    primalityTestNaive,
+    primalityTestFermat,
+    isCoprime,
+) where
 
+import Crypto.Error
+import Crypto.Number.Basic (gcde, sqrti)
 import Crypto.Number.Compat
 import Crypto.Number.Generate
-import Crypto.Number.Basic (sqrti, gcde)
 import Crypto.Number.ModArithmetic (expSafe)
-import Crypto.Random.Types
 import Crypto.Random.Probabilistic
-import Crypto.Error
+import Crypto.Random.Types
 
 import Data.Bits
 
@@ -36,9 +35,10 @@
 isProbablyPrime :: Integer -> Bool
 isProbablyPrime !n
     | any (\p -> p `divides` n) (filter (< n) firstPrimes) = False
-    | n >= 2 && n <= 2903                                  = True
-    | primalityTestFermat 50 (n `div` 2) n                 = primalityTestMillerRabin 30 n
-    | otherwise                                            = False
+    | n >= 2 && n <= 2903 = True
+    | primalityTestFermat 50 (n `div` 2) n =
+        primalityTestMillerRabin 30 n
+    | otherwise = False
 
 -- | Generate a prime number of the required bitsize (i.e. in the range
 -- [2^(b-1)+2^(b-2), 2^b)).
@@ -50,14 +50,16 @@
 -- the proper size.
 generatePrime :: MonadRandom m => Int -> m Integer
 generatePrime bits = do
-    if bits < 5 then
-        throwCryptoError $ CryptoFailed $ CryptoError_PrimeSizeInvalid
-    else do
-        sp <- generateParams bits (Just SetTwoHighest) True
-        let prime = findPrimeFrom sp
-        if prime < 1 `shiftL` bits then
-            return $ prime
-        else generatePrime bits
+    if bits < 5
+        then
+            throwCryptoError $ CryptoFailed $ CryptoError_PrimeSizeInvalid
+        else do
+            sp <- generateParams bits (Just SetTwoHighest) True
+            let prime = findPrimeFrom sp
+            if prime < 1 `shiftL` bits
+                then
+                    return $ prime
+                else generatePrime bits
 
 -- | Generate a prime number of the form 2p+1 where p is also prime.
 -- it is also knowed as a Sophie Germaine prime or safe prime.
@@ -69,27 +71,29 @@
 -- 6 bits, as the smallest safe prime with the two highest bits set is 59.
 generateSafePrime :: MonadRandom m => Int -> m Integer
 generateSafePrime bits = do
-    if bits < 6 then
-        throwCryptoError $ CryptoFailed $ CryptoError_PrimeSizeInvalid
-    else do
-        sp <- generateParams bits (Just SetTwoHighest) True
-        let p = findPrimeFromWith (\i -> isProbablyPrime (2*i+1)) (sp `div` 2)
-        let val = 2 * p + 1
-        if val < 1 `shiftL` bits then
-            return $ val
-        else generateSafePrime bits
+    if bits < 6
+        then
+            throwCryptoError $ CryptoFailed $ CryptoError_PrimeSizeInvalid
+        else do
+            sp <- generateParams bits (Just SetTwoHighest) True
+            let p = findPrimeFromWith (\i -> isProbablyPrime (2 * i + 1)) (sp `div` 2)
+            let val = 2 * p + 1
+            if val < 1 `shiftL` bits
+                then
+                    return $ val
+                else generateSafePrime bits
 
 -- | Find a prime from a starting point where the property hold.
 findPrimeFromWith :: (Integer -> Bool) -> Integer -> Integer
 findPrimeFromWith prop !n
-    | even n        = findPrimeFromWith prop (n+1)
-    | otherwise     =
+    | even n = findPrimeFromWith prop (n + 1)
+    | otherwise =
         if not (isProbablyPrime n)
-            then findPrimeFromWith prop (n+2)
+            then findPrimeFromWith prop (n + 2)
             else
                 if prop n
                     then n
-                    else findPrimeFromWith prop (n+2)
+                    else findPrimeFromWith prop (n + 2)
 
 -- | Find a prime from a starting point with no specific property.
 findPrimeFrom :: Integer -> Integer
@@ -107,41 +111,42 @@
         GmpUnsupported -> probabilistic run
   where
     run
-        | n <= 3     = error "Miller-Rabin requires tested value to be > 3"
-        | even n     = return False
+        | n <= 3 = error "Miller-Rabin requires tested value to be > 3"
+        | even n = return False
         | tries <= 0 = error "Miller-Rabin tries need to be > 0"
-        | otherwise  = loop <$> generateTries tries
+        | otherwise = loop <$> generateTries tries
 
-    !nm1 = n-1
-    !nm2 = n-2
+    !nm1 = n - 1
+    !nm2 = n - 2
 
-    (!s,!d) = (factorise 0 nm1)
+    (!s, !d) = (factorise 0 nm1)
 
     generateTries 0 = return []
     generateTries t = do
-        v  <- generateBetween 2 nm2
-        vs <- generateTries (t-1)
-        return (v:vs)
+        v <- generateBetween 2 nm2
+        vs <- generateTries (t - 1)
+        return (v : vs)
 
     -- factorise n-1 into the form 2^s*d
     factorise :: Integer -> Integer -> (Integer, Integer)
     factorise !si !vi
         | vi `testBit` 0 = (si, vi)
-        | otherwise     = factorise (si+1) (vi `shiftR` 1) -- probably faster to not shift v continuously, but just once.
+        | otherwise = factorise (si + 1) (vi `shiftR` 1) -- probably faster to not shift v continuously, but just once.
     expmod = expSafe
 
     -- when iteration reach zero, we have a probable prime
-    loop []     = True
-    loop (w:ws) = let x = expmod w d n
-                   in if x == (1 :: Integer) || x == nm1
-                          then loop ws
-                          else loop' ws ((x*x) `mod` n) 1
+    loop [] = True
+    loop (w : ws) =
+        let x = expmod w d n
+         in if x == (1 :: Integer) || x == nm1
+                then loop ws
+                else loop' ws ((x * x) `mod` n) 1
 
     -- loop from 1 to s-1. if we reach the end then it's composite
     loop' ws !x2 !r
-        | r == s    = False
-        | x2 == 1   = False
-        | x2 /= nm1 = loop' ws ((x2*x2) `mod` n) (r+1)
+        | r == s = False
+        | x2 == 1 = False
+        | x2 /= nm1 = loop' ws ((x2 * x2) `mod` n) (r + 1)
         | otherwise = loop ws
 
 {-
@@ -157,77 +162,461 @@
 -- | Probabilitic Test using Fermat primility test.
 -- Beware of Carmichael numbers that are Fermat liars, i.e. this test
 -- is useless for them. always combines with some other test.
-primalityTestFermat :: Int -- ^ number of iterations of the algorithm
-                    -> Integer -- ^ starting a
-                    -> Integer -- ^ number to test for primality
-                    -> Bool
-primalityTestFermat n a p = and $ map expTest [a..(a+fromIntegral n)]
-    where !pm1 = p-1
-          expTest i = expSafe i pm1 p == 1
+primalityTestFermat
+    :: Int
+    -- ^ number of iterations of the algorithm
+    -> Integer
+    -- ^ starting a
+    -> Integer
+    -- ^ number to test for primality
+    -> Bool
+primalityTestFermat n a p = and $ map expTest [a .. (a + fromIntegral n)]
+  where
+    !pm1 = p - 1
+    expTest i = expSafe i pm1 p == 1
 
 -- | Test naively is integer is prime.
 -- while naive, we skip even number and stop iteration at i > sqrt(n)
 primalityTestNaive :: Integer -> Bool
 primalityTestNaive n
-    | n <= 1    = False
-    | n == 2    = True
-    | even n    = False
+    | n <= 1 = False
+    | n == 2 = True
+    | even n = False
     | otherwise = search 3
-        where !ubound = snd $ sqrti n
-              search !i
-                  | i > ubound    = True
-                  | i `divides` n = False
-                  | otherwise     = search (i+2)
+  where
+    !ubound = snd $ sqrti n
+    search !i
+        | i > ubound = True
+        | i `divides` n = False
+        | otherwise = search (i + 2)
 
 -- | Test is two integer are coprime to each other
 isCoprime :: Integer -> Integer -> Bool
-isCoprime m n = case gcde m n of (_,_,d) -> d == 1
+isCoprime m n = case gcde m n of (_, _, d) -> d == 1
 
 -- | List of the first primes till 2903.
 firstPrimes :: [Integer]
 firstPrimes =
-    [ 2    , 3    , 5    , 7    , 11   , 13   , 17   , 19   , 23   , 29
-    , 31   , 37   , 41   , 43   , 47   , 53   , 59   , 61   , 67   , 71
-    , 73   , 79   , 83   , 89   , 97   , 101  , 103  , 107  , 109  , 113
-    , 127  , 131  , 137  , 139  , 149  , 151  , 157  , 163  , 167  , 173
-    , 179  , 181  , 191  , 193  , 197  , 199  , 211  , 223  , 227  , 229
-    , 233  , 239  , 241  , 251  , 257  , 263  , 269  , 271  , 277  , 281
-    , 283  , 293  , 307  , 311  , 313  , 317  , 331  , 337  , 347  , 349
-    , 353  , 359  , 367  , 373  , 379  , 383  , 389  , 397  , 401  , 409
-    , 419  , 421  , 431  , 433  , 439  , 443  , 449  , 457  , 461  , 463
-    , 467  , 479  , 487  , 491  , 499  , 503  , 509  , 521  , 523  , 541
-    , 547  , 557  , 563  , 569  , 571  , 577  , 587  , 593  , 599  , 601
-    , 607  , 613  , 617  , 619  , 631  , 641  , 643  , 647  , 653  , 659
-    , 661  , 673  , 677  , 683  , 691  , 701  , 709  , 719  , 727  , 733
-    , 739  , 743  , 751  , 757  , 761  , 769  , 773  , 787  , 797  , 809
-    , 811  , 821  , 823  , 827  , 829  , 839  , 853  , 857  , 859  , 863
-    , 877  , 881  , 883  , 887  , 907  , 911  , 919  , 929  , 937  , 941
-    , 947  , 953  , 967  , 971  , 977  , 983  , 991  , 997  , 1009 , 1013
-    , 1019 , 1021 , 1031 , 1033 , 1039 , 1049 , 1051 , 1061 , 1063 , 1069
-    , 1087 , 1091 , 1093 , 1097 , 1103 , 1109 , 1117 , 1123 , 1129 , 1151
-    , 1153 , 1163 , 1171 , 1181 , 1187 , 1193 , 1201 , 1213 , 1217 , 1223
-    , 1229 , 1231 , 1237 , 1249 , 1259 , 1277 , 1279 , 1283 , 1289 , 1291
-    , 1297 , 1301 , 1303 , 1307 , 1319 , 1321 , 1327 , 1361 , 1367 , 1373
-    , 1381 , 1399 , 1409 , 1423 , 1427 , 1429 , 1433 , 1439 , 1447 , 1451
-    , 1453 , 1459 , 1471 , 1481 , 1483 , 1487 , 1489 , 1493 , 1499 , 1511
-    , 1523 , 1531 , 1543 , 1549 , 1553 , 1559 , 1567 , 1571 , 1579 , 1583
-    , 1597 , 1601 , 1607 , 1609 , 1613 , 1619 , 1621 , 1627 , 1637 , 1657
-    , 1663 , 1667 , 1669 , 1693 , 1697 , 1699 , 1709 , 1721 , 1723 , 1733
-    , 1741 , 1747 , 1753 , 1759 , 1777 , 1783 , 1787 , 1789 , 1801 , 1811
-    , 1823 , 1831 , 1847 , 1861 , 1867 , 1871 , 1873 , 1877 , 1879 , 1889
-    , 1901 , 1907 , 1913 , 1931 , 1933 , 1949 , 1951 , 1973 , 1979 , 1987
-    , 1993 , 1997 , 1999 , 2003 , 2011 , 2017 , 2027 , 2029 , 2039 , 2053
-    , 2063 , 2069 , 2081 , 2083 , 2087 , 2089 , 2099 , 2111 , 2113 , 2129
-    , 2131 , 2137 , 2141 , 2143 , 2153 , 2161 , 2179 , 2203 , 2207 , 2213
-    , 2221 , 2237 , 2239 , 2243 , 2251 , 2267 , 2269 , 2273 , 2281 , 2287
-    , 2293 , 2297 , 2309 , 2311 , 2333 , 2339 , 2341 , 2347 , 2351 , 2357
-    , 2371 , 2377 , 2381 , 2383 , 2389 , 2393 , 2399 , 2411 , 2417 , 2423
-    , 2437 , 2441 , 2447 , 2459 , 2467 , 2473 , 2477 , 2503 , 2521 , 2531
-    , 2539 , 2543 , 2549 , 2551 , 2557 , 2579 , 2591 , 2593 , 2609 , 2617
-    , 2621 , 2633 , 2647 , 2657 , 2659 , 2663 , 2671 , 2677 , 2683 , 2687
-    , 2689 , 2693 , 2699 , 2707 , 2711 , 2713 , 2719 , 2729 , 2731 , 2741
-    , 2749 , 2753 , 2767 , 2777 , 2789 , 2791 , 2797 , 2801 , 2803 , 2819
-    , 2833 , 2837 , 2843 , 2851 , 2857 , 2861 , 2879 , 2887 , 2897 , 2903
+    [ 2
+    , 3
+    , 5
+    , 7
+    , 11
+    , 13
+    , 17
+    , 19
+    , 23
+    , 29
+    , 31
+    , 37
+    , 41
+    , 43
+    , 47
+    , 53
+    , 59
+    , 61
+    , 67
+    , 71
+    , 73
+    , 79
+    , 83
+    , 89
+    , 97
+    , 101
+    , 103
+    , 107
+    , 109
+    , 113
+    , 127
+    , 131
+    , 137
+    , 139
+    , 149
+    , 151
+    , 157
+    , 163
+    , 167
+    , 173
+    , 179
+    , 181
+    , 191
+    , 193
+    , 197
+    , 199
+    , 211
+    , 223
+    , 227
+    , 229
+    , 233
+    , 239
+    , 241
+    , 251
+    , 257
+    , 263
+    , 269
+    , 271
+    , 277
+    , 281
+    , 283
+    , 293
+    , 307
+    , 311
+    , 313
+    , 317
+    , 331
+    , 337
+    , 347
+    , 349
+    , 353
+    , 359
+    , 367
+    , 373
+    , 379
+    , 383
+    , 389
+    , 397
+    , 401
+    , 409
+    , 419
+    , 421
+    , 431
+    , 433
+    , 439
+    , 443
+    , 449
+    , 457
+    , 461
+    , 463
+    , 467
+    , 479
+    , 487
+    , 491
+    , 499
+    , 503
+    , 509
+    , 521
+    , 523
+    , 541
+    , 547
+    , 557
+    , 563
+    , 569
+    , 571
+    , 577
+    , 587
+    , 593
+    , 599
+    , 601
+    , 607
+    , 613
+    , 617
+    , 619
+    , 631
+    , 641
+    , 643
+    , 647
+    , 653
+    , 659
+    , 661
+    , 673
+    , 677
+    , 683
+    , 691
+    , 701
+    , 709
+    , 719
+    , 727
+    , 733
+    , 739
+    , 743
+    , 751
+    , 757
+    , 761
+    , 769
+    , 773
+    , 787
+    , 797
+    , 809
+    , 811
+    , 821
+    , 823
+    , 827
+    , 829
+    , 839
+    , 853
+    , 857
+    , 859
+    , 863
+    , 877
+    , 881
+    , 883
+    , 887
+    , 907
+    , 911
+    , 919
+    , 929
+    , 937
+    , 941
+    , 947
+    , 953
+    , 967
+    , 971
+    , 977
+    , 983
+    , 991
+    , 997
+    , 1009
+    , 1013
+    , 1019
+    , 1021
+    , 1031
+    , 1033
+    , 1039
+    , 1049
+    , 1051
+    , 1061
+    , 1063
+    , 1069
+    , 1087
+    , 1091
+    , 1093
+    , 1097
+    , 1103
+    , 1109
+    , 1117
+    , 1123
+    , 1129
+    , 1151
+    , 1153
+    , 1163
+    , 1171
+    , 1181
+    , 1187
+    , 1193
+    , 1201
+    , 1213
+    , 1217
+    , 1223
+    , 1229
+    , 1231
+    , 1237
+    , 1249
+    , 1259
+    , 1277
+    , 1279
+    , 1283
+    , 1289
+    , 1291
+    , 1297
+    , 1301
+    , 1303
+    , 1307
+    , 1319
+    , 1321
+    , 1327
+    , 1361
+    , 1367
+    , 1373
+    , 1381
+    , 1399
+    , 1409
+    , 1423
+    , 1427
+    , 1429
+    , 1433
+    , 1439
+    , 1447
+    , 1451
+    , 1453
+    , 1459
+    , 1471
+    , 1481
+    , 1483
+    , 1487
+    , 1489
+    , 1493
+    , 1499
+    , 1511
+    , 1523
+    , 1531
+    , 1543
+    , 1549
+    , 1553
+    , 1559
+    , 1567
+    , 1571
+    , 1579
+    , 1583
+    , 1597
+    , 1601
+    , 1607
+    , 1609
+    , 1613
+    , 1619
+    , 1621
+    , 1627
+    , 1637
+    , 1657
+    , 1663
+    , 1667
+    , 1669
+    , 1693
+    , 1697
+    , 1699
+    , 1709
+    , 1721
+    , 1723
+    , 1733
+    , 1741
+    , 1747
+    , 1753
+    , 1759
+    , 1777
+    , 1783
+    , 1787
+    , 1789
+    , 1801
+    , 1811
+    , 1823
+    , 1831
+    , 1847
+    , 1861
+    , 1867
+    , 1871
+    , 1873
+    , 1877
+    , 1879
+    , 1889
+    , 1901
+    , 1907
+    , 1913
+    , 1931
+    , 1933
+    , 1949
+    , 1951
+    , 1973
+    , 1979
+    , 1987
+    , 1993
+    , 1997
+    , 1999
+    , 2003
+    , 2011
+    , 2017
+    , 2027
+    , 2029
+    , 2039
+    , 2053
+    , 2063
+    , 2069
+    , 2081
+    , 2083
+    , 2087
+    , 2089
+    , 2099
+    , 2111
+    , 2113
+    , 2129
+    , 2131
+    , 2137
+    , 2141
+    , 2143
+    , 2153
+    , 2161
+    , 2179
+    , 2203
+    , 2207
+    , 2213
+    , 2221
+    , 2237
+    , 2239
+    , 2243
+    , 2251
+    , 2267
+    , 2269
+    , 2273
+    , 2281
+    , 2287
+    , 2293
+    , 2297
+    , 2309
+    , 2311
+    , 2333
+    , 2339
+    , 2341
+    , 2347
+    , 2351
+    , 2357
+    , 2371
+    , 2377
+    , 2381
+    , 2383
+    , 2389
+    , 2393
+    , 2399
+    , 2411
+    , 2417
+    , 2423
+    , 2437
+    , 2441
+    , 2447
+    , 2459
+    , 2467
+    , 2473
+    , 2477
+    , 2503
+    , 2521
+    , 2531
+    , 2539
+    , 2543
+    , 2549
+    , 2551
+    , 2557
+    , 2579
+    , 2591
+    , 2593
+    , 2609
+    , 2617
+    , 2621
+    , 2633
+    , 2647
+    , 2657
+    , 2659
+    , 2663
+    , 2671
+    , 2677
+    , 2683
+    , 2687
+    , 2689
+    , 2693
+    , 2699
+    , 2707
+    , 2711
+    , 2713
+    , 2719
+    , 2729
+    , 2731
+    , 2741
+    , 2749
+    , 2753
+    , 2767
+    , 2777
+    , 2789
+    , 2791
+    , 2797
+    , 2801
+    , 2803
+    , 2819
+    , 2833
+    , 2837
+    , 2843
+    , 2851
+    , 2857
+    , 2861
+    , 2879
+    , 2887
+    , 2897
+    , 2903
     ]
 
 {-# INLINE divides #-}
diff --git a/Crypto/Number/Serialize.hs b/Crypto/Number/Serialize.hs
--- a/Crypto/Number/Serialize.hs
+++ b/Crypto/Number/Serialize.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.Number.Serialize
 -- License     : BSD-style
@@ -6,17 +8,16 @@
 -- Portability : Good
 --
 -- Fast serialization primitives for integer
-{-# LANGUAGE BangPatterns #-}
-module Crypto.Number.Serialize
-    ( i2osp
-    , os2ip
-    , i2ospOf
-    , i2ospOf_
-    ) where
+module Crypto.Number.Serialize (
+    i2osp,
+    os2ip,
+    i2ospOf,
+    i2ospOf_,
+) where
 
-import           Crypto.Number.Basic
-import           Crypto.Internal.Compat (unsafeDoIO)
 import qualified Crypto.Internal.ByteArray as B
+import Crypto.Internal.Compat (unsafeDoIO)
+import Crypto.Number.Basic
 import qualified Crypto.Number.Serialize.Internal as Internal
 
 -- | @os2ip@ converts a byte string into a positive integer.
@@ -27,23 +28,24 @@
 --
 -- The first byte is MSB (most significant byte); the last byte is the LSB (least significant byte)
 i2osp :: B.ByteArray ba => Integer -> ba
-i2osp 0 = B.allocAndFreeze 1  (\p -> Internal.i2osp 0 p 1 >> return ())
+i2osp 0 = B.allocAndFreeze 1 (\p -> Internal.i2osp 0 p 1 >> return ())
 i2osp m = B.allocAndFreeze sz (\p -> Internal.i2osp m p sz >> return ())
   where
-        !sz = numBytes m
+    !sz = numBytes m
 
 -- | Just like 'i2osp', but takes an extra parameter for size.
 -- If the number is too big to fit in @len@ bytes, 'Nothing' is returned
 -- otherwise the number is padded with 0 to fit the @len@ required.
-{-# INLINABLE i2ospOf #-}
+{-# INLINEABLE i2ospOf #-}
 i2ospOf :: B.ByteArray ba => Int -> Integer -> Maybe ba
 i2ospOf len m
-    | len <= 0  = Nothing
-    | m < 0     = Nothing
-    | sz > len  = Nothing
-    | otherwise = Just $ B.unsafeCreate len (\p -> Internal.i2ospOf m p len >> return ())
+    | len <= 0 = Nothing
+    | m < 0 = Nothing
+    | sz > len = Nothing
+    | otherwise =
+        Just $ B.unsafeCreate len (\p -> Internal.i2ospOf m p len >> return ())
   where
-        !sz = numBytes m
+    !sz = numBytes m
 
 -- | Just like 'i2ospOf' except that it doesn't expect a failure: i.e.
 -- an integer larger than the number of output bytes requested.
diff --git a/Crypto/Number/Serialize/Internal.hs b/Crypto/Number/Serialize/Internal.hs
--- a/Crypto/Number/Serialize/Internal.hs
+++ b/Crypto/Number/Serialize/Internal.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.Number.Serialize.Internal
 -- License     : BSD-style
@@ -6,20 +8,19 @@
 -- Portability : Good
 --
 -- Fast serialization primitives for integer using raw pointers
-{-# LANGUAGE BangPatterns #-}
-module Crypto.Number.Serialize.Internal
-    ( i2osp
-    , i2ospOf
-    , os2ip
-    ) where
+module Crypto.Number.Serialize.Internal (
+    i2osp,
+    i2ospOf,
+    os2ip,
+) where
 
-import           Crypto.Number.Compat
-import           Crypto.Number.Basic
-import           Data.Bits
-import           Data.Memory.PtrMethods
-import           Data.Word (Word8)
-import           Foreign.Ptr
-import           Foreign.Storable
+import Crypto.Number.Basic
+import Crypto.Number.Compat
+import Data.Bits
+import Data.Memory.PtrMethods
+import Data.Word (Word8)
+import Foreign.Ptr
+import Foreign.Storable
 
 -- | Fill a pointer with the big endian binary representation of an integer
 --
@@ -30,47 +31,47 @@
 i2osp :: Integer -> Ptr Word8 -> Int -> IO Int
 i2osp m ptr ptrSz
     | ptrSz <= 0 = return 0
-    | m < 0      = return 0
-    | m == 0     = pokeByteOff ptr 0 (0 :: Word8) >> return 1
+    | m < 0 = return 0
+    | m == 0 = pokeByteOff ptr 0 (0 :: Word8) >> return 1
     | ptrSz < sz = return 0
-    | otherwise  = fillPtr ptr sz m >> return sz
+    | otherwise = fillPtr ptr sz m >> return sz
   where
-    !sz    = numBytes m
+    !sz = numBytes m
 
 -- | Similar to 'i2osp', except it will pad any remaining space with zero.
 i2ospOf :: Integer -> Ptr Word8 -> Int -> IO Int
 i2ospOf m ptr ptrSz
     | ptrSz <= 0 = return 0
-    | m < 0      = return 0
+    | m < 0 = return 0
     | ptrSz < sz = return 0
-    | otherwise  = do
+    | otherwise = do
         memSet ptr 0 ptrSz
         fillPtr (ptr `plusPtr` padSz) sz m
         return ptrSz
   where
-    !sz    = numBytes m
+    !sz = numBytes m
     !padSz = ptrSz - sz
 
 fillPtr :: Ptr Word8 -> Int -> Integer -> IO ()
-fillPtr p sz m = gmpExportInteger m p `onGmpUnsupported` export (sz-1) m
+fillPtr p sz m = gmpExportInteger m p `onGmpUnsupported` export (sz - 1) m
   where
     export ofs i
-        | ofs == 0  = pokeByteOff p ofs (fromIntegral i :: Word8)
+        | ofs == 0 = pokeByteOff p ofs (fromIntegral i :: Word8)
         | otherwise = do
             let (i', b) = i `divMod` 256
             pokeByteOff p ofs (fromIntegral b :: Word8)
-            export (ofs-1) i'
+            export (ofs - 1) i'
 
 -- | Transform a big endian binary integer representation pointed by a pointer and a size
 -- into an integer
 os2ip :: Ptr Word8 -> Int -> IO Integer
 os2ip ptr ptrSz
     | ptrSz <= 0 = return 0
-    | otherwise  = gmpImportInteger ptrSz ptr `onGmpUnsupported` loop 0 0 ptr
+    | otherwise = gmpImportInteger ptrSz ptr `onGmpUnsupported` loop 0 0 ptr
   where
     loop :: Integer -> Int -> Ptr Word8 -> IO Integer
     loop !acc i !p
         | i == ptrSz = return acc
-        | otherwise  = do
+        | otherwise = do
             w <- peekByteOff p i :: IO Word8
-            loop ((acc `shiftL` 8) .|. fromIntegral w) (i+1) p
+            loop ((acc `shiftL` 8) .|. fromIntegral w) (i + 1) p
diff --git a/Crypto/Number/Serialize/Internal/LE.hs b/Crypto/Number/Serialize/Internal/LE.hs
--- a/Crypto/Number/Serialize/Internal/LE.hs
+++ b/Crypto/Number/Serialize/Internal/LE.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.Number.Serialize.Internal.LE
 -- License     : BSD-style
@@ -6,20 +8,19 @@
 -- Portability : Good
 --
 -- Fast serialization primitives for integer using raw pointers (little endian)
-{-# LANGUAGE BangPatterns #-}
-module Crypto.Number.Serialize.Internal.LE
-    ( i2osp
-    , i2ospOf
-    , os2ip
-    ) where
+module Crypto.Number.Serialize.Internal.LE (
+    i2osp,
+    i2ospOf,
+    os2ip,
+) where
 
-import           Crypto.Number.Compat
-import           Crypto.Number.Basic
-import           Data.Bits
-import           Data.Memory.PtrMethods
-import           Data.Word (Word8)
-import           Foreign.Ptr
-import           Foreign.Storable
+import Crypto.Number.Basic
+import Crypto.Number.Compat
+import Data.Bits
+import Data.Memory.PtrMethods
+import Data.Word (Word8)
+import Foreign.Ptr
+import Foreign.Storable
 
 -- | Fill a pointer with the little endian binary representation of an integer
 --
@@ -30,25 +31,25 @@
 i2osp :: Integer -> Ptr Word8 -> Int -> IO Int
 i2osp m ptr ptrSz
     | ptrSz <= 0 = return 0
-    | m < 0      = return 0
-    | m == 0     = pokeByteOff ptr 0 (0 :: Word8) >> return 1
+    | m < 0 = return 0
+    | m == 0 = pokeByteOff ptr 0 (0 :: Word8) >> return 1
     | ptrSz < sz = return 0
-    | otherwise  = fillPtr ptr sz m >> return sz
+    | otherwise = fillPtr ptr sz m >> return sz
   where
-    !sz    = numBytes m
+    !sz = numBytes m
 
 -- | Similar to 'i2osp', except it will pad any remaining space with zero.
 i2ospOf :: Integer -> Ptr Word8 -> Int -> IO Int
 i2ospOf m ptr ptrSz
     | ptrSz <= 0 = return 0
-    | m < 0      = return 0
+    | m < 0 = return 0
     | ptrSz < sz = return 0
-    | otherwise  = do
+    | otherwise = do
         memSet ptr 0 ptrSz
         fillPtr ptr sz m
         return ptrSz
   where
-    !sz    = numBytes m
+    !sz = numBytes m
 
 fillPtr :: Ptr Word8 -> Int -> Integer -> IO ()
 fillPtr p sz m = gmpExportIntegerLE m p `onGmpUnsupported` export 0 m
@@ -58,18 +59,19 @@
         | otherwise = do
             let (i', b) = i `divMod` 256
             pokeByteOff p ofs (fromIntegral b :: Word8)
-            export (ofs+1) i'
+            export (ofs + 1) i'
 
 -- | Transform a little endian binary integer representation pointed by a
 -- pointer and a size into an integer
 os2ip :: Ptr Word8 -> Int -> IO Integer
 os2ip ptr ptrSz
     | ptrSz <= 0 = return 0
-    | otherwise  = gmpImportIntegerLE ptrSz ptr `onGmpUnsupported` loop 0 (ptrSz-1) ptr
+    | otherwise =
+        gmpImportIntegerLE ptrSz ptr `onGmpUnsupported` loop 0 (ptrSz - 1) ptr
   where
     loop :: Integer -> Int -> Ptr Word8 -> IO Integer
     loop !acc i !p
-        | i < 0      = return acc
-        | otherwise  = do
+        | i < 0 = return acc
+        | otherwise = do
             w <- peekByteOff p i :: IO Word8
-            loop ((acc `shiftL` 8) .|. fromIntegral w) (i-1) p
+            loop ((acc `shiftL` 8) .|. fromIntegral w) (i - 1) p
diff --git a/Crypto/Number/Serialize/LE.hs b/Crypto/Number/Serialize/LE.hs
--- a/Crypto/Number/Serialize/LE.hs
+++ b/Crypto/Number/Serialize/LE.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.Number.Serialize.LE
 -- License     : BSD-style
@@ -6,17 +8,16 @@
 -- Portability : Good
 --
 -- Fast serialization primitives for integer (little endian)
-{-# LANGUAGE BangPatterns #-}
-module Crypto.Number.Serialize.LE
-    ( i2osp
-    , os2ip
-    , i2ospOf
-    , i2ospOf_
-    ) where
+module Crypto.Number.Serialize.LE (
+    i2osp,
+    os2ip,
+    i2ospOf,
+    i2ospOf_,
+) where
 
-import           Crypto.Number.Basic
-import           Crypto.Internal.Compat (unsafeDoIO)
 import qualified Crypto.Internal.ByteArray as B
+import Crypto.Internal.Compat (unsafeDoIO)
+import Crypto.Number.Basic
 import qualified Crypto.Number.Serialize.Internal.LE as Internal
 
 -- | @os2ip@ converts a byte string into a positive integer.
@@ -27,23 +28,24 @@
 --
 -- The first byte is LSB (least significant byte); the last byte is the MSB (most significant byte)
 i2osp :: B.ByteArray ba => Integer -> ba
-i2osp 0 = B.allocAndFreeze 1  (\p -> Internal.i2osp 0 p 1 >> return ())
+i2osp 0 = B.allocAndFreeze 1 (\p -> Internal.i2osp 0 p 1 >> return ())
 i2osp m = B.allocAndFreeze sz (\p -> Internal.i2osp m p sz >> return ())
   where
-        !sz = numBytes m
+    !sz = numBytes m
 
 -- | Just like 'i2osp', but takes an extra parameter for size.
 -- If the number is too big to fit in @len@ bytes, 'Nothing' is returned
 -- otherwise the number is padded with 0 to fit the @len@ required.
-{-# INLINABLE i2ospOf #-}
+{-# INLINEABLE i2ospOf #-}
 i2ospOf :: B.ByteArray ba => Int -> Integer -> Maybe ba
 i2ospOf len m
-    | len <= 0  = Nothing
-    | m < 0     = Nothing
-    | sz > len  = Nothing
-    | otherwise = Just $ B.unsafeCreate len (\p -> Internal.i2ospOf m p len >> return ())
+    | len <= 0 = Nothing
+    | m < 0 = Nothing
+    | sz > len = Nothing
+    | otherwise =
+        Just $ B.unsafeCreate len (\p -> Internal.i2ospOf m p len >> return ())
   where
-        !sz = numBytes m
+    !sz = numBytes m
 
 -- | Just like 'i2ospOf' except that it doesn't expect a failure: i.e.
 -- an integer larger than the number of output bytes requested.
diff --git a/Crypto/OTP.hs b/Crypto/OTP.hs
--- a/Crypto/OTP.hs
+++ b/Crypto/OTP.hs
@@ -25,33 +25,30 @@
 -- >>> import Data.Time.Clock.POSIX
 -- >>>
 -- >>> let getOTPTime = getPOSIXTime >>= \t -> return (floor t :: OTPTime)
---
-
-module Crypto.OTP
-    ( OTP
-    , OTPDigits (..)
-    , OTPTime
-    , hotp
-    , resynchronize
-    , totp
-    , totpVerify
-    , TOTPParams
-    , ClockSkew (..)
-    , defaultTOTPParams
-    , mkTOTPParams
-    )
+module Crypto.OTP (
+    OTP,
+    OTPDigits (..),
+    OTPTime,
+    hotp,
+    resynchronize,
+    totp,
+    totpVerify,
+    TOTPParams,
+    ClockSkew (..),
+    defaultTOTPParams,
+    mkTOTPParams,
+)
 where
 
-import           Data.Bits (shiftL, (.&.), (.|.))
-import           Data.ByteArray.Mapping (fromW64BE)
-import           Data.List (elemIndex)
-import           Data.Word
-import           Control.Monad (unless)
-import           Crypto.Hash (HashAlgorithm, SHA1(..))
-import           Crypto.MAC.HMAC
-import           Crypto.Internal.ByteArray (ByteArrayAccess, Bytes)
+import Control.Monad (unless)
+import Crypto.Hash (HashAlgorithm, SHA1 (..))
+import Crypto.Internal.ByteArray (ByteArrayAccess, Bytes)
 import qualified Crypto.Internal.ByteArray as B
-
+import Crypto.MAC.HMAC
+import Data.Bits (shiftL, (.&.), (.|.))
+import Data.ByteArray.Mapping (fromW64BE)
+import Data.List (elemIndex)
+import Data.Word
 
 -- | A one-time password which is a sequence of 4 to 9 digits.
 type OTP = Word32
@@ -63,7 +60,9 @@
 -- | An integral time value in seconds.
 type OTPTime = Word64
 
-hotp :: forall hash key. (HashAlgorithm hash, ByteArrayAccess key)
+hotp
+    :: forall hash key
+     . (HashAlgorithm hash, ByteArrayAccess key)
     => hash
     -> OTPDigits
     -- ^ Number of digits in the HOTP value extracted from the calculated HMAC
@@ -77,14 +76,16 @@
   where
     mac = hmac k (fromW64BE c :: Bytes) :: HMAC hash
     offset = fromIntegral (B.index mac (B.length mac - 1) .&. 0xf)
-    dt = (fromIntegral (B.index mac offset       .&. 0x7f) `shiftL` 24) .|.
-         (fromIntegral (B.index mac (offset + 1) .&. 0xff) `shiftL` 16) .|.
-         (fromIntegral (B.index mac (offset + 2) .&. 0xff) `shiftL`  8) .|.
-         fromIntegral  (B.index mac (offset + 3) .&. 0xff)
+    dt =
+        (fromIntegral (B.index mac offset .&. 0x7f) `shiftL` 24)
+            .|. (fromIntegral (B.index mac (offset + 1) .&. 0xff) `shiftL` 16)
+            .|. (fromIntegral (B.index mac (offset + 2) .&. 0xff) `shiftL` 8)
+            .|. fromIntegral (B.index mac (offset + 3) .&. 0xff)
 
 -- | Attempt to resynchronize the server's counter value
 -- with the client, given a sequence of HOTP values.
-resynchronize :: (HashAlgorithm hash, ByteArrayAccess key)
+resynchronize
+    :: (HashAlgorithm hash, ByteArrayAccess key)
     => hash
     -> OTPDigits
     -> Word16
@@ -105,11 +106,11 @@
     checkExtraOtps (c + offBy + 1) extras
   where
     checkExtraOtps ctr [] = Just ctr
-    checkExtraOtps ctr (p:ps)
+    checkExtraOtps ctr (p : ps)
         | hotp h d k ctr /= p = Nothing
-        | otherwise           = checkExtraOtps (ctr + 1) ps
+        | otherwise = checkExtraOtps (ctr + 1) ps
 
-    range = map (hotp h d k)[c..c + fromIntegral s]
+    range = map (hotp h d k) [c .. c + fromIntegral s]
 
 digitsPower :: OTPDigits -> Word32
 digitsPower OTP4 = 10000
@@ -119,17 +120,18 @@
 digitsPower OTP8 = 100000000
 digitsPower OTP9 = 1000000000
 
-
 data TOTPParams h = TP !h !OTPTime !Word16 !OTPDigits !ClockSkew deriving (Show)
 
-data ClockSkew = NoSkew | OneStep | TwoSteps | ThreeSteps | FourSteps deriving (Enum, Show)
+data ClockSkew = NoSkew | OneStep | TwoSteps | ThreeSteps | FourSteps
+    deriving (Enum, Show)
 
 -- | The default TOTP configuration.
 defaultTOTPParams :: TOTPParams SHA1
 defaultTOTPParams = TP SHA1 0 30 OTP6 TwoSteps
 
 -- | Create a TOTP configuration with customized parameters.
-mkTOTPParams :: (HashAlgorithm hash)
+mkTOTPParams
+    :: HashAlgorithm hash
     => hash
     -> OTPTime
     -- ^ The T0 parameter in seconds. This is the Unix time from which to start
@@ -149,7 +151,8 @@
     return (TP h t0 x d skew)
 
 -- | Calculate a totp value for the given time.
-totp :: (HashAlgorithm hash, ByteArrayAccess key)
+totp
+    :: (HashAlgorithm hash, ByteArrayAccess key)
     => TOTPParams hash
     -> key
     -- ^ The shared secret
@@ -161,7 +164,8 @@
 
 -- | Check a supplied TOTP value is valid for the given time,
 -- within the window defined by the skew parameter.
-totpVerify :: (HashAlgorithm hash, ByteArrayAccess key)
+totpVerify
+    :: (HashAlgorithm hash, ByteArrayAccess key)
     => TOTPParams hash
     -> key
     -> OTPTime
@@ -172,7 +176,7 @@
     t = timeToCounter now t0 x
     window = fromIntegral (fromEnum skew)
     range 0 acc = t : acc
-    range n acc = range (n-1) ((t-n) : (t+n) : acc)
+    range n acc = range (n - 1) ((t - n) : (t + n) : acc)
 
 timeToCounter :: Word64 -> Word64 -> Word16 -> Word64
 timeToCounter now t0 x = (now - t0) `div` fromIntegral x
diff --git a/Crypto/PubKey/Curve25519.hs b/Crypto/PubKey/Curve25519.hs
--- a/Crypto/PubKey/Curve25519.hs
+++ b/Crypto/PubKey/Curve25519.hs
@@ -1,3 +1,7 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- |
 -- Module      : Crypto.PubKey.Curve25519
 -- License     : BSD-style
@@ -6,55 +10,59 @@
 -- Portability : unknown
 --
 -- Curve25519 support
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE MagicHash #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-module Crypto.PubKey.Curve25519
-    ( SecretKey
-    , PublicKey
-    , DhSecret
+module Crypto.PubKey.Curve25519 (
+    SecretKey,
+    PublicKey,
+    DhSecret,
+
     -- * Smart constructors
-    , dhSecret
-    , publicKey
-    , secretKey
+    dhSecret,
+    publicKey,
+    secretKey,
+
     -- * Methods
-    , dh
-    , toPublic
-    , generateSecretKey
-    ) where
+    dh,
+    toPublic,
+    generateSecretKey,
+) where
 
-import           Data.Bits
-import           Data.Word
-import           Foreign.Ptr
-import           Foreign.Storable
-import           GHC.Ptr
+import Data.Bits
+import Data.Word
+import Foreign.Ptr
+import Foreign.Storable
+import GHC.Ptr
 
-import           Crypto.Error
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ScrubbedBytes, Bytes, withByteArray)
+import Crypto.Error
+import Crypto.Internal.ByteArray (
+    ByteArrayAccess,
+    Bytes,
+    ScrubbedBytes,
+    withByteArray,
+ )
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Random
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Crypto.Random
 
 -- | A Curve25519 Secret key
 newtype SecretKey = SecretKey ScrubbedBytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | A Curve25519 public key
 newtype PublicKey = PublicKey Bytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | A Curve25519 Diffie Hellman secret related to a
 -- public key and a secret key.
 newtype DhSecret = DhSecret ScrubbedBytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | Try to build a public key from a bytearray
 publicKey :: ByteArrayAccess bs => bs -> CryptoFailable PublicKey
 publicKey bs
-    | B.length bs == 32 = CryptoPassed $ PublicKey $ B.copyAndFreeze bs (\_ -> return ())
-    | otherwise         = CryptoFailed CryptoError_PublicKeySizeInvalid
+    | B.length bs == 32 =
+        CryptoPassed $ PublicKey $ B.copyAndFreeze bs (\_ -> return ())
+    | otherwise = CryptoFailed CryptoError_PublicKeySizeInvalid
 
 -- | Try to build a secret key from a bytearray
 secretKey :: ByteArrayAccess bs => bs -> CryptoFailable SecretKey
@@ -67,14 +75,14 @@
                 else return $ CryptoFailed CryptoError_SecretKeyStructureInvalid
     | otherwise = CryptoFailed CryptoError_SecretKeySizeInvalid
   where
-        --  e[0] &= 0xf8;
-        --  e[31] &= 0x7f;
-        --  e[31] |= 40;
-        isValidPtr :: Ptr Word8 -> IO Bool
-        isValidPtr _ = do
-            --b0  <- peekElemOff inp 0
-            --b31 <- peekElemOff inp 31
-            return True
+    --  e[0] &= 0xf8;
+    --  e[31] &= 0x7f;
+    --  e[31] |= 40;
+    isValidPtr :: Ptr Word8 -> IO Bool
+    isValidPtr _ = do
+        -- b0  <- peekElemOff inp 0
+        -- b31 <- peekElemOff inp 31
+        return True
 {-
             return $ and [ testBit b0  0 == False
                          , testBit b0  1 == False
@@ -88,29 +96,34 @@
 -- | Create a DhSecret from a bytearray object
 dhSecret :: ByteArrayAccess b => b -> CryptoFailable DhSecret
 dhSecret bs
-    | B.length bs == 32 = CryptoPassed $ DhSecret $ B.copyAndFreeze bs (\_ -> return ())
-    | otherwise         = CryptoFailed CryptoError_SharedSecretSizeInvalid
+    | B.length bs == 32 =
+        CryptoPassed $ DhSecret $ B.copyAndFreeze bs (\_ -> return ())
+    | otherwise = CryptoFailed CryptoError_SharedSecretSizeInvalid
 
 -- | Compute the Diffie Hellman secret from a public key and a secret key.
 --
 -- This implementation may return an all-zero value as it does not check for
 -- the condition.
 dh :: PublicKey -> SecretKey -> DhSecret
-dh (PublicKey pub) (SecretKey sec) = DhSecret <$>
-    B.allocAndFreeze 32        $ \result ->
-    withByteArray sec          $ \psec   ->
-    withByteArray pub          $ \ppub   ->
-        ccrypton_curve25519 result psec ppub
+dh (PublicKey pub) (SecretKey sec) = DhSecret
+    <$> B.allocAndFreeze 32
+    $ \result ->
+        withByteArray sec $ \psec ->
+            withByteArray pub $ \ppub ->
+                ccrypton_curve25519 result psec ppub
 {-# NOINLINE dh #-}
 
 -- | Create a public key from a secret key
 toPublic :: SecretKey -> PublicKey
-toPublic (SecretKey sec) = PublicKey <$>
-    B.allocAndFreeze 32     $ \result ->
-    withByteArray sec       $ \psec   ->
-        ccrypton_curve25519 result psec basePoint
+toPublic (SecretKey sec) = PublicKey
+    <$> B.allocAndFreeze 32
+    $ \result ->
+        withByteArray sec $ \psec ->
+            ccrypton_curve25519 result psec basePoint
   where
-        basePoint = Ptr "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#
+    basePoint =
+        Ptr
+            "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#
 {-# NOINLINE toPublic #-}
 
 -- | Generate a secret key.
@@ -126,7 +139,11 @@
     modifyByte p n f = peekByteOff p n >>= pokeByteOff p n . f
 
 foreign import ccall "crypton_curve25519_donna"
-    ccrypton_curve25519 :: Ptr Word8 -- ^ public
-                           -> Ptr Word8 -- ^ secret
-                           -> Ptr Word8 -- ^ basepoint
-                           -> IO ()
+    ccrypton_curve25519
+        :: Ptr Word8
+        -- ^ public
+        -> Ptr Word8
+        -- ^ secret
+        -> Ptr Word8
+        -- ^ basepoint
+        -> IO ()
diff --git a/Crypto/PubKey/Curve448.hs b/Crypto/PubKey/Curve448.hs
--- a/Crypto/PubKey/Curve448.hs
+++ b/Crypto/PubKey/Curve448.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.PubKey.Curve448
 -- License     : BSD-style
@@ -10,50 +12,56 @@
 -- Internally uses Decaf point compression to omit the cofactor
 -- and implementation by Mike Hamburg.  Externally API and
 -- data types are compatible with the encoding specified in RFC 7748.
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.PubKey.Curve448
-    ( SecretKey
-    , PublicKey
-    , DhSecret
+module Crypto.PubKey.Curve448 (
+    SecretKey,
+    PublicKey,
+    DhSecret,
+
     -- * Smart constructors
-    , dhSecret
-    , publicKey
-    , secretKey
+    dhSecret,
+    publicKey,
+    secretKey,
+
     -- * Methods
-    , dh
-    , toPublic
-    , generateSecretKey
-    ) where
+    dh,
+    toPublic,
+    generateSecretKey,
+) where
 
-import           Data.Word
-import           Foreign.Ptr
+import Data.Word
+import Foreign.Ptr
 
-import           Crypto.Error
-import           Crypto.Random
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ScrubbedBytes, Bytes, withByteArray)
+import Crypto.Error
+import Crypto.Internal.ByteArray (
+    ByteArrayAccess,
+    Bytes,
+    ScrubbedBytes,
+    withByteArray,
+ )
 import qualified Crypto.Internal.ByteArray as B
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Crypto.Random
 
 -- | A Curve448 Secret key
 newtype SecretKey = SecretKey ScrubbedBytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | A Curve448 public key
 newtype PublicKey = PublicKey Bytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | A Curve448 Diffie Hellman secret related to a
 -- public key and a secret key.
 newtype DhSecret = DhSecret ScrubbedBytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | Try to build a public key from a bytearray
 publicKey :: ByteArrayAccess bs => bs -> CryptoFailable PublicKey
 publicKey bs
-    | B.length bs == x448_bytes = CryptoPassed $ PublicKey $ B.copyAndFreeze bs (\_ -> return ())
-    | otherwise                 = CryptoFailed CryptoError_PublicKeySizeInvalid
+    | B.length bs == x448_bytes =
+        CryptoPassed $ PublicKey $ B.copyAndFreeze bs (\_ -> return ())
+    | otherwise = CryptoFailed CryptoError_PublicKeySizeInvalid
 
 -- | Try to build a secret key from a bytearray
 secretKey :: ByteArrayAccess bs => bs -> CryptoFailable SecretKey
@@ -66,35 +74,38 @@
                 else return $ CryptoFailed CryptoError_SecretKeyStructureInvalid
     | otherwise = CryptoFailed CryptoError_SecretKeySizeInvalid
   where
-        isValidPtr :: Ptr Word8 -> IO Bool
-        isValidPtr _ =
-            return True
+    isValidPtr :: Ptr Word8 -> IO Bool
+    isValidPtr _ =
+        return True
 {-# NOINLINE secretKey #-}
 
 -- | Create a DhSecret from a bytearray object
 dhSecret :: ByteArrayAccess b => b -> CryptoFailable DhSecret
 dhSecret bs
-    | B.length bs == x448_bytes = CryptoPassed $ DhSecret $ B.copyAndFreeze bs (\_ -> return ())
-    | otherwise                 = CryptoFailed CryptoError_SharedSecretSizeInvalid
+    | B.length bs == x448_bytes =
+        CryptoPassed $ DhSecret $ B.copyAndFreeze bs (\_ -> return ())
+    | otherwise = CryptoFailed CryptoError_SharedSecretSizeInvalid
 
 -- | Compute the Diffie Hellman secret from a public key and a secret key.
 --
 -- This implementation may return an all-zero value as it does not check for
 -- the condition.
 dh :: PublicKey -> SecretKey -> DhSecret
-dh (PublicKey pub) (SecretKey sec) = DhSecret <$>
-    B.allocAndFreeze x448_bytes $ \result ->
-    withByteArray sec           $ \psec   ->
-    withByteArray pub           $ \ppub   ->
-        decaf_x448 result ppub psec
+dh (PublicKey pub) (SecretKey sec) = DhSecret
+    <$> B.allocAndFreeze x448_bytes
+    $ \result ->
+        withByteArray sec $ \psec ->
+            withByteArray pub $ \ppub ->
+                decaf_x448 result ppub psec
 {-# NOINLINE dh #-}
 
 -- | Create a public key from a secret key
 toPublic :: SecretKey -> PublicKey
-toPublic (SecretKey sec) = PublicKey <$>
-    B.allocAndFreeze x448_bytes     $ \result ->
-    withByteArray sec               $ \psec   ->
-        decaf_x448_derive_public_key result psec
+toPublic (SecretKey sec) = PublicKey
+    <$> B.allocAndFreeze x448_bytes
+    $ \result ->
+        withByteArray sec $ \psec ->
+            decaf_x448_derive_public_key result psec
 {-# NOINLINE toPublic #-}
 
 -- | Generate a secret key.
@@ -105,12 +116,19 @@
 x448_bytes = 448 `quot` 8
 
 foreign import ccall "crypton_decaf_x448"
-    decaf_x448 :: Ptr Word8 -- ^ public
-               -> Ptr Word8 -- ^ basepoint
-               -> Ptr Word8 -- ^ secret
-               -> IO ()
+    decaf_x448
+        :: Ptr Word8
+        -- ^ public
+        -> Ptr Word8
+        -- ^ basepoint
+        -> Ptr Word8
+        -- ^ secret
+        -> IO ()
 
 foreign import ccall "crypton_decaf_x448_derive_public_key"
-    decaf_x448_derive_public_key :: Ptr Word8 -- ^ public
-                                 -> Ptr Word8 -- ^ secret
-                                 -> IO ()
+    decaf_x448_derive_public_key
+        :: Ptr Word8
+        -- ^ public
+        -> Ptr Word8
+        -- ^ secret
+        -> IO ()
diff --git a/Crypto/PubKey/DH.hs b/Crypto/PubKey/DH.hs
--- a/Crypto/PubKey/DH.hs
+++ b/Crypto/PubKey/DH.hs
@@ -1,28 +1,28 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.PubKey.DH
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.PubKey.DH
-    ( Params(..)
-    , PublicNumber(..)
-    , PrivateNumber(..)
-    , SharedKey(..)
-    , generateParams
-    , generatePrivate
-    , calculatePublic
-    , generatePublic
-    , getShared
-    ) where
+module Crypto.PubKey.DH (
+    Params (..),
+    PublicNumber (..),
+    PrivateNumber (..),
+    SharedKey (..),
+    generateParams,
+    generatePrivate,
+    calculatePublic,
+    generatePublic,
+    getShared,
+) where
 
 import Crypto.Internal.Imports
+import Crypto.Number.Generate (generateMax)
 import Crypto.Number.ModArithmetic (expSafe)
 import Crypto.Number.Prime (generateSafePrime)
-import Crypto.Number.Generate (generateMax)
 import Crypto.Number.Serialize (i2ospOf_)
 import Crypto.Random.Types
 import Data.ByteArray (ByteArrayAccess, ScrubbedBytes)
@@ -33,29 +33,33 @@
     { params_p :: Integer
     , params_g :: Integer
     , params_bits :: Int
-    } deriving (Show,Read,Eq,Data)
+    }
+    deriving (Show, Read, Eq, Data)
 
 instance NFData Params where
     rnf (Params p g bits) = rnf p `seq` rnf g `seq` bits `seq` ()
 
 -- | Represent Diffie Hellman public number Y.
 newtype PublicNumber = PublicNumber Integer
-    deriving (Show,Read,Eq,Enum,Real,Num,Ord,NFData)
+    deriving (Show, Read, Eq, Enum, Real, Num, Ord, NFData)
 
 -- | Represent Diffie Hellman private number X.
 newtype PrivateNumber = PrivateNumber Integer
-    deriving (Show,Read,Eq,Enum,Real,Num,Ord,NFData)
+    deriving (Show, Read, Eq, Enum, Real, Num, Ord, NFData)
 
 -- | Represent Diffie Hellman shared secret.
 newtype SharedKey = SharedKey ScrubbedBytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | generate params from a specific generator (2 or 5 are common values)
 -- we generate a safe prime (a prime number of the form 2p+1 where p is also prime)
-generateParams :: MonadRandom m =>
-                  Int                   -- ^ number of bits
-               -> Integer               -- ^ generator
-               -> m Params
+generateParams
+    :: MonadRandom m
+    => Int
+    -- ^ number of bits
+    -> Integer
+    -- ^ generator
+    -> m Params
 generateParams bits generator =
     (\p -> Params p generator bits) <$> generateSafePrime bits
 
@@ -75,6 +79,7 @@
 -- DEPRECATED use calculatePublic
 generatePublic :: Params -> PrivateNumber -> PublicNumber
 generatePublic = calculatePublic
+
 -- commented until 0.3 {-# DEPRECATED generatePublic "use calculatePublic" #-}
 
 -- | generate a shared key using our private number and the other party public number
diff --git a/Crypto/PubKey/DSA.hs b/Crypto/PubKey/DSA.hs
--- a/Crypto/PubKey/DSA.hs
+++ b/Crypto/PubKey/DSA.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+
 -- |
 -- Module      : Crypto.PubKey.DSA
 -- License     : BSD-style
@@ -6,37 +8,39 @@
 -- Portability : Good
 --
 -- An implementation of the Digital Signature Algorithm (DSA)
-{-# LANGUAGE DeriveDataTypeable #-}
-module Crypto.PubKey.DSA
-    ( Params(..)
-    , Signature(..)
-    , PublicKey(..)
-    , PrivateKey(..)
-    , PublicNumber
-    , PrivateNumber
+module Crypto.PubKey.DSA (
+    Params (..),
+    Signature (..),
+    PublicKey (..),
+    PrivateKey (..),
+    PublicNumber,
+    PrivateNumber,
+
     -- * Generation
-    , generatePrivate
-    , calculatePublic
+    generatePrivate,
+    calculatePublic,
+
     -- * Signature primitive
-    , sign
-    , signWith
+    sign,
+    signWith,
+
     -- * Verification primitive
-    , verify
-    -- * Key pair
-    , KeyPair(..)
-    , toPublicKey
-    , toPrivateKey
-    ) where
+    verify,
 
+    -- * Key pair
+    KeyPair (..),
+    toPublicKey,
+    toPrivateKey,
+) where
 
 import Data.Data
 import Data.Maybe
 
-import Crypto.Number.ModArithmetic (expFast, expSafe, inverse)
-import Crypto.Number.Generate
+import Crypto.Hash
 import Crypto.Internal.ByteArray (ByteArrayAccess)
 import Crypto.Internal.Imports
-import Crypto.Hash
+import Crypto.Number.Generate
+import Crypto.Number.ModArithmetic (expFast, expSafe, inverse)
 import Crypto.PubKey.Internal (dsaTruncHash)
 import Crypto.Random.Types
 
@@ -48,28 +52,38 @@
 
 -- | Represent DSA parameters namely P, G, and Q.
 data Params = Params
-    { params_p :: Integer -- ^ DSA p
-    , params_g :: Integer -- ^ DSA g
-    , params_q :: Integer -- ^ DSA q
-    } deriving (Show,Read,Eq,Data)
+    { params_p :: Integer
+    -- ^ DSA p
+    , params_g :: Integer
+    -- ^ DSA g
+    , params_q :: Integer
+    -- ^ DSA q
+    }
+    deriving (Show, Read, Eq, Data)
 
 instance NFData Params where
     rnf (Params p g q) = p `seq` g `seq` q `seq` ()
 
 -- | Represent a DSA signature namely R and S.
 data Signature = Signature
-    { sign_r :: Integer -- ^ DSA r
-    , sign_s :: Integer -- ^ DSA s
-    } deriving (Show,Read,Eq,Data)
+    { sign_r :: Integer
+    -- ^ DSA r
+    , sign_s :: Integer
+    -- ^ DSA s
+    }
+    deriving (Show, Read, Eq, Data)
 
 instance NFData Signature where
     rnf (Signature r s) = r `seq` s `seq` ()
 
 -- | Represent a DSA public key.
 data PublicKey = PublicKey
-    { public_params :: Params       -- ^ DSA parameters
-    , public_y      :: PublicNumber -- ^ DSA public Y
-    } deriving (Show,Read,Eq,Data)
+    { public_params :: Params
+    -- ^ DSA parameters
+    , public_y :: PublicNumber
+    -- ^ DSA public Y
+    }
+    deriving (Show, Read, Eq, Data)
 
 instance NFData PublicKey where
     rnf (PublicKey params y) = y `seq` params `seq` ()
@@ -79,16 +93,19 @@
 -- Only x need to be secret.
 -- the DSA parameters are publicly shared with the other side.
 data PrivateKey = PrivateKey
-    { private_params :: Params        -- ^ DSA parameters
-    , private_x      :: PrivateNumber -- ^ DSA private X
-    } deriving (Show,Read,Eq,Data)
+    { private_params :: Params
+    -- ^ DSA parameters
+    , private_x :: PrivateNumber
+    -- ^ DSA private X
+    }
+    deriving (Show, Read, Eq, Data)
 
 instance NFData PrivateKey where
     rnf (PrivateKey params x) = x `seq` params `seq` ()
 
 -- | Represent a DSA key pair
 data KeyPair = KeyPair Params PublicNumber PrivateNumber
-    deriving (Show,Read,Eq,Data)
+    deriving (Show, Read, Eq, Data)
 
 instance NFData KeyPair where
     rnf (KeyPair params y x) = x `seq` y `seq` params `seq` ()
@@ -111,44 +128,55 @@
 calculatePublic (Params p g _) x = expSafe g x p
 
 -- | sign message using the private key and an explicit k number.
-signWith :: (ByteArrayAccess msg, HashAlgorithm hash)
-         => Integer         -- ^ k random number
-         -> PrivateKey      -- ^ private key
-         -> hash            -- ^ hash function
-         -> msg             -- ^ message to sign
-         -> Maybe Signature
+signWith
+    :: (ByteArrayAccess msg, HashAlgorithm hash)
+    => Integer
+    -- ^ k random number
+    -> PrivateKey
+    -- ^ private key
+    -> hash
+    -- ^ hash function
+    -> msg
+    -- ^ message to sign
+    -> Maybe Signature
 signWith k pk hashAlg msg
-    | r == 0 || s == 0  = Nothing
-    | otherwise         = Just $ Signature r s
-    where -- parameters
-          (Params p g q) = private_params pk
-          x              = private_x pk
-          -- compute r,s
-          kInv      = fromJust $ inverse k q
-          hm        = dsaTruncHash hashAlg msg q
-          r         = expSafe g k p `mod` q
-          s         = (kInv * (hm + x * r)) `mod` q
+    | r == 0 || s == 0 = Nothing
+    | otherwise = Just $ Signature r s
+  where
+    -- parameters
+    (Params p g q) = private_params pk
+    x = private_x pk
+    -- compute r,s
+    kInv = fromJust $ inverse k q
+    hm = dsaTruncHash hashAlg msg q
+    r = expSafe g k p `mod` q
+    s = (kInv * (hm + x * r)) `mod` q
 
 -- | sign message using the private key.
-sign :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m) => PrivateKey -> hash -> msg -> m Signature
+sign
+    :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m)
+    => PrivateKey -> hash -> msg -> m Signature
 sign pk hashAlg msg = do
     k <- generateMax q
     case signWith k pk hashAlg msg of
-        Nothing  -> sign pk hashAlg msg
+        Nothing -> sign pk hashAlg msg
         Just sig -> return sig
   where
     (Params _ _ q) = private_params pk
 
 -- | verify a bytestring using the public key.
-verify :: (ByteArrayAccess msg, HashAlgorithm hash) => hash -> PublicKey -> Signature -> msg -> Bool
+verify
+    :: (ByteArrayAccess msg, HashAlgorithm hash)
+    => hash -> PublicKey -> Signature -> msg -> Bool
 verify hashAlg pk (Signature r s) m
     -- Reject the signature if either 0 < r < q or 0 < s < q is not satisfied.
     | r <= 0 || r >= q || s <= 0 || s >= q = False
-    | otherwise                            = v == r
-    where (Params p g q) = public_params pk
-          y       = public_y pk
-          hm      = dsaTruncHash hashAlg m q
-          w       = fromJust $ inverse s q
-          u1      = (hm*w) `mod` q
-          u2      = (r*w) `mod` q
-          v       = ((expFast g u1 p) * (expFast y u2 p)) `mod` p `mod` q
+    | otherwise = v == r
+  where
+    (Params p g q) = public_params pk
+    y = public_y pk
+    hm = dsaTruncHash hashAlg m q
+    w = fromJust $ inverse s q
+    u1 = (hm * w) `mod` q
+    u2 = (r * w) `mod` q
+    v = ((expFast g u1 p) * (expFast y u2 p)) `mod` p `mod` q
diff --git a/Crypto/PubKey/ECC/DH.hs b/Crypto/PubKey/ECC/DH.hs
--- a/Crypto/PubKey/ECC/DH.hs
+++ b/Crypto/PubKey/ECC/DH.hs
@@ -6,25 +6,31 @@
 -- Portability : unknown
 --
 -- Elliptic curve Diffie Hellman
---
-module Crypto.PubKey.ECC.DH
-    (
-      Curve
-    , PublicPoint
-    , PrivateNumber
-    , SharedKey(..)
-    , generatePrivate
-    , calculatePublic
-    , getShared
-    ) where
+module Crypto.PubKey.ECC.DH (
+    Curve,
+    PublicPoint,
+    PrivateNumber,
+    SharedKey (..),
+    generatePrivate,
+    calculatePublic,
+    getShared,
+) where
 
 import Crypto.Number.Generate (generateMax)
 import Crypto.Number.Serialize (i2ospOf_)
+import Crypto.PubKey.DH (SharedKey (..))
 import Crypto.PubKey.ECC.Prim (pointMul)
+import Crypto.PubKey.ECC.Types (
+    Curve,
+    Point (..),
+    PrivateNumber,
+    PublicPoint,
+    common_curve,
+    curveSizeBits,
+    ecc_g,
+    ecc_n,
+ )
 import Crypto.Random.Types
-import Crypto.PubKey.DH (SharedKey(..))
-import Crypto.PubKey.ECC.Types (PublicPoint, PrivateNumber, Curve, Point(..), curveSizeBits)
-import Crypto.PubKey.ECC.Types (ecc_n, ecc_g, common_curve)
 
 -- | Generating a private number d.
 generatePrivate :: MonadRandom m => Curve -> m PrivateNumber
@@ -44,5 +50,7 @@
 getShared :: Curve -> PrivateNumber -> PublicPoint -> SharedKey
 getShared curve db qa = SharedKey $ i2ospOf_ ((nbBits + 7) `div` 8) x
   where
-    Point x _ = pointMul curve db qa
-    nbBits    = curveSizeBits curve
+    x = case pointMul curve db qa of
+        Point x' _ -> x'
+        _ -> error "getShared"
+    nbBits = curveSizeBits curve
diff --git a/Crypto/PubKey/ECC/ECDSA.hs b/Crypto/PubKey/ECC/ECDSA.hs
--- a/Crypto/PubKey/ECC/ECDSA.hs
+++ b/Crypto/PubKey/ECC/ECDSA.hs
@@ -1,56 +1,83 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+
 -- | /WARNING:/ Signature operations may leak the private key. Signature verification
 -- should be safe.
-{-# LANGUAGE DeriveDataTypeable #-}
-module Crypto.PubKey.ECC.ECDSA
-    ( Signature(..)
-    , PublicPoint
-    , PublicKey(..)
-    , PrivateNumber
-    , PrivateKey(..)
-    , KeyPair(..)
-    , toPublicKey
-    , toPrivateKey
-    , signWith
-    , signDigestWith
-    , sign
-    , signDigest
-    , verify
-    , verifyDigest
-    ) where
+module Crypto.PubKey.ECC.ECDSA (
+    Signature (..),
+    ExtendedSignature (..),
+    PublicPoint,
+    PublicKey (..),
+    PrivateNumber,
+    PrivateKey (..),
+    KeyPair (..),
+    toPublicKey,
+    toPrivateKey,
+    signWith,
+    signDigestWith,
+    signExtendedDigestWith,
+    sign,
+    signDigest,
+    signExtendedDigest,
+    verify,
+    verifyDigest,
+    recover,
+    recoverDigest,
+    deterministicNonce,
+) where
 
 import Control.Monad
+import Data.Bits
+import Data.ByteArray (ByteArrayAccess, ScrubbedBytes)
 import Data.Data
 
 import Crypto.Hash
-import Crypto.Internal.ByteArray (ByteArrayAccess)
-import Crypto.Number.ModArithmetic (inverse)
+import Crypto.Number.Basic
 import Crypto.Number.Generate
-import Crypto.PubKey.ECC.Types
+import Crypto.Number.ModArithmetic (inverse)
+import Crypto.Number.Serialize
 import Crypto.PubKey.ECC.Prim
+import Crypto.PubKey.ECC.Types
 import Crypto.PubKey.Internal (dsaTruncHashDigest)
+import Crypto.Random.HmacDRG
 import Crypto.Random.Types
 
 -- | Represent a ECDSA signature namely R and S.
 data Signature = Signature
-    { sign_r :: Integer -- ^ ECDSA r
-    , sign_s :: Integer -- ^ ECDSA s
-    } deriving (Show,Read,Eq,Data)
+    { sign_r :: Integer
+    -- ^ ECDSA r
+    , sign_s :: Integer
+    -- ^ ECDSA s
+    }
+    deriving (Show, Read, Eq, Data)
 
+-- | ECDSA signature with public key recovery information.
+data ExtendedSignature = ExtendedSignature
+    { index :: Integer
+    -- ^ Index of the X coordinate
+    , parity :: Bool
+    -- ^ Parity of the Y coordinate
+    , signature :: Signature
+    -- ^ Inner signature
+    }
+    deriving (Show, Read, Eq, Data)
+
 -- | ECDSA Private Key.
 data PrivateKey = PrivateKey
     { private_curve :: Curve
-    , private_d     :: PrivateNumber
-    } deriving (Show,Read,Eq,Data)
+    , private_d :: PrivateNumber
+    }
+    deriving (Show, Read, Eq, Data)
 
 -- | ECDSA Public Key.
 data PublicKey = PublicKey
     { public_curve :: Curve
-    , public_q     :: PublicPoint
-    } deriving (Show,Read,Eq,Data)
+    , public_q :: PublicPoint
+    }
+    deriving (Show, Read, Eq, Data)
 
 -- | ECDSA Key Pair.
 data KeyPair = KeyPair Curve PublicPoint PrivateNumber
-    deriving (Show,Read,Eq,Data)
+    deriving (Show, Read, Eq, Data)
 
 -- | Public key of a ECDSA Key pair.
 toPublicKey :: KeyPair -> PublicKey
@@ -63,71 +90,144 @@
 -- | Sign digest using the private key and an explicit k number.
 --
 -- /WARNING:/ Vulnerable to timing attacks.
-signDigestWith :: HashAlgorithm hash
-               => Integer     -- ^ k random number
-               -> PrivateKey  -- ^ private key
-               -> Digest hash -- ^ digest to sign
-               -> Maybe Signature
-signDigestWith k (PrivateKey curve d) digest = do
+signExtendedDigestWith
+    :: HashAlgorithm hash
+    => Integer
+    -- ^ k random number
+    -> PrivateKey
+    -- ^ private key
+    -> Digest hash
+    -- ^ digest to sign
+    -> Maybe ExtendedSignature
+signExtendedDigestWith k (PrivateKey curve d) digest = do
     let z = dsaTruncHashDigest digest n
         CurveCommon _ _ g n _ = common_curve curve
-    let point = pointMul curve k g
-    r <- case point of
-              PointO    -> Nothing
-              Point x _ -> return $ x `mod` n
+    (i, r, p) <- pointDecompose curve $ pointMul curve k g
     kInv <- inverse k n
     let s = kInv * (z + r * d) `mod` n
     when (r == 0 || s == 0) Nothing
-    return $ Signature r s
+    return $
+        if s <= n `unsafeShiftR` 1
+            then ExtendedSignature i p $ Signature r s
+            else ExtendedSignature i (not p) $ Signature r (n - s)
 
+-- | Sign digest using the private key and an explicit k number.
+--
+-- /WARNING:/ Vulnerable to timing attacks.
+signDigestWith
+    :: HashAlgorithm hash
+    => Integer
+    -- ^ k random number
+    -> PrivateKey
+    -- ^ private key
+    -> Digest hash
+    -- ^ digest to sign
+    -> Maybe Signature
+signDigestWith k pk digest = signature <$> signExtendedDigestWith k pk digest
+
 -- | Sign message using the private key and an explicit k number.
 --
 -- /WARNING:/ Vulnerable to timing attacks.
-signWith :: (ByteArrayAccess msg, HashAlgorithm hash)
-         => Integer    -- ^ k random number
-         -> PrivateKey -- ^ private key
-         -> hash       -- ^ hash function
-         -> msg        -- ^ message to sign
-         -> Maybe Signature
+signWith
+    :: (ByteArrayAccess msg, HashAlgorithm hash)
+    => Integer
+    -- ^ k random number
+    -> PrivateKey
+    -- ^ private key
+    -> hash
+    -- ^ hash function
+    -> msg
+    -- ^ message to sign
+    -> Maybe Signature
 signWith k pk hashAlg msg = signDigestWith k pk (hashWith hashAlg msg)
 
 -- | Sign digest using the private key.
 --
 -- /WARNING:/ Vulnerable to timing attacks.
-signDigest :: (HashAlgorithm hash, MonadRandom m)
-           => PrivateKey -> Digest hash -> m Signature
-signDigest pk digest = do
+signExtendedDigest
+    :: (HashAlgorithm hash, MonadRandom m)
+    => PrivateKey -> Digest hash -> m ExtendedSignature
+signExtendedDigest pk digest = do
     k <- generateBetween 1 (n - 1)
-    case signDigestWith k pk digest of
-         Nothing  -> signDigest pk digest
-         Just sig -> return sig
-  where n = ecc_n . common_curve $ private_curve pk
+    case signExtendedDigestWith k pk digest of
+        Nothing -> signExtendedDigest pk digest
+        Just sig -> return sig
+  where
+    n = ecc_n . common_curve $ private_curve pk
 
+-- | Sign digest using the private key.
+--
+-- /WARNING:/ Vulnerable to timing attacks.
+signDigest
+    :: (HashAlgorithm hash, MonadRandom m)
+    => PrivateKey -> Digest hash -> m Signature
+signDigest pk digest = signature <$> signExtendedDigest pk digest
+
 -- | Sign message using the private key.
 --
 -- /WARNING:/ Vulnerable to timing attacks.
-sign :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m)
-     => PrivateKey -> hash -> msg -> m Signature
+sign
+    :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m)
+    => PrivateKey -> hash -> msg -> m Signature
 sign pk hashAlg msg = signDigest pk (hashWith hashAlg msg)
 
 -- | Verify a digest using the public key.
-verifyDigest :: HashAlgorithm hash => PublicKey -> Signature -> Digest hash -> Bool
+verifyDigest
+    :: HashAlgorithm hash => PublicKey -> Signature -> Digest hash -> Bool
 verifyDigest (PublicKey _ PointO) _ _ = False
 verifyDigest pk@(PublicKey curve q) (Signature r s) digest
     | r < 1 || r >= n || s < 1 || s >= n = False
     | otherwise = maybe False (r ==) $ do
         w <- inverse s n
-        let z  = dsaTruncHashDigest digest n
+        let z = dsaTruncHashDigest digest n
             u1 = z * w `mod` n
             u2 = r * w `mod` n
-            x  = pointAddTwoMuls curve u1 g u2 q
+            x = pointAddTwoMuls curve u1 g u2 q
         case x of
-             PointO     -> Nothing
-             Point x1 _ -> return $ x1 `mod` n
-  where n = ecc_n cc
-        g = ecc_g cc
-        cc = common_curve $ public_curve pk
+            PointO -> Nothing
+            Point x1 _ -> return $ x1 `mod` n
+  where
+    n = ecc_n cc
+    g = ecc_g cc
+    cc = common_curve $ public_curve pk
 
 -- | Verify a bytestring using the public key.
-verify :: (ByteArrayAccess msg, HashAlgorithm hash) => hash -> PublicKey -> Signature -> msg -> Bool
+verify
+    :: (ByteArrayAccess msg, HashAlgorithm hash)
+    => hash -> PublicKey -> Signature -> msg -> Bool
 verify hashAlg pk sig msg = verifyDigest pk sig (hashWith hashAlg msg)
+
+-- | Recover the public key from an extended signature and a digest.
+recoverDigest
+    :: HashAlgorithm hash
+    => Curve -> ExtendedSignature -> Digest hash -> Maybe PublicKey
+recoverDigest curve (ExtendedSignature i p (Signature r s)) digest = do
+    let CurveCommon _ _ g n _ = common_curve curve
+    let z = dsaTruncHashDigest digest n
+    w <- inverse r n
+    c <- pointCompose curve i r p
+    pure $ PublicKey curve $ pointAddTwoMuls curve (s * w) c (negate $ z * w) g
+
+-- | Recover the public key from an extended signature and a message.
+recover
+    :: (ByteArrayAccess msg, HashAlgorithm hash)
+    => hash -> Curve -> ExtendedSignature -> msg -> Maybe PublicKey
+recover hashAlg curve sig msg = recoverDigest curve sig $ hashWith hashAlg msg
+
+-- | Deterministic nonce generation according to RFC 6979.
+-- Allows using different hash algorithms for the HMAC-based DRG and the message digest.
+deterministicNonce
+    :: (HashAlgorithm hashDRG, HashAlgorithm hashDigest)
+    => hashDRG -> PrivateKey -> Digest hashDigest -> (Integer -> Maybe a) -> a
+deterministicNonce alg (PrivateKey curve key) digest go = fst $ withDRG state run
+  where
+    state = update seed $ initial alg
+      where
+        seed = i2ospOf_ bytes key <> i2ospOf_ bytes message :: ScrubbedBytes
+        message = dsaTruncHashDigest digest n `mod` n
+    run = do
+        k <- generatePrefix bits
+        if 0 < k && k < n then maybe run pure $ go k else run
+    bytes = (bits + 7) `unsafeShiftR` 3
+    bits = numBits n
+    n = ecc_n $ common_curve curve
diff --git a/Crypto/PubKey/ECC/Generate.hs b/Crypto/PubKey/ECC/Generate.hs
--- a/Crypto/PubKey/ECC/Generate.hs
+++ b/Crypto/PubKey/ECC/Generate.hs
@@ -1,30 +1,34 @@
 -- | Signature generation.
 module Crypto.PubKey.ECC.Generate where
 
-import Crypto.Random.Types
-import Crypto.PubKey.ECC.Types
-import Crypto.PubKey.ECC.ECDSA
 import Crypto.Number.Generate
+import Crypto.PubKey.ECC.ECDSA
 import Crypto.PubKey.ECC.Prim
+import Crypto.PubKey.ECC.Types
+import Crypto.Random.Types
 
 -- | Generate Q given d.
 --
 -- /WARNING:/ Vulnerable to timing attacks.
-generateQ :: Curve
-          -> Integer
-          -> Point
+generateQ
+    :: Curve
+    -> Integer
+    -> Point
 generateQ curve d = pointMul curve d g
-  where g = ecc_g $ common_curve curve
+  where
+    g = ecc_g $ common_curve curve
 
 -- | Generate a pair of (private, public) key.
 --
 -- /WARNING:/ Vulnerable to timing attacks.
-generate :: MonadRandom m
-         => Curve -- ^ Elliptic Curve
-         -> m (PublicKey, PrivateKey)
+generate
+    :: MonadRandom m
+    => Curve
+    -- ^ Elliptic Curve
+    -> m (PublicKey, PrivateKey)
 generate curve = do
     d <- generateBetween 1 (n - 1)
     let q = generateQ curve d
     return (PublicKey curve q, PrivateKey curve d)
   where
-        n = ecc_n $ common_curve curve
+    n = ecc_n $ common_curve curve
diff --git a/Crypto/PubKey/ECC/P256.hs b/Crypto/PubKey/ECC/P256.hs
--- a/Crypto/PubKey/ECC/P256.hs
+++ b/Crypto/PubKey/ECC/P256.hs
@@ -1,3 +1,7 @@
+{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# OPTIONS_GHC -fno-warn-unused-binds #-}
+
 -- |
 -- Module      : Crypto.PubKey.ECC.P256
 -- License     : BSD-style
@@ -6,67 +10,65 @@
 -- Portability : unknown
 --
 -- P256 support
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE EmptyDataDecls #-}
-{-# OPTIONS_GHC -fno-warn-unused-binds #-}
-module Crypto.PubKey.ECC.P256
-    ( Scalar
-    , Point
+module Crypto.PubKey.ECC.P256 (
+    Scalar,
+    Point,
+
     -- * Point arithmetic
-    , pointBase
-    , pointAdd
-    , pointNegate
-    , pointMul
-    , pointDh
-    , pointsMulVarTime
-    , pointIsValid
-    , pointIsAtInfinity
-    , toPoint
-    , pointX
-    , pointToIntegers
-    , pointFromIntegers
-    , pointToBinary
-    , pointFromBinary
-    , unsafePointFromBinary
+    pointBase,
+    pointAdd,
+    pointNegate,
+    pointMul,
+    pointDh,
+    pointsMulVarTime,
+    pointIsValid,
+    pointIsAtInfinity,
+    toPoint,
+    pointX,
+    pointToIntegers,
+    pointFromIntegers,
+    pointToBinary,
+    pointFromBinary,
+    unsafePointFromBinary,
+
     -- * Scalar arithmetic
-    , scalarGenerate
-    , scalarZero
-    , scalarN
-    , scalarIsZero
-    , scalarAdd
-    , scalarSub
-    , scalarMul
-    , scalarInv
-    , scalarInvSafe
-    , scalarCmp
-    , scalarFromBinary
-    , scalarToBinary
-    , scalarFromInteger
-    , scalarToInteger
-    ) where
+    scalarGenerate,
+    scalarZero,
+    scalarN,
+    scalarIsZero,
+    scalarAdd,
+    scalarSub,
+    scalarMul,
+    scalarInv,
+    scalarInvSafe,
+    scalarCmp,
+    scalarFromBinary,
+    scalarToBinary,
+    scalarFromInteger,
+    scalarToInteger,
+) where
 
-import           Data.Word
-import           Foreign.Ptr
-import           Foreign.C.Types
+import Data.Word
+import Foreign.C.Types
+import Foreign.Ptr
 
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Crypto.Internal.ByteArray
+import Crypto.Error
+import Crypto.Internal.ByteArray
 import qualified Crypto.Internal.ByteArray as B
-import           Data.Memory.PtrMethods (memSet)
-import           Crypto.Error
-import           Crypto.Random
-import           Crypto.Number.Serialize.Internal (os2ip, i2ospOf)
-import qualified Crypto.Number.Serialize as S (os2ip, i2ospOf)
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import qualified Crypto.Number.Serialize as S (i2ospOf, os2ip)
+import Crypto.Number.Serialize.Internal (i2ospOf, os2ip)
+import Crypto.Random
+import Data.Memory.PtrMethods (memSet)
 
 -- | A P256 scalar
 newtype Scalar = Scalar ScrubbedBytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | A P256 point
 newtype Point = Point Bytes
-    deriving (Show,Eq,NFData)
+    deriving (Show, Eq, NFData)
 
 scalarSize :: Int
 scalarSize = 32
@@ -74,7 +76,7 @@
 pointSize :: Int
 pointSize = 64
 
-type P256Digit  = Word32
+type P256Digit = Word32
 
 data P256Scalar
 data P256Y
@@ -91,7 +93,7 @@
 pointBase :: Point
 pointBase =
     case scalarFromInteger 1 of
-        CryptoPassed s  -> toPoint s
+        CryptoPassed s -> toPoint s
         CryptoFailed _ -> error "pointBase: assumption failed"
 
 -- | Lift to curve a scalar
@@ -99,19 +101,21 @@
 -- Using the curve generator as base point compute:
 --
 -- > scalar * G
---
 toPoint :: Scalar -> Point
 toPoint s
     | scalarIsZero s = error "cannot create point from zero"
-    | otherwise      =
+    | otherwise =
         withNewPoint $ \px py -> withScalar s $ \p ->
             ccrypton_p256_basepoint_mul p px py
 
 -- | Add a point to another point
 pointAdd :: Point -> Point -> Point
-pointAdd a b = withNewPoint $ \dx dy ->
-    withPoint a $ \ax ay -> withPoint b $ \bx by ->
-        ccrypton_p256e_point_add ax ay bx by dx dy
+pointAdd a b
+    | pointIsAtInfinity a = b
+    | pointIsAtInfinity b = a
+    | otherwise = withNewPoint $ \dx dy ->
+        withPoint a $ \ax ay -> withPoint b $ \bx by ->
+            ccrypton_p256e_point_add ax ay bx by dx dy
 
 -- | Negate a point
 pointNegate :: Point -> Point
@@ -160,10 +164,10 @@
 pointX :: Point -> Maybe Scalar
 pointX p
     | pointIsAtInfinity p = Nothing
-    | otherwise           = Just $
-        withNewScalarFreeze $ \d    ->
-        withPoint p         $ \px _ ->
-            ccrypton_p256_mod ccrypton_SECP256r1_n (castPtr px) (castPtr d)
+    | otherwise = Just $
+        withNewScalarFreeze $ \d ->
+            withPoint p $ \px _ ->
+                ccrypton_p256_mod ccrypton_SECP256r1_n (castPtr px) (castPtr d)
 
 -- | Convert a point to (x,y) Integers
 pointToIntegers :: Point -> (Integer, Integer)
@@ -175,12 +179,14 @@
         x <- os2ip temp scalarSize
         ccrypton_p256_to_bin py temp
         y <- os2ip temp scalarSize
-        return (x,y)
+        return (x, y)
 
 -- | Convert from (x,y) Integers to a point
 pointFromIntegers :: (Integer, Integer) -> Point
-pointFromIntegers (x,y) = withNewPoint $ \dx dy ->
-    allocTemp scalarSize (\temp -> fill temp (castPtr dx) x >> fill temp (castPtr dy) y)
+pointFromIntegers (x, y) = withNewPoint $ \dx dy ->
+    allocTemp
+        scalarSize
+        (\temp -> fill temp (castPtr dx) x >> fill temp (castPtr dy) y)
   where
     -- put @n to @temp in big endian format, then from @temp to @dest in p256 scalar format
     fill :: Ptr Word8 -> Ptr P256Scalar -> Integer -> IO ()
@@ -207,15 +213,15 @@
     validatePoint :: Point -> CryptoFailable Point
     validatePoint p
         | pointIsValid p = CryptoPassed p
-        | otherwise      = CryptoFailed CryptoError_PointCoordinatesInvalid
+        | otherwise = CryptoFailed CryptoError_PointCoordinatesInvalid
 
 -- | Convert from binary to a point, possibly invalid
 unsafePointFromBinary :: ByteArrayAccess ba => ba -> CryptoFailable Point
 unsafePointFromBinary ba
     | B.length ba /= pointSize = CryptoFailed CryptoError_PublicKeySizeInvalid
-    | otherwise                =
+    | otherwise =
         CryptoPassed $ withNewPoint $ \px py -> B.withByteArray ba $ \src -> do
-            ccrypton_p256_from_bin src                        (castPtr px)
+            ccrypton_p256_from_bin src (castPtr px)
             ccrypton_p256_from_bin (src `plusPtr` scalarSize) (castPtr py)
 
 ------------------------------------------------------------------------
@@ -267,7 +273,7 @@
 scalarMul :: Scalar -> Scalar -> Scalar
 scalarMul a b =
     withNewScalarFreeze $ \d -> withScalar a $ \pa -> withScalar b $ \pb ->
-         ccrypton_p256_modmul ccrypton_SECP256r1_n pa 0 pb d
+        ccrypton_p256_modmul ccrypton_SECP256r1_n pa 0 pb d
 
 -- | Give the inverse of the scalar
 --
@@ -298,7 +304,7 @@
 scalarFromBinary :: ByteArrayAccess ba => ba -> CryptoFailable Scalar
 scalarFromBinary ba
     | B.length ba /= scalarSize = CryptoFailed CryptoError_SecretKeySizeInvalid
-    | otherwise                 =
+    | otherwise =
         CryptoPassed $ withNewScalarFreeze $ \p -> B.withByteArray ba $ \b ->
             ccrypton_p256_from_bin b p
 {-# NOINLINE scalarFromBinary #-}
@@ -312,7 +318,10 @@
 -- | Convert from an Integer to a P256 Scalar
 scalarFromInteger :: Integer -> CryptoFailable Scalar
 scalarFromInteger i =
-    maybe (CryptoFailed CryptoError_SecretKeySizeInvalid) scalarFromBinary (S.i2ospOf 32 i :: Maybe Bytes)
+    maybe
+        (CryptoFailed CryptoError_SecretKeySizeInvalid)
+        scalarFromBinary
+        (S.i2ospOf 32 i :: Maybe Bytes)
 
 -- | Convert from a P256 Scalar to an Integer
 scalarToInteger :: Scalar -> Integer
@@ -370,53 +379,78 @@
 foreign import ccall "crypton_p256_clear"
     ccrypton_p256_clear :: Ptr P256Scalar -> IO ()
 foreign import ccall "crypton_p256e_modadd"
-    ccrypton_p256e_modadd :: Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> IO ()
+    ccrypton_p256e_modadd
+        :: Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> IO ()
 foreign import ccall "crypton_p256_add_d"
     ccrypton_p256_add_d :: Ptr P256Scalar -> P256Digit -> Ptr P256Scalar -> IO CInt
 foreign import ccall "crypton_p256e_modsub"
-    ccrypton_p256e_modsub :: Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> IO ()
+    ccrypton_p256e_modsub
+        :: Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> IO ()
 foreign import ccall "crypton_p256_cmp"
     ccrypton_p256_cmp :: Ptr P256Scalar -> Ptr P256Scalar -> IO CInt
 foreign import ccall "crypton_p256_mod"
     ccrypton_p256_mod :: Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> IO ()
 foreign import ccall "crypton_p256_modmul"
-    ccrypton_p256_modmul :: Ptr P256Scalar -> Ptr P256Scalar -> P256Digit -> Ptr P256Scalar -> Ptr P256Scalar -> IO ()
+    ccrypton_p256_modmul
+        :: Ptr P256Scalar
+        -> Ptr P256Scalar
+        -> P256Digit
+        -> Ptr P256Scalar
+        -> Ptr P256Scalar
+        -> IO ()
 foreign import ccall "crypton_p256e_scalar_invert"
     ccrypton_p256e_scalar_invert :: Ptr P256Scalar -> Ptr P256Scalar -> IO ()
---foreign import ccall "crypton_p256_modinv"
+
+-- foreign import ccall "crypton_p256_modinv"
 --    ccrypton_p256_modinv :: Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> IO ()
 foreign import ccall "crypton_p256_modinv_vartime"
-    ccrypton_p256_modinv_vartime :: Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> IO ()
+    ccrypton_p256_modinv_vartime
+        :: Ptr P256Scalar -> Ptr P256Scalar -> Ptr P256Scalar -> IO ()
 foreign import ccall "crypton_p256_base_point_mul"
-    ccrypton_p256_basepoint_mul :: Ptr P256Scalar
-                                   -> Ptr P256X -> Ptr P256Y
-                                   -> IO ()
+    ccrypton_p256_basepoint_mul
+        :: Ptr P256Scalar
+        -> Ptr P256X
+        -> Ptr P256Y
+        -> IO ()
 
 foreign import ccall "crypton_p256e_point_add"
-    ccrypton_p256e_point_add :: Ptr P256X -> Ptr P256Y
-                                -> Ptr P256X -> Ptr P256Y
-                                -> Ptr P256X -> Ptr P256Y
-                                -> IO ()
+    ccrypton_p256e_point_add
+        :: Ptr P256X
+        -> Ptr P256Y
+        -> Ptr P256X
+        -> Ptr P256Y
+        -> Ptr P256X
+        -> Ptr P256Y
+        -> IO ()
 
 foreign import ccall "crypton_p256e_point_negate"
-    ccrypton_p256e_point_negate :: Ptr P256X -> Ptr P256Y
-                                   -> Ptr P256X -> Ptr P256Y
-                                   -> IO ()
+    ccrypton_p256e_point_negate
+        :: Ptr P256X
+        -> Ptr P256Y
+        -> Ptr P256X
+        -> Ptr P256Y
+        -> IO ()
 
 -- compute (out_x,out_y) = n * (in_x,in_y)
 foreign import ccall "crypton_p256e_point_mul"
-    ccrypton_p256e_point_mul :: Ptr P256Scalar -- n
-                                -> Ptr P256X -> Ptr P256Y -- in_{x,y}
-                                -> Ptr P256X -> Ptr P256Y -- out_{x,y}
-                                -> IO ()
+    ccrypton_p256e_point_mul
+        :: Ptr P256Scalar -- n
+        -> Ptr P256X
+        -> Ptr P256Y -- in_{x,y}
+        -> Ptr P256X
+        -> Ptr P256Y -- out_{x,y}
+        -> IO ()
 
 -- compute (out_x,out,y) = n1 * G + n2 * (in_x,in_y)
 foreign import ccall "crypton_p256_points_mul_vartime"
-    ccrypton_p256_points_mul_vartime :: Ptr P256Scalar -- n1
-                                        -> Ptr P256Scalar -- n2
-                                        -> Ptr P256X -> Ptr P256Y -- in_{x,y}
-                                        -> Ptr P256X -> Ptr P256Y -- out_{x,y}
-                                        -> IO ()
+    ccrypton_p256_points_mul_vartime
+        :: Ptr P256Scalar -- n1
+        -> Ptr P256Scalar -- n2
+        -> Ptr P256X
+        -> Ptr P256Y -- in_{x,y}
+        -> Ptr P256X
+        -> Ptr P256Y -- out_{x,y}
+        -> IO ()
 foreign import ccall "crypton_p256_is_valid_point"
     ccrypton_p256_is_valid_point :: Ptr P256X -> Ptr P256Y -> IO CInt
 
diff --git a/Crypto/PubKey/ECC/Prim.hs b/Crypto/PubKey/ECC/Prim.hs
--- a/Crypto/PubKey/ECC/Prim.hs
+++ b/Crypto/PubKey/ECC/Prim.hs
@@ -1,39 +1,41 @@
 -- | Elliptic Curve Arithmetic.
 --
 -- /WARNING:/ These functions are vulnerable to timing attacks.
-module Crypto.PubKey.ECC.Prim
-    ( scalarGenerate
-    , pointAdd
-    , pointNegate
-    , pointDouble
-    , pointBaseMul
-    , pointMul
-    , pointAddTwoMuls
-    , isPointAtInfinity
-    , isPointValid
-    ) where
+module Crypto.PubKey.ECC.Prim (
+    scalarGenerate,
+    pointAdd,
+    pointNegate,
+    pointDouble,
+    pointBaseMul,
+    pointMul,
+    pointAddTwoMuls,
+    pointDecompose,
+    pointCompose,
+    isPointAtInfinity,
+    isPointValid,
+) where
 
-import Data.Maybe
-import Crypto.Number.ModArithmetic
 import Crypto.Number.F2m
 import Crypto.Number.Generate (generateBetween)
+import Crypto.Number.ModArithmetic
 import Crypto.PubKey.ECC.Types
 import Crypto.Random
+import Data.Maybe
 
 -- | Generate a valid scalar for a specific Curve
 scalarGenerate :: MonadRandom randomly => Curve -> randomly PrivateNumber
 scalarGenerate curve = generateBetween 1 (n - 1)
   where
-        n = ecc_n $ common_curve curve
+    n = ecc_n $ common_curve curve
 
---TODO: Extract helper function for `fromMaybe PointO...`
+-- TODO: Extract helper function for `fromMaybe PointO...`
 
 -- | Elliptic Curve point negation:
 -- @pointNegate c p@ returns point @q@ such that @pointAdd c p q == PointO@.
 pointNegate :: Curve -> Point -> Point
-pointNegate _            PointO     = PointO
+pointNegate _ PointO = PointO
 pointNegate (CurveFP c) (Point x y) = Point x (ecc_p c - y)
-pointNegate CurveF2m{}  (Point x y) = Point x (x `addF2m` y)
+pointNegate CurveF2m{} (Point x y) = Point x (x `addF2m` y)
 
 -- | Elliptic Curve point addition.
 --
@@ -43,21 +45,22 @@
 pointAdd _ PointO q = q
 pointAdd _ p PointO = p
 pointAdd c p q
-  | p == q = pointDouble c p
-  | p == pointNegate c q = PointO
-pointAdd (CurveFP (CurvePrime pr _)) (Point xp yp) (Point xq yq)
-    = fromMaybe PointO $ do
+    | p == q = pointDouble c p
+    | p == pointNegate c q = PointO
+pointAdd (CurveFP (CurvePrime pr _)) (Point xp yp) (Point xq yq) =
+    fromMaybe PointO $ do
         s <- divmod (yp - yq) (xp - xq) pr
-        let xr = (s ^ (2::Int) - xp - xq) `mod` pr
+        let xr = (s ^ (2 :: Int) - xp - xq) `mod` pr
             yr = (s * (xp - xr) - yp) `mod` pr
         return $ Point xr yr
-pointAdd (CurveF2m (CurveBinary fx cc)) (Point xp yp) (Point xq yq)
-    = fromMaybe PointO $ do
+pointAdd (CurveF2m (CurveBinary fx cc)) (Point xp yp) (Point xq yq) =
+    fromMaybe PointO $ do
         s <- divF2m fx (yp `addF2m` yq) (xp `addF2m` xq)
         let xr = mulF2m fx s s `addF2m` s `addF2m` xp `addF2m` xq `addF2m` a
             yr = mulF2m fx s (xp `addF2m` xr) `addF2m` xr `addF2m` yp
         return $ Point xr yr
-  where a = ecc_a cc
+  where
+    a = ecc_a cc
 
 -- | Elliptic Curve point doubling.
 --
@@ -74,23 +77,24 @@
 -- >    s = xp + (yp / xp)
 -- >    xr = s ^ 2 + s + a
 -- >    yr = xp ^ 2 + (s+1) * xr
---
 pointDouble :: Curve -> Point -> Point
 pointDouble _ PointO = PointO
 pointDouble (CurveFP (CurvePrime pr cc)) (Point xp yp) = fromMaybe PointO $ do
-    lambda <- divmod (3 * xp ^ (2::Int) + a) (2 * yp) pr
-    let xr = (lambda ^ (2::Int) - 2 * xp) `mod` pr
+    lambda <- divmod (3 * xp ^ (2 :: Int) + a) (2 * yp) pr
+    let xr = (lambda ^ (2 :: Int) - 2 * xp) `mod` pr
         yr = (lambda * (xp - xr) - yp) `mod` pr
     return $ Point xr yr
-  where a = ecc_a cc
+  where
+    a = ecc_a cc
 pointDouble (CurveF2m (CurveBinary fx cc)) (Point xp yp)
-    | xp == 0   = PointO
+    | xp == 0 = PointO
     | otherwise = fromMaybe PointO $ do
         s <- return . addF2m xp =<< divF2m fx yp xp
         let xr = mulF2m fx s s `addF2m` s `addF2m` a
             yr = mulF2m fx xp xp `addF2m` mulF2m fx xr (s `addF2m` 1)
         return $ Point xr yr
-  where a = ecc_a cc
+  where
+    a = ecc_a cc
 
 -- | Elliptic curve point multiplication using the base
 --
@@ -104,7 +108,7 @@
 pointMul :: Curve -> Integer -> Point -> Point
 pointMul _ _ PointO = PointO
 pointMul c n p
-    | n <  0 = pointMul c (-n) (pointNegate c p)
+    | n < 0 = pointMul c (-n) (pointNegate c p)
     | n == 0 = PointO
     | n == 1 = p
     | odd n = pointAdd c p (pointMul c (n - 1) p)
@@ -117,30 +121,61 @@
 --
 -- /WARNING:/ Vulnerable to timing attacks.
 pointAddTwoMuls :: Curve -> Integer -> Point -> Integer -> Point -> Point
-pointAddTwoMuls _ _  PointO _  PointO = PointO
-pointAddTwoMuls c _  PointO n2 p2     = pointMul c n2 p2
-pointAddTwoMuls c n1 p1     _  PointO = pointMul c n1 p1
-pointAddTwoMuls c n1 p1     n2 p2
-    | n1 < 0    = pointAddTwoMuls c (-n1) (pointNegate c p1) n2 p2
-    | n2 < 0    = pointAddTwoMuls c n1 p1 (-n2) (pointNegate c p2)
+pointAddTwoMuls _ _ PointO _ PointO = PointO
+pointAddTwoMuls c _ PointO n2 p2 = pointMul c n2 p2
+pointAddTwoMuls c n1 p1 _ PointO = pointMul c n1 p1
+pointAddTwoMuls c n1 p1 n2 p2
+    | n1 < 0 = pointAddTwoMuls c (-n1) (pointNegate c p1) n2 p2
+    | n2 < 0 = pointAddTwoMuls c n1 p1 (-n2) (pointNegate c p2)
     | otherwise = go (n1, n2)
-
   where
     p0 = pointAdd c p1 p2
 
-    go (0,  0 ) = PointO
+    go (0, 0) = PointO
     go (k1, k2) =
         let q = pointDouble c $ go (k1 `div` 2, k2 `div` 2)
-        in case (odd k1, odd k2) of
-            (True  , True  ) -> pointAdd c p0 q
-            (True  , False ) -> pointAdd c p1 q
-            (False , True  ) -> pointAdd c p2 q
-            (False , False ) -> q
+         in case (odd k1, odd k2) of
+                (True, True) -> pointAdd c p0 q
+                (True, False) -> pointAdd c p1 q
+                (False, True) -> pointAdd c p2 q
+                (False, False) -> q
 
+-- | Decompose a point into index, residue, and parity.
+--
+-- Adapted from SEC 1: Elliptic Curve Cryptography, Version 2.0, section 2.3.3.
+pointDecompose :: Curve -> Point -> Maybe (Integer, Integer, Bool)
+pointDecompose _ PointO = Nothing
+pointDecompose curve (Point x y) = do
+    let CurveCommon _ _ _ n _ = common_curve curve
+    let (index, residue) = x `divMod` n
+    parity <- case curve of
+        CurveFP _ -> pure $ odd y
+        CurveF2m _ | x == 0 -> pure False
+        CurveF2m (CurveBinary fx _) -> odd <$> divF2m fx y x
+    pure (index, residue, parity)
+
+-- | Compose a point from index, residue, and parity.
+--
+-- Adapted from SEC 1: Elliptic Curve Cryptography, Version 2.0, section 2.3.4.
+pointCompose :: Curve -> Integer -> Integer -> Bool -> Maybe Point
+pointCompose curve index residue parity = do
+    let CurveCommon a b _ n _ = common_curve curve
+    let x = residue + index * n
+    y <- case curve of
+        CurveFP (CurvePrime p _) -> do
+            z <- squareRoot p $ x ^ (3 :: Int) + a * x + b
+            pure $ if odd z == parity then z else p - z
+        CurveF2m (CurveBinary fx _) | x == 0 -> pure $ sqrtF2m fx b
+        CurveF2m (CurveBinary fx _) -> do
+            c <- divF2m fx b $ squareF2m fx x
+            z <- quadraticF2m fx $ addF2m x $ addF2m a c
+            pure $ mulF2m fx x $ if odd z == parity then z else addF2m 1 z
+    pure $ Point x y
+
 -- | Check if a point is the point at infinity.
 isPointAtInfinity :: Point -> Bool
 isPointAtInfinity PointO = True
-isPointAtInfinity _      = False
+isPointAtInfinity _ = False
 
 -- | check if a point is on specific curve
 --
@@ -150,23 +185,26 @@
 -- * y is not out of range
 -- * the equation @y^2 = x^3 + a*x + b (mod p)@ holds
 isPointValid :: Curve -> Point -> Bool
-isPointValid _                           PointO      = True
+isPointValid _ PointO = True
 isPointValid (CurveFP (CurvePrime p cc)) (Point x y) =
     isValid x && isValid y && (y ^ (2 :: Int)) `eqModP` (x ^ (3 :: Int) + a * x + b)
-  where a  = ecc_a cc
-        b  = ecc_b cc
-        eqModP z1 z2 = (z1 `mod` p) == (z2 `mod` p)
-        isValid e = e >= 0 && e < p
+  where
+    a = ecc_a cc
+    b = ecc_b cc
+    eqModP z1 z2 = (z1 `mod` p) == (z2 `mod` p)
+    isValid e = e >= 0 && e < p
 isPointValid (CurveF2m (CurveBinary fx cc)) (Point x y) =
-    and [ isValid x
+    and
+        [ isValid x
         , isValid y
         , ((((x `add` a) `mul` x `add` y) `mul` x) `add` b `add` (squareF2m fx y)) == 0
         ]
-  where a  = ecc_a cc
-        b  = ecc_b cc
-        add = addF2m
-        mul = mulF2m fx
-        isValid e = modF2m fx e == e
+  where
+    a = ecc_a cc
+    b = ecc_b cc
+    add = addF2m
+    mul = mulF2m fx
+    isValid e = modF2m fx e == e
 
 -- | div and mod
 divmod :: Integer -> Integer -> Integer -> Maybe Integer
diff --git a/Crypto/PubKey/ECC/Types.hs b/Crypto/PubKey/ECC/Types.hs
--- a/Crypto/PubKey/ECC/Types.hs
+++ b/Crypto/PubKey/ECC/Types.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE DeriveDataTypeable #-}
+
 -- |
 -- Module      : Crypto.PubKey.ECC.Types
 -- License     : BSD-style
@@ -8,32 +9,35 @@
 --
 -- References:
 --   <https://tools.ietf.org/html/rfc5915>
---
-module Crypto.PubKey.ECC.Types
-    ( Curve(..)
-    , Point(..)
-    , PublicPoint
-    , PrivateNumber
-    , CurveBinary(..)
-    , CurvePrime(..)
-    , common_curve
-    , curveSizeBits
-    , ecc_fx
-    , ecc_p
-    , CurveCommon(..)
+module Crypto.PubKey.ECC.Types (
+    Curve (..),
+    Point (..),
+    PublicPoint,
+    PrivateNumber,
+    CurveBinary (..),
+    CurvePrime (..),
+    common_curve,
+    curveSizeBits,
+    ecc_fx,
+    ecc_p,
+    CurveCommon (..),
+
     -- * Recommended curves definition
-    , CurveName(..)
-    , getCurveByName
-    ) where
+    CurveName (..),
+    getCurveByName,
+) where
 
-import           Data.Data
-import           Crypto.Internal.Imports
-import           Crypto.Number.Basic (numBits)
+import Crypto.Internal.Imports
+import Crypto.Number.Basic (numBits)
+import Data.Data
 
 -- | Define either a binary curve or a prime curve.
-data Curve = CurveF2m CurveBinary -- ^ 𝔽(2^m)
-           | CurveFP  CurvePrime  -- ^ 𝔽p
-           deriving (Show,Read,Eq,Data)
+data Curve
+    = -- | 𝔽(2^m)
+      CurveF2m CurveBinary
+    | -- | 𝔽p
+      CurveFP CurvePrime
+    deriving (Show, Read, Eq, Data)
 
 -- | ECC Public Point
 type PublicPoint = Point
@@ -42,9 +46,11 @@
 type PrivateNumber = Integer
 
 -- | Define a point on a curve.
-data Point = Point Integer Integer
-           | PointO -- ^ Point at Infinity
-           deriving (Show,Read,Eq,Data)
+data Point
+    = Point Integer Integer
+    | -- | Point at Infinity
+      PointO
+    deriving (Show, Read, Eq, Data)
 
 instance NFData Point where
     rnf (Point x y) = x `seq` y `seq` ()
@@ -53,7 +59,7 @@
 -- | Define an elliptic curve in 𝔽(2^m).
 -- The firt parameter is the Integer representatioin of the irreducible polynomial f(x).
 data CurveBinary = CurveBinary Integer CurveCommon
-    deriving (Show,Read,Eq,Data)
+    deriving (Show, Read, Eq, Data)
 
 instance NFData CurveBinary where
     rnf (CurveBinary i cc) = i `seq` cc `seq` ()
@@ -61,12 +67,12 @@
 -- | Define an elliptic curve in 𝔽p.
 -- The first parameter is the Prime Number.
 data CurvePrime = CurvePrime Integer CurveCommon
-    deriving (Show,Read,Eq,Data)
+    deriving (Show, Read, Eq, Data)
 
 -- | Parameters in common between binary and prime curves.
 common_curve :: Curve -> CurveCommon
 common_curve (CurveF2m (CurveBinary _ cc)) = cc
-common_curve (CurveFP  (CurvePrime  _ cc)) = cc
+common_curve (CurveFP (CurvePrime _ cc)) = cc
 
 -- | Irreducible polynomial representing the characteristic of a CurveBinary.
 ecc_fx :: CurveBinary -> Integer
@@ -79,16 +85,22 @@
 -- | Define common parameters in a curve definition
 -- of the form: y^2 = x^3 + ax + b.
 data CurveCommon = CurveCommon
-    { ecc_a :: Integer -- ^ curve parameter a
-    , ecc_b :: Integer -- ^ curve parameter b
-    , ecc_g :: Point   -- ^ base point
-    , ecc_n :: Integer -- ^ order of G
-    , ecc_h :: Integer -- ^ cofactor
-    } deriving (Show,Read,Eq,Data)
+    { ecc_a :: Integer
+    -- ^ curve parameter a
+    , ecc_b :: Integer
+    -- ^ curve parameter b
+    , ecc_g :: Point
+    -- ^ base point
+    , ecc_n :: Integer
+    -- ^ order of G
+    , ecc_h :: Integer
+    -- ^ cofactor
+    }
+    deriving (Show, Read, Eq, Data)
 
 -- | Define names for known recommended curves.
-data CurveName =
-      SEC_p112r1
+data CurveName
+    = SEC_p112r1
     | SEC_p112r2
     | SEC_p128r1
     | SEC_p128r2
@@ -121,7 +133,7 @@
     | SEC_t409r1
     | SEC_t571k1
     | SEC_t571r1
-    deriving (Show,Read,Eq,Ord,Enum,Bounded,Data)
+    deriving (Show, Read, Eq, Ord, Enum, Bounded, Data)
 
 {-
 curvesOIDs :: [ (CurveName, [Integer]) ]
@@ -164,338 +176,527 @@
 
 -- | get the size of the curve in bits
 curveSizeBits :: Curve -> Int
-curveSizeBits (CurveFP  c) = numBits (ecc_p  c)
+curveSizeBits (CurveFP c) = numBits (ecc_p c)
 curveSizeBits (CurveF2m c) = numBits (ecc_fx c) - 1
 
 -- | Get the curve definition associated with a recommended known curve name.
 getCurveByName :: CurveName -> Curve
-getCurveByName SEC_p112r1 = CurveFP  $ CurvePrime
-    0xdb7c2abf62e35e668076bead208b
-    (CurveCommon
-        { ecc_a = 0xdb7c2abf62e35e668076bead2088
-        , ecc_b = 0x659ef8ba043916eede8911702b22
-        , ecc_g = Point 0x09487239995a5ee76b55f9c2f098
+getCurveByName SEC_p112r1 =
+    CurveFP $
+        CurvePrime
+            0xdb7c2abf62e35e668076bead208b
+            ( CurveCommon
+                { ecc_a = 0xdb7c2abf62e35e668076bead2088
+                , ecc_b = 0x659ef8ba043916eede8911702b22
+                , ecc_g =
+                    Point
+                        0x09487239995a5ee76b55f9c2f098
                         0xa89ce5af8724c0a23e0e0ff77500
-        , ecc_n = 0xdb7c2abf62e35e7628dfac6561c5
-        , ecc_h = 1
-        })
-getCurveByName SEC_p112r2 = CurveFP  $ CurvePrime
-    0xdb7c2abf62e35e668076bead208b
-    (CurveCommon
-        { ecc_a = 0x6127c24c05f38a0aaaf65c0ef02c
-        , ecc_b = 0x51def1815db5ed74fcc34c85d709
-        , ecc_g = Point 0x4ba30ab5e892b4e1649dd0928643
+                , ecc_n = 0xdb7c2abf62e35e7628dfac6561c5
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p112r2 =
+    CurveFP $
+        CurvePrime
+            0xdb7c2abf62e35e668076bead208b
+            ( CurveCommon
+                { ecc_a = 0x6127c24c05f38a0aaaf65c0ef02c
+                , ecc_b = 0x51def1815db5ed74fcc34c85d709
+                , ecc_g =
+                    Point
+                        0x4ba30ab5e892b4e1649dd0928643
                         0xadcd46f5882e3747def36e956e97
-        , ecc_n = 0x36df0aafd8b8d7597ca10520d04b
-        , ecc_h = 4
-        })
-getCurveByName SEC_p128r1 = CurveFP  $ CurvePrime
-    0xfffffffdffffffffffffffffffffffff
-    (CurveCommon
-        { ecc_a = 0xfffffffdfffffffffffffffffffffffc
-        , ecc_b = 0xe87579c11079f43dd824993c2cee5ed3
-        , ecc_g = Point 0x161ff7528b899b2d0c28607ca52c5b86
+                , ecc_n = 0x36df0aafd8b8d7597ca10520d04b
+                , ecc_h = 4
+                }
+            )
+getCurveByName SEC_p128r1 =
+    CurveFP $
+        CurvePrime
+            0xfffffffdffffffffffffffffffffffff
+            ( CurveCommon
+                { ecc_a = 0xfffffffdfffffffffffffffffffffffc
+                , ecc_b = 0xe87579c11079f43dd824993c2cee5ed3
+                , ecc_g =
+                    Point
+                        0x161ff7528b899b2d0c28607ca52c5b86
                         0xcf5ac8395bafeb13c02da292dded7a83
-        , ecc_n = 0xfffffffe0000000075a30d1b9038a115
-        , ecc_h = 1
-        })
-getCurveByName SEC_p128r2 = CurveFP  $ CurvePrime
-    0xfffffffdffffffffffffffffffffffff
-    (CurveCommon
-        { ecc_a = 0xd6031998d1b3bbfebf59cc9bbff9aee1
-        , ecc_b = 0x5eeefca380d02919dc2c6558bb6d8a5d
-        , ecc_g = Point 0x7b6aa5d85e572983e6fb32a7cdebc140
+                , ecc_n = 0xfffffffe0000000075a30d1b9038a115
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p128r2 =
+    CurveFP $
+        CurvePrime
+            0xfffffffdffffffffffffffffffffffff
+            ( CurveCommon
+                { ecc_a = 0xd6031998d1b3bbfebf59cc9bbff9aee1
+                , ecc_b = 0x5eeefca380d02919dc2c6558bb6d8a5d
+                , ecc_g =
+                    Point
+                        0x7b6aa5d85e572983e6fb32a7cdebc140
                         0x27b6916a894d3aee7106fe805fc34b44
-        , ecc_n = 0x3fffffff7fffffffbe0024720613b5a3
-        , ecc_h = 4
-        })
-getCurveByName SEC_p160k1 = CurveFP  $ CurvePrime
-    0x00fffffffffffffffffffffffffffffffeffffac73
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000000
-        , ecc_b = 0x000000000000000000000000000000000000000007
-        , ecc_g = Point 0x003b4c382ce37aa192a4019e763036f4f5dd4d7ebb
+                , ecc_n = 0x3fffffff7fffffffbe0024720613b5a3
+                , ecc_h = 4
+                }
+            )
+getCurveByName SEC_p160k1 =
+    CurveFP $
+        CurvePrime
+            0x00fffffffffffffffffffffffffffffffeffffac73
+            ( CurveCommon
+                { ecc_a = 0x000000000000000000000000000000000000000000
+                , ecc_b = 0x000000000000000000000000000000000000000007
+                , ecc_g =
+                    Point
+                        0x003b4c382ce37aa192a4019e763036f4f5dd4d7ebb
                         0x00938cf935318fdced6bc28286531733c3f03c4fee
-        , ecc_n = 0x0100000000000000000001b8fa16dfab9aca16b6b3
-        , ecc_h = 1
-        })
-getCurveByName SEC_p160r1 = CurveFP  $ CurvePrime
-    0x00ffffffffffffffffffffffffffffffff7fffffff
-    (CurveCommon
-        { ecc_a = 0x00ffffffffffffffffffffffffffffffff7ffffffc
-        , ecc_b = 0x001c97befc54bd7a8b65acf89f81d4d4adc565fa45
-        , ecc_g = Point 0x004a96b5688ef573284664698968c38bb913cbfc82
+                , ecc_n = 0x0100000000000000000001b8fa16dfab9aca16b6b3
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p160r1 =
+    CurveFP $
+        CurvePrime
+            0x00ffffffffffffffffffffffffffffffff7fffffff
+            ( CurveCommon
+                { ecc_a = 0x00ffffffffffffffffffffffffffffffff7ffffffc
+                , ecc_b = 0x001c97befc54bd7a8b65acf89f81d4d4adc565fa45
+                , ecc_g =
+                    Point
+                        0x004a96b5688ef573284664698968c38bb913cbfc82
                         0x0023a628553168947d59dcc912042351377ac5fb32
-        , ecc_n = 0x0100000000000000000001f4c8f927aed3ca752257
-        , ecc_h = 1
-        })
-getCurveByName SEC_p160r2 = CurveFP  $ CurvePrime
-    0x00fffffffffffffffffffffffffffffffeffffac73
-    (CurveCommon
-        { ecc_a = 0x00fffffffffffffffffffffffffffffffeffffac70
-        , ecc_b = 0x00b4e134d3fb59eb8bab57274904664d5af50388ba
-        , ecc_g = Point 0x0052dcb034293a117e1f4ff11b30f7199d3144ce6d
+                , ecc_n = 0x0100000000000000000001f4c8f927aed3ca752257
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p160r2 =
+    CurveFP $
+        CurvePrime
+            0x00fffffffffffffffffffffffffffffffeffffac73
+            ( CurveCommon
+                { ecc_a = 0x00fffffffffffffffffffffffffffffffeffffac70
+                , ecc_b = 0x00b4e134d3fb59eb8bab57274904664d5af50388ba
+                , ecc_g =
+                    Point
+                        0x0052dcb034293a117e1f4ff11b30f7199d3144ce6d
                         0x00feaffef2e331f296e071fa0df9982cfea7d43f2e
-        , ecc_n = 0x0100000000000000000000351ee786a818f3a1a16b
-        , ecc_h = 1
-        })
-getCurveByName SEC_p192k1 = CurveFP  $ CurvePrime
-    0xfffffffffffffffffffffffffffffffffffffffeffffee37
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000000000000
-        , ecc_b = 0x000000000000000000000000000000000000000000000003
-        , ecc_g = Point 0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d
+                , ecc_n = 0x0100000000000000000000351ee786a818f3a1a16b
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p192k1 =
+    CurveFP $
+        CurvePrime
+            0xfffffffffffffffffffffffffffffffffffffffeffffee37
+            ( CurveCommon
+                { ecc_a = 0x000000000000000000000000000000000000000000000000
+                , ecc_b = 0x000000000000000000000000000000000000000000000003
+                , ecc_g =
+                    Point
+                        0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d
                         0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d
-        , ecc_n = 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d
-        , ecc_h = 1
-        })
-getCurveByName SEC_p192r1 = CurveFP  $ CurvePrime
-    0xfffffffffffffffffffffffffffffffeffffffffffffffff
-    (CurveCommon
-        { ecc_a = 0xfffffffffffffffffffffffffffffffefffffffffffffffc
-        , ecc_b = 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1
-        , ecc_g = Point 0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012
+                , ecc_n = 0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p192r1 =
+    CurveFP $
+        CurvePrime
+            0xfffffffffffffffffffffffffffffffeffffffffffffffff
+            ( CurveCommon
+                { ecc_a = 0xfffffffffffffffffffffffffffffffefffffffffffffffc
+                , ecc_b = 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1
+                , ecc_g =
+                    Point
+                        0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012
                         0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811
-        , ecc_n = 0xffffffffffffffffffffffff99def836146bc9b1b4d22831
-        , ecc_h = 1
-        })
-getCurveByName SEC_p224k1 = CurveFP  $ CurvePrime
-    0x00fffffffffffffffffffffffffffffffffffffffffffffffeffffe56d
-    (CurveCommon
-        { ecc_a = 0x0000000000000000000000000000000000000000000000000000000000
-        , ecc_b = 0x0000000000000000000000000000000000000000000000000000000005
-        , ecc_g = Point 0x00a1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c
+                , ecc_n = 0xffffffffffffffffffffffff99def836146bc9b1b4d22831
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p224k1 =
+    CurveFP $
+        CurvePrime
+            0x00fffffffffffffffffffffffffffffffffffffffffffffffeffffe56d
+            ( CurveCommon
+                { ecc_a = 0x0000000000000000000000000000000000000000000000000000000000
+                , ecc_b = 0x0000000000000000000000000000000000000000000000000000000005
+                , ecc_g =
+                    Point
+                        0x00a1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c
                         0x007e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5
-        , ecc_n = 0x010000000000000000000000000001dce8d2ec6184caf0a971769fb1f7
-        , ecc_h = 1
-        })
-getCurveByName SEC_p224r1 = CurveFP  $ CurvePrime
-    0xffffffffffffffffffffffffffffffff000000000000000000000001
-    (CurveCommon
-        { ecc_a = 0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe
-        , ecc_b = 0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4
-        , ecc_g = Point 0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21
+                , ecc_n = 0x010000000000000000000000000001dce8d2ec6184caf0a971769fb1f7
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p224r1 =
+    CurveFP $
+        CurvePrime
+            0xffffffffffffffffffffffffffffffff000000000000000000000001
+            ( CurveCommon
+                { ecc_a = 0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe
+                , ecc_b = 0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4
+                , ecc_g =
+                    Point
+                        0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21
                         0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34
-        , ecc_n = 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d
-        , ecc_h = 1
-        })
-getCurveByName SEC_p256k1 = CurveFP  $ CurvePrime
-    0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
-    (CurveCommon
-        { ecc_a = 0x0000000000000000000000000000000000000000000000000000000000000000
-        , ecc_b = 0x0000000000000000000000000000000000000000000000000000000000000007
-        , ecc_g = Point 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
+                , ecc_n = 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p256k1 =
+    CurveFP $
+        CurvePrime
+            0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
+            ( CurveCommon
+                { ecc_a = 0x0000000000000000000000000000000000000000000000000000000000000000
+                , ecc_b = 0x0000000000000000000000000000000000000000000000000000000000000007
+                , ecc_g =
+                    Point
+                        0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
                         0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
-        , ecc_n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
-        , ecc_h = 1
-        })
-getCurveByName SEC_p256r1 = CurveFP  $ CurvePrime
-    0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
-    (CurveCommon
-        { ecc_a = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
-        , ecc_b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
-        , ecc_g = Point 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296
+                , ecc_n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p256r1 =
+    CurveFP $
+        CurvePrime
+            0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
+            ( CurveCommon
+                { ecc_a = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
+                , ecc_b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
+                , ecc_g =
+                    Point
+                        0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296
                         0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5
-        , ecc_n = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
-        , ecc_h = 1
-        })
-getCurveByName SEC_p384r1 = CurveFP  $ CurvePrime
-    0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff
-    (CurveCommon
-        { ecc_a = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc
-        , ecc_b = 0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef
-        , ecc_g = Point 0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7
+                , ecc_n = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p384r1 =
+    CurveFP $
+        CurvePrime
+            0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff
+            ( CurveCommon
+                { ecc_a =
+                    0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc
+                , ecc_b =
+                    0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef
+                , ecc_g =
+                    Point
+                        0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7
                         0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f
-        , ecc_n = 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973
-        , ecc_h = 1
-        })
-getCurveByName SEC_p521r1 = CurveFP  $ CurvePrime
-    0x01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-    (CurveCommon
-        { ecc_a = 0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc
-        , ecc_b = 0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00
-        , ecc_g = Point 0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66
+                , ecc_n =
+                    0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_p521r1 =
+    CurveFP $
+        CurvePrime
+            0x01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+            ( CurveCommon
+                { ecc_a =
+                    0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc
+                , ecc_b =
+                    0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00
+                , ecc_g =
+                    Point
+                        0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66
                         0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650
-        , ecc_n = 0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409
-        , ecc_h = 1
-        })
-getCurveByName SEC_t113r1 = CurveF2m $ CurveBinary
-    0x020000000000000000000000000201
-    (CurveCommon
-        { ecc_a = 0x003088250ca6e7c7fe649ce85820f7
-        , ecc_b = 0x00e8bee4d3e2260744188be0e9c723
-        , ecc_g = Point 0x009d73616f35f4ab1407d73562c10f
+                , ecc_n =
+                    0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409
+                , ecc_h = 1
+                }
+            )
+getCurveByName SEC_t113r1 =
+    CurveF2m $
+        CurveBinary
+            0x020000000000000000000000000201
+            ( CurveCommon
+                { ecc_a = 0x003088250ca6e7c7fe649ce85820f7
+                , ecc_b = 0x00e8bee4d3e2260744188be0e9c723
+                , ecc_g =
+                    Point
+                        0x009d73616f35f4ab1407d73562c10f
                         0x00a52830277958ee84d1315ed31886
-        , ecc_n = 0x0100000000000000d9ccec8a39e56f
-        , ecc_h = 2
-        })
-getCurveByName SEC_t113r2 = CurveF2m $ CurveBinary
-    0x020000000000000000000000000201
-    (CurveCommon
-        { ecc_a = 0x00689918dbec7e5a0dd6dfc0aa55c7
-        , ecc_b = 0x0095e9a9ec9b297bd4bf36e059184f
-        , ecc_g = Point 0x01a57a6a7b26ca5ef52fcdb8164797
+                , ecc_n = 0x0100000000000000d9ccec8a39e56f
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t113r2 =
+    CurveF2m $
+        CurveBinary
+            0x020000000000000000000000000201
+            ( CurveCommon
+                { ecc_a = 0x00689918dbec7e5a0dd6dfc0aa55c7
+                , ecc_b = 0x0095e9a9ec9b297bd4bf36e059184f
+                , ecc_g =
+                    Point
+                        0x01a57a6a7b26ca5ef52fcdb8164797
                         0x00b3adc94ed1fe674c06e695baba1d
-        , ecc_n = 0x010000000000000108789b2496af93
-        , ecc_h = 2
-        })
-getCurveByName SEC_t131r1 = CurveF2m $ CurveBinary
-    0x080000000000000000000000000000010d
-    (CurveCommon
-        { ecc_a = 0x07a11b09a76b562144418ff3ff8c2570b8
-        , ecc_b = 0x0217c05610884b63b9c6c7291678f9d341
-        , ecc_g = Point 0x0081baf91fdf9833c40f9c181343638399
+                , ecc_n = 0x010000000000000108789b2496af93
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t131r1 =
+    CurveF2m $
+        CurveBinary
+            0x080000000000000000000000000000010d
+            ( CurveCommon
+                { ecc_a = 0x07a11b09a76b562144418ff3ff8c2570b8
+                , ecc_b = 0x0217c05610884b63b9c6c7291678f9d341
+                , ecc_g =
+                    Point
+                        0x0081baf91fdf9833c40f9c181343638399
                         0x078c6e7ea38c001f73c8134b1b4ef9e150
-        , ecc_n = 0x0400000000000000023123953a9464b54d
-        , ecc_h = 2
-        })
-getCurveByName SEC_t131r2 = CurveF2m $ CurveBinary
-    0x080000000000000000000000000000010d
-    (CurveCommon
-        { ecc_a = 0x03e5a88919d7cafcbf415f07c2176573b2
-        , ecc_b = 0x04b8266a46c55657ac734ce38f018f2192
-        , ecc_g = Point 0x0356dcd8f2f95031ad652d23951bb366a8
+                , ecc_n = 0x0400000000000000023123953a9464b54d
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t131r2 =
+    CurveF2m $
+        CurveBinary
+            0x080000000000000000000000000000010d
+            ( CurveCommon
+                { ecc_a = 0x03e5a88919d7cafcbf415f07c2176573b2
+                , ecc_b = 0x04b8266a46c55657ac734ce38f018f2192
+                , ecc_g =
+                    Point
+                        0x0356dcd8f2f95031ad652d23951bb366a8
                         0x0648f06d867940a5366d9e265de9eb240f
-        , ecc_n = 0x0400000000000000016954a233049ba98f
-        , ecc_h = 2
-        })
-getCurveByName SEC_t163k1 = CurveF2m $ CurveBinary
-    0x0800000000000000000000000000000000000000c9
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000001
-        , ecc_b = 0x000000000000000000000000000000000000000001
-        , ecc_g = Point 0x02fe13c0537bbc11acaa07d793de4e6d5e5c94eee8
+                , ecc_n = 0x0400000000000000016954a233049ba98f
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t163k1 =
+    CurveF2m $
+        CurveBinary
+            0x0800000000000000000000000000000000000000c9
+            ( CurveCommon
+                { ecc_a = 0x000000000000000000000000000000000000000001
+                , ecc_b = 0x000000000000000000000000000000000000000001
+                , ecc_g =
+                    Point
+                        0x02fe13c0537bbc11acaa07d793de4e6d5e5c94eee8
                         0x0289070fb05d38ff58321f2e800536d538ccdaa3d9
-        , ecc_n = 0x04000000000000000000020108a2e0cc0d99f8a5ef
-        , ecc_h = 2
-        })
-getCurveByName SEC_t163r1 = CurveF2m $ CurveBinary
-    0x0800000000000000000000000000000000000000c9
-    (CurveCommon
-        { ecc_a = 0x07b6882caaefa84f9554ff8428bd88e246d2782ae2
-        , ecc_b = 0x0713612dcddcb40aab946bda29ca91f73af958afd9
-        , ecc_g = Point 0x0369979697ab43897789566789567f787a7876a654
+                , ecc_n = 0x04000000000000000000020108a2e0cc0d99f8a5ef
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t163r1 =
+    CurveF2m $
+        CurveBinary
+            0x0800000000000000000000000000000000000000c9
+            ( CurveCommon
+                { ecc_a = 0x07b6882caaefa84f9554ff8428bd88e246d2782ae2
+                , ecc_b = 0x0713612dcddcb40aab946bda29ca91f73af958afd9
+                , ecc_g =
+                    Point
+                        0x0369979697ab43897789566789567f787a7876a654
                         0x00435edb42efafb2989d51fefce3c80988f41ff883
-        , ecc_n = 0x03ffffffffffffffffffff48aab689c29ca710279b
-        , ecc_h = 2
-        })
-getCurveByName SEC_t163r2 = CurveF2m $ CurveBinary
-    0x0800000000000000000000000000000000000000c9
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000001
-        , ecc_b = 0x020a601907b8c953ca1481eb10512f78744a3205fd
-        , ecc_g = Point 0x03f0eba16286a2d57ea0991168d4994637e8343e36
+                , ecc_n = 0x03ffffffffffffffffffff48aab689c29ca710279b
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t163r2 =
+    CurveF2m $
+        CurveBinary
+            0x0800000000000000000000000000000000000000c9
+            ( CurveCommon
+                { ecc_a = 0x000000000000000000000000000000000000000001
+                , ecc_b = 0x020a601907b8c953ca1481eb10512f78744a3205fd
+                , ecc_g =
+                    Point
+                        0x03f0eba16286a2d57ea0991168d4994637e8343e36
                         0x00d51fbc6c71a0094fa2cdd545b11c5c0c797324f1
-        , ecc_n = 0x040000000000000000000292fe77e70c12a4234c33
-        , ecc_h = 2
-        })
-getCurveByName SEC_t193r1 = CurveF2m $ CurveBinary
-    0x02000000000000000000000000000000000000000000008001
-    (CurveCommon
-        { ecc_a = 0x0017858feb7a98975169e171f77b4087de098ac8a911df7b01
-        , ecc_b = 0x00fdfb49bfe6c3a89facadaa7a1e5bbc7cc1c2e5d831478814
-        , ecc_g = Point 0x01f481bc5f0ff84a74ad6cdf6fdef4bf6179625372d8c0c5e1
+                , ecc_n = 0x040000000000000000000292fe77e70c12a4234c33
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t193r1 =
+    CurveF2m $
+        CurveBinary
+            0x02000000000000000000000000000000000000000000008001
+            ( CurveCommon
+                { ecc_a = 0x0017858feb7a98975169e171f77b4087de098ac8a911df7b01
+                , ecc_b = 0x00fdfb49bfe6c3a89facadaa7a1e5bbc7cc1c2e5d831478814
+                , ecc_g =
+                    Point
+                        0x01f481bc5f0ff84a74ad6cdf6fdef4bf6179625372d8c0c5e1
                         0x0025e399f2903712ccf3ea9e3a1ad17fb0b3201b6af7ce1b05
-        , ecc_n = 0x01000000000000000000000000c7f34a778f443acc920eba49
-        , ecc_h = 2
-        })
-getCurveByName SEC_t193r2 = CurveF2m $ CurveBinary
-    0x02000000000000000000000000000000000000000000008001
-    (CurveCommon
-        { ecc_a = 0x0163f35a5137c2ce3ea6ed8667190b0bc43ecd69977702709b
-        , ecc_b = 0x00c9bb9e8927d4d64c377e2ab2856a5b16e3efb7f61d4316ae
-        , ecc_g = Point 0x00d9b67d192e0367c803f39e1a7e82ca14a651350aae617e8f
+                , ecc_n = 0x01000000000000000000000000c7f34a778f443acc920eba49
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t193r2 =
+    CurveF2m $
+        CurveBinary
+            0x02000000000000000000000000000000000000000000008001
+            ( CurveCommon
+                { ecc_a = 0x0163f35a5137c2ce3ea6ed8667190b0bc43ecd69977702709b
+                , ecc_b = 0x00c9bb9e8927d4d64c377e2ab2856a5b16e3efb7f61d4316ae
+                , ecc_g =
+                    Point
+                        0x00d9b67d192e0367c803f39e1a7e82ca14a651350aae617e8f
                         0x01ce94335607c304ac29e7defbd9ca01f596f927224cdecf6c
-        , ecc_n = 0x010000000000000000000000015aab561b005413ccd4ee99d5
-        , ecc_h = 2
-        })
-getCurveByName SEC_t233k1 = CurveF2m $ CurveBinary
-    0x020000000000000000000000000000000000000004000000000000000001
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000000000000000000000000
-        , ecc_b = 0x000000000000000000000000000000000000000000000000000000000001
-        , ecc_g = Point 0x017232ba853a7e731af129f22ff4149563a419c26bf50a4c9d6eefad6126
+                , ecc_n = 0x010000000000000000000000015aab561b005413ccd4ee99d5
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t233k1 =
+    CurveF2m $
+        CurveBinary
+            0x020000000000000000000000000000000000000004000000000000000001
+            ( CurveCommon
+                { ecc_a = 0x000000000000000000000000000000000000000000000000000000000000
+                , ecc_b = 0x000000000000000000000000000000000000000000000000000000000001
+                , ecc_g =
+                    Point
+                        0x017232ba853a7e731af129f22ff4149563a419c26bf50a4c9d6eefad6126
                         0x01db537dece819b7f70f555a67c427a8cd9bf18aeb9b56e0c11056fae6a3
-        , ecc_n = 0x008000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf
-        , ecc_h = 4
-        })
-getCurveByName SEC_t233r1 = CurveF2m $ CurveBinary
-    0x020000000000000000000000000000000000000004000000000000000001
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000000000000000000000001
-        , ecc_b = 0x0066647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad
-        , ecc_g = Point 0x00fac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b
+                , ecc_n = 0x008000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf
+                , ecc_h = 4
+                }
+            )
+getCurveByName SEC_t233r1 =
+    CurveF2m $
+        CurveBinary
+            0x020000000000000000000000000000000000000004000000000000000001
+            ( CurveCommon
+                { ecc_a = 0x000000000000000000000000000000000000000000000000000000000001
+                , ecc_b = 0x0066647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad
+                , ecc_g =
+                    Point
+                        0x00fac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b
                         0x01006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052
-        , ecc_n = 0x01000000000000000000000000000013e974e72f8a6922031d2603cfe0d7
-        , ecc_h = 2
-        })
-getCurveByName SEC_t239k1 = CurveF2m $ CurveBinary
-    0x800000000000000000004000000000000000000000000000000000000001
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000000000000000000000000
-        , ecc_b = 0x000000000000000000000000000000000000000000000000000000000001
-        , ecc_g = Point 0x29a0b6a887a983e9730988a68727a8b2d126c44cc2cc7b2a6555193035dc
+                , ecc_n = 0x01000000000000000000000000000013e974e72f8a6922031d2603cfe0d7
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t239k1 =
+    CurveF2m $
+        CurveBinary
+            0x800000000000000000004000000000000000000000000000000000000001
+            ( CurveCommon
+                { ecc_a = 0x000000000000000000000000000000000000000000000000000000000000
+                , ecc_b = 0x000000000000000000000000000000000000000000000000000000000001
+                , ecc_g =
+                    Point
+                        0x29a0b6a887a983e9730988a68727a8b2d126c44cc2cc7b2a6555193035dc
                         0x76310804f12e549bdb011c103089e73510acb275fc312a5dc6b76553f0ca
-        , ecc_n = 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5
-        , ecc_h = 4
-        })
-getCurveByName SEC_t283k1 = CurveF2m $ CurveBinary
-    0x0800000000000000000000000000000000000000000000000000000000000000000010a1
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000000000000000000000000000000000000
-        , ecc_b = 0x000000000000000000000000000000000000000000000000000000000000000000000001
-        , ecc_g = Point 0x0503213f78ca44883f1a3b8162f188e553cd265f23c1567a16876913b0c2ac2458492836
+                , ecc_n = 0x2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5
+                , ecc_h = 4
+                }
+            )
+getCurveByName SEC_t283k1 =
+    CurveF2m $
+        CurveBinary
+            0x0800000000000000000000000000000000000000000000000000000000000000000010a1
+            ( CurveCommon
+                { ecc_a =
+                    0x000000000000000000000000000000000000000000000000000000000000000000000000
+                , ecc_b =
+                    0x000000000000000000000000000000000000000000000000000000000000000000000001
+                , ecc_g =
+                    Point
+                        0x0503213f78ca44883f1a3b8162f188e553cd265f23c1567a16876913b0c2ac2458492836
                         0x01ccda380f1c9e318d90f95d07e5426fe87e45c0e8184698e45962364e34116177dd2259
-        , ecc_n = 0x01ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61
-        , ecc_h = 4
-        })
-getCurveByName SEC_t283r1 = CurveF2m $ CurveBinary
-    0x0800000000000000000000000000000000000000000000000000000000000000000010a1
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000000000000000000000000000000000001
-        , ecc_b = 0x027b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5
-        , ecc_g = Point 0x05f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053
+                , ecc_n =
+                    0x01ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61
+                , ecc_h = 4
+                }
+            )
+getCurveByName SEC_t283r1 =
+    CurveF2m $
+        CurveBinary
+            0x0800000000000000000000000000000000000000000000000000000000000000000010a1
+            ( CurveCommon
+                { ecc_a =
+                    0x000000000000000000000000000000000000000000000000000000000000000000000001
+                , ecc_b =
+                    0x027b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5
+                , ecc_g =
+                    Point
+                        0x05f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053
                         0x03676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4
-        , ecc_n = 0x03ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307
-        , ecc_h = 2
-        })
-getCurveByName SEC_t409k1 = CurveF2m $ CurveBinary
-    0x02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001
-    (CurveCommon
-        { ecc_a = 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-        , ecc_b = 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
-        , ecc_g = Point 0x0060f05f658f49c1ad3ab1890f7184210efd0987e307c84c27accfb8f9f67cc2c460189eb5aaaa62ee222eb1b35540cfe9023746
+                , ecc_n =
+                    0x03ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t409k1 =
+    CurveF2m $
+        CurveBinary
+            0x02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001
+            ( CurveCommon
+                { ecc_a =
+                    0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+                , ecc_b =
+                    0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+                , ecc_g =
+                    Point
+                        0x0060f05f658f49c1ad3ab1890f7184210efd0987e307c84c27accfb8f9f67cc2c460189eb5aaaa62ee222eb1b35540cfe9023746
                         0x01e369050b7c4e42acba1dacbf04299c3460782f918ea427e6325165e9ea10e3da5f6c42e9c55215aa9ca27a5863ec48d8e0286b
-        , ecc_n = 0x007ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf
-        , ecc_h = 4
-        })
-getCurveByName SEC_t409r1 = CurveF2m $ CurveBinary
-    0x02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001
-    (CurveCommon
-        { ecc_a = 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
-        , ecc_b = 0x0021a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f
-        , ecc_g = Point 0x015d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7
+                , ecc_n =
+                    0x007ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf
+                , ecc_h = 4
+                }
+            )
+getCurveByName SEC_t409r1 =
+    CurveF2m $
+        CurveBinary
+            0x02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001
+            ( CurveCommon
+                { ecc_a =
+                    0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+                , ecc_b =
+                    0x0021a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f
+                , ecc_g =
+                    Point
+                        0x015d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7
                         0x0061b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706
-        , ecc_n = 0x010000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173
-        , ecc_h = 2
-        })
-getCurveByName SEC_t571k1 = CurveF2m $ CurveBinary
-    0x080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-        , ecc_b = 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
-        , ecc_g = Point 0x026eb7a859923fbc82189631f8103fe4ac9ca2970012d5d46024804801841ca44370958493b205e647da304db4ceb08cbbd1ba39494776fb988b47174dca88c7e2945283a01c8972
+                , ecc_n =
+                    0x010000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173
+                , ecc_h = 2
+                }
+            )
+getCurveByName SEC_t571k1 =
+    CurveF2m $
+        CurveBinary
+            0x080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425
+            ( CurveCommon
+                { ecc_a =
+                    0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+                , ecc_b =
+                    0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+                , ecc_g =
+                    Point
+                        0x026eb7a859923fbc82189631f8103fe4ac9ca2970012d5d46024804801841ca44370958493b205e647da304db4ceb08cbbd1ba39494776fb988b47174dca88c7e2945283a01c8972
                         0x0349dc807f4fbf374f4aeade3bca95314dd58cec9f307a54ffc61efc006d8a2c9d4979c0ac44aea74fbebbb9f772aedcb620b01a7ba7af1b320430c8591984f601cd4c143ef1c7a3
-        , ecc_n = 0x020000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001
-        , ecc_h = 4
-        })
-getCurveByName SEC_t571r1 = CurveF2m $ CurveBinary
-    0x080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425
-    (CurveCommon
-        { ecc_a = 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
-        , ecc_b = 0x02f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a
-        , ecc_g = Point 0x0303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19
+                , ecc_n =
+                    0x020000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001
+                , ecc_h = 4
+                }
+            )
+getCurveByName SEC_t571r1 =
+    CurveF2m $
+        CurveBinary
+            0x080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425
+            ( CurveCommon
+                { ecc_a =
+                    0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+                , ecc_b =
+                    0x02f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a
+                , ecc_g =
+                    Point
+                        0x0303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19
                         0x037bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b
-        , ecc_n = 0x03ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47
-        , ecc_h = 2
-        })
+                , ecc_n =
+                    0x03ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47
+                , ecc_h = 2
+                }
+            )
diff --git a/Crypto/PubKey/ECDSA.hs b/Crypto/PubKey/ECDSA.hs
--- a/Crypto/PubKey/ECDSA.hs
+++ b/Crypto/PubKey/ECDSA.hs
@@ -1,3 +1,10 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE UndecidableInstances #-}
+
 -- |
 -- Module      : Crypto.PubKey.ECDSA
 -- License     : BSD-style
@@ -15,60 +22,59 @@
 -- Signature operations with P-384 and P-521 may leak the private key.
 --
 -- Signature verification should be safe for all curves.
-{-# LANGUAGE BangPatterns #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE StandaloneDeriving #-}
-{-# LANGUAGE TypeFamilies #-}
-{-# LANGUAGE UndecidableInstances #-}
-module Crypto.PubKey.ECDSA
-    ( EllipticCurveECDSA (..)
+module Crypto.PubKey.ECDSA (
+    EllipticCurveECDSA (..),
+
     -- * Public keys
-    , PublicKey
-    , encodePublic
-    , decodePublic
-    , toPublic
+    PublicKey,
+    encodePublic,
+    decodePublic,
+    toPublic,
+
     -- * Private keys
-    , PrivateKey
-    , encodePrivate
-    , decodePrivate
+    PrivateKey,
+    encodePrivate,
+    decodePrivate,
+
     -- * Signatures
-    , Signature(..)
-    , signatureFromIntegers
-    , signatureToIntegers
+    Signature (..),
+    signatureFromIntegers,
+    signatureToIntegers,
+
     -- * Generation and verification
-    , signWith
-    , signDigestWith
-    , sign
-    , signDigest
-    , verify
-    , verifyDigest
-    ) where
+    signWith,
+    signDigestWith,
+    sign,
+    signDigest,
+    verify,
+    verifyDigest,
+) where
 
-import           Control.Monad
+import Control.Monad
 
-import           Crypto.ECC
+import Crypto.ECC
 import qualified Crypto.ECC.Simple.Types as Simple
-import           Crypto.Error
-import           Crypto.Hash
-import           Crypto.Hash.Types
-import           Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
-import           Crypto.Internal.Imports
-import           Crypto.Number.ModArithmetic (inverseFermat)
+import Crypto.Error
+import Crypto.Hash
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
+import Crypto.Internal.Imports
+import Crypto.Number.ModArithmetic (inverseFermat)
 import qualified Crypto.PubKey.ECC.P256 as P256
-import           Crypto.Random.Types
+import Crypto.Random.Types
 
-import           Data.Bits
+import Data.Bits
 import qualified Data.ByteArray as B
-import           Data.Data
+import Data.Data
 
-import           Foreign.Ptr (Ptr)
-import           Foreign.Storable (peekByteOff, pokeByteOff)
+import Foreign.Ptr (Ptr)
+import Foreign.Storable (peekByteOff, pokeByteOff)
 
 -- | Represent a ECDSA signature namely R and S.
 data Signature curve = Signature
-    { sign_r :: Scalar curve -- ^ ECDSA r
-    , sign_s :: Scalar curve -- ^ ECDSA s
+    { sign_r :: Scalar curve
+    -- ^ ECDSA r
+    , sign_s :: Scalar curve
+    -- ^ ECDSA s
     }
 
 deriving instance Eq (Scalar curve) => Eq (Signature curve)
@@ -99,15 +105,17 @@
     pointX :: proxy curve -> Point curve -> Maybe (Scalar curve)
 
 instance EllipticCurveECDSA Curve_P256R1 where
-    scalarIsValid _ s = not (P256.scalarIsZero s)
-                            && P256.scalarCmp s P256.scalarN == LT
+    scalarIsValid _ s =
+        not (P256.scalarIsZero s)
+            && P256.scalarCmp s P256.scalarN == LT
 
     scalarIsZero _ = P256.scalarIsZero
 
-    scalarInv _ s = let inv = P256.scalarInvSafe s
-                     in if P256.scalarIsZero inv then Nothing else Just inv
+    scalarInv _ s =
+        let inv = P256.scalarInvSafe s
+         in if P256.scalarIsZero inv then Nothing else Just inv
 
-    pointX _  = P256.pointX
+    pointX _ = P256.pointX
 
 instance EllipticCurveECDSA Curve_P384R1 where
     scalarIsValid _ = ecScalarIsValid (Proxy :: Proxy Simple.SEC_p384r1)
@@ -116,7 +124,7 @@
 
     scalarInv _ = ecScalarInv (Proxy :: Proxy Simple.SEC_p384r1)
 
-    pointX _  = ecPointX (Proxy :: Proxy Simple.SEC_p384r1)
+    pointX _ = ecPointX (Proxy :: Proxy Simple.SEC_p384r1)
 
 instance EllipticCurveECDSA Curve_P521R1 where
     scalarIsValid _ = ecScalarIsValid (Proxy :: Proxy Simple.SEC_p521r1)
@@ -125,12 +133,12 @@
 
     scalarInv _ = ecScalarInv (Proxy :: Proxy Simple.SEC_p521r1)
 
-    pointX _  = ecPointX (Proxy :: Proxy Simple.SEC_p521r1)
-
+    pointX _ = ecPointX (Proxy :: Proxy Simple.SEC_p521r1)
 
 -- | Create a signature from integers (R, S).
-signatureFromIntegers :: EllipticCurveECDSA curve
-                      => proxy curve -> (Integer, Integer) -> CryptoFailable (Signature curve)
+signatureFromIntegers
+    :: EllipticCurveECDSA curve
+    => proxy curve -> (Integer, Integer) -> CryptoFailable (Signature curve)
 signatureFromIntegers prx (r, s) =
     liftA2 Signature (scalarFromInteger prx r) (scalarFromInteger prx s)
 
@@ -138,41 +146,52 @@
 --
 -- The values can then be used to encode the signature to binary with
 -- ASN.1.
-signatureToIntegers :: EllipticCurveECDSA curve
-                    => proxy curve -> Signature curve -> (Integer, Integer)
+signatureToIntegers
+    :: EllipticCurveECDSA curve
+    => proxy curve -> Signature curve -> (Integer, Integer)
 signatureToIntegers prx sig =
     (scalarToInteger prx $ sign_r sig, scalarToInteger prx $ sign_s sig)
 
 -- | Encode a public key into binary form, i.e. the uncompressed encoding
 -- referenced from <https://tools.ietf.org/html/rfc5480 RFC 5480> section 2.2.
-encodePublic :: (EllipticCurve curve, ByteArray bs)
-             => proxy curve -> PublicKey curve -> bs
+encodePublic
+    :: (EllipticCurve curve, ByteArray bs)
+    => proxy curve -> PublicKey curve -> bs
 encodePublic = encodePoint
 
 -- | Try to decode the binary form of a public key.
-decodePublic :: (EllipticCurve curve, ByteArray bs)
-             => proxy curve -> bs -> CryptoFailable (PublicKey curve)
+decodePublic
+    :: (EllipticCurve curve, ByteArray bs)
+    => proxy curve -> bs -> CryptoFailable (PublicKey curve)
 decodePublic = decodePoint
 
 -- | Encode a private key into binary form, i.e. the @privateKey@ field
 -- described in <https://tools.ietf.org/html/rfc5915 RFC 5915>.
-encodePrivate :: (EllipticCurveECDSA curve, ByteArray bs)
-              => proxy curve -> PrivateKey curve -> bs
+encodePrivate
+    :: (EllipticCurveECDSA curve, ByteArray bs)
+    => proxy curve -> PrivateKey curve -> bs
 encodePrivate = encodeScalar
 
 -- | Try to decode the binary form of a private key.
-decodePrivate :: (EllipticCurveECDSA curve, ByteArray bs)
-              => proxy curve -> bs -> CryptoFailable (PrivateKey curve)
+decodePrivate
+    :: (EllipticCurveECDSA curve, ByteArray bs)
+    => proxy curve -> bs -> CryptoFailable (PrivateKey curve)
 decodePrivate = decodeScalar
 
 -- | Create a public key from a private key.
-toPublic :: EllipticCurveECDSA curve
-         => proxy curve -> PrivateKey curve -> PublicKey curve
+toPublic
+    :: EllipticCurveECDSA curve
+    => proxy curve -> PrivateKey curve -> PublicKey curve
 toPublic = pointBaseSmul
 
 -- | Sign digest using the private key and an explicit k scalar.
-signDigestWith :: (EllipticCurveECDSA curve, HashAlgorithm hash)
-               => proxy curve -> Scalar curve -> PrivateKey curve -> Digest hash -> Maybe (Signature curve)
+signDigestWith
+    :: (EllipticCurveECDSA curve, HashAlgorithm hash)
+    => proxy curve
+    -> Scalar curve
+    -> PrivateKey curve
+    -> Digest hash
+    -> Maybe (Signature curve)
 signDigestWith prx k d digest = do
     let z = tHashDigest prx digest
         point = pointBaseSmul prx k
@@ -183,90 +202,114 @@
     return $ Signature r s
 
 -- | Sign message using the private key and an explicit k scalar.
-signWith :: (EllipticCurveECDSA curve, ByteArrayAccess msg, HashAlgorithm hash)
-         => proxy curve -> Scalar curve -> PrivateKey curve -> hash -> msg -> Maybe (Signature curve)
+signWith
+    :: (EllipticCurveECDSA curve, ByteArrayAccess msg, HashAlgorithm hash)
+    => proxy curve
+    -> Scalar curve
+    -> PrivateKey curve
+    -> hash
+    -> msg
+    -> Maybe (Signature curve)
 signWith prx k d hashAlg msg = signDigestWith prx k d (hashWith hashAlg msg)
 
 -- | Sign a digest using hash and private key.
-signDigest :: (EllipticCurveECDSA curve, MonadRandom m, HashAlgorithm hash)
-           => proxy curve -> PrivateKey curve -> Digest hash -> m (Signature curve)
+signDigest
+    :: (EllipticCurveECDSA curve, MonadRandom m, HashAlgorithm hash)
+    => proxy curve -> PrivateKey curve -> Digest hash -> m (Signature curve)
 signDigest prx pk digest = do
     k <- curveGenerateScalar prx
     case signDigestWith prx k pk digest of
-        Nothing  -> signDigest prx pk digest
+        Nothing -> signDigest prx pk digest
         Just sig -> return sig
 
 -- | Sign a message using hash and private key.
-sign :: (EllipticCurveECDSA curve, MonadRandom m, ByteArrayAccess msg, HashAlgorithm hash)
-     => proxy curve -> PrivateKey curve -> hash -> msg -> m (Signature curve)
+sign
+    :: ( EllipticCurveECDSA curve
+       , MonadRandom m
+       , ByteArrayAccess msg
+       , HashAlgorithm hash
+       )
+    => proxy curve -> PrivateKey curve -> hash -> msg -> m (Signature curve)
 sign prx pk hashAlg msg = signDigest prx pk (hashWith hashAlg msg)
 
 -- | Verify a digest using hash and public key.
-verifyDigest :: (EllipticCurveECDSA curve, HashAlgorithm hash)
-       => proxy curve -> PublicKey curve -> Signature curve -> Digest hash -> Bool
+verifyDigest
+    :: (EllipticCurveECDSA curve, HashAlgorithm hash)
+    => proxy curve -> PublicKey curve -> Signature curve -> Digest hash -> Bool
 verifyDigest prx q (Signature r s) digest
     | not (scalarIsValid prx r) = False
     | not (scalarIsValid prx s) = False
     | otherwise = maybe False (r ==) $ do
         w <- scalarInv prx s
-        let z  = tHashDigest prx digest
+        let z = tHashDigest prx digest
             u1 = scalarMul prx z w
             u2 = scalarMul prx r w
-            x  = pointsSmulVarTime prx u1 u2 q
+            x = pointsSmulVarTime prx u1 u2 q
         pointX prx x
-    -- Note: precondition q /= PointO is not tested because we assume
-    -- point decoding never decodes point at infinity.
 
+-- Note: precondition q /= PointO is not tested because we assume
+-- point decoding never decodes point at infinity.
+
 -- | Verify a signature using hash and public key.
-verify :: (EllipticCurveECDSA curve, ByteArrayAccess msg, HashAlgorithm hash)
-       => proxy curve -> hash -> PublicKey curve -> Signature curve -> msg -> Bool
+verify
+    :: (EllipticCurveECDSA curve, ByteArrayAccess msg, HashAlgorithm hash)
+    => proxy curve -> hash -> PublicKey curve -> Signature curve -> msg -> Bool
 verify prx hashAlg q sig msg = verifyDigest prx q sig (hashWith hashAlg msg)
 
 -- | Truncate a digest based on curve order size.
-tHashDigest :: (EllipticCurveECDSA curve, HashAlgorithm hash)
-            => proxy curve -> Digest hash -> Scalar curve
-tHashDigest prx (Digest digest) = throwCryptoError $ decodeScalar prx encoded
-  where m      = curveOrderBits prx
-        d      = m - B.length digest * 8
-        (n, r) = m `divMod` 8
-        n'     = if r > 0 then succ n else n
-
-        encoded
-            | d >  0    = B.zero (n' - B.length digest) `B.append` digest
-            | d == 0    = digest
-            | r == 0    = B.take n digest
-            | otherwise = shiftBytes digest
+tHashDigest
+    :: (EllipticCurveECDSA curve, HashAlgorithm hash)
+    => proxy curve -> Digest hash -> Scalar curve
+tHashDigest prx dig = throwCryptoError $ decodeScalar prx encoded
+  where
+    digest = B.convert dig :: B.Bytes
+    m = curveOrderBits prx
+    d = m - B.length digest * 8
+    (n, r) = m `divMod` 8
+    n' = if r > 0 then succ n else n
 
-        shiftBytes bs = B.allocAndFreeze n' $ \dst ->
-            B.withByteArray bs $ \src -> go dst src 0 0
+    encoded
+        | d > 0 = B.zero (n' - B.length digest) `B.append` digest
+        | d == 0 = digest
+        | r == 0 = B.take n digest
+        | otherwise = shiftBytes digest
 
-        go :: Ptr Word8 -> Ptr Word8 -> Word8 -> Int -> IO ()
-        go dst src !a i
-            | i >= n'   = return ()
-            | otherwise = do
-                b <- peekByteOff src i
-                pokeByteOff dst i (unsafeShiftR b (8 - r) .|. unsafeShiftL a r)
-                go dst src b (succ i)
+    shiftBytes bs = B.allocAndFreeze n' $ \dst ->
+        B.withByteArray bs $ \src -> go dst src 0 0
 
+    go :: Ptr Word8 -> Ptr Word8 -> Word8 -> Int -> IO ()
+    go dst src !a i
+        | i >= n' = return ()
+        | otherwise = do
+            b <- peekByteOff src i
+            pokeByteOff dst i (unsafeShiftR b (8 - r) .|. unsafeShiftL a r)
+            go dst src b (succ i)
 
 ecScalarIsValid :: Simple.Curve c => proxy c -> Simple.Scalar c -> Bool
 ecScalarIsValid prx (Simple.Scalar s) = s > 0 && s < n
-  where n = Simple.curveEccN $ Simple.curveParameters prx
+  where
+    n = Simple.curveEccN $ Simple.curveParameters prx
 
-ecScalarIsZero :: forall curve . Simple.Curve curve
-               => Simple.Scalar curve -> Bool
+ecScalarIsZero
+    :: forall curve
+     . Simple.Curve curve
+    => Simple.Scalar curve -> Bool
 ecScalarIsZero (Simple.Scalar a) = a == 0
 
-ecScalarInv :: Simple.Curve c
-            => proxy c -> Simple.Scalar c -> Maybe (Simple.Scalar c)
+ecScalarInv
+    :: Simple.Curve c
+    => proxy c -> Simple.Scalar c -> Maybe (Simple.Scalar c)
 ecScalarInv prx (Simple.Scalar s)
-    | i == 0    = Nothing
+    | i == 0 = Nothing
     | otherwise = Just $ Simple.Scalar i
-  where n = Simple.curveEccN $ Simple.curveParameters prx
-        i = inverseFermat s n
+  where
+    n = Simple.curveEccN $ Simple.curveParameters prx
+    i = inverseFermat s n
 
-ecPointX :: Simple.Curve c
-         => proxy c -> Simple.Point c -> Maybe (Simple.Scalar c)
-ecPointX _   Simple.PointO      = Nothing
+ecPointX
+    :: Simple.Curve c
+    => proxy c -> Simple.Point c -> Maybe (Simple.Scalar c)
+ecPointX _ Simple.PointO = Nothing
 ecPointX prx (Simple.Point x _) = Just (Simple.Scalar $ x `mod` n)
-  where n = Simple.curveEccN $ Simple.curveParameters prx
+  where
+    n = Simple.curveEccN $ Simple.curveParameters prx
diff --git a/Crypto/PubKey/ECIES.hs b/Crypto/PubKey/ECIES.hs
--- a/Crypto/PubKey/ECIES.hs
+++ b/Crypto/PubKey/ECIES.hs
@@ -18,31 +18,37 @@
 -- This module doesn't provide any symmetric data encryption capability or any mean to derive
 -- cryptographic key material for a symmetric key from the shared secret.
 -- this is left to the user for now.
---
-module Crypto.PubKey.ECIES
-    ( deriveEncrypt
-    , deriveDecrypt
-    ) where
+module Crypto.PubKey.ECIES (
+    deriveEncrypt,
+    deriveDecrypt,
+) where
 
-import           Crypto.ECC
-import           Crypto.Error
-import           Crypto.Random
+import Crypto.ECC
+import Crypto.Error
+import Crypto.Random
 
 -- | Generate random a new Shared secret and the associated point
 -- to do a ECIES style encryption
-deriveEncrypt :: (MonadRandom randomly, EllipticCurveDH curve)
-              => proxy curve -- ^ representation of the curve
-              -> Point curve -- ^ the public key of the receiver
-              -> randomly (CryptoFailable (Point curve, SharedSecret))
+deriveEncrypt
+    :: (MonadRandom randomly, EllipticCurveDH curve)
+    => proxy curve
+    -- ^ representation of the curve
+    -> Point curve
+    -- ^ the public key of the receiver
+    -> randomly (CryptoFailable (Point curve, SharedSecret))
 deriveEncrypt proxy pub = do
     (KeyPair rPoint rScalar) <- curveGenerateKeyPair proxy
     return $ (\s -> (rPoint, s)) `fmap` ecdh proxy rScalar pub
 
 -- | Derive the shared secret with the receiver key
 -- and the R point of the scheme.
-deriveDecrypt :: EllipticCurveDH curve
-              => proxy curve  -- ^ representation of the curve
-              -> Point curve  -- ^ The received R (supposedly, randomly generated on the encrypt side)
-              -> Scalar curve -- ^ The secret key of the receiver
-              -> CryptoFailable SharedSecret
+deriveDecrypt
+    :: EllipticCurveDH curve
+    => proxy curve
+    -- ^ representation of the curve
+    -> Point curve
+    -- ^ The received R (supposedly, randomly generated on the encrypt side)
+    -> Scalar curve
+    -- ^ The secret key of the receiver
+    -> CryptoFailable SharedSecret
 deriveDecrypt proxy point secret = ecdh proxy secret point
diff --git a/Crypto/PubKey/Ed25519.hs b/Crypto/PubKey/Ed25519.hs
--- a/Crypto/PubKey/Ed25519.hs
+++ b/Crypto/PubKey/Ed25519.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.PubKey.Ed25519
 -- License     : BSD-style
@@ -6,51 +9,56 @@
 -- Portability : unknown
 --
 -- Ed25519 support
---
-{-# LANGUAGE BangPatterns               #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.PubKey.Ed25519
-    ( SecretKey
-    , PublicKey
-    , Signature
+module Crypto.PubKey.Ed25519 (
+    SecretKey,
+    PublicKey,
+    Signature,
+
     -- * Size constants
-    , publicKeySize
-    , secretKeySize
-    , signatureSize
+    publicKeySize,
+    secretKeySize,
+    signatureSize,
+
     -- * Smart constructors
-    , signature
-    , publicKey
-    , secretKey
+    signature,
+    publicKey,
+    secretKey,
+
     -- * Methods
-    , toPublic
-    , sign
-    , verify
-    , generateSecretKey
-    ) where
+    toPublic,
+    sign,
+    unsafeSign,
+    verify,
+    generateSecretKey,
+) where
 
-import           Data.Word
-import           Foreign.C.Types
-import           Foreign.Ptr
+import Data.Word
+import Foreign.C.Types
+import Foreign.Ptr
 
-import           Crypto.Error
-import           Crypto.Internal.ByteArray (ByteArrayAccess, Bytes,
-                                            ScrubbedBytes, withByteArray)
+import Crypto.Error
+import Crypto.Internal.ByteArray (
+    ByteArrayAccess,
+    Bytes,
+    ScrubbedBytes,
+    withByteArray,
+ )
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Crypto.Random
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Crypto.Random
 
 -- | An Ed25519 Secret key
 newtype SecretKey = SecretKey ScrubbedBytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | An Ed25519 public key
 newtype PublicKey = PublicKey Bytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | An Ed25519 signature
 newtype Signature = Signature Bytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | Try to build a public key from a bytearray
 publicKey :: ByteArrayAccess ba => ba -> CryptoFailable PublicKey
@@ -64,15 +72,16 @@
 secretKey :: ByteArrayAccess ba => ba -> CryptoFailable SecretKey
 secretKey bs
     | B.length bs == secretKeySize = unsafeDoIO $ withByteArray bs initialize
-    | otherwise                    = CryptoFailed CryptoError_SecretKeyStructureInvalid
+    | otherwise =
+        CryptoFailed CryptoError_SecretKeyStructureInvalid
   where
-        initialize inp = do
-            valid <- isValidPtr inp
-            if valid
-                then (CryptoPassed . SecretKey) <$> B.copy bs (\_ -> return ())
-                else return $ CryptoFailed CryptoError_SecretKeyStructureInvalid
-        isValidPtr _ =
-            return True
+    initialize inp = do
+        valid <- isValidPtr inp
+        if valid
+            then (CryptoPassed . SecretKey) <$> B.copy bs (\_ -> return ())
+            else return $ CryptoFailed CryptoError_SecretKeyStructureInvalid
+    isValidPtr _ =
+        return True
 {-# NOINLINE secretKey #-}
 
 -- | Try to build a signature from a bytearray
@@ -85,31 +94,51 @@
 
 -- | Create a public key from a secret key
 toPublic :: SecretKey -> PublicKey
-toPublic (SecretKey sec) = PublicKey <$>
-    B.allocAndFreeze publicKeySize $ \result ->
-    withByteArray sec              $ \psec   ->
-        ccrypton_ed25519_publickey psec result
+toPublic (SecretKey sec) = PublicKey
+    <$> B.allocAndFreeze publicKeySize
+    $ \result ->
+        withByteArray sec $ \psec ->
+            ccrypton_ed25519_publickey psec result
 {-# NOINLINE toPublic #-}
 
--- | Sign a message using the key pair
+-- | Sign a message using the key pair.
+--   The public key parameter is ignored and its public key
+--   is generated from the secret key parameter to prevent
+--   Double Public Key Signing Function Oracle Attack.
 sign :: ByteArrayAccess ba => SecretKey -> PublicKey -> ba -> Signature
-sign secret public message =
+sign secret _public message =
     Signature $ B.allocAndFreeze signatureSize $ \sig ->
-        withByteArray secret  $ \sec ->
-        withByteArray public  $ \pub ->
-        withByteArray message $ \msg ->
-             ccrypton_ed25519_sign msg (fromIntegral msgLen) sec pub sig
+        withByteArray secret $ \sec ->
+            withByteArray public $ \pub ->
+                withByteArray message $ \msg ->
+                    ccrypton_ed25519_sign msg (fromIntegral msgLen) sec pub sig
   where
     !msgLen = B.length message
+    public = toPublic secret
 
+-- | Sign a message using the key pair.  This is old `sign`, which is
+-- vulnerable to private key compromise if the given public key does
+-- not correspond to the secret key. This function is provided for
+-- performance critical applications. To use it safely, applications
+-- must verify or derive the public key.
+unsafeSign :: ByteArrayAccess ba => SecretKey -> PublicKey -> ba -> Signature
+unsafeSign secret public message =
+    Signature $ B.allocAndFreeze signatureSize $ \sig ->
+        withByteArray secret $ \sec ->
+            withByteArray public $ \pub ->
+                withByteArray message $ \msg ->
+                    ccrypton_ed25519_sign msg (fromIntegral msgLen) sec pub sig
+  where
+    !msgLen = B.length message
+
 -- | Verify a message
 verify :: ByteArrayAccess ba => PublicKey -> ba -> Signature -> Bool
 verify public message signatureVal = unsafeDoIO $
     withByteArray signatureVal $ \sig ->
-    withByteArray public       $ \pub ->
-    withByteArray message      $ \msg -> do
-      r <- ccrypton_ed25519_sign_open msg (fromIntegral msgLen) pub sig
-      return (r == 0)
+        withByteArray public $ \pub ->
+            withByteArray message $ \msg -> do
+                r <- ccrypton_ed25519_sign_open msg (fromIntegral msgLen) pub sig
+                return (r == 0)
   where
     !msgLen = B.length message
 
@@ -130,21 +159,24 @@
 signatureSize = 64
 
 foreign import ccall "crypton_ed25519_publickey"
-    ccrypton_ed25519_publickey :: Ptr SecretKey -- secret key
-                                  -> Ptr PublicKey -- public key
-                                  -> IO ()
+    ccrypton_ed25519_publickey
+        :: Ptr SecretKey -- secret key
+        -> Ptr PublicKey -- public key
+        -> IO ()
 
 foreign import ccall "crypton_ed25519_sign_open"
-    ccrypton_ed25519_sign_open :: Ptr Word8     -- message
-                                  -> CSize         -- message len
-                                  -> Ptr PublicKey -- public
-                                  -> Ptr Signature -- signature
-                                  -> IO CInt
+    ccrypton_ed25519_sign_open
+        :: Ptr Word8 -- message
+        -> CSize -- message len
+        -> Ptr PublicKey -- public
+        -> Ptr Signature -- signature
+        -> IO CInt
 
 foreign import ccall "crypton_ed25519_sign"
-    ccrypton_ed25519_sign :: Ptr Word8     -- message
-                             -> CSize         -- message len
-                             -> Ptr SecretKey -- secret
-                             -> Ptr PublicKey -- public
-                             -> Ptr Signature -- signature
-                             -> IO ()
+    ccrypton_ed25519_sign
+        :: Ptr Word8 -- message
+        -> CSize -- message len
+        -> Ptr SecretKey -- secret
+        -> Ptr PublicKey -- public
+        -> Ptr Signature -- signature
+        -> IO ()
diff --git a/Crypto/PubKey/Ed448.hs b/Crypto/PubKey/Ed448.hs
--- a/Crypto/PubKey/Ed448.hs
+++ b/Crypto/PubKey/Ed448.hs
@@ -1,3 +1,6 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.PubKey.Ed448
 -- License     : BSD-style
@@ -10,51 +13,56 @@
 -- Internally uses Decaf point compression to omit the cofactor
 -- and implementation by Mike Hamburg.  Externally API and
 -- data types are compatible with the encoding specified in RFC 8032.
---
-{-# LANGUAGE BangPatterns               #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.PubKey.Ed448
-    ( SecretKey
-    , PublicKey
-    , Signature
+module Crypto.PubKey.Ed448 (
+    SecretKey,
+    PublicKey,
+    Signature,
+
     -- * Size constants
-    , publicKeySize
-    , secretKeySize
-    , signatureSize
+    publicKeySize,
+    secretKeySize,
+    signatureSize,
+
     -- * Smart constructors
-    , signature
-    , publicKey
-    , secretKey
+    signature,
+    publicKey,
+    secretKey,
+
     -- * Methods
-    , toPublic
-    , sign
-    , verify
-    , generateSecretKey
-    ) where
+    toPublic,
+    sign,
+    unsafeSign,
+    verify,
+    generateSecretKey,
+) where
 
-import           Data.Word
-import           Foreign.C.Types
-import           Foreign.Ptr
+import Data.Word
+import Foreign.C.Types
+import Foreign.Ptr
 
-import           Crypto.Error
-import           Crypto.Internal.ByteArray (ByteArrayAccess, Bytes,
-                                            ScrubbedBytes, withByteArray)
+import Crypto.Error
+import Crypto.Internal.ByteArray (
+    ByteArrayAccess,
+    Bytes,
+    ScrubbedBytes,
+    withByteArray,
+ )
 import qualified Crypto.Internal.ByteArray as B
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Crypto.Random
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Crypto.Random
 
 -- | An Ed448 Secret key
 newtype SecretKey = SecretKey ScrubbedBytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | An Ed448 public key
 newtype PublicKey = PublicKey Bytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | An Ed448 signature
 newtype Signature = Signature Bytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | Try to build a public key from a bytearray
 publicKey :: ByteArrayAccess ba => ba -> CryptoFailable PublicKey
@@ -68,15 +76,16 @@
 secretKey :: ByteArrayAccess ba => ba -> CryptoFailable SecretKey
 secretKey bs
     | B.length bs == secretKeySize = unsafeDoIO $ withByteArray bs initialize
-    | otherwise                    = CryptoFailed CryptoError_SecretKeyStructureInvalid
+    | otherwise =
+        CryptoFailed CryptoError_SecretKeyStructureInvalid
   where
-        initialize inp = do
-            valid <- isValidPtr inp
-            if valid
-                then (CryptoPassed . SecretKey) <$> B.copy bs (\_ -> return ())
-                else return $ CryptoFailed CryptoError_SecretKeyStructureInvalid
-        isValidPtr _ =
-            return True
+    initialize inp = do
+        valid <- isValidPtr inp
+        if valid
+            then (CryptoPassed . SecretKey) <$> B.copy bs (\_ -> return ())
+            else return $ CryptoFailed CryptoError_SecretKeyStructureInvalid
+    isValidPtr _ =
+        return True
 {-# NOINLINE secretKey #-}
 
 -- | Try to build a signature from a bytearray
@@ -89,31 +98,51 @@
 
 -- | Create a public key from a secret key
 toPublic :: SecretKey -> PublicKey
-toPublic (SecretKey sec) = PublicKey <$>
-    B.allocAndFreeze publicKeySize $ \result ->
-    withByteArray sec              $ \psec   ->
-        decaf_ed448_derive_public_key result psec
+toPublic (SecretKey sec) = PublicKey
+    <$> B.allocAndFreeze publicKeySize
+    $ \result ->
+        withByteArray sec $ \psec ->
+            decaf_ed448_derive_public_key result psec
 {-# NOINLINE toPublic #-}
 
 -- | Sign a message using the key pair
+--   The public key parameter is ignored and its public key
+--   is generated from the secret key parameter to prevent
+--   Double Public Key Signing Function Oracle Attack.
 sign :: ByteArrayAccess ba => SecretKey -> PublicKey -> ba -> Signature
-sign secret public message =
+sign secret _public message =
     Signature $ B.allocAndFreeze signatureSize $ \sig ->
-        withByteArray secret  $ \sec ->
-        withByteArray public  $ \pub ->
-        withByteArray message $ \msg ->
-             decaf_ed448_sign sig sec pub msg (fromIntegral msgLen) 0 no_context 0
+        withByteArray secret $ \sec ->
+            withByteArray public $ \pub ->
+                withByteArray message $ \msg ->
+                    decaf_ed448_sign sig sec pub msg (fromIntegral msgLen) 0 no_context 0
   where
     !msgLen = B.length message
+    public = toPublic secret
 
+-- | Sign a message using the key pair.  This is old `sign`, which is
+-- vulnerable to private key compromise if the given public key does
+-- not correspond to the secret key. This function is provided for
+-- performance critical applications. To use it safely, applications
+-- must verify or derive the public key.
+unsafeSign :: ByteArrayAccess ba => SecretKey -> PublicKey -> ba -> Signature
+unsafeSign secret public message =
+    Signature $ B.allocAndFreeze signatureSize $ \sig ->
+        withByteArray secret $ \sec ->
+            withByteArray public $ \pub ->
+                withByteArray message $ \msg ->
+                    decaf_ed448_sign sig sec pub msg (fromIntegral msgLen) 0 no_context 0
+  where
+    !msgLen = B.length message
+
 -- | Verify a message
 verify :: ByteArrayAccess ba => PublicKey -> ba -> Signature -> Bool
 verify public message signatureVal = unsafeDoIO $
     withByteArray signatureVal $ \sig ->
-    withByteArray public       $ \pub ->
-    withByteArray message      $ \msg -> do
-      r <- decaf_ed448_verify sig pub msg (fromIntegral msgLen) 0 no_context 0
-      return (r /= 0)
+        withByteArray public $ \pub ->
+            withByteArray message $ \msg -> do
+                r <- decaf_ed448_verify sig pub msg (fromIntegral msgLen) 0 no_context 0
+                return (r /= 0)
   where
     !msgLen = B.length message
 
@@ -137,27 +166,30 @@
 no_context = nullPtr -- not supported yet
 
 foreign import ccall "crypton_decaf_ed448_derive_public_key"
-    decaf_ed448_derive_public_key :: Ptr PublicKey -- public key
-                                  -> Ptr SecretKey -- secret key
-                                  -> IO ()
+    decaf_ed448_derive_public_key
+        :: Ptr PublicKey -- public key
+        -> Ptr SecretKey -- secret key
+        -> IO ()
 
 foreign import ccall "crypton_decaf_ed448_sign"
-    decaf_ed448_sign :: Ptr Signature -- signature
-                     -> Ptr SecretKey -- secret
-                     -> Ptr PublicKey -- public
-                     -> Ptr Word8     -- message
-                     -> CSize         -- message len
-                     -> Word8         -- prehashed
-                     -> Ptr Word8     -- context
-                     -> Word8         -- context len
-                     -> IO ()
+    decaf_ed448_sign
+        :: Ptr Signature -- signature
+        -> Ptr SecretKey -- secret
+        -> Ptr PublicKey -- public
+        -> Ptr Word8 -- message
+        -> CSize -- message len
+        -> Word8 -- prehashed
+        -> Ptr Word8 -- context
+        -> Word8 -- context len
+        -> IO ()
 
 foreign import ccall "crypton_decaf_ed448_verify"
-    decaf_ed448_verify :: Ptr Signature -- signature
-                       -> Ptr PublicKey -- public
-                       -> Ptr Word8     -- message
-                       -> CSize         -- message len
-                       -> Word8         -- prehashed
-                       -> Ptr Word8     -- context
-                       -> Word8         -- context len
-                       -> IO CInt
+    decaf_ed448_verify
+        :: Ptr Signature -- signature
+        -> Ptr PublicKey -- public
+        -> Ptr Word8 -- message
+        -> CSize -- message len
+        -> Word8 -- prehashed
+        -> Ptr Word8 -- context
+        -> Word8 -- context len
+        -> IO CInt
diff --git a/Crypto/PubKey/EdDSA.hs b/Crypto/PubKey/EdDSA.hs
--- a/Crypto/PubKey/EdDSA.hs
+++ b/Crypto/PubKey/EdDSA.hs
@@ -1,3 +1,12 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeOperators #-}
+
 -- |
 -- Module      : Crypto.PubKey.EdDSA
 -- License     : BSD-style
@@ -15,80 +24,82 @@
 -- This implementation is most useful when wanting to customize the hash
 -- algorithm.  See module "Crypto.PubKey.Ed25519" for faster Ed25519 with
 -- SHA-512.
---
-{-# LANGUAGE DataKinds                  #-}
-{-# LANGUAGE FlexibleContexts           #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE OverloadedStrings          #-}
-{-# LANGUAGE RankNTypes                 #-}
-{-# LANGUAGE ScopedTypeVariables        #-}
-{-# LANGUAGE TypeFamilies               #-}
-module Crypto.PubKey.EdDSA
-    ( SecretKey
-    , PublicKey
-    , Signature
+module Crypto.PubKey.EdDSA (
+    SecretKey,
+    PublicKey,
+    Signature,
+
     -- * Curves with EdDSA implementation
-    , EllipticCurveEdDSA(CurveDigestSize)
-    , publicKeySize
-    , secretKeySize
-    , signatureSize
+    EllipticCurveEdDSA (CurveDigestSize),
+    publicKeySize,
+    secretKeySize,
+    signatureSize,
+
     -- * Smart constructors
-    , signature
-    , publicKey
-    , secretKey
+    signature,
+    publicKey,
+    secretKey,
+
     -- * Methods
-    , toPublic
-    , sign
-    , signCtx
-    , signPh
-    , verify
-    , verifyCtx
-    , verifyPh
-    , generateSecretKey
-    ) where
+    toPublic,
+    sign,
+    signCtx,
+    signPh,
+    verify,
+    verifyCtx,
+    verifyPh,
+    generateSecretKey,
+) where
 
-import           Data.Bits
-import           Data.ByteArray (ByteArray, ByteArrayAccess, Bytes, ScrubbedBytes, View)
+import Data.Bits
+import Data.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    Bytes,
+    ScrubbedBytes,
+    View,
+ )
 import qualified Data.ByteArray as B
-import           Data.ByteString (ByteString)
-import           Data.Proxy
+import Data.ByteString (ByteString)
+import Data.Proxy
 
-import           Crypto.ECC
+import Crypto.ECC
 import qualified Crypto.ECC.Edwards25519 as Edwards25519
-import           Crypto.Error
-import           Crypto.Hash (Digest)
-import           Crypto.Hash.IO
-import           Crypto.Random
-
-import           GHC.TypeLits (KnownNat, Nat)
+import Crypto.Error
+import Crypto.Hash (Digest)
+import Crypto.Hash.IO
+import Crypto.Random
 
-import           Crypto.Internal.Builder
-import           Crypto.Internal.Compat
-import           Crypto.Internal.Imports
-import           Crypto.Internal.Nat (integralNatVal)
+import GHC.TypeLits (KnownNat, Nat)
 
-import           Foreign.Storable
+import Crypto.Internal.Builder
+import Crypto.Internal.Compat
+import Crypto.Internal.Imports
+import Crypto.Internal.Nat (integralNatVal)
 
+import Foreign.Storable
 
 -- API
 
 -- | An EdDSA Secret key
 newtype SecretKey curve = SecretKey ScrubbedBytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | An EdDSA public key
 newtype PublicKey curve hash = PublicKey Bytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | An EdDSA signature
 newtype Signature curve hash = Signature Bytes
-    deriving (Show,Eq,ByteArrayAccess,NFData)
+    deriving (Show, Eq, ByteArrayAccess, NFData)
 
 -- | Elliptic curves with an implementation of EdDSA
-class ( EllipticCurveBasepointArith curve
-      , KnownNat (CurveDigestSize curve)
-      ) => EllipticCurveEdDSA curve where
-
+class
+    ( EllipticCurveBasepointArith curve
+    , KnownNat (CurveDigestSize curve)
+    ) =>
+    EllipticCurveEdDSA curve
+    where
     -- | Size of the digest for this curve (in bytes)
     type CurveDigestSize curve :: Nat
 
@@ -96,43 +107,49 @@
     secretKeySize :: proxy curve -> Int
 
     -- hash with specified parameters
-    hashWithDom :: (HashAlgorithm hash, ByteArrayAccess ctx, ByteArrayAccess msg)
-                => proxy curve -> hash -> Bool -> ctx -> Builder -> msg -> Bytes
+    hashWithDom
+        :: (HashAlgorithm hash, ByteArrayAccess ctx, ByteArrayAccess msg)
+        => proxy curve -> hash -> Bool -> ctx -> Builder -> msg -> Bytes
 
     -- conversion between scalar, point and public key
     pointPublic :: proxy curve -> Point curve -> PublicKey curve hash
-    publicPoint :: proxy curve -> PublicKey curve hash -> CryptoFailable (Point curve)
+    publicPoint
+        :: proxy curve -> PublicKey curve hash -> CryptoFailable (Point curve)
     encodeScalarLE :: ByteArray bs => proxy curve -> Scalar curve -> bs
-    decodeScalarLE :: ByteArrayAccess bs => proxy curve -> bs -> CryptoFailable (Scalar curve)
+    decodeScalarLE
+        :: ByteArrayAccess bs => proxy curve -> bs -> CryptoFailable (Scalar curve)
 
     -- how to use bits in a secret key
-    scheduleSecret :: ( HashAlgorithm hash
-                      , HashDigestSize hash ~ CurveDigestSize curve
-                      )
-                   => proxy curve
-                   -> hash
-                   -> SecretKey curve
-                   -> (Scalar curve, View Bytes)
+    scheduleSecret
+        :: ( HashAlgorithm hash
+           , HashDigestSize hash ~ CurveDigestSize curve
+           )
+        => proxy curve
+        -> hash
+        -> SecretKey curve
+        -> (Scalar curve, View Bytes)
 
 -- | Size of public keys for this curve (in bytes)
 publicKeySize :: EllipticCurveEdDSA curve => proxy curve -> Int
 publicKeySize prx = signatureSize prx `div` 2
 
 -- | Size of signatures for this curve (in bytes)
-signatureSize :: forall proxy curve . EllipticCurveEdDSA curve
-              => proxy curve -> Int
+signatureSize
+    :: forall proxy curve
+     . EllipticCurveEdDSA curve
+    => proxy curve -> Int
 signatureSize _ = integralNatVal (Proxy :: Proxy (CurveDigestSize curve))
 
-
 -- Constructors
 
 -- | Try to build a public key from a bytearray
-publicKey :: ( EllipticCurveEdDSA curve
-             , HashAlgorithm hash
-             , HashDigestSize hash ~ CurveDigestSize curve
-             , ByteArrayAccess ba
-             )
-          => proxy curve -> hash -> ba -> CryptoFailable (PublicKey curve hash)
+publicKey
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess ba
+       )
+    => proxy curve -> hash -> ba -> CryptoFailable (PublicKey curve hash)
 publicKey prx _ bs
     | B.length bs == publicKeySize prx =
         CryptoPassed (PublicKey $ B.convert bs)
@@ -140,181 +157,239 @@
         CryptoFailed CryptoError_PublicKeySizeInvalid
 
 -- | Try to build a secret key from a bytearray
-secretKey :: (EllipticCurveEdDSA curve, ByteArrayAccess ba)
-          => proxy curve -> ba -> CryptoFailable (SecretKey curve)
+secretKey
+    :: (EllipticCurveEdDSA curve, ByteArrayAccess ba)
+    => proxy curve -> ba -> CryptoFailable (SecretKey curve)
 secretKey prx bs
     | B.length bs == secretKeySize prx =
         CryptoPassed (SecretKey $ B.convert bs)
-    | otherwise                        =
+    | otherwise =
         CryptoFailed CryptoError_SecretKeyStructureInvalid
 
 -- | Try to build a signature from a bytearray
-signature :: ( EllipticCurveEdDSA curve
-             , HashAlgorithm hash
-             , HashDigestSize hash ~ CurveDigestSize curve
-             , ByteArrayAccess ba
-             )
-          => proxy curve -> hash -> ba -> CryptoFailable (Signature curve hash)
+signature
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess ba
+       )
+    => proxy curve -> hash -> ba -> CryptoFailable (Signature curve hash)
 signature prx _ bs
     | B.length bs == signatureSize prx =
         CryptoPassed (Signature $ B.convert bs)
     | otherwise =
         CryptoFailed CryptoError_SecretKeyStructureInvalid
 
-
 -- Conversions
 
 -- | Generate a secret key
-generateSecretKey :: (EllipticCurveEdDSA curve, MonadRandom m)
-                  => proxy curve -> m (SecretKey curve)
+generateSecretKey
+    :: (EllipticCurveEdDSA curve, MonadRandom m)
+    => proxy curve -> m (SecretKey curve)
 generateSecretKey prx = SecretKey <$> getRandomBytes (secretKeySize prx)
 
 -- | Create a public key from a secret key
-toPublic :: ( EllipticCurveEdDSA curve
-            , HashAlgorithm hash
-            , HashDigestSize hash ~ CurveDigestSize curve
-            )
-         => proxy curve -> hash -> SecretKey curve -> PublicKey curve hash
+toPublic
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       )
+    => proxy curve -> hash -> SecretKey curve -> PublicKey curve hash
 toPublic prx alg priv =
     let p = pointBaseSmul prx (secretScalar prx alg priv)
      in pointPublic prx p
 
-secretScalar :: ( EllipticCurveEdDSA curve
-                , HashAlgorithm hash
-                , HashDigestSize hash ~ CurveDigestSize curve
-                )
-             => proxy curve -> hash -> SecretKey curve -> Scalar curve
+secretScalar
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       )
+    => proxy curve -> hash -> SecretKey curve -> Scalar curve
 secretScalar prx alg priv = fst (scheduleSecret prx alg priv)
 
-
 -- EdDSA signature generation & verification
 
 -- | Sign a message using the key pair
-sign :: ( EllipticCurveEdDSA curve
-        , HashAlgorithm hash
-        , HashDigestSize hash ~ CurveDigestSize curve
-        , ByteArrayAccess msg
-        )
-     => proxy curve -> SecretKey curve -> PublicKey curve hash -> msg -> Signature curve hash
+sign
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess msg
+       )
+    => proxy curve
+    -> SecretKey curve
+    -> PublicKey curve hash
+    -> msg
+    -> Signature curve hash
 sign prx = signCtx prx emptyCtx
 
 -- | Verify a message
-verify :: ( EllipticCurveEdDSA curve
-          , HashAlgorithm hash
-          , HashDigestSize hash ~ CurveDigestSize curve
-          , ByteArrayAccess msg
-          )
-       => proxy curve -> PublicKey curve hash -> msg -> Signature curve hash -> Bool
+verify
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess msg
+       )
+    => proxy curve -> PublicKey curve hash -> msg -> Signature curve hash -> Bool
 verify prx = verifyCtx prx emptyCtx
 
 -- | Sign a message using the key pair under context @ctx@
-signCtx :: ( EllipticCurveEdDSA curve
-           , HashAlgorithm hash
-           , HashDigestSize hash ~ CurveDigestSize curve
-           , ByteArrayAccess ctx
-           , ByteArrayAccess msg
-           )
-        => proxy curve -> ctx -> SecretKey curve -> PublicKey curve hash -> msg -> Signature curve hash
+signCtx
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess ctx
+       , ByteArrayAccess msg
+       )
+    => proxy curve
+    -> ctx
+    -> SecretKey curve
+    -> PublicKey curve hash
+    -> msg
+    -> Signature curve hash
 signCtx prx = signPhCtx prx False
 
 -- | Verify a message under context @ctx@
-verifyCtx :: ( EllipticCurveEdDSA curve
-             , HashAlgorithm hash
-             , HashDigestSize hash ~ CurveDigestSize curve
-             , ByteArrayAccess ctx
-             , ByteArrayAccess msg
-             )
-          => proxy curve -> ctx -> PublicKey curve hash -> msg -> Signature curve hash -> Bool
+verifyCtx
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess ctx
+       , ByteArrayAccess msg
+       )
+    => proxy curve
+    -> ctx
+    -> PublicKey curve hash
+    -> msg
+    -> Signature curve hash
+    -> Bool
 verifyCtx prx = verifyPhCtx prx False
 
 -- | Sign a prehashed message using the key pair under context @ctx@
-signPh :: ( EllipticCurveEdDSA curve
-          , HashAlgorithm hash
-          , HashDigestSize hash ~ CurveDigestSize curve
-          , ByteArrayAccess ctx
-          )
-       => proxy curve -> ctx -> SecretKey curve -> PublicKey curve hash -> Digest prehash -> Signature curve hash
+signPh
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess ctx
+       )
+    => proxy curve
+    -> ctx
+    -> SecretKey curve
+    -> PublicKey curve hash
+    -> Digest prehash
+    -> Signature curve hash
 signPh prx = signPhCtx prx True
 
 -- | Verify a prehashed message under context @ctx@
-verifyPh :: ( EllipticCurveEdDSA curve
-            , HashAlgorithm hash
-            , HashDigestSize hash ~ CurveDigestSize curve
-            , ByteArrayAccess ctx
-            )
-         => proxy curve -> ctx -> PublicKey curve hash -> Digest prehash -> Signature curve hash -> Bool
+verifyPh
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess ctx
+       )
+    => proxy curve
+    -> ctx
+    -> PublicKey curve hash
+    -> Digest prehash
+    -> Signature curve hash
+    -> Bool
 verifyPh prx = verifyPhCtx prx True
 
-signPhCtx :: forall proxy curve hash ctx msg .
-             ( EllipticCurveEdDSA curve
-             , HashAlgorithm hash
-             , HashDigestSize hash ~ CurveDigestSize curve
-             , ByteArrayAccess ctx
-             , ByteArrayAccess msg
-             )
-          => proxy curve -> Bool -> ctx -> SecretKey curve -> PublicKey curve hash -> msg -> Signature curve hash
+signPhCtx
+    :: forall proxy curve hash ctx msg
+     . ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess ctx
+       , ByteArrayAccess msg
+       )
+    => proxy curve
+    -> Bool
+    -> ctx
+    -> SecretKey curve
+    -> PublicKey curve hash
+    -> msg
+    -> Signature curve hash
 signPhCtx prx ph ctx priv pub msg =
-    let alg  = undefined :: hash
+    let alg = undefined :: hash
         (s, prefix) = scheduleSecret prx alg priv
         digR = hashWithDom prx alg ph ctx (bytes prefix) msg
-        r    = decodeScalarNoErr prx digR
-        pR   = pointBaseSmul prx r
-        bsR  = encodePoint prx pR
-        sK   = getK prx ph ctx pub bsR msg
-        sS   = scalarAdd prx r (scalarMul prx sK s)
+        r = decodeScalarNoErr prx digR
+        pR = pointBaseSmul prx r
+        bsR = encodePoint prx pR
+        sK = getK prx ph ctx pub bsR msg
+        sS = scalarAdd prx r (scalarMul prx sK s)
      in encodeSignature prx (bsR, pR, sS)
 
-verifyPhCtx :: ( EllipticCurveEdDSA curve
-               , HashAlgorithm hash
-               , HashDigestSize hash ~ CurveDigestSize curve
-               , ByteArrayAccess ctx
-               , ByteArrayAccess msg
-               )
-            => proxy curve -> Bool -> ctx -> PublicKey curve hash -> msg -> Signature curve hash -> Bool
+verifyPhCtx
+    :: ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess ctx
+       , ByteArrayAccess msg
+       )
+    => proxy curve
+    -> Bool
+    -> ctx
+    -> PublicKey curve hash
+    -> msg
+    -> Signature curve hash
+    -> Bool
 verifyPhCtx prx ph ctx pub msg sig =
     case doVerify of
         CryptoPassed verified -> verified
-        CryptoFailed _        -> False
+        CryptoFailed _ -> False
   where
     doVerify = do
         (bsR, pR, sS) <- decodeSignature prx sig
         nPub <- pointNegate prx `fmap` publicPoint prx pub
-        let sK  = getK prx ph ctx pub bsR msg
+        let sK = getK prx ph ctx pub bsR msg
             pR' = pointsSmulVarTime prx sS sK nPub
         return (pR == pR')
 
 emptyCtx :: Bytes
 emptyCtx = B.empty
 
-getK :: forall proxy curve hash ctx msg .
-        ( EllipticCurveEdDSA curve
-        , HashAlgorithm hash
-        , HashDigestSize hash ~ CurveDigestSize curve
-        , ByteArrayAccess ctx
-        , ByteArrayAccess msg
-        )
-     => proxy curve -> Bool -> ctx -> PublicKey curve hash -> Bytes -> msg -> Scalar curve
+getK
+    :: forall proxy curve hash ctx msg
+     . ( EllipticCurveEdDSA curve
+       , HashAlgorithm hash
+       , HashDigestSize hash ~ CurveDigestSize curve
+       , ByteArrayAccess ctx
+       , ByteArrayAccess msg
+       )
+    => proxy curve
+    -> Bool
+    -> ctx
+    -> PublicKey curve hash
+    -> Bytes
+    -> msg
+    -> Scalar curve
 getK prx ph ctx (PublicKey pub) bsR msg =
-    let alg  = undefined :: hash
+    let alg = undefined :: hash
         digK = hashWithDom prx alg ph ctx (bytes bsR <> bytes pub) msg
      in decodeScalarNoErr prx digK
 
-encodeSignature :: EllipticCurveEdDSA curve
-                => proxy curve
-                -> (Bytes, Point curve, Scalar curve)
-                -> Signature curve hash
-encodeSignature prx (bsR, _, sS) = Signature $ buildAndFreeze $
-    bytes bsR <> bytes bsS <> zero len0
+encodeSignature
+    :: EllipticCurveEdDSA curve
+    => proxy curve
+    -> (Bytes, Point curve, Scalar curve)
+    -> Signature curve hash
+encodeSignature prx (bsR, _, sS) =
+    Signature $
+        buildAndFreeze $
+            bytes bsR <> bytes bsS <> zero len0
   where
-    bsS  = encodeScalarLE prx sS :: Bytes
+    bsS = encodeScalarLE prx sS :: Bytes
     len0 = signatureSize prx - B.length bsR - B.length bsS
 
-decodeSignature :: ( EllipticCurveEdDSA curve
-                   , HashDigestSize hash ~ CurveDigestSize curve
-                   )
-                => proxy curve
-                -> Signature curve hash
-                -> CryptoFailable (Bytes, Point curve, Scalar curve)
+decodeSignature
+    :: ( EllipticCurveEdDSA curve
+       , HashDigestSize hash ~ CurveDigestSize curve
+       )
+    => proxy curve
+    -> Signature curve hash
+    -> CryptoFailable (Bytes, Point curve, Scalar curve)
 decodeSignature prx (Signature bs) = do
     let (bsR, bsS) = B.splitAt (publicKeySize prx) bs
     pR <- decodePoint prx bsR
@@ -322,14 +397,14 @@
     return (bsR, pR, sS)
 
 -- implementations are supposed to decode any scalar up to the size of the digest
-decodeScalarNoErr :: (EllipticCurveEdDSA curve, ByteArrayAccess bs)
-                  => proxy curve -> bs -> Scalar curve
+decodeScalarNoErr
+    :: (EllipticCurveEdDSA curve, ByteArrayAccess bs)
+    => proxy curve -> bs -> Scalar curve
 decodeScalarNoErr prx = unwrap "decodeScalarNoErr" . decodeScalarLE prx
 
 unwrap :: String -> CryptoFailable a -> a
 unwrap name (CryptoFailed _) = error (name ++ ": assumption failed")
-unwrap _    (CryptoPassed x) = x
-
+unwrap _ (CryptoPassed x) = x
 
 -- Ed25519 implementation
 
@@ -339,11 +414,13 @@
 
     hashWithDom _ alg ph ctx bss
         | not ph && B.null ctx = digestDomMsg alg bss
-        | otherwise            = digestDomMsg alg (dom <> bss)
-      where dom = bytes ("SigEd25519 no Ed25519 collisions" :: ByteString) <>
-                  byte (if ph then 1 else 0) <>
-                  byte (fromIntegral $ B.length ctx) <>
-                  bytes ctx
+        | otherwise = digestDomMsg alg (dom <> bss)
+      where
+        dom =
+            bytes ("SigEd25519 no Ed25519 collisions" :: ByteString)
+                <> byte (if ph then 1 else 0)
+                <> byte (fromIntegral $ B.length ctx)
+                <> bytes ctx
 
     pointPublic _ = PublicKey . Edwards25519.pointEncode
     publicPoint _ = Edwards25519.pointDecode
@@ -353,15 +430,14 @@
     scheduleSecret prx alg priv =
         (decodeScalarNoErr prx clamped, B.dropView hashed 32)
       where
-        hashed  = digest alg $ \update -> update priv
+        hashed = digest alg $ \update -> update priv
 
         clamped :: Bytes
         clamped = B.copyAndFreeze (B.takeView hashed 32) $ \p -> do
-                      b0  <- peekElemOff p 0  :: IO Word8
-                      b31 <- peekElemOff p 31 :: IO Word8
-                      pokeElemOff p 31 ((b31 .&. 0x7F) .|. 0x40)
-                      pokeElemOff p 0  (b0 .&. 0xF8)
-
+            b0 <- peekElemOff p 0 :: IO Word8
+            b31 <- peekElemOff p 31 :: IO Word8
+            pokeElemOff p 31 ((b31 .&. 0x7F) .|. 0x40)
+            pokeElemOff p 0 (b0 .&. 0xF8)
 
 {-
   Optimize hashing by limiting the number of roundtrips between Haskell and C.
@@ -375,15 +451,17 @@
   pinned trampoline.
 -}
 
-digestDomMsg :: (HashAlgorithm alg, ByteArrayAccess msg)
-             => alg -> Builder -> msg -> Bytes
+digestDomMsg
+    :: (HashAlgorithm alg, ByteArrayAccess msg)
+    => alg -> Builder -> msg -> Bytes
 digestDomMsg alg bss bs = digest alg $ \update ->
     update (buildAndFreeze bss :: Bytes) >> update bs
 
-digest :: HashAlgorithm alg
-       => alg
-       -> ((forall bs . ByteArrayAccess bs => bs -> IO ()) -> IO ())
-       -> Bytes
+digest
+    :: HashAlgorithm alg
+    => alg
+    -> ((forall bs. ByteArrayAccess bs => bs -> IO ()) -> IO ())
+    -> Bytes
 digest alg fn = B.convert $ unsafeDoIO $ do
     mc <- hashMutableInitWith alg
     fn (hashMutableUpdate mc)
diff --git a/Crypto/PubKey/ElGamal.hs b/Crypto/PubKey/ElGamal.hs
--- a/Crypto/PubKey/ElGamal.hs
+++ b/Crypto/PubKey/ElGamal.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.PubKey.ElGamal
 -- License     : BSD-style
@@ -10,39 +12,46 @@
 --
 -- TODO: provide a mapping between integer and ciphertext
 --       generate numbers correctly
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.PubKey.ElGamal
-    ( Params
-    , PublicNumber
-    , PrivateNumber
-    , EphemeralKey(..)
-    , SharedKey
-    , Signature
+module Crypto.PubKey.ElGamal (
+    Params,
+    PublicNumber,
+    PrivateNumber,
+    EphemeralKey (..),
+    SharedKey,
+    Signature,
+
     -- * Generation
-    , generatePrivate
-    , generatePublic
+    generatePrivate,
+    generatePublic,
+
     -- * Encryption and decryption with no scheme
-    , encryptWith
-    , encrypt
-    , decrypt
+    encryptWith,
+    encrypt,
+    decrypt,
+
     -- * Signature primitives
-    , signWith
-    , sign
+    signWith,
+    sign,
+
     -- * Verification primitives
-    , verify
-    ) where
+    verify,
+) where
 
-import Data.Maybe (fromJust)
-import Crypto.Internal.Imports
+import Crypto.Hash
 import Crypto.Internal.ByteArray (ByteArrayAccess)
-import Crypto.Number.ModArithmetic (expSafe, expFast, inverse)
+import Crypto.Internal.Imports
+import Crypto.Number.Basic (gcde)
 import Crypto.Number.Generate (generateMax)
+import Crypto.Number.ModArithmetic (expFast, expSafe, inverse)
 import Crypto.Number.Serialize (os2ip)
-import Crypto.Number.Basic (gcde)
+import Crypto.PubKey.DH (
+    Params (..),
+    PrivateNumber (..),
+    PublicNumber (..),
+    SharedKey (..),
+ )
 import Crypto.Random.Types
-import Crypto.PubKey.DH (PrivateNumber(..), PublicNumber(..), Params(..), SharedKey(..))
-import Crypto.Hash
+import Data.Maybe (fromJust)
 
 -- | ElGamal Signature
 data Signature = Signature (Integer, Integer)
@@ -54,16 +63,15 @@
 -- | generate a private number with no specific property
 -- this number is usually called a and need to be between
 -- 0 and q (order of the group G).
---
 generatePrivate :: MonadRandom m => Integer -> m PrivateNumber
 generatePrivate q = PrivateNumber <$> generateMax q
 
 -- | generate an ephemeral key which is a number with no specific property,
 -- and need to be between 0 and q (order of the group G).
---
 generateEphemeral :: MonadRandom m => Integer -> m EphemeralKey
 generateEphemeral q = toEphemeral <$> generatePrivate q
-    where toEphemeral (PrivateNumber n) = EphemeralKey n
+  where
+    toEphemeral (PrivateNumber n) = EphemeralKey n
 
 -- | generate a public number that is for the other party benefits.
 -- this number is usually called h=g^a
@@ -72,23 +80,28 @@
 
 -- | encrypt with a specified ephemeral key
 -- do not reuse ephemeral key.
-encryptWith :: EphemeralKey -> Params -> PublicNumber -> Integer -> (Integer,Integer)
-encryptWith (EphemeralKey b) (Params p g _) (PublicNumber h) m = (c1,c2)
-    where s  = expSafe h b p
-          c1 = expSafe g b p
-          c2 = (s * m) `mod` p
+encryptWith
+    :: EphemeralKey -> Params -> PublicNumber -> Integer -> (Integer, Integer)
+encryptWith (EphemeralKey b) (Params p g _) (PublicNumber h) m = (c1, c2)
+  where
+    s = expSafe h b p
+    c1 = expSafe g b p
+    c2 = (s * m) `mod` p
 
 -- | encrypt a message using params and public keys
 -- will generate b (called the ephemeral key)
-encrypt :: MonadRandom m => Params -> PublicNumber -> Integer -> m (Integer,Integer)
+encrypt
+    :: MonadRandom m => Params -> PublicNumber -> Integer -> m (Integer, Integer)
 encrypt params@(Params p _ _) public m = (\b -> encryptWith b params public m) <$> generateEphemeral q
-    where q = p-1 -- p is prime, hence order of the group is p-1
+  where
+    q = p - 1 -- p is prime, hence order of the group is p-1
 
 -- | decrypt message
 decrypt :: Params -> PrivateNumber -> (Integer, Integer) -> Integer
-decrypt (Params p _ _) (PrivateNumber a) (c1,c2) = (c2 * sm1) `mod` p
-    where s   = expSafe c1 a p
-          sm1 = fromJust $ inverse s p -- always inversible in Zp
+decrypt (Params p _ _) (PrivateNumber a) (c1, c2) = (c2 * sm1) `mod` p
+  where
+    s = expSafe c1 a p
+    sm1 = fromJust $ inverse s p -- always inversible in Zp
 
 -- | sign a message with an explicit k number
 --
@@ -97,51 +110,64 @@
 -- with some appropriate value of k, the signature generation can fail,
 -- and no signature is returned. User of this function need to retry
 -- with a different k value.
-signWith :: (ByteArrayAccess msg, HashAlgorithm hash)
-         => Integer         -- ^ random number k, between 0 and p-1 and gcd(k,p-1)=1
-         -> Params          -- ^ DH params (p,g)
-         -> PrivateNumber   -- ^ DH private key
-         -> hash            -- ^ collision resistant hash algorithm
-         -> msg             -- ^ message to sign
-         -> Maybe Signature
+signWith
+    :: (ByteArrayAccess msg, HashAlgorithm hash)
+    => Integer
+    -- ^ random number k, between 0 and p-1 and gcd(k,p-1)=1
+    -> Params
+    -- ^ DH params (p,g)
+    -> PrivateNumber
+    -- ^ DH private key
+    -> hash
+    -- ^ collision resistant hash algorithm
+    -> msg
+    -- ^ message to sign
+    -> Maybe Signature
 signWith k (Params p g _) (PrivateNumber x) hashAlg msg
-    | k >= p-1 || d > 1 = Nothing -- gcd(k,p-1) is not 1
-    | s == 0            = Nothing
-    | otherwise         = Just $ Signature (r,s)
-    where r          = expSafe g k p
-          h          = os2ip $ hashWith hashAlg msg
-          s          = ((h - x*r) * kInv) `mod` (p-1)
-          (kInv,_,d) = gcde k (p-1)
+    | k >= p - 1 || d > 1 = Nothing -- gcd(k,p-1) is not 1
+    | s == 0 = Nothing
+    | otherwise = Just $ Signature (r, s)
+  where
+    r = expSafe g k p
+    h = os2ip $ hashWith hashAlg msg
+    s = ((h - x * r) * kInv) `mod` (p - 1)
+    (kInv, _, d) = gcde k (p - 1)
 
 -- | sign message
 --
 -- This function will generate a random number, however
 -- as the signature might fail, the function will automatically retry
 -- until a proper signature has been created.
---
-sign :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m)
-     => Params         -- ^ DH params (p,g)
-     -> PrivateNumber  -- ^ DH private key
-     -> hash           -- ^ collision resistant hash algorithm
-     -> msg            -- ^ message to sign
-     -> m Signature
+sign
+    :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m)
+    => Params
+    -- ^ DH params (p,g)
+    -> PrivateNumber
+    -- ^ DH private key
+    -> hash
+    -- ^ collision resistant hash algorithm
+    -> msg
+    -- ^ message to sign
+    -> m Signature
 sign params@(Params p _ _) priv hashAlg msg = do
-    k <- generateMax (p-1)
+    k <- generateMax (p - 1)
     case signWith k params priv hashAlg msg of
-        Nothing  -> sign params priv hashAlg msg
+        Nothing -> sign params priv hashAlg msg
         Just sig -> return sig
 
 -- | verify a signature
-verify :: (ByteArrayAccess msg, HashAlgorithm hash)
-       => Params
-       -> PublicNumber
-       -> hash
-       -> msg
-       -> Signature
-       -> Bool
-verify (Params p g _) (PublicNumber y) hashAlg msg (Signature (r,s))
-    | or [r <= 0,r >= p,s <= 0,s >= (p-1)] = False
-    | otherwise                            = lhs == rhs
-    where h   = os2ip $ hashWith hashAlg msg
-          lhs = expFast g h p
-          rhs = (expFast y r p * expFast r s p) `mod` p
+verify
+    :: (ByteArrayAccess msg, HashAlgorithm hash)
+    => Params
+    -> PublicNumber
+    -> hash
+    -> msg
+    -> Signature
+    -> Bool
+verify (Params p g _) (PublicNumber y) hashAlg msg (Signature (r, s))
+    | or [r <= 0, r >= p, s <= 0, s >= (p - 1)] = False
+    | otherwise = lhs == rhs
+  where
+    h = os2ip $ hashWith hashAlg msg
+    lhs = expFast g h p
+    rhs = (expFast y r p * expFast r s p) `mod` p
diff --git a/Crypto/PubKey/Internal.hs b/Crypto/PubKey/Internal.hs
--- a/Crypto/PubKey/Internal.hs
+++ b/Crypto/PubKey/Internal.hs
@@ -4,16 +4,16 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.PubKey.Internal
-    ( and'
-    , (&&!)
-    , dsaTruncHash
-    , dsaTruncHashDigest
-    ) where
+module Crypto.PubKey.Internal (
+    and',
+    (&&!),
+    dsaTruncHash,
+    dsaTruncHashDigest,
+) where
 
 import Data.Bits (shiftR)
 import Data.List (foldl')
+import Prelude hiding (foldl')
 
 import Crypto.Hash
 import Crypto.Internal.ByteArray (ByteArrayAccess)
@@ -26,13 +26,14 @@
 
 -- | This is a strict version of &&.
 (&&!) :: Bool -> Bool -> Bool
-True  &&! True  = True
-True  &&! False = False
-False &&! True  = False
+True &&! True = True
+True &&! False = False
+False &&! True = False
 False &&! False = False
 
 -- | Truncate and hash for DSA and ECDSA.
-dsaTruncHash :: (ByteArrayAccess msg, HashAlgorithm hash) => hash -> msg -> Integer -> Integer
+dsaTruncHash
+    :: (ByteArrayAccess msg, HashAlgorithm hash) => hash -> msg -> Integer -> Integer
 dsaTruncHash hashAlg = dsaTruncHashDigest . hashWith hashAlg
 
 -- | Truncate a digest for DSA and ECDSA.
@@ -40,8 +41,9 @@
 dsaTruncHashDigest digest n
     | d > 0 = shiftR e d
     | otherwise = e
-  where e = os2ip digest
-        d = hashDigestSize (getHashAlg digest) * 8 - numBits n
+  where
+    e = os2ip digest
+    d = hashDigestSize (getHashAlg digest) * 8 - numBits n
 
 getHashAlg :: Digest hash -> hash
 getHashAlg _ = undefined
diff --git a/Crypto/PubKey/MaskGenFunction.hs b/Crypto/PubKey/MaskGenFunction.hs
--- a/Crypto/PubKey/MaskGenFunction.hs
+++ b/Crypto/PubKey/MaskGenFunction.hs
@@ -1,40 +1,45 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.PubKey.MaskGenFunction
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-{-# LANGUAGE BangPatterns #-}
-module Crypto.PubKey.MaskGenFunction
-    ( MaskGenAlgorithm
-    , mgf1
-    ) where
+module Crypto.PubKey.MaskGenFunction (
+    MaskGenAlgorithm,
+    mgf1,
+) where
 
-import           Crypto.Number.Serialize (i2ospOf_)
-import           Crypto.Hash
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray, Bytes)
+import Crypto.Hash
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, Bytes)
 import qualified Crypto.Internal.ByteArray as B
+import Crypto.Number.Serialize (i2ospOf_)
 
 -- | Represent a mask generation algorithm
 type MaskGenAlgorithm seed output =
-       seed   -- ^ seed
-    -> Int    -- ^ length to generate
+    seed
+    -- ^ seed
+    -> Int
+    -- ^ length to generate
     -> output
 
 -- | Mask generation algorithm MGF1
-mgf1 :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hashAlg)
-     => hashAlg
-     -> seed
-     -> Int
-     -> output
+mgf1
+    :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hashAlg)
+    => hashAlg
+    -> seed
+    -> Int
+    -> output
 mgf1 hashAlg seed len =
     let !seededCtx = hashUpdate (hashInitWith hashAlg) seed
-     in B.take len $ B.concat $ map (hashCounter seededCtx) [0..fromIntegral (maxCounter-1)]
+     in B.take len $
+            B.concat $
+                map (hashCounter seededCtx) [0 .. fromIntegral (maxCounter - 1)]
   where
-    digestLen     = hashDigestSize hashAlg
-    (chunks,left) = len `divMod` digestLen
-    maxCounter    = if left > 0 then chunks + 1 else chunks
+    digestLen = hashDigestSize hashAlg
+    (chunks, left) = len `divMod` digestLen
+    maxCounter = if left > 0 then chunks + 1 else chunks
 
     hashCounter :: HashAlgorithm a => Context a -> Integer -> Digest a
     hashCounter ctx counter = hashFinalize $ hashUpdate ctx (i2ospOf_ 4 counter :: Bytes)
diff --git a/Crypto/PubKey/RSA.hs b/Crypto/PubKey/RSA.hs
--- a/Crypto/PubKey/RSA.hs
+++ b/Crypto/PubKey/RSA.hs
@@ -4,23 +4,23 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.PubKey.RSA
-    ( Error(..)
-    , PublicKey(..)
-    , PrivateKey(..)
-    , Blinder(..)
+module Crypto.PubKey.RSA (
+    Error (..),
+    PublicKey (..),
+    PrivateKey (..),
+    Blinder (..),
+
     -- * Generation function
-    , generateWith
-    , generate
-    , generateBlinder
-    ) where
+    generateWith,
+    generate,
+    generateBlinder,
+) where
 
-import Crypto.Random.Types
-import Crypto.Number.ModArithmetic (inverse, inverseCoprimes)
 import Crypto.Number.Generate (generateMax)
+import Crypto.Number.ModArithmetic (inverse, inverseCoprimes)
 import Crypto.Number.Prime (generatePrime)
 import Crypto.PubKey.RSA.Types
+import Crypto.Random.Types
 
 {-
 -- some bad implementation will not serialize ASN.1 integer properly, leading
@@ -51,40 +51,52 @@
 -- * e=0x10001 is a popular choice
 --
 -- * e=3 is popular as well, but proven to not be as secure for some cases.
---
-generateWith :: (Integer, Integer) -- ^ chosen distinct primes p and q
-             -> Int                -- ^ size in bytes
-             -> Integer            -- ^ RSA public exponent 'e'
-             -> Maybe (PublicKey, PrivateKey)
-generateWith (p,q) size e =
+generateWith
+    :: (Integer, Integer)
+    -- ^ chosen distinct primes p and q
+    -> Int
+    -- ^ size in bytes
+    -> Integer
+    -- ^ RSA public exponent 'e'
+    -> Maybe (PublicKey, PrivateKey)
+generateWith (p, q) size e =
     case inverse e phi of
         Nothing -> Nothing
-        Just d  -> Just (pub,priv d)
-  where n   = p*q
-        phi = (p-1)*(q-1)
-        -- q and p should be *distinct* *prime* numbers, hence always coprime
-        qinv = inverseCoprimes q p
-        pub = PublicKey { public_size = size
-                        , public_n    = n
-                        , public_e    = e
-                        }
-        priv d = PrivateKey { private_pub  = pub
-                            , private_d    = d
-                            , private_p    = p
-                            , private_q    = q
-                            , private_dP   = d `mod` (p-1)
-                            , private_dQ   = d `mod` (q-1)
-                            , private_qinv = qinv
-                            }
+        Just d -> Just (pub, priv d)
+  where
+    n = p * q
+    phi = (p - 1) * (q - 1)
+    -- q and p should be *distinct* *prime* numbers, hence always coprime
+    qinv = inverseCoprimes q p
+    pub =
+        PublicKey
+            { public_size = size
+            , public_n = n
+            , public_e = e
+            }
+    priv d =
+        PrivateKey
+            { private_pub = pub
+            , private_d = d
+            , private_p = p
+            , private_q = q
+            , private_dP = d `mod` (p - 1)
+            , private_dQ = d `mod` (q - 1)
+            , private_qinv = qinv
+            }
 
 -- | generate a pair of (private, public) key of size in bytes.
-generate :: MonadRandom m
-         => Int     -- ^ size in bytes
-         -> Integer -- ^ RSA public exponent 'e'
-         -> m (PublicKey, PrivateKey)
+generate
+    :: MonadRandom m
+    => Int
+    -- ^ size in bytes
+    -> Integer
+    -- ^ RSA public exponent 'e'
+    -> m (PublicKey, PrivateKey)
 generate size e = loop
   where
-    loop = do -- loop until we find a valid key pair given e
+    loop = do
+        -- loop until we find a valid key pair given e
         pq <- generatePQ
         case generateWith pq size e of
             Nothing -> loop
@@ -92,7 +104,7 @@
     generatePQ = do
         p <- generatePrime (8 * (size `div` 2))
         q <- generateQ p
-        return (p,q)
+        return (p, q)
     generateQ p = do
         q <- generatePrime (8 * (size - (size `div` 2)))
         if p == q then generateQ p else return q
@@ -101,8 +113,10 @@
 --
 -- the unique parameter apart from the random number generator is the
 -- public key value N.
-generateBlinder :: MonadRandom m
-                => Integer -- ^ RSA public N parameter.
-                -> m Blinder
+generateBlinder
+    :: MonadRandom m
+    => Integer
+    -- ^ RSA public N parameter.
+    -> m Blinder
 generateBlinder n =
     (\r -> Blinder r (inverseCoprimes r n)) <$> generateMax n
diff --git a/Crypto/PubKey/RSA/OAEP.hs b/Crypto/PubKey/RSA/OAEP.hs
--- a/Crypto/PubKey/RSA/OAEP.hs
+++ b/Crypto/PubKey/RSA/OAEP.hs
@@ -7,121 +7,143 @@
 --
 -- RSA OAEP mode
 -- <http://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding>
---
-module Crypto.PubKey.RSA.OAEP
-    (
-      OAEPParams(..)
-    , defaultOAEPParams
+module Crypto.PubKey.RSA.OAEP (
+    OAEPParams (..),
+    defaultOAEPParams,
+
     -- * OAEP encryption
-    , encryptWithSeed
-    , encrypt
+    encryptWithSeed,
+    encrypt,
+
     -- * OAEP decryption
-    , decrypt
-    , decryptSafer
-    ) where
+    decrypt,
+    decryptSafer,
+) where
 
-import           Crypto.Hash
-import           Crypto.Random.Types
-import           Crypto.PubKey.RSA.Types
-import           Crypto.PubKey.MaskGenFunction
-import           Crypto.PubKey.RSA.Prim
-import           Crypto.PubKey.RSA (generateBlinder)
-import           Crypto.PubKey.Internal (and')
-import           Data.ByteString (ByteString)
+import Crypto.Hash
+import Crypto.PubKey.Internal (and')
+import Crypto.PubKey.MaskGenFunction
+import Crypto.PubKey.RSA (generateBlinder)
+import Crypto.PubKey.RSA.Prim
+import Crypto.PubKey.RSA.Types
+import Crypto.Random.Types
+import Data.Bits (xor)
+import Data.ByteString (ByteString)
 import qualified Data.ByteString as B
-import           Data.Bits (xor)
 
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray)
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B (convert)
 
 -- | Parameters for OAEP encryption/decryption
 data OAEPParams hash seed output = OAEPParams
-    { oaepHash       :: hash                         -- ^ Hash function to use.
-    , oaepMaskGenAlg :: MaskGenAlgorithm seed output -- ^ Mask Gen algorithm to use.
-    , oaepLabel      :: Maybe ByteString             -- ^ Optional label prepended to message.
+    { oaepHash :: hash
+    -- ^ Hash function to use.
+    , oaepMaskGenAlg :: MaskGenAlgorithm seed output
+    -- ^ Mask Gen algorithm to use.
+    , oaepLabel :: Maybe ByteString
+    -- ^ Optional label prepended to message.
     }
 
 -- | Default Params with a specified hash function
-defaultOAEPParams :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash)
-                  => hash
-                  -> OAEPParams hash seed output
+defaultOAEPParams
+    :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash)
+    => hash
+    -> OAEPParams hash seed output
 defaultOAEPParams hashAlg =
-    OAEPParams { oaepHash         = hashAlg
-               , oaepMaskGenAlg   = mgf1 hashAlg
-               , oaepLabel        = Nothing
-               }
+    OAEPParams
+        { oaepHash = hashAlg
+        , oaepMaskGenAlg = mgf1 hashAlg
+        , oaepLabel = Nothing
+        }
 
 -- | Encrypt a message using OAEP with a predefined seed.
-encryptWithSeed :: HashAlgorithm hash
-                => ByteString      -- ^ Seed
-                -> OAEPParams hash ByteString ByteString -- ^ OAEP params to use for encryption
-                -> PublicKey       -- ^ Public key.
-                -> ByteString      -- ^ Message to encrypt
-                -> Either Error ByteString
+encryptWithSeed
+    :: HashAlgorithm hash
+    => ByteString
+    -- ^ Seed
+    -> OAEPParams hash ByteString ByteString
+    -- ^ OAEP params to use for encryption
+    -> PublicKey
+    -- ^ Public key.
+    -> ByteString
+    -- ^ Message to encrypt
+    -> Either Error ByteString
 encryptWithSeed seed oaep pk msg
-    | k < 2*hashLen+2          = Left InvalidParameters
+    | k < 2 * hashLen + 2 = Left InvalidParameters
     | B.length seed /= hashLen = Left InvalidParameters
-    | mLen > k - 2*hashLen-2   = Left MessageTooLong
-    | otherwise                = Right $ ep pk em
-    where -- parameters
-          k          = public_size pk
-          mLen       = B.length msg
-          mgf        = oaepMaskGenAlg oaep
-          labelHash  = hashWith (oaepHash oaep) (maybe B.empty id $ oaepLabel oaep)
-          hashLen    = hashDigestSize (oaepHash oaep)
+    | mLen > k - 2 * hashLen - 2 = Left MessageTooLong
+    | otherwise = Right $ ep pk em
+  where
+    -- parameters
+    k = public_size pk
+    mLen = B.length msg
+    mgf = oaepMaskGenAlg oaep
+    labelHash = hashWith (oaepHash oaep) (maybe B.empty id $ oaepLabel oaep)
+    hashLen = hashDigestSize (oaepHash oaep)
 
-          -- put fields
-          ps         = B.replicate (k - mLen - 2*hashLen - 2) 0
-          db         = B.concat [B.convert labelHash, ps, B.singleton 0x1, msg]
-          dbmask     = mgf seed (k - hashLen - 1)
-          maskedDB   = B.pack $ B.zipWith xor db dbmask
-          seedMask   = mgf maskedDB hashLen
-          maskedSeed = B.pack $ B.zipWith xor seed seedMask
-          em         = B.concat [B.singleton 0x0,maskedSeed,maskedDB]
+    -- put fields
+    ps = B.replicate (k - mLen - 2 * hashLen - 2) 0
+    db = B.concat [B.convert labelHash, ps, B.singleton 0x1, msg]
+    dbmask = mgf seed (k - hashLen - 1)
+    maskedDB = B.pack $ B.zipWith xor db dbmask
+    seedMask = mgf maskedDB hashLen
+    maskedSeed = B.pack $ B.zipWith xor seed seedMask
+    em = B.concat [B.singleton 0x0, maskedSeed, maskedDB]
 
 -- | Encrypt a message using OAEP
-encrypt :: (HashAlgorithm hash, MonadRandom m)
-        => OAEPParams hash ByteString ByteString -- ^ OAEP params to use for encryption.
-        -> PublicKey       -- ^ Public key.
-        -> ByteString      -- ^ Message to encrypt
-        -> m (Either Error ByteString)
+encrypt
+    :: (HashAlgorithm hash, MonadRandom m)
+    => OAEPParams hash ByteString ByteString
+    -- ^ OAEP params to use for encryption.
+    -> PublicKey
+    -- ^ Public key.
+    -> ByteString
+    -- ^ Message to encrypt
+    -> m (Either Error ByteString)
 encrypt oaep pk msg = do
     seed <- getRandomBytes hashLen
     return (encryptWithSeed seed oaep pk msg)
   where
-    hashLen    = hashDigestSize (oaepHash oaep)
+    hashLen = hashDigestSize (oaepHash oaep)
 
 -- | un-pad a OAEP encoded message.
 --
 -- It doesn't apply the RSA decryption primitive
-unpad :: HashAlgorithm hash
-      => OAEPParams hash ByteString ByteString -- ^ OAEP params to use
-      -> Int             -- ^ size of the key in bytes
-      -> ByteString      -- ^ encoded message (not encrypted)
-      -> Either Error ByteString
+unpad
+    :: HashAlgorithm hash
+    => OAEPParams hash ByteString ByteString
+    -- ^ OAEP params to use
+    -> Int
+    -- ^ size of the key in bytes
+    -> ByteString
+    -- ^ encoded message (not encrypted)
+    -> Either Error ByteString
 unpad oaep k em
     | paddingSuccess = Right msg
-    | otherwise      = Left MessageNotRecognized
-    where -- parameters
-          mgf        = oaepMaskGenAlg oaep
-          labelHash  = B.convert $ hashWith (oaepHash oaep) (maybe B.empty id $ oaepLabel oaep)
-          hashLen    = hashDigestSize (oaepHash oaep)
-          -- getting em's fields
-          (pb, em0)  = B.splitAt 1 em
-          (maskedSeed,maskedDB) = B.splitAt hashLen em0
-          seedMask   = mgf maskedDB hashLen
-          seed       = B.pack $ B.zipWith xor maskedSeed seedMask
-          dbmask     = mgf seed (k - hashLen - 1)
-          db         = B.pack $ B.zipWith xor maskedDB dbmask
-          -- getting db's fields
-          (labelHash',db1) = B.splitAt hashLen db
-          (_,db2)    = B.break (/= 0) db1
-          (ps1,msg)  = B.splitAt 1 db2
+    | otherwise = Left MessageNotRecognized
+  where
+    -- parameters
+    mgf = oaepMaskGenAlg oaep
+    labelHash = B.convert $ hashWith (oaepHash oaep) (maybe B.empty id $ oaepLabel oaep)
+    hashLen = hashDigestSize (oaepHash oaep)
+    -- getting em's fields
+    (pb, em0) = B.splitAt 1 em
+    (maskedSeed, maskedDB) = B.splitAt hashLen em0
+    seedMask = mgf maskedDB hashLen
+    seed = B.pack $ B.zipWith xor maskedSeed seedMask
+    dbmask = mgf seed (k - hashLen - 1)
+    db = B.pack $ B.zipWith xor maskedDB dbmask
+    -- getting db's fields
+    (labelHash', db1) = B.splitAt hashLen db
+    (_, db2) = B.break (/= 0) db1
+    (ps1, msg) = B.splitAt 1 db2
 
-          paddingSuccess = and' [ labelHash' == labelHash -- no need for constant eq
-                                , ps1        == B.replicate 1 0x1
-                                , pb         == B.replicate 1 0x0
-                                ]
+    paddingSuccess =
+        and'
+            [ labelHash' == labelHash -- no need for constant eq
+            , ps1 == B.replicate 1 0x1
+            , pb == B.replicate 1 0x0
+            ]
 
 -- | Decrypt a ciphertext using OAEP
 --
@@ -129,26 +151,36 @@
 -- information from the timing of the operation, the blinder can be set to None.
 --
 -- If unsure always set a blinder or use decryptSafer
-decrypt :: HashAlgorithm hash
-        => Maybe Blinder   -- ^ Optional blinder
-        -> OAEPParams hash ByteString ByteString -- ^ OAEP params to use for decryption
-        -> PrivateKey      -- ^ Private key
-        -> ByteString      -- ^ Cipher text
-        -> Either Error ByteString
+decrypt
+    :: HashAlgorithm hash
+    => Maybe Blinder
+    -- ^ Optional blinder
+    -> OAEPParams hash ByteString ByteString
+    -- ^ OAEP params to use for decryption
+    -> PrivateKey
+    -- ^ Private key
+    -> ByteString
+    -- ^ Cipher text
+    -> Either Error ByteString
 decrypt blinder oaep pk cipher
     | B.length cipher /= k = Left MessageSizeIncorrect
-    | k < 2*hashLen+2      = Left InvalidParameters
-    | otherwise            = unpad oaep (private_size pk) $ dp blinder pk cipher
-    where -- parameters
-          k          = private_size pk
-          hashLen    = hashDigestSize (oaepHash oaep)
+    | k < 2 * hashLen + 2 = Left InvalidParameters
+    | otherwise = unpad oaep (private_size pk) $ dp blinder pk cipher
+  where
+    -- parameters
+    k = private_size pk
+    hashLen = hashDigestSize (oaepHash oaep)
 
 -- | Decrypt a ciphertext using OAEP and by automatically generating a blinder.
-decryptSafer :: (HashAlgorithm hash, MonadRandom m)
-             => OAEPParams hash ByteString ByteString -- ^ OAEP params to use for decryption
-             -> PrivateKey -- ^ Private key
-             -> ByteString -- ^ Cipher text
-             -> m (Either Error ByteString)
+decryptSafer
+    :: (HashAlgorithm hash, MonadRandom m)
+    => OAEPParams hash ByteString ByteString
+    -- ^ OAEP params to use for decryption
+    -> PrivateKey
+    -- ^ Private key
+    -> ByteString
+    -- ^ Cipher text
+    -> m (Either Error ByteString)
 decryptSafer oaep pk cipher = do
     blinder <- generateBlinder (private_n pk)
     return (decrypt (Just blinder) oaep pk cipher)
diff --git a/Crypto/PubKey/RSA/PKCS15.hs b/Crypto/PubKey/RSA/PKCS15.hs
--- a/Crypto/PubKey/RSA/PKCS15.hs
+++ b/Crypto/PubKey/RSA/PKCS15.hs
@@ -4,36 +4,37 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.PubKey.RSA.PKCS15
-    (
+module Crypto.PubKey.RSA.PKCS15 (
     -- * Padding and unpadding
-      pad
-    , padSignature
-    , unpad
+    pad,
+    padSignature,
+    unpad,
+
     -- * Private key operations
-    , decrypt
-    , decryptSafer
-    , sign
-    , signSafer
+    decrypt,
+    decryptSafer,
+    sign,
+    signSafer,
+
     -- * Public key operations
-    , encrypt
-    , verify
+    encrypt,
+    verify,
+
     -- * Hash ASN1 description
-    , HashAlgorithmASN1
-    ) where
+    HashAlgorithmASN1,
+) where
 
-import           Crypto.Random.Types
-import           Crypto.PubKey.Internal (and')
-import           Crypto.PubKey.RSA.Types
-import           Crypto.PubKey.RSA.Prim
-import           Crypto.PubKey.RSA (generateBlinder)
-import           Crypto.Hash
+import Crypto.Hash
+import Crypto.PubKey.Internal (and')
+import Crypto.PubKey.RSA (generateBlinder)
+import Crypto.PubKey.RSA.Prim
+import Crypto.PubKey.RSA.Types
+import Crypto.Random.Types
 
-import           Data.ByteString (ByteString)
-import           Data.Word
+import Data.ByteString (ByteString)
+import Data.Word
 
-import           Crypto.Internal.ByteArray (ByteArray, Bytes)
+import Crypto.Internal.ByteArray (ByteArray, Bytes)
 import qualified Crypto.Internal.ByteArray as B
 
 -- | A specialized class for hash algorithm that can product
@@ -46,28 +47,230 @@
 -- http://uk.emc.com/emc-plus/rsa-labs/pkcs/files/h11300-wp-pkcs-1v2-2-rsa-cryptography-standard.pdf
 -- EMSA-PKCS1-v1_5
 instance HashAlgorithmASN1 MD2 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x02,0x05,0x00,0x04,0x10]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x20
+            , 0x30
+            , 0x0c
+            , 0x06
+            , 0x08
+            , 0x2a
+            , 0x86
+            , 0x48
+            , 0x86
+            , 0xf7
+            , 0x0d
+            , 0x02
+            , 0x02
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x10
+            ]
 instance HashAlgorithmASN1 MD5 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x04,0x10]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x20
+            , 0x30
+            , 0x0c
+            , 0x06
+            , 0x08
+            , 0x2a
+            , 0x86
+            , 0x48
+            , 0x86
+            , 0xf7
+            , 0x0d
+            , 0x02
+            , 0x05
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x10
+            ]
 instance HashAlgorithmASN1 SHA1 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,0x05,0x00,0x04,0x14]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x21
+            , 0x30
+            , 0x09
+            , 0x06
+            , 0x05
+            , 0x2b
+            , 0x0e
+            , 0x03
+            , 0x02
+            , 0x1a
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x14
+            ]
 instance HashAlgorithmASN1 SHA224 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x2d,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,0x05,0x00,0x04,0x1c]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x2d
+            , 0x30
+            , 0x0d
+            , 0x06
+            , 0x09
+            , 0x60
+            , 0x86
+            , 0x48
+            , 0x01
+            , 0x65
+            , 0x03
+            , 0x04
+            , 0x02
+            , 0x04
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x1c
+            ]
 instance HashAlgorithmASN1 SHA256 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x31
+            , 0x30
+            , 0x0d
+            , 0x06
+            , 0x09
+            , 0x60
+            , 0x86
+            , 0x48
+            , 0x01
+            , 0x65
+            , 0x03
+            , 0x04
+            , 0x02
+            , 0x01
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x20
+            ]
 instance HashAlgorithmASN1 SHA384 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x41
+            , 0x30
+            , 0x0d
+            , 0x06
+            , 0x09
+            , 0x60
+            , 0x86
+            , 0x48
+            , 0x01
+            , 0x65
+            , 0x03
+            , 0x04
+            , 0x02
+            , 0x02
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x30
+            ]
 instance HashAlgorithmASN1 SHA512 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x51
+            , 0x30
+            , 0x0d
+            , 0x06
+            , 0x09
+            , 0x60
+            , 0x86
+            , 0x48
+            , 0x01
+            , 0x65
+            , 0x03
+            , 0x04
+            , 0x02
+            , 0x03
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x40
+            ]
 instance HashAlgorithmASN1 SHA512t_224 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x2d,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x05,0x05,0x00,0x04,0x1c]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x2d
+            , 0x30
+            , 0x0d
+            , 0x06
+            , 0x09
+            , 0x60
+            , 0x86
+            , 0x48
+            , 0x01
+            , 0x65
+            , 0x03
+            , 0x04
+            , 0x02
+            , 0x05
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x1c
+            ]
 instance HashAlgorithmASN1 SHA512t_256 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x06,0x05,0x00,0x04,0x20]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x31
+            , 0x30
+            , 0x0d
+            , 0x06
+            , 0x09
+            , 0x60
+            , 0x86
+            , 0x48
+            , 0x01
+            , 0x65
+            , 0x03
+            , 0x04
+            , 0x02
+            , 0x06
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x20
+            ]
 instance HashAlgorithmASN1 RIPEMD160 where
-    hashDigestASN1 = addDigestPrefix [0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x24,0x03,0x02,0x01,0x05,0x00,0x04,0x14]
+    hashDigestASN1 =
+        addDigestPrefix
+            [ 0x30
+            , 0x21
+            , 0x30
+            , 0x09
+            , 0x06
+            , 0x05
+            , 0x2b
+            , 0x24
+            , 0x03
+            , 0x02
+            , 0x01
+            , 0x05
+            , 0x00
+            , 0x04
+            , 0x14
+            ]
 
 --
+
 -- ** Hack **
+
 --
 -- this happens to not need a real ASN1 encoder, because
 -- thanks to the digest being a specific size AND
@@ -89,47 +292,51 @@
     B.pack prefix `B.append` B.convert digest
 
 -- | This produce a standard PKCS1.5 padding for encryption
-pad :: (MonadRandom m, ByteArray message) => Int -> message -> m (Either Error message)
+pad
+    :: (MonadRandom m, ByteArray message) => Int -> message -> m (Either Error message)
 pad len m
     | B.length m > len - 11 = return (Left MessageTooLong)
-    | otherwise             = do
+    | otherwise = do
         padding <- getNonNullRandom (len - B.length m - 3)
-        return $ Right $ B.concat [ B.pack [0,2], padding, B.pack [0], m ]
-
+        return $ Right $ B.concat [B.pack [0, 2], padding, B.pack [0], m]
   where
     -- get random non-null bytes
     getNonNullRandom :: (ByteArray bytearray, MonadRandom m) => Int -> m bytearray
     getNonNullRandom n = do
         bs0 <- getRandomBytes n
         let bytes = B.pack $ filter (/= 0) $ B.unpack (bs0 :: Bytes)
-            left  = n - B.length bytes
+            left = n - B.length bytes
         if left == 0
             then return bytes
-            else do bend <- getNonNullRandom left
-                    return (bytes `B.append` bend)
+            else do
+                bend <- getNonNullRandom left
+                return (bytes `B.append` bend)
 
 -- | Produce a standard PKCS1.5 padding for signature
-padSignature :: ByteArray signature => Int -> signature -> Either Error signature
+padSignature
+    :: ByteArray signature => Int -> signature -> Either Error signature
 padSignature klen signature
     | klen < siglen + 11 = Left SignatureTooLong
-    | otherwise          = Right (B.pack padding `B.append` signature)
+    | otherwise = Right (B.pack padding `B.append` signature)
   where
-        siglen    = B.length signature
-        padding   = 0 : 1 : (replicate (klen - siglen - 3) 0xff ++ [0])
+    siglen = B.length signature
+    padding = 0 : 1 : (replicate (klen - siglen - 3) 0xff ++ [0])
 
 -- | Try to remove a standard PKCS1.5 encryption padding.
 unpad :: ByteArray bytearray => bytearray -> Either Error bytearray
 unpad packed
     | paddingSuccess = Right m
-    | otherwise      = Left MessageNotRecognized
+    | otherwise = Left MessageNotRecognized
   where
-        (zt, ps0m)   = B.splitAt 2 packed
-        (ps, zm)     = B.span (/= 0) ps0m
-        (z, m)       = B.splitAt 1 zm
-        paddingSuccess = and' [ zt `B.constEq` (B.pack [0,2] :: Bytes)
-                              , z == B.zero 1
-                              , B.length ps >= 8
-                              ]
+    (zt, ps0m) = B.splitAt 2 packed
+    (ps, zm) = B.span (/= 0) ps0m
+    (z, m) = B.splitAt 1 zm
+    paddingSuccess =
+        and'
+            [ zt `B.constEq` (B.pack [0, 2] :: Bytes)
+            , z == B.zero 1
+            , B.length ps >= 8
+            ]
 
 -- | decrypt message using the private key.
 --
@@ -139,19 +346,28 @@
 -- If unsure always set a blinder or use decryptSafer
 --
 -- The message is returned un-padded.
-decrypt :: Maybe Blinder -- ^ optional blinder
-        -> PrivateKey    -- ^ RSA private key
-        -> ByteString    -- ^ cipher text
-        -> Either Error ByteString
+decrypt
+    :: ByteArray ba
+    => Maybe Blinder
+    -- ^ optional blinder
+    -> PrivateKey
+    -- ^ RSA private key
+    -> ByteString
+    -- ^ cipher text
+    -> Either Error ba
 decrypt blinder pk c
     | B.length c /= (private_size pk) = Left MessageSizeIncorrect
-    | otherwise                       = unpad $ dp blinder pk c
+    -- "convert" must be apply to "c".
+    | otherwise = unpad $ dp blinder pk $ B.convert c
 
 -- | decrypt message using the private key and by automatically generating a blinder.
-decryptSafer :: MonadRandom m
-             => PrivateKey -- ^ RSA private key
-             -> ByteString -- ^ cipher text
-             -> m (Either Error ByteString)
+decryptSafer
+    :: (MonadRandom m, ByteArray ba)
+    => PrivateKey
+    -- ^ RSA private key
+    -> ByteString
+    -- ^ cipher text
+    -> m (Either Error ba)
 decryptSafer pk b = do
     blinder <- generateBlinder (private_n pk)
     return (decrypt (Just blinder) pk b)
@@ -160,12 +376,13 @@
 --
 -- The message needs to be smaller than the key size - 11.
 -- The message should not be padded.
-encrypt :: MonadRandom m => PublicKey -> ByteString -> m (Either Error ByteString)
+encrypt
+    :: (MonadRandom m, ByteArray ba) => PublicKey -> ba -> m (Either Error ByteString)
 encrypt pk m = do
     r <- pad (public_size pk) m
     case r of
         Left err -> return $ Left err
-        Right em -> return $ Right (ep pk em)
+        Right em -> return $ Right (B.convert $ ep pk em)
 
 -- | sign message using private key, a hash and its ASN1 description
 --
@@ -173,41 +390,55 @@
 -- information from the timing of the operation, the blinder can be set to None.
 --
 -- If unsure always set a blinder or use signSafer
-sign :: HashAlgorithmASN1 hashAlg
-     => Maybe Blinder -- ^ optional blinder
-     -> Maybe hashAlg -- ^ hash algorithm
-     -> PrivateKey    -- ^ private key
-     -> ByteString    -- ^ message to sign
-     -> Either Error ByteString
+sign
+    :: HashAlgorithmASN1 hashAlg
+    => Maybe Blinder
+    -- ^ optional blinder
+    -> Maybe hashAlg
+    -- ^ hash algorithm
+    -> PrivateKey
+    -- ^ private key
+    -> ByteString
+    -- ^ message to sign
+    -> Either Error ByteString
 sign blinder hashDescr pk m = dp blinder pk `fmap` makeSignature hashDescr (private_size pk) m
 
 -- | sign message using the private key and by automatically generating a blinder.
-signSafer :: (HashAlgorithmASN1 hashAlg, MonadRandom m)
-          => Maybe hashAlg -- ^ Hash algorithm
-          -> PrivateKey    -- ^ private key
-          -> ByteString    -- ^ message to sign
-          -> m (Either Error ByteString)
+signSafer
+    :: (HashAlgorithmASN1 hashAlg, MonadRandom m)
+    => Maybe hashAlg
+    -- ^ Hash algorithm
+    -> PrivateKey
+    -- ^ private key
+    -> ByteString
+    -- ^ message to sign
+    -> m (Either Error ByteString)
 signSafer hashAlg pk m = do
     blinder <- generateBlinder (private_n pk)
     return (sign (Just blinder) hashAlg pk m)
 
 -- | verify message with the signed message
-verify :: HashAlgorithmASN1 hashAlg
-       => Maybe hashAlg
-       -> PublicKey
-       -> ByteString
-       -> ByteString
-       -> Bool
+verify
+    :: HashAlgorithmASN1 hashAlg
+    => Maybe hashAlg
+    -> PublicKey
+    -> ByteString
+    -- ^ Message
+    -> ByteString
+    -- ^ Signature
+    -> Bool
 verify hashAlg pk m sm =
     case makeSignature hashAlg (public_size pk) m of
-        Left _  -> False
+        Left _ -> False
         Right s -> s == (ep pk sm)
 
 -- | make signature digest, used in 'sign' and 'verify'
-makeSignature :: HashAlgorithmASN1 hashAlg
-              => Maybe hashAlg -- ^ optional hashing algorithm
-              -> Int
-              -> ByteString
-              -> Either Error ByteString
-makeSignature Nothing        klen m = padSignature klen m
+makeSignature
+    :: HashAlgorithmASN1 hashAlg
+    => Maybe hashAlg
+    -- ^ optional hashing algorithm
+    -> Int
+    -> ByteString
+    -> Either Error ByteString
+makeSignature Nothing klen m = padSignature klen m
 makeSignature (Just hashAlg) klen m = padSignature klen (hashDigestASN1 $ hashWith hashAlg m)
diff --git a/Crypto/PubKey/RSA/PSS.hs b/Crypto/PubKey/RSA/PSS.hs
--- a/Crypto/PubKey/RSA/PSS.hs
+++ b/Crypto/PubKey/RSA/PSS.hs
@@ -4,56 +4,62 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.PubKey.RSA.PSS
-    ( PSSParams(..)
-    , defaultPSSParams
-    , defaultPSSParamsSHA1
+module Crypto.PubKey.RSA.PSS (
+    PSSParams (..),
+    defaultPSSParams,
+    defaultPSSParamsSHA1,
+
     -- * Sign and verify functions
-    , signWithSalt
-    , signDigestWithSalt
-    , sign
-    , signDigest
-    , signSafer
-    , signDigestSafer
-    , verify
-    , verifyDigest
-    ) where
+    signWithSalt,
+    signDigestWithSalt,
+    sign,
+    signDigest,
+    signSafer,
+    signDigestSafer,
+    verify,
+    verifyDigest,
+) where
 
-import           Crypto.Random.Types
-import           Crypto.PubKey.RSA.Types
-import           Crypto.PubKey.RSA.Prim
-import           Crypto.PubKey.RSA (generateBlinder)
-import           Crypto.PubKey.MaskGenFunction
-import           Crypto.Hash
-import           Crypto.Number.Basic (numBits)
-import           Data.Bits (xor, shiftR, (.&.))
-import           Data.Word
+import Crypto.Hash
+import Crypto.Number.Basic (numBits)
+import Crypto.PubKey.MaskGenFunction
+import Crypto.PubKey.RSA (generateBlinder)
+import Crypto.PubKey.RSA.Prim
+import Crypto.PubKey.RSA.Types
+import Crypto.Random.Types
+import Data.Bits (shiftR, xor, (.&.))
+import Data.Word
 
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray)
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B (convert, eq)
 
-import           Data.ByteString (ByteString)
+import Data.ByteString (ByteString)
 import qualified Data.ByteString as B
 
 -- | Parameters for PSS signature/verification.
 data PSSParams hash seed output = PSSParams
-    { pssHash         :: hash             -- ^ Hash function to use
-    , pssMaskGenAlg   :: MaskGenAlgorithm seed output -- ^ Mask Gen algorithm to use
-    , pssSaltLength   :: Int              -- ^ Length of salt. need to be <= to hLen.
-    , pssTrailerField :: Word8            -- ^ Trailer field, usually 0xbc
+    { pssHash :: hash
+    -- ^ Hash function to use
+    , pssMaskGenAlg :: MaskGenAlgorithm seed output
+    -- ^ Mask Gen algorithm to use
+    , pssSaltLength :: Int
+    -- ^ Length of salt. need to be <= to hLen.
+    , pssTrailerField :: Word8
+    -- ^ Trailer field, usually 0xbc
     }
 
 -- | Default Params with a specified hash function
-defaultPSSParams :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash)
-                 => hash
-                 -> PSSParams hash seed output
+defaultPSSParams
+    :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash)
+    => hash
+    -> PSSParams hash seed output
 defaultPSSParams hashAlg =
-    PSSParams { pssHash         = hashAlg
-              , pssMaskGenAlg   = mgf1 hashAlg
-              , pssSaltLength   = hashDigestSize hashAlg
-              , pssTrailerField = 0xbc
-              }
+    PSSParams
+        { pssHash = hashAlg
+        , pssMaskGenAlg = mgf1 hashAlg
+        , pssSaltLength = hashDigestSize hashAlg
+        , pssTrailerField = 0xbc
+        }
 
 -- | Default Params using SHA1 algorithm.
 defaultPSSParamsSHA1 :: PSSParams SHA1 ByteString ByteString
@@ -62,138 +68,181 @@
 -- | Sign using the PSS parameters and the salt explicitely passed as parameters.
 --
 -- the function ignore SaltLength from the PSS Parameters
-signDigestWithSalt :: HashAlgorithm hash
-                   => ByteString    -- ^ Salt to use
-                   -> Maybe Blinder -- ^ optional blinder to use
-                   -> PSSParams hash ByteString ByteString -- ^ PSS Parameters to use
-                   -> PrivateKey    -- ^ RSA Private Key
-                   -> Digest hash   -- ^ Message digest
-                   -> Either Error ByteString
+signDigestWithSalt
+    :: HashAlgorithm hash
+    => ByteString
+    -- ^ Salt to use
+    -> Maybe Blinder
+    -- ^ optional blinder to use
+    -> PSSParams hash ByteString ByteString
+    -- ^ PSS Parameters to use
+    -> PrivateKey
+    -- ^ RSA Private Key
+    -> Digest hash
+    -- ^ Message digest
+    -> Either Error ByteString
 signDigestWithSalt salt blinder params pk digest
     | emLen < hashLen + saltLen + 2 = Left InvalidParameters
-    | otherwise                     = Right $ dp blinder pk em
-    where k        = private_size pk
-          emLen    = if emTruncate pubBits then k - 1 else k
-          mHash    = B.convert digest
-          dbLen    = emLen - hashLen - 1
-          saltLen  = B.length salt
-          hashLen  = hashDigestSize (pssHash params)
-          pubBits  = numBits (private_n pk)
-          m'       = B.concat [B.replicate 8 0,mHash,salt]
-          h        = B.convert $ hashWith (pssHash params) m'
-          db       = B.concat [B.replicate (dbLen - saltLen - 1) 0,B.singleton 1,salt]
-          dbmask   = pssMaskGenAlg params h dbLen
-          maskedDB = B.pack $ normalizeToKeySize pubBits $ B.zipWith xor db dbmask
-          em       = B.concat [maskedDB, h, B.singleton (pssTrailerField params)]
+    | otherwise = Right $ dp blinder pk em
+  where
+    k = private_size pk
+    emLen = if emTruncate pubBits then k - 1 else k
+    mHash = B.convert digest
+    dbLen = emLen - hashLen - 1
+    saltLen = B.length salt
+    hashLen = hashDigestSize (pssHash params)
+    pubBits = numBits (private_n pk)
+    m' = B.concat [B.replicate 8 0, mHash, salt]
+    h = B.convert $ hashWith (pssHash params) m'
+    db = B.concat [B.replicate (dbLen - saltLen - 1) 0, B.singleton 1, salt]
+    dbmask = pssMaskGenAlg params h dbLen
+    maskedDB = B.pack $ normalizeToKeySize pubBits $ B.zipWith xor db dbmask
+    em = B.concat [maskedDB, h, B.singleton (pssTrailerField params)]
 
 -- | Sign using the PSS parameters and the salt explicitely passed as parameters.
 --
 -- the function ignore SaltLength from the PSS Parameters
-signWithSalt :: HashAlgorithm hash
-             => ByteString    -- ^ Salt to use
-             -> Maybe Blinder -- ^ optional blinder to use
-             -> PSSParams hash ByteString ByteString -- ^ PSS Parameters to use
-             -> PrivateKey    -- ^ RSA Private Key
-             -> ByteString    -- ^ Message to sign
-             -> Either Error ByteString
+signWithSalt
+    :: HashAlgorithm hash
+    => ByteString
+    -- ^ Salt to use
+    -> Maybe Blinder
+    -- ^ optional blinder to use
+    -> PSSParams hash ByteString ByteString
+    -- ^ PSS Parameters to use
+    -> PrivateKey
+    -- ^ RSA Private Key
+    -> ByteString
+    -- ^ Message to sign
+    -> Either Error ByteString
 signWithSalt salt blinder params pk m = signDigestWithSalt salt blinder params pk mHash
-    where mHash    = hashWith (pssHash params) m
+  where
+    mHash = hashWith (pssHash params) m
 
 -- | Sign using the PSS Parameters
-sign :: (HashAlgorithm hash, MonadRandom m)
-     => Maybe Blinder   -- ^ optional blinder to use
-     -> PSSParams hash ByteString ByteString -- ^ PSS Parameters to use
-     -> PrivateKey      -- ^ RSA Private Key
-     -> ByteString      -- ^ Message to sign
-     -> m (Either Error ByteString)
+sign
+    :: (HashAlgorithm hash, MonadRandom m)
+    => Maybe Blinder
+    -- ^ optional blinder to use
+    -> PSSParams hash ByteString ByteString
+    -- ^ PSS Parameters to use
+    -> PrivateKey
+    -- ^ RSA Private Key
+    -> ByteString
+    -- ^ Message to sign
+    -> m (Either Error ByteString)
 sign blinder params pk m = do
     salt <- getRandomBytes (pssSaltLength params)
     return (signWithSalt salt blinder params pk m)
 
 -- | Sign using the PSS Parameters
-signDigest :: (HashAlgorithm hash, MonadRandom m)
-           => Maybe Blinder   -- ^ optional blinder to use
-           -> PSSParams hash ByteString ByteString -- ^ PSS Parameters to use
-           -> PrivateKey      -- ^ RSA Private Key
-           -> Digest hash     -- ^ Message digest
-           -> m (Either Error ByteString)
+signDigest
+    :: (HashAlgorithm hash, MonadRandom m)
+    => Maybe Blinder
+    -- ^ optional blinder to use
+    -> PSSParams hash ByteString ByteString
+    -- ^ PSS Parameters to use
+    -> PrivateKey
+    -- ^ RSA Private Key
+    -> Digest hash
+    -- ^ Message digest
+    -> m (Either Error ByteString)
 signDigest blinder params pk digest = do
     salt <- getRandomBytes (pssSaltLength params)
     return (signDigestWithSalt salt blinder params pk digest)
 
 -- | Sign using the PSS Parameters and an automatically generated blinder.
-signSafer :: (HashAlgorithm hash, MonadRandom m)
-          => PSSParams hash ByteString ByteString -- ^ PSS Parameters to use
-          -> PrivateKey     -- ^ private key
-          -> ByteString     -- ^ message to sign
-          -> m (Either Error ByteString)
+signSafer
+    :: (HashAlgorithm hash, MonadRandom m)
+    => PSSParams hash ByteString ByteString
+    -- ^ PSS Parameters to use
+    -> PrivateKey
+    -- ^ private key
+    -> ByteString
+    -- ^ message to sign
+    -> m (Either Error ByteString)
 signSafer params pk m = do
     blinder <- generateBlinder (private_n pk)
     sign (Just blinder) params pk m
 
 -- | Sign using the PSS Parameters and an automatically generated blinder.
-signDigestSafer :: (HashAlgorithm hash, MonadRandom m)
-                => PSSParams hash ByteString ByteString -- ^ PSS Parameters to use
-                -> PrivateKey     -- ^ private key
-                -> Digest hash    -- ^ message digst
-                -> m (Either Error ByteString)
+signDigestSafer
+    :: (HashAlgorithm hash, MonadRandom m)
+    => PSSParams hash ByteString ByteString
+    -- ^ PSS Parameters to use
+    -> PrivateKey
+    -- ^ private key
+    -> Digest hash
+    -- ^ message digst
+    -> m (Either Error ByteString)
 signDigestSafer params pk digest = do
     blinder <- generateBlinder (private_n pk)
     signDigest (Just blinder) params pk digest
 
 -- | Verify a signature using the PSS Parameters
-verify :: HashAlgorithm hash
-       => PSSParams hash ByteString ByteString
-                     -- ^ PSS Parameters to use to verify,
-                     --   this need to be identical to the parameters when signing
-       -> PublicKey  -- ^ RSA Public Key
-       -> ByteString -- ^ Message to verify
-       -> ByteString -- ^ Signature
-       -> Bool
+verify
+    :: HashAlgorithm hash
+    => PSSParams hash ByteString ByteString
+    -- ^ PSS Parameters to use to verify,
+    --   this need to be identical to the parameters when signing
+    -> PublicKey
+    -- ^ RSA Public Key
+    -> ByteString
+    -- ^ Message to verify
+    -> ByteString
+    -- ^ Signature
+    -> Bool
 verify params pk m = verifyDigest params pk mHash
-  where mHash     = hashWith (pssHash params) m
+  where
+    mHash = hashWith (pssHash params) m
 
 -- | Verify a signature using the PSS Parameters
-verifyDigest :: HashAlgorithm hash
-             => PSSParams hash ByteString ByteString
-                            -- ^ PSS Parameters to use to verify,
-                            --   this need to be identical to the parameters when signing
-             -> PublicKey   -- ^ RSA Public Key
-             -> Digest hash -- ^ Digest to verify
-             -> ByteString  -- ^ Signature
-             -> Bool
+verifyDigest
+    :: HashAlgorithm hash
+    => PSSParams hash ByteString ByteString
+    -- ^ PSS Parameters to use to verify,
+    --   this need to be identical to the parameters when signing
+    -> PublicKey
+    -- ^ RSA Public Key
+    -> Digest hash
+    -- ^ Digest to verify
+    -> ByteString
+    -- ^ Signature
+    -> Bool
 verifyDigest params pk digest s
-    | B.length s /= k                     = False
-    | B.any (/= 0) pre                    = False
+    | B.length s /= k = False
+    | B.any (/= 0) pre = False
     | B.last em /= pssTrailerField params = False
-    | B.any (/= 0) ps0                    = False
-    | b1 /= B.singleton 1                 = False
-    | otherwise                           = B.eq h h'
-        where -- parameters
-              hashLen   = hashDigestSize (pssHash params)
-              mHash     = B.convert digest
-              k         = public_size pk
-              emLen     = if emTruncate pubBits then k - 1 else k
-              dbLen     = emLen - hashLen - 1
-              pubBits   = numBits (public_n pk)
-              -- unmarshall fields
-              (pre, em) = B.splitAt (k - emLen) (ep pk s) -- drop 0..1 byte
-              maskedDB  = B.take dbLen em
-              h         = B.take hashLen $ B.drop (B.length maskedDB) em
-              dbmask    = pssMaskGenAlg params h dbLen
-              db        = B.pack $ normalizeToKeySize pubBits $ B.zipWith xor maskedDB dbmask
-              (ps0,z)   = B.break (== 1) db
-              (b1,salt) = B.splitAt 1 z
-              m'        = B.concat [B.replicate 8 0,mHash,salt]
-              h'        = hashWith (pssHash params) m'
+    | B.any (/= 0) ps0 = False
+    | b1 /= B.singleton 1 = False
+    | pssSaltLength params /= B.length salt = False
+    | otherwise = B.eq h h'
+  where
+    -- parameters
+    hashLen = hashDigestSize (pssHash params)
+    mHash = B.convert digest
+    k = public_size pk
+    emLen = if emTruncate pubBits then k - 1 else k
+    dbLen = emLen - hashLen - 1
+    pubBits = numBits (public_n pk)
+    -- unmarshall fields
+    (pre, em) = B.splitAt (k - emLen) (ep pk s) -- drop 0..1 byte
+    maskedDB = B.take dbLen em
+    h = B.take hashLen $ B.drop (B.length maskedDB) em
+    dbmask = pssMaskGenAlg params h dbLen
+    db = B.pack $ normalizeToKeySize pubBits $ B.zipWith xor maskedDB dbmask
+    (ps0, z) = B.break (== 1) db
+    (b1, salt) = B.splitAt 1 z
+    m' = B.concat [B.replicate 8 0, mHash, salt]
+    h' = hashWith (pssHash params) m'
 
 -- When the modulus has bit length 1 modulo 8 we drop the first byte.
 emTruncate :: Int -> Bool
-emTruncate bits = ((bits-1) .&. 0x7) == 0
+emTruncate bits = ((bits - 1) .&. 0x7) == 0
 
 normalizeToKeySize :: Int -> [Word8] -> [Word8]
-normalizeToKeySize _    []     = [] -- very unlikely
-normalizeToKeySize bits (x:xs) = x .&. mask : xs
-    where mask = if sh > 0 then 0xff `shiftR` (8-sh) else 0xff
-          sh   = (bits-1) .&. 0x7
-
+normalizeToKeySize _ [] = [] -- very unlikely
+normalizeToKeySize bits (x : xs) = x .&. mask : xs
+  where
+    mask = if sh > 0 then 0xff `shiftR` (8 - sh) else 0xff
+    sh = (bits - 1) .&. 0x7
diff --git a/Crypto/PubKey/RSA/Prim.hs b/Crypto/PubKey/RSA/Prim.hs
--- a/Crypto/PubKey/RSA/Prim.hs
+++ b/Crypto/PubKey/RSA/Prim.hs
@@ -4,19 +4,18 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.PubKey.RSA.Prim
-    (
+module Crypto.PubKey.RSA.Prim (
     -- * Decrypt primitive
-      dp
+    dp,
+
     -- * Encrypt primitive
-    , ep
-    ) where
+    ep,
+) where
 
-import           Crypto.PubKey.RSA.Types
-import           Crypto.Number.ModArithmetic (expFast, expSafe)
-import           Crypto.Number.Serialize (os2ip, i2ospOf_)
-import           Crypto.Internal.ByteArray (ByteArray)
+import Crypto.Internal.ByteArray (ByteArray)
+import Crypto.Number.ModArithmetic (expFast, expSafe)
+import Crypto.Number.Serialize (i2ospOf_, os2ip)
+import Crypto.PubKey.RSA.Types
 
 {- dpSlow computes the decrypted message not using any precomputed cache value.
    only n and d need to valid. -}
@@ -28,28 +27,32 @@
    to compute than mod pq -}
 dpFast :: ByteArray ba => Blinder -> PrivateKey -> ba -> ba
 dpFast (Blinder r rm1) pk c =
-    i2ospOf_ (private_size pk) (multiplication rm1 (m2 + h * (private_q pk)) (private_n pk))
-    where
-        re  = expFast r (public_e $ private_pub pk) (private_n pk)
-        iC  = multiplication re (os2ip c) (private_n pk)
-        m1  = expSafe iC (private_dP pk) (private_p pk)
-        m2  = expSafe iC (private_dQ pk) (private_q pk)
-        h   = ((private_qinv pk) * (m1 - m2)) `mod` (private_p pk)
+    i2ospOf_
+        (private_size pk)
+        (multiplication rm1 (m2 + h * (private_q pk)) (private_n pk))
+  where
+    re = expFast r (public_e $ private_pub pk) (private_n pk)
+    iC = multiplication re (os2ip c) (private_n pk)
+    m1 = expSafe iC (private_dP pk) (private_p pk)
+    m2 = expSafe iC (private_dQ pk) (private_q pk)
+    h = ((private_qinv pk) * (m1 - m2)) `mod` (private_p pk)
 
 dpFastNoBlinder :: ByteArray ba => PrivateKey -> ba -> ba
 dpFastNoBlinder pk c = i2ospOf_ (private_size pk) (m2 + h * (private_q pk))
-     where iC = os2ip c
-           m1 = expSafe iC (private_dP pk) (private_p pk)
-           m2 = expSafe iC (private_dQ pk) (private_q pk)
-           h  = ((private_qinv pk) * (m1 - m2)) `mod` (private_p pk)
+  where
+    iC = os2ip c
+    m1 = expSafe iC (private_dP pk) (private_p pk)
+    m2 = expSafe iC (private_dQ pk) (private_q pk)
+    h = ((private_qinv pk) * (m1 - m2)) `mod` (private_p pk)
 
 -- | Compute the RSA decrypt primitive.
 -- if the p and q numbers are available, then dpFast is used
 -- otherwise, we use dpSlow which only need d and n.
 dp :: ByteArray ba => Maybe Blinder -> PrivateKey -> ba -> ba
 dp blinder pk
-    | private_p pk /= 0 && private_q pk /= 0 = maybe dpFastNoBlinder dpFast blinder $ pk
-    | otherwise                              = dpSlow pk
+    | private_p pk /= 0 && private_q pk /= 0 =
+        maybe dpFastNoBlinder dpFast blinder $ pk
+    | otherwise = dpSlow pk
 
 -- | Compute the RSA encrypt primitive
 ep :: ByteArray ba => PublicKey -> ba -> ba
diff --git a/Crypto/PubKey/RSA/Types.hs b/Crypto/PubKey/RSA/Types.hs
--- a/Crypto/PubKey/RSA/Types.hs
+++ b/Crypto/PubKey/RSA/Types.hs
@@ -1,54 +1,66 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.PubKey.RSA.Types
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.PubKey.RSA.Types
-    ( Error(..)
-    , Blinder(..)
-    , PublicKey(..)
-    , PrivateKey(..)
-    , KeyPair(..)
-    , toPublicKey
-    , toPrivateKey
-    , private_size
-    , private_n
-    , private_e
-    ) where
+module Crypto.PubKey.RSA.Types (
+    Error (..),
+    Blinder (..),
+    PublicKey (..),
+    PrivateKey (..),
+    KeyPair (..),
+    toPublicKey,
+    toPrivateKey,
+    private_size,
+    private_n,
+    private_e,
+) where
 
-import           Data.Data
-import           Crypto.Internal.Imports
+import Crypto.Internal.Imports
+import Data.Data
 
+import GHC.Generics
+
 -- | Blinder which is used to obfuscate the timing
 -- of the decryption primitive (used by decryption and signing).
 data Blinder = Blinder !Integer !Integer
-             deriving (Show,Eq)
+    deriving (Show, Eq)
 
 -- | error possible during encryption, decryption or signing.
-data Error =
-      MessageSizeIncorrect -- ^ the message to decrypt is not of the correct size (need to be == private_size)
-    | MessageTooLong       -- ^ the message to encrypt is too long
-    | MessageNotRecognized -- ^ the message decrypted doesn't have a PKCS15 structure (0 2 .. 0 msg)
-    | SignatureTooLong     -- ^ the message's digest is too long
-    | InvalidParameters    -- ^ some parameters lead to breaking assumptions.
-    deriving (Show,Eq)
+data Error
+    = -- | the message to decrypt is not of the correct size (need to be == private_size)
+      MessageSizeIncorrect
+    | -- | the message to encrypt is too long
+      MessageTooLong
+    | -- | the message decrypted doesn't have a PKCS15 structure (0 2 .. 0 msg)
+      MessageNotRecognized
+    | -- | the message's digest is too long
+      SignatureTooLong
+    | -- | some parameters lead to breaking assumptions.
+      InvalidParameters
+    deriving (Show, Eq)
 
 -- | Represent a RSA public key
 data PublicKey = PublicKey
-    { public_size :: Int      -- ^ size of key in bytes
-    , public_n    :: Integer  -- ^ public p*q
-    , public_e    :: Integer  -- ^ public exponent e
-    } deriving (Show,Read,Eq,Data)
+    { public_size :: Int
+    -- ^ size of key in bytes
+    , public_n :: Integer
+    -- ^ public p*q
+    , public_e :: Integer
+    -- ^ public exponent e
+    }
+    deriving (Show, Read, Eq, Data, Generic)
 
 instance NFData PublicKey where
     rnf (PublicKey sz n e) = rnf n `seq` rnf e `seq` sz `seq` ()
 
 -- | Represent a RSA private key.
--- 
+--
 -- Only the pub, d fields are mandatory to fill.
 --
 -- p, q, dP, dQ, qinv are by-product during RSA generation,
@@ -56,20 +68,34 @@
 -- the decrypt and sign operation.
 --
 -- implementations can leave optional fields to 0.
---
 data PrivateKey = PrivateKey
-    { private_pub  :: PublicKey -- ^ public part of a private key (size, n and e)
-    , private_d    :: Integer   -- ^ private exponent d
-    , private_p    :: Integer   -- ^ p prime number
-    , private_q    :: Integer   -- ^ q prime number
-    , private_dP   :: Integer   -- ^ d mod (p-1)
-    , private_dQ   :: Integer   -- ^ d mod (q-1)
-    , private_qinv :: Integer   -- ^ q^(-1) mod p
-    } deriving (Show,Read,Eq,Data)
+    { private_pub :: PublicKey
+    -- ^ public part of a private key (size, n and e)
+    , private_d :: Integer
+    -- ^ private exponent d
+    , private_p :: Integer
+    -- ^ p prime number
+    , private_q :: Integer
+    -- ^ q prime number
+    , private_dP :: Integer
+    -- ^ d mod (p-1)
+    , private_dQ :: Integer
+    -- ^ d mod (q-1)
+    , private_qinv :: Integer
+    -- ^ q^(-1) mod p
+    }
+    deriving (Show, Read, Eq, Data, Generic)
 
 instance NFData PrivateKey where
     rnf (PrivateKey pub d p q dp dq qinv) =
-        rnf pub `seq` rnf d `seq` rnf p `seq` rnf q `seq` rnf dp `seq` rnf dq `seq` qinv `seq` ()
+        rnf pub `seq`
+            rnf d `seq`
+                rnf p `seq`
+                    rnf q `seq`
+                        rnf dp `seq`
+                            rnf dq `seq`
+                                qinv `seq`
+                                    ()
 
 -- | get the size in bytes from a private key
 private_size :: PrivateKey -> Int
@@ -87,7 +113,7 @@
 --
 -- note the RSA private key contains already an instance of public key for efficiency
 newtype KeyPair = KeyPair PrivateKey
-    deriving (Show,Read,Eq,Data,NFData)
+    deriving (Show, Read, Eq, Data, NFData)
 
 -- | Public key of a RSA KeyPair
 toPublicKey :: KeyPair -> PublicKey
diff --git a/Crypto/PubKey/Rabin/Basic.hs b/Crypto/PubKey/Rabin/Basic.hs
--- a/Crypto/PubKey/Rabin/Basic.hs
+++ b/Crypto/PubKey/Rabin/Basic.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+
 -- |
 -- Module      : Crypto.PubKey.Rabin.Basic
 -- License     : BSD-style
@@ -6,48 +8,52 @@
 -- Portability : unknown
 --
 -- Rabin cryptosystem for public-key cryptography and digital signature.
---
-{-# LANGUAGE DeriveDataTypeable #-}
-module Crypto.PubKey.Rabin.Basic
-    ( PublicKey(..)
-    , PrivateKey(..)
-    , Signature(..)
-    , generate
-    , encrypt
-    , encryptWithSeed
-    , decrypt
-    , sign
-    , signWith
-    , verify
-    ) where
+module Crypto.PubKey.Rabin.Basic (
+    PublicKey (..),
+    PrivateKey (..),
+    Signature (..),
+    generate,
+    encrypt,
+    encryptWithSeed,
+    decrypt,
+    sign,
+    signWith,
+    verify,
+) where
 
-import           Data.ByteString (ByteString)
+import Data.ByteString (ByteString)
 import qualified Data.ByteString as B
-import           Data.Data
-import           Data.Either (rights)
+import Data.Data
+import Data.Either (rights)
 
-import           Crypto.Hash
-import           Crypto.Number.Basic (gcde, numBytes)
-import           Crypto.Number.ModArithmetic (expSafe, jacobi)
-import           Crypto.Number.Serialize (i2osp, i2ospOf_, os2ip)
-import           Crypto.PubKey.Rabin.OAEP 
-import           Crypto.PubKey.Rabin.Types
-import           Crypto.Random (MonadRandom, getRandomBytes)
+import Crypto.Hash
+import Crypto.Number.Basic (gcde, numBytes)
+import Crypto.Number.ModArithmetic (expSafe, jacobi)
+import Crypto.Number.Serialize (i2osp, i2ospOf_, os2ip)
+import Crypto.PubKey.Rabin.OAEP
+import Crypto.PubKey.Rabin.Types
+import Crypto.Random (MonadRandom, getRandomBytes)
 
 -- | Represent a Rabin public key.
 data PublicKey = PublicKey
-    { public_size :: Int      -- ^ size of key in bytes
-    , public_n    :: Integer  -- ^ public p*q
-    } deriving (Show, Read, Eq, Data)
+    { public_size :: Int
+    -- ^ size of key in bytes
+    , public_n :: Integer
+    -- ^ public p*q
+    }
+    deriving (Show, Read, Eq, Data)
 
 -- | Represent a Rabin private key.
 data PrivateKey = PrivateKey
     { private_pub :: PublicKey
-    , private_p   :: Integer   -- ^ p prime number
-    , private_q   :: Integer   -- ^ q prime number
-    , private_a   :: Integer
-    , private_b   :: Integer
-    } deriving (Show, Read, Eq, Data)
+    , private_p :: Integer
+    -- ^ p prime number
+    , private_q :: Integer
+    -- ^ q prime number
+    , private_a :: Integer
+    , private_b :: Integer
+    }
+    deriving (Show, Read, Eq, Data)
 
 -- | Rabin Signature.
 data Signature = Signature (Integer, Integer) deriving (Show, Read, Eq, Data)
@@ -56,85 +62,112 @@
 -- Primes p and q are both congruent 3 mod 4.
 --
 -- See algorithm 8.11 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
-generate :: MonadRandom m
-         => Int
-         -> m (PublicKey, PrivateKey)
+generate
+    :: MonadRandom m
+    => Int
+    -> m (PublicKey, PrivateKey)
 generate size = do
     (p, q) <- generatePrimes size (\p -> p `mod` 4 == 3) (\q -> q `mod` 4 == 3)
     return $ generateKeys p q
-  where 
+  where
     generateKeys p q =
-        let n = p*q
-            (a, b, _) = gcde p q 
-            publicKey = PublicKey { public_size = size
-                                    , public_n    = n }
-            privateKey = PrivateKey { private_pub = publicKey
-                                    , private_p   = p
-                                    , private_q   = q
-                                    , private_a   = a
-                                    , private_b   = b }
-            in (publicKey, privateKey)
+        let n = p * q
+            (a, b, _) = gcde p q
+            publicKey =
+                PublicKey
+                    { public_size = size
+                    , public_n = n
+                    }
+            privateKey =
+                PrivateKey
+                    { private_pub = publicKey
+                    , private_p = p
+                    , private_q = q
+                    , private_a = a
+                    , private_b = b
+                    }
+         in (publicKey, privateKey)
 
 -- | Encrypt plaintext using public key an a predefined OAEP seed.
 --
 -- See algorithm 8.11 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
-encryptWithSeed :: HashAlgorithm hash
-                => ByteString                               -- ^ Seed
-                -> OAEPParams hash ByteString ByteString    -- ^ OAEP padding
-                -> PublicKey                                -- ^ public key
-                -> ByteString                               -- ^ plaintext
-                -> Either Error ByteString
+encryptWithSeed
+    :: HashAlgorithm hash
+    => ByteString
+    -- ^ Seed
+    -> OAEPParams hash ByteString ByteString
+    -- ^ OAEP padding
+    -> PublicKey
+    -- ^ public key
+    -> ByteString
+    -- ^ plaintext
+    -> Either Error ByteString
 encryptWithSeed seed oaep pk m =
-    let n  = public_n pk
-        k  = numBytes n
+    let n = public_n pk
+        k = numBytes n
      in do
-        m' <- pad seed oaep k m
-        let m'' = os2ip m'
-        return $ i2osp $ expSafe m'' 2 n
+            m' <- pad seed oaep k m
+            let m'' = os2ip m'
+            return $ i2osp $ expSafe m'' 2 n
 
 -- | Encrypt plaintext using public key.
-encrypt :: (HashAlgorithm hash, MonadRandom m)
-        => OAEPParams hash ByteString ByteString    -- ^ OAEP padding parameters
-        -> PublicKey                                -- ^ public key
-        -> ByteString                               -- ^ plaintext 
-        -> m (Either Error ByteString)
+encrypt
+    :: (HashAlgorithm hash, MonadRandom m)
+    => OAEPParams hash ByteString ByteString
+    -- ^ OAEP padding parameters
+    -> PublicKey
+    -- ^ public key
+    -> ByteString
+    -- ^ plaintext
+    -> m (Either Error ByteString)
 encrypt oaep pk m = do
     seed <- getRandomBytes hashLen
     return $ encryptWithSeed seed oaep pk m
   where
-    hashLen = hashDigestSize (oaepHash oaep) 
+    hashLen = hashDigestSize (oaepHash oaep)
 
 -- | Decrypt ciphertext using private key.
 --
 -- See algorithm 8.12 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
-decrypt :: HashAlgorithm hash
-        => OAEPParams hash ByteString ByteString    -- ^ OAEP padding parameters
-        -> PrivateKey                               -- ^ private key
-        -> ByteString                               -- ^ ciphertext
-        -> Maybe ByteString
+decrypt
+    :: HashAlgorithm hash
+    => OAEPParams hash ByteString ByteString
+    -- ^ OAEP padding parameters
+    -> PrivateKey
+    -- ^ private key
+    -> ByteString
+    -- ^ ciphertext
+    -> Maybe ByteString
 decrypt oaep pk c =
-    let p  = private_p pk 
-        q  = private_q pk     
-        a  = private_a pk 
-        b  = private_b pk
-        n  = public_n $ private_pub pk
-        k  = numBytes n
+    let p = private_p pk
+        q = private_q pk
+        a = private_a pk
+        b = private_b pk
+        n = public_n $ private_pub pk
+        k = numBytes n
         c' = os2ip c
         solutions = rights $ toList $ mapTuple (unpad oaep k . i2ospOf_ k) $ sqroot' c' p q a b n
-     in if length solutions /= 1 then Nothing
-        else Just $ head solutions
-      where toList (w, x, y, z) = w:x:y:z:[]
-            mapTuple f (w, x, y, z) = (f w, f x, f y, f z)
+     in case solutions of
+            [x] -> Just x
+            _ -> Nothing
+  where
+    toList (w, x, y, z) = w : x : y : z : []
+    mapTuple f (w, x, y, z) = (f w, f x, f y, f z)
 
 -- | Sign message using padding, hash algorithm and private key.
 --
 -- See <https://en.wikipedia.org/wiki/Rabin_signature_algorithm>.
-signWith :: HashAlgorithm hash
-         => ByteString    -- ^ padding
-         -> PrivateKey    -- ^ private key
-         -> hash          -- ^ hash function
-         -> ByteString    -- ^ message to sign
-         -> Either Error Signature
+signWith
+    :: HashAlgorithm hash
+    => ByteString
+    -- ^ padding
+    -> PrivateKey
+    -- ^ private key
+    -> hash
+    -- ^ hash function
+    -> ByteString
+    -- ^ message to sign
+    -> Either Error Signature
 signWith padding pk hashAlg m = do
     h <- calculateHash padding pk hashAlg m
     signature <- calculateSignature h
@@ -142,61 +175,77 @@
   where
     calculateSignature h =
         let p = private_p pk
-            q = private_q pk     
-            a = private_a pk 
+            q = private_q pk
+            a = private_a pk
             b = private_b pk
             n = public_n $ private_pub pk
-         in if h >= n then Left MessageTooLong
-            else let (r, _, _, _) = sqroot' h p q a b n
-                  in Right $ Signature (os2ip padding, r)
+         in if h >= n
+                then Left MessageTooLong
+                else
+                    let (r, _, _, _) = sqroot' h p q a b n
+                     in Right $ Signature (os2ip padding, r)
 
 -- | Sign message using hash algorithm and private key.
 --
 -- See <https://en.wikipedia.org/wiki/Rabin_signature_algorithm>.
-sign :: (MonadRandom m, HashAlgorithm hash)
-     => PrivateKey    -- ^ private key
-     -> hash          -- ^ hash function
-     -> ByteString    -- ^ message to sign
-     -> m (Either Error Signature)
+sign
+    :: (MonadRandom m, HashAlgorithm hash)
+    => PrivateKey
+    -- ^ private key
+    -> hash
+    -- ^ hash function
+    -> ByteString
+    -- ^ message to sign
+    -> m (Either Error Signature)
 sign pk hashAlg m = do
     padding <- findPadding
     return $ signWith padding pk hashAlg m
-  where 
+  where
     findPadding = do
         padding <- getRandomBytes 8
         case calculateHash padding pk hashAlg m of
             Right _ -> return padding
-            _       -> findPadding
+            _ -> findPadding
 
 -- | Calculate hash of message and padding.
 -- If the padding is valid, then the result of the hash operation is returned, otherwise an error.
-calculateHash :: HashAlgorithm hash
-              => ByteString    -- ^ padding
-              -> PrivateKey    -- ^ private key
-              -> hash          -- ^ hash function
-              -> ByteString    -- ^ message to sign
-              -> Either Error Integer
-calculateHash padding pk hashAlg m = 
+calculateHash
+    :: HashAlgorithm hash
+    => ByteString
+    -- ^ padding
+    -> PrivateKey
+    -- ^ private key
+    -> hash
+    -- ^ hash function
+    -> ByteString
+    -- ^ message to sign
+    -> Either Error Integer
+calculateHash padding pk hashAlg m =
     let p = private_p pk
         q = private_q pk
         h = os2ip $ hashWith hashAlg $ B.append padding m
      in case (jacobi (h `mod` p) p, jacobi (h `mod` q) q) of
             (Just 1, Just 1) -> Right h
-            _                -> Left InvalidParameters
+            _ -> Left InvalidParameters
 
 -- | Verify signature using hash algorithm and public key.
 --
 -- See <https://en.wikipedia.org/wiki/Rabin_signature_algorithm>.
-verify :: HashAlgorithm hash
-       => PublicKey     -- ^ private key
-       -> hash          -- ^ hash function
-       -> ByteString    -- ^ message
-       -> Signature     -- ^ signature
-       -> Bool
+verify
+    :: HashAlgorithm hash
+    => PublicKey
+    -- ^ private key
+    -> hash
+    -- ^ hash function
+    -> ByteString
+    -- ^ message
+    -> Signature
+    -- ^ signature
+    -> Bool
 verify pk hashAlg m (Signature (padding, s)) =
-    let n  = public_n pk
-        p  = i2osp padding
-        h  = os2ip $ hashWith hashAlg $ B.append p m 
+    let n = public_n pk
+        p = i2osp padding
+        h = os2ip $ hashWith hashAlg $ B.append p m
         h' = expSafe s 2 n
      in h' == h
 
@@ -204,27 +253,35 @@
 -- Value a must be a quadratic residue modulo p (i.e. jacobi symbol (a/n) = 1).
 --
 -- See algorithm 3.36 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
-sqroot :: Integer
-       -> Integer   -- ^ prime p
-       -> (Integer, Integer)
+sqroot
+    :: Integer
+    -> Integer
+    -- ^ prime p
+    -> (Integer, Integer)
 sqroot a p =
     let r = expSafe a ((p + 1) `div` 4) p
      in (r, -r)
 
 -- | Square roots modulo n given its prime factors p and q (both congruent 3 mod 4)
 -- Value a must be a quadratic residue of both modulo p and modulo q (i.e. jacobi symbols (a/p) = (a/q) = 1).
--- 
+--
 -- See algorithm 3.44 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
-sqroot' :: Integer 
-        -> Integer  -- ^ prime p
-        -> Integer  -- ^ prime q
-        -> Integer  -- ^ c such that c*p + d*q = 1
-        -> Integer  -- ^ d such that c*p + d*q = 1
-        -> Integer  -- ^ n = p*q
-        -> (Integer, Integer, Integer, Integer)
+sqroot'
+    :: Integer
+    -> Integer
+    -- ^ prime p
+    -> Integer
+    -- ^ prime q
+    -> Integer
+    -- ^ c such that c*p + d*q = 1
+    -> Integer
+    -- ^ d such that c*p + d*q = 1
+    -> Integer
+    -- ^ n = p*q
+    -> (Integer, Integer, Integer, Integer)
 sqroot' a p q c d n =
     let (r, _) = sqroot a p
         (s, _) = sqroot a q
-        x      = (r*d*q + s*c*p) `mod` n
-        y      = (r*d*q - s*c*p) `mod` n
+        x = (r * d * q + s * c * p) `mod` n
+        y = (r * d * q - s * c * p) `mod` n
      in (x, (-x) `mod` n, y, (-y) `mod` n)
diff --git a/Crypto/PubKey/Rabin/Modified.hs b/Crypto/PubKey/Rabin/Modified.hs
--- a/Crypto/PubKey/Rabin/Modified.hs
+++ b/Crypto/PubKey/Rabin/Modified.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+
 -- |
 -- Module      : Crypto.PubKey.Rabin.Modified
 -- License     : BSD-style
@@ -7,95 +9,118 @@
 --
 -- Modified-Rabin public-key digital signature algorithm.
 -- See algorithm 11.30 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
---
-{-# LANGUAGE DeriveDataTypeable #-}
-module Crypto.PubKey.Rabin.Modified
-    ( PublicKey(..)
-    , PrivateKey(..)
-    , generate
-    , sign
-    , verify
-    ) where
+module Crypto.PubKey.Rabin.Modified (
+    PublicKey (..),
+    PrivateKey (..),
+    generate,
+    sign,
+    verify,
+) where
 
-import           Data.ByteString
-import           Data.Data
+import Data.ByteString
+import Data.Data
 
-import           Crypto.Hash
-import           Crypto.Number.ModArithmetic (expSafe, jacobi)
-import           Crypto.Number.Serialize (os2ip)
-import           Crypto.PubKey.Rabin.Types
-import           Crypto.Random.Types
+import Crypto.Hash
+import Crypto.Number.ModArithmetic (expSafe, jacobi)
+import Crypto.Number.Serialize (os2ip)
+import Crypto.PubKey.Rabin.Types
+import Crypto.Random.Types
 
 -- | Represent a Modified-Rabin public key.
 data PublicKey = PublicKey
-    { public_size :: Int      -- ^ size of key in bytes
-    , public_n    :: Integer  -- ^ public p*q
-    } deriving (Show, Read, Eq, Data)
+    { public_size :: Int
+    -- ^ size of key in bytes
+    , public_n :: Integer
+    -- ^ public p*q
+    }
+    deriving (Show, Read, Eq, Data)
 
 -- | Represent a Modified-Rabin private key.
 data PrivateKey = PrivateKey
     { private_pub :: PublicKey
-    , private_p   :: Integer   -- ^ p prime number
-    , private_q   :: Integer   -- ^ q prime number
-    , private_d   :: Integer
-    } deriving (Show, Read, Eq, Data)
+    , private_p :: Integer
+    -- ^ p prime number
+    , private_q :: Integer
+    -- ^ q prime number
+    , private_d :: Integer
+    }
+    deriving (Show, Read, Eq, Data)
 
 -- | Generate a pair of (private, public) key of size in bytes.
 -- Prime p is congruent 3 mod 8 and prime q is congruent 7 mod 8.
-generate :: MonadRandom m
-         => Int           
-         -> m (PublicKey, PrivateKey)
+generate
+    :: MonadRandom m
+    => Int
+    -> m (PublicKey, PrivateKey)
 generate size = do
     (p, q) <- generatePrimes size (\p -> p `mod` 8 == 3) (\q -> q `mod` 8 == 7)
     return $ generateKeys p q
-  where 
+  where
     generateKeys p q =
-        let n = p*q   
+        let n = p * q
             d = (n - p - q + 5) `div` 8
-            publicKey = PublicKey { public_size = size
-                                    , public_n    = n }
-            privateKey = PrivateKey { private_pub = publicKey
-                                    , private_p   = p
-                                    , private_q   = q
-                                    , private_d   = d }
-            in (publicKey, privateKey)
+            publicKey =
+                PublicKey
+                    { public_size = size
+                    , public_n = n
+                    }
+            privateKey =
+                PrivateKey
+                    { private_pub = publicKey
+                    , private_p = p
+                    , private_q = q
+                    , private_d = d
+                    }
+         in (publicKey, privateKey)
 
 -- | Sign message using hash algorithm and private key.
-sign :: HashAlgorithm hash
-     => PrivateKey    -- ^ private key
-     -> hash          -- ^ hash function
-     -> ByteString    -- ^ message to sign
-     -> Either Error Integer
+sign
+    :: HashAlgorithm hash
+    => PrivateKey
+    -- ^ private key
+    -> hash
+    -- ^ hash function
+    -> ByteString
+    -- ^ message to sign
+    -> Either Error Integer
 sign pk hashAlg m =
     let d = private_d pk
         n = public_n $ private_pub pk
         h = os2ip $ hashWith hashAlg m
         limit = (n - 6) `div` 16
-     in if h > limit then Left MessageTooLong
-        else let h' = 16*h + 6
-              in case jacobi h' n of
-                    Just 1    -> Right $ expSafe h' d n
-                    Just (-1) -> Right $ expSafe (h' `div` 2) d n
-                    _         -> Left InvalidParameters
+     in if h > limit
+            then Left MessageTooLong
+            else
+                let h' = 16 * h + 6
+                 in case jacobi h' n of
+                        Just 1 -> Right $ expSafe h' d n
+                        Just (-1) -> Right $ expSafe (h' `div` 2) d n
+                        _ -> Left InvalidParameters
 
 -- | Verify signature using hash algorithm and public key.
-verify :: HashAlgorithm hash
-       => PublicKey     -- ^ public key
-       -> hash          -- ^ hash function
-       -> ByteString    -- ^ message
-       -> Integer       -- ^ signature
-       -> Bool
+verify
+    :: HashAlgorithm hash
+    => PublicKey
+    -- ^ public key
+    -> hash
+    -- ^ hash function
+    -> ByteString
+    -- ^ message
+    -> Integer
+    -- ^ signature
+    -> Bool
 verify pk hashAlg m s =
-    let n   = public_n pk
-        h   = os2ip $ hashWith hashAlg m
-        s'  = expSafe s 2 n
+    let n = public_n pk
+        h = os2ip $ hashWith hashAlg m
+        s' = expSafe s 2 n
         s'' = case s' `mod` 8 of
             6 -> s'
-            3 -> 2*s'
+            3 -> 2 * s'
             7 -> n - s'
-            2 -> 2*(n - s')
+            2 -> 2 * (n - s')
             _ -> 0
      in case s'' `mod` 16 of
-            6 -> let h' = (s'' - 6) `div` 16
-                  in h' == h 
+            6 ->
+                let h' = (s'' - 6) `div` 16
+                 in h' == h
             _ -> False
diff --git a/Crypto/PubKey/Rabin/OAEP.hs b/Crypto/PubKey/Rabin/OAEP.hs
--- a/Crypto/PubKey/Rabin/OAEP.hs
+++ b/Crypto/PubKey/Rabin/OAEP.hs
@@ -7,94 +7,111 @@
 --
 -- OAEP padding scheme.
 -- See <http://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding>.
---
-module Crypto.PubKey.Rabin.OAEP
-    ( OAEPParams(..)
-    , defaultOAEPParams
-    , pad
-    , unpad
-    ) where
-        
-import           Data.ByteString (ByteString)
+module Crypto.PubKey.Rabin.OAEP (
+    OAEPParams (..),
+    defaultOAEPParams,
+    pad,
+    unpad,
+) where
+
+import Data.Bits (xor)
+import Data.ByteString (ByteString)
 import qualified Data.ByteString as B
-import           Data.Bits (xor)
 
-import           Crypto.Hash
-import           Crypto.Internal.ByteArray (ByteArrayAccess, ByteArray)
+import Crypto.Hash
+import Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess)
 import qualified Crypto.Internal.ByteArray as B (convert)
-import           Crypto.PubKey.MaskGenFunction
-import           Crypto.PubKey.Internal (and')
-import           Crypto.PubKey.Rabin.Types
+import Crypto.PubKey.Internal (and')
+import Crypto.PubKey.MaskGenFunction
+import Crypto.PubKey.Rabin.Types
 
 -- | Parameters for OAEP padding.
 data OAEPParams hash seed output = OAEPParams
-    { oaepHash       :: hash                            -- ^ hash function to use
-    , oaepMaskGenAlg :: MaskGenAlgorithm seed output    -- ^ mask Gen algorithm to use
-    , oaepLabel      :: Maybe ByteString                -- ^ optional label prepended to message
+    { oaepHash :: hash
+    -- ^ hash function to use
+    , oaepMaskGenAlg :: MaskGenAlgorithm seed output
+    -- ^ mask Gen algorithm to use
+    , oaepLabel :: Maybe ByteString
+    -- ^ optional label prepended to message
     }
 
 -- | Default Params with a specified hash function.
-defaultOAEPParams :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash)
-                  => hash
-                  -> OAEPParams hash seed output
+defaultOAEPParams
+    :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash)
+    => hash
+    -> OAEPParams hash seed output
 defaultOAEPParams hashAlg =
-    OAEPParams { oaepHash       = hashAlg
-               , oaepMaskGenAlg = mgf1 hashAlg
-               , oaepLabel      = Nothing
-               }
+    OAEPParams
+        { oaepHash = hashAlg
+        , oaepMaskGenAlg = mgf1 hashAlg
+        , oaepLabel = Nothing
+        }
 
 -- | Pad a message using OAEP.
-pad :: HashAlgorithm hash
-    => ByteString                               -- ^ Seed
-    -> OAEPParams hash ByteString ByteString    -- ^ OAEP params to use
-    -> Int                                      -- ^ size of public key in bytes
-    -> ByteString                               -- ^ Message pad
+pad
+    :: HashAlgorithm hash
+    => ByteString
+    -- ^ Seed
+    -> OAEPParams hash ByteString ByteString
+    -- ^ OAEP params to use
+    -> Int
+    -- ^ size of public key in bytes
+    -> ByteString
+    -- ^ Message pad
     -> Either Error ByteString
 pad seed oaep k msg
-    | k < 2*hashLen+2          = Left InvalidParameters
+    | k < 2 * hashLen + 2 = Left InvalidParameters
     | B.length seed /= hashLen = Left InvalidParameters
-    | mLen > k - 2*hashLen-2   = Left MessageTooLong
-    | otherwise                = Right em
-    where -- parameters
-        mLen       = B.length msg
-        mgf        = oaepMaskGenAlg oaep
-        labelHash  = hashWith (oaepHash oaep) (maybe B.empty id $ oaepLabel oaep)
-        hashLen    = hashDigestSize (oaepHash oaep)
-        -- put fields
-        ps         = B.replicate (k - mLen - 2*hashLen - 2) 0
-        db         = B.concat [B.convert labelHash, ps, B.singleton 0x1, msg]
-        dbmask     = mgf seed (k - hashLen - 1)
-        maskedDB   = B.pack $ B.zipWith xor db dbmask
-        seedMask   = mgf maskedDB hashLen
-        maskedSeed = B.pack $ B.zipWith xor seed seedMask
-        em         = B.concat [B.singleton 0x0, maskedSeed, maskedDB]
+    | mLen > k - 2 * hashLen - 2 = Left MessageTooLong
+    | otherwise = Right em
+  where
+    -- parameters
+    mLen = B.length msg
+    mgf = oaepMaskGenAlg oaep
+    labelHash = hashWith (oaepHash oaep) (maybe B.empty id $ oaepLabel oaep)
+    hashLen = hashDigestSize (oaepHash oaep)
+    -- put fields
+    ps = B.replicate (k - mLen - 2 * hashLen - 2) 0
+    db = B.concat [B.convert labelHash, ps, B.singleton 0x1, msg]
+    dbmask = mgf seed (k - hashLen - 1)
+    maskedDB = B.pack $ B.zipWith xor db dbmask
+    seedMask = mgf maskedDB hashLen
+    maskedSeed = B.pack $ B.zipWith xor seed seedMask
+    em = B.concat [B.singleton 0x0, maskedSeed, maskedDB]
 
 -- | Un-pad a OAEP encoded message.
-unpad :: HashAlgorithm hash
-      => OAEPParams hash ByteString ByteString  -- ^ OAEP params to use
-      -> Int                                    -- ^ size of public key in bytes
-      -> ByteString                             -- ^ encoded message (not encrypted)
-      -> Either Error ByteString
+unpad
+    :: HashAlgorithm hash
+    => OAEPParams hash ByteString ByteString
+    -- ^ OAEP params to use
+    -> Int
+    -- ^ size of public key in bytes
+    -> ByteString
+    -- ^ encoded message (not encrypted)
+    -> Either Error ByteString
 unpad oaep k em
     | paddingSuccess = Right msg
-    | otherwise      = Left MessageNotRecognized
-    where -- parameters
-        mgf        = oaepMaskGenAlg oaep
-        labelHash  = B.convert $ hashWith (oaepHash oaep) (maybe B.empty id $ oaepLabel oaep)
-        hashLen    = hashDigestSize (oaepHash oaep)
-        -- getting em's fields
-        (pb, em0)  = B.splitAt 1 em
-        (maskedSeed, maskedDB) = B.splitAt hashLen em0
-        seedMask   = mgf maskedDB hashLen
-        seed       = B.pack $ B.zipWith xor maskedSeed seedMask
-        dbmask     = mgf seed (k - hashLen - 1)
-        db         = B.pack $ B.zipWith xor maskedDB dbmask
-        -- getting db's fields
-        (labelHash', db1) = B.splitAt hashLen db
-        (_, db2)   = B.break (/= 0) db1
-        (ps1, msg) = B.splitAt 1 db2
+    | otherwise = Left MessageNotRecognized
+  where
+    -- parameters
+    mgf = oaepMaskGenAlg oaep
+    labelHash = B.convert $ hashWith (oaepHash oaep) (maybe B.empty id $ oaepLabel oaep)
+    hashLen = hashDigestSize (oaepHash oaep)
+    -- getting em's fields
+    (pb, em0) = B.splitAt 1 em
+    (maskedSeed, maskedDB) = B.splitAt hashLen em0
+    seedMask = mgf maskedDB hashLen
+    seed = B.pack $ B.zipWith xor maskedSeed seedMask
+    dbmask = mgf seed (k - hashLen - 1)
+    db = B.pack $ B.zipWith xor maskedDB dbmask
+    -- getting db's fields
+    (labelHash', db1) = B.splitAt hashLen db
+    (_, db2) = B.break (/= 0) db1
+    (ps1, msg) = B.splitAt 1 db2
 
-        paddingSuccess = and' [ labelHash' == labelHash -- no need for constant eq
-                              , ps1        == B.replicate 1 0x1
-                              , pb         == B.replicate 1 0x0
-                              ]
+    paddingSuccess =
+        and'
+            [ labelHash' == labelHash -- no need for constant eq
+            , ps1 == B.replicate 1 0x1
+            , pb == B.replicate 1 0x0
+            ]
diff --git a/Crypto/PubKey/Rabin/RW.hs b/Crypto/PubKey/Rabin/RW.hs
--- a/Crypto/PubKey/Rabin/RW.hs
+++ b/Crypto/PubKey/Rabin/RW.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+
 -- |
 -- Module      : Crypto.PubKey.Rabin.RW
 -- License     : BSD-style
@@ -5,147 +7,180 @@
 -- Stability   : experimental
 -- Portability : unknown
 --
--- Rabin-Williams cryptosystem for public-key encryption and digital signature. 
+-- Rabin-Williams cryptosystem for public-key encryption and digital signature.
 -- See pages 323 - 324 in "Computational Number Theory and Modern Cryptography" by Song Y. Yan.
 -- Also inspired by https://github.com/vanilala/vncrypt/blob/master/vncrypt/vnrw_gmp.c.
--- 
-{-# LANGUAGE DeriveDataTypeable #-}
-module Crypto.PubKey.Rabin.RW
-    ( PublicKey(..)
-    , PrivateKey(..)
-    , generate
-    , encrypt
-    , encryptWithSeed
-    , decrypt
-    , sign
-    , verify
-    ) where
+module Crypto.PubKey.Rabin.RW (
+    PublicKey (..),
+    PrivateKey (..),
+    generate,
+    encrypt,
+    encryptWithSeed,
+    decrypt,
+    sign,
+    verify,
+) where
 
-import           Data.ByteString
-import           Data.Data
+import Data.ByteString
+import Data.Data
 
-import           Crypto.Hash
-import           Crypto.Number.Basic (numBytes)
-import           Crypto.Number.ModArithmetic (expSafe, jacobi)
-import           Crypto.Number.Serialize (i2osp, i2ospOf_, os2ip)
-import           Crypto.PubKey.Rabin.OAEP
-import           Crypto.PubKey.Rabin.Types
-import           Crypto.Random.Types
+import Crypto.Hash
+import Crypto.Number.Basic (numBytes)
+import Crypto.Number.ModArithmetic (expSafe, jacobi)
+import Crypto.Number.Serialize (i2osp, i2ospOf_, os2ip)
+import Crypto.PubKey.Rabin.OAEP
+import Crypto.PubKey.Rabin.Types
+import Crypto.Random.Types
 
 -- | Represent a Rabin-Williams public key.
 data PublicKey = PublicKey
-    { public_size :: Int      -- ^ size of key in bytes
-    , public_n    :: Integer  -- ^ public p*q
-    } deriving (Show, Read, Eq, Data)
+    { public_size :: Int
+    -- ^ size of key in bytes
+    , public_n :: Integer
+    -- ^ public p*q
+    }
+    deriving (Show, Read, Eq, Data)
 
 -- | Represent a Rabin-Williams private key.
 data PrivateKey = PrivateKey
     { private_pub :: PublicKey
-    , private_p   :: Integer   -- ^ p prime number
-    , private_q   :: Integer   -- ^ q prime number
-    , private_d   :: Integer
-    } deriving (Show, Read, Eq, Data)
+    , private_p :: Integer
+    -- ^ p prime number
+    , private_q :: Integer
+    -- ^ q prime number
+    , private_d :: Integer
+    }
+    deriving (Show, Read, Eq, Data)
 
 -- | Generate a pair of (private, public) key of size in bytes.
 -- Prime p is congruent 3 mod 8 and prime q is congruent 7 mod 8.
-generate :: MonadRandom m
-         => Int           
-         -> m (PublicKey, PrivateKey)
+generate
+    :: MonadRandom m
+    => Int
+    -> m (PublicKey, PrivateKey)
 generate size = do
-    (p, q) <- generatePrimes size (\p -> p `mod` 8 == 3) (\q -> q `mod` 8 == 7) 
+    (p, q) <- generatePrimes size (\p -> p `mod` 8 == 3) (\q -> q `mod` 8 == 7)
     return (generateKeys p q)
-  where 
+  where
     generateKeys p q =
-        let n = p*q   
-            d = ((p - 1)*(q - 1) `div` 4 + 1) `div` 2
-            publicKey = PublicKey { public_size = size
-                                    , public_n    = n }
-            privateKey = PrivateKey { private_pub = publicKey
-                                    , private_p   = p
-                                    , private_q   = q
-                                    , private_d   = d }
-            in (publicKey, privateKey)
+        let n = p * q
+            d = ((p - 1) * (q - 1) `div` 4 + 1) `div` 2
+            publicKey =
+                PublicKey
+                    { public_size = size
+                    , public_n = n
+                    }
+            privateKey =
+                PrivateKey
+                    { private_pub = publicKey
+                    , private_p = p
+                    , private_q = q
+                    , private_d = d
+                    }
+         in (publicKey, privateKey)
 
 -- | Encrypt plaintext using public key an a predefined OAEP seed.
 --
 -- See algorithm 8.11 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
-encryptWithSeed :: HashAlgorithm hash
-                => ByteString                               -- ^ Seed
-                -> OAEPParams hash ByteString ByteString    -- ^ OAEP padding
-                -> PublicKey                                -- ^ public key
-                -> ByteString                               -- ^ plaintext
-                -> Either Error ByteString
+encryptWithSeed
+    :: HashAlgorithm hash
+    => ByteString
+    -- ^ Seed
+    -> OAEPParams hash ByteString ByteString
+    -- ^ OAEP padding
+    -> PublicKey
+    -- ^ public key
+    -> ByteString
+    -- ^ plaintext
+    -> Either Error ByteString
 encryptWithSeed seed oaep pk m =
     let n = public_n pk
         k = numBytes n
      in do
-        m'  <- pad seed oaep k m
-        m'' <- ep1 n $ os2ip m'
-        return $ i2osp $ ep2 n m''
+            m' <- pad seed oaep k m
+            m'' <- ep1 n $ os2ip m'
+            return $ i2osp $ ep2 n m''
 
 -- | Encrypt plaintext using public key.
-encrypt :: (HashAlgorithm hash, MonadRandom m)
-        => OAEPParams hash ByteString ByteString    -- ^ OAEP padding parameters
-        -> PublicKey                                -- ^ public key
-        -> ByteString                               -- ^ plaintext 
-        -> m (Either Error ByteString)
+encrypt
+    :: (HashAlgorithm hash, MonadRandom m)
+    => OAEPParams hash ByteString ByteString
+    -- ^ OAEP padding parameters
+    -> PublicKey
+    -- ^ public key
+    -> ByteString
+    -- ^ plaintext
+    -> m (Either Error ByteString)
 encrypt oaep pk m = do
     seed <- getRandomBytes hashLen
     return $ encryptWithSeed seed oaep pk m
   where
-    hashLen = hashDigestSize (oaepHash oaep)   
+    hashLen = hashDigestSize (oaepHash oaep)
 
 -- | Decrypt ciphertext using private key.
-decrypt :: HashAlgorithm hash
-        => OAEPParams hash ByteString ByteString    -- ^ OAEP padding parameters
-        -> PrivateKey                               -- ^ private key
-        -> ByteString                               -- ^ ciphertext
-        -> Maybe ByteString
+decrypt
+    :: HashAlgorithm hash
+    => OAEPParams hash ByteString ByteString
+    -- ^ OAEP padding parameters
+    -> PrivateKey
+    -- ^ private key
+    -> ByteString
+    -- ^ ciphertext
+    -> Maybe ByteString
 decrypt oaep pk c =
-    let d  = private_d pk    
-        n  = public_n $ private_pub pk
-        k  = numBytes n
+    let d = private_d pk
+        n = public_n $ private_pub pk
+        k = numBytes n
         c' = i2ospOf_ k $ dp2 n $ dp1 d n $ os2ip c
      in case unpad oaep k c' of
-            Left _  -> Nothing
-            Right p -> Just p   
+            Left _ -> Nothing
+            Right p -> Just p
 
 -- | Sign message using hash algorithm and private key.
-sign :: HashAlgorithm hash
-     => PrivateKey  -- ^ private key
-     -> hash        -- ^ hash function
-     -> ByteString  -- ^ message to sign
-     -> Either Error Integer
+sign
+    :: HashAlgorithm hash
+    => PrivateKey
+    -- ^ private key
+    -> hash
+    -- ^ hash function
+    -> ByteString
+    -- ^ message to sign
+    -> Either Error Integer
 sign pk hashAlg m =
     let d = private_d pk
         n = public_n $ private_pub pk
      in do
-        m' <- ep1 n $ os2ip $ hashWith hashAlg m
-        return $ dp1 d n m' 
+            m' <- ep1 n $ os2ip $ hashWith hashAlg m
+            return $ dp1 d n m'
 
 -- | Verify signature using hash algorithm and public key.
-verify :: HashAlgorithm hash
-       => PublicKey     -- ^ public key
-       -> hash          -- ^ hash function
-       -> ByteString    -- ^ message
-       -> Integer       -- ^ signature
-       -> Bool
+verify
+    :: HashAlgorithm hash
+    => PublicKey
+    -- ^ public key
+    -> hash
+    -- ^ hash function
+    -> ByteString
+    -- ^ message
+    -> Integer
+    -- ^ signature
+    -> Bool
 verify pk hashAlg m s =
-    let n  = public_n pk
-        h  = os2ip $ hashWith hashAlg m
+    let n = public_n pk
+        h = os2ip $ hashWith hashAlg m
         h' = dp2 n $ ep2 n s
      in h' == h
 
 -- | Encryption primitive 1
 ep1 :: Integer -> Integer -> Either Error Integer
 ep1 n m =
-    let m'   = 2*m + 1
-        m''  = 2*m'
-        m''' = 2*m''
+    let m' = 2 * m + 1
+        m'' = 2 * m'
+        m''' = 2 * m''
      in case jacobi m' n of
             Just (-1) | m'' < n -> Right m''
-            Just 1 | m''' < n   -> Right m'''
-            _                   -> Left InvalidParameters
+            Just 1 | m''' < n -> Right m'''
+            _ -> Left InvalidParameters
 
 -- | Encryption primitive 2
 ep2 :: Integer -> Integer -> Integer
@@ -157,10 +192,11 @@
 
 -- | Decryption primitive 2
 dp2 :: Integer -> Integer -> Integer
-dp2 n c = let c'  = c `div` 2
-              c'' = (n - c) `div` 2
-           in case c `mod` 4 of
-                0 -> ((c' `div` 2 - 1) `div` 2)
-                1 -> ((c'' `div` 2 - 1) `div` 2)
-                2 -> ((c' - 1) `div` 2)
-                _ -> ((c'' - 1) `div` 2)
+dp2 n c =
+    let c' = c `div` 2
+        c'' = (n - c) `div` 2
+     in case c `mod` 4 of
+            0 -> ((c' `div` 2 - 1) `div` 2)
+            1 -> ((c'' `div` 2 - 1) `div` 2)
+            2 -> ((c' - 1) `div` 2)
+            _ -> ((c'' - 1) `div` 2)
diff --git a/Crypto/PubKey/Rabin/Types.hs b/Crypto/PubKey/Rabin/Types.hs
--- a/Crypto/PubKey/Rabin/Types.hs
+++ b/Crypto/PubKey/Rabin/Types.hs
@@ -4,40 +4,49 @@
 -- Maintainer  : Carlos Rodriguez-Vega <crodveg@yahoo.es>
 -- Stability   : experimental
 -- Portability : unknown
---
-module Crypto.PubKey.Rabin.Types
-    ( Error(..)
-    , generatePrimes
-    ) where
+module Crypto.PubKey.Rabin.Types (
+    Error (..),
+    generatePrimes,
+) where
 
 import Crypto.Number.Basic (numBits)
-import Crypto.Number.Prime (generatePrime, findPrimeFromWith)
+import Crypto.Number.Prime (findPrimeFromWith, generatePrime)
 import Crypto.Random.Types
 
 type PrimeCondition = Integer -> Bool
 
 -- | Error possible during encryption, decryption or signing.
-data Error = MessageTooLong       -- ^ the message to encrypt is too long
-           | MessageNotRecognized -- ^ the message decrypted doesn't have a OAEP structure
-           | InvalidParameters    -- ^ some parameters lead to breaking assumptions
-           deriving (Show, Eq)
+data Error
+    = -- | the message to encrypt is too long
+      MessageTooLong
+    | -- | the message decrypted doesn't have a OAEP structure
+      MessageNotRecognized
+    | -- | some parameters lead to breaking assumptions
+      InvalidParameters
+    deriving (Show, Eq)
 
 -- | Generate primes p & q
-generatePrimes :: MonadRandom m 
-               => Int                   -- ^ size in bytes          
-               -> PrimeCondition        -- ^ condition prime p must satisfy
-               -> PrimeCondition        -- ^ condition prime q must satisfy
-               -> m (Integer, Integer)  -- ^ chosen distinct primes p and q
+generatePrimes
+    :: MonadRandom m
+    => Int
+    -- ^ size in bytes
+    -> PrimeCondition
+    -- ^ condition prime p must satisfy
+    -> PrimeCondition
+    -- ^ condition prime q must satisfy
+    -> m (Integer, Integer)
+    -- ^ chosen distinct primes p and q
 generatePrimes size pCond qCond =
-    let pBits = (8*(size `div` 2))
-        qBits = (8*(size - (size `div` 2)))
+    let pBits = (8 * (size `div` 2))
+        qBits = (8 * (size - (size `div` 2)))
      in do
-        p <- generatePrime' pBits pCond
-        q <- generatePrime' qBits qCond
-        return (p, q)
-      where
-        generatePrime' bits cond = do
-            pr' <- generatePrime bits
-            let pr = findPrimeFromWith cond pr'
-            if numBits pr == bits then return pr
+            p <- generatePrime' pBits pCond
+            q <- generatePrime' qBits qCond
+            return (p, q)
+  where
+    generatePrime' bits cond = do
+        pr' <- generatePrime bits
+        let pr = findPrimeFromWith cond pr'
+        if numBits pr == bits
+            then return pr
             else generatePrime' bits cond
diff --git a/Crypto/Random.hs b/Crypto/Random.hs
--- a/Crypto/Random.hs
+++ b/Crypto/Random.hs
@@ -1,46 +1,55 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.Random
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : stable
 -- Portability : good
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.Random
-    (
+module Crypto.Random (
     -- * Deterministic instances
-      ChaChaDRG
-    , SystemDRG
-    , Seed
+    ChaChaDRG,
+    SystemDRG,
+    Seed,
+
     -- * Seed
-    , seedNew
-    , seedFromInteger
-    , seedToInteger
-    , seedFromBinary
+    seedNew,
+    seedFromInteger,
+    seedToInteger,
+    seedFromBinary,
+
     -- * Deterministic Random class
-    , getSystemDRG
-    , drgNew
-    , drgNewSeed
-    , drgNewTest
-    , withDRG
-    , withRandomBytes
-    , DRG(..)
+    getSystemDRG,
+    drgNew,
+    drgNewSeed,
+    drgNewTest,
+    withDRG,
+    withRandomBytes,
+    DRG (..),
+
     -- * Random abstraction
-    , MonadRandom(..)
-    , MonadPseudoRandom
-    ) where
+    MonadRandom (..),
+    MonadPseudoRandom,
+) where
 
 import Crypto.Error
-import Crypto.Random.Types
+import Crypto.Internal.Imports
 import Crypto.Random.ChaChaDRG
 import Crypto.Random.SystemDRG
+import Crypto.Random.Types
 import Data.ByteArray (ByteArray, ByteArrayAccess, ScrubbedBytes)
 import qualified Data.ByteArray as B
-import Crypto.Internal.Imports
-import Crypto.Hash (Digest, SHA512, hash)
 
 import qualified Crypto.Number.Serialize as Serialize
 
+#ifdef INSECURE_ENTROPY
+import Crypto.Hash (SHA512, Context)
+import Crypto.Hash.IO
+import Data.Memory.PtrMethods (memSet)
+import Foreign.Ptr (Ptr, castPtr)
+#endif
+
 newtype Seed = Seed ScrubbedBytes
     deriving (ByteArrayAccess)
 
@@ -50,27 +59,43 @@
 
 -- | Create a new Seed from system entropy
 seedNew :: MonadRandom randomly => randomly Seed
+
+#ifdef INSECURE_ENTROPY
 -- The degree of its randomness depends on the source, e.g. for iOS we
 -- have to compile with DoNotUseEntropy flag, as iOS doesn't allow
 -- using getentropy, and on some other systems it can be also
 -- potentially comprisable sources. Hashing of entropy before using
 -- it as a seed is a common mitigation for attacks via RNG/entropy
 -- source.
-seedNew = (Seed . B.take seedLength . B.convert . (hash :: ScrubbedBytes -> Digest SHA512)) `fmap` getRandomBytes 64
+seedNew = (Seed . scrubbedHash512) `fmap` getRandomBytes 64
 
+scrubbedHash512 :: ScrubbedBytes -> ScrubbedBytes
+scrubbedHash512 = B.take seedLength . hash512
+  where
+    hash512 ba = B.unsafeCreate (hashDigestSize (undefined :: SHA512)) $ hashIO ba
+    hashIO ba ptr = do
+        ctx <- hashMutableInit
+        hashMutableUpdate (ctx :: MutableContext SHA512) ba
+        B.withByteArray ctx $ \pctx -> do
+            hashInternalFinalize (castPtr pctx :: Ptr (Context SHA512)) ptr
+            memSet pctx 0 $ hashInternalContextSize (undefined :: SHA512)
+#else
+seedNew = Seed `fmap` getRandomBytes seedLength
+#endif
+
 -- | Convert a Seed to an integer
 seedToInteger :: Seed -> Integer
 seedToInteger (Seed b) = Serialize.os2ip b
 
 -- | Convert an integer to a Seed
 seedFromInteger :: Integer -> Seed
-seedFromInteger i = Seed $ Serialize.i2ospOf_ seedLength (i `mod` 2^(seedLength * 8))
+seedFromInteger i = Seed $ Serialize.i2ospOf_ seedLength (i `mod` 2 ^ (seedLength * 8))
 
 -- | Convert a binary to a seed
 seedFromBinary :: ByteArrayAccess b => b -> CryptoFailable Seed
 seedFromBinary b
     | B.length b /= 40 = CryptoFailed (CryptoError_SeedSizeInvalid)
-    | otherwise        = CryptoPassed $ Seed $ B.convert b
+    | otherwise = CryptoPassed $ Seed $ B.convert b
 
 -- | Create a new DRG from system entropy
 drgNew :: MonadRandom randomly => randomly ChaChaDRG
@@ -102,4 +127,5 @@
 -- This is equivalent to use Control.Arrow 'first' with 'randomBytesGenerate'
 withRandomBytes :: (ByteArray ba, DRG g) => g -> Int -> (ba -> a) -> (a, g)
 withRandomBytes rng len f = (f bs, rng')
-  where (bs, rng') = randomBytesGenerate len rng
+  where
+    (bs, rng') = randomBytesGenerate len rng
diff --git a/Crypto/Random/ChaChaDRG.hs b/Crypto/Random/ChaChaDRG.hs
--- a/Crypto/Random/ChaChaDRG.hs
+++ b/Crypto/Random/ChaChaDRG.hs
@@ -1,22 +1,26 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
 -- |
 -- Module      : Crypto.Random.ChaChaDRG
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : stable
 -- Portability : good
---
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-module Crypto.Random.ChaChaDRG
-    ( ChaChaDRG
-    , initialize
-    , initializeWords
-    ) where
+module Crypto.Random.ChaChaDRG (
+    ChaChaDRG,
+    initialize,
+    initializeWords,
+) where
 
-import           Crypto.Random.Types
-import           Crypto.Internal.Imports
-import           Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, ScrubbedBytes)
+import Crypto.Internal.ByteArray (
+    ByteArray,
+    ByteArrayAccess,
+    ScrubbedBytes,
+ )
 import qualified Crypto.Internal.ByteArray as B
-import           Foreign.Storable (pokeElemOff)
+import Crypto.Internal.Imports
+import Crypto.Random.Types
+import Foreign.Storable (pokeElemOff)
 
 import qualified Crypto.Cipher.ChaCha as C
 
@@ -29,18 +33,24 @@
 
 -- | Initialize a new ChaCha context with the number of rounds,
 -- the key and the nonce associated.
-initialize :: ByteArrayAccess seed
-           => seed        -- ^ 40 bytes of seed
-           -> ChaChaDRG   -- ^ the initial ChaCha state
+initialize
+    :: ByteArrayAccess seed
+    => seed
+    -- ^ 40 bytes of seed
+    -> ChaChaDRG
+    -- ^ the initial ChaCha state
 initialize seed = ChaChaDRG $ C.initializeSimple seed
 
 -- | Initialize a new ChaCha context from 5-tuple of words64.
 -- This interface is useful when creating a RNG out of tests generators (e.g. QuickCheck).
 initializeWords :: (Word64, Word64, Word64, Word64, Word64) -> ChaChaDRG
-initializeWords (a,b,c,d,e) = initialize (B.allocAndFreeze 40 fill :: ScrubbedBytes)
-  where fill s = mapM_ (uncurry (pokeElemOff s)) [(0,a), (1,b), (2,c), (3,d), (4,e)]
+initializeWords (a, b, c, d, e) = initialize (B.allocAndFreeze 40 fill :: ScrubbedBytes)
+  where
+    fill s = mapM_ (uncurry (pokeElemOff s)) [(0, a), (1, b), (2, c), (3, d), (4, e)]
 
 generate :: ByteArray output => Int -> ChaChaDRG -> (output, ChaChaDRG)
 generate nbBytes st@(ChaChaDRG prevSt)
     | nbBytes <= 0 = (B.empty, st)
-    | otherwise    = let (output, newSt) = C.generateSimple prevSt nbBytes in (output, ChaChaDRG newSt)
+    | otherwise =
+        let (output, newSt) = C.generateSimple prevSt nbBytes
+         in (output, ChaChaDRG newSt)
diff --git a/Crypto/Random/Entropy.hs b/Crypto/Random/Entropy.hs
--- a/Crypto/Random/Entropy.hs
+++ b/Crypto/Random/Entropy.hs
@@ -4,16 +4,15 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.Random.Entropy
-    ( getEntropy
-    ) where
+module Crypto.Random.Entropy (
+    getEntropy,
+) where
 
-import           Data.Maybe (catMaybes)
-import           Crypto.Internal.ByteArray (ByteArray)
+import Crypto.Internal.ByteArray (ByteArray)
 import qualified Crypto.Internal.ByteArray as B
+import Data.Maybe (catMaybes)
 
-import           Crypto.Random.Entropy.Unsafe
+import Crypto.Random.Entropy.Unsafe
 
 -- | Get some entropy from the system source of entropy
 getEntropy :: ByteArray byteArray => Int -> IO byteArray
diff --git a/Crypto/Random/Entropy/RDRand.hs b/Crypto/Random/Entropy/RDRand.hs
--- a/Crypto/Random/Entropy/RDRand.hs
+++ b/Crypto/Random/Entropy/RDRand.hs
@@ -1,38 +1,39 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+
 -- |
 -- Module      : Crypto.Random.Entropy.RDRand
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-{-# LANGUAGE ForeignFunctionInterface #-}
-module Crypto.Random.Entropy.RDRand
-    ( RDRand
-    ) where
+module Crypto.Random.Entropy.RDRand (
+    RDRand,
+) where
 
-import Foreign.Ptr
-import Foreign.C.Types
-import Data.Word (Word8)
 import Crypto.Random.Entropy.Source
+import Data.Word (Word8)
+import Foreign.C.Types
+import Foreign.Ptr
 
 foreign import ccall unsafe "crypton_cpu_has_rdrand"
-   c_cpu_has_rdrand :: IO CInt
+    c_cpu_has_rdrand :: IO CInt
 
 foreign import ccall unsafe "crypton_get_rand_bytes"
-  c_get_rand_bytes :: Ptr Word8 -> CInt -> IO CInt
+    c_get_rand_bytes :: Ptr Word8 -> CInt -> IO CInt
 
 -- | Fake handle to Intel RDRand entropy CPU instruction
 data RDRand = RDRand
 
 instance EntropySource RDRand where
-    entropyOpen     = rdrandGrab
+    entropyOpen = rdrandGrab
     entropyGather _ = rdrandGetBytes
-    entropyClose  _ = return ()
+    entropyClose _ = return ()
 
 rdrandGrab :: IO (Maybe RDRand)
 rdrandGrab = supported `fmap` c_cpu_has_rdrand
-  where supported 0 = Nothing
-        supported _ = Just RDRand
+  where
+    supported 0 = Nothing
+    supported _ = Just RDRand
 
 rdrandGetBytes :: Ptr Word8 -> Int -> IO Int
 rdrandGetBytes ptr sz = fromIntegral `fmap` c_get_rand_bytes ptr (fromIntegral sz)
diff --git a/Crypto/Random/Entropy/Source.hs b/Crypto/Random/Entropy/Source.hs
--- a/Crypto/Random/Entropy/Source.hs
+++ b/Crypto/Random/Entropy/Source.hs
@@ -4,19 +4,20 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
 module Crypto.Random.Entropy.Source where
 
-import Foreign.Ptr
 import Data.Word (Word8)
+import Foreign.Ptr
 
 -- | A handle to an entropy maker, either a system capability
 -- or a hardware generator.
 class EntropySource a where
     -- | Try to open an handle for this source
-    entropyOpen   :: IO (Maybe a)
+    entropyOpen :: IO (Maybe a)
+
     -- | Try to gather a number of entropy bytes into a buffer.
     -- Return the number of actual bytes gathered
     entropyGather :: a -> Ptr Word8 -> Int -> IO Int
+
     -- | Close an open handle
-    entropyClose  :: a -> IO ()
+    entropyClose :: a -> IO ()
diff --git a/Crypto/Random/Entropy/Unix.hs b/Crypto/Random/Entropy/Unix.hs
--- a/Crypto/Random/Entropy/Unix.hs
+++ b/Crypto/Random/Entropy/Unix.hs
@@ -1,29 +1,29 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- |
 -- Module      : Crypto.Random.Entropy.Unix
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-{-# LANGUAGE ScopedTypeVariables #-}
-module Crypto.Random.Entropy.Unix
-    ( DevRandom
-    , DevURandom
-    ) where
+module Crypto.Random.Entropy.Unix (
+    DevRandom,
+    DevURandom,
+) where
 
-import Foreign.Ptr
-import Data.Word (Word8)
-import Crypto.Random.Entropy.Source
 import Control.Exception as E
+import Crypto.Random.Entropy.Source
+import Data.Word (Word8)
+import Foreign.Ptr
 
---import System.Posix.Types (Fd)
+-- import System.Posix.Types (Fd)
 import System.IO
 
 type H = Handle
 type DeviceName = String
 
 -- | Entropy device @/dev/random@ on unix system
-newtype DevRandom  = DevRandom DeviceName
+newtype DevRandom = DevRandom DeviceName
 
 -- | Entropy device @/dev/urandom@ on unix system
 newtype DevURandom = DevURandom DeviceName
@@ -32,43 +32,46 @@
     entropyOpen = fmap DevRandom `fmap` testOpen "/dev/random"
     entropyGather (DevRandom name) ptr n =
         withDev name $ \h -> gatherDevEntropyNonBlock h ptr n
-    entropyClose (DevRandom _)  = return ()
+    entropyClose (DevRandom _) = return ()
 
 instance EntropySource DevURandom where
     entropyOpen = fmap DevURandom `fmap` testOpen "/dev/urandom"
     entropyGather (DevURandom name) ptr n =
         withDev name $ \h -> gatherDevEntropy h ptr n
-    entropyClose (DevURandom _)  = return ()
+    entropyClose (DevURandom _) = return ()
 
 testOpen :: DeviceName -> IO (Maybe DeviceName)
 testOpen filepath = do
     d <- openDev filepath
     case d of
         Nothing -> return Nothing
-        Just h  -> closeDev h >> return (Just filepath)
+        Just h -> closeDev h >> return (Just filepath)
 
 openDev :: String -> IO (Maybe H)
-openDev filepath = (Just `fmap` openAndNoBuffering) `E.catch` \(_ :: IOException) -> return Nothing
-  where openAndNoBuffering = do
-            h <- openBinaryFile filepath ReadMode
-            hSetBuffering h NoBuffering
-            return h
+openDev filepath =
+    (Just `fmap` openAndNoBuffering) `E.catch` \(_ :: IOException) -> return Nothing
+  where
+    openAndNoBuffering = do
+        h <- openBinaryFile filepath ReadMode
+        hSetBuffering h NoBuffering
+        return h
 
 withDev :: String -> (H -> IO a) -> IO a
-withDev filepath f = openDev filepath >>= \h ->
-    case h of
-        Nothing -> error ("device " ++ filepath ++ " cannot be grabbed")
-        Just fd -> f fd `E.finally` closeDev fd
+withDev filepath f =
+    openDev filepath >>= \h ->
+        case h of
+            Nothing -> error ("device " ++ filepath ++ " cannot be grabbed")
+            Just fd -> f fd `E.finally` closeDev fd
 
 closeDev :: H -> IO ()
 closeDev h = hClose h `E.catch` \(_ :: IOException) -> return ()
 
 gatherDevEntropy :: H -> Ptr Word8 -> Int -> IO Int
 gatherDevEntropy h ptr sz =
-     (fromIntegral `fmap` hGetBufSome h ptr (fromIntegral sz))
-    `E.catch` \(_ :: IOException) -> return 0
+    (fromIntegral `fmap` hGetBufSome h ptr (fromIntegral sz))
+        `E.catch` \(_ :: IOException) -> return 0
 
 gatherDevEntropyNonBlock :: H -> Ptr Word8 -> Int -> IO Int
 gatherDevEntropyNonBlock h ptr sz =
-     (fromIntegral `fmap` hGetBufNonBlocking h ptr (fromIntegral sz))
-    `E.catch` \(_ :: IOException) -> return 0
+    (fromIntegral `fmap` hGetBufNonBlocking h ptr (fromIntegral sz))
+        `E.catch` \(_ :: IOException) -> return 0
diff --git a/Crypto/Random/Entropy/Unsafe.hs b/Crypto/Random/Entropy/Unsafe.hs
--- a/Crypto/Random/Entropy/Unsafe.hs
+++ b/Crypto/Random/Entropy/Unsafe.hs
@@ -4,15 +4,14 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.Random.Entropy.Unsafe
-    ( replenish
-    , module Crypto.Random.Entropy.Backend
-    ) where
+module Crypto.Random.Entropy.Unsafe (
+    replenish,
+    module Crypto.Random.Entropy.Backend,
+) where
 
+import Crypto.Random.Entropy.Backend
 import Data.Word (Word8)
 import Foreign.Ptr (Ptr, plusPtr)
-import Crypto.Random.Entropy.Backend
 
 -- | Refill the entropy in a buffer
 --
@@ -22,12 +21,14 @@
 -- If the buffer cannot be refill after 3 loopings, this will raise
 -- an User Error exception
 replenish :: Int -> [EntropyBackend] -> Ptr Word8 -> IO ()
-replenish _        []       _   = fail "crypton: random: cannot get any source of entropy on this system"
+replenish _ [] _ = fail "crypton: random: cannot get any source of entropy on this system"
 replenish poolSize backends ptr = loop 0 backends ptr poolSize
-  where loop :: Int -> [EntropyBackend] -> Ptr Word8 -> Int -> IO ()
-        loop _     _  _ 0 = return ()
-        loop retry [] p n | retry == 3 = error "crypton: random: cannot fully replenish"
-                          | otherwise  = loop (retry+1) backends p n
-        loop retry (b:bs) p n = do
-            r <- gatherBackend b p n
-            loop retry bs (p `plusPtr` r) (n - r)
+  where
+    loop :: Int -> [EntropyBackend] -> Ptr Word8 -> Int -> IO ()
+    loop _ _ _ 0 = return ()
+    loop retry [] p n
+        | retry == 3 = error "crypton: random: cannot fully replenish"
+        | otherwise = loop (retry + 1) backends p n
+    loop retry (b : bs) p n = do
+        r <- gatherBackend b p n
+        loop retry bs (p `plusPtr` r) (n - r)
diff --git a/Crypto/Random/EntropyPool.hs b/Crypto/Random/EntropyPool.hs
--- a/Crypto/Random/EntropyPool.hs
+++ b/Crypto/Random/EntropyPool.hs
@@ -4,22 +4,21 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.Random.EntropyPool
-    ( EntropyPool
-    , createEntropyPool
-    , createEntropyPoolWith
-    , getEntropyFrom
-    ) where
+module Crypto.Random.EntropyPool (
+    EntropyPool,
+    createEntropyPool,
+    createEntropyPoolWith,
+    getEntropyFrom,
+) where
 
-import           Control.Concurrent.MVar
-import           Crypto.Random.Entropy.Unsafe
-import           Crypto.Internal.ByteArray (ByteArray, ScrubbedBytes)
+import Control.Concurrent.MVar
+import Crypto.Internal.ByteArray (ByteArray, ScrubbedBytes)
 import qualified Crypto.Internal.ByteArray as B
-import           Data.Word (Word8)
-import           Data.Maybe (catMaybes)
-import           Foreign.Marshal.Utils (copyBytes)
-import           Foreign.Ptr (plusPtr, Ptr)
+import Crypto.Random.Entropy.Unsafe
+import Data.Maybe (catMaybes)
+import Data.Word (Word8)
+import Foreign.Marshal.Utils (copyBytes)
+import Foreign.Ptr (Ptr, plusPtr)
 
 -- | Pool of Entropy. Contains a self-mutating pool of entropy,
 -- that is always guaranteed to contain data.
@@ -35,7 +34,7 @@
 -- the pool can be shared between multiples RNGs.
 createEntropyPoolWith :: Int -> [EntropyBackend] -> IO EntropyPool
 createEntropyPoolWith poolSize backends = do
-    m  <- newMVar 0
+    m <- newMVar 0
     sm <- B.alloc poolSize (replenish poolSize backends)
     return $ EntropyPool backends m sm
 
@@ -54,17 +53,18 @@
     B.withByteArray sm $ \entropyPoolPtr ->
         modifyMVar_ posM $ \pos ->
             copyLoop outPtr entropyPoolPtr pos n
-  where poolSize = B.length sm
-        copyLoop d s pos left
-            | left == 0 = return pos
-            | otherwise = do
-                wrappedPos <-
-                    if pos == poolSize
-                        then replenish poolSize backends s >> return 0
-                        else return pos
-                let m = min (poolSize - wrappedPos) left
-                copyBytes d (s `plusPtr` wrappedPos) m
-                copyLoop (d `plusPtr` m) s (wrappedPos + m) (left - m)
+  where
+    poolSize = B.length sm
+    copyLoop d s pos left
+        | left == 0 = return pos
+        | otherwise = do
+            wrappedPos <-
+                if pos == poolSize
+                    then replenish poolSize backends s >> return 0
+                    else return pos
+            let m = min (poolSize - wrappedPos) left
+            copyBytes d (s `plusPtr` wrappedPos) m
+            copyLoop (d `plusPtr` m) s (wrappedPos + m) (left - m)
 
 -- | Grab a chunk of entropy from the entropy pool.
 getEntropyFrom :: ByteArray byteArray => EntropyPool -> Int -> IO byteArray
diff --git a/Crypto/Random/HmacDRG.hs b/Crypto/Random/HmacDRG.hs
new file mode 100644
--- /dev/null
+++ b/Crypto/Random/HmacDRG.hs
@@ -0,0 +1,51 @@
+{-# LANGUAGE TypeApplications #-}
+
+module Crypto.Random.HmacDRG (HmacDRG, initial, update) where
+
+import Crypto.Hash
+import Crypto.MAC.HMAC (HMAC (..), hmac)
+import Crypto.Random.Types
+import Data.ByteArray (ByteArrayAccess, Bytes, ScrubbedBytes)
+import qualified Data.ByteArray as M
+import Data.Maybe
+
+-- | HMAC-based Deterministic Random Generator
+--
+-- Adapted from NIST Special Publication 800-90A Revision 1, Section 10.1.2
+data HmacDRG hash = HmacDRG (Digest hash) (Digest hash)
+
+-- | The initial DRG state. It should be seeded via 'update' before use.
+initial :: HashAlgorithm hash => hash -> HmacDRG hash
+initial algorithm = HmacDRG (constant 0x00) (constant 0x01)
+  where
+    constant =
+        fromJust . digestFromByteString . M.replicate @Bytes (hashDigestSize algorithm)
+
+-- | Update the DRG state with optional provided data.
+update
+    :: ByteArrayAccess input
+    => HashAlgorithm hash
+    => input -> HmacDRG hash -> HmacDRG hash
+update input state0 = if M.null input then state1 else state2
+  where
+    state1 = step 0x00 state0
+    state2 = step 0x01 state1
+    step byte (HmacDRG key value) = HmacDRG keyNew valueNew
+      where
+        keyNew =
+            hmacGetDigest $
+                hmac key $
+                    M.convert value <> M.singleton @ScrubbedBytes byte <> M.convert input
+        valueNew = hmacGetDigest $ hmac keyNew value
+
+instance HashAlgorithm hash => DRG (HmacDRG hash) where
+    randomBytesGenerate count (HmacDRG key value) = (output, state)
+      where
+        output = M.take count result
+        state = update @Bytes M.empty $ HmacDRG key new
+        (result, new) = go M.empty value
+        go buffer current
+            | M.length buffer >= count = (buffer, current)
+            | otherwise = go (buffer <> M.convert next) next
+          where
+            next = hmacGetDigest $ hmac key current
diff --git a/Crypto/Random/Probabilistic.hs b/Crypto/Random/Probabilistic.hs
--- a/Crypto/Random/Probabilistic.hs
+++ b/Crypto/Random/Probabilistic.hs
@@ -4,25 +4,24 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.Random.Probabilistic
-    ( probabilistic
-    ) where
+module Crypto.Random.Probabilistic (
+    probabilistic,
+) where
 
 import Crypto.Internal.Compat
-import Crypto.Random.Types
 import Crypto.Random
 
 -- | This create a random number generator out of thin air with
 -- the system entropy; don't generally use as the IO is not exposed
 -- this can have unexpected random for.
--- 
+--
 -- This is useful for probabilistic algorithm like Miller Rabin
 -- probably prime algorithm, given appropriate choice of the heuristic
 --
 -- Generally, it's advised not to use this function.
 probabilistic :: MonadPseudoRandom ChaChaDRG a -> a
 probabilistic f = fst $ withDRG drg f
-  where {-# NOINLINE drg #-}
-        drg = unsafeDoIO drgNew
+  where
+    {-# NOINLINE drg #-}
+    drg = unsafeDoIO drgNew
 {-# NOINLINE probabilistic #-}
diff --git a/Crypto/Random/SystemDRG.hs b/Crypto/Random/SystemDRG.hs
--- a/Crypto/Random/SystemDRG.hs
+++ b/Crypto/Random/SystemDRG.hs
@@ -1,26 +1,26 @@
+{-# LANGUAGE BangPatterns #-}
+
 -- |
 -- Module      : Crypto.Random.SystemDRG
 -- License     : BSD-style
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-{-# LANGUAGE BangPatterns #-}
-module Crypto.Random.SystemDRG
-    ( SystemDRG
-    , getSystemDRG
-    ) where
+module Crypto.Random.SystemDRG (
+    SystemDRG,
+    getSystemDRG,
+) where
 
-import           Crypto.Random.Types
-import           Crypto.Random.Entropy.Unsafe
-import           Crypto.Internal.Compat
-import           Data.ByteArray (ScrubbedBytes, ByteArray)
-import           Data.Memory.PtrMethods as B (memCopy)
-import           Data.Maybe (catMaybes)
-import           Data.Tuple (swap)
-import           Foreign.Ptr
+import Crypto.Internal.Compat
+import Crypto.Random.Entropy.Unsafe
+import Crypto.Random.Types
+import Data.ByteArray (ByteArray, ScrubbedBytes)
 import qualified Data.ByteArray as B
-import           System.IO.Unsafe (unsafeInterleaveIO)
+import Data.Maybe (catMaybes)
+import Data.Memory.PtrMethods as B (memCopy)
+import Data.Tuple (swap)
+import Foreign.Ptr
+import System.IO.Unsafe (unsafeInterleaveIO)
 
 -- | A referentially transparent System representation of
 -- the random evaluated out of the system.
@@ -43,21 +43,22 @@
 getSystemDRG = do
     backends <- catMaybes `fmap` sequence supportedBackends
     let getNext = unsafeInterleaveIO $ do
-            bs   <- B.alloc systemChunkSize (replenish systemChunkSize backends)
+            bs <- B.alloc systemChunkSize (replenish systemChunkSize backends)
             more <- getNext
-            return (bs:more)
+            return (bs : more)
     SystemDRG 0 <$> getNext
 
 generate :: ByteArray output => Int -> SystemDRG -> (output, SystemDRG)
 generate nbBytes (SystemDRG ofs sysChunks) = swap $ unsafeDoIO $ B.allocRet nbBytes $ loop ofs sysChunks nbBytes
-  where loop currentOfs chunks 0 _ = return $! SystemDRG currentOfs chunks
-        loop _          []     _ _ = error "SystemDRG: the impossible happened: empty chunk"
-        loop currentOfs oChunks@(c:cs) n d = do
-            let currentLeft = B.length c - currentOfs
-                toCopy      = min n currentLeft
-                nextOfs     = currentOfs + toCopy
-                n'          = n - toCopy
-            B.withByteArray c $ \src -> B.memCopy d (src `plusPtr` currentOfs) toCopy
-            if nextOfs == B.length c
-                then loop 0 cs n' (d `plusPtr` toCopy)
-                else loop nextOfs oChunks n' (d `plusPtr` toCopy)
+  where
+    loop currentOfs chunks 0 _ = return $! SystemDRG currentOfs chunks
+    loop _ [] _ _ = error "SystemDRG: the impossible happened: empty chunk"
+    loop currentOfs oChunks@(c : cs) n d = do
+        let currentLeft = B.length c - currentOfs
+            toCopy = min n currentLeft
+            nextOfs = currentOfs + toCopy
+            n' = n - toCopy
+        B.withByteArray c $ \src -> B.memCopy d (src `plusPtr` currentOfs) toCopy
+        if nextOfs == B.length c
+            then loop 0 cs n' (d `plusPtr` toCopy)
+            else loop nextOfs oChunks n' (d `plusPtr` toCopy)
diff --git a/Crypto/Random/Types.hs b/Crypto/Random/Types.hs
--- a/Crypto/Random/Types.hs
+++ b/Crypto/Random/Types.hs
@@ -4,17 +4,15 @@
 -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
 -- Stability   : experimental
 -- Portability : Good
---
-module Crypto.Random.Types
-    (
-      MonadRandom(..)
-    , MonadPseudoRandom
-    , DRG(..)
-    , withDRG
-    ) where
+module Crypto.Random.Types (
+    MonadRandom (..),
+    MonadPseudoRandom,
+    DRG (..),
+    withDRG,
+) where
 
-import Crypto.Random.Entropy
 import Crypto.Internal.ByteArray
+import Crypto.Random.Entropy
 
 -- | A monad constraint that allows to generate random bytes
 class Monad m => MonadRandom m where
@@ -39,14 +37,14 @@
         let (a, g2) = runPseudoRandom m g1 in (f a, g2)
 
 instance DRG gen => Applicative (MonadPseudoRandom gen) where
-    pure a     = MonadPseudoRandom $ \g -> (a, g)
+    pure a = MonadPseudoRandom $ \g -> (a, g)
     (<*>) fm m = MonadPseudoRandom $ \g1 ->
         let (f, g2) = runPseudoRandom fm g1
             (a, g3) = runPseudoRandom m g2
          in (f a, g3)
 
 instance DRG gen => Monad (MonadPseudoRandom gen) where
-    return      = pure
+    return = pure
     (>>=) m1 m2 = MonadPseudoRandom $ \g1 ->
         let (a, g2) = runPseudoRandom m1 g1
          in runPseudoRandom (m2 a) g2
diff --git a/Crypto/System/CPU.hs b/Crypto/System/CPU.hs
--- a/Crypto/System/CPU.hs
+++ b/Crypto/System/CPU.hs
@@ -1,3 +1,7 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+
 -- |
 -- Module      : Crypto.System.CPU
 -- License     : BSD-style
@@ -6,14 +10,10 @@
 -- Portability : unknown
 --
 -- Gives information about crypton runtime environment.
---
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE ForeignFunctionInterface #-}
-module Crypto.System.CPU
-    ( ProcessorOption (..)
-    , processorOptions
-    ) where
+module Crypto.System.CPU (
+    ProcessorOption (..),
+    processorOptions,
+) where
 
 import Data.Data
 import Data.List (findIndices)
@@ -33,10 +33,13 @@
 
 -- | CPU options impacting cryptography implementation and library performance.
 data ProcessorOption
-    = AESNI   -- ^ Support for AES instructions, with flag @support_aesni@
-    | PCLMUL  -- ^ Support for CLMUL instructions, with flag @support_pclmuldq@
-    | RDRAND  -- ^ Support for RDRAND instruction, with flag @support_rdrand@
-    deriving (Show,Eq,Enum,Data)
+    = -- | Support for AES instructions, with flag @support_aesni@
+      AESNI
+    | -- | Support for CLMUL instructions, with flag @support_pclmuldq@
+      PCLMUL
+    | -- | Support for RDRAND instruction, with flag @support_rdrand@
+      RDRAND
+    deriving (Show, Eq, Enum, Data)
 
 -- | Options which have been enabled at compile time and are supported by the
 -- current CPU.
@@ -44,11 +47,11 @@
 processorOptions = unsafeDoIO $ do
     p <- crypton_aes_cpu_init
     options <- traverse (getOption p) aesOptions
-    rdrand  <- hasRDRand
-    return (decodeOptions options ++ [ RDRAND | rdrand ])
+    rdrand <- hasRDRand
+    return (decodeOptions options ++ [RDRAND | rdrand])
   where
-    aesOptions    = [ AESNI .. PCLMUL ]
-    getOption p   = peekElemOff p . fromEnum
+    aesOptions = [AESNI .. PCLMUL]
+    getOption p = peekElemOff p . fromEnum
     decodeOptions = map toEnum . findIndices (> 0)
 {-# NOINLINE processorOptions #-}
 
diff --git a/Crypto/Tutorial.hs b/Crypto/Tutorial.hs
--- a/Crypto/Tutorial.hs
+++ b/Crypto/Tutorial.hs
@@ -1,22 +1,22 @@
 -- | Examples of how to use @crypton@.
-module Crypto.Tutorial
-    ( -- * API design
-      -- $api_design
+module Crypto.Tutorial (
+    -- * API design
+    -- $api_design
 
-      -- * Hash algorithms
-      -- $hash_algorithms
+    -- * Hash algorithms
+    -- $hash_algorithms
 
-      -- * Symmetric block ciphers
-      -- $symmetric_block_ciphers
+    -- * Symmetric block ciphers
+    -- $symmetric_block_ciphers
 
-      -- * Combining primitives
-      -- $combining_primitives
-    ) where
+    -- * Combining primitives
+    -- $combining_primitives
+) where
 
 -- $api_design
 --
 -- APIs in crypton are often based on type classes from package
--- <https://hackage.haskell.org/package/memory memory>, notably
+-- <https://hackage.haskell.org/package/ram ram>, notably
 -- 'Data.ByteArray.ByteArrayAccess' and 'Data.ByteArray.ByteArray'.
 -- Module "Data.ByteArray" provides many primitives that are useful to
 -- work with crypton types.  For example function 'Data.ByteArray.convert'
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,2 +1,3 @@
 import Distribution.Simple
+
 main = defaultMain
diff --git a/benchs/Bench.hs b/benchs/Bench.hs
--- a/benchs/Bench.hs
+++ b/benchs/Bench.hs
@@ -1,43 +1,44 @@
-{-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE ExistentialQuantification #-}
 {-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE TypeFamilies #-}
+
 module Main where
 
 import Gauge.Main
 
-import           Crypto.Cipher.AES
+import Crypto.Cipher.AES
 import qualified Crypto.Cipher.AESGCMSIV as AESGCMSIV
-import           Crypto.Cipher.Blowfish
-import           Crypto.Cipher.CAST5
+import Crypto.Cipher.Blowfish
+import Crypto.Cipher.CAST5
 import qualified Crypto.Cipher.ChaChaPoly1305 as CP
-import           Crypto.Cipher.DES
-import           Crypto.Cipher.Twofish
-import           Crypto.Cipher.Types
-import           Crypto.ECC
-import           Crypto.Error
-import           Crypto.Hash
+import Crypto.Cipher.DES
+import Crypto.Cipher.Twofish
+import Crypto.Cipher.Types
+import Crypto.ECC
+import Crypto.Error
+import Crypto.Hash
 import qualified Crypto.KDF.BCrypt as BCrypt
 import qualified Crypto.KDF.PBKDF2 as PBKDF2
-import           Crypto.Number.Basic (numBits)
-import           Crypto.Number.Generate
+import Crypto.Number.Basic (numBits)
+import Crypto.Number.Generate
 import qualified Crypto.PubKey.DH as DH
-import qualified Crypto.PubKey.ECC.Types as ECC
 import qualified Crypto.PubKey.ECC.Prim as ECC
+import qualified Crypto.PubKey.ECC.Types as ECC
 import qualified Crypto.PubKey.ECDSA as ECDSA
 import qualified Crypto.PubKey.Ed25519 as Ed25519
 import qualified Crypto.PubKey.EdDSA as EdDSA
-import           Crypto.Random
+import Crypto.Random
 
-import           Control.DeepSeq (NFData)
-import           Data.ByteArray (ByteArray, Bytes)
+import Control.DeepSeq (NFData)
+import Data.ByteArray (ByteArray, Bytes)
 import qualified Data.ByteString as B
 
 import qualified Crypto.PubKey.ECC.P256 as P256
 
 import Number.F2m
 
-data HashAlg = forall alg . HashAlgorithm alg => HashAlg alg
+data HashAlg = forall alg. HashAlgorithm alg => HashAlg alg
 
 benchHash =
     [ env oneKB $ \b -> bgroup "1KB" $ map (doHashBench b) hashAlgs
@@ -65,13 +66,13 @@
         , ("SHA512t_256", HashAlg SHA512t_256)
         , ("RIPEMD160", HashAlg RIPEMD160)
         , ("Tiger", HashAlg Tiger)
-        --, ("Skein256-160", HashAlg Skein256_160)
-        , ("Skein256-256", HashAlg Skein256_256)
-        --, ("Skein512-160", HashAlg Skein512_160)
-        , ("Skein512-384", HashAlg Skein512_384)
+        , -- , ("Skein256-160", HashAlg Skein256_160)
+          ("Skein256-256", HashAlg Skein256_256)
+        , -- , ("Skein512-160", HashAlg Skein512_160)
+          ("Skein512-384", HashAlg Skein512_384)
         , ("Skein512-512", HashAlg Skein512_512)
-        --, ("Skein512-896", HashAlg Skein512_896)
-        , ("Whirlpool", HashAlg Whirlpool)
+        , -- , ("Skein512-896", HashAlg Skein512_896)
+          ("Whirlpool", HashAlg Whirlpool)
         , ("Keccak-224", HashAlg Keccak_224)
         , ("Keccak-256", HashAlg Keccak_256)
         , ("Keccak-384", HashAlg Keccak_384)
@@ -91,82 +92,99 @@
         ]
 
 benchPBKDF2 =
-    [ bgroup "64"
+    [ bgroup
+        "64"
         [ bench "cryptonite-PBKDF2-100-64" $ nf (pbkdf2 64) 100
         , bench "cryptonite-PBKDF2-1000-64" $ nf (pbkdf2 64) 1000
         , bench "cryptonite-PBKDF2-10000-64" $ nf (pbkdf2 64) 10000
         ]
-    , bgroup "128"
+    , bgroup
+        "128"
         [ bench "cryptonite-PBKDF2-100-128" $ nf (pbkdf2 128) 100
         , bench "cryptonite-PBKDF2-1000-128" $ nf (pbkdf2 128) 1000
         , bench "cryptonite-PBKDF2-10000-128" $ nf (pbkdf2 128) 10000
         ]
     ]
   where
-        pbkdf2 :: Int -> Int -> B.ByteString
-        pbkdf2 n iter = PBKDF2.generate (PBKDF2.prfHMAC SHA512) (params n iter) mypass mysalt
+    pbkdf2 :: Int -> Int -> B.ByteString
+    pbkdf2 n iter = PBKDF2.generate (PBKDF2.prfHMAC SHA512) (params n iter) mypass mysalt
 
-        mypass, mysalt :: B.ByteString
-        mypass = "password"
-        mysalt = "salt"
+    mypass, mysalt :: B.ByteString
+    mypass = "password"
+    mysalt = "salt"
 
-        params n iter = PBKDF2.Parameters iter n
+    params n iter = PBKDF2.Parameters iter n
 
 benchBCrypt =
-    [ bench "cryptonite-BCrypt-4"  $ nf bcrypt 4
-    , bench "cryptonite-BCrypt-5"  $ nf bcrypt 5
-    , bench "cryptonite-BCrypt-7"  $ nf bcrypt 7
+    [ bench "cryptonite-BCrypt-4" $ nf bcrypt 4
+    , bench "cryptonite-BCrypt-5" $ nf bcrypt 5
+    , bench "cryptonite-BCrypt-7" $ nf bcrypt 7
     , bench "cryptonite-BCrypt-11" $ nf bcrypt 11
     ]
   where
-        bcrypt :: Int -> B.ByteString
-        bcrypt cost = BCrypt.bcrypt cost mysalt mypass
+    bcrypt :: Int -> B.ByteString
+    bcrypt cost = BCrypt.bcrypt cost mysalt mypass
 
-        mypass, mysalt :: B.ByteString
-        mypass = "password"
-        mysalt = "saltsaltsaltsalt"
+    mypass, mysalt :: B.ByteString
+    mypass = "password"
+    mysalt = "saltsaltsaltsalt"
 
 benchBlockCipher =
     [ bgroup "ECB" benchECB
     , bgroup "CBC" benchCBC
     ]
   where
-        benchECB =
-            [ bench "DES-input=1024" $ nf (run (undefined :: DES) cipherInit key8) input1024
-            , bench "Blowfish128-input=1024" $ nf (run (undefined :: Blowfish128) cipherInit key16) input1024
-            , bench "Twofish128-input=1024" $ nf (run (undefined :: Twofish128) cipherInit key16) input1024
-            , bench "CAST5-128-input=1024" $ nf (run (undefined :: CAST5) cipherInit key16) input1024
-            , bench "AES128-input=1024" $ nf (run (undefined :: AES128) cipherInit key16) input1024
-            , bench "AES256-input=1024" $ nf (run (undefined :: AES256) cipherInit key32) input1024
-            ]
-          where run :: (ByteArray ba, ByteArray key, BlockCipher c)
-                    => c -> (key -> CryptoFailable c) -> key -> ba -> ba
-                run _witness initF key input =
-                    (ecbEncrypt (throwCryptoError (initF key))) input
+    benchECB =
+        [ bench "DES-input=1024" $ nf (run (undefined :: DES) cipherInit key8) input1024
+        , bench "Blowfish128-input=1024" $
+            nf (run (undefined :: Blowfish128) cipherInit key16) input1024
+        , bench "Twofish128-input=1024" $
+            nf (run (undefined :: Twofish128) cipherInit key16) input1024
+        , bench "CAST5-128-input=1024" $
+            nf (run (undefined :: CAST5) cipherInit key16) input1024
+        , bench "AES128-input=1024" $
+            nf (run (undefined :: AES128) cipherInit key16) input1024
+        , bench "AES256-input=1024" $
+            nf (run (undefined :: AES256) cipherInit key32) input1024
+        ]
+      where
+        run
+            :: (ByteArray ba, ByteArray key, BlockCipher c)
+            => c -> (key -> CryptoFailable c) -> key -> ba -> ba
+        run _witness initF key input =
+            (ecbEncrypt (throwCryptoError (initF key))) input
 
-        benchCBC =
-            [ bench "DES-input=1024" $ nf (run (undefined :: DES) cipherInit key8 iv8) input1024
-            , bench "Blowfish128-input=1024" $ nf (run (undefined :: Blowfish128) cipherInit key16 iv8) input1024
-            , bench "Twofish128-input=1024" $ nf (run (undefined :: Twofish128) cipherInit key16 iv16) input1024
-            , bench "CAST5-128-input=1024" $ nf (run (undefined :: CAST5) cipherInit key16 iv8) input1024
-            , bench "AES128-input=1024" $ nf (run (undefined :: AES128) cipherInit key16 iv16) input1024
-            , bench "AES256-input=1024" $ nf (run (undefined :: AES256) cipherInit key32 iv16) input1024
-            ]
-          where run :: (ByteArray ba, ByteArray key, BlockCipher c)
-                    => c -> (key -> CryptoFailable c) -> key -> IV c -> ba -> ba
-                run _witness initF key iv input =
-                    (cbcEncrypt (throwCryptoError (initF key))) iv input
+    benchCBC =
+        [ bench "DES-input=1024" $
+            nf (run (undefined :: DES) cipherInit key8 iv8) input1024
+        , bench "Blowfish128-input=1024" $
+            nf (run (undefined :: Blowfish128) cipherInit key16 iv8) input1024
+        , bench "Twofish128-input=1024" $
+            nf (run (undefined :: Twofish128) cipherInit key16 iv16) input1024
+        , bench "CAST5-128-input=1024" $
+            nf (run (undefined :: CAST5) cipherInit key16 iv8) input1024
+        , bench "AES128-input=1024" $
+            nf (run (undefined :: AES128) cipherInit key16 iv16) input1024
+        , bench "AES256-input=1024" $
+            nf (run (undefined :: AES256) cipherInit key32 iv16) input1024
+        ]
+      where
+        run
+            :: (ByteArray ba, ByteArray key, BlockCipher c)
+            => c -> (key -> CryptoFailable c) -> key -> IV c -> ba -> ba
+        run _witness initF key iv input =
+            (cbcEncrypt (throwCryptoError (initF key))) iv input
 
-        key8  = B.replicate 8 0
-        key16 = B.replicate 16 0
-        key32 = B.replicate 32 0
-        input1024 = B.replicate 1024 0
+    key8 = B.replicate 8 0
+    key16 = B.replicate 16 0
+    key32 = B.replicate 32 0
+    input1024 = B.replicate 1024 0
 
-        iv8 :: BlockCipher c => IV c
-        iv8  = maybe (error "iv size 8") id  $ makeIV key8
+    iv8 :: BlockCipher c => IV c
+    iv8 = maybe (error "iv size 8") id $ makeIV key8
 
-        iv16 :: BlockCipher c => IV c
-        iv16 = maybe (error "iv size 16") id $ makeIV key16
+    iv16 :: BlockCipher c => IV c
+    iv16 = maybe (error "iv size 16") id $ makeIV key16
 
 benchAE =
     [ bench "ChaChaPoly1305" $ nf (cp key32) (input64, input1024)
@@ -174,81 +192,92 @@
     , bench "AES-CCM" $ nf (ccm key32) (input64, input1024)
     , bench "AES-GCM-SIV" $ nf (gcmsiv key32) (input64, input1024)
     ]
-  where cp k (ini, plain) =
-            let iniState            = throwCryptoError $ CP.initialize k (throwCryptoError $ CP.nonce12 nonce12)
-                afterAAD            = CP.finalizeAAD (CP.appendAAD ini iniState)
-                (out, afterEncrypt) = CP.encrypt plain afterAAD
-                outtag              = CP.finalize afterEncrypt
-             in (outtag, out)
+  where
+    cp k (ini, plain) =
+        let iniState =
+                throwCryptoError $ CP.initialize k (throwCryptoError $ CP.nonce12 nonce12)
+            afterAAD = CP.finalizeAAD (CP.appendAAD ini iniState)
+            (out, afterEncrypt) = CP.encrypt plain afterAAD
+            outtag = CP.finalize afterEncrypt
+         in (outtag, out)
 
-        gcm k (ini, plain) =
-            let ctx = throwCryptoError (cipherInit k) :: AES256
-                state = throwCryptoError $ aeadInit AEAD_GCM ctx nonce12
-             in aeadSimpleEncrypt state ini plain 16
+    gcm k (ini, plain) =
+        let ctx = throwCryptoError (cipherInit k) :: AES256
+            state = throwCryptoError $ aeadInit AEAD_GCM ctx nonce12
+         in aeadSimpleEncrypt state ini plain 16
 
-        ccm k (ini, plain) =
-            let ctx = throwCryptoError (cipherInit k) :: AES256
-                mode = AEAD_CCM 1024 CCM_M16 CCM_L3
-                state = throwCryptoError $ aeadInit mode ctx nonce12
-             in aeadSimpleEncrypt state ini plain 16
+    ccm k (ini, plain) =
+        let ctx = throwCryptoError (cipherInit k) :: AES256
+            mode = AEAD_CCM 1024 CCM_M16 CCM_L3
+            state = throwCryptoError $ aeadInit mode ctx nonce12
+         in aeadSimpleEncrypt state ini plain 16
 
-        gcmsiv k (ini, plain) =
-            let ctx = throwCryptoError (cipherInit k) :: AES256
-                iv = throwCryptoError (AESGCMSIV.nonce nonce12)
-             in AESGCMSIV.encrypt ctx iv ini plain
+    gcmsiv k (ini, plain) =
+        let ctx = throwCryptoError (cipherInit k) :: AES256
+            iv = throwCryptoError (AESGCMSIV.nonce nonce12)
+         in AESGCMSIV.encrypt ctx iv ini plain
 
-        input64 = B.replicate 64 0
-        input1024 = B.replicate 1024 0
+    input64 = B.replicate 64 0
+    input1024 = B.replicate 1024 0
 
-        nonce12 :: B.ByteString
-        nonce12 = B.replicate 12 0
+    nonce12 :: B.ByteString
+    nonce12 = B.replicate 12 0
 
-        key32 = B.replicate 32 0
+    key32 = B.replicate 32 0
 
 benchECC =
-    [ bench "pointAddTwoMuls-baseline"  $ nf run_b (n1, p1, n2, p2)
+    [ bench "pointAddTwoMuls-baseline" $ nf run_b (n1, p1, n2, p2)
     , bench "pointAddTwoMuls-optimized" $ nf run_o (n1, p1, n2, p2)
     , bench "pointAdd-ECC" $ nf run_c (p1, p2)
     , bench "pointMul-ECC" $ nf run_d (n1, p2)
     ]
-  where run_b (n, p, k, q) = ECC.pointAdd c (ECC.pointMul c n p)
-                                            (ECC.pointMul c k q)
+  where
+    run_b (n, p, k, q) =
+        ECC.pointAdd
+            c
+            (ECC.pointMul c n p)
+            (ECC.pointMul c k q)
 
-        run_o (n, p, k, q) = ECC.pointAddTwoMuls c n p k q
-        run_c (p, q) = ECC.pointAdd c p q
-        run_d (n, p) = ECC.pointMul c n p
+    run_o (n, p, k, q) = ECC.pointAddTwoMuls c n p k q
+    run_c (p, q) = ECC.pointAdd c p q
+    run_d (n, p) = ECC.pointMul c n p
 
-        c  = ECC.getCurveByName ECC.SEC_p256r1
-        p1 = ECC.pointBaseMul c n1
-        p2 = ECC.pointBaseMul c n2
-        n1 = 0x2ba9daf2363b2819e69b34a39cf496c2458a9b2a21505ea9e7b7cbca42dc7435
-        n2 = 0xf054a7f60d10b8c2cf847ee90e9e029f8b0e971b09ca5f55c4d49921a11fadc1
+    c = ECC.getCurveByName ECC.SEC_p256r1
+    p1 = ECC.pointBaseMul c n1
+    p2 = ECC.pointBaseMul c n2
+    n1 = 0x2ba9daf2363b2819e69b34a39cf496c2458a9b2a21505ea9e7b7cbca42dc7435
+    n2 = 0xf054a7f60d10b8c2cf847ee90e9e029f8b0e971b09ca5f55c4d49921a11fadc1
 
 benchP256 =
-    [ bench "pointAddTwoMuls-P256"  $ nf run_p (n1, p1, n2, p2)
-    , bench "pointAdd-P256"  $ nf run_q (p1, p2)
-    , bench "pointMul-P256"  $ nf run_t (n1, p1)
+    [ bench "pointAddTwoMuls-P256" $ nf run_p (n1, p1, n2, p2)
+    , bench "pointAdd-P256" $ nf run_q (p1, p2)
+    , bench "pointMul-P256" $ nf run_t (n1, p1)
     ]
-  where run_p (n, p, k, q) = P256.pointAdd (P256.pointMul n p) (P256.pointMul k q)
-        run_q (p, q) = P256.pointAdd p q
-        run_t (n, p) = P256.pointMul n p
-
-        xS = 0xde2444bebc8d36e682edd27e0f271508617519b3221a8fa0b77cab3989da97c9
-        yS = 0xc093ae7ff36e5380fc01a5aad1e66659702de80f53cec576b6350b243042a256
-        xT = 0x55a8b00f8da1d44e62f6b3b25316212e39540dc861c89575bb8cf92e35e0986b
-        yT = 0x5421c3209c2d6c704835d82ac4c3dd90f61a8a52598b9e7ab656e9d8c8b24316
-        p1 = P256.pointFromIntegers (xS, yS)
-        p2 = P256.pointFromIntegers (xT, yT)
-        n1 = throwCryptoError $ P256.scalarFromInteger 0x2ba9daf2363b2819e69b34a39cf496c2458a9b2a21505ea9e7b7cbca42dc7435
-        n2 = throwCryptoError $ P256.scalarFromInteger 0xf054a7f60d10b8c2cf847ee90e9e029f8b0e971b09ca5f55c4d49921a11fadc1
-
+  where
+    run_p (n, p, k, q) = P256.pointAdd (P256.pointMul n p) (P256.pointMul k q)
+    run_q (p, q) = P256.pointAdd p q
+    run_t (n, p) = P256.pointMul n p
 
+    xS = 0xde2444bebc8d36e682edd27e0f271508617519b3221a8fa0b77cab3989da97c9
+    yS = 0xc093ae7ff36e5380fc01a5aad1e66659702de80f53cec576b6350b243042a256
+    xT = 0x55a8b00f8da1d44e62f6b3b25316212e39540dc861c89575bb8cf92e35e0986b
+    yT = 0x5421c3209c2d6c704835d82ac4c3dd90f61a8a52598b9e7ab656e9d8c8b24316
+    p1 = P256.pointFromIntegers (xS, yS)
+    p2 = P256.pointFromIntegers (xT, yT)
+    n1 =
+        throwCryptoError $
+            P256.scalarFromInteger
+                0x2ba9daf2363b2819e69b34a39cf496c2458a9b2a21505ea9e7b7cbca42dc7435
+    n2 =
+        throwCryptoError $
+            P256.scalarFromInteger
+                0xf054a7f60d10b8c2cf847ee90e9e029f8b0e971b09ca5f55c4d49921a11fadc1
 
 benchFFDH = map doFFDHBench primes
   where
     doFFDHBench (e, p) =
         let bits = numBits p
-            params = DH.Params { DH.params_p = p, DH.params_g = 2, DH.params_bits = bits }
+            params = DH.Params{DH.params_p = p, DH.params_g = 2, DH.params_bits = bits}
          in env (generate e params) $ bench (show bits) . nf (run params)
 
     generate e params = do
@@ -261,14 +290,31 @@
     run params (priv, pub) = DH.getShared params priv pub
 
     -- RFC 7919: prime p with minimal size of exponent
-    primes = [ (225, 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B423861285C97FFFFFFFFFFFFFFFF)
-             , (275, 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF)
-             , (325, 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB7930E9E4E58857B6AC7D5F42D69F6D187763CF1D5503400487F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832A907600A918130C46DC778F971AD0038092999A333CB8B7A1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6AFFFFFFFFFFFFFFFF)
-             , (375, 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB7930E9E4E58857B6AC7D5F42D69F6D187763CF1D5503400487F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832A907600A918130C46DC778F971AD0038092999A333CB8B7A1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD9020BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA63BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3ACDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477A52471F7A9A96910B855322EDB6340D8A00EF092350511E30ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538CD72B03746AE77F5E62292C311562A846505DC82DB854338AE49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B045B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1A41D570D7938DAD4A40E329CD0E40E65FFFFFFFFFFFFFFFF)
-             , (400, 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB7930E9E4E58857B6AC7D5F42D69F6D187763CF1D5503400487F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832A907600A918130C46DC778F971AD0038092999A333CB8B7A1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD9020BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA63BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3ACDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477A52471F7A9A96910B855322EDB6340D8A00EF092350511E30ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538CD72B03746AE77F5E62292C311562A846505DC82DB854338AE49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B045B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1A41D570D7938DAD4A40E329CCFF46AAA36AD004CF600C8381E425A31D951AE64FDB23FCEC9509D43687FEB69EDD1CC5E0B8CC3BDF64B10EF86B63142A3AB8829555B2F747C932665CB2C0F1CC01BD70229388839D2AF05E454504AC78B7582822846C0BA35C35F5C59160CC046FD8251541FC68C9C86B022BB7099876A460E7451A8A93109703FEE1C217E6C3826E52C51AA691E0E423CFC99E9E31650C1217B624816CDAD9A95F9D5B8019488D9C0A0A1FE3075A577E23183F81D4A3F2FA4571EFC8CE0BA8A4FE8B6855DFE72B0A66EDED2FBABFBE58A30FAFABE1C5D71A87E2F741EF8C1FE86FEA6BBFDE530677F0D97D11D49F7A8443D0822E506A9F4614E011E2A94838FF88CD68C8BB7C5C6424CFFFFFFFFFFFFFFFF)
-             ]
+    primes =
+        [
+            ( 225
+            , 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B423861285C97FFFFFFFFFFFFFFFF
+            )
+        ,
+            ( 275
+            , 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF
+            )
+        ,
+            ( 325
+            , 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB7930E9E4E58857B6AC7D5F42D69F6D187763CF1D5503400487F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832A907600A918130C46DC778F971AD0038092999A333CB8B7A1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6AFFFFFFFFFFFFFFFF
+            )
+        ,
+            ( 375
+            , 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB7930E9E4E58857B6AC7D5F42D69F6D187763CF1D5503400487F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832A907600A918130C46DC778F971AD0038092999A333CB8B7A1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD9020BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA63BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3ACDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477A52471F7A9A96910B855322EDB6340D8A00EF092350511E30ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538CD72B03746AE77F5E62292C311562A846505DC82DB854338AE49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B045B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1A41D570D7938DAD4A40E329CD0E40E65FFFFFFFFFFFFFFFF
+            )
+        ,
+            ( 400
+            , 0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB7930E9E4E58857B6AC7D5F42D69F6D187763CF1D5503400487F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832A907600A918130C46DC778F971AD0038092999A333CB8B7A1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD9020BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA63BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3ACDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477A52471F7A9A96910B855322EDB6340D8A00EF092350511E30ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538CD72B03746AE77F5E62292C311562A846505DC82DB854338AE49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B045B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1A41D570D7938DAD4A40E329CCFF46AAA36AD004CF600C8381E425A31D951AE64FDB23FCEC9509D43687FEB69EDD1CC5E0B8CC3BDF64B10EF86B63142A3AB8829555B2F747C932665CB2C0F1CC01BD70229388839D2AF05E454504AC78B7582822846C0BA35C35F5C59160CC046FD8251541FC68C9C86B022BB7099876A460E7451A8A93109703FEE1C217E6C3826E52C51AA691E0E423CFC99E9E31650C1217B624816CDAD9A95F9D5B8019488D9C0A0A1FE3075A577E23183F81D4A3F2FA4571EFC8CE0BA8A4FE8B6855DFE72B0A66EDED2FBABFBE58A30FAFABE1C5D71A87E2F741EF8C1FE86FEA6BBFDE530677F0D97D11D49F7A8443D0822E506A9F4614E011E2A94838FF88CD68C8BB7C5C6424CFFFFFFFFFFFFFFFF
+            )
+        ]
 
-data CurveDH = forall c . (EllipticCurveDH c, NFData (Scalar c), NFData (Point c)) => CurveDH c
+data CurveDH
+    = forall c. (EllipticCurveDH c, NFData (Scalar c), NFData (Point c)) => CurveDH c
 
 benchECDH = map doECDHBench curves
   where
@@ -277,32 +323,38 @@
          in env (generate proxy) $ bench name . nf (run proxy)
 
     generate proxy = do
-        KeyPair _      aScalar <- curveGenerateKeyPair proxy
-        KeyPair bPoint _       <- curveGenerateKeyPair proxy
+        KeyPair _ aScalar <- curveGenerateKeyPair proxy
+        KeyPair bPoint _ <- curveGenerateKeyPair proxy
         return (aScalar, bPoint)
 
     run proxy (s, p) = throwCryptoError (ecdh proxy s p)
 
-    curves = [ ("P256R1", CurveDH Curve_P256R1)
-             , ("P384R1", CurveDH Curve_P384R1)
-             , ("P521R1", CurveDH Curve_P521R1)
-             , ("X25519", CurveDH Curve_X25519)
-             , ("X448",   CurveDH Curve_X448)
-             ]
+    curves =
+        [ ("P256R1", CurveDH Curve_P256R1)
+        , ("P384R1", CurveDH Curve_P384R1)
+        , ("P521R1", CurveDH Curve_P521R1)
+        , ("X25519", CurveDH Curve_X25519)
+        , ("X448", CurveDH Curve_X448)
+        ]
 
-data CurveHashECDSA =
-    forall curve hashAlg . (ECDSA.EllipticCurveECDSA curve,
-                            NFData (Scalar curve),
-                            NFData (Point curve),
-                            HashAlgorithm hashAlg) => CurveHashECDSA curve hashAlg
+data CurveHashECDSA
+    = forall curve hashAlg.
+        ( ECDSA.EllipticCurveECDSA curve
+        , NFData (Scalar curve)
+        , NFData (Point curve)
+        , HashAlgorithm hashAlg
+        ) =>
+      CurveHashECDSA curve hashAlg
 
 benchECDSA = map doECDSABench curveHashes
   where
     doECDSABench (name, CurveHashECDSA c hashAlg) =
         let proxy = Just c -- using Maybe as Proxy
-         in bgroup name
+         in bgroup
+                name
                 [ env (signGenerate proxy) $ bench "sign" . nfIO . signRun proxy hashAlg
-                , env (verifyGenerate proxy hashAlg) $ bench "verify" . nf (verifyRun proxy hashAlg)
+                , env (verifyGenerate proxy hashAlg) $
+                    bench "verify" . nf (verifyRun proxy hashAlg)
                 ]
 
     signGenerate proxy = do
@@ -323,29 +375,29 @@
     tenKB :: IO Bytes
     tenKB = getRandomBytes 10240
 
-    curveHashes = [ ("secp256r1_sha256", CurveHashECDSA Curve_P256R1 SHA256)
-                  , ("secp384r1_sha384", CurveHashECDSA Curve_P384R1 SHA384)
-                  , ("secp521r1_sha512", CurveHashECDSA Curve_P521R1 SHA512)
-                  ]
+    curveHashes =
+        [ ("secp256r1_sha256", CurveHashECDSA Curve_P256R1 SHA256)
+        , ("secp384r1_sha384", CurveHashECDSA Curve_P384R1 SHA384)
+        , ("secp521r1_sha512", CurveHashECDSA Curve_P521R1 SHA512)
+        ]
 
 benchEdDSA =
     [ bgroup "EdDSA-Ed25519" benchGenEd25519
-    , bgroup "Ed25519"       benchEd25519
+    , bgroup "Ed25519" benchEd25519
     ]
   where
     benchGen prx alg =
-        [ bench "sign"   $ perBatchEnv (genEnv prx alg) (run_gen_sign   prx)
+        [ bench "sign" $ perBatchEnv (genEnv prx alg) (run_gen_sign prx)
         , bench "verify" $ perBatchEnv (genEnv prx alg) (run_gen_verify prx)
         ]
 
     benchGenEd25519 = benchGen (Just Curve_Edwards25519) SHA512
-    benchEd25519    =
-        [ bench "sign"   $ perBatchEnv ed25519Env run_ed25519_sign
+    benchEd25519 =
+        [ bench "sign" $ perBatchEnv ed25519Env run_ed25519_sign
         , bench "verify" $ perBatchEnv ed25519Env run_ed25519_verify
         ]
 
     msg = B.empty -- empty message = worst-case scenario showing API overhead
-
     genEnv prx alg _ = do
         sec <- EdDSA.generateSecretKey prx
         let pub = EdDSA.toPublic prx alg sec
@@ -366,19 +418,21 @@
 
     run_ed25519_verify (_, pub, sig) = return (Ed25519.verify pub msg sig)
 
-main = defaultMain
-    [ bgroup "hash" benchHash
-    , bgroup "block-cipher" benchBlockCipher
-    , bgroup "AE" benchAE
-    , bgroup "pbkdf2" benchPBKDF2
-    , bgroup "bcrypt" benchBCrypt
-    , bgroup "ECC" benchECC
-    , bgroup "P256" benchP256
-    , bgroup "DH"
-          [ bgroup "FFDH" benchFFDH
-          , bgroup "ECDH" benchECDH
-          ]
-    , bgroup "ECDSA" benchECDSA
-    , bgroup "EdDSA" benchEdDSA
-    , bgroup "F2m" benchF2m
-    ]
+main =
+    defaultMain
+        [ bgroup "hash" benchHash
+        , bgroup "block-cipher" benchBlockCipher
+        , bgroup "AE" benchAE
+        , bgroup "pbkdf2" benchPBKDF2
+        , bgroup "bcrypt" benchBCrypt
+        , bgroup "ECC" benchECC
+        , bgroup "P256" benchP256
+        , bgroup
+            "DH"
+            [ bgroup "FFDH" benchFFDH
+            , bgroup "ECDH" benchECDH
+            ]
+        , bgroup "ECDSA" benchECDSA
+        , bgroup "EdDSA" benchEdDSA
+        , bgroup "F2m" benchF2m
+        ]
diff --git a/benchs/Number/F2m.hs b/benchs/Number/F2m.hs
--- a/benchs/Number/F2m.hs
+++ b/benchs/Number/F2m.hs
@@ -9,13 +9,13 @@
 import Crypto.Number.F2m
 
 genInteger :: Int -> Int -> Integer
-genInteger salt bits
-    = head
-    . dropWhile ((< bits) . log2)
-    . scanl (\a r -> a * 2^(31 :: Int) + abs r) 0
-    . randoms
-    . mkStdGen
-    $ salt + bits
+genInteger salt bits =
+    head
+        . dropWhile ((< bits) . log2)
+        . scanl (\a r -> a * 2 ^ (31 :: Int) + abs r) 0
+        . randoms
+        . mkStdGen
+        $ salt + bits
 
 benchMod :: Int -> Benchmark
 benchMod bits = bench (show bits) $ nf (modF2m m) a
@@ -46,8 +46,8 @@
 bitsList = [64, 128, 256, 512, 1024, 2048]
 
 benchF2m =
-    [ bgroup    "modF2m" $ map benchMod    bitsList
-    , bgroup    "mulF2m" $ map benchMul    bitsList
+    [ bgroup "modF2m" $ map benchMod bitsList
+    , bgroup "mulF2m" $ map benchMul bitsList
     , bgroup "squareF2m" $ map benchSquare bitsList
-    , bgroup    "invF2m" $ map benchInv    bitsList
+    , bgroup "invF2m" $ map benchInv bitsList
     ]
diff --git a/cbits/crypton_chacha.c b/cbits/crypton_chacha.c
--- a/cbits/crypton_chacha.c
+++ b/cbits/crypton_chacha.c
@@ -260,9 +260,12 @@
 	for (; bytes >= 64; bytes -= 64, src += 64, dst += 64) {
 		/* generate new chunk and update state */
 		chacha_core(ctx->nb_rounds, &out, st);
-		st->d[12] += 1;
-		if (st->d[12] == 0)
-			st->d[13] += 1;
+		uint32_t t0 = le32_to_cpu(st->d[12]);
+		st->d[12] = cpu_to_le32(t0 + 1);
+		if (st->d[12] == 0) {
+			uint32_t t1 = le32_to_cpu(st->d[13]);
+			st->d[13] = cpu_to_le32(t1 + 1);
+		}
 
 		for (i = 0; i < 64; ++i)
 			dst[i] = src[i] ^ out.b[i];
@@ -271,14 +274,17 @@
 	if (bytes > 0) {
 		/* generate new chunk and update state */
 		chacha_core(ctx->nb_rounds, &out, st);
-		st->d[12] += 1;
-		if (st->d[12] == 0)
-			st->d[13] += 1;
+		uint32_t t0 = le32_to_cpu(st->d[12]);
+		st->d[12] = cpu_to_le32(t0 + 1);
+		if (st->d[12] == 0) {
+			uint32_t t1 = le32_to_cpu(st->d[13]);
+			st->d[13] = cpu_to_le32(t1 + 1);
+		}
 
 		/* xor as much as needed */
 		for (i = 0; i < bytes; i++)
 			dst[i] = src[i] ^ out.b[i];
-		
+
 		/* copy the left over in the buffer */
 		ctx->prev_len = 64 - bytes;
 		ctx->prev_ofs = i;
@@ -288,6 +294,41 @@
 	}
 }
 
+uint64_t crypton_chacha_counter64(crypton_chacha_state *st)
+{
+	uint64_t result = ((uint64_t) le32_to_cpu(st->d[12]))
+		| (((uint64_t) le32_to_cpu(st->d[13])) << 32);
+	return result;
+}
+
+uint32_t crypton_chacha_counter32(crypton_chacha_state *st)
+{
+	return le32_to_cpu(st->d[12]);
+}
+
+void crypton_chacha_set_counter64(crypton_chacha_state *st, uint64_t block_counter)
+{
+	uint64_t current_counter;
+	current_counter = ((uint64_t) le32_to_cpu(st->d[12]))
+		| (((uint64_t) le32_to_cpu(st->d[13])) << 32);
+
+	if (current_counter == block_counter)
+		return;
+
+	st->d[12] = cpu_to_le32((uint32_t) block_counter);
+	st->d[13] = cpu_to_le32((uint32_t) (block_counter >> 32));
+}
+
+void crypton_chacha_set_counter32(crypton_chacha_state *st, uint32_t block_counter)
+{
+	uint32_t current_counter = le32_to_cpu(st->d[12]);
+
+	if (current_counter == block_counter)
+		return;
+
+	st->d[12] = cpu_to_le32(block_counter);
+}
+
 void crypton_chacha_generate(uint8_t *dst, crypton_chacha_context *ctx, uint32_t bytes)
 {
 	crypton_chacha_state *st;
@@ -319,18 +360,24 @@
 		for (; bytes >= 64; bytes -= 64, dst += 64) {
 			/* generate new chunk and update state */
 			chacha_core(ctx->nb_rounds, (block *) dst, st);
-			st->d[12] += 1;
-			if (st->d[12] == 0)
-				st->d[13] += 1;
+			uint32_t t0 = le32_to_cpu(st->d[12]);
+			st->d[12] = cpu_to_le32(t0 + 1);
+			if (st->d[12] == 0) {
+				uint32_t t1 = le32_to_cpu(st->d[13]);
+				st->d[13] = cpu_to_le32(t1 + 1);
+			}
 		}
 	} else {
 		/* xor new 64-bytes chunks and store the left over if any */
 		for (; bytes >= 64; bytes -= 64, dst += 64) {
 			/* generate new chunk and update state */
 			chacha_core(ctx->nb_rounds, &out, st);
-			st->d[12] += 1;
-			if (st->d[12] == 0)
-				st->d[13] += 1;
+			uint32_t t0 = le32_to_cpu(st->d[12]);
+			st->d[12] = cpu_to_le32(t0 + 1);
+			if (st->d[12] == 0) {
+				uint32_t t1 = le32_to_cpu(st->d[13]);
+				st->d[13] = cpu_to_le32(t1 + 1);
+			}
 
 			for (i = 0; i < 64; ++i)
 				dst[i] = out.b[i];
@@ -340,19 +387,43 @@
 	if (bytes > 0) {
 		/* generate new chunk and update state */
 		chacha_core(ctx->nb_rounds, &out, st);
-		st->d[12] += 1;
-		if (st->d[12] == 0)
-			st->d[13] += 1;
+		uint32_t t0 = le32_to_cpu(st->d[12]);
+		st->d[12] = cpu_to_le32(t0 + 1);
+		if (st->d[12] == 0) {
+			uint32_t t1 = le32_to_cpu(st->d[13]);
+			st->d[13] = cpu_to_le32(t1 + 1);
+		}
 
 		/* xor as much as needed */
 		for (i = 0; i < bytes; i++)
 			dst[i] = out.b[i];
-		
+
 		/* copy the left over in the buffer */
 		ctx->prev_len = 64 - bytes;
 		ctx->prev_ofs = i;
 		for (; i < 64; i++)
 			ctx->prev[i] = out.b[i];
+	}
+}
+
+void crypton_chacha_generate_simple_block(uint8_t *dst, crypton_chacha_state *st, uint8_t rounds)
+{
+	if (ALIGNED64(dst)) {
+		chacha_core(rounds, (block *) dst, st);
+	} else {
+		block out;
+		int i;
+		chacha_core(rounds, &out, st);
+		for (i = 0; i < 64; ++i) {
+			dst[i] = out.b[i];
+		}
+	}
+
+	uint32_t t0 = le32_to_cpu(st->d[12]);
+	st->d[12] = cpu_to_le32(t0 + 1);
+	if (st->d[12] == 0) {
+		uint32_t t1 = le32_to_cpu(st->d[13]);
+		st->d[13] = cpu_to_le32(t1 + 1);
 	}
 }
 
diff --git a/cbits/crypton_chacha.h b/cbits/crypton_chacha.h
--- a/cbits/crypton_chacha.h
+++ b/cbits/crypton_chacha.h
@@ -51,5 +51,10 @@
 void crypton_xchacha_init(crypton_chacha_context *ctx, uint8_t nb_rounds, const uint8_t *key, const uint8_t *iv);
 void crypton_chacha_combine(uint8_t *dst, crypton_chacha_context *st, const uint8_t *src, uint32_t bytes);
 void crypton_chacha_generate(uint8_t *dst, crypton_chacha_context *st, uint32_t bytes);
-
+uint64_t crypton_chacha_counter64(crypton_chacha_state *st);
+uint32_t crypton_chacha_counter32(crypton_chacha_state *st);
+void crypton_chacha_set_counter64(crypton_chacha_state *st, uint64_t block_counter);
+void crypton_chacha_set_counter32(crypton_chacha_state *st, uint32_t block_counter);
+void crypton_chacha_generate_simple_block(uint8_t *dst, crypton_chacha_state *st, uint8_t rounds);
+#define crypton_chacha_get_state(context) (&((crypton_chacha_context *) context)->st)
 #endif
diff --git a/cbits/decaf/ed448goldilocks/decaf.c b/cbits/decaf/ed448goldilocks/decaf.c
--- a/cbits/decaf/ed448goldilocks/decaf.c
+++ b/cbits/decaf/ed448goldilocks/decaf.c
@@ -18,6 +18,23 @@
 #include <decaf.h>
 #include <decaf/ed448.h>
 
+/* MSVC has no builtint ctz, this is a fix as in
+https://stackoverflow.com/questions/355967/how-to-use-msvc-intrinsics-to-get-the-equivalent-of-this-gcc-code/5468852#5468852
+*/
+#ifdef _MSC_VER
+#include <intrin.h>
+
+uint32_t __inline ctz(uint32_t value)
+{
+    DWORD trailing_zero = 0;
+    if ( _BitScanForward( &trailing_zero, value ) )
+        return trailing_zero;
+    else
+        return 32;  // This is undefined, I better choose 32 than 0
+}
+#define __builtin_ctz(x) ctz(x)
+#endif
+
 /* Template stuff */
 #define API_NS(_id) crypton_decaf_448_##_id
 #define SCALAR_BITS CRYPTON_DECAF_448_SCALAR_BITS
@@ -48,12 +65,25 @@
 
 const uint8_t crypton_decaf_x448_base_point[CRYPTON_DECAF_X448_PUBLIC_BYTES] = { 0x05 };
 
-#if COFACTOR==8 || EDDSA_USE_SIGMA_ISOGENY
-    static const gf SQRT_ONE_MINUS_D = {FIELD_LITERAL(
-        /* NONE */
-    )};
+#define RISTRETTO_FACTOR CRYPTON_DECAF_448_RISTRETTO_FACTOR
+const gf RISTRETTO_FACTOR = {FIELD_LITERAL(
+    0x42ef0f45572736, 0x7bf6aa20ce5296, 0xf4fd6eded26033, 0x968c14ba839a66, 0xb8d54b64a2d780, 0x6aa0a1f1a7b8a5, 0x683bf68d722fa2, 0x22d962fbeb24f7
+)};
+
+#if IMAGINE_TWIST
+#define TWISTED_D (-(EDWARDS_D))
+#else
+#define TWISTED_D ((EDWARDS_D)-1)
 #endif
 
+#if TWISTED_D < 0
+#define EFF_D (-(TWISTED_D))
+#define NEG_D 1
+#else
+#define EFF_D TWISTED_D
+#define NEG_D 0
+#endif
+
 /* End of template stuff */
 
 /* Sanity */
@@ -109,128 +139,112 @@
     crypton_gf_copy(y, t2);
 }
 
-/** Return high bit of x = low bit of 2x mod p */
-static mask_t crypton_gf_lobit(const gf x) {
-    gf y;
-    crypton_gf_copy(y,x);
-    crypton_gf_strong_reduce(y);
-    return -(y->limb[0]&1);
-}
-
 /** identity = (0,1) */
 const point_t API_NS(point_identity) = {{{{{0}}},{{{1}}},{{{1}}},{{{0}}}}};
 
+/* Predeclare because not static: called by elligator */
 void API_NS(deisogenize) (
     crypton_gf_s *__restrict__ s,
-    crypton_gf_s *__restrict__ minus_t_over_s,
+    crypton_gf_s *__restrict__ inv_el_sum,
+    crypton_gf_s *__restrict__ inv_el_m1,
     const point_t p,
-    mask_t toggle_hibit_s,
-    mask_t toggle_hibit_t_over_s,
+    mask_t toggle_s,
+    mask_t toggle_altx,
     mask_t toggle_rotation
 );
 
 void API_NS(deisogenize) (
     crypton_gf_s *__restrict__ s,
-    crypton_gf_s *__restrict__ minus_t_over_s,
+    crypton_gf_s *__restrict__ inv_el_sum,
+    crypton_gf_s *__restrict__ inv_el_m1,
     const point_t p,
-    mask_t toggle_hibit_s,
-    mask_t toggle_hibit_t_over_s,
+    mask_t toggle_s,
+    mask_t toggle_altx,
     mask_t toggle_rotation
 ) {
 #if COFACTOR == 4 && !IMAGINE_TWIST
-    (void) toggle_rotation;
-    
-    gf b, d;
-    crypton_gf_s *c = s, *a = minus_t_over_s;
-    crypton_gf_mulw(a, p->y, 1-EDWARDS_D);
-    crypton_gf_mul(c, a, p->t);     /* -dYT, with EDWARDS_D = d-1 */
-    crypton_gf_mul(a, p->x, p->z); 
-    crypton_gf_sub(d, c, a);  /* aXZ-dYT with a=-1 */
-    crypton_gf_add(a, p->z, p->y); 
-    crypton_gf_sub(b, p->z, p->y); 
-    crypton_gf_mul(c, b, a);
-    crypton_gf_mulw(b, c, -EDWARDS_D); /* (a-d)(Z+Y)(Z-Y) */
-    mask_t ok = crypton_gf_isr (a,b); /* r in the paper */
-    (void)ok; assert(ok | crypton_gf_eq(b,ZERO));
-    crypton_gf_mulw (b, a, -EDWARDS_D); /* u in the paper */
-
-    crypton_gf_mul(c,a,d); /* r(aZX-dYT) */
-    crypton_gf_mul(a,b,p->z); /* uZ */
-    crypton_gf_add(a,a,a); /* 2uZ */
+    (void)toggle_rotation; /* Only applies to cofactor 8 */
+    gf t1;
+    crypton_gf_s *t2 = s, *t3=inv_el_sum, *t4=inv_el_m1;
     
-    mask_t tg = toggle_hibit_t_over_s ^ ~crypton_gf_hibit(minus_t_over_s);
-    crypton_gf_cond_neg(minus_t_over_s, tg); /* t/s <-? -t/s */
-    crypton_gf_cond_neg(c, tg); /* u <- -u if negative. */
+    crypton_gf_add(t1,p->x,p->t);
+    crypton_gf_sub(t2,p->x,p->t);
+    crypton_gf_mul(t3,t1,t2); /* t3 = num */
+    crypton_gf_sqr(t2,p->x);
+    crypton_gf_mul(t1,t2,t3);
+    crypton_gf_mulw(t2,t1,-1-TWISTED_D); /* -x^2 * (a-d) * num */
+    crypton_gf_isr(t1,t2);    /* t1 = isr */
+    crypton_gf_mul(t2,t1,t3); /* t2 = ratio */
+    crypton_gf_mul(t4,t2,RISTRETTO_FACTOR);
+    mask_t negx = crypton_gf_lobit(t4) ^ toggle_altx;
+    crypton_gf_cond_neg(t2, negx);
+    crypton_gf_mul(t3,t2,p->z);
+    crypton_gf_sub(t3,t3,p->t);
+    crypton_gf_mul(t2,t3,p->x);
+    crypton_gf_mulw(t4,t2,-1-TWISTED_D);
+    crypton_gf_mul(s,t4,t1);
+    mask_t lobs = crypton_gf_lobit(s);
+    crypton_gf_cond_neg(s,lobs);
+    crypton_gf_copy(inv_el_m1,p->x);
+    crypton_gf_cond_neg(inv_el_m1,~lobs^negx^toggle_s);
+    crypton_gf_add(inv_el_m1,inv_el_m1,p->t);
     
-    crypton_gf_add(d,c,p->y);
-    crypton_gf_mul(s,b,d);
-    crypton_gf_cond_neg(s, toggle_hibit_s ^ crypton_gf_hibit(s));
-#else
+#elif COFACTOR == 8 && IMAGINE_TWIST
     /* More complicated because of rotation */
-    /* MAGIC This code is wrong for certain non-Curve25519 curves;
-     * check if it's because of Cofactor==8 or IMAGINE_TWIST */
-    
-    gf c, d;
-    crypton_gf_s *b = s, *a = minus_t_over_s;
+    gf t1,t2,t3,t4,t5;
+    crypton_gf_add(t1,p->z,p->y);
+    crypton_gf_sub(t2,p->z,p->y);
+    crypton_gf_mul(t3,t1,t2);      /* t3 = num */
+    crypton_gf_mul(t2,p->x,p->y);  /* t2 = den */
+    crypton_gf_sqr(t1,t2);
+    crypton_gf_mul(t4,t1,t3);
+    crypton_gf_mulw(t1,t4,-1-TWISTED_D);
+    crypton_gf_isr(t4,t1);         /* isqrt(num*(a-d)*den^2) */
+    crypton_gf_mul(t1,t2,t4);
+    crypton_gf_mul(t2,t1,RISTRETTO_FACTOR); /* t2 = "iden" in ristretto.sage */
+    crypton_gf_mul(t1,t3,t4);                 /* t1 = "inum" in ristretto.sage */
 
-    #if IMAGINE_TWIST
-        gf x, t;
-        crypton_gf_div_qnr(x,p->x);
-        crypton_gf_div_qnr(t,p->t);
-        crypton_gf_add ( a, p->z, x );
-        crypton_gf_sub ( b, p->z, x );
-        crypton_gf_mul ( c, a, b ); /* "zx" = Z^2 - aX^2 = Z^2 - X^2 */
-    #else
-        const crypton_gf_s *x = p->x, *t = p->t;
-        crypton_gf_sqr ( a, p->z );
-        crypton_gf_sqr ( b, p->x );
-        crypton_gf_add ( c, a, b ); /* "zx" = Z^2 - aX^2 = Z^2 + X^2 */
-    #endif
-    /* Here: c = "zx" in the SAGE code = Z^2 - aX^2 */
+    /* Calculate altxy = iden*inum*i*t^2*(d-a) */
+    crypton_gf_mul(t3,t1,t2);
+    crypton_gf_mul_i(t4,t3);
+    crypton_gf_mul(t3,t4,p->t);
+    crypton_gf_mul(t4,t3,p->t);
+    crypton_gf_mulw(t3,t4,TWISTED_D+1);      /* iden*inum*i*t^2*(d-1) */
+    mask_t rotate = toggle_rotation ^ crypton_gf_lobit(t3);
     
-    crypton_gf_mul ( a, p->z, t ); /* "tz" = T*Z */
-    crypton_gf_sqr ( b, a );
-    crypton_gf_mul ( d, b, c ); /* (TZ)^2 * (Z^2-aX^2) */
-    mask_t ok = crypton_gf_isr(b, d);
-    (void)ok; assert(ok | crypton_gf_eq(d,ZERO));
-    crypton_gf_mul ( d, b, a ); /* "osx" = 1 / sqrt(z^2-ax^2) */
-    crypton_gf_mul ( a, b, c ); 
-    crypton_gf_mul ( b, a, d ); /* 1/tz */
-
-    mask_t rotate;
-    #if (COFACTOR == 8)
-        gf e;
-        crypton_gf_sqr(e, p->z);
-        crypton_gf_mul(a, e, b); /* z^2 / tz = z/t = 1/xy */
-        rotate = crypton_gf_hibit(a) ^ toggle_rotation;
-        /* Curve25519: cond select between zx * 1/tz or sqrt(1-d); y=-x */
-        crypton_gf_mul ( a, b, c ); 
-        crypton_gf_cond_sel ( a, a, SQRT_ONE_MINUS_D, rotate );
-        crypton_gf_cond_sel ( e, p->y, x, rotate );
-    #else
-        const crypton_gf_s *e = x;
-        (void)toggle_rotation;
-        rotate = 0;
-    #endif
+    /* Rotate if altxy is negative */
+    crypton_gf_cond_swap(t1,t2,rotate);
+    crypton_gf_mul_i(t4,p->x);
+    crypton_gf_cond_sel(t4,p->y,t4,rotate);  /* t4 = "fac" = ix if rotate, else y */
     
-    crypton_gf_mul ( c, a, d ); // new "osx"
-    crypton_gf_mul ( a, c, p->z );
-    crypton_gf_add ( minus_t_over_s, a, a ); // 2 * "osx" * Z
-    crypton_gf_mul ( d, b, p->z );
+    crypton_gf_mul_i(t5,RISTRETTO_FACTOR); /* t5 = imi */
+    crypton_gf_mul(t3,t5,t2);                /* iden * imi */
+    crypton_gf_mul(t2,t5,t1);
+    crypton_gf_mul(t5,t2,p->t);              /* "altx" = iden*imi*t */
+    mask_t negx = crypton_gf_lobit(t5) ^ toggle_altx;
     
-    mask_t tg = toggle_hibit_t_over_s ^~ crypton_gf_hibit(minus_t_over_s);
-    crypton_gf_cond_neg ( minus_t_over_s, tg );
-    crypton_gf_cond_neg ( c, rotate ^ tg );
-    crypton_gf_add ( d, d, c );
-    crypton_gf_mul ( s, d, e ); /* here "x" = y unless rotate */
-    crypton_gf_cond_neg ( s, toggle_hibit_s ^ crypton_gf_hibit(s) );
+    crypton_gf_cond_neg(t1,negx^rotate);
+    crypton_gf_mul(t2,t1,p->z);
+    crypton_gf_add(t2,t2,ONE);
+    crypton_gf_mul(inv_el_sum,t2,t4);
+    crypton_gf_mul(s,inv_el_sum,t3);
+    
+    mask_t negs = crypton_gf_lobit(s);
+    crypton_gf_cond_neg(s,negs);
+    
+    mask_t negz = ~negs ^ toggle_s ^ negx;
+    crypton_gf_copy(inv_el_m1,p->z);
+    crypton_gf_cond_neg(inv_el_m1,negz);
+    crypton_gf_sub(inv_el_m1,inv_el_m1,t4);
+#else
+#error "Cofactor must be 4 (with no IMAGINE_TWIST) or 8 (with IMAGINE_TWIST)"
 #endif
 }
 
 void API_NS(point_encode)( unsigned char ser[SER_BYTES], const point_t p ) {
-    gf s, mtos;
-    API_NS(deisogenize)(s,mtos,p,0,0,0);
-    crypton_gf_serialize(ser,s,0);
+    gf s,ie1,ie2;
+    API_NS(deisogenize)(s,ie1,ie2,p,0,0,0);
+    crypton_gf_serialize(ser,s);
 }
 
 crypton_decaf_error_t API_NS(point_decode) (
@@ -238,89 +252,54 @@
     const unsigned char ser[SER_BYTES],
     crypton_decaf_bool_t allow_identity
 ) {
-    gf s, a, b, c, d, e, f;
+    gf s, s2, num, tmp;
+    crypton_gf_s *tmp2=s2, *ynum=p->z, *isr=p->x, *den=p->t;
+    
     mask_t succ = crypton_gf_deserialize(s, ser, 0);
-    mask_t zero = crypton_gf_eq(s, ZERO);
-    succ &= bool_to_mask(allow_identity) | ~zero;
-    crypton_gf_sqr ( a, s ); /* s^2 */
+    succ &= bool_to_mask(allow_identity) | ~crypton_gf_eq(s, ZERO);
+    succ &= ~crypton_gf_lobit(s);
+    
+    crypton_gf_sqr(s2,s);                  /* s^2 = -as^2 */
 #if IMAGINE_TWIST
-    crypton_gf_sub ( f, ONE, a ); /* f = 1-as^2 = 1-s^2*/
-#else
-    crypton_gf_add ( f, ONE, a ); /* f = 1-as^2 = 1+s^2 */
+    crypton_gf_sub(s2,ZERO,s2);            /* -as^2 */
 #endif
-    succ &= ~ crypton_gf_eq( f, ZERO );
-    crypton_gf_sqr ( b, f );  /* (1-as^2)^2 = 1 - 2as^2 + a^2 s^4 */
-    crypton_gf_mulw ( c, a, 4*IMAGINE_TWIST-4*EDWARDS_D ); 
-    crypton_gf_add ( c, c, b ); /* t^2 = 1 + (2a-4d) s^2 + s^4 */
-    crypton_gf_mul ( d, f, s ); /* s * (1-as^2) for denoms */
-    crypton_gf_sqr ( e, d );    /* s^2 * (1-as^2)^2 */
-    crypton_gf_mul ( b, c, e ); /* t^2 * s^2 * (1-as^2)^2 */
+    crypton_gf_sub(den,ONE,s2);            /* 1+as^2 */
+    crypton_gf_add(ynum,ONE,s2);           /* 1-as^2 */
+    crypton_gf_mulw(num,s2,-4*TWISTED_D);
+    crypton_gf_sqr(tmp,den);               /* tmp = den^2 */
+    crypton_gf_add(num,tmp,num);           /* num = den^2 - 4*d*s^2 */
+    crypton_gf_mul(tmp2,num,tmp);          /* tmp2 = num*den^2 */
+    succ &= crypton_gf_isr(isr,tmp2);      /* isr = 1/sqrt(num*den^2) */
+    crypton_gf_mul(tmp,isr,den);           /* isr*den */
+    crypton_gf_mul(p->y,tmp,ynum);         /* isr*den*(1-as^2) */
+    crypton_gf_mul(tmp2,tmp,s);            /* s*isr*den */
+    crypton_gf_add(tmp2,tmp2,tmp2);        /* 2*s*isr*den */
+    crypton_gf_mul(tmp,tmp2,isr);          /* 2*s*isr^2*den */
+    crypton_gf_mul(p->x,tmp,num);          /* 2*s*isr^2*den*num */
+    crypton_gf_mul(tmp,tmp2,RISTRETTO_FACTOR); /* 2*s*isr*den*magic */
+    crypton_gf_cond_neg(p->x,crypton_gf_lobit(tmp)); /* flip x */
     
-    succ &= crypton_gf_isr(e,b) | crypton_gf_eq(b,ZERO); /* e = 1/(t s (1-as^2)) */
-    crypton_gf_mul ( b, e, d ); /* 1 / t */
-    crypton_gf_mul ( d, e, c ); /* t / (s(1-as^2)) */
-    crypton_gf_mul ( e, d, f ); /* t / s */
-    mask_t negtos = crypton_gf_hibit(e);
-    crypton_gf_cond_neg(b, negtos);
-    crypton_gf_cond_neg(d, negtos);
-
-#if IMAGINE_TWIST
-    crypton_gf_add ( p->z, ONE, a); /* Z = 1+as^2 = 1-s^2 */
-#else
-    crypton_gf_sub ( p->z, ONE, a); /* Z = 1+as^2 = 1-s^2 */
+#if COFACTOR==8
+    /* Additionally check y != 0 and x*y*isomagic nonegative */
+    succ &= ~crypton_gf_eq(p->y,ZERO);
+    crypton_gf_mul(tmp,p->x,p->y);
+    crypton_gf_mul(tmp2,tmp,RISTRETTO_FACTOR);
+    succ &= ~crypton_gf_lobit(tmp2);
 #endif
 
-#if COFACTOR == 8
-    crypton_gf_mul ( a, p->z, d); /* t(1+s^2) / s(1-s^2) = 2/xy */
-    succ &= ~crypton_gf_lobit(a); /* = ~crypton_gf_hibit(a/2), since crypton_gf_hibit(x) = crypton_gf_lobit(2x) */
-#endif
-    
-    crypton_gf_mul ( a, f, b ); /* y = (1-s^2) / t */
-    crypton_gf_mul ( p->y, p->z, a ); /* Y = yZ */
 #if IMAGINE_TWIST
-    crypton_gf_add ( b, s, s );
-    crypton_gf_mul(p->x, b, SQRT_MINUS_ONE); /* Curve25519 */
-#else
-    crypton_gf_add ( p->x, s, s );
-#endif
-    crypton_gf_mul ( p->t, p->x, a ); /* T = 2s (1-as^2)/t */
-    
-#if UNSAFE_CURVE_HAS_POINTS_AT_INFINITY
-    /* This can't happen for any of the supported configurations.
-     *
-     * If it can happen (because s=1), it's because the curve has points
-     * at infinity, which means that there may be critical security bugs
-     * elsewhere in the library.  In that case, it's better that you hit
-     * the assertion in point_valid, which will happen in the test suite
-     * since it tests s=1.
-     *
-     * This debugging option is to allow testing of IMAGINE_TWIST = 0 on
-     * Ed25519, without hitting that assertion.  Don't use it in
-     * production.
-     */
-    succ &= ~crypton_gf_eq(p->z,ZERO);
+    crypton_gf_copy(tmp,p->x);
+    crypton_gf_mul_i(p->x,tmp);
 #endif
+
+    /* Fill in z and t */
+    crypton_gf_copy(p->z,ONE);
+    crypton_gf_mul(p->t,p->x,p->y);
     
-    p->y->limb[0] -= zero;
     assert(API_NS(point_valid)(p) | ~succ);
-    
     return crypton_decaf_succeed_if(mask_to_bool(succ));
 }
 
-#if IMAGINE_TWIST
-#define TWISTED_D (-(EDWARDS_D))
-#else
-#define TWISTED_D ((EDWARDS_D)-1)
-#endif
-
-#if TWISTED_D < 0
-#define EFF_D (-(TWISTED_D))
-#define NEG_D 1
-#else
-#define EFF_D TWISTED_D
-#define NEG_D 0
-#endif
-
 void API_NS(point_sub) (
     point_t p,
     const point_t q,
@@ -563,6 +542,7 @@
     const point_t b,
     const scalar_t scalar
 ) {
+
     const int WINDOW = CRYPTON_DECAF_WINDOW_BITS,
         WINDOW_MASK = (1<<WINDOW)-1,
         WINDOW_T_MASK = WINDOW_MASK >> 1,
@@ -573,7 +553,7 @@
     API_NS(scalar_halve)(scalar1x,scalar1x);
     
     /* Set up a precomputed table with odd multiples of b. */
-    pniels_t pn, multiples[NTABLE];
+    pniels_t pn, multiples[1<<((int)(CRYPTON_DECAF_WINDOW_BITS)-1)];  // == NTABLE (MSVC compatibility issue)
     point_t tmp;
     prepare_fixed_window(multiples, b, NTABLE);
 
@@ -624,12 +604,13 @@
     const scalar_t scalarb,
     const point_t c,
     const scalar_t scalarc
-) {
+) {    
+    
     const int WINDOW = CRYPTON_DECAF_WINDOW_BITS,
         WINDOW_MASK = (1<<WINDOW)-1,
         WINDOW_T_MASK = WINDOW_MASK >> 1,
         NTABLE = 1<<(WINDOW-1);
-        
+
     scalar_t scalar1x, scalar2x;
     API_NS(scalar_add)(scalar1x, scalarb, point_scalarmul_adjustment);
     API_NS(scalar_halve)(scalar1x,scalar1x);
@@ -637,9 +618,10 @@
     API_NS(scalar_halve)(scalar2x,scalar2x);
     
     /* Set up a precomputed table with odd multiples of b. */
-    pniels_t pn, multiples1[NTABLE], multiples2[NTABLE];
+    pniels_t pn, multiples1[1<<((int)(CRYPTON_DECAF_WINDOW_BITS)-1)], multiples2[1<<((int)(CRYPTON_DECAF_WINDOW_BITS)-1)];
+    // Array size above equal NTABLE (MSVC compatibility issue)
     point_t tmp;
-    prepare_fixed_window(multiples1, b, NTABLE);
+    prepare_fixed_window(multiples1, b, NTABLE);  
     prepare_fixed_window(multiples2, c, NTABLE);
 
     /* Initialize. */
@@ -701,11 +683,13 @@
     const scalar_t scalar1,
     const scalar_t scalar2
 ) {
+    
     const int WINDOW = CRYPTON_DECAF_WINDOW_BITS,
         WINDOW_MASK = (1<<WINDOW)-1,
         WINDOW_T_MASK = WINDOW_MASK >> 1,
         NTABLE = 1<<(WINDOW-1);
-        
+
+
     scalar_t scalar1x, scalar2x;
     API_NS(scalar_add)(scalar1x, scalar1, point_scalarmul_adjustment);
     API_NS(scalar_halve)(scalar1x,scalar1x);
@@ -713,7 +697,9 @@
     API_NS(scalar_halve)(scalar2x,scalar2x);
     
     /* Set up a precomputed table with odd multiples of b. */
-    point_t multiples1[NTABLE], multiples2[NTABLE], working, tmp;
+    point_t multiples1[1<<((int)(CRYPTON_DECAF_WINDOW_BITS)-1)], multiples2[1<<((int)(CRYPTON_DECAF_WINDOW_BITS)-1)], working, tmp;
+    // Array sizes above equal NTABLE (MSVC compatibility issue)
+
     pniels_t pn;
     
     API_NS(point_copy)(working, b);
@@ -801,7 +787,7 @@
     crypton_gf_mul ( b, q->y, p->x );
     mask_t succ = crypton_gf_eq(a,b);
     
-    #if (COFACTOR == 8) && IMAGINE_TWIST
+    #if (COFACTOR == 8)
         crypton_gf_mul ( a, p->y, q->y );
         crypton_gf_mul ( b, q->x, p->x );
         #if !(IMAGINE_TWIST)
@@ -936,11 +922,11 @@
     const unsigned int n = COMBS_N, t = COMBS_T, s = COMBS_S;
     assert(n*t*s >= SCALAR_BITS);
   
-    point_t working, start, doubles[t-1];
+    point_t working, start, doubles[COMBS_T-1];
     API_NS(point_copy)(working, base);
     pniels_t pn_tmp;
   
-    gf zs[n<<(t-1)], zis[n<<(t-1)];
+    gf zs[(unsigned int)(COMBS_N)<<(unsigned int)(COMBS_T-1)], zis[(unsigned int)(COMBS_N)<<(unsigned int)(COMBS_T-1)];
   
     unsigned int i,j,k;
     
@@ -1078,7 +1064,7 @@
     return succ;
 }
 
-void API_NS(point_mul_by_cofactor_and_encode_like_eddsa) (
+void API_NS(point_mul_by_ratio_and_encode_like_eddsa) (
     uint8_t enc[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
     const point_t p
 ) {
@@ -1116,15 +1102,20 @@
         crypton_gf_mul ( y, u, t ); // (x^2+y^2)(2z^2-y^2+x^2)
         crypton_gf_mul ( u, z, t );
         crypton_gf_copy( z, u );
-        crypton_gf_mul ( u, x, SQRT_ONE_MINUS_D );
+        crypton_gf_mul ( u, x, RISTRETTO_FACTOR );
+#if IMAGINE_TWIST
+        crypton_gf_mul_i( x, u );
+#else
+#error "... probably wrong"
         crypton_gf_copy( x, u );
+#endif
         crypton_decaf_bzero(u,sizeof(u));
     }
 #elif IMAGINE_TWIST
     {
         API_NS(point_double)(q,q);
         API_NS(point_double)(q,q);
-        crypton_gf_mul_qnr(x, q->x);
+        crypton_gf_mul_i(x, q->x);
         crypton_gf_copy(y, q->y);
         crypton_gf_copy(z, q->z);
     }
@@ -1137,7 +1128,7 @@
         crypton_gf_add( u, x, t );
         crypton_gf_add( z, q->y, q->x );
         crypton_gf_sqr ( y, z);
-        crypton_gf_sub ( y, u, y );
+        crypton_gf_sub ( y, y, u );
         crypton_gf_sub ( z, t, x );
         crypton_gf_sqr ( x, q->z );
         crypton_gf_add ( t, x, x); 
@@ -1155,7 +1146,7 @@
     
     /* Encode */
     enc[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES-1] = 0;
-    crypton_gf_serialize(enc, x, 1);
+    crypton_gf_serialize(enc, x);
     enc[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES-1] |= 0x80 & crypton_gf_lobit(t);
 
     crypton_decaf_bzero(x,sizeof(x));
@@ -1166,7 +1157,7 @@
 }
 
 
-crypton_decaf_error_t API_NS(point_decode_like_eddsa_and_ignore_cofactor) (
+crypton_decaf_error_t API_NS(point_decode_like_eddsa_and_mul_by_ratio) (
     point_t p,
     const uint8_t enc[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES]
 ) {
@@ -1176,7 +1167,7 @@
     mask_t low = ~word_is_zero(enc2[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES-1] & 0x80);
     enc2[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES-1] &= ~0x80;
     
-    mask_t succ = crypton_gf_deserialize(p->y, enc2, 1);
+    mask_t succ = crypton_gf_deserialize(p->y, enc2, 0);
 #if 0 == 0
     succ &= word_is_zero(enc2[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES-1]);
 #endif
@@ -1196,7 +1187,7 @@
     succ &= crypton_gf_isr(p->t,p->x); /* 1/sqrt(num * denom) */
     
     crypton_gf_mul(p->x,p->t,p->z); /* sqrt(num / denom) */
-    crypton_gf_cond_neg(p->x,~crypton_gf_lobit(p->x)^low);
+    crypton_gf_cond_neg(p->x,crypton_gf_lobit(p->x)^low);
     crypton_gf_copy(p->z,ONE);
   
     #if EDDSA_USE_SIGMA_ISOGENY
@@ -1221,8 +1212,9 @@
         crypton_gf_sub ( p->t, a, c ); // y^2 - x^2
         crypton_gf_sqr ( p->x, p->z );
         crypton_gf_add ( p->z, p->x, p->x );
-        crypton_gf_sub ( a, p->z, p->t ); // 2z^2 - y^2 + x^2
-        crypton_gf_mul ( c, a, SQRT_ONE_MINUS_D );
+        crypton_gf_sub ( c, p->z, p->t ); // 2z^2 - y^2 + x^2
+        crypton_gf_div_i ( a, c );
+        crypton_gf_mul ( c, a, RISTRETTO_FACTOR );
         crypton_gf_mul ( p->x, b, p->t); // (2xy)(y^2-x^2)
         crypton_gf_mul ( p->z, p->t, c ); // (y^2-x^2)sd(2z^2 - y^2 + x^2)
         crypton_gf_mul ( p->y, d, c ); // (y^2+x^2)sd(2z^2 - y^2 + x^2)
@@ -1265,6 +1257,7 @@
     
     crypton_decaf_bzero(enc2,sizeof(enc2));
     assert(API_NS(point_valid)(p) || ~succ);
+    
     return crypton_decaf_succeed_if(mask_to_bool(succ));
 }
 
@@ -1274,7 +1267,7 @@
     const uint8_t scalar[X_PRIVATE_BYTES]
 ) {
     gf x1, x2, z2, x3, z3, t1, t2;
-    ignore_result(crypton_gf_deserialize(x1,base,1));
+    ignore_result(crypton_gf_deserialize(x1,base,0));
     crypton_gf_copy(x2,ONE);
     crypton_gf_copy(z2,ZERO);
     crypton_gf_copy(x3,x1);
@@ -1290,8 +1283,7 @@
         if (t/8==0) sb &= -(uint8_t)COFACTOR;
         else if (t == X_PRIVATE_BITS-1) sb = -1;
         
-        mask_t k_t = (sb>>(t%8)) & 1;
-        k_t = -k_t; /* set to all 0s or all 1s */
+        mask_t k_t = bit_to_mask((sb>>(t%8)) & 1);
         
         swap ^= k_t;
         crypton_gf_cond_swap(x2,x3,swap);
@@ -1325,7 +1317,7 @@
     crypton_gf_cond_swap(z2,z3,swap);
     crypton_gf_invert(z2,z2,0);
     crypton_gf_mul(x1,x2,z2);
-    crypton_gf_serialize(out,x1,1);
+    crypton_gf_serialize(out,x1);
     mask_t nz = ~crypton_gf_eq(x1,ZERO);
     
     crypton_decaf_bzero(x1,sizeof(x1));
@@ -1345,15 +1337,8 @@
     const uint8_t ed[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES]
 ) {
     gf y;
-    {
-        uint8_t enc2[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES];
-        memcpy(enc2,ed,sizeof(enc2));
-
-        /* retrieve y from the ed compressed point */
-        enc2[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES-1] &= ~0x80;
-        ignore_result(crypton_gf_deserialize(y, enc2, 0));
-        crypton_decaf_bzero(enc2,sizeof(enc2));
-    }
+    const uint8_t mask = (uint8_t)(0xFE<<(7));
+    ignore_result(crypton_gf_deserialize(y, ed, mask));
     
     {
         gf n,d;
@@ -1364,7 +1349,7 @@
         crypton_gf_sub(d, ONE, y); /* d = 1-y */
         crypton_gf_invert(d, d, 0); /* d = 1/(1-y) */
         crypton_gf_mul(y, n, d); /* u = (y+1)/(1-y) */
-        crypton_gf_serialize(x,y,1);
+        crypton_gf_serialize(x,y);
 #else /* EDDSA_USE_SIGMA_ISOGENY */
         /* u = y^2 * (1-dy^2) / (1-y^2) */
         crypton_gf_sqr(n,y); /* y^2*/
@@ -1374,7 +1359,7 @@
         crypton_gf_mulw(d,n,EDWARDS_D); /* dy^2*/
         crypton_gf_sub(d, ONE, d); /* 1-dy^2*/
         crypton_gf_mul(n, y, d); /* y^2 * (1-dy^2) / (1-y^2) */
-        crypton_gf_serialize(x,n,1);
+        crypton_gf_serialize(x,n);
 #endif /* EDDSA_USE_SIGMA_ISOGENY */
         
         crypton_decaf_bzero(y,sizeof(y));
@@ -1390,6 +1375,26 @@
     crypton_decaf_x448_derive_public_key(out,scalar);
 }
 
+void API_NS(point_mul_by_ratio_and_encode_like_x448) (
+    uint8_t out[X_PUBLIC_BYTES],
+    const point_t p
+) {
+    point_t q;
+#if COFACTOR == 8
+    point_double_internal(q,p,1);
+#else
+    API_NS(point_copy)(q,p);
+#endif
+    crypton_gf_invert(q->t,q->x,0); /* 1/x */
+    crypton_gf_mul(q->z,q->t,q->y); /* y/x */
+    crypton_gf_sqr(q->y,q->z); /* (y/x)^2 */
+#if IMAGINE_TWIST
+    crypton_gf_sub(q->y,ZERO,q->y);
+#endif
+    crypton_gf_serialize(out,q->y);
+    API_NS(point_destroy(q));
+}
+
 void crypton_decaf_x448_derive_public_key (
     uint8_t out[X_PUBLIC_BYTES],
     const uint8_t scalar[X_PRIVATE_BYTES]
@@ -1399,45 +1404,19 @@
     memcpy(scalar2,scalar,sizeof(scalar2));
     scalar2[0] &= -(uint8_t)COFACTOR;
     
-    scalar2[X_PRIVATE_BYTES-1] &= ~(-1u<<((X_PRIVATE_BITS+7)%8));
+    scalar2[X_PRIVATE_BYTES-1] &= ~(0xFF<<((X_PRIVATE_BITS+7)%8));
     scalar2[X_PRIVATE_BYTES-1] |= 1<<((X_PRIVATE_BITS+7)%8);
     
     scalar_t the_scalar;
     API_NS(scalar_decode_long)(the_scalar,scalar2,sizeof(scalar2));
     
-    /* We're gonna isogenize by 2, so divide by 2.
-     *
-     * Why by 2, even though it's a 4-isogeny?
-     *
-     * The isogeny map looks like
-     * Montgomery <-2-> Jacobi <-2-> Edwards
-     *
-     * Since the Jacobi base point is the PREimage of the iso to
-     * the Montgomery curve, and we're going
-     * Jacobi -> Edwards -> Jacobi -> Montgomery,
-     * we pick up only a factor of 2 over Jacobi -> Montgomery. 
-     */
-    API_NS(scalar_halve)(the_scalar,the_scalar);
+    /* Compensate for the encoding ratio */
+    for (unsigned i=1; i<CRYPTON_DECAF_X448_ENCODE_RATIO; i<<=1) {
+        API_NS(scalar_halve)(the_scalar,the_scalar);
+    }
     point_t p;
     API_NS(precomputed_scalarmul)(p,API_NS(precomputed_base),the_scalar);
-    
-    /* Isogenize to Montgomery curve.
-     *
-     * Why isn't this just a separate function, eg crypton_decaf_encode_like_x448?
-     * Basically because in general it does the wrong thing if there is a cofactor
-     * component in the input.  In this function though, there isn't a cofactor
-     * component in the input.
-     */
-    crypton_gf_invert(p->t,p->x,0); /* 1/x */
-    crypton_gf_mul(p->z,p->t,p->y); /* y/x */
-    crypton_gf_sqr(p->y,p->z); /* (y/x)^2 */
-#if IMAGINE_TWIST
-    crypton_gf_sub(p->y,ZERO,p->y);
-#endif
-    crypton_gf_serialize(out,p->y,1);
-        
-    crypton_decaf_bzero(scalar2,sizeof(scalar2));
-    API_NS(scalar_destroy)(the_scalar);
+    API_NS(point_mul_by_ratio_and_encode_like_x448)(out,p);
     API_NS(point_destroy)(p);
 }
 
@@ -1566,13 +1545,13 @@
 ) {
     const int table_bits_var = CRYPTON_DECAF_WNAF_VAR_TABLE_BITS,
         table_bits_pre = CRYPTON_DECAF_WNAF_FIXED_TABLE_BITS;
-    struct smvt_control control_var[SCALAR_BITS/(table_bits_var+1)+3];
-    struct smvt_control control_pre[SCALAR_BITS/(table_bits_pre+1)+3];
+    struct smvt_control control_var[SCALAR_BITS/((int)(CRYPTON_DECAF_WNAF_VAR_TABLE_BITS)+1)+3];
+    struct smvt_control control_pre[SCALAR_BITS/((int)(CRYPTON_DECAF_WNAF_FIXED_TABLE_BITS)+1)+3];
     
     int ncb_pre = recode_wnaf(control_pre, scalar1, table_bits_pre);
     int ncb_var = recode_wnaf(control_var, scalar2, table_bits_var);
   
-    pniels_t precmp_var[1<<table_bits_var];
+    pniels_t precmp_var[1<<(int)(CRYPTON_DECAF_WNAF_VAR_TABLE_BITS)];
     prepare_wnaf_table(precmp_var, base2, table_bits_var);
   
     int contp=0, contv=0, i = control_var[0].power;
diff --git a/cbits/decaf/ed448goldilocks/decaf_tables.c b/cbits/decaf/ed448goldilocks/decaf_tables.c
--- a/cbits/decaf/ed448goldilocks/decaf_tables.c
+++ b/cbits/decaf/ed448goldilocks/decaf_tables.c
@@ -5,350 +5,350 @@
 
 #define API_NS(_id) crypton_decaf_448_##_id
 const API_NS(point_t) API_NS(point_base) = {{
-{FIELD_LITERAL(0x00fffffffffffffe,0x00ffffffffffffff,0x00ffffffffffffff,0x00ffffffffffffff,0x0000000000000003,0x0000000000000000,0x0000000000000000,0x0000000000000000)},
-  {FIELD_LITERAL(0x0081e6d37f752992,0x003078ead1c28721,0x00135cfd2394666c,0x0041149c50506061,0x0031d30e4f5490b3,0x00902014990dc141,0x0052341b04c1e328,0x0014237853c10a1b)},
-  {FIELD_LITERAL(0x00fffffffffffffb,0x00ffffffffffffff,0x00ffffffffffffff,0x00ffffffffffffff,0x00fffffffffffffe,0x00ffffffffffffff,0x00ffffffffffffff,0x00ffffffffffffff)},
-  {FIELD_LITERAL(0x008f205b70660415,0x00881c60cfd3824f,0x00377a638d08500d,0x008c66d5d4672615,0x00e52fa558e08e13,0x0087770ae1b6983d,0x004388f55a0aa7ff,0x00b4d9a785cf1a91)}
+{FIELD_LITERAL(0x0000000000000000,0x0000000000000000,0x0000000000000000,0x0080000000000000,0x00fffffffffffffe,0x00ffffffffffffff,0x00ffffffffffffff,0x007fffffffffffff)},
+  {FIELD_LITERAL(0x006079b4dfdd4a64,0x000c1e3ab470a1c8,0x0044d73f48e5199b,0x0050452714141818,0x004c74c393d5242c,0x0024080526437050,0x00d48d06c13078ca,0x008508de14f04286)},
+  {FIELD_LITERAL(0x0000000000000001,0x0000000000000000,0x0000000000000000,0x0000000000000000,0x0000000000000000,0x0000000000000000,0x0000000000000000,0x0000000000000000)},
+  {FIELD_LITERAL(0x00e3c816dc198105,0x0062071833f4e093,0x004dde98e3421403,0x00a319b57519c985,0x00794be956382384,0x00e1ddc2b86da60f,0x0050e23d5682a9ff,0x006d3669e173c6a4)}
 }};
 const gf API_NS(precomputed_base_as_fe)[240]
 VECTOR_ALIGNED = {
-  {FIELD_LITERAL(0x00e614a9f7278dc5,0x002e454ad04c5124,0x00d8f58cee1436f3,0x00c83ed46e4180ec,0x00a41e93274a38fa,0x00c1e7e53257771e,0x0043e0ff03c0392f,0x002c7c6405ce61df)},
-  {FIELD_LITERAL(0x0033c4f9dc990b33,0x00c291cb1ceb55c3,0x002ae3f58ade88b2,0x006b1f9f11395474,0x002ded6e4b27ff7c,0x0041012ed4aa10e1,0x003c22d20a36bae7,0x001f584eed472b19)},
-  {FIELD_LITERAL(0x00c3514779ee6f60,0x001574c873b20c2b,0x004cd6a46a5a5e65,0x0059a068aeb4204a,0x004c610458bc354d,0x00e94567479d02d2,0x00feaf77ed118e28,0x00f58a8bf115eeb5)},
-  {FIELD_LITERAL(0x0046110878fcb20f,0x00df43db21cc6f32,0x00ffdde9f4516644,0x00519917791686b9,0x00b72b441fd34473,0x008d45684cb1c72b,0x0015181370fc17a5,0x00a456d1307f74d3)},
-  {FIELD_LITERAL(0x001430f149b607dc,0x00e992ccd16715fc,0x00a62209b0a32a09,0x00b889cedc26b8e4,0x0059bf9a3ac109cf,0x006871bb3b7feac2,0x00f4a4d5fd9a0e6b,0x00b95db460cd69a5)},
-  {FIELD_LITERAL(0x0036304418bda702,0x007bc56861561558,0x00f344bc8e30416f,0x00a64537080f59d7,0x00b4c20077d00ace,0x00ee79620b26f8cc,0x00a6a558e0b5403d,0x008f1d2c766f3d19)},
-  {FIELD_LITERAL(0x00ef21c0297d3112,0x0073f89bd27c35b1,0x00ec44f9b1ff5e33,0x006bee51d878f1ee,0x001571a4b2aceddb,0x00cd0182d55131d1,0x0026761dbc1844be,0x00f01865af716474)},
-  {FIELD_LITERAL(0x0021dfef3f5fe8cc,0x0038c659ed1dbd68,0x0058ded9bcebe283,0x00077bbb094983ee,0x00b7b484e913d70c,0x0063e477a9506397,0x0000b996a6e01629,0x00ab68b41f75cd37)},
-  {FIELD_LITERAL(0x00a1fbd946403a4e,0x00be5a4e2d611b05,0x00ea4f210888bc6e,0x0043e9b0e0ae50fe,0x002abc4f6bd86845,0x00c3ed649c67f663,0x00d4eeb391a520e7,0x004b19cf1bfe7584)},
-  {FIELD_LITERAL(0x0099a75e6f22999e,0x001f16454c79f659,0x00d776a37fddc812,0x0095fdd63b6b0a78,0x00d232169366e947,0x002ea77dd21e9de7,0x00e8c46e85f97a90,0x00358758651f8cd9)},
-  {FIELD_LITERAL(0x002b6f5036a07bdf,0x004f6940af3e2646,0x00866028f8986799,0x00838b26ccb50415,0x0010557417f00b11,0x008a3b6bc447e96b,0x003de3d035e9e0c9,0x00188fca2b6d4011)},
-  {FIELD_LITERAL(0x001ca4038635312b,0x0078dc75c1e01c44,0x004340f00b3100a4,0x005e63e36bf6646e,0x008e1efd4b624688,0x00a61c2ffb1525e1,0x0072587505a75b81,0x00a8637140d96e78)},
-  {FIELD_LITERAL(0x004a7c41ffac8a41,0x005bf37075b1c20b,0x00c053b570a42408,0x002bb7e278d328e7,0x00b2378b63245100,0x003318bf2a1a368a,0x00f4e3e0bdbe02de,0x0058921e4b1e32f8)},
-  {FIELD_LITERAL(0x005e93d6fa1118a0,0x0062b43515d381e2,0x002c42864052e620,0x00af258bae6ccbd3,0x00954247094d654d,0x005db01f5b010810,0x009c8cf25efa8204,0x005f73ced3714ef7)},
-  {FIELD_LITERAL(0x0085f89aff2cf49d,0x00f591ee8480f6f0,0x00378ed518114265,0x00f04293e2a09008,0x00c58688db9140ed,0x00e9912696399ff1,0x0055bd1b96367413,0x0023a70cf830f999)},
-  {FIELD_LITERAL(0x001c83772944584e,0x00c1ba881e472bcc,0x00af2715a0aef13f,0x00bd0360d25610a6,0x00c42f8b3eebebde,0x00a9e474849788b1,0x00dcd1a1a2efec5c,0x009480d34c2818c0)},
-  {FIELD_LITERAL(0x00b4b6e09a565d74,0x0095efcf6175aa48,0x00498defe7ae7810,0x00309b684ed26470,0x007a8873a91d4e44,0x00ea4b3f857eb27a,0x00979b8619d25a9e,0x00721a2770eeb6e9)},
-  {FIELD_LITERAL(0x00b422f0f4be195f,0x00e88cfa83bfa2db,0x009fd60666ea4268,0x0095a458f5e801d0,0x00b9eee6882081f6,0x00b27edb37604948,0x00a7f67c4d44d8db,0x00df840ccf290c01)},
-  {FIELD_LITERAL(0x00c9fed0d47c9103,0x00ba73ed9294a043,0x005cbbc928e652e1,0x0068419e98ee8215,0x00f63de63786300b,0x009aa9bb6c19f8aa,0x0066c536b573213f,0x00d2b77a5b2f2450)},
-  {FIELD_LITERAL(0x00810236c68d5b74,0x00d0a1af1872a011,0x007f23ee29e3801a,0x009a55a678f8dba4,0x0065445dcff9be40,0x00f3978789a9abc5,0x00001f010d23f5e8,0x00ff80042934b0c5)},
-  {FIELD_LITERAL(0x00a6749f4b3f9745,0x003ab85f4180e502,0x006a7de9b530ed50,0x0050b5353b0441bf,0x00a093583ac6ede4,0x00c4918ad1406299,0x000f75cf2a353a2b,0x001c6644a0683a56)},
-  {FIELD_LITERAL(0x00e8694156c09bfe,0x00f6f3a5bd17ad96,0x0098dbed45edad12,0x00edfe2b84921821,0x0097884330199b67,0x004aab02685b3e9e,0x0068ac0bd2453c30,0x00167c1c1c87d8f5)},
-  {FIELD_LITERAL(0x008bba5fbf63f599,0x0059a3c960c7d63f,0x00ce2db75b08b7d9,0x0097e80cb2104171,0x009b68be26a140d0,0x002b9b9954e94c68,0x00023ca8fc411beb,0x00cbc4bcccbada07)},
-  {FIELD_LITERAL(0x0053c100e77b678d,0x000f115c400fa96f,0x005928d3de22afa2,0x00e47cd9bdbdbe96,0x00597ecfe84abf19,0x0058bb428e4c7a32,0x00dd582f76ecf584,0x00b1211365eccb79)},
-  {FIELD_LITERAL(0x00dbfb9a00a58e68,0x004468189350d82f,0x00b4b12407ee92c6,0x00e27a7908f73455,0x00f071170071b5ae,0x00221a5e6ba229dd,0x001903e3f6a81f83,0x00be36325402775f)},
-  {FIELD_LITERAL(0x004d298d6e691756,0x00775644dfce310b,0x00a861887823ea98,0x00cf0b6014fa6e6f,0x005f4e296380826f,0x00bf423392627f90,0x002893bfc8122f6a,0x00440dbc89bea228)},
-  {FIELD_LITERAL(0x00acbb4f40a4ab73,0x00d6a82f48fa3366,0x000a7958fc6faac2,0x008a4cdd60a7c33c,0x005e5587dd8b6f1a,0x00e40f63086a88e8,0x0030940cbbcda0ad,0x009a42e3dc35c130)},
-  {FIELD_LITERAL(0x00d37716cad825f1,0x00883870cba9552a,0x008ef785f5c762e3,0x006cb253e0469242,0x007b8f17fee9d967,0x00a43de6932b52b6,0x001aca9fe2af783c,0x008967778ff0b680)},
-  {FIELD_LITERAL(0x006400c4cdc6c9c3,0x001e8c978691083f,0x00ad74f01f68e0c5,0x00f7feb0372b5f6a,0x002f60d175ade13a,0x0098ec54a221a678,0x00fcfea8a71f244e,0x00dea6660e45ded2)},
-  {FIELD_LITERAL(0x002585b4aa8d6752,0x00e62da7615a2089,0x0010c1c741f39b68,0x00569bb1eced9f65,0x00ba6d09e4daa724,0x007d3e20aef281b9,0x00bd7f65aca3ffdc,0x00dea434a50288a8)},
-  {FIELD_LITERAL(0x007ba92a2489170f,0x00cd356354d31e9c,0x00a60d47406e5430,0x009c3d5fde8ed877,0x00079eaa50dd08d1,0x0024674d593ffa5f,0x005391be9596c53b,0x00856ca8d50acdd9)},
-  {FIELD_LITERAL(0x00d4620aa5e5bdec,0x002303c4b9b5d941,0x003b061f857ebb2a,0x00371f9e856d49fd,0x0071c36c5335051e,0x0040e4346a4d359f,0x00b31dbd959ec40c,0x00d99353a71bf6de)},
-  {FIELD_LITERAL(0x0078898adf0f21dd,0x006e09bfedd8604a,0x00efaf0e0f9bb666,0x00b0f685db8852c3,0x0094c86ec566b841,0x00e5c2879ba50dbe,0x00a87cd444cff758,0x00d3e26fd47f23df)},
-  {FIELD_LITERAL(0x00b82c07fb1854f8,0x0057f654a06fad9f,0x004c00383250cf92,0x008b91713d291af6,0x002f2521777859b9,0x00533111421f22c8,0x00643da86fab9794,0x00dc7fb0680e3d40)},
-  {FIELD_LITERAL(0x00e59ffd40e87788,0x006431e9755a50af,0x00a03ce700fb580a,0x00ad7e70aa3c9b9e,0x0078970a2b4db503,0x00c800451849637a,0x00e7e6a5b49e123f,0x00e1ed15f77bcb4d)},
-  {FIELD_LITERAL(0x00bc1d1d1af47f28,0x00ebc5501bbd81f0,0x00aa6b5513547aa4,0x0074ed33551343fe,0x00d2114f6ef7d43b,0x006335b41d518aeb,0x00ebd46919692fb8,0x0052d5d4e3fada95)},
-  {FIELD_LITERAL(0x00ebfc9f489799a4,0x00497535b6980688,0x00fef76499e6a51b,0x00018eedde7a18da,0x00f435d9e72b69c7,0x005ab0faa8281675,0x003232d06e290be8,0x005473ec8be0286c)},
-  {FIELD_LITERAL(0x00c6eb0d0ebb4874,0x00856a2274119097,0x00380bc7b29e3719,0x00b1ae149f0e424d,0x0009b41855b9de26,0x0098684013d0f53f,0x0082e8554c38a6ff,0x00e76c18c353743a)},
-  {FIELD_LITERAL(0x008da1194e1ab61f,0x008edb5f89688805,0x00f4970252f851bd,0x007a46f632b6ad20,0x006d2d1c37e9f90a,0x0060dd09353f665f,0x000a625a80d86657,0x000f93f6fedd0888)},
-  {FIELD_LITERAL(0x003b019b31992fb4,0x004f6a2ad1f64c28,0x008a744134e5c571,0x000ca33172f9af3f,0x00d478755a67bb8b,0x009d1f5c48abb223,0x004da4d6f12ee901,0x0084f09541f4140d)},
-  {FIELD_LITERAL(0x0031f412f5cacd43,0x00e5afb75dd20e94,0x001ce24b3452740e,0x00176d6dedf30ff1,0x0082e22e564fffca,0x001d56fbe007097f,0x0095b37c851a6918,0x008ec50ef97f8f4c)},
-  {FIELD_LITERAL(0x007e2b1c52251f57,0x00cbef37c9380033,0x0037ed652761bceb,0x00f1c2a5dc6dd232,0x0026e1b90d63ce0b,0x00938d732173a6b8,0x00d439aa45da993f,0x00d356b8deaccef7)},
-  {FIELD_LITERAL(0x00ed32377f56c67d,0x00c3b6a4de32e4a7,0x00481a36c0dd5d91,0x00bb557d20466ba7,0x00645f6d3200163e,0x005eb4c54df7c48c,0x00fd8e3d08f1e3b4,0x001156353f099147)},
-  {FIELD_LITERAL(0x00ae1b4c089b2756,0x00e686d2b916fb5f,0x007ac43ec2437dd8,0x00f7bfdf7e860ed2,0x0097dbcb8b786dc9,0x00ec7a90401c8b2f,0x00425ed017989bdb,0x00444bc9ca6d914d)},
-  {FIELD_LITERAL(0x00e5e7b83b53ab7f,0x004e4bed6ca44fc5,0x0008bd7a67c40d4d,0x009dbec74a4a2f0e,0x0077df3f4fc2c73f,0x0046b1af5e73ea8d,0x009f096cb7be8670,0x003ad0a29929141d)},
-  {FIELD_LITERAL(0x00991a1222e9b2e1,0x00be7583901d7dc7,0x00fd1d0c8169d3da,0x000fe0a94a68acf9,0x00b77bd05afc78a2,0x00a84f1697f87ebc,0x000097cfdb0c2ecb,0x007d51d70352ed1b)},
-  {FIELD_LITERAL(0x0025dc2a60643159,0x001f0d8ff85f95b4,0x00ed74a4bc598a73,0x00f30afe6f0574a9,0x0003788545d4d28c,0x009dc410ad120ac0,0x001950947e69961d,0x001ceb23cb0355b0)},
-  {FIELD_LITERAL(0x00ee2202ded9f1bd,0x002fa4fce658976d,0x00e7c15bc9716470,0x004f7ea99d500369,0x004b995a18318376,0x00246c4f8af91911,0x00cc77a07d09dbfe,0x007906f6f1364be6)},
-  {FIELD_LITERAL(0x003c97e6384da36e,0x00423d53eac81a09,0x00b70d68f3cdce35,0x00ee7959b354b92c,0x00f4e9718819c8ca,0x009349f12acbffe9,0x005aee7b62cb7da6,0x00d97764154ffc86)},
+  {FIELD_LITERAL(0x00cc3b062366f4cc,0x003d6e34e314aa3c,0x00d51c0a7521774d,0x0094e060eec6ab8b,0x00d21291b4d80082,0x00befed12b55ef1e,0x00c3dd2df5c94518,0x00e0a7b112b8d4e6)},
+  {FIELD_LITERAL(0x0019eb5608d8723a,0x00d1bab52fb3aedb,0x00270a7311ebc90c,0x0037c12b91be7f13,0x005be16cd8b5c704,0x003e181acda888e1,0x00bc1f00fc3fc6d0,0x00d3839bfa319e20)},
+  {FIELD_LITERAL(0x003caeb88611909f,0x00ea8b378c4df3d4,0x00b3295b95a5a19a,0x00a65f97514bdfb5,0x00b39efba743cab1,0x0016ba98b862fd2d,0x0001508812ee71d7,0x000a75740eea114a)},
+  {FIELD_LITERAL(0x00ebcf0eb649f823,0x00166d332e98ea03,0x0059ddf64f5cd5f6,0x0047763123d9471b,0x00a64065c53ef62f,0x00978e44c480153d,0x000b5b2a0265f194,0x0046a24b9f32965a)},
+  {FIELD_LITERAL(0x00b9eef787034df0,0x0020bc24de3390cd,0x000022160bae99bb,0x00ae66e886e97946,0x0048d4bbe02cbb8b,0x0072ba97b34e38d4,0x00eae7ec8f03e85a,0x005ba92ecf808b2c)},
+  {FIELD_LITERAL(0x00c9cfbbe74258fd,0x00843a979ea9eaa7,0x000cbb4371cfbe90,0x0059bac8f7f0a628,0x004b3dff882ff530,0x0011869df4d90733,0x00595aa71f4abfc2,0x0070e2d38990c2e6)},
+  {FIELD_LITERAL(0x00de2010c0a01733,0x00c739a612e24297,0x00a7212643141d7c,0x00f88444f6b67c11,0x00484b7b16ec28f2,0x009c1b8856af9c68,0x00ff4669591fe9d6,0x0054974be08a32c8)},
+  {FIELD_LITERAL(0x0010de3fd682ceed,0x008c07642d83ca4e,0x0013bb064e00a1cc,0x009411ae27870e11,0x00ea8e5b4d531223,0x0032fe7d2aaece2e,0x00d989e243e7bb41,0x000fe79a508e9b8b)},
+  {FIELD_LITERAL(0x005e0426b9bfc5b1,0x0041a5b1d29ee4fa,0x0015b0def7774391,0x00bc164f1f51af01,0x00d543b0942797b9,0x003c129b6398099c,0x002b114c6e5adf18,0x00b4e630e4018a7b)},
+  {FIELD_LITERAL(0x00d490afc95f8420,0x00b096bf50c1d9b9,0x00799fd707679866,0x007c74d9334afbea,0x00efaa8be80ff4ed,0x0075c4943bb81694,0x00c21c2fca161f36,0x00e77035d492bfee)},
+  {FIELD_LITERAL(0x006658a190dd6661,0x00e0e9bab38609a6,0x0028895c802237ed,0x006a0229c494f587,0x002dcde96c9916b7,0x00d158822de16218,0x00173b917a06856f,0x00ca78a79ae07326)},
+  {FIELD_LITERAL(0x00e35bfc79caced4,0x0087238a3e1fe3bb,0x00bcbf0ff4ceff5b,0x00a19c1c94099b91,0x0071e102b49db976,0x0059e3d004eada1e,0x008da78afa58a47e,0x00579c8ebf269187)},
+  {FIELD_LITERAL(0x00a16c2905eee75f,0x009d4bcaea2c7e1d,0x00d3bd79bfad19df,0x0050da745193342c,0x006abdb8f6b29ab1,0x00a24fe0a4fef7ef,0x0063730da1057dfb,0x00a08c312c8eb108)},
+  {FIELD_LITERAL(0x00b583be005375be,0x00a40c8f8a4e3df4,0x003fac4a8f5bdbf7,0x00d4481d872cd718,0x004dc8749cdbaefe,0x00cce740d5e5c975,0x000b1c1f4241fd21,0x00a76de1b4e1cd07)},
+  {FIELD_LITERAL(0x007a076500d30b62,0x000a6e117b7f090f,0x00c8712ae7eebd9a,0x000fbd6c1d5f6ff7,0x003a7977246ebf11,0x00166ed969c6600e,0x00aa42e469c98bec,0x00dc58f307cf0666)},
+  {FIELD_LITERAL(0x004b491f65a9a28b,0x006a10309e8a55b7,0x00b67210185187ef,0x00cf6497b12d9b8f,0x0085778c56e2b1ba,0x0015b4c07a814d85,0x00686479e62da561,0x008de5d88f114916)},
+  {FIELD_LITERAL(0x00e37c88d6bba7b1,0x003e4577e1b8d433,0x0050d8ea5f510ec0,0x0042fc9f2da9ef59,0x003bd074c1141420,0x00561b8b7b68774e,0x00232e5e5d1013a3,0x006b7f2cb3d7e73f)},
+  {FIELD_LITERAL(0x004bdd0f0b41e6a0,0x001773057c405d24,0x006029f99915bd97,0x006a5ba70a17fe2f,0x0046111977df7e08,0x004d8124c89fb6b7,0x00580983b2bb2724,0x00207bf330d6f3fe)},
+  {FIELD_LITERAL(0x007efdc93972a48b,0x002f5e50e78d5fee,0x0080dc11d61c7fe5,0x0065aa598707245b,0x009abba2300641be,0x000c68787656543a,0x00ffe0fef2dc0a17,0x00007ffbd6cb4f3a)},
+  {FIELD_LITERAL(0x0036012f2b836efc,0x00458c126d6b5fbc,0x00a34436d719ad1e,0x0097be6167117dea,0x0009c219c879cff3,0x0065564493e60755,0x00993ac94a8cdec0,0x002d4885a4d0dbaf)},
+  {FIELD_LITERAL(0x00598b60b4c068ba,0x00c547a0be7f1afd,0x009582164acf12af,0x00af4acac4fbbe40,0x005f6ca7c539121a,0x003b6e752ebf9d66,0x00f08a30d5cac5d4,0x00e399bb5f97c5a9)},
+  {FIELD_LITERAL(0x007445a0409c0a66,0x00a65c369f3829c0,0x0031d248a4f74826,0x006817f34defbe8e,0x00649741d95ebf2e,0x00d46466ab16b397,0x00fdc35703bee414,0x00343b43334525f8)},
+  {FIELD_LITERAL(0x001796bea93f6401,0x00090c5a42e85269,0x00672412ba1252ed,0x001201d47b6de7de,0x006877bccfe66497,0x00b554fd97a4c161,0x009753f42dbac3cf,0x00e983e3e378270a)},
+  {FIELD_LITERAL(0x00ac3eff18849872,0x00f0eea3bff05690,0x00a6d72c21dd505d,0x001b832642424169,0x00a6813017b540e5,0x00a744bd71b385cd,0x0022a7d089130a7b,0x004edeec9a133486)},
+  {FIELD_LITERAL(0x00b2d6729196e8a9,0x0088a9bb2031cef4,0x00579e7787dc1567,0x0030f49feb059190,0x00a0b1d69c7f7d8f,0x0040bdcc6d9d806f,0x00d76c4037edd095,0x00bbf24376415dd7)},
+  {FIELD_LITERAL(0x00240465ff5a7197,0x00bb97e76caf27d0,0x004b4edbf8116d39,0x001d8586f708cbaa,0x000f8ee8ff8e4a50,0x00dde5a1945dd622,0x00e6fc1c0957e07c,0x0041c9cdabfd88a0)},
+  {FIELD_LITERAL(0x005344b0bf5b548c,0x002957d0b705cc99,0x00f586a70390553d,0x0075b3229f583cc3,0x00a1aa78227490e4,0x001bf09cf7957717,0x00cf6bf344325f52,0x0065bd1c23ca3ecf)},
+  {FIELD_LITERAL(0x009bff3b3239363c,0x00e17368796ef7c0,0x00528b0fe0971f3a,0x0008014fc8d4a095,0x00d09f2e8a521ec4,0x006713ab5dde5987,0x0003015758e0dbb1,0x00215999f1ba212d)},
+  {FIELD_LITERAL(0x002c88e93527da0e,0x0077c78f3456aad5,0x0071087a0a389d1c,0x00934dac1fb96dbd,0x008470e801162697,0x005bc2196cd4ad49,0x00e535601d5087c3,0x00769888700f497f)},
+  {FIELD_LITERAL(0x00da7a4b557298ad,0x0019d2589ea5df76,0x00ef3e38be0c6497,0x00a9644e1312609a,0x004592f61b2558da,0x0082c1df510d7e46,0x0042809a535c0023,0x00215bcb5afd7757)},
+  {FIELD_LITERAL(0x002b9df55a1a4213,0x00dcfc3b464a26be,0x00c4f9e07a8144d5,0x00c8e0617a92b602,0x008e3c93accafae0,0x00bf1bcb95b2ca60,0x004ce2426a613bf3,0x00266cac58e40921)},
+  {FIELD_LITERAL(0x008456d5db76e8f0,0x0032ca9cab2ce163,0x0059f2b8bf91abcf,0x0063c2a021712788,0x00f86155af22f72d,0x00db98b2a6c005a0,0x00ac6e416a693ac4,0x007a93572af53226)},
+  {FIELD_LITERAL(0x0087767520f0de22,0x0091f64012279fb5,0x001050f1f0644999,0x004f097a2477ad3c,0x006b37913a9947bd,0x001a3d78645af241,0x0057832bbb3008a7,0x002c1d902b80dc20)},
+  {FIELD_LITERAL(0x001a6002bf178877,0x009bce168aa5af50,0x005fc318ff04a7f5,0x0052818f55c36461,0x008768f5d4b24afb,0x0037ffbae7b69c85,0x0018195a4b61edc0,0x001e12ea088434b2)},
+  {FIELD_LITERAL(0x0047d3f804e7ab07,0x00a809ab5f905260,0x00b3ffc7cdaf306d,0x00746e8ec2d6e509,0x00d0dade8887a645,0x00acceeebde0dd37,0x009bc2579054686b,0x0023804f97f1c2bf)},
+  {FIELD_LITERAL(0x0043e2e2e50b80d7,0x00143aafe4427e0f,0x005594aaecab855b,0x008b12ccaaecbc01,0x002deeb091082bc3,0x009cca4be2ae7514,0x00142b96e696d047,0x00ad2a2b1c05256a)},
+  {FIELD_LITERAL(0x003914f2f144b78b,0x007a95dd8bee6f68,0x00c7f4384d61c8e6,0x004e51eb60f1bdb2,0x00f64be7aa4621d8,0x006797bfec2f0ac0,0x007d17aab3c75900,0x001893e73cac8bc5)},
+  {FIELD_LITERAL(0x00140360b768665b,0x00b68aca4967f977,0x0001089b66195ae4,0x00fe71122185e725,0x000bca2618d49637,0x00a54f0557d7e98a,0x00cdcd2f91d6f417,0x00ab8c13741fd793)},
+  {FIELD_LITERAL(0x00725ee6b1e549e0,0x007124a0769777fa,0x000b68fdad07ae42,0x0085b909cd4952df,0x0092d2e3c81606f4,0x009f22f6cac099a0,0x00f59da57f2799a8,0x00f06c090122f777)},
+  {FIELD_LITERAL(0x00ce0bed0a3532bc,0x001a5048a22df16b,0x00e31db4cbad8bf1,0x00e89292120cf00e,0x007d1dd1a9b00034,0x00e2a9041ff8f680,0x006a4c837ae596e7,0x00713af1068070b3)},
+  {FIELD_LITERAL(0x00c4fe64ce66d04b,0x00b095d52e09b3d7,0x00758bbecb1a3a8e,0x00f35cce8d0650c0,0x002b878aa5984473,0x0062e0a3b7544ddc,0x00b25b290ed116fe,0x007b0f6abe0bebf2)},
+  {FIELD_LITERAL(0x0081d4e3addae0a8,0x003410c836c7ffcc,0x00c8129ad89e4314,0x000e3d5a23922dcd,0x00d91e46f29c31f3,0x006c728cde8c5947,0x002bc655ba2566c0,0x002ca94721533108)},
+  {FIELD_LITERAL(0x0051e4b3f764d8a9,0x0019792d46e904a0,0x00853bc13dbc8227,0x000840208179f12d,0x0068243474879235,0x0013856fbfe374d0,0x00bda12fe8676424,0x00bbb43635926eb2)},
+  {FIELD_LITERAL(0x0012cdc880a93982,0x003c495b21cd1b58,0x00b7e5c93f22a26e,0x0044aa82dfb99458,0x009ba092cdffe9c0,0x00a14b3ab2083b73,0x000271c2f70e1c4b,0x00eea9cac0f66eb8)},
+  {FIELD_LITERAL(0x001a1847c4ac5480,0x00b1b412935bb03a,0x00f74285983bf2b2,0x00624138b5b5d0f1,0x008820c0b03d38bf,0x00b94e50a18c1572,0x0060f6934841798f,0x00c52f5d66d6ebe2)},
+  {FIELD_LITERAL(0x00da23d59f9bcea6,0x00e0f27007a06a4b,0x00128b5b43a6758c,0x000cf50190fa8b56,0x00fc877aba2b2d72,0x00623bef52edf53f,0x00e6af6b819669e2,0x00e314dc34fcaa4f)},
+  {FIELD_LITERAL(0x0066e5eddd164d1e,0x00418a7c6fe28238,0x0002e2f37e962c25,0x00f01f56b5975306,0x0048842fa503875c,0x0057b0e968078143,0x00ff683024f3d134,0x0082ae28fcad12e4)},
+  {FIELD_LITERAL(0x0011ddfd21260e42,0x00d05b0319a76892,0x00183ea4368e9b8f,0x00b0815662affc96,0x00b466a5e7ce7c88,0x00db93b07506e6ee,0x0033885f82f62401,0x0086f9090ec9b419)},
   {FIELD_LITERAL(0x00d95d1c5fcb435a,0x0016d1ed6b5086f9,0x00792aa0b7e54d71,0x0067b65715f1925d,0x00a219755ec6176b,0x00bc3f026b12c28f,0x00700c897ffeb93e,0x0089b83f6ec50b46)},
-  {FIELD_LITERAL(0x00ad9cdb4544b923,0x00d11664c7284061,0x00815ae86b8f910b,0x005414fb2591c3c6,0x0094ba83e2d7ef9e,0x0001dbc16599386c,0x00c8721f0493911b,0x00c1be6b463c346c)},
-  {FIELD_LITERAL(0x0079680ce111ed3b,0x001a1ed82806122c,0x000c2e7466d15df3,0x002c407f6f7150fd,0x00c5e7c96b1b0ce3,0x009aa44626863ff9,0x00887b8b5b80be42,0x00b6023cec964825)},
+  {FIELD_LITERAL(0x003c97e6384da36e,0x00423d53eac81a09,0x00b70d68f3cdce35,0x00ee7959b354b92c,0x00f4e9718819c8ca,0x009349f12acbffe9,0x005aee7b62cb7da6,0x00d97764154ffc86)},
+  {FIELD_LITERAL(0x00526324babb46dc,0x002ee99b38d7bf9e,0x007ea51794706ef4,0x00abeb04da6e3c39,0x006b457c1d281060,0x00fe243e9a66c793,0x00378de0fb6c6ee4,0x003e4194b9c3cb93)},
   {FIELD_LITERAL(0x00fed3cd80ca2292,0x0015b043a73ca613,0x000a9fd7bf9be227,0x003b5e03de2db983,0x005af72d46904ef7,0x00c0f1b5c49faa99,0x00dc86fc3bd305e1,0x00c92f08c1cb1797)},
-  {FIELD_LITERAL(0x001b571efb768f37,0x009d778487cf5cfd,0x00430e37327ebfd4,0x00a92447e5970a41,0x00eb13127c0edbac,0x00ec61e5aefeaf20,0x00447eebf57d2e5c,0x00f01433e550e558)},
-  {FIELD_LITERAL(0x0039dd7ce7fc6860,0x00d64f6425653da1,0x003e037c7f57d0af,0x0063477a06e2bcf2,0x001727dbb7ac67e6,0x0049589f5efafe2e,0x00fc0fef2e813d54,0x008baa5d087fb50d)},
+  {FIELD_LITERAL(0x0079680ce111ed3b,0x001a1ed82806122c,0x000c2e7466d15df3,0x002c407f6f7150fd,0x00c5e7c96b1b0ce3,0x009aa44626863ff9,0x00887b8b5b80be42,0x00b6023cec964825)},
+  {FIELD_LITERAL(0x00e4a8e1048970c8,0x0062887b7830a302,0x00bcf1c8cd81402b,0x0056dbb81a68f5be,0x0014eced83f12452,0x00139e1a510150df,0x00bb81140a82d1a3,0x000febcc1aaf1aa7)},
   {FIELD_LITERAL(0x00a7527958238159,0x0013ec9537a84cd6,0x001d7fee7d562525,0x00b9eefa6191d5e5,0x00dbc97db70bcb8a,0x00481affc7a4d395,0x006f73d3e70c31bb,0x00183f324ed96a61)},
-  {FIELD_LITERAL(0x00db04a6264ba838,0x00582b1f9fddc1b3,0x003ee72e4aaa027f,0x007d1de938cd0dd5,0x0032d5d66cf76afa,0x00c9c717c95c1ec2,0x00f27aa11764b8d6,0x00713a482b7ef36e)},
-  {FIELD_LITERAL(0x00ece96f95f2b66f,0x00ece7952813a27b,0x0026fc36592e489e,0x007157d1a2de0f66,0x00759dc111d86ddf,0x0012881e5780bb0f,0x00c8ccc83ad29496,0x0012b9bd1929eb71)},
+  {FIELD_LITERAL(0x0039dd7ce7fc6860,0x00d64f6425653da1,0x003e037c7f57d0af,0x0063477a06e2bcf2,0x001727dbb7ac67e6,0x0049589f5efafe2e,0x00fc0fef2e813d54,0x008baa5d087fb50d)},
+  {FIELD_LITERAL(0x0024fb59d9b457c7,0x00a7d4e060223e4c,0x00c118d1b555fd80,0x0082e216c732f22a,0x00cd2a2993089504,0x003638e836a3e13d,0x000d855ee89b4729,0x008ec5b7d4810c91)},
   {FIELD_LITERAL(0x001bf51f7d65cdfd,0x00d14cdafa16a97d,0x002c38e60fcd10e7,0x00a27446e393efbd,0x000b5d8946a71fdd,0x0063df2cde128f2f,0x006c8679569b1888,0x0059ffc4925d732d)},
-  {FIELD_LITERAL(0x00f05ea5df25a20f,0x00cb6224e5b932ce,0x00d3aed52e2718d9,0x00fb89ee0996ce72,0x006197045a6e1e80,0x00bcdf20057fc6f9,0x0059bf78b6ae5c2c,0x0049cacb87455db0)},
-  {FIELD_LITERAL(0x006a15bb20f75c0c,0x0079a144027a5d0c,0x00d19116ce0b4d70,0x0059b83bcb0b268e,0x005f58f63f16c127,0x0079958318ee2c37,0x00defbb063d07f82,0x00f1f0b931d2d446)},
+  {FIELD_LITERAL(0x00ece96f95f2b66f,0x00ece7952813a27b,0x0026fc36592e489e,0x007157d1a2de0f66,0x00759dc111d86ddf,0x0012881e5780bb0f,0x00c8ccc83ad29496,0x0012b9bd1929eb71)},
+  {FIELD_LITERAL(0x000fa15a20da5df0,0x00349ddb1a46cd31,0x002c512ad1d8e726,0x00047611f669318d,0x009e68fba591e17e,0x004320dffa803906,0x00a640874951a3d3,0x00b6353478baa24f)},
   {FIELD_LITERAL(0x009696510000d333,0x00ec2f788bc04826,0x000e4d02b1f67ba5,0x00659aa8dace08b6,0x00d7a38a3a3ae533,0x008856defa8c746b,0x004d7a4402d3da1a,0x00ea82e06229260f)},
-  {FIELD_LITERAL(0x0034a1b3c3ca2bdd,0x0072077a35bca880,0x0005af4e935c1b8e,0x00a5f1a71e8b7737,0x004d3133292cb2e5,0x000fe2a2dca1c916,0x0024d181b41935bb,0x00d9f54880ca0332)},
-  {FIELD_LITERAL(0x009ffd90abfeae96,0x00cba3c2b624a516,0x005ef08bcee46c91,0x00e6fde30afb6185,0x00f0b4db4f818ce4,0x006c54f45d2127f5,0x00040125035854c7,0x00372658a3287e13)},
+  {FIELD_LITERAL(0x006a15bb20f75c0c,0x0079a144027a5d0c,0x00d19116ce0b4d70,0x0059b83bcb0b268e,0x005f58f63f16c127,0x0079958318ee2c37,0x00defbb063d07f82,0x00f1f0b931d2d446)},
+  {FIELD_LITERAL(0x00cb5e4c3c35d422,0x008df885ca43577f,0x00fa50b16ca3e471,0x005a0e58e17488c8,0x00b2ceccd6d34d19,0x00f01d5d235e36e9,0x00db2e7e4be6ca44,0x00260ab77f35fccd)},
   {FIELD_LITERAL(0x006f6fd9baac61d5,0x002a7710a020a895,0x009de0db7fc03d4d,0x00cdedcb1875f40b,0x00050caf9b6b1e22,0x005e3a6654456ab0,0x00775fdf8c4423d4,0x0028701ea5738b5d)},
-  {FIELD_LITERAL(0x0028f8f04e414d54,0x0087037ba56c7694,0x00976b5b4d0ddb59,0x00a4227e6d462421,0x004c77c678b4c560,0x0006c9e74fb485a8,0x00c1c138a02d3981,0x0040a19403d6b6b5)},
-  {FIELD_LITERAL(0x0045e8dda9400888,0x002ff12e5fc05db7,0x00a7098d54afe69c,0x00cdbe846a500585,0x00879c1593ca1882,0x003f7a7fea76c8b0,0x002cd73dd0c8e0a1,0x00645d6ce96f51fe)},
+  {FIELD_LITERAL(0x009ffd90abfeae96,0x00cba3c2b624a516,0x005ef08bcee46c91,0x00e6fde30afb6185,0x00f0b4db4f818ce4,0x006c54f45d2127f5,0x00040125035854c7,0x00372658a3287e13)},
+  {FIELD_LITERAL(0x00d7070fb1beb2ab,0x0078fc845a93896b,0x006894a4b2f224a6,0x005bdd8192b9dbde,0x00b38839874b3a9e,0x00f93618b04b7a57,0x003e3ec75fd2c67e,0x00bf5e6bfc29494a)},
   {FIELD_LITERAL(0x00f19224ebba2aa5,0x0074f89d358e694d,0x00eea486597135ad,0x0081579a4555c7e1,0x0010b9b872930a9d,0x00f002e87a30ecc0,0x009b9d66b6de56e2,0x00a3c4f45e8004eb)},
-  {FIELD_LITERAL(0x00d4817c1edc2929,0x00c67cb908be637f,0x00bd6dd1aa6bfe9c,0x00a1803a9fe7795c,0x001770d311e2cefb,0x0018054eca0d1c88,0x004fa667b240f212,0x00f631f7f055a447)},
-  {FIELD_LITERAL(0x00f89335c2a59286,0x00a0f5c905d55141,0x00b41fb836ee9382,0x00e235d51730ca43,0x00a5cb37b5c0a69a,0x009b966ffe136c45,0x00cb2ea10bf80ed1,0x00fb2b370b40dc35)},
+  {FIELD_LITERAL(0x0045e8dda9400888,0x002ff12e5fc05db7,0x00a7098d54afe69c,0x00cdbe846a500585,0x00879c1593ca1882,0x003f7a7fea76c8b0,0x002cd73dd0c8e0a1,0x00645d6ce96f51fe)},
+  {FIELD_LITERAL(0x002b7e83e123d6d6,0x00398346f7419c80,0x0042922e55940163,0x005e7fc5601886a3,0x00e88f2cee1d3103,0x00e7fab135f2e377,0x00b059984dbf0ded,0x0009ce080faa5bb8)},
   {FIELD_LITERAL(0x0085e78af7758979,0x00275a4ee1631a3a,0x00d26bc0ed78b683,0x004f8355ea21064f,0x00d618e1a32696e5,0x008d8d7b150e5680,0x00a74cd854b278d2,0x001dd62702203ea0)},
-  {FIELD_LITERAL(0x0029782e92b11745,0x008eadf422f96200,0x00217a39f2cdcaa2,0x00782d1ca9aefd0b,0x00321c6e47203654,0x001e72961020101a,0x00b562fa6e6ab16e,0x0005c92274af111a)},
-  {FIELD_LITERAL(0x006bc3d53011f470,0x00032d6e692b83e8,0x00059722f497cd0b,0x0009b4e6f0c497cc,0x0058a804b7cce6c0,0x002b71d3302bbd5d,0x00e2f82a36765fce,0x008dded99524c703)},
+  {FIELD_LITERAL(0x00f89335c2a59286,0x00a0f5c905d55141,0x00b41fb836ee9382,0x00e235d51730ca43,0x00a5cb37b5c0a69a,0x009b966ffe136c45,0x00cb2ea10bf80ed1,0x00fb2b370b40dc35)},
+  {FIELD_LITERAL(0x00d687d16d4ee8ba,0x0071520bdd069dff,0x00de85c60d32355d,0x0087d2e3565102f4,0x00cde391b8dfc9aa,0x00e18d69efdfefe5,0x004a9d0591954e91,0x00fa36dd8b50eee5)},
   {FIELD_LITERAL(0x002e788749a865f7,0x006e4dc3116861ea,0x009f1428c37276e6,0x00e7d2e0fc1e1226,0x003aeebc6b6c45f6,0x0071a8073bf500c9,0x004b22ad986b530c,0x00f439e63c0d79d4)},
-  {FIELD_LITERAL(0x00b2fa76ac8b829b,0x008fe6bf01865590,0x0059df538e389f40,0x006acd49eeea748a,0x00ab81280b990cfe,0x00c34a54ac57bfe5,0x003889ce9731cedf,0x0081b71cc1b4654d)},
-  {FIELD_LITERAL(0x002f194eaafa46dc,0x008e38f57fe87613,0x00dc8e5ae25f4ab2,0x000a17809575e6bd,0x00d3ec7923ba366a,0x003a7e72e0ad75e3,0x0010024b88436e0a,0x00ed3c5444b64051)},
+  {FIELD_LITERAL(0x006bc3d53011f470,0x00032d6e692b83e8,0x00059722f497cd0b,0x0009b4e6f0c497cc,0x0058a804b7cce6c0,0x002b71d3302bbd5d,0x00e2f82a36765fce,0x008dded99524c703)},
+  {FIELD_LITERAL(0x004d058953747d64,0x00701940fe79aa6f,0x00a620ac71c760bf,0x009532b611158b75,0x00547ed7f466f300,0x003cb5ab53a8401a,0x00c7763168ce3120,0x007e48e33e4b9ab2)},
   {FIELD_LITERAL(0x001b2fc57bf3c738,0x006a3f918993fb80,0x0026f7a14fdec288,0x0075a2cdccef08db,0x00d3ecbc9eecdbf1,0x0048c40f06e5bf7f,0x00d63e423009896b,0x000598bc99c056a8)},
-  {FIELD_LITERAL(0x007ce03ecbf50cbd,0x00369ba996b992ca,0x00896d4b33a5f7f0,0x00602b5b8536da60,0x00e1122082ba6d73,0x00c3fbb903ba0d74,0x00d3f8ec55c1daf8,0x006a8f96ca0f0be1)},
-  {FIELD_LITERAL(0x001fb73475c45509,0x00d2b2e5ea43345a,0x00cb3c3842077bd1,0x0029f90ad820946e,0x007c11b2380778aa,0x009e54ece62c1704,0x004bc60c41ca01c3,0x004525679a5a0b03)},
+  {FIELD_LITERAL(0x002f194eaafa46dc,0x008e38f57fe87613,0x00dc8e5ae25f4ab2,0x000a17809575e6bd,0x00d3ec7923ba366a,0x003a7e72e0ad75e3,0x0010024b88436e0a,0x00ed3c5444b64051)},
+  {FIELD_LITERAL(0x00831fc1340af342,0x00c9645669466d35,0x007692b4cc5a080f,0x009fd4a47ac9259f,0x001eeddf7d45928b,0x003c0446fc45f28b,0x002c0713aa3e2507,0x0095706935f0f41e)},
   {FIELD_LITERAL(0x00766ae4190ec6d8,0x0065768cabc71380,0x00b902598416cdc2,0x00380021ad38df52,0x008f0b89d6551134,0x004254d4cc62c5a5,0x000d79f4484b9b94,0x00b516732ae3c50e)},
-  {FIELD_LITERAL(0x0039b0422412784c,0x00bf9fe2ee8ce055,0x0063ddb8a4906298,0x00db48625178a0ea,0x009e9012c0fd3c4e,0x00ff30c60950d2c4,0x003b9453f5565977,0x0054dc1d7ff25dfb)},
-  {FIELD_LITERAL(0x0017085f4a346148,0x00c7cf7a37f62272,0x001776e129bc5c30,0x009955134c9eef2a,0x001ba5bdf1df07be,0x00ec39497103a55c,0x006578354fda6cfb,0x005f02719d4f15ee)},
+  {FIELD_LITERAL(0x001fb73475c45509,0x00d2b2e5ea43345a,0x00cb3c3842077bd1,0x0029f90ad820946e,0x007c11b2380778aa,0x009e54ece62c1704,0x004bc60c41ca01c3,0x004525679a5a0b03)},
+  {FIELD_LITERAL(0x00c64fbddbed87b3,0x0040601d11731faa,0x009c22475b6f9d67,0x0024b79dae875f15,0x00616fed3f02c3b0,0x0000cf39f6af2d3b,0x00c46bac0aa9a688,0x00ab23e2800da204)},
   {FIELD_LITERAL(0x000b3a37617632b0,0x00597199fe1cfb6c,0x0042a7ccdfeafdd6,0x004cc9f15ebcea17,0x00f436e596a6b4a4,0x00168861142df0d8,0x000753edfec26af5,0x000c495d7e388116)},
-  {FIELD_LITERAL(0x00ad46264a269aa2,0x002b13845e4b9e3c,0x0006a20b68b0d7f4,0x00c271a35ee514ae,0x002b67e14a58f4d8,0x00f5065b099a60d6,0x00ba6737b90514bc,0x00b6265e7c5b898f)},
-  {FIELD_LITERAL(0x00b60167d9e7d065,0x00e60ba0d07381e8,0x003a4f17b725c2d4,0x006c19fe176b64fa,0x003b57b31af86ccb,0x0021047c286180fd,0x00bdc8fb00c6dbb6,0x00fe4a9f4bab4f3f)},
+  {FIELD_LITERAL(0x0017085f4a346148,0x00c7cf7a37f62272,0x001776e129bc5c30,0x009955134c9eef2a,0x001ba5bdf1df07be,0x00ec39497103a55c,0x006578354fda6cfb,0x005f02719d4f15ee)},
+  {FIELD_LITERAL(0x0052b9d9b5d9655d,0x00d4ec7ba1b461c3,0x00f95df4974f280b,0x003d8e5ca11aeb51,0x00d4981eb5a70b26,0x000af9a4f6659f29,0x004598c846faeb43,0x0049d9a183a47670)},
   {FIELD_LITERAL(0x000a72d23dcb3f1f,0x00a3737f84011727,0x00f870c0fbbf4a47,0x00a7aadd04b5c9ca,0x000c7715c67bd072,0x00015a136afcd74e,0x0080d5caea499634,0x0026b448ec7514b7)},
-  {FIELD_LITERAL(0x0077003c5e9eee08,0x006eaa1bdba2f437,0x007ae297ddfa8d2a,0x00aa8531e1aeb2d6,0x00ce283cc626efdc,0x00efe2f51d153115,0x00db954c07c84995,0x002ade92c7e00acf)},
-  {FIELD_LITERAL(0x00a6295218dc136a,0x00563b3af0e9c012,0x00d3753b0145db1b,0x004550389c043dc1,0x00ea94ae27401bdf,0x002b0b949f2b7956,0x00c63f780ad8e23c,0x00e591c47d6bab15)},
+  {FIELD_LITERAL(0x00b60167d9e7d065,0x00e60ba0d07381e8,0x003a4f17b725c2d4,0x006c19fe176b64fa,0x003b57b31af86ccb,0x0021047c286180fd,0x00bdc8fb00c6dbb6,0x00fe4a9f4bab4f3f)},
+  {FIELD_LITERAL(0x0088ffc3a16111f7,0x009155e4245d0bc8,0x00851d68220572d5,0x00557ace1e514d29,0x0031d7c339d91022,0x00101d0ae2eaceea,0x00246ab3f837b66a,0x00d5216d381ff530)},
   {FIELD_LITERAL(0x0057e7ea35f36dae,0x00f47d7ad15de22e,0x00d757ea4b105115,0x008311457d579d7e,0x00b49b75b1edd4eb,0x0081c7ff742fd63a,0x00ddda3187433df6,0x00475727d55f9c66)},
-  {FIELD_LITERAL(0x00be93a7d4fa7149,0x00bef825a4d3396a,0x004c32daa951139b,0x003f4be7d981a85e,0x00e866d6ca8642d0,0x00b912bba6f1b2f8,0x00e28ba64c9cf5e1,0x0039504574996955)},
-  {FIELD_LITERAL(0x002419222c607674,0x00a7f23af89188b3,0x00ad127284e73d1c,0x008bba582fae1c51,0x00fc6aa7ca9ecab1,0x003df5319eb6c2ba,0x002a05af8a8b199a,0x004bf8354558407c)},
+  {FIELD_LITERAL(0x00a6295218dc136a,0x00563b3af0e9c012,0x00d3753b0145db1b,0x004550389c043dc1,0x00ea94ae27401bdf,0x002b0b949f2b7956,0x00c63f780ad8e23c,0x00e591c47d6bab15)},
+  {FIELD_LITERAL(0x00416c582b058eb6,0x004107da5b2cc695,0x00b3cd2556aeec64,0x00c0b418267e57a1,0x001799293579bd2e,0x0046ed44590e4d07,0x001d7459b3630a1e,0x00c6afba8b6696aa)},
   {FIELD_LITERAL(0x008d6009b26da3f8,0x00898e88ca06b1ca,0x00edb22b2ed7fe62,0x00fbc93516aabe80,0x008b4b470c42ce0d,0x00e0032ba7d0dcbb,0x00d76da3a956ecc8,0x007f20fe74e3852a)},
-  {FIELD_LITERAL(0x003182b5cf0f0340,0x002fd3d8d9d60fc2,0x00b73ffe08bff43d,0x00d3dec97fee6a72,0x00675aafc6e16949,0x00d27f499c6f0c86,0x00e0578789f3387a,0x00e52031ab49ec2a)},
-  {FIELD_LITERAL(0x006b7a0674f9f8de,0x00a742414e5c7cff,0x0041cbf3c6e13221,0x00e3a64fd207af24,0x0087c05f15fbe8d1,0x004c50936d9e8a33,0x001306ec21042b6d,0x00a4f4137d1141c2)},
+  {FIELD_LITERAL(0x002419222c607674,0x00a7f23af89188b3,0x00ad127284e73d1c,0x008bba582fae1c51,0x00fc6aa7ca9ecab1,0x003df5319eb6c2ba,0x002a05af8a8b199a,0x004bf8354558407c)},
+  {FIELD_LITERAL(0x00ce7d4a30f0fcbf,0x00d02c272629f03d,0x0048c001f7400bc2,0x002c21368011958d,0x0098a550391e96b5,0x002d80b66390f379,0x001fa878760cc785,0x001adfce54b613d5)},
   {FIELD_LITERAL(0x001ed4dc71fa2523,0x005d0bff19bf9b5c,0x00c3801cee065a64,0x001ed0b504323fbf,0x0003ab9fdcbbc593,0x00df82070178b8d2,0x00a2bcaa9c251f85,0x00c628a3674bd02e)},
-  {FIELD_LITERAL(0x00f619046dea974f,0x004c39fedfde6ee7,0x00d593cb9f22afc5,0x00624e10ee9ab4ab,0x009c1b40f41869fd,0x0098f2cb44da6d46,0x002311d093becf31,0x004d97d1771880ab)},
-  {FIELD_LITERAL(0x00ddbe0750dd1add,0x004b3c7b885844b8,0x00363e7ecf12f1ae,0x0062e953e6438f9d,0x0023cc73b076afe9,0x00b09fa083b4da32,0x00c7c3d2456c541d,0x005b591ec6b694d4)},
+  {FIELD_LITERAL(0x006b7a0674f9f8de,0x00a742414e5c7cff,0x0041cbf3c6e13221,0x00e3a64fd207af24,0x0087c05f15fbe8d1,0x004c50936d9e8a33,0x001306ec21042b6d,0x00a4f4137d1141c2)},
+  {FIELD_LITERAL(0x0009e6fb921568b0,0x00b3c60120219118,0x002a6c3460dd503a,0x009db1ef11654b54,0x0063e4bf0be79601,0x00670d34bb2592b9,0x00dcee2f6c4130ce,0x00b2682e88e77f54)},
   {FIELD_LITERAL(0x000d5b4b3da135ab,0x00838f3e5064d81d,0x00d44eb50f6d94ed,0x0008931ab502ac6d,0x00debe01ca3d3586,0x0025c206775f0641,0x005ad4b6ae912763,0x007e2c318ad8f247)},
-  {FIELD_LITERAL(0x00d79a91e629d030,0x00ad5b50fc20eb72,0x00edd89a222eb1bd,0x000ddad6fb098ea8,0x00b8be69a49c90c4,0x009bbe2d69ecd346,0x00a1def906a95a48,0x00db8fd6a6d2cca3)},
-  {FIELD_LITERAL(0x00c41d1f9c1f1ac1,0x007b2df4e9f19146,0x00b469355fd5ba7a,0x00b5e1965afc852a,0x00388d5f1e2d8217,0x0022079e4c09ae93,0x0014268acd4ef518,0x00c1dd8d9640464c)},
+  {FIELD_LITERAL(0x00ddbe0750dd1add,0x004b3c7b885844b8,0x00363e7ecf12f1ae,0x0062e953e6438f9d,0x0023cc73b076afe9,0x00b09fa083b4da32,0x00c7c3d2456c541d,0x005b591ec6b694d4)},
+  {FIELD_LITERAL(0x0028656e19d62fcf,0x0052a4af03df148d,0x00122765ddd14e42,0x00f2252904f67157,0x004741965b636f3a,0x006441d296132cb9,0x005e2106f956a5b7,0x00247029592d335c)},
   {FIELD_LITERAL(0x003fe038eb92f894,0x000e6da1b72e8e32,0x003a1411bfcbe0fa,0x00b55d473164a9e4,0x00b9a775ac2df48d,0x0002ddf350659e21,0x00a279a69eb19cb3,0x00f844eab25cba44)},
-  {FIELD_LITERAL(0x00c7ad952112f3aa,0x00229739f81c017a,0x0008b9222b75a2a8,0x00bd0d6ad469c483,0x00e344297892a13c,0x00a1cbeb8f435a3d,0x0078e2be1f7a0bec,0x001ac54f670ba8cd)},
-  {FIELD_LITERAL(0x00adb2c1566e8b8f,0x0096c68a35771a9a,0x00869933356f334a,0x00ba9c93459f5962,0x009ec73fb6e8ca4b,0x003c3802c27202e1,0x0031f5b733e0c008,0x00f9058c19611fa9)},
+  {FIELD_LITERAL(0x00c41d1f9c1f1ac1,0x007b2df4e9f19146,0x00b469355fd5ba7a,0x00b5e1965afc852a,0x00388d5f1e2d8217,0x0022079e4c09ae93,0x0014268acd4ef518,0x00c1dd8d9640464c)},
+  {FIELD_LITERAL(0x0038526adeed0c55,0x00dd68c607e3fe85,0x00f746ddd48a5d57,0x0042f2952b963b7c,0x001cbbd6876d5ec2,0x005e341470bca5c2,0x00871d41e085f413,0x00e53ab098f45732)},
   {FIELD_LITERAL(0x004d51124797c831,0x008f5ae3750347ad,0x0070ced94c1a0c8e,0x00f6db2043898e64,0x000d00c9a5750cd0,0x000741ec59bad712,0x003c9d11aab37b7f,0x00a67ba169807714)},
-  {FIELD_LITERAL(0x00dc70fe7eb5cbde,0x003cda5bb49331d7,0x00dec9068514f18c,0x00f3537d975b501d,0x00dd02de725b8e4b,0x0062327200072106,0x0034607e7e266644,0x00ebc51a91215cb6)},
-  {FIELD_LITERAL(0x00a5187e6ee7341b,0x00e6d52e82d83b6e,0x00df3c41323094a7,0x00b3324f444e9de9,0x00689eb21a35bfe5,0x00f16363becd548d,0x00e187cc98e7f60f,0x00127d9062f0ccab)},
+  {FIELD_LITERAL(0x00adb2c1566e8b8f,0x0096c68a35771a9a,0x00869933356f334a,0x00ba9c93459f5962,0x009ec73fb6e8ca4b,0x003c3802c27202e1,0x0031f5b733e0c008,0x00f9058c19611fa9)},
+  {FIELD_LITERAL(0x00238f01814a3421,0x00c325a44b6cce28,0x002136f97aeb0e73,0x000cac8268a4afe2,0x0022fd218da471b3,0x009dcd8dfff8def9,0x00cb9f8181d999bb,0x00143ae56edea349)},
   {FIELD_LITERAL(0x0000623bf87622c5,0x00a1966fdd069496,0x00c315b7b812f9fc,0x00bdf5efcd128b97,0x001d464f532e3e16,0x003cd94f081bfd7e,0x00ed9dae12ce4009,0x002756f5736eee70)},
-  {FIELD_LITERAL(0x00b528e4ce3d61bf,0x005a03531ed051d6,0x00bbda4aa68d7f12,0x001810a28e93ccb9,0x00ef4ac525bef536,0x006dcefdd9f9f364,0x006e3d9ed78d6381,0x00774bd6ff0713c4)},
-  {FIELD_LITERAL(0x00c13c5aae3ae341,0x009c6c9ed98373e7,0x00098f26864577a8,0x0015b886e9488b45,0x0037692c42aadba5,0x00b83170b8e7791c,0x001670952ece1b44,0x00fd932a39276da2)},
+  {FIELD_LITERAL(0x00a5187e6ee7341b,0x00e6d52e82d83b6e,0x00df3c41323094a7,0x00b3324f444e9de9,0x00689eb21a35bfe5,0x00f16363becd548d,0x00e187cc98e7f60f,0x00127d9062f0ccab)},
+  {FIELD_LITERAL(0x004ad71b31c29e40,0x00a5fcace12fae29,0x004425b5597280ed,0x00e7ef5d716c3346,0x0010b53ada410ac8,0x0092310226060c9b,0x0091c26128729c7e,0x0088b42900f8ec3b)},
   {FIELD_LITERAL(0x00f1e26e9762d4a8,0x00d9d74082183414,0x00ffec9bd57a0282,0x000919e128fd497a,0x00ab7ae7d00fe5f8,0x0054dc442851ff68,0x00c9ebeb3b861687,0x00507f7cab8b698f)},
-  {FIELD_LITERAL(0x007e5cda6410cc67,0x00ab7f000be9ef84,0x0031b09f82de4167,0x00c003f7b4be2064,0x00bc2f44effafd2d,0x0013ca0a8a45cd9e,0x0035e70988cff10c,0x001744f57d827ab7)},
-  {FIELD_LITERAL(0x009ae3b93a56c404,0x004a410b7a456699,0x00023a619355e6b2,0x009cdc7297387257,0x0055b94d4ae70d04,0x002cbd607f65b005,0x003208b489697166,0x00ea2aa058867370)},
+  {FIELD_LITERAL(0x00c13c5aae3ae341,0x009c6c9ed98373e7,0x00098f26864577a8,0x0015b886e9488b45,0x0037692c42aadba5,0x00b83170b8e7791c,0x001670952ece1b44,0x00fd932a39276da2)},
+  {FIELD_LITERAL(0x0081a3259bef3398,0x005480fff416107b,0x00ce4f607d21be98,0x003ffc084b41df9b,0x0043d0bb100502d1,0x00ec35f575ba3261,0x00ca18f677300ef3,0x00e8bb0a827d8548)},
   {FIELD_LITERAL(0x00df76b3328ada72,0x002e20621604a7c2,0x00f910638a105b09,0x00ef4724d96ef2cd,0x00377d83d6b8a2f7,0x00b4f48805ade324,0x001cd5da8b152018,0x0045af671a20ca7f)},
-  {FIELD_LITERAL(0x000d62da6711c0cd,0x004b53ac7a27d523,0x0089cc150fb20e64,0x0055d2c2883154fe,0x00b5dcfd03448874,0x006d80dda2a505cb,0x00b57162afb80dc8,0x007ddb5162431acf)},
-  {FIELD_LITERAL(0x00c845923c084294,0x00072419a201bc25,0x0045f408b5f8e669,0x00e9d6a186b74dfe,0x00e19108c68fa075,0x0017b91d874177b7,0x002f0ca2c7912c5a,0x009400aa385a90a2)},
+  {FIELD_LITERAL(0x009ae3b93a56c404,0x004a410b7a456699,0x00023a619355e6b2,0x009cdc7297387257,0x0055b94d4ae70d04,0x002cbd607f65b005,0x003208b489697166,0x00ea2aa058867370)},
+  {FIELD_LITERAL(0x00f29d2598ee3f32,0x00b4ac5385d82adc,0x007633eaf04df19b,0x00aa2d3d77ceab01,0x004a2302fcbb778a,0x00927f225d5afa34,0x004a8e9d5047f237,0x008224ae9dbce530)},
   {FIELD_LITERAL(0x001cf640859b02f8,0x00758d1d5d5ce427,0x00763c784ef4604c,0x005fa81aee205270,0x00ac537bfdfc44cb,0x004b919bd342d670,0x00238508d9bf4b7a,0x00154888795644f3)},
-  {FIELD_LITERAL(0x008eeef4feb7de7b,0x003012ffbb0d4107,0x00cb0d6fe30b99d1,0x00c4b51d598067cb,0x003356469016b7ee,0x00addaf85188542f,0x004538bdd8de18c1,0x00999dd4f0c59d4f)},
-  {FIELD_LITERAL(0x0026ef1614e160af,0x00c023f9edfc9c76,0x00cff090da5f57ba,0x0076db7a66643ae9,0x0019462f8c646999,0x008fec00b3854b22,0x00d55041692a0a1c,0x0065db894215ca00)},
+  {FIELD_LITERAL(0x00c845923c084294,0x00072419a201bc25,0x0045f408b5f8e669,0x00e9d6a186b74dfe,0x00e19108c68fa075,0x0017b91d874177b7,0x002f0ca2c7912c5a,0x009400aa385a90a2)},
+  {FIELD_LITERAL(0x0071110b01482184,0x00cfed0044f2bef8,0x0034f2901cf4662e,0x003b4ae2a67f9834,0x00cca9b96fe94810,0x00522507ae77abd0,0x00bac7422721e73e,0x0066622b0f3a62b0)},
   {FIELD_LITERAL(0x00f8ac5cf4705b6a,0x00867d82dcb457e3,0x007e13ab2ccc2ce9,0x009ee9a018d3930e,0x008370f8ecb42df8,0x002d9f019add263e,0x003302385b92d196,0x00a15654536e2c0c)},
-  {FIELD_LITERAL(0x0056dafc91f5bae3,0x00d5fc6f3c94933e,0x000d8fdf26f76b0b,0x00726f2ad342c280,0x001e2fec8c6d0c46,0x000fe83ea74ae570,0x00353cec2c128243,0x0046657e1c14bd2c)},
-  {FIELD_LITERAL(0x008cc9cd236315c0,0x0031d9c5b39fda54,0x00a5713ef37e1171,0x00293d5ae2886325,0x00c4aba3e05015e1,0x0003f35ef78e4fc6,0x0039d6bd3ac1527b,0x0019d7c3afb77106)},
+  {FIELD_LITERAL(0x0026ef1614e160af,0x00c023f9edfc9c76,0x00cff090da5f57ba,0x0076db7a66643ae9,0x0019462f8c646999,0x008fec00b3854b22,0x00d55041692a0a1c,0x0065db894215ca00)},
+  {FIELD_LITERAL(0x00a925036e0a451c,0x002a0390c36b6cc1,0x00f27020d90894f4,0x008d90d52cbd3d7f,0x00e1d0137392f3b8,0x00f017c158b51a8f,0x00cac313d3ed7dbc,0x00b99a81e3eb42d3)},
   {FIELD_LITERAL(0x00b54850275fe626,0x0053a3fd1ec71140,0x00e3d2d7dbe096fa,0x00e4ac7b595cce4c,0x0077bad449c0a494,0x00b7c98814afd5b3,0x0057226f58486cf9,0x00b1557154f0cc57)},
-  {FIELD_LITERAL(0x0084e9d6ce567a50,0x0052bf5d1f2558ec,0x00920d83bff60ee7,0x00afc160b1d17413,0x008ae58837d3e7d1,0x00fd676c8896dba4,0x00004e170540611a,0x00f7ccb8f91f6541)},
-  {FIELD_LITERAL(0x004246bfcecc627a,0x004ba431246c03a4,0x00bd1d101872d497,0x003b73d3f185ee16,0x001feb2e2678c0e3,0x00ff13c5a89dec76,0x00ed06042e771d8f,0x00a4fd2a897a83dd)},
+  {FIELD_LITERAL(0x008cc9cd236315c0,0x0031d9c5b39fda54,0x00a5713ef37e1171,0x00293d5ae2886325,0x00c4aba3e05015e1,0x0003f35ef78e4fc6,0x0039d6bd3ac1527b,0x0019d7c3afb77106)},
+  {FIELD_LITERAL(0x007b162931a985af,0x00ad40a2e0daa713,0x006df27c4009f118,0x00503e9f4e2e8bec,0x00751a77c82c182d,0x000298937769245b,0x00ffb1e8fabf9ee5,0x0008334706e09abe)},
   {FIELD_LITERAL(0x00dbca4e98a7dcd9,0x00ee29cfc78bde99,0x00e4a3b6995f52e9,0x0045d70189ae8096,0x00fd2a8a3b9b0d1b,0x00af1793b107d8e1,0x00dbf92cbe4afa20,0x00da60f798e3681d)},
-  {FIELD_LITERAL(0x0065b5c41af29a68,0x0021ce9a03a5ef69,0x00b0c0a91cba4f38,0x0008408de2a54743,0x00bcec1b84f673ae,0x001b382a3f1e5244,0x00d1c1c24c9afae1,0x005b7f3d32956904)},
-  {FIELD_LITERAL(0x004ede34af2813f3,0x00d4a8e11c9e8216,0x004796d5041de8a5,0x00c4c6b4d21cc987,0x00e8a433ee07fa1e,0x0055720b5abcc5a1,0x008873ea9c74b080,0x005b3fec1ab65d48)},
+  {FIELD_LITERAL(0x004246bfcecc627a,0x004ba431246c03a4,0x00bd1d101872d497,0x003b73d3f185ee16,0x001feb2e2678c0e3,0x00ff13c5a89dec76,0x00ed06042e771d8f,0x00a4fd2a897a83dd)},
+  {FIELD_LITERAL(0x009a4a3be50d6597,0x00de3165fc5a1096,0x004f3f56e345b0c7,0x00f7bf721d5ab8bc,0x004313e47b098c50,0x00e4c7d5c0e1adbb,0x002e3e3db365051e,0x00a480c2cd6a96fb)},
   {FIELD_LITERAL(0x00417fa30a7119ed,0x00af257758419751,0x00d358a487b463d4,0x0089703cc720b00d,0x00ce56314ff7f271,0x0064db171ade62c1,0x00640b36d4a22fed,0x00424eb88696d23f)},
-  {FIELD_LITERAL(0x00b81ad88248f13a,0x00f5f69399248294,0x004be9b33e8cfea6,0x00b56087c018df01,0x0057e8846bbb6242,0x006a5db00b65a660,0x00963e3a87daf343,0x00badfe6dec2140b)},
-  {FIELD_LITERAL(0x001bd59c09e982ea,0x00f72daeb937b289,0x0018b76dca908e0e,0x00edb498512384ad,0x00ce0243b6cc9538,0x00f96ff690cb4e70,0x007c77bf9f673c8d,0x005bf704c088a528)},
+  {FIELD_LITERAL(0x004ede34af2813f3,0x00d4a8e11c9e8216,0x004796d5041de8a5,0x00c4c6b4d21cc987,0x00e8a433ee07fa1e,0x0055720b5abcc5a1,0x008873ea9c74b080,0x005b3fec1ab65d48)},
+  {FIELD_LITERAL(0x0047e5277db70ec5,0x000a096c66db7d6b,0x00b4164cc1730159,0x004a9f783fe720fe,0x00a8177b94449dbc,0x0095a24ff49a599f,0x0069c1c578250cbc,0x00452019213debf4)},
   {FIELD_LITERAL(0x0021ce99e09ebda3,0x00fcbd9f91875ad0,0x009bbf6b7b7a0b5f,0x00388886a69b1940,0x00926a56d0f81f12,0x00e12903c3358d46,0x005dfce4e8e1ce9d,0x0044cfa94e2f7e23)},
-  {FIELD_LITERAL(0x006c2b9d7234cc41,0x006ad9c2ae2bda7d,0x00b64cdddba701f9,0x00180318c49ac580,0x00c35d14319f4c95,0x003a21dc65cd415b,0x009c474c28e04940,0x00c65114875e57c6)},
-  {FIELD_LITERAL(0x00fb22bb5fd3ce50,0x0017b48aada7ae54,0x00fd5c44ad19a536,0x000ccc4e4e55e45c,0x00fd637d45b4c3f5,0x0038914e023c37cf,0x00ac1881d6a8d898,0x00611ed8d3d943a8)},
+  {FIELD_LITERAL(0x001bd59c09e982ea,0x00f72daeb937b289,0x0018b76dca908e0e,0x00edb498512384ad,0x00ce0243b6cc9538,0x00f96ff690cb4e70,0x007c77bf9f673c8d,0x005bf704c088a528)},
+  {FIELD_LITERAL(0x0093d4628dcb33be,0x0095263d51d42582,0x0049b3222458fe06,0x00e7fce73b653a7f,0x003ca2ebce60b369,0x00c5de239a32bea4,0x0063b8b3d71fb6bf,0x0039aeeb78a1a839)},
   {FIELD_LITERAL(0x007dc52da400336c,0x001fded1e15b9457,0x00902e00f5568e3a,0x00219bef40456d2d,0x005684161fb3dbc9,0x004a4e9be49a76ea,0x006e685ae88b78ff,0x0021c42f13042d3c)},
-  {FIELD_LITERAL(0x00a91dda62eec2d4,0x00a6b7e64d7b13e9,0x00384086b44c9969,0x008de118af683239,0x0008e416fb85d76c,0x0020945ebda9b120,0x0096a7f485e7b172,0x000fa91c7035f011)},
-  {FIELD_LITERAL(0x005e8694077a1535,0x008bef75f71c8f1d,0x000a7c1316423511,0x00906e1d70604320,0x003fc46c1a2ffbd6,0x00d1d5022e68f360,0x002515fba37bbf46,0x00ca16234e023b44)},
+  {FIELD_LITERAL(0x00fb22bb5fd3ce50,0x0017b48aada7ae54,0x00fd5c44ad19a536,0x000ccc4e4e55e45c,0x00fd637d45b4c3f5,0x0038914e023c37cf,0x00ac1881d6a8d898,0x00611ed8d3d943a8)},
+  {FIELD_LITERAL(0x0056e2259d113d2b,0x00594819b284ec16,0x00c7bf794bb36696,0x00721ee75097cdc6,0x00f71be9047a2892,0x00df6ba142564edf,0x0069580b7a184e8d,0x00f056e38fca0fee)},
   {FIELD_LITERAL(0x009df98566a18c6d,0x00cf3a200968f219,0x0044ba60da6d9086,0x00dbc9c0e344da03,0x000f9401c4466855,0x00d46a57c5b0a8d1,0x00875a635d7ac7c6,0x00ef4a933b7e0ae6)},
-  {FIELD_LITERAL(0x00878366a9e0b96f,0x0057a8573ea9e0d8,0x005ef206ddc3f601,0x0046756a9d1c4eab,0x00bccf478bb3c12c,0x001f97ed7f813a3b,0x001b309582460e1c,0x0026a4f760ecd5cb)},
-  {FIELD_LITERAL(0x00139078397030bd,0x000e3c447e859a00,0x0064a5b334c82393,0x00b8aabeb7358093,0x00020778bb9ae73b,0x0032ee94c7892a18,0x008215253cb41bda,0x005e2797593517ae)},
+  {FIELD_LITERAL(0x005e8694077a1535,0x008bef75f71c8f1d,0x000a7c1316423511,0x00906e1d70604320,0x003fc46c1a2ffbd6,0x00d1d5022e68f360,0x002515fba37bbf46,0x00ca16234e023b44)},
+  {FIELD_LITERAL(0x00787c99561f4690,0x00a857a8c1561f27,0x00a10df9223c09fe,0x00b98a9562e3b154,0x004330b8744c3ed2,0x00e06812807ec5c4,0x00e4cf6a7db9f1e3,0x00d95b089f132a34)},
   {FIELD_LITERAL(0x002922b39ca33eec,0x0090d12a5f3ab194,0x00ab60c02fb5f8ed,0x00188d292abba1cf,0x00e10edec9698f6e,0x0069a4d9934133c8,0x0024aac40e6d3d06,0x001702c2177661b0)},
-  {FIELD_LITERAL(0x007c89a5a07aa2b5,0x00ae492ecae4711d,0x00ee921ab74f0844,0x007842778fc5005f,0x006a4d33cb28022c,0x007b327e4ac0f437,0x007a9d0366acaf12,0x005c6544e6c9ae1c)},
-  {FIELD_LITERAL(0x0091868594265aa2,0x00797accae98ca6d,0x0008d8c5f0f8a184,0x00d1f4f1c2b2fe6e,0x0036783dfb48a006,0x008c165120503527,0x0025fd780058ce9b,0x0068beb007be7d27)},
+  {FIELD_LITERAL(0x00139078397030bd,0x000e3c447e859a00,0x0064a5b334c82393,0x00b8aabeb7358093,0x00020778bb9ae73b,0x0032ee94c7892a18,0x008215253cb41bda,0x005e2797593517ae)},
+  {FIELD_LITERAL(0x0083765a5f855d4a,0x0051b6d1351b8ee2,0x00116de548b0f7bb,0x0087bd88703affa0,0x0095b2cc34d7fdd2,0x0084cd81b53f0bc8,0x008562fc995350ed,0x00a39abb193651e3)},
   {FIELD_LITERAL(0x0019e23f0474b114,0x00eb94c2ad3b437e,0x006ddb34683b75ac,0x00391f9209b564c6,0x00083b3bb3bff7aa,0x00eedcd0f6dceefc,0x00b50817f794fe01,0x0036474deaaa75c9)},
-  {FIELD_LITERAL(0x002f007755836f3d,0x004d39f2530acc6b,0x006b58d7b2699929,0x004126fdd3185e62,0x003aeaac0f32897c,0x003c0478f4edb66d,0x0072f43ac66a9364,0x0003730da744777a)},
-  {FIELD_LITERAL(0x0045fdc16487cda3,0x00b2d8e844cf2ed7,0x00612c50e88c1607,0x00a08aabc66c1672,0x006031fdcbb24d97,0x001b639525744b93,0x004409d62639ab17,0x00a1853d0347ab1d)},
+  {FIELD_LITERAL(0x0091868594265aa2,0x00797accae98ca6d,0x0008d8c5f0f8a184,0x00d1f4f1c2b2fe6e,0x0036783dfb48a006,0x008c165120503527,0x0025fd780058ce9b,0x0068beb007be7d27)},
+  {FIELD_LITERAL(0x00d0ff88aa7c90c2,0x00b2c60dacf53394,0x0094a7284d9666d6,0x00bed9022ce7a19d,0x00c51553f0cd7682,0x00c3fb870b124992,0x008d0bc539956c9b,0x00fc8cf258bb8885)},
   {FIELD_LITERAL(0x003667bf998406f8,0x0000115c43a12975,0x001e662f3b20e8fd,0x0019ffa534cb24eb,0x00016be0dc8efb45,0x00ff76a8b26243f5,0x00ae20d241a541e3,0x0069bd6af13cd430)},
-  {FIELD_LITERAL(0x008a5e5a9140a3de,0x005c18d41653ac12,0x0010321e9d6e8f3d,0x00fbdda016e10aca,0x0077fb6038c20257,0x00b5438b7a81ed77,0x00db1dbcb9a8ce83,0x0026734c2c1aabc3)},
-  {FIELD_LITERAL(0x007e32c049b5c477,0x009d2bfdbd9bcfd8,0x00636e93045938c6,0x007fde4af7687298,0x0046a5184fafa5d3,0x0079b1e7f13a359b,0x00875adf1fb927d6,0x00333e21c61bcad2)},
+  {FIELD_LITERAL(0x0045fdc16487cda3,0x00b2d8e844cf2ed7,0x00612c50e88c1607,0x00a08aabc66c1672,0x006031fdcbb24d97,0x001b639525744b93,0x004409d62639ab17,0x00a1853d0347ab1d)},
+  {FIELD_LITERAL(0x0075a1a56ebf5c21,0x00a3e72be9ac53ed,0x00efcde1629170c2,0x0004225fe91ef535,0x0088049fc73dfda7,0x004abc74857e1288,0x0024e2434657317c,0x00d98cb3d3e5543c)},
   {FIELD_LITERAL(0x00b4b53eab6bdb19,0x009b22d8b43711d0,0x00d948b9d961785d,0x00cb167b6f279ead,0x00191de3a678e1c9,0x00d9dd9511095c2e,0x00f284324cd43067,0x00ed74fa535151dd)},
-  {FIELD_LITERAL(0x00fb7feb08c27472,0x008a97b55f699c77,0x006d41820f923b83,0x006831432f0aa975,0x00a58ffb263b3955,0x004f13449a66db38,0x0026fccd22b6d583,0x00a803eb20eeb6c2)},
-  {FIELD_LITERAL(0x007df6cbb926830b,0x00d336058ae37865,0x007af47dac696423,0x0048d3011ec64ac8,0x006b87666e40049f,0x0036a2e0e51303d7,0x00ba319bd79dbc55,0x003e2737ecc94f53)},
+  {FIELD_LITERAL(0x007e32c049b5c477,0x009d2bfdbd9bcfd8,0x00636e93045938c6,0x007fde4af7687298,0x0046a5184fafa5d3,0x0079b1e7f13a359b,0x00875adf1fb927d6,0x00333e21c61bcad2)},
+  {FIELD_LITERAL(0x00048014f73d8b8d,0x0075684aa0966388,0x0092be7df06dc47c,0x0097cebcd0f5568a,0x005a7004d9c4c6a9,0x00b0ecbb659924c7,0x00d90332dd492a7c,0x0057fc14df11493d)},
   {FIELD_LITERAL(0x0008ed8ea0ad95be,0x0041d324b9709645,0x00e25412257a19b4,0x0058df9f3423d8d2,0x00a9ab20def71304,0x009ae0dbf8ac4a81,0x00c9565977e4392a,0x003c9269444baf55)},
-  {FIELD_LITERAL(0x002d69008d9d8d26,0x00092f686d7030a8,0x001f19e95aa28fec,0x002150bab1261538,0x008c5a941210b26c,0x009330209036d1e6,0x0062e11ec8e58de7,0x0011c3d11bb9d27f)},
-  {FIELD_LITERAL(0x008132ae5c5d8cd1,0x00121d68324a1d9f,0x00d6be9dafcb8c76,0x00684d9070edf745,0x00519fbc96d7448e,0x00388182fdc1f27e,0x000235baed41f158,0x00bf6cf6f1a1796a)},
+  {FIELD_LITERAL(0x007df6cbb926830b,0x00d336058ae37865,0x007af47dac696423,0x0048d3011ec64ac8,0x006b87666e40049f,0x0036a2e0e51303d7,0x00ba319bd79dbc55,0x003e2737ecc94f53)},
+  {FIELD_LITERAL(0x00d296ff726272d9,0x00f6d097928fcf57,0x00e0e616a55d7013,0x00deaf454ed9eac7,0x0073a56bedef4d92,0x006ccfdf6fc92e19,0x009d1ee1371a7218,0x00ee3c2ee4462d80)},
   {FIELD_LITERAL(0x00437bce9bccdf9d,0x00e0c8e2f85dc0a3,0x00c91a7073995a19,0x00856ec9fe294559,0x009e4b33394b156e,0x00e245b0dc497e5c,0x006a54e687eeaeff,0x00f1cd1cd00fdb7c)},
-  {FIELD_LITERAL(0x00d523b4b2eb7de6,0x00cf7b525f2c56f5,0x00b9217554f0d1b1,0x00bad2cbd5984a02,0x002b4af0fe2b21dd,0x002492603f310486,0x0073e7b3795b9d32,0x001e837c89b2bd25)},
-  {FIELD_LITERAL(0x00ce382dc7993d92,0x00021153e938b4c8,0x00096f7567f48f51,0x0058f81ddfe4b0d5,0x00cc379a56b355c7,0x002c760770d3e819,0x00ee22d1d26e5a40,0x00de6d93d5b082d7)},
+  {FIELD_LITERAL(0x008132ae5c5d8cd1,0x00121d68324a1d9f,0x00d6be9dafcb8c76,0x00684d9070edf745,0x00519fbc96d7448e,0x00388182fdc1f27e,0x000235baed41f158,0x00bf6cf6f1a1796a)},
+  {FIELD_LITERAL(0x002adc4b4d148219,0x003084ada0d3a90a,0x0046de8aab0f2e4e,0x00452d342a67b5fd,0x00d4b50f01d4de21,0x00db6d9fc0cefb79,0x008c184c86a462cd,0x00e17c83764d42da)},
   {FIELD_LITERAL(0x007b2743b9a1e01a,0x007847ffd42688c4,0x006c7844d610a316,0x00f0cb8b250aa4b0,0x00a19060143b3ae6,0x0014eb10b77cfd80,0x000170905729dd06,0x00063b5b9cd72477)},
-  {FIELD_LITERAL(0x00f56e5bd3ad1fa9,0x00e7a09488031815,0x00f7fc3ae69d094a,0x00ddad7a7d45a9c2,0x00bc07fbf167a928,0x007a5d6137e0479f,0x00a0659eeab60a00,0x003e068b1342b4f9)},
-  {FIELD_LITERAL(0x00ffc5c89d2b0cba,0x00d363d42e3e6fc3,0x0019a1a0118e2e8a,0x00f7baeff48882e1,0x001bd5af28c6b514,0x0055476ca2253cb2,0x00d8eb1977e2ddf3,0x00b173b1adb228a1)},
+  {FIELD_LITERAL(0x00ce382dc7993d92,0x00021153e938b4c8,0x00096f7567f48f51,0x0058f81ddfe4b0d5,0x00cc379a56b355c7,0x002c760770d3e819,0x00ee22d1d26e5a40,0x00de6d93d5b082d7)},
+  {FIELD_LITERAL(0x000a91a42c52e056,0x00185f6b77fce7ea,0x000803c51962f6b5,0x0022528582ba563d,0x0043f8040e9856d6,0x0085a29ec81fb860,0x005f9a611549f5ff,0x00c1f974ecbd4b06)},
   {FIELD_LITERAL(0x005b64c6fd65ec97,0x00c1fdd7f877bc7f,0x000d9cc6c89f841c,0x005c97b7f1aff9ad,0x0075e3c61475d47e,0x001ecb1ba8153011,0x00fe7f1c8d71d40d,0x003fa9757a229832)},
-  {FIELD_LITERAL(0x000d346622f528f8,0x001e1f7497a62227,0x00fff70d2f9af433,0x002812c6d079ea3c,0x006898af56b25d7f,0x00c17c44f1349645,0x00207172ea3eb539,0x000608e8bd6a263d)},
-  {FIELD_LITERAL(0x002389319450f9ba,0x003677f31aa1250a,0x0092c3db642f38cb,0x00f8b64c0dfc9773,0x00cd49fe3505b795,0x0068105a4090a510,0x00df0ba2072a8bb6,0x00eb396143afd8be)},
+  {FIELD_LITERAL(0x00ffc5c89d2b0cba,0x00d363d42e3e6fc3,0x0019a1a0118e2e8a,0x00f7baeff48882e1,0x001bd5af28c6b514,0x0055476ca2253cb2,0x00d8eb1977e2ddf3,0x00b173b1adb228a1)},
+  {FIELD_LITERAL(0x00f2cb99dd0ad707,0x00e1e08b6859ddd8,0x000008f2d0650bcc,0x00d7ed392f8615c3,0x00976750a94da27f,0x003e83bb0ecb69ba,0x00df8e8d15c14ac6,0x00f9f7174295d9c2)},
   {FIELD_LITERAL(0x00f11cc8e0e70bcb,0x00e5dc689974e7dd,0x0014e409f9ee5870,0x00826e6689acbd63,0x008a6f4e3d895d88,0x00b26a8da41fd4ad,0x000fb7723f83efd7,0x009c749db0a5f6c3)},
-  {FIELD_LITERAL(0x005f2b1304db3200,0x0022507ff7459b86,0x000f4c1c92b4f0bb,0x00c8cb42c50e0eb9,0x004781d1038aad80,0x002dcf20aa2254af,0x00d9ecda851a93e2,0x0043f6b92eca6cb2)},
-  {FIELD_LITERAL(0x0067f8f0c4fe26c9,0x0079c4a3cc8f67b9,0x0082b1e62f23550d,0x00f2d409caefd7f5,0x0080e67dcdb26e81,0x0087ae993ea1f98a,0x00aa108becf61d03,0x001acf11efb608a3)},
+  {FIELD_LITERAL(0x002389319450f9ba,0x003677f31aa1250a,0x0092c3db642f38cb,0x00f8b64c0dfc9773,0x00cd49fe3505b795,0x0068105a4090a510,0x00df0ba2072a8bb6,0x00eb396143afd8be)},
+  {FIELD_LITERAL(0x00a0d4ecfb24cdff,0x00ddaf8008ba6479,0x00f0b3e36d4b0f44,0x003734bd3af1f146,0x00b87e2efc75527e,0x00d230df55ddab50,0x002613257ae56c1d,0x00bc0946d135934d)},
   {FIELD_LITERAL(0x00468711bd994651,0x0033108fa67561bf,0x0089d760192a54b4,0x00adc433de9f1871,0x000467d05f36e050,0x007847e0f0579f7f,0x00a2314ad320052d,0x00b3a93649f0b243)},
-  {FIELD_LITERAL(0x007dda014454af26,0x000c49fa1b22df7c,0x005cd4d7e761dc2d,0x002af81a1a14b368,0x00a5e57b1cfd7ddf,0x00f90ab3e3a0f738,0x005cb83734d7bc0f,0x00f608c16abb405a)},
-  {FIELD_LITERAL(0x00e828333c297f8b,0x009ef3cf8c3f7e1f,0x00ab45f8fff31cb9,0x00c8b4178cb0b013,0x00d0c50dd3260a3f,0x0097126ac257f5bc,0x0042376cc90c705a,0x001d96fdb4a1071e)},
+  {FIELD_LITERAL(0x0067f8f0c4fe26c9,0x0079c4a3cc8f67b9,0x0082b1e62f23550d,0x00f2d409caefd7f5,0x0080e67dcdb26e81,0x0087ae993ea1f98a,0x00aa108becf61d03,0x001acf11efb608a3)},
+  {FIELD_LITERAL(0x008225febbab50d9,0x00f3b605e4dd2083,0x00a32b28189e23d2,0x00d507e5e5eb4c97,0x005a1a84e302821f,0x0006f54c1c5f08c7,0x00a347c8cb2843f0,0x0009f73e9544bfa5)},
   {FIELD_LITERAL(0x006c59c9ae744185,0x009fc32f1b4282cd,0x004d6348ca59b1ac,0x00105376881be067,0x00af4096013147dc,0x004abfb5a5cb3124,0x000d2a7f8626c354,0x009c6ed568e07431)},
-  {FIELD_LITERAL(0x00abd2bb27611e57,0x00cf99bd1fbbd267,0x006f7ac78d478cc7,0x00dc9d340dd23fbb,0x00d3ddd520099c46,0x009836dbb6a03486,0x00f19de267c36883,0x0020885613349904)},
-  {FIELD_LITERAL(0x00832d02369b482c,0x00cba52ff0d93450,0x003fa9c908d554db,0x008d1e357b54122f,0x00abd91c2dc950c6,0x007eff1df4c0ec69,0x003f6aeb13fb2d31,0x00002d6179fc5b2c)},
+  {FIELD_LITERAL(0x00e828333c297f8b,0x009ef3cf8c3f7e1f,0x00ab45f8fff31cb9,0x00c8b4178cb0b013,0x00d0c50dd3260a3f,0x0097126ac257f5bc,0x0042376cc90c705a,0x001d96fdb4a1071e)},
+  {FIELD_LITERAL(0x00542d44d89ee1a8,0x00306642e0442d98,0x0090853872b87338,0x002362cbf22dc044,0x002c222adff663b8,0x0067c924495fcb79,0x000e621d983c977c,0x00df77a9eccb66fb)},
   {FIELD_LITERAL(0x002809e4bbf1814a,0x00b9e854f9fafb32,0x00d35e67c10f7a67,0x008f1bcb76e748cf,0x004224d9515687d2,0x005ba0b774e620c4,0x00b5e57db5d54119,0x00e15babe5683282)},
-  {FIELD_LITERAL(0x00b9361257e36376,0x0049f348e3709d03,0x00dd0a597c455aa7,0x00078ce603320668,0x00635f64ae3195dc,0x00a4ed450b508288,0x0075b9adb5e1cc1d,0x00fca588167741f2)},
-  {FIELD_LITERAL(0x00a9e7730a819691,0x00d9cc73c4992b70,0x00e299bde067de5a,0x008c314eb705192a,0x00e7226f17e8a3cc,0x0029dfd956e65a47,0x0053a8e839073b12,0x006f942b2ab1597e)},
+  {FIELD_LITERAL(0x00832d02369b482c,0x00cba52ff0d93450,0x003fa9c908d554db,0x008d1e357b54122f,0x00abd91c2dc950c6,0x007eff1df4c0ec69,0x003f6aeb13fb2d31,0x00002d6179fc5b2c)},
+  {FIELD_LITERAL(0x0046c9eda81c9c89,0x00b60cb71c8f62fc,0x0022f5a683baa558,0x00f87319fccdf997,0x009ca09b51ce6a22,0x005b12baf4af7d77,0x008a46524a1e33e2,0x00035a77e988be0d)},
   {FIELD_LITERAL(0x00a7efe46a7dbe2f,0x002f66fd55014fe7,0x006a428afa1ff026,0x0056caaa9604ab72,0x0033f3bcd7fac8ae,0x00ccb1aa01c86764,0x00158d1edf13bf40,0x009848ee76fcf3b4)},
-  {FIELD_LITERAL(0x00e3c287f132a1c6,0x006b0db804233a01,0x002a387902ad889b,0x00490b258b0f24d5,0x007f0e0745232a02,0x000c95c8c52d1dc4,0x0007fb060bcbc40d,0x002e50bf139dc67d)},
-  {FIELD_LITERAL(0x0039343746531ebe,0x00c8509d835d429d,0x00e79eceff6b0018,0x004abfd31e8efce5,0x007bbfaaa1e20210,0x00e3be89c193e179,0x001c420f4c31d585,0x00f414a315bef5ae)},
+  {FIELD_LITERAL(0x00a9e7730a819691,0x00d9cc73c4992b70,0x00e299bde067de5a,0x008c314eb705192a,0x00e7226f17e8a3cc,0x0029dfd956e65a47,0x0053a8e839073b12,0x006f942b2ab1597e)},
+  {FIELD_LITERAL(0x001c3d780ecd5e39,0x0094f247fbdcc5fe,0x00d5c786fd527764,0x00b6f4da74f0db2a,0x0080f1f8badcd5fc,0x00f36a373ad2e23b,0x00f804f9f4343bf2,0x00d1af40ec623982)},
   {FIELD_LITERAL(0x0082aeace5f1b144,0x00f68b3108cf4dd3,0x00634af01dde3020,0x000beab5df5c2355,0x00e8b790d1b49b0b,0x00e48d15854e36f4,0x0040ab2d95f3db9f,0x002711c4ed9e899a)},
-  {FIELD_LITERAL(0x0083d695db66f207,0x002a2f8ada58aa77,0x002271eec16b4818,0x008443a70141f337,0x00d60ae50640352b,0x00816cee1385490c,0x006577b21e989cbc,0x00af2a0d2317b416)},
-  {FIELD_LITERAL(0x0098cddc8b39549a,0x006da37e3b05d22c,0x00ce633cfd4eb3cb,0x00fda288ef526acd,0x0025338878c5d30a,0x00f34438c4e5a1b4,0x00584efea7c310f1,0x0041a551f1b660ad)},
+  {FIELD_LITERAL(0x0039343746531ebe,0x00c8509d835d429d,0x00e79eceff6b0018,0x004abfd31e8efce5,0x007bbfaaa1e20210,0x00e3be89c193e179,0x001c420f4c31d585,0x00f414a315bef5ae)},
+  {FIELD_LITERAL(0x007c296a24990df8,0x00d5d07525a75588,0x00dd8e113e94b7e7,0x007bbc58febe0cc8,0x0029f51af9bfcad3,0x007e9311ec7ab6f3,0x009a884de1676343,0x0050d5f2dce84be9)},
   {FIELD_LITERAL(0x005fa020cca2450a,0x00491c29db6416d8,0x0037cefe3f9f9a85,0x003d405230647066,0x0049e835f0fdbe89,0x00feb78ac1a0815c,0x00828e4b32dc9724,0x00db84f2dc8d6fd4)},
-  {FIELD_LITERAL(0x002808570429bc85,0x009d78dbec40c8ac,0x0052b4434bc3a7b4,0x00801b6419fe281c,0x008839a68764540a,0x0014ba034f958be4,0x00a31dbb6ec068f7,0x0077bd9bfe8c9cd9)},
-  {FIELD_LITERAL(0x00a0b68ec1eb72d2,0x002c03235c0d45a0,0x00553627323fe8c5,0x006186e94b17af94,0x00a9906196e29f14,0x0025b3aee6567733,0x007e0dd840080517,0x0018eb5801a4ba93)},
+  {FIELD_LITERAL(0x0098cddc8b39549a,0x006da37e3b05d22c,0x00ce633cfd4eb3cb,0x00fda288ef526acd,0x0025338878c5d30a,0x00f34438c4e5a1b4,0x00584efea7c310f1,0x0041a551f1b660ad)},
+  {FIELD_LITERAL(0x00d7f7a8fbd6437a,0x0062872413bf3753,0x00ad4bbcb43c584b,0x007fe49be601d7e3,0x0077c659789babf4,0x00eb45fcb06a741b,0x005ce244913f9708,0x0088426401736326)},
   {FIELD_LITERAL(0x007bf562ca768d7c,0x006c1f3a174e387c,0x00f024b447fee939,0x007e7af75f01143f,0x003adb70b4eed89d,0x00e43544021ad79a,0x0091f7f7042011f6,0x0093c1a1ee3a0ddc)},
-  {FIELD_LITERAL(0x0028018fe84095bf,0x0091c0f9db41f3bd,0x0000445dfaca7dba,0x000603d307e6bdc6,0x00726c4c840ea4b0,0x009220d1c741716a,0x00d4918640a03006,0x0054caa25bda1d21)},
-  {FIELD_LITERAL(0x003973d8938971d6,0x002aca26fa80c1f5,0x00108af1faa6b513,0x00daae275d7924e6,0x0053634ced721308,0x00d2355fe0bbd443,0x00357612b2d22095,0x00f9bb9dd4136cf3)},
+  {FIELD_LITERAL(0x00a0b68ec1eb72d2,0x002c03235c0d45a0,0x00553627323fe8c5,0x006186e94b17af94,0x00a9906196e29f14,0x0025b3aee6567733,0x007e0dd840080517,0x0018eb5801a4ba93)},
+  {FIELD_LITERAL(0x00d7fe7017bf6a40,0x006e3f0624be0c42,0x00ffbba205358245,0x00f9fc2cf8194239,0x008d93b37bf15b4e,0x006ddf2e38be8e95,0x002b6e79bf5fcff9,0x00ab355da425e2de)},
   {FIELD_LITERAL(0x00938f97e20be973,0x0099141a36aaf306,0x0057b0ca29e545a1,0x0085db571f9fbc13,0x008b333c554b4693,0x0043ab6ef3e241cb,0x0054fb20aa1e5c70,0x00be0ff852760adf)},
-  {FIELD_LITERAL(0x00d400ed30a1fc5a,0x00e424e0575e6307,0x0036e3986c07b2c6,0x0007960e4d145650,0x00a643ab823cdc93,0x0026e9ee292c7976,0x001f9d2555d3fdeb,0x0012c3fb833d437d)},
-  {FIELD_LITERAL(0x0062dd0fb31be374,0x00fcc96b84c8e727,0x003f64f1375e6ae3,0x0057d9b6dd1af004,0x00d6a167b1103c7b,0x00dd28f3180fb537,0x004ff27ad7167128,0x008934c33461f2ac)},
+  {FIELD_LITERAL(0x003973d8938971d6,0x002aca26fa80c1f5,0x00108af1faa6b513,0x00daae275d7924e6,0x0053634ced721308,0x00d2355fe0bbd443,0x00357612b2d22095,0x00f9bb9dd4136cf3)},
+  {FIELD_LITERAL(0x002bff12cf5e03a5,0x001bdb1fa8a19cf8,0x00c91c6793f84d39,0x00f869f1b2eba9af,0x0059bc547dc3236b,0x00d91611d6d38689,0x00e062daaa2c0214,0x00ed3c047cc2bc82)},
   {FIELD_LITERAL(0x000050d70c32b31a,0x001939d576d437b3,0x00d709e598bf9fe6,0x00a885b34bd2ee9e,0x00dd4b5c08ab1a50,0x0091bebd50b55639,0x00cf79ff64acdbc6,0x006067a39d826336)},
-  {FIELD_LITERAL(0x009a4b8d486fffbc,0x00458102d00ef9b4,0x00f498293b3cfdf0,0x00ed2d7b960b1b92,0x00ce3cd6c68fc137,0x004b60f431eccf99,0x00081efbe9e7e2b8,0x00a36f0ae7981133)},
-  {FIELD_LITERAL(0x0006918f5dfce6dc,0x00d4bf1c793c57fb,0x0069a3f649435364,0x00e89a50e5b0cd6e,0x00b9f6a237e973af,0x006d4ed8b104e41d,0x00498946a3924cd2,0x00c136ec5ac9d4f7)},
+  {FIELD_LITERAL(0x0062dd0fb31be374,0x00fcc96b84c8e727,0x003f64f1375e6ae3,0x0057d9b6dd1af004,0x00d6a167b1103c7b,0x00dd28f3180fb537,0x004ff27ad7167128,0x008934c33461f2ac)},
+  {FIELD_LITERAL(0x0065b472b7900043,0x00ba7efd2ff1064b,0x000b67d6c4c3020f,0x0012d28469f4e46d,0x0031c32939703ec7,0x00b49f0bce133066,0x00f7e10416181d47,0x005c90f51867eecc)},
   {FIELD_LITERAL(0x0051207abd179101,0x00fc2a5c20d9c5da,0x00fb9d5f2701b6df,0x002dd040fdea82b8,0x00f163b0738442ff,0x00d9736bd68855b8,0x00e0d8e93005e61c,0x00df5a40b3988570)},
-  {FIELD_LITERAL(0x00ee563d6f53acc9,0x00d465d2b5959acc,0x006575973bba26c8,0x00c9e4d84f81a1a3,0x00c3fbc4e8aa468a,0x0048149930eeaa11,0x008850a6f611000d,0x006709f6788337f9)},
-  {FIELD_LITERAL(0x00b373076597455f,0x00e83f1af53ac0f5,0x0041f63c01dc6840,0x0097dea19b0c6f4b,0x007f9d63b4c1572c,0x00e692d492d0f5f0,0x00cbcb392e83b4ad,0x0069c0f39ed9b1a8)},
+  {FIELD_LITERAL(0x0006918f5dfce6dc,0x00d4bf1c793c57fb,0x0069a3f649435364,0x00e89a50e5b0cd6e,0x00b9f6a237e973af,0x006d4ed8b104e41d,0x00498946a3924cd2,0x00c136ec5ac9d4f7)},
+  {FIELD_LITERAL(0x0011a9c290ac5336,0x002b9a2d4a6a6533,0x009a8a68c445d937,0x00361b27b07e5e5c,0x003c043b1755b974,0x00b7eb66cf1155ee,0x0077af5909eefff2,0x0098f609877cc806)},
   {FIELD_LITERAL(0x00ab13af436bf8f4,0x000bcf0a0dac8574,0x00d50c864f705045,0x00c40e611debc842,0x0085010489bd5caa,0x007c5050acec026f,0x00f67d943c8da6d1,0x00de1da0278074c6)},
-  {FIELD_LITERAL(0x0079efcffed8f836,0x00604423802b5504,0x0070a6e294aab7dd,0x0020f75be15e7521,0x0062827c19bd5414,0x006738e425c48700,0x00dd37618fde0ffa,0x00bb2d65c01e1c3b)},
-  {FIELD_LITERAL(0x00c903ee6d825540,0x00add6c4cf98473e,0x007636efed4227f1,0x00905124ae55e772,0x00e6b38fab12ed53,0x0045e132b863fe55,0x003974662edb366a,0x00b1787052be8208)},
+  {FIELD_LITERAL(0x00b373076597455f,0x00e83f1af53ac0f5,0x0041f63c01dc6840,0x0097dea19b0c6f4b,0x007f9d63b4c1572c,0x00e692d492d0f5f0,0x00cbcb392e83b4ad,0x0069c0f39ed9b1a8)},
+  {FIELD_LITERAL(0x00861030012707c9,0x009fbbdc7fd4aafb,0x008f591d6b554822,0x00df08a41ea18ade,0x009d7d83e642abea,0x0098c71bda3b78ff,0x0022c89e7021f005,0x0044d29a3fe1e3c4)},
   {FIELD_LITERAL(0x00e748cd7b5c52f2,0x00ea9df883f89cc3,0x0018970df156b6c7,0x00c5a46c2a33a847,0x00cbde395e32aa09,0x0072474ebb423140,0x00fb00053086a23d,0x001dafcfe22d4e1f)},
-  {FIELD_LITERAL(0x0059eb4ff288a383,0x00283876be3388ab,0x00bdd22974a2543b,0x0059eef0fe982d74,0x0097a5cf63dad778,0x004bc6002aebc99f,0x00c9a91d6118c690,0x0038364612a527ab)},
-  {FIELD_LITERAL(0x00006e34a35d9fbc,0x00eee4e48b2f019a,0x006b344743003a5f,0x00541d514f04a7e3,0x00e81f9ee7647455,0x005e2b916c438f81,0x00116f8137b7eff0,0x009bd3decc7039d1)},
+  {FIELD_LITERAL(0x00c903ee6d825540,0x00add6c4cf98473e,0x007636efed4227f1,0x00905124ae55e772,0x00e6b38fab12ed53,0x0045e132b863fe55,0x003974662edb366a,0x00b1787052be8208)},
+  {FIELD_LITERAL(0x00a614b00d775c7c,0x00d7c78941cc7754,0x00422dd68b5dabc4,0x00a6110f0167d28b,0x00685a309c252886,0x00b439ffd5143660,0x003656e29ee7396f,0x00c7c9b9ed5ad854)},
   {FIELD_LITERAL(0x0040f7e7c5b37bf2,0x0064e4dc81181bba,0x00a8767ae2a366b6,0x001496b4f90546f2,0x002a28493f860441,0x0021f59513049a3a,0x00852d369a8b7ee3,0x00dd2e7d8b7d30a9)},
-  {FIELD_LITERAL(0x00fa2dd90bcbeef2,0x00507d774710de2a,0x00b585ad10e7e373,0x0041f487e4b4f921,0x00191c9d8212f81d,0x001bc55cbdd8d474,0x0017954bdba8827b,0x0004d6d3a991ca44)},
-  {FIELD_LITERAL(0x00e38abece3c82ab,0x005a51f18a2c7a86,0x009dafa2e86d592e,0x00495a62eb688678,0x00b79df74c0eb212,0x0023e8cc78b75982,0x005998cb91075e13,0x00735aa9ba61bc76)},
+  {FIELD_LITERAL(0x00006e34a35d9fbc,0x00eee4e48b2f019a,0x006b344743003a5f,0x00541d514f04a7e3,0x00e81f9ee7647455,0x005e2b916c438f81,0x00116f8137b7eff0,0x009bd3decc7039d1)},
+  {FIELD_LITERAL(0x0005d226f434110d,0x00af8288b8ef21d5,0x004a7a52ef181c8c,0x00be0b781b4b06de,0x00e6e3627ded07e1,0x00e43aa342272b8b,0x00e86ab424577d84,0x00fb292c566e35bb)},
   {FIELD_LITERAL(0x00334f5303ea1222,0x00dfb3dbeb0a5d3e,0x002940d9592335c1,0x00706a7a63e8938a,0x005a533558bc4caf,0x00558e33192022a9,0x00970d9faf74c133,0x002979fcb63493ca)},
-  {FIELD_LITERAL(0x00260857d22419d7,0x005e0387d77651f0,0x008e0025ed2eb499,0x00c830b135804c2a,0x0037f43dbd3a77f6,0x008a4073d2f7379c,0x0072be0ce503ad58,0x00e6869d130c78be)},
-  {FIELD_LITERAL(0x00bfc5fa1e4ea21f,0x00c21d7b6bb892e6,0x00cf043f3acf0291,0x00c13f2f849b3c90,0x00d1a97ebef10891,0x0061e130a445e7fe,0x0019513fdedbf22b,0x001d60c813bff841)},
+  {FIELD_LITERAL(0x00e38abece3c82ab,0x005a51f18a2c7a86,0x009dafa2e86d592e,0x00495a62eb688678,0x00b79df74c0eb212,0x0023e8cc78b75982,0x005998cb91075e13,0x00735aa9ba61bc76)},
+  {FIELD_LITERAL(0x00d9f7a82ddbe628,0x00a1fc782889ae0f,0x0071ffda12d14b66,0x0037cf4eca7fb3d5,0x00c80bc242c58808,0x0075bf8c2d08c863,0x008d41f31afc52a7,0x00197962ecf38741)},
   {FIELD_LITERAL(0x006e9f475cccf2ee,0x00454b9cd506430c,0x00224a4fb79ee479,0x0062e3347ef0b5e2,0x0034fd2a3512232a,0x00b8b3cb0f457046,0x00eb20165daa38ec,0x00128eebc2d9c0f7)},
-  {FIELD_LITERAL(0x00e6a9e38030fdec,0x001c23597bc14288,0x0097156a46356df1,0x00642048f0daca6a,0x003970a6e7955fd4,0x00a511e335e3cfc6,0x0054865756c85e31,0x00465f1ab66a6190)},
-  {FIELD_LITERAL(0x003e4964fa8a8fc8,0x00f6a1cdbcf41689,0x00943cb18fe7fda7,0x00606dafbf34440a,0x005d37a86399c789,0x00e79a2a69417403,0x00fe34f7e68b8866,0x0011f448ed2df10e)},
+  {FIELD_LITERAL(0x00bfc5fa1e4ea21f,0x00c21d7b6bb892e6,0x00cf043f3acf0291,0x00c13f2f849b3c90,0x00d1a97ebef10891,0x0061e130a445e7fe,0x0019513fdedbf22b,0x001d60c813bff841)},
+  {FIELD_LITERAL(0x0019561c7fcf0213,0x00e3dca6843ebd77,0x0068ea95b9ca920e,0x009bdfb70f253595,0x00c68f59186aa02a,0x005aee1cca1c3039,0x00ab79a8a937a1ce,0x00b9a0e549959e6f)},
   {FIELD_LITERAL(0x00c79e0b6d97dfbd,0x00917c71fd2bc6e8,0x00db7529ccfb63d8,0x00be5be957f17866,0x00a9e11fdc2cdac1,0x007b91a8e1f44443,0x00a3065e4057d80f,0x004825f5b8d5f6d4)},
-  {FIELD_LITERAL(0x000e0a81033e033b,0x00aec986ee821eab,0x00d1a4a48379273c,0x00609b79a9e06304,0x00e9618b4fe8f307,0x006ffdfa50b50969,0x009530224887ac0c,0x0020e7b36f0cef97)},
-  {FIELD_LITERAL(0x00fd579ffb691713,0x00b76af4f81c412d,0x00f239de96110f82,0x00e965fb437f0306,0x00ca7e9436900921,0x00e487f1325fa24a,0x00633907de476380,0x00721c62ac5b8ea0)},
+  {FIELD_LITERAL(0x003e4964fa8a8fc8,0x00f6a1cdbcf41689,0x00943cb18fe7fda7,0x00606dafbf34440a,0x005d37a86399c789,0x00e79a2a69417403,0x00fe34f7e68b8866,0x0011f448ed2df10e)},
+  {FIELD_LITERAL(0x00f1f57efcc1fcc4,0x00513679117de154,0x002e5b5b7c86d8c3,0x009f6486561f9cfb,0x00169e74b0170cf7,0x00900205af4af696,0x006acfddb77853f3,0x00df184c90f31068)},
   {FIELD_LITERAL(0x00b37396c3320791,0x00fc7b67175c5783,0x00c36d2cd73ecc38,0x0080ebcc0b328fc5,0x0043a5b22b35d35d,0x00466c9f1713c9da,0x0026ad346dcaa8da,0x007c684e701183a6)},
-  {FIELD_LITERAL(0x003f2ab1abd14b06,0x00b129a8e8e37230,0x0048bc5b083d5c64,0x0002606c12933a98,0x00cf8051ceec1a73,0x00a755a8836c3ce6,0x002dabaa90ca4cb9,0x00b6e5525ddfc0f2)},
-  {FIELD_LITERAL(0x00c4a1fb48635413,0x00b5dd54423ad59f,0x009ff5d53fd24a88,0x003c98d267fc06a7,0x002db7cb20013641,0x00bd1d6716e191f2,0x006dbc8b29094241,0x0044bbf233dafa2c)},
+  {FIELD_LITERAL(0x00fd579ffb691713,0x00b76af4f81c412d,0x00f239de96110f82,0x00e965fb437f0306,0x00ca7e9436900921,0x00e487f1325fa24a,0x00633907de476380,0x00721c62ac5b8ea0)},
+  {FIELD_LITERAL(0x00c0d54e542eb4f9,0x004ed657171c8dcf,0x00b743a4f7c2a39b,0x00fd9f93ed6cc567,0x00307fae3113e58b,0x0058aa577c93c319,0x00d254556f35b346,0x00491aada2203f0d)},
   {FIELD_LITERAL(0x00dff3103786ff34,0x000144553b1f20c3,0x0095613baeb930e4,0x00098058275ea5d4,0x007cd1402b046756,0x0074d74e4d58aee3,0x005f93fc343ff69b,0x00873df17296b3b0)},
-  {FIELD_LITERAL(0x00aa7c72be0ace19,0x004095d22fc37e4d,0x00a7d85f9e3b7c61,0x00ff21d344c9553c,0x00d105d6268e8b86,0x000616d733758845,0x003ecb4ba7210610,0x006a75e7dddc03b7)},
-  {FIELD_LITERAL(0x007860d99db787cf,0x00fda8983018f4a8,0x008c8866bac4743c,0x00ef471f84c82a3f,0x00abea5976d3b8e7,0x00714882896cd015,0x00b49fae584ddac5,0x008e33a1a0b69c81)},
+  {FIELD_LITERAL(0x00c4a1fb48635413,0x00b5dd54423ad59f,0x009ff5d53fd24a88,0x003c98d267fc06a7,0x002db7cb20013641,0x00bd1d6716e191f2,0x006dbc8b29094241,0x0044bbf233dafa2c)},
+  {FIELD_LITERAL(0x0055838d41f531e6,0x00bf6a2dd03c81b2,0x005827a061c4839e,0x0000de2cbb36aac3,0x002efa29d9717478,0x00f9e928cc8a77ba,0x00c134b458def9ef,0x00958a182223fc48)},
   {FIELD_LITERAL(0x000a9ee23c06881f,0x002c727d3d871945,0x00f47d971512d24a,0x00671e816f9ef31a,0x00883af2cfaad673,0x00601f98583d6c9a,0x00b435f5adc79655,0x00ad87b71c04bff2)},
-  {FIELD_LITERAL(0x0084911d36175613,0x00dbaa24427629dd,0x009b6f30b1554fc7,0x0026da093cf7ea9e,0x00eac4cfb8218c7c,0x00c4bde074231490,0x0089e5b5afb62587,0x0067fcb73adfdbcc)},
-  {FIELD_LITERAL(0x00eebfd4e2312cc3,0x00474b2564e4fc8c,0x003303ef14b1da9b,0x003c93e0e66beb1d,0x0013619b0566925a,0x008817c24d901bf3,0x00b62bd8898d218b,0x0075a7716f1e88a2)},
+  {FIELD_LITERAL(0x007860d99db787cf,0x00fda8983018f4a8,0x008c8866bac4743c,0x00ef471f84c82a3f,0x00abea5976d3b8e7,0x00714882896cd015,0x00b49fae584ddac5,0x008e33a1a0b69c81)},
+  {FIELD_LITERAL(0x007b6ee2c9e8a9ec,0x002455dbbd89d622,0x006490cf4eaab038,0x00d925f6c3081561,0x00153b3047de7382,0x003b421f8bdceb6f,0x00761a4a5049da78,0x00980348c5202433)},
   {FIELD_LITERAL(0x007f8a43da97dd5c,0x00058539c800fc7b,0x0040f3cf5a28414a,0x00d68dd0d95283d6,0x004adce9da90146e,0x00befa41c7d4f908,0x007603bc2e3c3060,0x00bdf360ab3545db)},
-  {FIELD_LITERAL(0x00f6de725e1976f0,0x00d96f80a02fda8a,0x00b25412a0e629fa,0x00c540e7e78fdb62,0x004ad02fb7336d3a,0x004922ae1bea5a3a,0x0026147d42d4bfeb,0x00d379a5bc4b94bc)},
-  {FIELD_LITERAL(0x00c338b915d8fef0,0x00a893292045c39a,0x0028ab4f2eba6887,0x0060743cb519fd61,0x0006213964093ac0,0x007c0b7a43f6266d,0x008e3557c4fa5bda,0x002da976de7b8d9d)},
+  {FIELD_LITERAL(0x00eebfd4e2312cc3,0x00474b2564e4fc8c,0x003303ef14b1da9b,0x003c93e0e66beb1d,0x0013619b0566925a,0x008817c24d901bf3,0x00b62bd8898d218b,0x0075a7716f1e88a2)},
+  {FIELD_LITERAL(0x0009218da1e6890f,0x0026907f5fd02575,0x004dabed5f19d605,0x003abf181870249d,0x00b52fd048cc92c4,0x00b6dd51e415a5c5,0x00d9eb82bd2b4014,0x002c865a43b46b43)},
   {FIELD_LITERAL(0x0070047189452f4c,0x00f7ad12e1ce78d5,0x00af1ba51ec44a8b,0x005f39f63e667cd6,0x00058eac4648425e,0x00d7fdab42bea03b,0x0028576a5688de15,0x00af973209e77c10)},
-  {FIELD_LITERAL(0x00b78d6075749232,0x0001dc47a33b2cdc,0x0018c7b2e91b24f1,0x00b5bdc68f9876bd,0x0013f489ccba2b44,0x003b8846066128de,0x003d6252c8884dcf,0x00e3ae84b9908209)},
-  {FIELD_LITERAL(0x00aa2261022d883f,0x00ebcca4548010ac,0x002528512e28a437,0x0070ca7676b66082,0x0084bda170f7c6d3,0x00581b4747c9b8bb,0x005c96a01061c7e2,0x00fb7c4a362b5273)},
+  {FIELD_LITERAL(0x00c338b915d8fef0,0x00a893292045c39a,0x0028ab4f2eba6887,0x0060743cb519fd61,0x0006213964093ac0,0x007c0b7a43f6266d,0x008e3557c4fa5bda,0x002da976de7b8d9d)},
+  {FIELD_LITERAL(0x0048729f8a8b6dcd,0x00fe23b85cc4d323,0x00e7384d16e4db0e,0x004a423970678942,0x00ec0b763345d4ba,0x00c477b9f99ed721,0x00c29dad3777b230,0x001c517b466f7df6)},
   {FIELD_LITERAL(0x006366c380f7b574,0x001c7d1f09ff0438,0x003e20a7301f5b22,0x00d3efb1916d28f6,0x0049f4f81060ce83,0x00c69d91ea43ced1,0x002b6f3e5cd269ed,0x005b0fb22ce9ec65)},
-  {FIELD_LITERAL(0x003cffdf14aed2fd,0x009f0d77d7c5b2d9,0x004812ec41321d9f,0x008a1448bddf0916,0x008fef86030175df,0x00e3d703200a76c7,0x00d1babb470b2094,0x009f3a43b0e5828c)},
-  {FIELD_LITERAL(0x00a94700032a093f,0x0076e96c225216e7,0x00a63a4316e45f91,0x007d8bbb4645d3b2,0x00340a6ff22793eb,0x006f935d4572aeb7,0x00b1fb69f00afa28,0x009e8f3423161ed3)},
+  {FIELD_LITERAL(0x00aa2261022d883f,0x00ebcca4548010ac,0x002528512e28a437,0x0070ca7676b66082,0x0084bda170f7c6d3,0x00581b4747c9b8bb,0x005c96a01061c7e2,0x00fb7c4a362b5273)},
+  {FIELD_LITERAL(0x00c30020eb512d02,0x0060f288283a4d26,0x00b7ed13becde260,0x0075ebb74220f6e9,0x00701079fcfe8a1f,0x001c28fcdff58938,0x002e4544b8f4df6b,0x0060c5bc4f1a7d73)},
   {FIELD_LITERAL(0x00ae307cf069f701,0x005859f222dd618b,0x00212d6c46ec0b0d,0x00a0fe4642afb62d,0x00420d8e4a0a8903,0x00a80ff639bdf7b0,0x0019bee1490b5d8e,0x007439e4b9c27a86)},
-  {FIELD_LITERAL(0x00610b6394a312e8,0x005aaa19d96160f5,0x008190e286138c4a,0x006538796a5cd53b,0x00fe28804432a97c,0x007315e011f55112,0x000bd4157d5acb9d,0x00d1b95469350336)},
-  {FIELD_LITERAL(0x0060db815bc4786c,0x006fab25beedc434,0x00c610d06084797c,0x000c48f08537bec0,0x0031aba51c5b93da,0x007968fa6e01f347,0x0030070da52840c6,0x00c043c225a4837f)},
+  {FIELD_LITERAL(0x00a94700032a093f,0x0076e96c225216e7,0x00a63a4316e45f91,0x007d8bbb4645d3b2,0x00340a6ff22793eb,0x006f935d4572aeb7,0x00b1fb69f00afa28,0x009e8f3423161ed3)},
+  {FIELD_LITERAL(0x009ef49c6b5ced17,0x00a555e6269e9f0a,0x007e6f1d79ec73b5,0x009ac78695a32ac4,0x0001d77fbbcd5682,0x008cea1fee0aaeed,0x00f42bea82a53462,0x002e46ab96cafcc9)},
   {FIELD_LITERAL(0x0051cfcc5885377a,0x00dce566cb1803ca,0x00430c7643f2c7d4,0x00dce1a1337bdcc0,0x0010d5bd7283c128,0x003b1b547f9b46fe,0x000f245e37e770ab,0x007b72511f022b37)},
-  {FIELD_LITERAL(0x00e4302ff9b6116c,0x0092314b81d5f02a,0x000d31425f30702f,0x004946262e04213c,0x007ead9d19b6f9ed,0x001080a31ce8989f,0x001b632f36672a74,0x00a03933d9645a83)},
-  {FIELD_LITERAL(0x004a2902926f8d3f,0x00ad79b42637ab75,0x0088f60b90f2d4e8,0x0030f54ef0e398c4,0x00021dc9bf99681e,0x007ebf66fde74ee3,0x004ade654386e9a4,0x00e7485066be4c27)},
+  {FIELD_LITERAL(0x0060db815bc4786c,0x006fab25beedc434,0x00c610d06084797c,0x000c48f08537bec0,0x0031aba51c5b93da,0x007968fa6e01f347,0x0030070da52840c6,0x00c043c225a4837f)},
+  {FIELD_LITERAL(0x001bcfd00649ee93,0x006dceb47e2a0fd5,0x00f2cebda0cf8fd0,0x00b6b9d9d1fbdec3,0x00815262e6490611,0x00ef7f5ce3176760,0x00e49cd0c998d58b,0x005fc6cc269ba57c)},
   {FIELD_LITERAL(0x008940211aa0d633,0x00addae28136571d,0x00d68fdbba20d673,0x003bc6129bc9e21a,0x000346cf184ebe9a,0x0068774d741ebc7f,0x0019d5e9e6966557,0x0003cbd7f981b651)},
-  {FIELD_LITERAL(0x00bba0ed9c67c41f,0x00b30c8e225ba195,0x008bb5762a5cef18,0x00e0df31b06fb7cc,0x0018b912141991d5,0x00f6ed54e093eac2,0x0009e288264dbbb3,0x00feb663299b89ef)}
+  {FIELD_LITERAL(0x004a2902926f8d3f,0x00ad79b42637ab75,0x0088f60b90f2d4e8,0x0030f54ef0e398c4,0x00021dc9bf99681e,0x007ebf66fde74ee3,0x004ade654386e9a4,0x00e7485066be4c27)},
+  {FIELD_LITERAL(0x00445f1263983be0,0x004cf371dda45e6a,0x00744a89d5a310e7,0x001f20ce4f904833,0x00e746edebe66e29,0x000912ab1f6c153d,0x00f61d77d9b2444c,0x0001499cd6647610)}
 };
 const gf API_NS(precomputed_wnaf_as_fe)[96]
 VECTOR_ALIGNED = {
-  {FIELD_LITERAL(0x00cfc32590115acd,0x0079f0e2a5c7af1b,0x00dd94605b8d7332,0x0097dd6c75f5f3f3,0x00d9c59e36156de9,0x00edfbfd6cde47d7,0x0095b97c9f67c39a,0x007d7b90f587debc)},
-  {FIELD_LITERAL(0x00cfc32590115acd,0x0079f0e2a5c7af1b,0x00dd94605b8d7332,0x0017dd6c75f5f3f3,0x00d9c59e36156de8,0x00edfbfd6cde47d7,0x0095b97c9f67c39a,0x00fd7b90f587debc)},
-  {FIELD_LITERAL(0x001071dd4d8ae672,0x004f14ebe5f4f174,0x00e0987625c34c73,0x0092d00712c6f8c1,0x009ef424965e980b,0x00a8e0cf9369764b,0x000aa81907b4d207,0x00d5002c74d37924)},
-  {FIELD_LITERAL(0x00f3c4efe62b8b17,0x001e6acc1b6add7b,0x003367ef45836df5,0x000efc2d87a6ba53,0x00405a96933964ca,0x00572c2ae16357c6,0x00a9dc34ba6a7946,0x00151831e32ad161)},
-  {FIELD_LITERAL(0x00315f0372d1774a,0x007de9ed2960e79d,0x008b3d7c4c198add,0x00a5e6a45fa57892,0x00f32201aa80115a,0x007fb9386a433a1a,0x00abf6960b291ee6,0x002d8069294ebc2a)},
-  {FIELD_LITERAL(0x00fa5e878ae22827,0x00d33c7bb3963bd0,0x0053401a101efac6,0x0063df0bcbce59a5,0x007bca269c8b584b,0x00611a8a9978842c,0x00bb96e8da12b8a8,0x00e17844d01d394d)},
-  {FIELD_LITERAL(0x00c107c50e9b4d0d,0x00f6b65a5fada2f2,0x000bb67e79353fae,0x0018853f610ed92d,0x008c51f4d36d6915,0x00e3e9c096dd1c12,0x009d6b9ea6cde415,0x00304864dd66f4c6)},
-  {FIELD_LITERAL(0x00f3123b214085fb,0x00d005bafffb8f53,0x00d1606987dfe6ea,0x00e825edf73b018d,0x0082aa733829a933,0x00c857d8d7830d76,0x00ebdb8d2cbbe7e6,0x0063de0e9930722e)},
-  {FIELD_LITERAL(0x004ffebce35619ab,0x00d281a1543365c5,0x00ad17eeb3d098b8,0x008653b06bb7806d,0x0040026e64a28b62,0x00d9e06d52ea19df,0x008e7c684856876a,0x003ebbc191443f3b)},
-  {FIELD_LITERAL(0x00c0a062813b8884,0x0054d18cc36e636b,0x00e4493fcadba51a,0x005cda5b6577c9cf,0x00cc165615c315cf,0x001bbd5e155f17bb,0x004dee92a4f18e47,0x003e95412929bfb8)},
-  {FIELD_LITERAL(0x0015326f3e1f5fb6,0x0076886ca4eb6041,0x00fb34645ee36c23,0x006042a4cb8f7bb2,0x00b43e736403dd2f,0x00a8986566e7c60c,0x0010ea48904bf6d1,0x008b5ae8c5ddafbe)},
-  {FIELD_LITERAL(0x003a9f4a12faee9a,0x00e6ba523a29af6b,0x001dde79a8ef06ef,0x0033ed4361647314,0x00b0556ae76eb1c9,0x00e8b892762bd092,0x004709c83705e374,0x0077382d86f79b47)},
-  {FIELD_LITERAL(0x006638c5cee4113d,0x005c100c7276ed52,0x00d10562e281768d,0x0008e851e1eb2ed9,0x00d7cc086a7af373,0x00993ed528eb7942,0x0051677625b7df14,0x0029fbbcf6aaa3f7)},
-  {FIELD_LITERAL(0x001081503e396419,0x007a2c7aa8870415,0x00d372a4baf3490a,0x00b18821a1e18013,0x00b83fa876c54211,0x00e4bcf47a2ae1e9,0x0069a384ba9bf3c3,0x00b784d44ee9d468)},
-  {FIELD_LITERAL(0x00b4e3ad7c2ea1be,0x009962715cf7008a,0x00fbc6fdcc089d5e,0x001e29847c349313,0x00c1145569b3874d,0x0094f50069a1499b,0x004cec2bb8f423c8,0x0077eb0034c34627)},
-  {FIELD_LITERAL(0x008f00d279b21a44,0x00a5c81149c8116a,0x00cc8be3da721e9f,0x001935a34e6770b9,0x00e315426d5db99d,0x00cf6a842aff01bf,0x00e3cc9d5016ed3a,0x00ae78776098742d)},
-  {FIELD_LITERAL(0x0068db473197248f,0x0089874a12ff90c2,0x00420b4763f5428c,0x00d668b71fb38392,0x0022279b6d3c3687,0x003a5801405cf566,0x00127b8ea4b4fd44,0x00ce6a975208fb79)},
-  {FIELD_LITERAL(0x00797ca039d44238,0x0063cae935b6ef5e,0x006a938e072ff87c,0x006a3870309cdca0,0x0003800945fa3ddc,0x0032274c0728b5ad,0x0053a51e9217da91,0x00162b41712b79db)},
-  {FIELD_LITERAL(0x000911f06768bdc6,0x00bd27650f82c5b0,0x007b948017bcb94a,0x0095de039572c65e,0x0053743dabe00d25,0x0092b1d5888cd8cd,0x0065c6496b33c0d0,0x007a3f55d5bfb370)},
-  {FIELD_LITERAL(0x003f31eebfa20d27,0x00b1c0c84d6c2849,0x00dbefe8d1e53924,0x00472400b407ebc2,0x00c584bf62a91498,0x00c1f095f2010650,0x007e3b1b2c9ba41e,0x003189f894ed89dc)},
-  {FIELD_LITERAL(0x004d9eefe5de7ab7,0x003e35169bdbd884,0x0079625f58822d97,0x0043f4f607137c15,0x0029efd80717d455,0x0055b37a66623198,0x00153cecd460c01e,0x000464f30e396a2d)},
-  {FIELD_LITERAL(0x0057b28375dc4b6e,0x00771e6557974d80,0x00fa6792bc187316,0x000d7fed0f9f92d7,0x00e821281efdb64b,0x00a12bf7b4dc5064,0x00464f56bfa9bb8d,0x00526fa933114e0b)},
-  {FIELD_LITERAL(0x00bcf86d6aaed0f2,0x00b95ff679e8a71f,0x00c11d7bd57f8c87,0x00cb3362ed671b05,0x0068bb14b2ce4c10,0x00505313699af32f,0x005376e4cec89e51,0x00179b292d918f75)},
-  {FIELD_LITERAL(0x00246e4ca8018aa1,0x005e55abb4eaca63,0x0050b6ce5fe6aa8b,0x008979edb01ee510,0x002e152c38461080,0x00550a03a7f073ea,0x0018d841eb811e13,0x00c39e3e1ea88479)},
-  {FIELD_LITERAL(0x007f1264364f8cc7,0x000315388ba2d9ad,0x007562aa0a0d3396,0x0069318d20cfe53a,0x000acdcd1868b277,0x008e8d738518c6b8,0x006faf89fda8f887,0x00347e30277c4e4d)},
-  {FIELD_LITERAL(0x0062c03567cddf30,0x0032ee53437ac23b,0x00e8a6fbf62d80e2,0x002de89967f7d7fd,0x0005fedae4d7c736,0x0022d685f264ae39,0x0028936d3fba7df5,0x00acb4383b936fcc)},
-  {FIELD_LITERAL(0x00afee55215c8c25,0x00c57a8713769fcb,0x000df59aca05928e,0x00aead2ce1a57830,0x00d453e3719735cd,0x004f1cdc24b3ec7e,0x000e2a69482a51da,0x00151ba7f6834b1f)},
-  {FIELD_LITERAL(0x003eaec329954173,0x00fec61feee76bb2,0x009b544347f7f444,0x004c4f7dfdb8cebd,0x0039d610da25dbfb,0x000f513ccef26480,0x00af4ddd8b8d2732,0x00093756dd2be04b)},
-  {FIELD_LITERAL(0x006df537f064f2de,0x0007f0808cbfedb9,0x00792c87b64aa829,0x00fd42b4ce848ad1,0x004d9b9c66c5bd43,0x00df8fbdd58c4ed6,0x00cbe5355fc7f34c,0x00abe6eb22995e4d)},
-  {FIELD_LITERAL(0x00ef8a330d9484e0,0x0044944dece8fbcc,0x0016b6e52d9d2586,0x00610b0b72d2c7b3,0x00766d88f8990f61,0x00ea7bc69494eefe,0x0050c07989360110,0x00db9fc3bfd96ee7)},
-  {FIELD_LITERAL(0x0069991db096c6b8,0x0008ebceed962ba0,0x00ef0053e2f37ae3,0x009917f3c8c9cb68,0x000e0b52fef39f4e,0x00ea378bf7b8f008,0x009ae2a16388995b,0x007ec77e628ee921)},
-  {FIELD_LITERAL(0x0062284cece6ad83,0x00e18536b7278c56,0x0005ab4b910698c5,0x009910472a4fd019,0x008ab4e2c6d75150,0x00fbd9d538d59094,0x0086482b65914fd9,0x00ced958acabfefd)},
-  {FIELD_LITERAL(0x00c6cb4ee3a8dac4,0x0010cf7120de0b91,0x001ab166385e9e67,0x007f2a8eca89b19c,0x008ae3d846b943da,0x0022c7631b161ed6,0x005e5d402e327b23,0x00d0518c1aeb64cd)},
-  {FIELD_LITERAL(0x000d45c95be55ebb,0x005f3dd26b911e70,0x00755171065eb066,0x00110b2864e644c9,0x00718a31c2d84e02,0x0059a255fc4d65d8,0x0026337c97b14eba,0x0061e127f33d128b)},
-  {FIELD_LITERAL(0x006ee9a82004b322,0x003eff4833aac2f9,0x00bb62f8a13b9833,0x008f9deff439b18f,0x00bc30790842de17,0x000bfe23b4868215,0x00addb504d09d19a,0x002e121c04a5bd41)},
-  {FIELD_LITERAL(0x004126ac2e668677,0x0046c12e8a5dbed7,0x0078e3a69c049c9a,0x0035d20dffeb5878,0x000a263e2f4cbcdc,0x00090a6bd7e724f5,0x00b33f6e0b6366f9,0x00175e7759f40060)},
-  {FIELD_LITERAL(0x0083b4b835838c18,0x00ac69ddefc68cb4,0x00749b220f1ba281,0x004052a50d7a193d,0x007138ee3a4e5e56,0x003099ccfedc8067,0x006e811c0e9aaed9,0x00bead0cc8101227)},
-  {FIELD_LITERAL(0x00cd3889dfcd0517,0x001bf78dcd1f43de,0x000898cbb491727a,0x00440c964893d55d,0x0075e0b9391ea8f2,0x00ec9732687fc960,0x008ca65c62f86bcf,0x00fc9b9aed6debcb)},
-  {FIELD_LITERAL(0x00f8381236cfa255,0x00f5999b0d8c8fe3,0x000918786a1dff4e,0x00a2fa46132db8c1,0x00eb0a0e8379a878,0x003802d2e990566a,0x00b6c65d27147f1f,0x00ddbb45f6bd3e66)},
-  {FIELD_LITERAL(0x000f68a71ee1c67a,0x00e96102429b052c,0x0017776482925329,0x00ca322a71577df6,0x004325b8a79280b5,0x00c322234d786f77,0x00e9258fe7816ab4,0x006aa915d16d5532)},
-  {FIELD_LITERAL(0x00cde18980fd9d30,0x00d1a82889350971,0x0040d36b7eb0fbc8,0x003cc6e695329dd0,0x00e24b3318e1d88e,0x00e212a22459111d,0x00879f754eaab372,0x00f9801f5489c9a4)},
-  {FIELD_LITERAL(0x007354e942e00768,0x004c7668d3208ac0,0x0015712e1b92023f,0x00b018106b3a760b,0x00d4751647fa130b,0x00da3f7276d78b5a,0x00dc6c71672bb3b3,0x0008a6ecb3540963)},
-  {FIELD_LITERAL(0x00e13a624c26a6f1,0x00e161c0e3c0e7d2,0x00ba563c13d354eb,0x00f7e67a8d51498c,0x0088c48bf9742e97,0x00edaca155c6abcb,0x00bb24561c4448b5,0x00d045b2c38b42f1)},
-  {FIELD_LITERAL(0x0093d57b9871b4c4,0x0085e6b5532e7970,0x0012fdda50bdb89e,0x0025f590d6c39b47,0x00ef9d53a39585e6,0x00cf0a88a575110b,0x00fd53552894850f,0x00bef47029c5a860)},
-  {FIELD_LITERAL(0x00bd40f701996dd3,0x00cce747044b6173,0x0028a6b9ffb55eb3,0x0009fea794bd40e3,0x0038b30e26ed0198,0x005434c968b4cf52,0x00814878df362d47,0x0060ab54842b207a)},
-  {FIELD_LITERAL(0x00bd19d97479e8ae,0x00f722fb96aff3e9,0x004ae4a83cc75c02,0x0033bb6827a30094,0x00d0ec294a83cb5a,0x007c9ad150cfeefa,0x0033cbbd6b336c57,0x009f0b2fd7ef1d8f)},
-  {FIELD_LITERAL(0x00246036b708c7d9,0x000574c8b9127116,0x00ecd349a550414d,0x003c900c0186da47,0x007c82512cac2d00,0x001399e41f99830b,0x00a414712d16fdfb,0x0028822961a9b698)},
-  {FIELD_LITERAL(0x00576abc9c32ae74,0x0052e8eedb433484,0x009a0b95b52551ff,0x00e4e5a4d5691aff,0x00bc01db07dccd79,0x00996692751e0d3c,0x003acf0cd9be9606,0x003f06d2f83095a8)},
-  {FIELD_LITERAL(0x0028c4051a1ff7bb,0x0040ba689904a0ad,0x009e4b0a5acec321,0x00bc6d2b3c46aaeb,0x00f2caae4ef88adb,0x00ff6677bf11a28e,0x0092191cbfbb7484,0x00dae55afb78a291)},
-  {FIELD_LITERAL(0x00c95aa397ea26bc,0x007372e21066c24c,0x00d1f1e17008ce70,0x00277c5b46d24ff5,0x00d0a187e51cc6f8,0x00e58d524dca3f92,0x000d1a618c916355,0x00e5b4a71cfce6eb)},
-  {FIELD_LITERAL(0x00c40cbcbd853cbd,0x00523f5879bd473a,0x00fc476ce8a57ceb,0x009e5cb521a8fc43,0x0015c157448e29cc,0x0041f2065e0e673d,0x00b9227183e9ca04,0x000eadc022da2a1a)},
-  {FIELD_LITERAL(0x00d6313aad8c08f2,0x008fbb11d8a39cbf,0x00bf09c856cfea1d,0x00cc7448724a5516,0x00eb6e4d59ecdeb7,0x005eda293019421c,0x00a0853a9e457996,0x00e2a1515c045530)},
-  {FIELD_LITERAL(0x009cc09c03622bf9,0x0018ec007f1fb5bc,0x009f39168f0d29de,0x005a83280f20e76e,0x000dbf95aaf9af43,0x004f9bd6f102397b,0x00e154febb2e86e9,0x0032ea079c3d6c54)},
-  {FIELD_LITERAL(0x00fab169ca1c41ce,0x00f1bc0ce1d78d41,0x002fa4e361cc67be,0x009053af427e0267,0x0032387ad15144f5,0x00b00ae64f9e66e4,0x006f6617ef82b37a,0x00d8c1db3c95b59e)},
-  {FIELD_LITERAL(0x0035175500c7799c,0x00a167c5ca225e38,0x00854efcf271c80b,0x001b76bf0a2fcd01,0x0095c90610cf4ccd,0x0064190fc6a738a8,0x0079dce31456ebff,0x00742f0847dc1855)},
-  {FIELD_LITERAL(0x00f8f4bbbe10d3b9,0x00105a4fd7fe5ef6,0x0040f473c119b520,0x0075981f4cbad167,0x00e6e94e0d05858a,0x00287e587009323c,0x00797d31a81a36e6,0x0033eef622def25c)},
-  {FIELD_LITERAL(0x003077e1410a5ba5,0x00b14158718390d3,0x006f256df630d95f,0x0021d4d1b388a47b,0x008e29fce3c3ea50,0x002616d810e8828f,0x0076b1173dc76902,0x001c4c4bfe1be552)},
-  {FIELD_LITERAL(0x00a2657cac024d24,0x00aa33dfb739670f,0x00093b53769a8de7,0x00adafcb28c0514d,0x00bca8890425c381,0x008f15acedcdc343,0x0085efa2bb2f9604,0x0092437292387955)},
-  {FIELD_LITERAL(0x00dfb010d979be8f,0x007e6d963a211f07,0x00404b8ec1368699,0x00d9cc6590cb2087,0x00e0d919b389e23c,0x001001c50cec349f,0x001e848fec709fe4,0x000e91e3326121a1)},
-  {FIELD_LITERAL(0x00e8300e632c6b13,0x00010847ef6dda78,0x0019b7c68f200ab7,0x00220c952978bd9b,0x0019e887adc0331c,0x006c5993f36c4db5,0x0002c98eeb248079,0x0089ad282231d922)},
-  {FIELD_LITERAL(0x0059811830606614,0x00a8ec4d8a0d0097,0x000e2ac957beaec2,0x007dc4a64fdb8ed1,0x0063b9462f2c7312,0x00324ea6a55d282b,0x007c8a4cbdc26507,0x00f54f4ae9268708)},
-  {FIELD_LITERAL(0x0026d312845ed7bc,0x0051563888e17918,0x00b99c696ccab084,0x0059d7244957f3b8,0x00c5f4faf8c8d6ab,0x00bdeeec54ba3f26,0x001aba0f7c9d5485,0x00d731f784b29269)},
-  {FIELD_LITERAL(0x00bd7234c3aef4f0,0x00a7a9f815db44b1,0x00c8c940e9fc9785,0x003b81a973b01c38,0x00c32ffd7d7b79f9,0x00bc5b783c46e6c6,0x00b003fb1ef6a5f9,0x005b36765c2b46e7)},
-  {FIELD_LITERAL(0x0030b09f9659a719,0x00ac35ad7a6bc959,0x009b466b281c1ee8,0x0034b96465f80acb,0x00304970c66162b7,0x000f2347253e3918,0x000d54980ac74c5a,0x00aaabb0e875468a)},
-  {FIELD_LITERAL(0x00578872f1bd6085,0x00b3fd4fa6efa597,0x00e99ac49f625c00,0x002aef842e5ed2d8,0x004b8f706588e353,0x00449c499dfcc096,0x008d0cdddbf18dea,0x00e6bba4a6396ddd)},
-  {FIELD_LITERAL(0x0066485d97a2ac73,0x001d0e768483ffe7,0x00c5253731b7251c,0x00f76d892a3af3f3,0x00e8d035f85298e7,0x0034e58d0abf961a,0x00b11bd0eccaba4c,0x0087a079aec9d0e9)},
-  {FIELD_LITERAL(0x00d38488bd2e2026,0x00d35414e79dc3fe,0x00faa0a1c1fbbbb9,0x0093df0c4b10ab45,0x0039ffebe1394c9f,0x00cab0bc80e5cd5c,0x00453b9db5cadf06,0x003b7c08cb56f96e)},
-  {FIELD_LITERAL(0x00b63453c7af61ee,0x00eadcbafa2bd320,0x0086b04f4a7bf0e3,0x00b69bc8cbbfba5a,0x00ce4926bb1b064e,0x004df8ce753e0a27,0x00ff37bf2580a3a2,0x00ad90c8c5a377eb)},
-  {FIELD_LITERAL(0x00ac58c82bdd6e72,0x0008035e278a79da,0x003c9fcc92524fb3,0x000c71c26ea75e47,0x009631c4be717b38,0x00a2e968135e9152,0x00074295ca131ec2,0x00877a203d4a5015)},
-  {FIELD_LITERAL(0x00a49896f002be26,0x00ad6b0d720ae906,0x005786d8dbed0346,0x00f6749d6592e372,0x000542c37faf79a4,0x003281a4f5c7863a,0x00eacdc7def0cbdc,0x00ca8353efe160bd)},
-  {FIELD_LITERAL(0x003c9e851d9f8893,0x004df23c1696dd28,0x005e587fddb98f95,0x00359afa5adbfdbb,0x00ddb949d26e687c,0x00ebc6efd285564c,0x001750eec619bdd3,0x0037772e4ad0d4fa)},
-  {FIELD_LITERAL(0x0076e84babbbb048,0x000a6db83681bbe4,0x0059dff597eaead2,0x00f65bdd79fe2dab,0x00e3fc9faa642c8a,0x008a9cc9dfc634c9,0x00428a4b728b1cd4,0x00e80aea53cb6617)},
-  {FIELD_LITERAL(0x002ab17fdf7d2bd3,0x005aa55f23183393,0x009b88469f8c0eb9,0x007d101b314bca6b,0x0056dd4345fd97b9,0x00880e62e548ae7d,0x003d44d8c87b91a6,0x00fb2811386e22cc)},
-  {FIELD_LITERAL(0x00eacd58001be3a5,0x0014e1231ca72940,0x0022453384987584,0x0075848f0c37be5c,0x000e6dc40d82c0b2,0x00f4d8ec1270878c,0x00550981d6fb86fd,0x00bb66b58f4c6892)},
-  {FIELD_LITERAL(0x00bba772e57e297f,0x004f56f68df71b07,0x00ded9facaf23a81,0x00d78e832d78eedc,0x0004f7c3eff02685,0x00ba5fa931f9c020,0x005a29fb4b2295be,0x00e2543f745b1dc9)},
-  {FIELD_LITERAL(0x00712177652580f9,0x00e9ee16e21d1eca,0x0002465ba75b8e46,0x00a9cb7b1fc8ef2e,0x00ce337e6da1cf8e,0x009d3684c507fffa,0x00058cc115d71214,0x0017dba81e144377)},
-  {FIELD_LITERAL(0x003b778e67285805,0x00dbb06704ba87b5,0x00ba6ee1ea5ea2fe,0x00e2cdc2c8b3f699,0x006983c6eae69a9c,0x00c6c8c542d0c398,0x00f2d3a9ebcedbdc,0x00be30ddeabbd31c)},
-  {FIELD_LITERAL(0x0095f20a016490a6,0x005f2b00b9fbf26d,0x00b583124906cdaf,0x002e2077aa473ca8,0x0018c5b9f7902fa6,0x00b704f5229201a6,0x00e1fc5d70e4b1c2,0x00578e366ccf7289)},
-  {FIELD_LITERAL(0x00932127be1d579d,0x00e6729f50f54904,0x00e70f6247f618af,0x00b1953989fe9d9c,0x0015032e9df69633,0x00d3687b35cb6e82,0x00ab0fff86869218,0x0026054a3a68ddfb)},
-  {FIELD_LITERAL(0x00cf244d2e899137,0x00a793f52ec7aaa1,0x002e5cb0616e3883,0x009cbf752f176feb,0x0029edce4fa090a3,0x00f6540a960a0275,0x00513985eef0e3bc,0x00ce2e586f6c7228)},
-  {FIELD_LITERAL(0x00b42f011dbc757c,0x004a8e19d4f07c42,0x00a6d7828318b7ff,0x0004c9ce49ba3c0f,0x005fe71688087b6a,0x006e1d8f9a3d84ed,0x0089693e7e8e9a1f,0x0073bf4183ba45c5)},
-  {FIELD_LITERAL(0x0029e8ce35530d30,0x00d20f389f61fe3a,0x00cf9e8ddf74e1d4,0x004bec01b04d4979,0x007d92c9f6fd5ddd,0x00c072fa91981808,0x009afda4fe8a1676,0x00c96522ee879a14)},
-  {FIELD_LITERAL(0x005f0cd9cd83497b,0x00e382f098d97f00,0x0073e37e004eed2e,0x000707fe98b12237,0x0016d92a2b73d561,0x00a42926ab390165,0x00b394db4b1cc8fc,0x002fa14a3f6efa33)},
-  {FIELD_LITERAL(0x0055076a513d05ee,0x00f076d43cec14ad,0x00a4e386b252faf4,0x00c0713b79b313eb,0x00507efa72f46f19,0x00141bc1e7c66844,0x005629ef060c19ea,0x0085327113d1772c)},
-  {FIELD_LITERAL(0x00ed490108514e35,0x006bed897e6b4958,0x0000f2cae0dc546c,0x008175eb3e5008e4,0x0093e3fe8f3aed42,0x00e9dbc15fd54d1a,0x00844979a4cfc0c1,0x00ea3194d64ea60b)},
-  {FIELD_LITERAL(0x00b64d054ec7ed5c,0x007b924cd329fbce,0x00fe8805a8737293,0x00fb82f1d52b43ae,0x004ea745c72e1a76,0x0095ba2552861c0c,0x00f66846c3547784,0x003b815bd05dc23c)},
-  {FIELD_LITERAL(0x00669e32fd197ef7,0x001dfca2c5e2f7c9,0x00a2ae0964a1e5e2,0x00b4334b15c91232,0x0096419585110d96,0x009c0b2262172a58,0x009d7c87cf6d35ca,0x008a5ce50d3cabf6)},
-  {FIELD_LITERAL(0x00888b9c1cf73530,0x00375346c6afecd2,0x00142240b35b74d3,0x00d952835f86a5f5,0x000665c2658eaf9a,0x00f29f43062b2033,0x00a19a58c5bc85f9,0x00e62ac95724a937)},
-  {FIELD_LITERAL(0x003bedc9ae9d1730,0x00fedd7c04cbc775,0x00c19abc4540c61d,0x00115294c57fb687,0x00663fceb174cd8f,0x001671f572b885b0,0x002d14694ed85978,0x00127282078a8e44)},
-  {FIELD_LITERAL(0x00e6d2822aa72eca,0x00d832957cdc0058,0x00dc60e5bed23e18,0x00b94b4c418b03a3,0x00df3b85d410a430,0x0055e81b70bc79d4,0x00081d9369cbd1a0,0x00f7fee3acf0c656)},
-  {FIELD_LITERAL(0x003baba41b5abffb,0x00661ee09fca8193,0x00e0c6c92e6aea59,0x00886c207bcbe591,0x00aef9e7798e8004,0x00164f599f4d707a,0x00bb1597a76d21f2,0x00fda82d5e025626)},
-  {FIELD_LITERAL(0x00552b53a9640f0e,0x005985236f4d88bf,0x00b7aaec965a8ae5,0x00cedada7b5ccf95,0x007b1ea2088f1902,0x0028445e38b4a7fa,0x0057f10ddc50efed,0x007637a3147bc5cb)},
-  {FIELD_LITERAL(0x008174fe4db53757,0x00930c4f4a35ecc8,0x000e9f82c1c95a8f,0x00c6480547d66e5e,0x00dce888f9a7bf39,0x006671a5022cb906,0x004823c19b5337a0,0x00455338b7fec529)},
-  {FIELD_LITERAL(0x005ac123fdc45964,0x00395057c2221d17,0x003c09c74cf84eb1,0x00b5ca859bbebf9d,0x001b26b274a7d235,0x00e8c63508e96a48,0x00edbce4d51d721e,0x00c49436797d6f83)},
-  {FIELD_LITERAL(0x0071595be88a7f40,0x00a05e6ac1c0fc87,0x00a01bf6538b29eb,0x00badcd80b881fb8,0x005bfe7af8049f8b,0x0084918e6ae35537,0x00ed4bd54759316e,0x007f135988d6b548)},
-  {FIELD_LITERAL(0x0075656c41e06629,0x0086059d83396637,0x004f304ecb457b37,0x00e3b4887db6be65,0x0020b54c263bb0be,0x0060a69193e561c3,0x00e6863f20dc8ce9,0x00afe16ac56e6478)}
+  {FIELD_LITERAL(0x00303cda6feea532,0x00860f1d5a3850e4,0x00226b9fa4728ccd,0x00e822938a0a0c0c,0x00263a61c9ea9216,0x001204029321b828,0x006a468360983c65,0x0002846f0a782143)},
+  {FIELD_LITERAL(0x00303cda6feea532,0x00860f1d5a3850e4,0x00226b9fa4728ccd,0x006822938a0a0c0c,0x00263a61c9ea9215,0x001204029321b828,0x006a468360983c65,0x0082846f0a782143)},
+  {FIELD_LITERAL(0x00ef8e22b275198d,0x00b0eb141a0b0e8b,0x001f6789da3cb38c,0x006d2ff8ed39073e,0x00610bdb69a167f3,0x00571f306c9689b4,0x00f557e6f84b2df8,0x002affd38b2c86db)},
+  {FIELD_LITERAL(0x00cea0fc8d2e88b5,0x00821612d69f1862,0x0074c283b3e67522,0x005a195ba05a876d,0x000cddfe557feea4,0x008046c795bcc5e5,0x00540969f4d6e119,0x00d27f96d6b143d5)},
+  {FIELD_LITERAL(0x000c3b1019d474e8,0x00e19533e4952284,0x00cc9810ba7c920a,0x00f103d2785945ac,0x00bfa5696cc69b34,0x00a8d3d51e9ca839,0x005623cb459586b9,0x00eae7ce1cd52e9e)},
+  {FIELD_LITERAL(0x0005a178751dd7d8,0x002cc3844c69c42f,0x00acbfe5efe10539,0x009c20f43431a65a,0x008435d96374a7b3,0x009ee57566877bd3,0x0044691725ed4757,0x001e87bb2fe2c6b2)},
+  {FIELD_LITERAL(0x000cedc4debf7a04,0x002ffa45000470ac,0x002e9f9678201915,0x0017da1208c4fe72,0x007d558cc7d656cb,0x0037a827287cf289,0x00142472d3441819,0x009c21f166cf8dd1)},
+  {FIELD_LITERAL(0x003ef83af164b2f2,0x000949a5a0525d0d,0x00f4498186cac051,0x00e77ac09ef126d2,0x0073ae0b2c9296e9,0x001c163f6922e3ed,0x0062946159321bea,0x00cfb79b22990b39)},
+  {FIELD_LITERAL(0x00b001431ca9e654,0x002d7e5eabcc9a3a,0x0052e8114c2f6747,0x0079ac4f94487f92,0x00bffd919b5d749c,0x00261f92ad15e620,0x00718397b7a97895,0x00c1443e6ebbc0c4)},
+  {FIELD_LITERAL(0x00eacd90c1e0a049,0x008977935b149fbe,0x0004cb9ba11c93dc,0x009fbd5b3470844d,0x004bc18c9bfc22cf,0x0057679a991839f3,0x00ef15b76fb4092e,0x0074a5173a225041)},
+  {FIELD_LITERAL(0x003f5f9d7ec4777b,0x00ab2e733c919c94,0x001bb6c035245ae5,0x00a325a49a883630,0x0033e9a9ea3cea2f,0x00e442a1eaa0e844,0x00b2116d5b0e71b8,0x00c16abed6d64047)},
+  {FIELD_LITERAL(0x00c560b5ed051165,0x001945adc5d65094,0x00e221865710f910,0x00cc12bc9e9b8ceb,0x004faa9518914e35,0x0017476d89d42f6d,0x00b8f637c8fa1c8b,0x0088c7d2790864b8)},
+  {FIELD_LITERAL(0x00ef7eafc1c69be6,0x0085d3855778fbea,0x002c8d5b450cb6f5,0x004e77de5e1e7fec,0x0047c057893abded,0x001b430b85d51e16,0x00965c7b45640c3c,0x00487b2bb1162b97)},
+  {FIELD_LITERAL(0x0099c73a311beec2,0x00a3eff38d8912ad,0x002efa9d1d7e8972,0x00f717ae1e14d126,0x002833f795850c8b,0x0066c12ad71486bd,0x00ae9889da4820eb,0x00d6044309555c08)},
+  {FIELD_LITERAL(0x004b1c5283d15e41,0x00669d8ea308ff75,0x0004390233f762a1,0x00e1d67b83cb6cec,0x003eebaa964c78b1,0x006b0aff965eb664,0x00b313d4470bdc37,0x008814ffcb3cb9d8)},
+  {FIELD_LITERAL(0x009724b8ce68db70,0x007678b5ed006f3d,0x00bdf4b89c0abd73,0x00299748e04c7c6d,0x00ddd86492c3c977,0x00c5a7febfa30a99,0x00ed84715b4b02bb,0x00319568adf70486)},
+  {FIELD_LITERAL(0x0070ff2d864de5bb,0x005a37eeb637ee95,0x0033741c258de160,0x00e6ca5cb1988f46,0x001ceabd92a24661,0x0030957bd500fe40,0x001c3362afe912c5,0x005187889f678bd2)},
+  {FIELD_LITERAL(0x0086835fc62bbdc7,0x009c3516ca4910a1,0x00956c71f8d00783,0x0095c78fcf63235f,0x00fc7ff6ba05c222,0x00cdd8b3f8d74a52,0x00ac5ae16de8256e,0x00e9d4be8ed48624)},
+  {FIELD_LITERAL(0x00c0ce11405df2d8,0x004e3f37b293d7b6,0x002410172e1ac6db,0x00b8dbff4bf8143d,0x003a7b409d56eb66,0x003e0f6a0dfef9af,0x0081c4e4d3645be1,0x00ce76076b127623)},
+  {FIELD_LITERAL(0x00f6ee0f98974239,0x0042d89af07d3a4f,0x00846b7fe84346b5,0x006a21fc6a8d39a1,0x00ac8bc2541ff2d9,0x006d4e2a77732732,0x009a39b694cc3f2f,0x0085c0aa2a404c8f)},
+  {FIELD_LITERAL(0x00b261101a218548,0x00c1cae96424277b,0x00869da0a77dd268,0x00bc0b09f8ec83ea,0x00d61027f8e82ba9,0x00aa4c85999dce67,0x00eac3132b9f3fe1,0x00fb9b0cf1c695d2)},
+  {FIELD_LITERAL(0x0043079295512f0d,0x0046a009861758e0,0x003ee2842a807378,0x0034cc9d1298e4fa,0x009744eb4d31b3ee,0x00afacec96650cd0,0x00ac891b313761ae,0x00e864d6d26e708a)},
+  {FIELD_LITERAL(0x00a84d7c8a23b491,0x0088e19aa868b27f,0x0005986d43e78ce9,0x00f28012f0606d28,0x0017ded7e10249b3,0x005ed4084b23af9b,0x00b9b0a940564472,0x00ad9056cceeb1f4)},
+  {FIELD_LITERAL(0x00db91b357fe755e,0x00a1aa544b15359c,0x00af4931a0195574,0x007686124fe11aef,0x00d1ead3c7b9ef7e,0x00aaf5fc580f8c15,0x00e727be147ee1ec,0x003c61c1e1577b86)},
+  {FIELD_LITERAL(0x009d3fca983220cf,0x00cd11acbc853dc4,0x0017590409d27f1d,0x00d2176698082802,0x00fa01251b2838c8,0x00dd297a0d9b51c6,0x00d76c92c045820a,0x00534bc7c46c9033)},
+  {FIELD_LITERAL(0x0080ed9bc9b07338,0x00fceac7745d2652,0x008a9d55f5f2cc69,0x0096ce72df301ac5,0x00f53232e7974d87,0x0071728c7ae73947,0x0090507602570778,0x00cb81cfd883b1b2)},
+  {FIELD_LITERAL(0x005011aadea373da,0x003a8578ec896034,0x00f20a6535fa6d71,0x005152d31e5a87cf,0x002bac1c8e68ca31,0x00b0e323db4c1381,0x00f1d596b7d5ae25,0x00eae458097cb4e0)},
+  {FIELD_LITERAL(0x00920ac80f9b0d21,0x00f80f7f73401246,0x0086d37849b557d6,0x0002bd4b317b752e,0x00b26463993a42bb,0x002070422a73b129,0x00341acaa0380cb3,0x00541914dd66a1b2)},
+  {FIELD_LITERAL(0x00c1513cd66abe8c,0x000139e01118944d,0x0064abbcb8080bbb,0x00b3b08202473142,0x00c629ef25da2403,0x00f0aec3310d9b7f,0x0050b2227472d8cd,0x00f6c8a922d41fb4)},
+  {FIELD_LITERAL(0x001075ccf26b7b1f,0x00bb6bb213170433,0x00e9491ad262da79,0x009ef4f48d2d384c,0x008992770766f09d,0x001584396b6b1101,0x00af3f8676c9feef,0x0024603c40269118)},
+  {FIELD_LITERAL(0x009dd7b31319527c,0x001e7ac948d873a9,0x00fa54b46ef9673a,0x0066efb8d5b02fe6,0x00754b1d3928aeae,0x0004262ac72a6f6b,0x0079b7d49a6eb026,0x003126a753540102)},
+  {FIELD_LITERAL(0x009666e24f693947,0x00f714311269d45f,0x0010ffac1d0c851c,0x0066e80c37363497,0x00f1f4ad010c60b0,0x0015c87408470ff7,0x00651d5e9c7766a4,0x008138819d7116de)},
+  {FIELD_LITERAL(0x003934b11c57253b,0x00ef308edf21f46e,0x00e54e99c7a16198,0x0080d57135764e63,0x00751c27b946bc24,0x00dd389ce4e9e129,0x00a1a2bfd1cd84dc,0x002fae73e5149b32)},
+  {FIELD_LITERAL(0x00911657dffb4cdd,0x00c100b7cc553d06,0x00449d075ec467cc,0x007062100bc64e70,0x0043cf86f7bd21e7,0x00f401dc4b797dea,0x005224afb2f62e65,0x00d1ede3fb5a42be)},
+  {FIELD_LITERAL(0x00f2ba36a41aa144,0x00a0c22d946ee18f,0x008aae8ef9a14f99,0x00eef4d79b19bb36,0x008e75ce3d27b1fc,0x00a65daa03b29a27,0x00d9cc83684eb145,0x009e1ed80cc2ed74)},
+  {FIELD_LITERAL(0x00bed953d1997988,0x00b93ed175a24128,0x00871c5963fb6365,0x00ca2df20014a787,0x00f5d9c1d0b34322,0x00f6f5942818db0a,0x004cc091f49c9906,0x00e8a188a60bff9f)},
+  {FIELD_LITERAL(0x0032c7762032fae8,0x00e4087232e0bc21,0x00f767344b6e8d85,0x00bbf369b76c2aa2,0x008a1f46c6e1570c,0x001368cd9780369f,0x007359a39d079430,0x0003646512921434)},
+  {FIELD_LITERAL(0x007c4b47ca7c73e7,0x005396221039734b,0x008b64ddf0e45d7e,0x00bfad5af285e6c2,0x008ec711c5b1a1a8,0x00cf663301237f98,0x00917ee3f1655126,0x004152f337efedd8)},
+  {FIELD_LITERAL(0x0007c7edc9305daa,0x000a6664f273701c,0x00f6e78795e200b1,0x005d05b9ecd2473e,0x0014f5f17c865786,0x00c7fd2d166fa995,0x004939a2d8eb80e0,0x002244ba0942c199)},
+  {FIELD_LITERAL(0x00321e767f0262cf,0x002e57d776caf68e,0x00bf2c94814f0437,0x00c339196acd622f,0x001db4cce71e2770,0x001ded5ddba6eee2,0x0078608ab1554c8d,0x00067fe0ab76365b)},
+  {FIELD_LITERAL(0x00f09758e11e3985,0x00169efdbd64fad3,0x00e8889b7d6dacd6,0x0035cdd58ea88209,0x00bcda47586d7f49,0x003cdddcb2879088,0x0016da70187e954b,0x009556ea2e92aacd)},
+  {FIELD_LITERAL(0x008cab16bd1ff897,0x00b389972cdf753f,0x00ea8ed1e46dfdc0,0x004fe7ef94c589f4,0x002b8ae9b805ecf3,0x0025c08d892874a5,0x0023938e98d44c4c,0x00f759134cabf69c)},
+  {FIELD_LITERAL(0x006c2a84678e4b3b,0x007a194aacd1868f,0x00ed0225af424761,0x00da0a6f293c64b8,0x001062ac5c6a7a18,0x0030f5775a8aeef4,0x0002acaad76b7af0,0x00410b8fd63a579f)},
+  {FIELD_LITERAL(0x001ec59db3d9590e,0x001e9e3f1c3f182d,0x0045a9c3ec2cab14,0x0008198572aeb673,0x00773b74068bd167,0x0012535eaa395434,0x0044dba9e3bbb74a,0x002fba4d3c74bd0e)},
+  {FIELD_LITERAL(0x0042bf08fe66922c,0x003318b8fbb49e8c,0x00d75946004aa14c,0x00f601586b42bf1c,0x00c74cf1d912fe66,0x00abcb36974b30ad,0x007eb78720c9d2b8,0x009f54ab7bd4df85)},
+  {FIELD_LITERAL(0x00db9fc948f73826,0x00fa8b3746ed8ee9,0x00132cb65aafbeb2,0x00c36ff3fe7925b8,0x00837daed353d2fe,0x00ec661be0667cf4,0x005beb8ed2e90204,0x00d77dd69e564967)},
+  {FIELD_LITERAL(0x0042e6268b861751,0x0008dd0469500c16,0x00b51b57c338a3fd,0x00cc4497d85cff6b,0x002f13d6b57c34a4,0x0083652eaf301105,0x00cc344294cc93a8,0x0060f4d02810e270)},
+  {FIELD_LITERAL(0x00a8954363cd518b,0x00ad171124bccb7b,0x0065f46a4adaae00,0x001b1a5b2a96e500,0x0043fe24f8233285,0x0066996d8ae1f2c3,0x00c530f3264169f9,0x00c0f92d07cf6a57)},
+  {FIELD_LITERAL(0x0036a55c6815d943,0x008c8d1def993db3,0x002e0e1e8ff7318f,0x00d883a4b92db00a,0x002f5e781ae33906,0x001a72adb235c06d,0x00f2e59e736e9caa,0x001a4b58e3031914)},
+  {FIELD_LITERAL(0x00d73bfae5e00844,0x00bf459766fb5f52,0x0061b4f5a5313cde,0x004392d4c3b95514,0x000d3551b1077523,0x0000998840ee5d71,0x006de6e340448b7b,0x00251aa504875d6e)},
+  {FIELD_LITERAL(0x003bf343427ac342,0x00adc0a78642b8c5,0x0003b893175a8314,0x0061a34ade5703bc,0x00ea3ea8bb71d632,0x00be0df9a1f198c2,0x0046dd8e7c1635fb,0x00f1523fdd25d5e5)},
+  {FIELD_LITERAL(0x00633f63fc9dd406,0x00e713ff80e04a43,0x0060c6e970f2d621,0x00a57cd7f0df1891,0x00f2406a550650bb,0x00b064290efdc684,0x001eab0144d17916,0x00cd15f863c293ab)},
+  {FIELD_LITERAL(0x0029cec55273f70d,0x007044ee275c6340,0x0040f637a93015e2,0x00338bb78db5aae9,0x001491b2a6132147,0x00a125d6cfe6bde3,0x005f7ac561ba8669,0x001d5eaea3fbaacf)},
+  {FIELD_LITERAL(0x00054e9635e3be31,0x000e43f31e2872be,0x00d05b1c9e339841,0x006fac50bd81fd98,0x00cdc7852eaebb09,0x004ff519b061991b,0x009099e8107d4c85,0x00273e24c36a4a61)},
+  {FIELD_LITERAL(0x00070b4441ef2c46,0x00efa5b02801a109,0x00bf0b8c3ee64adf,0x008a67e0b3452e98,0x001916b1f2fa7a74,0x00d781a78ff6cdc3,0x008682ce57e5c919,0x00cc1109dd210da3)},
+  {FIELD_LITERAL(0x00cae8aaff388663,0x005e983a35dda1c7,0x007ab1030d8e37f4,0x00e48940f5d032fe,0x006a36f9ef30b331,0x009be6f03958c757,0x0086231ceba91400,0x008bd0f7b823e7aa)},
+  {FIELD_LITERAL(0x00cf881ebef5a45a,0x004ebea78e7c6f2c,0x0090da9209cf26a0,0x00de2b2e4c775b84,0x0071d6031c3c15ae,0x00d9e927ef177d70,0x00894ee8c23896fd,0x00e3b3b401e41aad)},
+  {FIELD_LITERAL(0x00204fef26864170,0x00819269c5dee0f8,0x00bfb4713ec97966,0x0026339a6f34df78,0x001f26e64c761dc2,0x00effe3af313cb60,0x00e17b70138f601b,0x00f16e1ccd9ede5e)},
+  {FIELD_LITERAL(0x005d9a8353fdb2db,0x0055cc2048c698f0,0x00f6c4ac89657218,0x00525034d73faeb2,0x00435776fbda3c7d,0x0070ea5312323cbc,0x007a105d44d069fb,0x006dbc8d6dc786aa)},
+  {FIELD_LITERAL(0x0017cff19cd394ec,0x00fef7b810922587,0x00e6483970dff548,0x00ddf36ad6874264,0x00e61778523fcce2,0x0093a66c0c93b24a,0x00fd367114db7f86,0x007652d7ddce26dd)},
+  {FIELD_LITERAL(0x00d92ced7ba12843,0x00aea9c7771e86e7,0x0046639693354f7b,0x00a628dbb6a80c47,0x003a0b0507372953,0x00421113ab45c0d9,0x00e545f08362ab7a,0x0028ce087b4d6d96)},
+  {FIELD_LITERAL(0x00a67ee7cf9f99eb,0x005713b275f2ff68,0x00f1d536a841513d,0x00823b59b024712e,0x009c46b9d0d38cec,0x00cdb1595aa2d7d4,0x008375b3423d9af8,0x000ab0b516d978f7)},
+  {FIELD_LITERAL(0x00428dcb3c510b0f,0x00585607ea24bb4e,0x003736bf1603687a,0x00c47e568c4fe3c7,0x003cd00282848605,0x0043a487c3b91939,0x004ffc04e1095a06,0x00a4c989a3d4b918)},
+  {FIELD_LITERAL(0x00a8778d0e429f7a,0x004c02b059105a68,0x0016653b609da3ff,0x00d5107bd1a12d27,0x00b4708f9a771cab,0x00bb63b662033f69,0x0072f322240e7215,0x0019445b59c69222)},
+  {FIELD_LITERAL(0x00cf4f6069a658e6,0x0053ca52859436a6,0x0064b994d7e3e117,0x00cb469b9a07f534,0x00cfb68f399e9d47,0x00f0dcb8dac1c6e7,0x00f2ab67f538b3a5,0x0055544f178ab975)},
+  {FIELD_LITERAL(0x0099b7a2685d538c,0x00e2f1897b7c0018,0x003adac8ce48dae3,0x00089276d5c50c0c,0x00172fca07ad6717,0x00cb1a72f54069e5,0x004ee42f133545b3,0x00785f8651362f16)},
+  {FIELD_LITERAL(0x0049cbac38509e11,0x0015234505d42cdf,0x00794fb0b5840f1c,0x00496437344045a5,0x0031b6d944e4f9b0,0x00b207318ac1f5d8,0x0000c840da7f5c5d,0x00526f373a5c8814)},
+  {FIELD_LITERAL(0x002c7b7742d1dfd9,0x002cabeb18623c01,0x00055f5e3e044446,0x006c20f3b4ef54ba,0x00c600141ec6b35f,0x00354f437f1a32a3,0x00bac4624a3520f9,0x00c483f734a90691)},
+  {FIELD_LITERAL(0x0053a737d422918d,0x00f7fca1d8758625,0x00c360336dadb04c,0x00f38e3d9158a1b8,0x0069ce3b418e84c6,0x005d1697eca16ead,0x00f8bd6a35ece13d,0x007885dfc2b5afea)},
+  {FIELD_LITERAL(0x00c3617ae260776c,0x00b20dc3e96922d7,0x00a1a7802246706a,0x00ca6505a5240244,0x002246b62d919782,0x001439102d7aa9b3,0x00e8af1139e6422c,0x00c888d1b52f2b05)},
+  {FIELD_LITERAL(0x005b67690ffd41d9,0x005294f28df516f9,0x00a879272412fcb9,0x00098b629a6d1c8d,0x00fabd3c8050865a,0x00cd7e5b0a3879c5,0x00153238210f3423,0x00357cac101e9f42)},
+  {FIELD_LITERAL(0x008917b454444fb7,0x00f59247c97e441b,0x00a6200a6815152d,0x0009a4228601d254,0x001c0360559bd374,0x007563362039cb36,0x00bd75b48d74e32b,0x0017f515ac3499e8)},
+  {FIELD_LITERAL(0x001532a7ffe41c5a,0x00eb1edce358d6bf,0x00ddbacc7b678a7b,0x008a7b70f3c841a3,0x00f1923bf27d3f4c,0x000b2713ed8f7873,0x00aaf67e29047902,0x0044994a70b3976d)},
+  {FIELD_LITERAL(0x00d54e802082d42c,0x00a55aa0dce7cc6c,0x006477b96073f146,0x0082efe4ceb43594,0x00a922bcba026845,0x0077f19d1ab75182,0x00c2bb2737846e59,0x0004d7eec791dd33)},
+  {FIELD_LITERAL(0x0044588d1a81d680,0x00b0a9097208e4f8,0x00212605350dc57e,0x0028717cd2871123,0x00fb083c100fd979,0x0045a056ce063fdf,0x00a5d604b4dd6a41,0x001dabc08ba4e236)},
+  {FIELD_LITERAL(0x00c4887198d7a7fa,0x00244f98fb45784a,0x0045911e15a15d01,0x001d323d374c0966,0x00967c3915196562,0x0039373abd2f3c67,0x000d2c5614312423,0x0041cf2215442ce3)},
+  {FIELD_LITERAL(0x008ede889ada7f06,0x001611e91de2e135,0x00fdb9a458a471b9,0x00563484e03710d1,0x0031cc81925e3070,0x0062c97b3af80005,0x00fa733eea28edeb,0x00e82457e1ebbc88)},
+  {FIELD_LITERAL(0x006a0df5fe9b6f59,0x00a0d4ff46040d92,0x004a7cedb6f93250,0x00d1df8855b8c357,0x00e73a46086fd058,0x0048fb0add6dfe59,0x001e03a28f1b4e3d,0x00a871c993308d76)},
+  {FIELD_LITERAL(0x0030dbb2d1766ec8,0x00586c0ad138555e,0x00d1a34f9e91c77c,0x0063408ad0e89014,0x00d61231b05f6f5b,0x0009abf569f5fd8a,0x00aec67a110f1c43,0x0031d1a790938dd7)},
+  {FIELD_LITERAL(0x006cded841e2a862,0x00198d60af0ab6fb,0x0018f09db809e750,0x004e6ac676016263,0x00eafcd1620969cb,0x002c9784ca34917d,0x0054f00079796de7,0x00d9fab5c5972204)},
+  {FIELD_LITERAL(0x004bd0fee2438a83,0x00b571e62b0f83bd,0x0059287d7ce74800,0x00fb3631b645c3f0,0x00a018e977f78494,0x0091e27065c27b12,0x007696c1817165e0,0x008c40be7c45ba3a)},
+  {FIELD_LITERAL(0x00a0f326327cb684,0x001c7d0f672680ff,0x008c1c81ffb112d1,0x00f8f801674eddc8,0x00e926d5d48c2a9d,0x005bd6d954c6fe9a,0x004c6b24b4e33703,0x00d05eb5c09105cc)},
+  {FIELD_LITERAL(0x00d61731caacf2cf,0x002df0c7609e01c5,0x00306172208b1e2b,0x00b413fe4fb2b686,0x00826d360902a221,0x003f8d056e67e7f7,0x0065025b0175e989,0x00369add117865eb)},
+  {FIELD_LITERAL(0x00aaf895aec2fa11,0x000f892bc313eb52,0x005b1c794dad050b,0x003f8ec4864cec14,0x00af81058d0b90e5,0x00ebe43e183997bb,0x00a9d610f9f3e615,0x007acd8eec2e88d3)},
+  {FIELD_LITERAL(0x0049b2fab13812a3,0x00846db32cd60431,0x000177fa578c8d6c,0x00047d0e2ad4bc51,0x00b158ba38d1e588,0x006a45daad79e3f3,0x000997b93cab887b,0x00c47ea42fa23dc3)},
+  {FIELD_LITERAL(0x0012b6fef7aeb1ca,0x009412768194b6a7,0x00ff0d351f23ab93,0x007e8a14c1aff71b,0x006c1c0170c512bc,0x0016243ea02ab2e5,0x007bb6865b303f3e,0x0015ce6b29b159f4)},
+  {FIELD_LITERAL(0x009961cd02e68108,0x00e2035d3a1d0836,0x005d51f69b5e1a1d,0x004bccb4ea36edcd,0x0069be6a7aeef268,0x0063f4dd9de8d5a7,0x006283783092ca35,0x0075a31af2c35409)},
+  {FIELD_LITERAL(0x00c412365162e8cf,0x00012283fb34388a,0x003e6543babf39e2,0x00eead6b3a804978,0x0099c0314e8b326f,0x00e98e0a8d477a4f,0x00d2eb96b127a687,0x00ed8d7df87571bb)},
+  {FIELD_LITERAL(0x00777463e308cacf,0x00c8acb93950132d,0x00ebddbf4ca48b2c,0x0026ad7ca0795a0a,0x00f99a3d9a715064,0x000d60bcf9d4dfcc,0x005e65a73a437a06,0x0019d536a8db56c8)},
+  {FIELD_LITERAL(0x00192d7dd558d135,0x0027cd6a8323ffa7,0x00239f1a412dc1e7,0x0046b4b3be74fc5c,0x0020c47a2bef5bce,0x00aa17e48f43862b,0x00f7e26c96342e5f,0x0008011c530f39a9)},
+  {FIELD_LITERAL(0x00aad4ac569bf0f1,0x00a67adc90b27740,0x0048551369a5751a,0x0031252584a3306a,0x0084e15df770e6fc,0x00d7bba1c74b5805,0x00a80ef223af1012,0x0089c85ceb843a34)},
+  {FIELD_LITERAL(0x00c4545be4a54004,0x0099e11f60357e6c,0x001f3936d19515a6,0x007793df84341a6e,0x0051061886717ffa,0x00e9b0a660b28f85,0x0044ea685892de0d,0x000257d2a1fda9d9)},
+  {FIELD_LITERAL(0x007e8b01b24ac8a8,0x006cf3b0b5ca1337,0x00f1607d3e36a570,0x0039b7fab82991a1,0x00231777065840c5,0x00998e5afdd346f9,0x00b7dc3e64acc85f,0x00baacc748013ad6)},
+  {FIELD_LITERAL(0x008ea6a4177580bf,0x005fa1953e3f0378,0x005fe409ac74d614,0x00452327f477e047,0x00a4018507fb6073,0x007b6e71951caac8,0x0012b42ab8a6ce91,0x0080eca677294ab7)},
+  {FIELD_LITERAL(0x00a53edc023ba69b,0x00c6afa83ddde2e8,0x00c3f638b307b14e,0x004a357a64414062,0x00e4d94d8b582dc9,0x001739caf71695b7,0x0012431b2ae28de1,0x003b6bc98682907c)},
+  {FIELD_LITERAL(0x008a9a93be1f99d6,0x0079fa627cc699c8,0x00b0cfb134ba84c8,0x001c4b778249419a,0x00df4ab3d9c44f40,0x009f596e6c1a9e3c,0x001979c0df237316,0x00501e953a919b87)}
 };
diff --git a/cbits/decaf/ed448goldilocks/eddsa.c b/cbits/decaf/ed448goldilocks/eddsa.c
--- a/cbits/decaf/ed448goldilocks/eddsa.c
+++ b/cbits/decaf/ed448goldilocks/eddsa.c
@@ -31,18 +31,13 @@
 #define NO_CONTEXT CRYPTON_DECAF_EDDSA_448_SUPPORTS_CONTEXTLESS_SIGS
 #define EDDSA_USE_SIGMA_ISOGENY 0
 #define COFACTOR 4
+#define EDDSA_PREHASH_BYTES 64
 
 #if NO_CONTEXT
 const uint8_t CRYPTON_NO_CONTEXT_POINTS_HERE = 0;
 const uint8_t * const CRYPTON_DECAF_ED448_NO_CONTEXT = &CRYPTON_NO_CONTEXT_POINTS_HERE;
 #endif
 
-/* EDDSA_BASE_POINT_RATIO = 1 or 2
- * Because EdDSA25519 is not on E_d but on the isogenous E_sigma_d,
- * its base point is twice ours.
- */
-#define EDDSA_BASE_POINT_RATIO (1+EDDSA_USE_SIGMA_ISOGENY)
-
 static void clamp (
     uint8_t secret_scalar_ser[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES]
 ) {
@@ -128,22 +123,22 @@
      * the decaf base point is on Etwist_d, and when converted it effectively
      * picks up a factor of 2 from the isogenies.  So we might start at 2 instead of 1. 
      */
-    for (unsigned int c = EDDSA_BASE_POINT_RATIO; c < COFACTOR; c <<= 1) {
+    for (unsigned int c=1; c<CRYPTON_DECAF_448_EDDSA_ENCODE_RATIO; c <<= 1) {
         API_NS(scalar_halve)(secret_scalar,secret_scalar);
     }
     
     API_NS(point_t) p;
     API_NS(precomputed_scalarmul)(p,API_NS(precomputed_base),secret_scalar);
     
-    API_NS(point_mul_by_cofactor_and_encode_like_eddsa)(pubkey, p);
+    API_NS(point_mul_by_ratio_and_encode_like_eddsa)(pubkey, p);
         
     /* Cleanup */
     API_NS(scalar_destroy)(secret_scalar);
     API_NS(point_destroy)(p);
     crypton_decaf_bzero(secret_scalar_ser, sizeof(secret_scalar_ser));
 }
-
-void crypton_decaf_ed448_sign (
+        
+static void crypton_decaf_ed448_sign_internal (
     uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
     const uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES],
     const uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
@@ -191,13 +186,13 @@
         /* Scalarmul to create the nonce-point */
         API_NS(scalar_t) nonce_scalar_2;
         API_NS(scalar_halve)(nonce_scalar_2,nonce_scalar);
-        for (unsigned int c = 2*EDDSA_BASE_POINT_RATIO; c < COFACTOR; c <<= 1) {
+        for (unsigned int c = 2; c < CRYPTON_DECAF_448_EDDSA_ENCODE_RATIO; c <<= 1) {
             API_NS(scalar_halve)(nonce_scalar_2,nonce_scalar_2);
         }
         
         API_NS(point_t) p;
         API_NS(precomputed_scalarmul)(p,API_NS(precomputed_base),nonce_scalar_2);
-        API_NS(point_mul_by_cofactor_and_encode_like_eddsa)(nonce_point, p);
+        API_NS(point_mul_by_ratio_and_encode_like_eddsa)(nonce_point, p);
         API_NS(point_destroy)(p);
         API_NS(scalar_destroy)(nonce_scalar_2);
     }
@@ -228,6 +223,26 @@
     API_NS(scalar_destroy)(challenge_scalar);
 }
 
+void crypton_decaf_ed448_sign (
+    uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
+    const uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES],
+    const uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
+    const uint8_t *message,
+    size_t message_len,
+    uint8_t prehashed,
+    const uint8_t *context,
+    uint8_t context_len
+) {
+    /* rederivation already performed in Crypto.PubKey.Ed448.sign
+    uint8_t rederived_pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES];
+    crypton_decaf_ed448_derive_public_key(rederived_pubkey, privkey);
+    if (CRYPTON_DECAF_TRUE != crypton_decaf_memeq(rederived_pubkey, pubkey, sizeof(rederived_pubkey))) {
+        abort();
+    }
+    */
+    crypton_decaf_ed448_sign_internal(signature,privkey,/*rederived_*/pubkey,message,
+        message_len,prehashed,context,context_len);
+}
 
 void crypton_decaf_ed448_sign_prehash (
     uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
@@ -237,7 +252,7 @@
     const uint8_t *context,
     uint8_t context_len
 ) {
-    uint8_t hash_output[64]; /* MAGIC but true for all existing schemes */
+    uint8_t hash_output[EDDSA_PREHASH_BYTES];
     {
         crypton_decaf_ed448_prehash_ctx_t hash_too;
         memcpy(hash_too,hash,sizeof(hash_too));
@@ -245,10 +260,78 @@
         hash_destroy(hash_too);
     }
 
-    crypton_decaf_ed448_sign(signature,privkey,pubkey,hash_output,sizeof(hash_output),1,context,context_len);
+    uint8_t rederived_pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES];
+    crypton_decaf_ed448_derive_public_key(rederived_pubkey, privkey);
+    if (CRYPTON_DECAF_TRUE != crypton_decaf_memeq(rederived_pubkey, pubkey, sizeof(rederived_pubkey))) {
+        abort();
+    }
+
+    crypton_decaf_ed448_sign_internal(signature,privkey,rederived_pubkey,hash_output,
+        sizeof(hash_output),1,context,context_len);
     crypton_decaf_bzero(hash_output,sizeof(hash_output));
 }
 
+void crypton_decaf_ed448_derive_keypair (
+    crypton_decaf_eddsa_448_keypair_t keypair,
+    const uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES]
+) {
+    memcpy(keypair->privkey, privkey, CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES);
+    crypton_decaf_ed448_derive_public_key(keypair->pubkey, keypair->privkey);
+}
+
+void crypton_decaf_ed448_keypair_extract_public_key (
+    uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
+    const crypton_decaf_eddsa_448_keypair_t keypair
+) {
+    memcpy(pubkey,keypair->pubkey,CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES);
+}
+
+void crypton_decaf_ed448_keypair_extract_private_key (
+    uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES],
+    const crypton_decaf_eddsa_448_keypair_t keypair
+) {
+    memcpy(privkey,keypair->privkey,CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES);
+}
+
+void crypton_decaf_ed448_keypair_destroy (
+    crypton_decaf_eddsa_448_keypair_t keypair
+) {
+    crypton_decaf_bzero(keypair, sizeof(crypton_decaf_eddsa_448_keypair_t));
+}
+
+void crypton_decaf_ed448_keypair_sign (
+    uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
+    const crypton_decaf_eddsa_448_keypair_t keypair,
+    const uint8_t *message,
+    size_t message_len,
+    uint8_t prehashed,
+    const uint8_t *context,
+    uint8_t context_len
+) {
+    crypton_decaf_ed448_sign_internal(signature,keypair->privkey,keypair->pubkey,message,
+        message_len,prehashed,context,context_len);
+}
+
+void crypton_decaf_ed448_keypair_sign_prehash (
+    uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
+    const crypton_decaf_eddsa_448_keypair_t keypair,
+    const crypton_decaf_ed448_prehash_ctx_t hash,
+    const uint8_t *context,
+    uint8_t context_len
+) {
+    uint8_t hash_output[EDDSA_PREHASH_BYTES];
+    {
+        crypton_decaf_ed448_prehash_ctx_t hash_too;
+        memcpy(hash_too,hash,sizeof(hash_too));
+        hash_final(hash_too,hash_output,sizeof(hash_output));
+        hash_destroy(hash_too);
+    }
+
+    crypton_decaf_ed448_sign_internal(signature,keypair->privkey,keypair->pubkey,hash_output,
+        sizeof(hash_output),1,context,context_len);
+    crypton_decaf_bzero(hash_output,sizeof(hash_output));
+}
+
 crypton_decaf_error_t crypton_decaf_ed448_verify (
     const uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
     const uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
@@ -259,10 +342,10 @@
     uint8_t context_len
 ) { 
     API_NS(point_t) pk_point, r_point;
-    crypton_decaf_error_t error = API_NS(point_decode_like_eddsa_and_ignore_cofactor)(pk_point,pubkey);
+    crypton_decaf_error_t error = API_NS(point_decode_like_eddsa_and_mul_by_ratio)(pk_point,pubkey);
     if (CRYPTON_DECAF_SUCCESS != error) { return error; }
     
-    error = API_NS(point_decode_like_eddsa_and_ignore_cofactor)(r_point,signature);
+    error = API_NS(point_decode_like_eddsa_and_mul_by_ratio)(r_point,signature);
     if (CRYPTON_DECAF_SUCCESS != error) { return error; }
     
     API_NS(scalar_t) challenge_scalar;
@@ -282,16 +365,27 @@
     API_NS(scalar_sub)(challenge_scalar, API_NS(scalar_zero), challenge_scalar);
     
     API_NS(scalar_t) response_scalar;
-    API_NS(scalar_decode_long)(
+    error = API_NS(scalar_decode)(
         response_scalar,
-        &signature[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
-        CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES
+        &signature[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES]
     );
-#if EDDSA_BASE_POINT_RATIO == 2
-    API_NS(scalar_add)(response_scalar,response_scalar,response_scalar);
+    if (CRYPTON_DECAF_SUCCESS != error) { return error; }
+
+#if CRYPTON_DECAF_448_SCALAR_BYTES < CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES
+    for (unsigned i = CRYPTON_DECAF_448_SCALAR_BYTES;
+         i < CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES;
+         i++) {
+        if (signature[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES+i] != 0x00) {
+            return CRYPTON_DECAF_FAILURE;
+        }
+    }
 #endif
     
+    for (unsigned c=1; c<CRYPTON_DECAF_448_EDDSA_DECODE_RATIO; c<<=1) {
+        API_NS(scalar_add)(response_scalar,response_scalar,response_scalar);
+    }
     
+    
     /* pk_point = -c(x(P)) + (cx + k)G = kG */
     API_NS(base_double_scalarmul_non_secret)(
         pk_point,
@@ -312,7 +406,7 @@
 ) {
     crypton_decaf_error_t ret;
     
-    uint8_t hash_output[64]; /* MAGIC but true for all existing schemes */
+    uint8_t hash_output[EDDSA_PREHASH_BYTES];
     {
         crypton_decaf_ed448_prehash_ctx_t hash_too;
         memcpy(hash_too,hash,sizeof(hash_too));
diff --git a/cbits/decaf/ed448goldilocks/scalar.c b/cbits/decaf/ed448goldilocks/scalar.c
--- a/cbits/decaf/ed448goldilocks/scalar.c
+++ b/cbits/decaf/ed448goldilocks/scalar.c
@@ -48,15 +48,15 @@
     unsigned int i;
     for (i=0; i<SCALAR_LIMBS; i++) {
         chain = (chain + accum[i]) - sub->limb[i];
-        out->limb[i] = chain;
+        out->limb[i] = (crypton_decaf_word_t)chain;
         chain >>= WBITS;
     }
-    crypton_decaf_word_t borrow = chain+extra; /* = 0 or -1 */
+    crypton_decaf_word_t borrow = (crypton_decaf_word_t)chain+extra; /* = 0 or -1 */
     
     chain = 0;
     for (i=0; i<SCALAR_LIMBS; i++) {
         chain = (chain + out->limb[i]) + (p->limb[i] & borrow);
-        out->limb[i] = chain;
+        out->limb[i] = (crypton_decaf_word_t)chain;
         chain >>= WBITS;
     }
 }
@@ -77,22 +77,22 @@
         crypton_decaf_dword_t chain = 0;
         for (j=0; j<SCALAR_LIMBS; j++) {
             chain += ((crypton_decaf_dword_t)mand)*mier[j] + accum[j];
-            accum[j] = chain;
+            accum[j] = (crypton_decaf_word_t)chain;
             chain >>= WBITS;
         }
-        accum[j] = chain;
+        accum[j] = (crypton_decaf_word_t)chain;
         
         mand = accum[0] * MONTGOMERY_FACTOR;
         chain = 0;
         mier = sc_p->limb;
         for (j=0; j<SCALAR_LIMBS; j++) {
             chain += (crypton_decaf_dword_t)mand*mier[j] + accum[j];
-            if (j) accum[j-1] = chain;
+            if (j) accum[j-1] = (crypton_decaf_word_t)chain;
             chain >>= WBITS;
         }
         chain += accum[j];
         chain += hi_carry;
-        accum[j-1] = chain;
+        accum[j-1] = (crypton_decaf_word_t)chain;
         hi_carry = chain >> WBITS;
     }
     
@@ -121,7 +121,7 @@
      * Sliding window is fine here because the modulus isn't secret.
      */
     const int SCALAR_WINDOW_BITS = 3;
-    scalar_t precmp[1<<SCALAR_WINDOW_BITS];
+    scalar_t precmp[1<<3];  // Rewritten from SCALAR_WINDOW_BITS for windows compatibility
     const int LAST = (1<<SCALAR_WINDOW_BITS)-1;
 
     /* Precompute precmp = [a^1,a^3,...] */
@@ -190,10 +190,10 @@
     unsigned int i;
     for (i=0; i<SCALAR_LIMBS; i++) {
         chain = (chain + a->limb[i]) + b->limb[i];
-        out->limb[i] = chain;
+        out->limb[i] = (crypton_decaf_word_t)chain;
         chain >>= WBITS;
     }
-    sc_subx(out, out->limb, sc_p, sc_p, chain);
+    sc_subx(out, out->limb, sc_p, sc_p, (crypton_decaf_word_t)chain);
 }
 
 void
@@ -204,7 +204,7 @@
     memset(out,0,sizeof(scalar_t));
     unsigned int i = 0;
     for (; i<sizeof(uint64_t)/sizeof(crypton_decaf_word_t); i++) {
-        out->limb[i] = w;
+        out->limb[i] = (crypton_decaf_word_t)w;
 #if CRYPTON_DECAF_WORD_BITS < 64
         w >>= 8*sizeof(crypton_decaf_word_t);
 #endif
@@ -227,7 +227,7 @@
 static CRYPTON_DECAF_INLINE void scalar_decode_short (
     scalar_t s,
     const unsigned char *ser,
-    unsigned int nbytes
+    size_t nbytes
 ) {
     unsigned int i,j,k=0;
     for (i=0; i<SCALAR_LIMBS; i++) {
@@ -253,7 +253,7 @@
     
     API_NS(scalar_mul)(s,s,API_NS(scalar_one)); /* ham-handed reduce */
     
-    return crypton_decaf_succeed_if(~word_is_zero(accum));
+    return crypton_decaf_succeed_if(~word_is_zero((crypton_decaf_word_t)accum));
 }
 
 void API_NS(scalar_destroy) (
@@ -325,17 +325,17 @@
     scalar_t out,
     const scalar_t a
 ) {
-    crypton_decaf_word_t mask = -(a->limb[0] & 1);
+    crypton_decaf_word_t mask = bit_to_mask((a->limb[0]) & 1);
     crypton_decaf_dword_t chain = 0;
     unsigned int i;
     for (i=0; i<SCALAR_LIMBS; i++) {
         chain = (chain + a->limb[i]) + (sc_p->limb[i] & mask);
-        out->limb[i] = chain;
+        out->limb[i] = (crypton_decaf_word_t)chain;
         chain >>= CRYPTON_DECAF_WORD_BITS;
     }
     for (i=0; i<SCALAR_LIMBS-1; i++) {
         out->limb[i] = out->limb[i]>>1 | out->limb[i+1]<<(WBITS-1);
     }
-    out->limb[i] = out->limb[i]>>1 | chain<<(WBITS-1);
+    out->limb[i] = out->limb[i]>>1 | (crypton_decaf_word_t)(chain<<(WBITS-1));
 }
 
diff --git a/cbits/decaf/include/arch_32/arch_intrinsics.h b/cbits/decaf/include/arch_32/arch_intrinsics.h
--- a/cbits/decaf/include/arch_32/arch_intrinsics.h
+++ b/cbits/decaf/include/arch_32/arch_intrinsics.h
@@ -7,6 +7,11 @@
 
 #define ARCH_WORD_BITS 32
 
+#if defined _MSC_VER
+#define __attribute(x)
+#define __inline__ __inline
+#endif // MSVC
+
 static __inline__ __attribute((always_inline,unused))
 uint32_t word_is_zero(uint32_t a) {
     /* let's hope the compiler isn't clever enough to optimize this. */
diff --git a/cbits/decaf/include/decaf/common.h b/cbits/decaf/include/decaf/common.h
--- a/cbits/decaf/include/decaf/common.h
+++ b/cbits/decaf/include/decaf/common.h
@@ -13,7 +13,9 @@
 #define __CRYPTON_DECAF_COMMON_H__ 1
 
 #include <stdint.h>
+#if defined (__GNUC__)  // File only exists for GNU compilers
 #include <sys/types.h>
+#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -21,14 +23,35 @@
 
 /* Goldilocks' build flags default to hidden and stripping executables. */
 /** @cond internal */
-#if defined(DOXYGEN) && !defined(__attribute__)
-#define __attribute__((x))
+#if DOXYGEN || defined(__attribute__)
+#define __attribute__(x)
+#define NOINLINE
 #endif
+
+/* Aliasing MSVC preprocessing to GNU preprocessing */
+#if defined _MSC_VER
+#   define __attribute__(x)        // Turn off attribute code
+#   define __attribute(x)
+#   define __restrict__ __restrict  // Use MSVC restrict code
+#   if defined _DLL
+#       define CRYPTON_DECAF_API_VIS __declspec(dllexport)  // MSVC for visibility
+#   else
+#       define CRYPTON_DECAF_API_VIS __declspec(dllimport)
+#   endif
+
+//#   define CRYPTON_DECAF_NOINLINE __declspec(noinline) // MSVC for noinline
+//#   define CRYPTON_DECAF_INLINE __forceinline // MSVC for always inline
+//#   define CRYPTON_DECAF_WARN_UNUSED _Check_return_    
+#else // MSVC
 #define CRYPTON_DECAF_API_VIS __attribute__((visibility("default")))
+#define CRYPTON_DECAF_API_IMPORT
+#endif
+
+// The following are disabled for MSVC
 #define CRYPTON_DECAF_NOINLINE  __attribute__((noinline))
-#define CRYPTON_DECAF_WARN_UNUSED __attribute__((warn_unused_result))
-#define CRYPTON_DECAF_NONNULL __attribute__((nonnull))
 #define CRYPTON_DECAF_INLINE inline __attribute__((always_inline,unused))
+#define CRYPTON_DECAF_WARN_UNUSED __attribute__((warn_unused_result))
+#define CRYPTON_DECAF_NONNULL __attribute__((nonnull))  
 // Cribbed from libnotmuch
 #if defined (__clang_major__) && __clang_major__ >= 3 \
     || defined (__GNUC__) && __GNUC__ >= 5 \
@@ -70,8 +93,25 @@
 #error "Only supporting CRYPTON_DECAF_WORD_BITS = 32 or 64 for now"
 #endif
     
-/** CRYPTON_DECAF_TRUE = -1 so that CRYPTON_DECAF_TRUE & x = x */
-static const crypton_decaf_bool_t CRYPTON_DECAF_TRUE = -(crypton_decaf_bool_t)1;
+/* MSCV compiler doesn't like the trick to have -1 assigned to an unsigned int to
+ * set it to all ones, so do it openly */
+#if CRYPTON_DECAF_WORD_BITS == 64
+/** CRYPTON_DECAF_TRUE = all ones so that CRYPTON_DECAF_TRUE & x = x */
+static const crypton_decaf_bool_t CRYPTON_DECAF_TRUE = (crypton_decaf_bool_t)0xFFFFFFFFFFFFFFFF;
+/** CRYPTON_DECAF_WORD_ALL_SET : all ones */
+static const crypton_decaf_word_t CRYPTON_DECAF_WORD_ALL_SET = (crypton_decaf_word_t)0xFFFFFFFFFFFFFFFF;
+/** CRYPTON_DECAF_WORD_ALL_UNSET : all zeros */
+static const crypton_decaf_word_t CRYPTON_DECAF_WORD_ALL_UNSET = (crypton_decaf_word_t)0x0;
+#elif CRYPTON_DECAF_WORD_BITS == 32         /**< The number of bits in a word */
+/** CRYPTON_DECAF_TRUE = all ones so that CRYPTON_DECAF_TRUE & x = x */
+static const crypton_decaf_bool_t CRYPTON_DECAF_TRUE = (crypton_decaf_bool_t)0xFFFFFFFF;
+/** CRYPTON_DECAF_WORD_ALL_SET : all ones */
+static const crypton_decaf_word_t CRYPTON_DECAF_WORD_ALL_SET = (crypton_decaf_word_t)0xFFFFFFFF;
+/** CRYPTON_DECAF_WORD_ALL_UNSET : all zeros */
+static const crypton_decaf_word_t CRYPTON_DECAF_WORD_ALL_UNSET = (crypton_decaf_word_t)0x0;
+#else
+#error "Only supporting CRYPTON_DECAF_WORD_BITS = 32 or 64 for now"
+#endif
 
 /** CRYPTON_DECAF_FALSE = 0 so that CRYPTON_DECAF_FALSE & x = 0 */
 static const crypton_decaf_bool_t CRYPTON_DECAF_FALSE = 0;
@@ -92,22 +132,23 @@
 /** Return CRYPTON_DECAF_TRUE iff x == CRYPTON_DECAF_SUCCESS */
 static CRYPTON_DECAF_INLINE crypton_decaf_bool_t
 crypton_decaf_successful(crypton_decaf_error_t e) {
-    crypton_decaf_dword_t w = ((crypton_decaf_word_t)e) ^  ((crypton_decaf_word_t)CRYPTON_DECAF_SUCCESS);
+    crypton_decaf_word_t succ = CRYPTON_DECAF_SUCCESS;
+    crypton_decaf_dword_t w = ((crypton_decaf_word_t)e) ^  succ;
     return (w-1)>>CRYPTON_DECAF_WORD_BITS;
 }
     
 /** Overwrite data with zeros.  Uses memset_s if available. */
-void crypton_decaf_bzero (
+void CRYPTON_DECAF_API_VIS crypton_decaf_bzero (
     void *data,
     size_t size
-) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_API_VIS;
+) CRYPTON_DECAF_NONNULL;
 
 /** Compare two buffers, returning CRYPTON_DECAF_TRUE if they are equal. */
-crypton_decaf_bool_t crypton_decaf_memeq (
+crypton_decaf_bool_t CRYPTON_DECAF_API_VIS crypton_decaf_memeq (
     const void *data1,
     const void *data2,
     size_t size
-) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_API_VIS;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_WARN_UNUSED;
     
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/cbits/decaf/include/decaf/ed448.h b/cbits/decaf/include/decaf/ed448.h
--- a/cbits/decaf/include/decaf/ed448.h
+++ b/cbits/decaf/include/decaf/ed448.h
@@ -33,14 +33,45 @@
 #define CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES (CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES + CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES)
 
 /** Does EdDSA support non-contextual signatures? */
+#if defined _MSC_VER  /* Different syntax for exposing API */
 #define CRYPTON_DECAF_EDDSA_448_SUPPORTS_CONTEXTLESS_SIGS 0
 
-/** Prehash context renaming macros. */
+#else
+#define CRYPTON_DECAF_EDDSA_448_SUPPORTS_CONTEXTLESS_SIGS 0
+
+#endif
+
+/** Prehash context (raw), because each EdDSA instance has a different prehash. */
 #define crypton_decaf_ed448_prehash_ctx_s   crypton_decaf_shake256_ctx_s
+
+/** Prehash context, array[1] form. */
 #define crypton_decaf_ed448_prehash_ctx_t   crypton_decaf_shake256_ctx_t
+    
+/** Prehash update. */
 #define crypton_decaf_ed448_prehash_update  crypton_decaf_shake256_update
+    
+/** Prehash destroy. */
 #define crypton_decaf_ed448_prehash_destroy crypton_decaf_shake256_destroy
 
+/** EdDSA encoding ratio. */
+#define CRYPTON_DECAF_448_EDDSA_ENCODE_RATIO 4
+
+/** EdDSA decoding ratio. */
+#define CRYPTON_DECAF_448_EDDSA_DECODE_RATIO (4 / 4)
+    
+#ifndef CRYPTON_DECAF_EDDSA_NON_KEYPAIR_API_IS_DEPRECATED
+/** If 1, add deprecation attribute to non-keypair API functions. Now deprecated. */
+#define CRYPTON_DECAF_EDDSA_NON_KEYPAIR_API_IS_DEPRECATED 1
+#endif
+
+/** @cond internal */
+/** @brief Scheduled EdDSA keypair */
+typedef struct crypton_decaf_eddsa_448_keypair_s {
+    uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES];
+    uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES];
+}  crypton_decaf_eddsa_448_keypair_s, crypton_decaf_eddsa_448_keypair_t[1];
+/** @endcond */
+
 /**
  * @brief EdDSA key generation.  This function uses a different (non-Decaf)
  * encoding.
@@ -48,14 +79,60 @@
  * @param [out] pubkey The public key.
  * @param [in] privkey The private key.
  */    
-void crypton_decaf_ed448_derive_public_key (
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_derive_public_key (
     uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
     const uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
- * @brief EdDSA signing.
+ * @brief EdDSA keypair scheduling.  This is to add a safer version of the signing algorithm,
+ * where it is harder to use the wrong pubkey for your private key..
  *
+ * @param [out] keypair The scheduled keypair.
+ * @param [in] privkey The private key.
+ */    
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_derive_keypair (
+    crypton_decaf_eddsa_448_keypair_t keypair,
+    const uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES]
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+
+/**
+ * @brief Extract the public key from an EdDSA keypair.
+ *
+ * @param [out] pubkey The public key.
+ * @param [in] keypair The keypair.
+ */    
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_keypair_extract_public_key (
+    uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
+    const crypton_decaf_eddsa_448_keypair_t keypair
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+
+/**
+ * @brief Extract the private key from an EdDSA keypair.
+ *
+ * @param [out] privkey The private key.
+ * @param [in] keypair The keypair.
+ */    
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_keypair_extract_private_key (
+    uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES],
+    const crypton_decaf_eddsa_448_keypair_t keypair
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+
+/**
+ * @brief EdDSA keypair destructor.
+ * @param [in] pubkey The keypair.
+ */    
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_keypair_destroy (
+    crypton_decaf_eddsa_448_keypair_t keypair
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+
+/**
+ * @brief EdDSA signing.  However, this API is deprecated because it isn't safe: if the wrong
+ * public key is passed, it would reveal the private key.  Instead, this function checks that
+ * the public key is correct, and otherwise aborts.
+ *
+ * @deprecated Use CRYPTON_DECAF_API_VIS crypton_decaf_ed448_keypair_sign instead.
+ *
  * @param [out] signature The signature.
  * @param [in] privkey The private key.
  * @param [in] pubkey The public key.
@@ -70,7 +147,7 @@
  * safe.  The C++ wrapper is designed to make it harder to screw this up, but this C code gives
  * you no seat belt.
  */  
-void crypton_decaf_ed448_sign (
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_sign (
     uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
     const uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES],
     const uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
@@ -79,40 +156,85 @@
     uint8_t prehashed,
     const uint8_t *context,
     uint8_t context_len
-) CRYPTON_DECAF_API_VIS __attribute__((nonnull(1,2,3))) CRYPTON_DECAF_NOINLINE;
+) __attribute__((nonnull(1,2,3))) CRYPTON_DECAF_NOINLINE
+#if CRYPTON_DECAF_EDDSA_NON_KEYPAIR_API_IS_DEPRECATED
+  CRYPTON_DECAF_DEPRECATED("Passing the pubkey and privkey separately is unsafe, use crypton_decaf_ed448_keypair_sign")
+#endif
+;
 
 /**
- * @brief EdDSA signing with prehash.
+ * @brief EdDSA signing with prehash.  However, this API is deprecated because it isn't safe: if the wrong
+ * public key is passed, it would reveal the private key.  Instead, this function checks that
+ * the public key is correct, and otherwise aborts.
  *
+ * @deprecated Use CRYPTON_DECAF_API_VIS crypton_decaf_ed448_keypair_sign_prehash instead.
+ *
  * @param [out] signature The signature.
  * @param [in] privkey The private key.
  * @param [in] pubkey The public key.
  * @param [in] hash The hash of the message.  This object will not be modified by the call.
  * @param [in] context A "context" for this signature of up to 255 bytes.  Must be the same as what was used for the prehash.
  * @param [in] context_len Length of the context.
- *
- * @warning For Ed25519, it is unsafe to use the same key for both prehashed and non-prehashed
- * messages, at least without some very careful protocol-level disambiguation.  For Ed448 it is
- * safe.  The C++ wrapper is designed to make it harder to screw this up, but this C code gives
- * you no seat belt.
  */  
-void crypton_decaf_ed448_sign_prehash (
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_sign_prehash (
     uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
     const uint8_t privkey[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES],
     const uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
     const crypton_decaf_ed448_prehash_ctx_t hash,
     const uint8_t *context,
     uint8_t context_len
-) CRYPTON_DECAF_API_VIS __attribute__((nonnull(1,2,3,4))) CRYPTON_DECAF_NOINLINE;
+) __attribute__((nonnull(1,2,3,4))) CRYPTON_DECAF_NOINLINE
+#if CRYPTON_DECAF_EDDSA_NON_KEYPAIR_API_IS_DEPRECATED
+  CRYPTON_DECAF_DEPRECATED("Passing the pubkey and privkey separately is unsafe, use crypton_decaf_ed448_keypair_sign_prehash")
+#endif
+;
+
+/**
+ * @brief EdDSA signing.
+ *
+ * @param [out] signature The signature.
+ * @param [in] keypair The private and public key.
+ * @param [in] message The message to sign.
+ * @param [in] message_len The length of the message.
+ * @param [in] prehashed Nonzero if the message is actually the hash of something you want to sign.
+ * @param [in] context A "context" for this signature of up to 255 bytes.
+ * @param [in] context_len Length of the context.
+ */  
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_keypair_sign (
+    uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
+    const crypton_decaf_eddsa_448_keypair_t keypair,
+    const uint8_t *message,
+    size_t message_len,
+    uint8_t prehashed,
+    const uint8_t *context,
+    uint8_t context_len
+) __attribute__((nonnull(1,2,3))) CRYPTON_DECAF_NOINLINE;
+
+/**
+ * @brief EdDSA signing with prehash.
+ *
+ * @param [out] signature The signature.
+ * @param [in] keypair The private and public key.
+ * @param [in] hash The hash of the message.  This object will not be modified by the call.
+ * @param [in] context A "context" for this signature of up to 255 bytes.  Must be the same as what was used for the prehash.
+ * @param [in] context_len Length of the context.
+ */  
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_keypair_sign_prehash (
+    uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
+    const crypton_decaf_eddsa_448_keypair_t keypair,
+    const crypton_decaf_ed448_prehash_ctx_t hash,
+    const uint8_t *context,
+    uint8_t context_len
+) __attribute__((nonnull(1,2,3,4))) CRYPTON_DECAF_NOINLINE;
     
 /**
  * @brief Prehash initialization, with contexts if supported.
  *
  * @param [out] hash The hash object to be initialized.
  */
-void crypton_decaf_ed448_prehash_init (
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_prehash_init (
     crypton_decaf_ed448_prehash_ctx_t hash
-) CRYPTON_DECAF_API_VIS __attribute__((nonnull(1))) CRYPTON_DECAF_NOINLINE;
+) __attribute__((nonnull(1))) CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief EdDSA signature verification.
@@ -132,7 +254,7 @@
  * safe.  The C++ wrapper is designed to make it harder to screw this up, but this C code gives
  * you no seat belt.
  */
-crypton_decaf_error_t crypton_decaf_ed448_verify (
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS crypton_decaf_ed448_verify (
     const uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
     const uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
     const uint8_t *message,
@@ -140,7 +262,7 @@
     uint8_t prehashed,
     const uint8_t *context,
     uint8_t context_len
-) CRYPTON_DECAF_API_VIS __attribute__((nonnull(1,2))) CRYPTON_DECAF_NOINLINE;
+) __attribute__((nonnull(1,2))) CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief EdDSA signature verification.
@@ -158,38 +280,56 @@
  * safe.  The C++ wrapper is designed to make it harder to screw this up, but this C code gives
  * you no seat belt.
  */
-crypton_decaf_error_t crypton_decaf_ed448_verify_prehash (
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS crypton_decaf_ed448_verify_prehash (
     const uint8_t signature[CRYPTON_DECAF_EDDSA_448_SIGNATURE_BYTES],
     const uint8_t pubkey[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
     const crypton_decaf_ed448_prehash_ctx_t hash,
     const uint8_t *context,
     uint8_t context_len
-) CRYPTON_DECAF_API_VIS __attribute__((nonnull(1,2))) CRYPTON_DECAF_NOINLINE;
+) __attribute__((nonnull(1,2))) CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief EdDSA point encoding.  Used internally, exposed externally.
- * Multiplies the point by the current cofactor first.
+ * Multiplies by CRYPTON_DECAF_448_EDDSA_ENCODE_RATIO first.
  *
+ * The multiplication is required because the EdDSA encoding represents
+ * the cofactor information, but the Decaf encoding ignores it (which
+ * is the whole point).  So if you decode from EdDSA and re-encode to
+ * EdDSA, the cofactor info must get cleared, because the intermediate
+ * representation doesn't track it.
+ *
+ * The way libdecaf handles this is to multiply by
+ * CRYPTON_DECAF_448_EDDSA_DECODE_RATIO when decoding, and by
+ * CRYPTON_DECAF_448_EDDSA_ENCODE_RATIO when encoding.  The product of these
+ * ratios is always exactly the cofactor 4, so the cofactor
+ * ends up cleared one way or another.  But exactly how that shakes
+ * out depends on the base points specified in RFC 8032.
+ *
+ * The upshot is that if you pass the Decaf/Ristretto base point to
+ * this function, you will get CRYPTON_DECAF_448_EDDSA_ENCODE_RATIO times the
+ * EdDSA base point.
+ *
  * @param [out] enc The encoded point.
  * @param [in] p The point.
  */       
-void crypton_decaf_448_point_mul_by_cofactor_and_encode_like_eddsa (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_mul_by_ratio_and_encode_like_eddsa (
     uint8_t enc[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES],
     const crypton_decaf_448_point_t p
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
- * @brief EdDSA point decoding.  Remember that while points on the
- * EdDSA curves have cofactor information, Decaf ignores (quotients
- * out) all cofactor information.
+ * @brief EdDSA point decoding.  Multiplies by CRYPTON_DECAF_448_EDDSA_DECODE_RATIO,
+ * and ignores cofactor information.
  *
+ * See notes on crypton_decaf_448_point_mul_by_ratio_and_encode_like_eddsa
+ *
  * @param [out] enc The encoded point.
  * @param [in] p The point.
  */       
-crypton_decaf_error_t crypton_decaf_448_point_decode_like_eddsa_and_ignore_cofactor (
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS crypton_decaf_448_point_decode_like_eddsa_and_mul_by_ratio (
     crypton_decaf_448_point_t p,
     const uint8_t enc[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief EdDSA to ECDH public key conversion
@@ -202,10 +342,10 @@
  * @param[out] x The ECDH public key as in RFC7748(point on Montgomery curve)
  * @param[in] ed The EdDSA public key(point on Edwards curve)
  */
-void crypton_decaf_ed448_convert_public_key_to_x448 (
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_convert_public_key_to_x448 (
     uint8_t x[CRYPTON_DECAF_X448_PUBLIC_BYTES],
     const uint8_t ed[CRYPTON_DECAF_EDDSA_448_PUBLIC_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief EdDSA to ECDH private key conversion
@@ -215,10 +355,10 @@
  * @param[out] x The ECDH private key as in RFC7748
  * @param[in] ed The EdDSA private key
  */
-void crypton_decaf_ed448_convert_private_key_to_x448 (
+void CRYPTON_DECAF_API_VIS crypton_decaf_ed448_convert_private_key_to_x448 (
     uint8_t x[CRYPTON_DECAF_X448_PRIVATE_BYTES],
     const uint8_t ed[CRYPTON_DECAF_EDDSA_448_PRIVATE_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/cbits/decaf/include/decaf/point_448.h b/cbits/decaf/include/decaf/point_448.h
--- a/cbits/decaf/include/decaf/point_448.h
+++ b/cbits/decaf/include/decaf/point_448.h
@@ -34,7 +34,7 @@
 /** @brief Galois field element internal structure */
 typedef struct crypton_gf_448_s {
     crypton_decaf_word_t limb[512/CRYPTON_DECAF_WORD_BITS];
-} __attribute__((aligned(16))) crypton_gf_448_s, crypton_gf_448_t[1];
+} __attribute__((aligned(32))) crypton_gf_448_s, crypton_gf_448_t[1];
 #endif /* __CRYPTON_DECAF_448_GF_DEFINED__ */
 /** @endcond */
 
@@ -52,16 +52,22 @@
 /** Number of bits in the "which" field of an elligator inverse */
 #define CRYPTON_DECAF_448_INVERT_ELLIGATOR_WHICH_BITS 3
 
+/** The cofactor the curve would have, if we hadn't removed it */
+#define CRYPTON_DECAF_448_REMOVED_COFACTOR 4
+
+/** X448 encoding ratio. */
+#define CRYPTON_DECAF_X448_ENCODE_RATIO 2
+
 /** Number of bytes in an x448 public key */
 #define CRYPTON_DECAF_X448_PUBLIC_BYTES 56
 
 /** Number of bytes in an x448 private key */
 #define CRYPTON_DECAF_X448_PRIVATE_BYTES 56
 
-/** Twisted Edwards extended homogeneous coordinates */
+/** Representation of a point on the elliptic curve. */
 typedef struct crypton_decaf_448_point_s {
     /** @cond internal */
-    crypton_gf_448_t x,y,z,t;
+    crypton_gf_448_t x,y,z,t; /* Twisted extended homogeneous coordinates */
     /** @endcond */
 } crypton_decaf_448_point_t[1];
 
@@ -72,30 +78,51 @@
 typedef struct crypton_decaf_448_precomputed_s crypton_decaf_448_precomputed_s; 
 
 /** Size and alignment of precomputed point tables. */
-extern const size_t crypton_decaf_448_sizeof_precomputed_s CRYPTON_DECAF_API_VIS, crypton_decaf_448_alignof_precomputed_s CRYPTON_DECAF_API_VIS;
+CRYPTON_DECAF_API_VIS extern const size_t crypton_decaf_448_sizeof_precomputed_s, crypton_decaf_448_alignof_precomputed_s;
 
-/** Scalar is stored packed, because we don't need the speed. */
+/** Representation of an element of the scalar field. */
 typedef struct crypton_decaf_448_scalar_s {
     /** @cond internal */
     crypton_decaf_word_t limb[CRYPTON_DECAF_448_SCALAR_LIMBS];
     /** @endcond */
 } crypton_decaf_448_scalar_t[1];
 
-/** A scalar equal to 1. */
-extern const crypton_decaf_448_scalar_t crypton_decaf_448_scalar_one CRYPTON_DECAF_API_VIS;
+#if defined _MSC_VER
 
-/** A scalar equal to 0. */
-extern const crypton_decaf_448_scalar_t crypton_decaf_448_scalar_zero CRYPTON_DECAF_API_VIS;
+/** The scalar 1. */
+extern const crypton_decaf_448_scalar_t CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_one;
 
-/** The identity point on the curve. */
-extern const crypton_decaf_448_point_t crypton_decaf_448_point_identity CRYPTON_DECAF_API_VIS;
+/** The scalar 0. */
+extern const crypton_decaf_448_scalar_t CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_zero;
 
-/** An arbitrarily chosen base point on the curve. */
-extern const crypton_decaf_448_point_t crypton_decaf_448_point_base CRYPTON_DECAF_API_VIS;
+/** The identity (zero) point on the curve. */
+extern const crypton_decaf_448_point_t CRYPTON_DECAF_API_VIS crypton_decaf_448_point_identity;
 
-/** Precomputed table for the base point on the curve. */
-extern const struct crypton_decaf_448_precomputed_s *crypton_decaf_448_precomputed_base CRYPTON_DECAF_API_VIS;
+/** An arbitrarily-chosen base point on the curve. */
+extern const crypton_decaf_448_point_t CRYPTON_DECAF_API_VIS crypton_decaf_448_point_base;
 
+/** Precomputed table of multiples of the base point on the curve. */
+extern const struct CRYPTON_DECAF_API_VIS crypton_decaf_448_precomputed_s *crypton_decaf_448_precomputed_base;
+
+
+#else // _MSC_VER
+
+/** The scalar 1. */
+CRYPTON_DECAF_API_VIS extern const crypton_decaf_448_scalar_t crypton_decaf_448_scalar_one;
+
+/** The scalar 0. */
+CRYPTON_DECAF_API_VIS extern const crypton_decaf_448_scalar_t crypton_decaf_448_scalar_zero;
+
+/** The identity (zero) point on the curve. */
+CRYPTON_DECAF_API_VIS extern const crypton_decaf_448_point_t crypton_decaf_448_point_identity;
+
+/** An arbitrarily-chosen base point on the curve. */
+CRYPTON_DECAF_API_VIS extern const crypton_decaf_448_point_t crypton_decaf_448_point_base;
+
+/** Precomputed table of multiples of the base point on the curve. */
+CRYPTON_DECAF_API_VIS extern const struct crypton_decaf_448_precomputed_s *crypton_decaf_448_precomputed_base;
+
+#endif // _MSC_VER
 /**
  * @brief Read a scalar from wire format or from bytes.
  *
@@ -106,10 +133,10 @@
  * @retval CRYPTON_DECAF_FAILURE The scalar was greater than the modulus,
  * and has been reduced modulo that modulus.
  */
-crypton_decaf_error_t crypton_decaf_448_scalar_decode (
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_decode (
     crypton_decaf_448_scalar_t out,
     const unsigned char ser[CRYPTON_DECAF_448_SCALAR_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Read a scalar from wire format or from bytes.  Reduces mod
@@ -119,11 +146,11 @@
  * @param [in] ser_len Length of serialized form.
  * @param [out] out Deserialized form.
  */
-void crypton_decaf_448_scalar_decode_long (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_decode_long (
     crypton_decaf_448_scalar_t out,
     const unsigned char *ser,
     size_t ser_len
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
     
 /**
  * @brief Serialize a scalar to wire format.
@@ -131,10 +158,10 @@
  * @param [out] ser Serialized form of a scalar.
  * @param [in] s Deserialized scalar.
  */
-void crypton_decaf_448_scalar_encode (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_encode (
     unsigned char ser[CRYPTON_DECAF_448_SCALAR_BYTES],
     const crypton_decaf_448_scalar_t s
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE CRYPTON_DECAF_NOINLINE;
         
 /**
  * @brief Add two scalars.  The scalars may use the same memory.
@@ -142,11 +169,11 @@
  * @param [in] b Another scalar.
  * @param [out] out a+b.
  */
-void crypton_decaf_448_scalar_add (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_add (
     crypton_decaf_448_scalar_t out,
     const crypton_decaf_448_scalar_t a,
     const crypton_decaf_448_scalar_t b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Compare two scalars.
@@ -155,10 +182,10 @@
  * @retval CRYPTON_DECAF_TRUE The scalars are equal.
  * @retval CRYPTON_DECAF_FALSE The scalars are not equal.
  */    
-crypton_decaf_bool_t crypton_decaf_448_scalar_eq (
+crypton_decaf_bool_t CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_eq (
     const crypton_decaf_448_scalar_t a,
     const crypton_decaf_448_scalar_t b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Subtract two scalars.  The scalars may use the same memory.
@@ -166,11 +193,11 @@
  * @param [in] b Another scalar.
  * @param [out] out a-b.
  */  
-void crypton_decaf_448_scalar_sub (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_sub (
     crypton_decaf_448_scalar_t out,
     const crypton_decaf_448_scalar_t a,
     const crypton_decaf_448_scalar_t b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Multiply two scalars.  The scalars may use the same memory.
@@ -178,21 +205,21 @@
  * @param [in] b Another scalar.
  * @param [out] out a*b.
  */  
-void crypton_decaf_448_scalar_mul (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_mul (
     crypton_decaf_448_scalar_t out,
     const crypton_decaf_448_scalar_t a,
     const crypton_decaf_448_scalar_t b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
         
 /**
 * @brief Halve a scalar.  The scalars may use the same memory.
 * @param [in] a A scalar.
 * @param [out] out a/2.
 */
-void crypton_decaf_448_scalar_halve (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_halve (
    crypton_decaf_448_scalar_t out,
    const crypton_decaf_448_scalar_t a
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Invert a scalar.  When passed zero, return 0.  The input and output may alias.
@@ -200,10 +227,10 @@
  * @param [out] out 1/a.
  * @return CRYPTON_DECAF_SUCCESS The input is nonzero.
  */  
-crypton_decaf_error_t crypton_decaf_448_scalar_invert (
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_invert (
     crypton_decaf_448_scalar_t out,
     const crypton_decaf_448_scalar_t a
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Copy a scalar.  The scalars may use the same memory, in which
@@ -223,10 +250,10 @@
  * @param [in] a An integer.
  * @param [out] out Will become equal to a.
  */  
-void crypton_decaf_448_scalar_set_unsigned (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_set_unsigned (
     crypton_decaf_448_scalar_t out,
     uint64_t a
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL;
+) CRYPTON_DECAF_NONNULL;
 
 /**
  * @brief Encode a point as a sequence of bytes.
@@ -234,10 +261,10 @@
  * @param [out] ser The byte representation of the point.
  * @param [in] pt The point to encode.
  */
-void crypton_decaf_448_point_encode (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_encode (
     uint8_t ser[CRYPTON_DECAF_448_SER_BYTES],
     const crypton_decaf_448_point_t pt
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Decode a point from a sequence of bytes.
@@ -253,11 +280,11 @@
  * @retval CRYPTON_DECAF_FAILURE The decoding didn't succeed, because
  * ser does not represent a point.
  */
-crypton_decaf_error_t crypton_decaf_448_point_decode (
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS crypton_decaf_448_point_decode (
     crypton_decaf_448_point_t pt,
     const uint8_t ser[CRYPTON_DECAF_448_SER_BYTES],
     crypton_decaf_bool_t allow_identity
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Copy a point.  The input and output may alias,
@@ -282,10 +309,10 @@
  * @retval CRYPTON_DECAF_TRUE The points are equal.
  * @retval CRYPTON_DECAF_FALSE The points are not equal.
  */
-crypton_decaf_bool_t crypton_decaf_448_point_eq (
+crypton_decaf_bool_t CRYPTON_DECAF_API_VIS crypton_decaf_448_point_eq (
     const crypton_decaf_448_point_t a,
     const crypton_decaf_448_point_t b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Add two points to produce a third point.  The
@@ -296,11 +323,11 @@
  * @param [in] a An addend.
  * @param [in] b An addend.
  */
-void crypton_decaf_448_point_add (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_add (
     crypton_decaf_448_point_t sum,
     const crypton_decaf_448_point_t a,
     const crypton_decaf_448_point_t b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL;
+) CRYPTON_DECAF_NONNULL;
 
 /**
  * @brief Double a point.  Equivalent to
@@ -309,10 +336,10 @@
  * @param [out] two_a The sum a+a.
  * @param [in] a A point.
  */
-void crypton_decaf_448_point_double (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_double (
     crypton_decaf_448_point_t two_a,
     const crypton_decaf_448_point_t a
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL;
+) CRYPTON_DECAF_NONNULL;
 
 /**
  * @brief Subtract two points to produce a third point.  The
@@ -323,11 +350,11 @@
  * @param [in] a The minuend.
  * @param [in] b The subtrahend.
  */
-void crypton_decaf_448_point_sub (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_sub (
     crypton_decaf_448_point_t diff,
     const crypton_decaf_448_point_t a,
     const crypton_decaf_448_point_t b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL;
+) CRYPTON_DECAF_NONNULL;
     
 /**
  * @brief Negate a point to produce another point.  The input
@@ -336,10 +363,10 @@
  * @param [out] nega The negated input point
  * @param [in] a The input point.
  */
-void crypton_decaf_448_point_negate (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_negate (
    crypton_decaf_448_point_t nega,
    const crypton_decaf_448_point_t a
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL;
+) CRYPTON_DECAF_NONNULL;
 
 /**
  * @brief Multiply a base point by a scalar: scaled = scalar*base.
@@ -348,11 +375,11 @@
  * @param [in] base The point to be scaled.
  * @param [in] scalar The scalar to multiply by.
  */
-void crypton_decaf_448_point_scalarmul (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_scalarmul (
     crypton_decaf_448_point_t scaled,
     const crypton_decaf_448_point_t base,
     const crypton_decaf_448_scalar_t scalar
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Multiply a base point by a scalar: scaled = scalar*base.
@@ -371,34 +398,64 @@
  * @retval CRYPTON_DECAF_FAILURE The scalarmul didn't succeed, because
  * base does not represent a point.
  */
-crypton_decaf_error_t crypton_decaf_448_direct_scalarmul (
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS crypton_decaf_448_direct_scalarmul (
     uint8_t scaled[CRYPTON_DECAF_448_SER_BYTES],
     const uint8_t base[CRYPTON_DECAF_448_SER_BYTES],
     const crypton_decaf_448_scalar_t scalar,
     crypton_decaf_bool_t allow_identity,
     crypton_decaf_bool_t short_circuit
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NOINLINE;
 
 /**
- * @brief RFC 7748 Diffie-Hellman scalarmul.  This function uses a different
- * (non-Decaf) encoding.
+ * @brief RFC 7748 Diffie-Hellman scalarmul, used to compute shared secrets.
+ * This function uses a different (non-Decaf) encoding.
  *
- * @param [out] scaled The scaled point base*scalar
- * @param [in] base The point to be scaled.
- * @param [in] scalar The scalar to multiply by.
+ * @param [out] shared The shared secret base*scalar
+ * @param [in] base The other party's public key, used as the base of the scalarmul.
+ * @param [in] scalar The private scalar to multiply by.
  *
  * @retval CRYPTON_DECAF_SUCCESS The scalarmul succeeded.
  * @retval CRYPTON_DECAF_FAILURE The scalarmul didn't succeed, because the base
  * point is in a small subgroup.
  */
-crypton_decaf_error_t crypton_decaf_x448 (
-    uint8_t out[CRYPTON_DECAF_X448_PUBLIC_BYTES],
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS crypton_decaf_x448 (
+    uint8_t shared[CRYPTON_DECAF_X448_PUBLIC_BYTES],
     const uint8_t base[CRYPTON_DECAF_X448_PUBLIC_BYTES],
     const uint8_t scalar[CRYPTON_DECAF_X448_PRIVATE_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NOINLINE;
 
+/**
+ * @brief Multiply a point by CRYPTON_DECAF_X448_ENCODE_RATIO,
+ * then encode it like RFC 7748.
+ *
+ * This function is mainly used internally, but is exported in case
+ * it will be useful.
+ *
+ * The ratio is necessary because the internal representation doesn't
+ * track the cofactor information, so on output we must clear the cofactor.
+ * This would multiply by the cofactor, but in fact internally libdecaf's
+ * points are always even, so it multiplies by half the cofactor instead.
+ *
+ * As it happens, this aligns with the base point definitions; that is,
+ * if you pass the Decaf/Ristretto base point to this function, the result
+ * will be CRYPTON_DECAF_X448_ENCODE_RATIO times the X448
+ * base point.
+ *
+ * @param [out] out The scaled and encoded point.
+ * @param [in] p The point to be scaled and encoded.
+ */
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_mul_by_ratio_and_encode_like_x448 (
+    uint8_t out[CRYPTON_DECAF_X448_PUBLIC_BYTES],
+    const crypton_decaf_448_point_t p
+) CRYPTON_DECAF_NONNULL;
+
 /** The base point for X448 Diffie-Hellman */
-extern const uint8_t crypton_decaf_x448_base_point[CRYPTON_DECAF_X448_PUBLIC_BYTES] CRYPTON_DECAF_API_VIS;
+extern const uint8_t
+#ifndef DOXYGEN
+    /* For some reason Doxygen chokes on this despite the defense in common.h... */
+    CRYPTON_DECAF_API_VIS
+#endif
+    crypton_decaf_x448_base_point[CRYPTON_DECAF_X448_PUBLIC_BYTES];
 
 /**
  * @brief RFC 7748 Diffie-Hellman base point scalarmul.  This function uses
@@ -407,13 +464,13 @@
  * @deprecated Renamed to crypton_decaf_x448_derive_public_key.
  * I have no particular timeline for removing this name.
  *
- * @param [out] scaled The scaled point base*scalar
- * @param [in] scalar The scalar to multiply by.
+ * @param [out] out The public key base*scalar.
+ * @param [in] scalar The private scalar.
  */
-void crypton_decaf_x448_generate_key (
+void CRYPTON_DECAF_API_VIS crypton_decaf_x448_generate_key (
     uint8_t out[CRYPTON_DECAF_X448_PUBLIC_BYTES],
     const uint8_t scalar[CRYPTON_DECAF_X448_PRIVATE_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE CRYPTON_DECAF_DEPRECATED("Renamed to crypton_decaf_x448_derive_public_key");
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE CRYPTON_DECAF_DEPRECATED("Renamed to crypton_decaf_x448_derive_public_key");
     
 /**
  * @brief RFC 7748 Diffie-Hellman base point scalarmul.  This function uses
@@ -422,13 +479,13 @@
  * Does exactly the same thing as crypton_decaf_x448_generate_key,
  * but has a better name.
  *
- * @param [out] scaled The scaled point base*scalar
- * @param [in] scalar The scalar to multiply by.
+ * @param [out] out The public key base*scalar
+ * @param [in] scalar The private scalar.
  */
-void crypton_decaf_x448_derive_public_key (
+void CRYPTON_DECAF_API_VIS crypton_decaf_x448_derive_public_key (
     uint8_t out[CRYPTON_DECAF_X448_PUBLIC_BYTES],
     const uint8_t scalar[CRYPTON_DECAF_X448_PRIVATE_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /* FUTURE: uint8_t crypton_decaf_448_encode_like_curve448) */
 
@@ -441,10 +498,10 @@
  * @param [out] a A precomputed table of multiples of the point.
  * @param [in] b Any point.
  */
-void crypton_decaf_448_precompute (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_precompute (
     crypton_decaf_448_precomputed_s *a,
     const crypton_decaf_448_point_t b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Multiply a precomputed base point by a scalar:
@@ -457,11 +514,11 @@
  * @param [in] base The point to be scaled.
  * @param [in] scalar The scalar to multiply by.
  */
-void crypton_decaf_448_precomputed_scalarmul (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_precomputed_scalarmul (
     crypton_decaf_448_point_t scaled,
     const crypton_decaf_448_precomputed_s *base,
     const crypton_decaf_448_scalar_t scalar
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Multiply two base points by two scalars:
@@ -476,13 +533,13 @@
  * @param [in] base2 A second point to be scaled.
  * @param [in] scalar2 A second scalar to multiply by.
  */
-void crypton_decaf_448_point_double_scalarmul (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_double_scalarmul (
     crypton_decaf_448_point_t combo,
     const crypton_decaf_448_point_t base1,
     const crypton_decaf_448_scalar_t scalar1,
     const crypton_decaf_448_point_t base2,
     const crypton_decaf_448_scalar_t scalar2
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
     
 /**
  * Multiply one base point by two scalars:
@@ -499,13 +556,13 @@
  * @param [in] scalar1 A first scalar to multiply by.
  * @param [in] scalar2 A second scalar to multiply by.
  */
-void crypton_decaf_448_point_dual_scalarmul (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_dual_scalarmul (
     crypton_decaf_448_point_t a1,
     crypton_decaf_448_point_t a2,
     const crypton_decaf_448_point_t base1,
     const crypton_decaf_448_scalar_t scalar1,
     const crypton_decaf_448_scalar_t scalar2
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Multiply two base points by two scalars:
@@ -522,12 +579,12 @@
  * @warning: This function takes variable time, and may leak the scalars
  * used.  It is designed for signature verification.
  */
-void crypton_decaf_448_base_double_scalarmul_non_secret (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_base_double_scalarmul_non_secret (
     crypton_decaf_448_point_t combo,
     const crypton_decaf_448_scalar_t scalar1,
     const crypton_decaf_448_point_t base2,
     const crypton_decaf_448_scalar_t scalar2
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Constant-time decision between two points.  If pick_b
@@ -538,12 +595,12 @@
  * @param [in] b Any point.
  * @param [in] pick_b If nonzero, choose point b.
  */
-void crypton_decaf_448_point_cond_sel (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_cond_sel (
     crypton_decaf_448_point_t out,
     const crypton_decaf_448_point_t a,
     const crypton_decaf_448_point_t b,
     crypton_decaf_word_t pick_b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Constant-time decision between two scalars.  If pick_b
@@ -554,12 +611,12 @@
  * @param [in] b Any scalar.
  * @param [in] pick_b If nonzero, choose scalar b.
  */
-void crypton_decaf_448_scalar_cond_sel (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_cond_sel (
     crypton_decaf_448_scalar_t out,
     const crypton_decaf_448_scalar_t a,
     const crypton_decaf_448_scalar_t b,
     crypton_decaf_word_t pick_b
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Test that a point is valid, for debugging purposes.
@@ -568,9 +625,9 @@
  * @retval CRYPTON_DECAF_TRUE The point is valid.
  * @retval CRYPTON_DECAF_FALSE The point is invalid.
  */
-crypton_decaf_bool_t crypton_decaf_448_point_valid (
+crypton_decaf_bool_t CRYPTON_DECAF_API_VIS crypton_decaf_448_point_valid (
     const crypton_decaf_448_point_t to_test
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_WARN_UNUSED CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Torque a point, for debugging purposes.  The output
@@ -579,10 +636,10 @@
  * @param [out] q The point to torque.
  * @param [in] p The point to torque.
  */
-void crypton_decaf_448_point_debugging_torque (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_debugging_torque (
     crypton_decaf_448_point_t q,
     const crypton_decaf_448_point_t p
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Projectively scale a point, for debugging purposes.
@@ -593,11 +650,11 @@
  * @param [in] p The point to scale.
  * @param [in] factor Serialized GF factor to scale.
  */
-void crypton_decaf_448_point_debugging_pscale (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_debugging_pscale (
     crypton_decaf_448_point_t q,
     const crypton_decaf_448_point_t p,
     const unsigned char factor[CRYPTON_DECAF_448_SER_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Almost-Elligator-like hash to curve.
@@ -627,11 +684,11 @@
  * @param [in] hashed_data Output of some hash function.
  * @param [out] pt The data hashed to the curve.
  */
-void
+void CRYPTON_DECAF_API_VIS
 crypton_decaf_448_point_from_hash_nonuniform (
     crypton_decaf_448_point_t pt,
     const unsigned char hashed_data[CRYPTON_DECAF_448_HASH_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Indifferentiable hash function encoding to curve.
@@ -641,10 +698,10 @@
  * @param [in] hashed_data Output of some hash function.
  * @param [out] pt The data hashed to the curve.
  */ 
-void crypton_decaf_448_point_from_hash_uniform (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_from_hash_uniform (
     crypton_decaf_448_point_t pt,
     const unsigned char hashed_data[2*CRYPTON_DECAF_448_HASH_BYTES]
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE;
 
 /**
  * @brief Inverse of elligator-like hash to curve.
@@ -656,6 +713,16 @@
  * inverse sampling, this function succeeds or fails
  * independently for different "which" values.
  *
+ * This function isn't guaranteed to find every possible
+ * preimage, but it finds all except a small finite number.
+ * In particular, when the number of bits in the modulus isn't
+ * a multiple of 8 (i.e. for curve25519), it sets the high bits
+ * independently, which enables the generated data to be uniform.
+ * But it doesn't add p, so you'll never get exactly p from this
+ * function.  This might change in the future, especially if
+ * we ever support eg Brainpool curves, where this could cause
+ * real nonuniformity.
+ *
  * @param [out] recovered_hash Encoded data.
  * @param [in] pt The point to encode.
  * @param [in] which A value determining which inverse point
@@ -664,12 +731,12 @@
  * @retval CRYPTON_DECAF_SUCCESS The inverse succeeded.
  * @retval CRYPTON_DECAF_FAILURE The inverse failed.
  */
-crypton_decaf_error_t
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS
 crypton_decaf_448_invert_elligator_nonuniform (
     unsigned char recovered_hash[CRYPTON_DECAF_448_HASH_BYTES],
     const crypton_decaf_448_point_t pt,
     uint32_t which
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE CRYPTON_DECAF_WARN_UNUSED;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE CRYPTON_DECAF_WARN_UNUSED;
 
 /**
  * @brief Inverse of elligator-like hash to curve.
@@ -689,33 +756,31 @@
  * @retval CRYPTON_DECAF_SUCCESS The inverse succeeded.
  * @retval CRYPTON_DECAF_FAILURE The inverse failed.
  */
-crypton_decaf_error_t
+crypton_decaf_error_t CRYPTON_DECAF_API_VIS
 crypton_decaf_448_invert_elligator_uniform (
     unsigned char recovered_hash[2*CRYPTON_DECAF_448_HASH_BYTES],
     const crypton_decaf_448_point_t pt,
     uint32_t which
-) CRYPTON_DECAF_API_VIS CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE CRYPTON_DECAF_WARN_UNUSED;
+) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_NOINLINE CRYPTON_DECAF_WARN_UNUSED;
 
-/**
- * @brief Overwrite scalar with zeros.
- */
-void crypton_decaf_448_scalar_destroy (
+/** Securely erase a scalar. */
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_scalar_destroy (
     crypton_decaf_448_scalar_t scalar
-) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_API_VIS;
+) CRYPTON_DECAF_NONNULL;
 
-/**
- * @brief Overwrite point with zeros.
+/** Securely erase a point by overwriting it with zeros.
+ * @warning This causes the point object to become invalid.
  */
-void crypton_decaf_448_point_destroy (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_point_destroy (
     crypton_decaf_448_point_t point
-) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_API_VIS;
+) CRYPTON_DECAF_NONNULL;
 
-/**
- * @brief Overwrite precomputed table with zeros.
+/** Securely erase a precomputed table by overwriting it with zeros.
+ * @warning This causes the table object to become invalid.
  */
-void crypton_decaf_448_precomputed_destroy (
+void CRYPTON_DECAF_API_VIS crypton_decaf_448_precomputed_destroy (
     crypton_decaf_448_precomputed_s *pre
-) CRYPTON_DECAF_NONNULL CRYPTON_DECAF_API_VIS;
+) CRYPTON_DECAF_NONNULL;
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/cbits/decaf/include/field.h b/cbits/decaf/include/field.h
--- a/cbits/decaf/include/field.h
+++ b/cbits/decaf/include/field.h
@@ -103,5 +103,10 @@
 #endif
 }
 
+#if P_MOD_8 == 5
+#define crypton_gf_mul_i crypton_gf_mul_qnr
+#define crypton_gf_div_i crypton_gf_div_qnr
+#endif
+
 
 #endif // __GF_H__
diff --git a/cbits/decaf/include/word.h b/cbits/decaf/include/word.h
--- a/cbits/decaf/include/word.h
+++ b/cbits/decaf/include/word.h
@@ -13,6 +13,11 @@
 extern int posix_memalign(void **, size_t, size_t);
 #endif
 
+// MSVC has no posix_memalign
+#if defined(_MSC_VER)
+#define posix_memalign(p, a, s) (((*(p)) = _aligned_malloc((s), (a))), *(p) ?0 :errno)
+#endif
+
 #include <assert.h>
 #include <stdint.h>
 #include "arch_intrinsics.h"
@@ -58,6 +63,22 @@
 #else
     #error "For now, libdecaf only supports 32- and 64-bit architectures."
 #endif
+
+/**
+ * Expand bit 0 of the given uint8_t to a mask_t all 1 or all 0
+ * The input must be either 0 or 1
+ */
+CRYPTON_DECAF_INLINE mask_t bit_to_mask(uint8_t bit) {
+#ifdef _MSC_VER
+#pragma warning ( push)
+#pragma warning ( disable : 4146)
+#endif
+	return -(mask_t)bit;
+#ifdef _MSC_VER
+#pragma warning ( pop)
+#endif
+
+}
     
 /* Scalar limbs are keyed off of the API word size instead of the arch word size. */
 #if CRYPTON_DECAF_WORD_BITS == 64
@@ -130,7 +151,7 @@
     br_set_to_mask(mask_t x) {
         return vdupq_n_u32(x);
     }
-#elif _WIN64 || __amd64__ || __X86_64__ || __aarch64__
+#elif __amd64__ || __X86_64__ || __aarch64__ || __loongarch_lp64 || __PPC64__ || __riscv ||  __s390x__ || __alpha__ || __powerpc64__ || (__sparc__ && __arch64__) /* || _WIN64 -> WIN64 does not support int128 so force the build on arch32 default so do not use this define for _WIN64*/
     #define VECTOR_ALIGNED __attribute__((aligned(8)))
     typedef uint64_t big_register_t, uint64xn_t;
 
diff --git a/cbits/decaf/p448/arch_32/f_impl.c b/cbits/decaf/p448/arch_32/f_impl.c
--- a/cbits/decaf/p448/arch_32/f_impl.c
+++ b/cbits/decaf/p448/arch_32/f_impl.c
@@ -88,11 +88,11 @@
 
     accum0 += accum8 + c[8];
     c[8] = accum0 & mask;
-    c[9] += accum0 >> 28;
+    c[9] += (uint32_t)(accum0 >> 28);
 
     accum8 += c[0];
     c[0] = accum8 & mask;
-    c[1] += accum8 >> 28;
+    c[1] += (uint32_t)(accum8 >> 28);
 }
 
 void crypton_gf_sqr (crypton_gf_s *__restrict__ cs, const gf as) {
diff --git a/cbits/decaf/p448/f_field.h b/cbits/decaf/p448/f_field.h
--- a/cbits/decaf/p448/f_field.h
+++ b/cbits/decaf/p448/f_field.h
@@ -23,11 +23,10 @@
 
 #define __CRYPTON_DECAF_448_GF_DEFINED__ 1
 #define NLIMBS (64/sizeof(word_t))
-#define X_SER_BYTES 56
 #define SER_BYTES 56
 typedef struct crypton_gf_448_s {
     word_t limb[NLIMBS];
-} __attribute__((aligned(16))) crypton_gf_448_s, crypton_gf_448_t[1];
+} __attribute__((aligned(32))) crypton_gf_448_s, crypton_gf_448_t[1];
 
 #define GF_LIT_LIMB_BITS  56
 #define GF_BITS           448
@@ -37,7 +36,7 @@
 #define gf                crypton_gf_448_t
 #define crypton_gf_s              crypton_gf_448_s
 #define crypton_gf_eq             crypton_gf_448_eq
-#define crypton_gf_hibit          crypton_gf_448_hibit
+#define crypton_gf_lobit          crypton_gf_448_lobit
 #define crypton_gf_copy           crypton_gf_448_copy
 #define crypton_gf_add            crypton_gf_448_add
 #define crypton_gf_sub            crypton_gf_448_sub
@@ -54,7 +53,7 @@
 #define crypton_gf_deserialize    crypton_gf_448_deserialize
 
 /* RFC 7748 support */
-#define X_PUBLIC_BYTES  X_SER_BYTES
+#define X_PUBLIC_BYTES  SER_BYTES
 #define X_PRIVATE_BYTES X_PUBLIC_BYTES
 #define X_PRIVATE_BITS  448
 
@@ -81,10 +80,10 @@
 void crypton_gf_sqr (crypton_gf_s *__restrict__ out, const gf a);
 mask_t crypton_gf_isr(gf a, const gf x); /** a^2 x = 1, QNR, or 0 if x=0.  Return true if successful */
 mask_t crypton_gf_eq (const gf x, const gf y);
-mask_t crypton_gf_hibit (const gf x);
+mask_t crypton_gf_lobit (const gf x);
 
-void crypton_gf_serialize (uint8_t *serial, const gf x,int with_highbit);
-mask_t crypton_gf_deserialize (gf x, const uint8_t serial[SER_BYTES],int with_highbit);
+void crypton_gf_serialize (uint8_t serial[SER_BYTES], const gf x);
+mask_t crypton_gf_deserialize (gf x, const uint8_t serial[SER_BYTES],uint8_t hi_nmask);
 
 
 #ifdef __cplusplus
diff --git a/cbits/decaf/p448/f_generic.c b/cbits/decaf/p448/f_generic.c
--- a/cbits/decaf/p448/f_generic.c
+++ b/cbits/decaf/p448/f_generic.c
@@ -24,52 +24,52 @@
 #endif
 
 /** Serialize to wire format. */
-void crypton_gf_serialize (uint8_t serial[SER_BYTES], const gf x, int with_hibit) {
+void crypton_gf_serialize (uint8_t serial[SER_BYTES], const gf x) {
     gf red;
     crypton_gf_copy(red, x);
     crypton_gf_strong_reduce(red);
-    if (!with_hibit) { assert(crypton_gf_hibit(red) == 0); }
     
     unsigned int j=0, fill=0;
     dword_t buffer = 0;
-    UNROLL for (unsigned int i=0; i<(with_hibit ? X_SER_BYTES : SER_BYTES); i++) {
+    UNROLL for (unsigned int i=0; i<SER_BYTES; i++) {
         if (fill < 8 && j < NLIMBS) {
             buffer |= ((dword_t)red->limb[LIMBPERM(j)]) << fill;
             fill += LIMB_PLACE_VALUE(LIMBPERM(j));
             j++;
         }
-        serial[i] = buffer;
+        serial[i] = (uint8_t)buffer;
         fill -= 8;
         buffer >>= 8;
     }
 }
 
 /** Return high bit of x = low bit of 2x mod p */
-mask_t crypton_gf_hibit(const gf x) {
+mask_t crypton_gf_lobit(const gf x) {
     gf y;
-    crypton_gf_add(y,x,x);
+    crypton_gf_copy(y,x);
     crypton_gf_strong_reduce(y);
-    return -(y->limb[0]&1);
+    return bit_to_mask((y->limb[0]) & 1);
 }
 
 /** Deserialize from wire format; return -1 on success and 0 on failure. */
-mask_t crypton_gf_deserialize (gf x, const uint8_t serial[SER_BYTES], int with_hibit) {
+mask_t crypton_gf_deserialize (gf x, const uint8_t serial[SER_BYTES], uint8_t hi_nmask) {
     unsigned int j=0, fill=0;
     dword_t buffer = 0;
     dsword_t scarry = 0;
     UNROLL for (unsigned int i=0; i<NLIMBS; i++) {
-        UNROLL while (fill < LIMB_PLACE_VALUE(LIMBPERM(i)) && j < (with_hibit ? X_SER_BYTES : SER_BYTES)) {
-            buffer |= ((dword_t)serial[j]) << fill;
+        UNROLL while (fill < (unsigned int)(LIMB_PLACE_VALUE(LIMBPERM(i))) && j < SER_BYTES) {
+            uint8_t sj = serial[j];
+            if (j==SER_BYTES-1) sj &= ~hi_nmask;
+            buffer |= ((dword_t)sj) << fill;
             fill += 8;
             j++;
         }
-        x->limb[LIMBPERM(i)] = (i<NLIMBS-1) ? buffer & LIMB_MASK(LIMBPERM(i)) : buffer;
+        x->limb[LIMBPERM(i)] = (word_t)((i<NLIMBS-1) ? buffer & LIMB_MASK(LIMBPERM(i)) : buffer);
         fill -= LIMB_PLACE_VALUE(LIMBPERM(i));
         buffer >>= LIMB_PLACE_VALUE(LIMBPERM(i));
         scarry = (scarry + x->limb[LIMBPERM(i)] - MODULUS->limb[LIMBPERM(i)]) >> (8*sizeof(word_t));
     }
-    mask_t succ = with_hibit ? -(mask_t)1 : ~crypton_gf_hibit(x);
-    return succ & word_is_zero(buffer) & ~word_is_zero(scarry);
+    return word_is_zero((word_t)buffer) & ~word_is_zero((word_t)scarry);
 }
 
 /** Reduce to canonical form. */
@@ -91,9 +91,9 @@
      * common case: it was < p, so now scarry = -1 and this = x - p + 2^255
      * so let's add back in p.  will carry back off the top for 2^255.
      */
-    assert(word_is_zero(scarry) | word_is_zero(scarry+1));
+    assert(word_is_zero((word_t)scarry) | word_is_zero((word_t)scarry+1));
 
-    word_t scarry_0 = scarry;
+    word_t scarry_0 = (word_t)scarry;
     dword_t carry = 0;
 
     /* add it back */
@@ -103,7 +103,7 @@
         carry >>= LIMB_PLACE_VALUE(LIMBPERM(i));
     }
 
-    assert(word_is_zero(carry + scarry_0));
+    assert(word_is_zero((word_t)(carry) + scarry_0));
 }
 
 /** Subtract two gf elements d=a-b */
diff --git a/crypton.cabal b/crypton.cabal
--- a/crypton.cabal
+++ b/crypton.cabal
@@ -1,13 +1,15 @@
 cabal-version:      1.18
 name:               crypton
-version:            0.34
+version:            1.1.4
 license:            BSD3
 license-file:       LICENSE
 copyright:          Vincent Hanquez <vincent@snarc.org>
 maintainer:         Kazu Yamamoto <kazu@iij.ad.jp>
 author:             Vincent Hanquez <vincent@snarc.org>
 stability:          experimental
-tested-with:        ghc ==9.2.2 ghc ==9.0.2 ghc ==8.10.7 ghc ==8.8.4
+tested-with:
+    ghc ==9.2.8 || ==9.4.8 || ==9.6.7 || ==9.8.4 || ==9.10.1 || ==9.12.1
+
 homepage:           https://github.com/kazu-yamamoto/crypton
 bug-reports:        https://github.com/kazu-yamamoto/crypton/issues
 synopsis:           Cryptography Primitives sink
@@ -41,29 +43,29 @@
 extra-source-files:
     cbits/*.h
     cbits/aes/*.h
-    cbits/ed25519/*.h
+    cbits/aes/x86ni_impl.c
+    cbits/argon2/*.c
+    cbits/argon2/*.h
+    cbits/blake2/ref/*.h
+    cbits/blake2/sse/*.h
+    cbits/crypton_hash_prefix.c
+    cbits/decaf/ed448goldilocks/decaf.c
+    cbits/decaf/ed448goldilocks/decaf_tables.c
     cbits/decaf/include/*.h
-    cbits/decaf/include/decaf/*.h
     cbits/decaf/include/arch_32/*.h
     cbits/decaf/include/arch_ref64/*.h
+    cbits/decaf/include/decaf/*.h
+    cbits/decaf/p448/*.h
     cbits/decaf/p448/arch_32/*.h
     cbits/decaf/p448/arch_ref64/*.h
-    cbits/decaf/p448/*.h
-    cbits/decaf/ed448goldilocks/decaf_tables.c
-    cbits/decaf/ed448goldilocks/decaf.c
+    cbits/ed25519/*.h
     cbits/include32/p256/*.h
     cbits/include64/p256/*.h
-    cbits/blake2/ref/*.h
-    cbits/blake2/sse/*.h
-    cbits/argon2/*.h
-    cbits/argon2/*.c
-    cbits/aes/x86ni_impl.c
-    cbits/crypton_hash_prefix.c
     tests/*.hs
 
 extra-doc-files:
-    README.md
     CHANGELOG.md
+    README.md
 
 source-repository head
     type:     git
@@ -125,8 +127,8 @@
         Crypto.Cipher.AES
         Crypto.Cipher.AESGCMSIV
         Crypto.Cipher.Blowfish
-        Crypto.Cipher.CAST5
         Crypto.Cipher.Camellia
+        Crypto.Cipher.CAST5
         Crypto.Cipher.ChaCha
         Crypto.Cipher.ChaChaPoly1305
         Crypto.Cipher.DES
@@ -143,11 +145,20 @@
         Crypto.ECC
         Crypto.ECC.Edwards25519
         Crypto.Error
+        Crypto.Hash
+        Crypto.Hash.Algorithms
+        Crypto.Hash.IO
+        Crypto.KDF.Argon2
+        Crypto.KDF.BCrypt
+        Crypto.KDF.BCryptPBKDF
+        Crypto.KDF.HKDF
+        Crypto.KDF.PBKDF2
+        Crypto.KDF.Scrypt
         Crypto.MAC.CMAC
-        Crypto.MAC.Poly1305
         Crypto.MAC.HMAC
         Crypto.MAC.KeyedBlake2
         Crypto.MAC.KMAC
+        Crypto.MAC.Poly1305
         Crypto.Number.Basic
         Crypto.Number.F2m
         Crypto.Number.Generate
@@ -155,91 +166,82 @@
         Crypto.Number.Nat
         Crypto.Number.Prime
         Crypto.Number.Serialize
-        Crypto.Number.Serialize.LE
         Crypto.Number.Serialize.Internal
         Crypto.Number.Serialize.Internal.LE
-        Crypto.KDF.Argon2
-        Crypto.KDF.PBKDF2
-        Crypto.KDF.Scrypt
-        Crypto.KDF.BCrypt
-        Crypto.KDF.BCryptPBKDF
-        Crypto.KDF.HKDF
-        Crypto.Hash
-        Crypto.Hash.IO
-        Crypto.Hash.Algorithms
+        Crypto.Number.Serialize.LE
         Crypto.OTP
         Crypto.PubKey.Curve25519
         Crypto.PubKey.Curve448
-        Crypto.PubKey.MaskGenFunction
         Crypto.PubKey.DH
         Crypto.PubKey.DSA
-        Crypto.PubKey.ECC.Generate
-        Crypto.PubKey.ECC.Prim
         Crypto.PubKey.ECC.DH
         Crypto.PubKey.ECC.ECDSA
+        Crypto.PubKey.ECC.Generate
         Crypto.PubKey.ECC.P256
+        Crypto.PubKey.ECC.Prim
         Crypto.PubKey.ECC.Types
         Crypto.PubKey.ECDSA
         Crypto.PubKey.ECIES
         Crypto.PubKey.Ed25519
         Crypto.PubKey.Ed448
         Crypto.PubKey.EdDSA
+        Crypto.PubKey.MaskGenFunction
+        Crypto.PubKey.Rabin.Basic
+        Crypto.PubKey.Rabin.Modified
+        Crypto.PubKey.Rabin.OAEP
+        Crypto.PubKey.Rabin.RW
+        Crypto.PubKey.Rabin.Types
         Crypto.PubKey.RSA
+        Crypto.PubKey.RSA.OAEP
         Crypto.PubKey.RSA.PKCS15
         Crypto.PubKey.RSA.Prim
         Crypto.PubKey.RSA.PSS
-        Crypto.PubKey.RSA.OAEP
         Crypto.PubKey.RSA.Types
-        Crypto.PubKey.Rabin.OAEP
-        Crypto.PubKey.Rabin.Basic
-        Crypto.PubKey.Rabin.Modified
-        Crypto.PubKey.Rabin.RW
-        Crypto.PubKey.Rabin.Types
         Crypto.Random
-        Crypto.Random.Types
         Crypto.Random.Entropy
-        Crypto.Random.EntropyPool
         Crypto.Random.Entropy.Unsafe
+        Crypto.Random.EntropyPool
+        Crypto.Random.Types
         Crypto.System.CPU
         Crypto.Tutorial
 
     cc-options:       -std=gnu99
     c-sources:
-        cbits/crypton_chacha.c
-        cbits/crypton_salsa.c
-        cbits/crypton_xsalsa.c
-        cbits/crypton_rc4.c
-        cbits/crypton_cpu.c
-        cbits/p256/p256.c
-        cbits/p256/p256_ec.c
-        cbits/crypton_blake2s.c
-        cbits/crypton_blake2sp.c
+        cbits/argon2/argon2.c
         cbits/crypton_blake2b.c
         cbits/crypton_blake2bp.c
-        cbits/crypton_poly1305.c
-        cbits/crypton_sha1.c
-        cbits/crypton_sha256.c
-        cbits/crypton_sha512.c
-        cbits/crypton_sha3.c
+        cbits/crypton_blake2s.c
+        cbits/crypton_blake2sp.c
+        cbits/crypton_chacha.c
+        cbits/crypton_cpu.c
         cbits/crypton_md2.c
         cbits/crypton_md4.c
         cbits/crypton_md5.c
+        cbits/crypton_pbkdf2.c
+        cbits/crypton_poly1305.c
+        cbits/crypton_rc4.c
         cbits/crypton_ripemd.c
+        cbits/crypton_salsa.c
+        cbits/crypton_scrypt.c
+        cbits/crypton_sha1.c
+        cbits/crypton_sha256.c
+        cbits/crypton_sha3.c
+        cbits/crypton_sha512.c
         cbits/crypton_skein256.c
         cbits/crypton_skein512.c
         cbits/crypton_tiger.c
         cbits/crypton_whirlpool.c
-        cbits/crypton_scrypt.c
-        cbits/crypton_pbkdf2.c
+        cbits/crypton_xsalsa.c
         cbits/ed25519/ed25519.c
-        cbits/argon2/argon2.c
+        cbits/p256/p256.c
+        cbits/p256/p256_ec.c
 
     other-modules:
         Crypto.Cipher.AES.Primitive
         Crypto.Cipher.Blowfish.Box
         Crypto.Cipher.Blowfish.Primitive
-        Crypto.Cipher.CAST5.Primitive
         Crypto.Cipher.Camellia.Primitive
+        Crypto.Cipher.CAST5.Primitive
         Crypto.Cipher.DES.Primitive
         Crypto.Cipher.Twofish.Primitive
         Crypto.Cipher.Types.AEAD
@@ -248,49 +250,51 @@
         Crypto.Cipher.Types.GF
         Crypto.Cipher.Types.Stream
         Crypto.Cipher.Types.Utils
+        Crypto.ECC.Simple.Prim
+        Crypto.ECC.Simple.Types
         Crypto.Error.Types
-        Crypto.Number.Compat
-        Crypto.Hash.Types
         Crypto.Hash.Blake2
-        Crypto.Hash.Blake2s
-        Crypto.Hash.Blake2sp
         Crypto.Hash.Blake2b
         Crypto.Hash.Blake2bp
+        Crypto.Hash.Blake2s
+        Crypto.Hash.Blake2sp
+        Crypto.Hash.Keccak
+        Crypto.Hash.MD2
+        Crypto.Hash.MD4
+        Crypto.Hash.MD5
+        Crypto.Hash.RIPEMD160
         Crypto.Hash.SHA1
         Crypto.Hash.SHA224
         Crypto.Hash.SHA256
+        Crypto.Hash.SHA3
         Crypto.Hash.SHA384
         Crypto.Hash.SHA512
         Crypto.Hash.SHA512t
-        Crypto.Hash.SHA3
         Crypto.Hash.SHAKE
-        Crypto.Hash.Keccak
-        Crypto.Hash.MD2
-        Crypto.Hash.MD4
-        Crypto.Hash.MD5
-        Crypto.Hash.RIPEMD160
         Crypto.Hash.Skein256
         Crypto.Hash.Skein512
         Crypto.Hash.Tiger
+        Crypto.Hash.Types
         Crypto.Hash.Whirlpool
-        Crypto.Random.Entropy.Source
-        Crypto.Random.Entropy.Backend
-        Crypto.Random.ChaChaDRG
-        Crypto.Random.SystemDRG
-        Crypto.Random.Probabilistic
-        Crypto.PubKey.Internal
-        Crypto.PubKey.ElGamal
-        Crypto.ECC.Simple.Types
-        Crypto.ECC.Simple.Prim
         Crypto.Internal.Builder
         Crypto.Internal.ByteArray
         Crypto.Internal.Compat
         Crypto.Internal.CompatPrim
         Crypto.Internal.DeepSeq
+        Crypto.Internal.Endian
         Crypto.Internal.Imports
         Crypto.Internal.Nat
-        Crypto.Internal.Words
         Crypto.Internal.WordArray
+        Crypto.Internal.Words
+        Crypto.Number.Compat
+        Crypto.PubKey.ElGamal
+        Crypto.PubKey.Internal
+        Crypto.Random.ChaChaDRG
+        Crypto.Random.Entropy.Backend
+        Crypto.Random.Entropy.Source
+        Crypto.Random.HmacDRG
+        Crypto.Random.Probabilistic
+        Crypto.Random.SystemDRG
 
     default-language: Haskell2010
     include-dirs:
@@ -299,60 +303,55 @@
 
     ghc-options:      -Wall -fwarn-tabs -optc-O3
     build-depends:
+        base >=4.13 && <5,
         bytestring,
-        memory >=0.14.18,
-        basement >=0.0.6,
-        ghc-prim
-
-    if impl(ghc <8.8)
-        buildable: False
-
-    else
-        build-depends: base
-
-    if os(linux)
-        extra-libraries: pthread
+        primitive >=0.9,
+        deepseq,
+        base16 >=1.0,
+        bytestring,
+        text,
+        ram >=0.20.1 && <0.23
 
     if flag(old_toolchain_inliner)
         cc-options: -fgnu89-inline
 
-    if (arch(x86_64) || arch(aarch64))
+    if ((((((((arch(x86_64) || arch(aarch64)) || arch(loongarch64)) || arch(ppc64le)) || arch(riscv64)) || arch(s390x)) || arch(alpha)) || arch(ppc64)) || arch(sparc64))
         include-dirs: cbits/include64
 
     else
         include-dirs: cbits/include32
 
-    if (arch(x86_64) || arch(aarch64))
+    if ((((((((arch(x86_64) || arch(aarch64)) || arch(loongarch64)) || arch(ppc64le)) || arch(riscv64)) || arch(s390x)) || arch(alpha)) || arch(ppc64)) || arch(sparc64))
         c-sources:
+            cbits/decaf/ed448goldilocks/decaf_all.c
+            cbits/decaf/ed448goldilocks/eddsa.c
+            cbits/decaf/ed448goldilocks/scalar.c
             cbits/decaf/p448/arch_ref64/f_impl.c
-            cbits/decaf/p448/f_generic.c
             cbits/decaf/p448/f_arithmetic.c
+            cbits/decaf/p448/f_generic.c
             cbits/decaf/utils.c
-            cbits/decaf/ed448goldilocks/scalar.c
-            cbits/decaf/ed448goldilocks/decaf_all.c
-            cbits/decaf/ed448goldilocks/eddsa.c
 
         include-dirs: cbits/decaf/include/arch_ref64 cbits/decaf/p448/arch_ref64
 
     else
         c-sources:
+            cbits/decaf/ed448goldilocks/decaf_all.c
+            cbits/decaf/ed448goldilocks/eddsa.c
+            cbits/decaf/ed448goldilocks/scalar.c
             cbits/decaf/p448/arch_32/f_impl.c
-            cbits/decaf/p448/f_generic.c
             cbits/decaf/p448/f_arithmetic.c
+            cbits/decaf/p448/f_generic.c
             cbits/decaf/utils.c
-            cbits/decaf/ed448goldilocks/scalar.c
-            cbits/decaf/ed448goldilocks/decaf_all.c
-            cbits/decaf/ed448goldilocks/eddsa.c
 
         include-dirs: cbits/decaf/include/arch_32 cbits/decaf/p448/arch_32
 
-    if (arch(x86_64) || arch(aarch64))
+    if ((((((((arch(x86_64) || arch(aarch64)) || arch(loongarch64)) || arch(ppc64le)) || arch(riscv64)) || arch(s390x)) || arch(alpha)) || arch(ppc64)) || arch(sparc64))
         c-sources: cbits/curve25519/curve25519-donna-c64.c
 
     else
         c-sources: cbits/curve25519/curve25519-donna.c
 
-    if (arch(i386) || arch(x86_64))
+    if (((((arch(i386) || arch(x86_64)) || arch(loongarch64)) || arch(ppc64le)) || arch(riscv64)) || arch(alpha))
         cpp-options: -DARCH_IS_LITTLE_ENDIAN
 
     if arch(i386)
@@ -369,9 +368,9 @@
     if ((flag(support_aesni) && ((os(linux) || os(freebsd)) || os(osx))) && (arch(i386) || arch(x86_64)))
         cc-options: -DWITH_AESNI
         c-sources:
-            cbits/aes/x86ni.c
             cbits/aes/generic.c
             cbits/aes/gf.c
+            cbits/aes/x86ni.c
             cbits/crypton_aes.c
 
         if !flag(use_target_attributes)
@@ -391,19 +390,19 @@
 
     if (arch(x86_64) || flag(support_sse))
         c-sources:
-            cbits/blake2/sse/blake2s.c
-            cbits/blake2/sse/blake2sp.c
             cbits/blake2/sse/blake2b.c
             cbits/blake2/sse/blake2bp.c
+            cbits/blake2/sse/blake2s.c
+            cbits/blake2/sse/blake2sp.c
 
         include-dirs: cbits/blake2/sse
 
     else
         c-sources:
-            cbits/blake2/ref/blake2s-ref.c
-            cbits/blake2/ref/blake2sp-ref.c
             cbits/blake2/ref/blake2b-ref.c
             cbits/blake2/ref/blake2bp-ref.c
+            cbits/blake2/ref/blake2s-ref.c
+            cbits/blake2/ref/blake2sp-ref.c
 
         include-dirs: cbits/blake2/ref
 
@@ -435,61 +434,64 @@
     if flag(use_target_attributes)
         cc-options: -DWITH_TARGET_ATTRIBUTES
 
+    if os(ios)
+        cpp-options: -DINSECURE_ENTROPY
+
 test-suite test-crypton
     type:             exitcode-stdio-1.0
     main-is:          Tests.hs
     hs-source-dirs:   tests
     other-modules:
-        BlockCipher
-        ChaCha
         BCrypt
         BCryptPBKDF
+        BlockCipher
+        ChaCha
+        ChaChaPoly1305
         ECC
         ECC.Edwards25519
         ECDSA
         Hash
         Imports
+        KAT_AES
         KAT_AES.KATCBC
+        KAT_AES.KATCCM
         KAT_AES.KATECB
         KAT_AES.KATGCM
-        KAT_AES.KATCCM
         KAT_AES.KATOCB3
         KAT_AES.KATXTS
-        KAT_AES
         KAT_AESGCMSIV
         KAT_AFIS
         KAT_Argon2
+        KAT_Blake2
         KAT_Blowfish
-        KAT_CAST5
         KAT_Camellia
+        KAT_CAST5
+        KAT_CMAC
         KAT_Curve25519
         KAT_Curve448
         KAT_DES
         KAT_Ed25519
         KAT_Ed448
         KAT_EdDSA
-        KAT_Blake2
-        KAT_CMAC
         KAT_HKDF
         KAT_HMAC
         KAT_KMAC
         KAT_MiyaguchiPreneel
-        KAT_PBKDF2
         KAT_OTP
+        KAT_PBKDF2
+        KAT_PubKey
         KAT_PubKey.DSA
         KAT_PubKey.ECC
         KAT_PubKey.ECDSA
         KAT_PubKey.OAEP
-        KAT_PubKey.PSS
         KAT_PubKey.P256
-        KAT_PubKey.RSA
+        KAT_PubKey.PSS
         KAT_PubKey.Rabin
-        KAT_PubKey
+        KAT_PubKey.RSA
         KAT_RC4
         KAT_Scrypt
         KAT_TripleDES
         KAT_Twofish
-        ChaChaPoly1305
         Number
         Number.F2m
         Padding
@@ -503,14 +505,14 @@
         -Wall -fno-warn-orphans -fno-warn-missing-signatures -rtsopts
 
     build-depends:
-        base >=0 && <10,
+        base >=4.13 && <5,
         bytestring,
-        memory,
+        crypton,
+        ram,
         tasty,
-        tasty-quickcheck,
         tasty-hunit,
         tasty-kat,
-        crypton
+        tasty-quickcheck
 
 benchmark bench-crypton
     type:             exitcode-stdio-1.0
@@ -520,10 +522,10 @@
     default-language: Haskell2010
     ghc-options:      -Wall -fno-warn-missing-signatures
     build-depends:
-        base,
+        base >=4.13 && <5,
         bytestring,
+        crypton,
         deepseq,
-        memory,
         gauge,
-        random,
-        crypton
+        ram,
+        random
diff --git a/tests/BCrypt.hs b/tests/BCrypt.hs
--- a/tests/BCrypt.hs
+++ b/tests/BCrypt.hs
@@ -1,8 +1,8 @@
 {-# LANGUAGE OverloadedStrings #-}
 
-module BCrypt
-    ( tests
-    )
+module BCrypt (
+    tests,
+)
 where
 
 import Crypto.KDF.BCrypt
@@ -15,37 +15,45 @@
     [ ("$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW", "U*U")
     , ("$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK", "U*U*")
     , ("$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a", "U*U*U")
-    , ("$2a$05$abcdefghijklmnopqrstuu5s2v8.iXieOjg/.AySBTTZIIVFJeBui",
-            "0123456789abcdefghijklmnopqrstuvwxyz\
-            \ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\
-            \chars after 72 are ignored")
+    ,
+        ( "$2a$05$abcdefghijklmnopqrstuu5s2v8.iXieOjg/.AySBTTZIIVFJeBui"
+        , "0123456789abcdefghijklmnopqrstuvwxyz\
+          \ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\
+          \chars after 72 are ignored"
+        )
     , ("$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e", "\xff\xff\xa3")
     , ("$2b$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e", "\xff\xff\xa3")
     , ("$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", "\xa3")
     , ("$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", "\xa3")
     , ("$2b$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", "\xa3")
-    , ("$2a$05$/OK.fbVrR/bpIqNJ5ianF.swQOIzjOiJ9GHEPuhEkvqrUyvWhEMx6",
-            "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
-            \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
-            \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
-            \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
-            \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
-            \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
-            \chars after 72 are ignored as usual")
-    , ("$2a$05$/OK.fbVrR/bpIqNJ5ianF.R9xrDjiycxMbQE2bp.vgqlYpW5wx2yy",
-            "\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
-            \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
-            \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
-            \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
-            \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
-            \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55")
-    , ("$2a$05$/OK.fbVrR/bpIqNJ5ianF.9tQZzcJfm3uj2NvJ/n5xkhpqLrMpWCe",
-            "\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
-            \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
-            \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
-            \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
-            \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
-            \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff")
+    ,
+        ( "$2a$05$/OK.fbVrR/bpIqNJ5ianF.swQOIzjOiJ9GHEPuhEkvqrUyvWhEMx6"
+        , "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
+          \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
+          \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
+          \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
+          \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
+          \\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\
+          \\x00\x01\x02\x03\x04\x05" -- chars after 72 are ignored as usual
+        )
+    ,
+        ( "$2a$05$/OK.fbVrR/bpIqNJ5ianF.R9xrDjiycxMbQE2bp.vgqlYpW5wx2yy"
+        , "\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
+          \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
+          \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
+          \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
+          \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\
+          \\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55"
+        )
+    ,
+        ( "$2a$05$/OK.fbVrR/bpIqNJ5ianF.9tQZzcJfm3uj2NvJ/n5xkhpqLrMpWCe"
+        , "\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
+          \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
+          \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
+          \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
+          \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\
+          \\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff"
+        )
     , ("$2a$05$CCCCCCCCCCCCCCCCCCCCC.7uG0VCzI2bS7j6ymqJi9CdcdxiRTWNy", "")
     , ("$2a$06$DCq7YPn5Rq63x1Lad4cll.TV4S6ytwfsfvkgY8jIucDrjc8deX1s.", "")
     , ("$2a$08$HqWuK6/Ng6sg9gQzbLrgb.Tl.ZHfXLhvt/SgVyWhQqgqcZ7ZuUtye", "")
@@ -57,26 +65,47 @@
     , ("$2a$06$If6bvum7DFjUnE9p2uDeDu0YHzrHM6tf.iqN8.yx.jNN1ILEf7h0i", "abc")
     , ("$2a$08$Ro0CUfOqk6cXEKf3dyaM7OhSCvnwM9s4wIX9JeLapehKK5YdLxKcm", "abc")
     , ("$2a$10$WvvTPHKwdBJ3uk0Z37EMR.hLA2W6N9AEBhEgrAOljy2Ae5MtaSIUi", "abc")
-    , ("$2a$06$.rCVZVOThsIa97pEDOxvGuRRgzG64bvtJ0938xuqzv18d3ZpQhstC", "abcdefghijklmnopqrstuvwxyz")
+    ,
+        ( "$2a$06$.rCVZVOThsIa97pEDOxvGuRRgzG64bvtJ0938xuqzv18d3ZpQhstC"
+        , "abcdefghijklmnopqrstuvwxyz"
+        )
     ]
 
 makeKATs = concatMap maketest (zip3 is passwords hashes)
   where
     is :: [Int]
-    is = [1..]
+    is = [1 ..]
 
     passwords = map snd expected
-    hashes    = map fst expected
+    hashes = map fst expected
 
     maketest (i, password, hash) =
         [ testCase (show i) (assertBool "" (validatePassword password hash))
         ]
 
-tests = testGroup "bcrypt"
-    [ testGroup "KATs" makeKATs
-    , testCase "Invalid hash length" (assertEqual "" (Left "Invalid hash format") (validatePasswordEither B.empty ("$2a$06$DCq7YPn5Rq63x1Lad4cll.TV4S6ytwfsfvkgY8jIucDrjc8deX1s" :: B.ByteString)))
-    , testCase "Hash and validate" (assertBool "Hashed password should validate" (validatePassword somePassword (bcrypt 5 aSalt somePassword :: B.ByteString)))
-    ]
+tests =
+    testGroup
+        "bcrypt"
+        [ testGroup "KATs" makeKATs
+        , testCase
+            "Invalid hash length"
+            ( assertEqual
+                ""
+                (Left "Invalid hash format")
+                ( validatePasswordEither
+                    B.empty
+                    ("$2a$06$DCq7YPn5Rq63x1Lad4cll.TV4S6ytwfsfvkgY8jIucDrjc8deX1s" :: B.ByteString)
+                )
+            )
+        , testCase
+            "Hash and validate"
+            ( assertBool
+                "Hashed password should validate"
+                (validatePassword somePassword (bcrypt 5 aSalt somePassword :: B.ByteString))
+            )
+        ]
   where
     somePassword = "some password" :: B.ByteString
-    aSalt = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" :: B.ByteString
+    aSalt =
+        "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+            :: B.ByteString
diff --git a/tests/BCryptPBKDF.hs b/tests/BCryptPBKDF.hs
--- a/tests/BCryptPBKDF.hs
+++ b/tests/BCryptPBKDF.hs
@@ -2,74 +2,211 @@
 
 module BCryptPBKDF (tests) where
 
-import qualified Data.ByteString        as B
+import qualified Data.ByteString as B
 
-import           Test.Tasty
-import           Test.Tasty.HUnit
+import Test.Tasty
+import Test.Tasty.HUnit
 
-import           Crypto.KDF.BCryptPBKDF (Parameters (..), generate,
-                                         hashInternal)
+import Crypto.KDF.BCryptPBKDF (
+    Parameters (..),
+    generate,
+    hashInternal,
+ )
 
 tests :: TestTree
-tests = testGroup "BCryptPBKDF"
-    [ testGroup "generate"
-        [ testCase "1" generate1
-        , testCase "2" generate2
-        , testCase "3" generate3
-        ]
-    , testGroup "hashInternal"
-        [ testCase "1" hashInternal1
+tests =
+    testGroup
+        "BCryptPBKDF"
+        [ testGroup
+            "generate"
+            [ testCase "1" generate1
+            , testCase "2" generate2
+            , testCase "3" generate3
+            ]
+        , testGroup
+            "hashInternal"
+            [ testCase "1" hashInternal1
+            ]
         ]
-    ]
   where
     -- test vector taken from the go implementation by @dchest
     generate1 = expected @=? generate params pass salt
-        where
-            params   = Parameters 12 32
-            pass     = "password" :: B.ByteString
-            salt     = "salt"     :: B.ByteString
-            expected = B.pack
-                [ 0x1a, 0xe4, 0x2c, 0x05, 0xd4, 0x87, 0xbc, 0x02
-                , 0xf6, 0x49, 0x21, 0xa4, 0xeb, 0xe4, 0xea, 0x93
-                , 0xbc, 0xac, 0xfe, 0x13, 0x5f, 0xda, 0x99, 0x97
-                , 0x4c, 0x06, 0xb7, 0xb0, 0x1f, 0xae, 0x14, 0x9a
-                ] :: B.ByteString
+      where
+        params = Parameters 12 32
+        pass = "password" :: B.ByteString
+        salt = "salt" :: B.ByteString
+        expected =
+            B.pack
+                [ 0x1a
+                , 0xe4
+                , 0x2c
+                , 0x05
+                , 0xd4
+                , 0x87
+                , 0xbc
+                , 0x02
+                , 0xf6
+                , 0x49
+                , 0x21
+                , 0xa4
+                , 0xeb
+                , 0xe4
+                , 0xea
+                , 0x93
+                , 0xbc
+                , 0xac
+                , 0xfe
+                , 0x13
+                , 0x5f
+                , 0xda
+                , 0x99
+                , 0x97
+                , 0x4c
+                , 0x06
+                , 0xb7
+                , 0xb0
+                , 0x1f
+                , 0xae
+                , 0x14
+                , 0x9a
+                ]
+                :: B.ByteString
 
     -- test vector generated with the go implemenation by @dchest
     generate2 = expected @=? generate params pass salt
-        where
-            params   = Parameters 7 71
-            pass     = "DieWuerdeDesMenschenIstUnantastbar" :: B.ByteString
-            salt     = "Tafelsalz"                          :: B.ByteString
-            expected = B.pack
-                [ 0x17, 0xb4, 0x76, 0xaa, 0xd7, 0x42, 0x33, 0x49
-                , 0x5c, 0xe8, 0x79, 0x49, 0x15, 0x74, 0x4c, 0x71
-                , 0xf9, 0x99, 0x66, 0x89, 0x7a, 0x60, 0xc3, 0x70
-                , 0xb4, 0x3c, 0xa8, 0x83, 0x80, 0x5a, 0x56, 0xde
-                , 0x38, 0xbc, 0x51, 0x8c, 0xd4, 0xeb, 0xd1, 0xcf
-                , 0x46, 0x0a, 0x68, 0x3d, 0xc8, 0x12, 0xcf, 0xf8
-                , 0x43, 0xce, 0x21, 0x9d, 0x98, 0x81, 0x20, 0x26
-                , 0x6e, 0x42, 0x0f, 0xaa, 0x75, 0x5d, 0x09, 0x8d
-                , 0x45, 0xda, 0xd5, 0x15, 0x6e, 0x65, 0x1d
-                ] :: B.ByteString
+      where
+        params = Parameters 7 71
+        pass = "DieWuerdeDesMenschenIstUnantastbar" :: B.ByteString
+        salt = "Tafelsalz" :: B.ByteString
+        expected =
+            B.pack
+                [ 0x17
+                , 0xb4
+                , 0x76
+                , 0xaa
+                , 0xd7
+                , 0x42
+                , 0x33
+                , 0x49
+                , 0x5c
+                , 0xe8
+                , 0x79
+                , 0x49
+                , 0x15
+                , 0x74
+                , 0x4c
+                , 0x71
+                , 0xf9
+                , 0x99
+                , 0x66
+                , 0x89
+                , 0x7a
+                , 0x60
+                , 0xc3
+                , 0x70
+                , 0xb4
+                , 0x3c
+                , 0xa8
+                , 0x83
+                , 0x80
+                , 0x5a
+                , 0x56
+                , 0xde
+                , 0x38
+                , 0xbc
+                , 0x51
+                , 0x8c
+                , 0xd4
+                , 0xeb
+                , 0xd1
+                , 0xcf
+                , 0x46
+                , 0x0a
+                , 0x68
+                , 0x3d
+                , 0xc8
+                , 0x12
+                , 0xcf
+                , 0xf8
+                , 0x43
+                , 0xce
+                , 0x21
+                , 0x9d
+                , 0x98
+                , 0x81
+                , 0x20
+                , 0x26
+                , 0x6e
+                , 0x42
+                , 0x0f
+                , 0xaa
+                , 0x75
+                , 0x5d
+                , 0x09
+                , 0x8d
+                , 0x45
+                , 0xda
+                , 0xd5
+                , 0x15
+                , 0x6e
+                , 0x65
+                , 0x1d
+                ]
+                :: B.ByteString
 
     -- test vector generated with the go implemenation by @dchest
     generate3 = expected @=? generate params pass salt
-        where
-            params    = Parameters 5 5
-            pass      = "ABC" :: B.ByteString
-            salt      = "DEF" :: B.ByteString
-            expected  = B.pack
-                [ 0xdd, 0x6e, 0xa0, 0x69, 0x29
-                ] :: B.ByteString
+      where
+        params = Parameters 5 5
+        pass = "ABC" :: B.ByteString
+        salt = "DEF" :: B.ByteString
+        expected =
+            B.pack
+                [ 0xdd
+                , 0x6e
+                , 0xa0
+                , 0x69
+                , 0x29
+                ]
+                :: B.ByteString
 
     hashInternal1 = expected @=? hashInternal passHash saltHash
-        where
-            passHash = B.pack [ 0  ..  63 ] :: B.ByteString
-            saltHash = B.pack [ 64 .. 127 ] :: B.ByteString
-            expected = B.pack
-                [ 0x87, 0x90, 0x48, 0x70, 0xee, 0xf9, 0xde, 0xdd
-                , 0xf8, 0xe7, 0x61, 0x1a, 0x14, 0x01, 0x06, 0xe6
-                , 0xaa, 0xf1, 0xa3, 0x63, 0xd9, 0xa2, 0xc5, 0x04
-                , 0xdb, 0x35, 0x64, 0x43, 0x72, 0x1e, 0xb5, 0x55
-                ] :: B.ByteString
+      where
+        passHash = B.pack [0 .. 63] :: B.ByteString
+        saltHash = B.pack [64 .. 127] :: B.ByteString
+        expected =
+            B.pack
+                [ 0x87
+                , 0x90
+                , 0x48
+                , 0x70
+                , 0xee
+                , 0xf9
+                , 0xde
+                , 0xdd
+                , 0xf8
+                , 0xe7
+                , 0x61
+                , 0x1a
+                , 0x14
+                , 0x01
+                , 0x06
+                , 0xe6
+                , 0xaa
+                , 0xf1
+                , 0xa3
+                , 0x63
+                , 0xd9
+                , 0xa2
+                , 0xc5
+                , 0x04
+                , 0xdb
+                , 0x35
+                , 0x64
+                , 0x43
+                , 0x72
+                , 0x1e
+                , 0xb5
+                , 0x55
+                ]
+                :: B.ByteString
diff --git a/tests/BlockCipher.hs b/tests/BlockCipher.hs
--- a/tests/BlockCipher.hs
+++ b/tests/BlockCipher.hs
@@ -1,24 +1,25 @@
 {-# LANGUAGE ViewPatterns #-}
-module BlockCipher
-    ( KAT_ECB(..)
-    , KAT_CBC(..)
-    , KAT_CFB(..)
-    , KAT_CTR(..)
-    , KAT_XTS(..)
-    , KAT_AEAD(..)
-    , KATs(..)
-    , defaultKATs
-    , testBlockCipher
-    , CipherInfo
-    ) where
 
-import           Imports
-import           Data.Maybe
-import           Crypto.Error
-import           Crypto.Cipher.Types
-import           Data.ByteArray as B hiding (pack, null, length)
-import qualified Data.ByteString as B hiding (all, take, replicate)
+module BlockCipher (
+    KAT_ECB (..),
+    KAT_CBC (..),
+    KAT_CFB (..),
+    KAT_CTR (..),
+    KAT_XTS (..),
+    KAT_AEAD (..),
+    KATs (..),
+    defaultKATs,
+    testBlockCipher,
+    CipherInfo,
+) where
 
+import Crypto.Cipher.Types
+import Crypto.Error
+import Data.ByteArray as B hiding (length, null, pack)
+import qualified Data.ByteString as B hiding (all, replicate, take)
+import Data.Maybe
+import Imports
+
 ------------------------------------------------------------------------
 -- KAT
 ------------------------------------------------------------------------
@@ -32,66 +33,100 @@
 
 -- | ECB KAT
 data KAT_ECB = KAT_ECB
-    { ecbKey        :: ByteString -- ^ Key
-    , ecbPlaintext  :: ByteString -- ^ Plaintext
-    , ecbCiphertext :: ByteString -- ^ Ciphertext
-    } deriving (Show,Eq)
+    { ecbKey :: ByteString
+    -- ^ Key
+    , ecbPlaintext :: ByteString
+    -- ^ Plaintext
+    , ecbCiphertext :: ByteString
+    -- ^ Ciphertext
+    }
+    deriving (Show, Eq)
 
 -- | CBC KAT
 data KAT_CBC = KAT_CBC
-    { cbcKey        :: ByteString -- ^ Key
-    , cbcIV         :: ByteString -- ^ IV
-    , cbcPlaintext  :: ByteString -- ^ Plaintext
-    , cbcCiphertext :: ByteString -- ^ Ciphertext
-    } deriving (Show,Eq)
+    { cbcKey :: ByteString
+    -- ^ Key
+    , cbcIV :: ByteString
+    -- ^ IV
+    , cbcPlaintext :: ByteString
+    -- ^ Plaintext
+    , cbcCiphertext :: ByteString
+    -- ^ Ciphertext
+    }
+    deriving (Show, Eq)
 
 -- | CFB KAT
 data KAT_CFB = KAT_CFB
-    { cfbKey        :: ByteString -- ^ Key
-    , cfbIV         :: ByteString -- ^ IV
-    , cfbPlaintext  :: ByteString -- ^ Plaintext
-    , cfbCiphertext :: ByteString -- ^ Ciphertext
-    } deriving (Show,Eq)
+    { cfbKey :: ByteString
+    -- ^ Key
+    , cfbIV :: ByteString
+    -- ^ IV
+    , cfbPlaintext :: ByteString
+    -- ^ Plaintext
+    , cfbCiphertext :: ByteString
+    -- ^ Ciphertext
+    }
+    deriving (Show, Eq)
 
 -- | CTR KAT
 data KAT_CTR = KAT_CTR
-    { ctrKey        :: ByteString -- ^ Key
-    , ctrIV         :: ByteString -- ^ IV (usually represented as a 128 bits integer)
-    , ctrPlaintext  :: ByteString -- ^ Plaintext
-    , ctrCiphertext :: ByteString -- ^ Ciphertext
-    } deriving (Show,Eq)
+    { ctrKey :: ByteString
+    -- ^ Key
+    , ctrIV :: ByteString
+    -- ^ IV (usually represented as a 128 bits integer)
+    , ctrPlaintext :: ByteString
+    -- ^ Plaintext
+    , ctrCiphertext :: ByteString
+    -- ^ Ciphertext
+    }
+    deriving (Show, Eq)
 
 -- | XTS KAT
 data KAT_XTS = KAT_XTS
-    { xtsKey1       :: ByteString -- ^ 1st XTS key
-    , xtsKey2       :: ByteString -- ^ 2nd XTS key
-    , xtsIV         :: ByteString -- ^ XTS IV
-    , xtsPlaintext  :: ByteString -- ^ plaintext
-    , xtsCiphertext :: ByteString -- ^ Ciphertext
-    } deriving (Show,Eq)
+    { xtsKey1 :: ByteString
+    -- ^ 1st XTS key
+    , xtsKey2 :: ByteString
+    -- ^ 2nd XTS key
+    , xtsIV :: ByteString
+    -- ^ XTS IV
+    , xtsPlaintext :: ByteString
+    -- ^ plaintext
+    , xtsCiphertext :: ByteString
+    -- ^ Ciphertext
+    }
+    deriving (Show, Eq)
 
 -- | AEAD KAT
 data KAT_AEAD = KAT_AEAD
-    { aeadMode       :: AEADMode
-    , aeadKey        :: ByteString -- ^ Key
-    , aeadIV         :: ByteString -- ^ IV for initialization
-    , aeadHeader     :: ByteString -- ^ Authenticated Header
-    , aeadPlaintext  :: ByteString -- ^ Plaintext
-    , aeadCiphertext :: ByteString -- ^ Ciphertext
-    , aeadTaglen     :: Int        -- ^ aead tag len
-    , aeadTag        :: ByteString -- ^ expected tag
-    } deriving (Show,Eq)
+    { aeadMode :: AEADMode
+    , aeadKey :: ByteString
+    -- ^ Key
+    , aeadIV :: ByteString
+    -- ^ IV for initialization
+    , aeadHeader :: ByteString
+    -- ^ Authenticated Header
+    , aeadPlaintext :: ByteString
+    -- ^ Plaintext
+    , aeadCiphertext :: ByteString
+    -- ^ Ciphertext
+    , aeadTaglen :: Int
+    -- ^ aead tag len
+    , aeadTag :: ByteString
+    -- ^ expected tag
+    }
+    deriving (Show, Eq)
 
 -- | all the KATs. use defaultKATs to prevent compilation error
 -- from future expansion of this data structure
 data KATs = KATs
-    { kat_ECB  :: [KAT_ECB]
-    , kat_CBC  :: [KAT_CBC]
-    , kat_CFB  :: [KAT_CFB]
-    , kat_CTR  :: [KAT_CTR]
-    , kat_XTS  :: [KAT_XTS]
+    { kat_ECB :: [KAT_ECB]
+    , kat_CBC :: [KAT_CBC]
+    , kat_CFB :: [KAT_CFB]
+    , kat_CTR :: [KAT_CTR]
+    , kat_XTS :: [KAT_XTS]
     , kat_AEAD :: [KAT_AEAD]
-    } deriving (Show,Eq)
+    }
+    deriving (Show, Eq)
 
 defaultKATs = KATs [] [] [] [] [] []
 
@@ -151,90 +186,102 @@
         dtag = aeadFinalize aeadDFinal (aeadTaglen d)
 -}
 
-testKATs :: BlockCipher cipher
-         => KATs
-         -> cipher
-         -> TestTree
-testKATs kats cipher = testGroup "KAT"
-    (   maybeGroup makeECBTest "ECB" (kat_ECB kats)
-     ++ maybeGroup makeCBCTest "CBC" (kat_CBC kats)
-     ++ maybeGroup makeCFBTest "CFB" (kat_CFB kats)
-     ++ maybeGroup makeCTRTest "CTR" (kat_CTR kats)
-     -- ++ maybeGroup makeXTSTest "XTS" (kat_XTS kats)
-     ++ maybeGroup makeAEADTest "AEAD" (kat_AEAD kats)
-    )
-  where makeECBTest i d =
-            [ testCase ("E" ++ i) (ecbEncrypt ctx (ecbPlaintext d) @?= ecbCiphertext d)
-            , testCase ("D" ++ i) (ecbDecrypt ctx (ecbCiphertext d) @?= ecbPlaintext d)
-            ]
-          where ctx = cipherInitNoErr (cipherMakeKey cipher $ ecbKey d)
-        makeCBCTest i d =
-            [ testCase ("E" ++ i) (cbcEncrypt ctx iv (cbcPlaintext d) @?= cbcCiphertext d)
-            , testCase ("D" ++ i) (cbcDecrypt ctx iv (cbcCiphertext d) @?= cbcPlaintext d)
-            ]
-          where ctx = cipherInitNoErr (cipherMakeKey cipher $ cbcKey d)
-                iv  = cipherMakeIV cipher $ cbcIV d
-        makeCFBTest i d =
-            [ testCase ("E" ++ i) (cfbEncrypt ctx iv (cfbPlaintext d) @?= cfbCiphertext d)
-            , testCase ("D" ++ i) (cfbDecrypt ctx iv (cfbCiphertext d) @?= cfbPlaintext d)
-            ]
-          where ctx = cipherInitNoErr (cipherMakeKey cipher $ cfbKey d)
-                iv  = cipherMakeIV cipher $ cfbIV d
-        makeCTRTest i d =
-            [ testCase ("E" ++ i) (ctrCombine ctx iv (ctrPlaintext d) @?= ctrCiphertext d)
-            , testCase ("D" ++ i) (ctrCombine ctx iv (ctrCiphertext d) @?= ctrPlaintext d)
-            ]
-          where ctx = cipherInitNoErr (cipherMakeKey cipher $ ctrKey d)
-                iv  = cipherMakeIV cipher $ ctrIV d
-{-
-        makeXTSTest i d  =
-            [ testCase ("E" ++ i) (xtsEncrypt ctx iv 0 (xtsPlaintext d) @?= xtsCiphertext d)
-            , testCase ("D" ++ i) (xtsDecrypt ctx iv 0 (xtsCiphertext d) @?= xtsPlaintext d)
-            ]
-          where ctx1 = cipherInitNoErr (cipherMakeKey cipher $ xtsKey1 d)
-                ctx2 = cipherInitNoErr (cipherMakeKey cipher $ xtsKey2 d)
-                ctx  = (ctx1, ctx2)
-                iv   = cipherMakeIV cipher $ xtsIV d
--}
-        makeAEADTest i d =
-            [ testCase ("AE" ++ i) (etag @?= AuthTag (B.convert (aeadTag d)))
-            , testCase ("AD" ++ i) (dtag @?= AuthTag (B.convert (aeadTag d)))
-            , testCase ("E" ++ i)  (ebs @?= aeadCiphertext d)
-            , testCase ("D" ++ i)  (dbs @?= aeadPlaintext d)
-            ]
-          where ctx  = cipherInitNoErr (cipherMakeKey cipher $ aeadKey d)
-                aead = aeadInitNoErr (aeadMode d) ctx (aeadIV d)
-                aeadHeaded     = aeadAppendHeader aead (aeadHeader d)
-                (ebs,aeadEFinal) = aeadEncrypt aeadHeaded (aeadPlaintext d)
-                (dbs,aeadDFinal) = aeadDecrypt aeadHeaded (aeadCiphertext d)
-                etag = aeadFinalize aeadEFinal (aeadTaglen d)
-                dtag = aeadFinalize aeadDFinal (aeadTaglen d)
+testKATs
+    :: BlockCipher cipher
+    => KATs
+    -> cipher
+    -> TestTree
+testKATs kats cipher =
+    testGroup
+        "KAT"
+        ( maybeGroup makeECBTest "ECB" (kat_ECB kats)
+            ++ maybeGroup makeCBCTest "CBC" (kat_CBC kats)
+            ++ maybeGroup makeCFBTest "CFB" (kat_CFB kats)
+            ++ maybeGroup makeCTRTest "CTR" (kat_CTR kats)
+            -- ++ maybeGroup makeXTSTest "XTS" (kat_XTS kats)
+            ++ maybeGroup makeAEADTest "AEAD" (kat_AEAD kats)
+        )
+  where
+    makeECBTest i d =
+        [ testCase ("E" ++ i) (ecbEncrypt ctx (ecbPlaintext d) @?= ecbCiphertext d)
+        , testCase ("D" ++ i) (ecbDecrypt ctx (ecbCiphertext d) @?= ecbPlaintext d)
+        ]
+      where
+        ctx = cipherInitNoErr (cipherMakeKey cipher $ ecbKey d)
+    makeCBCTest i d =
+        [ testCase ("E" ++ i) (cbcEncrypt ctx iv (cbcPlaintext d) @?= cbcCiphertext d)
+        , testCase ("D" ++ i) (cbcDecrypt ctx iv (cbcCiphertext d) @?= cbcPlaintext d)
+        ]
+      where
+        ctx = cipherInitNoErr (cipherMakeKey cipher $ cbcKey d)
+        iv = cipherMakeIV cipher $ cbcIV d
+    makeCFBTest i d =
+        [ testCase ("E" ++ i) (cfbEncrypt ctx iv (cfbPlaintext d) @?= cfbCiphertext d)
+        , testCase ("D" ++ i) (cfbDecrypt ctx iv (cfbCiphertext d) @?= cfbPlaintext d)
+        ]
+      where
+        ctx = cipherInitNoErr (cipherMakeKey cipher $ cfbKey d)
+        iv = cipherMakeIV cipher $ cfbIV d
+    makeCTRTest i d =
+        [ testCase ("E" ++ i) (ctrCombine ctx iv (ctrPlaintext d) @?= ctrCiphertext d)
+        , testCase ("D" ++ i) (ctrCombine ctx iv (ctrCiphertext d) @?= ctrPlaintext d)
+        ]
+      where
+        ctx = cipherInitNoErr (cipherMakeKey cipher $ ctrKey d)
+        iv = cipherMakeIV cipher $ ctrIV d
+    {-
+            makeXTSTest i d  =
+                [ testCase ("E" ++ i) (xtsEncrypt ctx iv 0 (xtsPlaintext d) @?= xtsCiphertext d)
+                , testCase ("D" ++ i) (xtsDecrypt ctx iv 0 (xtsCiphertext d) @?= xtsPlaintext d)
+                ]
+              where ctx1 = cipherInitNoErr (cipherMakeKey cipher $ xtsKey1 d)
+                    ctx2 = cipherInitNoErr (cipherMakeKey cipher $ xtsKey2 d)
+                    ctx  = (ctx1, ctx2)
+                    iv   = cipherMakeIV cipher $ xtsIV d
+    -}
+    makeAEADTest i d =
+        [ testCase ("AE" ++ i) (etag @?= AuthTag (B.convert (aeadTag d)))
+        , testCase ("AD" ++ i) (dtag @?= AuthTag (B.convert (aeadTag d)))
+        , testCase ("E" ++ i) (ebs @?= aeadCiphertext d)
+        , testCase ("D" ++ i) (dbs @?= aeadPlaintext d)
+        ]
+      where
+        ctx = cipherInitNoErr (cipherMakeKey cipher $ aeadKey d)
+        aead = aeadInitNoErr (aeadMode d) ctx (aeadIV d)
+        aeadHeaded = aeadAppendHeader aead (aeadHeader d)
+        (ebs, aeadEFinal) = aeadEncrypt aeadHeaded (aeadPlaintext d)
+        (dbs, aeadDFinal) = aeadDecrypt aeadHeaded (aeadCiphertext d)
+        etag = aeadFinalize aeadEFinal (aeadTaglen d)
+        dtag = aeadFinalize aeadDFinal (aeadTaglen d)
 
-        cipherInitNoErr :: BlockCipher c => Key c -> c
-        cipherInitNoErr (Key k) =
-            case cipherInit k of
-                CryptoPassed a -> a
-                CryptoFailed e -> error (show e)
+    cipherInitNoErr :: BlockCipher c => Key c -> c
+    cipherInitNoErr (Key k) =
+        case cipherInit k of
+            CryptoPassed a -> a
+            CryptoFailed e -> error (show e)
 
-        aeadInitNoErr :: (ByteArrayAccess iv, BlockCipher cipher) => AEADMode -> cipher -> iv -> AEAD cipher
-        aeadInitNoErr mode ct iv =
-            case aeadInit mode ct iv of
-                CryptoPassed a -> a
-                CryptoFailed _ -> error $ "cipher doesn't support aead mode: " ++ show mode
+    aeadInitNoErr
+        :: (ByteArrayAccess iv, BlockCipher cipher)
+        => AEADMode -> cipher -> iv -> AEAD cipher
+    aeadInitNoErr mode ct iv =
+        case aeadInit mode ct iv of
+            CryptoPassed a -> a
+            CryptoFailed _ -> error $ "cipher doesn't support aead mode: " ++ show mode
+
 ------------------------------------------------------------------------
 -- Properties
 ------------------------------------------------------------------------
 
 -- | any sized bytestring
-newtype Plaintext a = Plaintext { unPlaintext :: B.ByteString }
-    deriving (Show,Eq)
+newtype Plaintext a = Plaintext {unPlaintext :: B.ByteString}
+    deriving (Show, Eq)
 
 -- | A multiple of blocksize bytestring
-newtype PlaintextBS a = PlaintextBS { unPlaintextBS :: B.ByteString }
-    deriving (Show,Eq)
+newtype PlaintextBS a = PlaintextBS {unPlaintextBS :: B.ByteString}
+    deriving (Show, Eq)
 
 newtype Key a = Key ByteString
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 -- | a ECB unit test
 data ECBUnit a = ECBUnit (Key a) (PlaintextBS a)
@@ -279,116 +326,159 @@
 instance Show (CTRUnit a) where
     show (CTRUnit key iv b) = "CTR(key=" ++ show key ++ ",iv=" ++ show iv ++ ",input=" ++ show b ++ ")"
 instance Show (XTSUnit a) where
-    show (XTSUnit key1 key2 iv b) = "XTS(key1=" ++ show key1 ++ ",key2=" ++ show key2 ++ ",iv=" ++ show iv ++ ",input=" ++ show b ++ ")"
+    show (XTSUnit key1 key2 iv b) =
+        "XTS(key1="
+            ++ show key1
+            ++ ",key2="
+            ++ show key2
+            ++ ",iv="
+            ++ show iv
+            ++ ",input="
+            ++ show b
+            ++ ")"
 instance Show (AEADUnit a) where
-    show (AEADUnit key iv aad b) = "AEAD(key=" ++ show key ++ ",iv=" ++ show iv ++ ",aad=" ++ show (unPlaintext aad) ++ ",input=" ++ show b ++ ")"
+    show (AEADUnit key iv aad b) =
+        "AEAD(key="
+            ++ show key
+            ++ ",iv="
+            ++ show iv
+            ++ ",aad="
+            ++ show (unPlaintext aad)
+            ++ ",input="
+            ++ show b
+            ++ ")"
 instance Show (StreamUnit a) where
     show (StreamUnit key b) = "Stream(key=" ++ show key ++ ",input=" ++ show b ++ ")"
 
 -- | Generate an arbitrary valid key for a specific block cipher
 generateKey :: Cipher a => Gen (Key a)
 generateKey = keyFromCipher undefined
-  where keyFromCipher :: Cipher a => a -> Gen (Key a)
-        keyFromCipher cipher = do
-            sz <- case cipherKeySize cipher of
-                         KeySizeRange low high -> choose (low, high)
-                         KeySizeFixed v -> return v
-                         KeySizeEnum l  -> elements l
-            Key . B.pack <$> replicateM sz arbitrary
+  where
+    keyFromCipher :: Cipher a => a -> Gen (Key a)
+    keyFromCipher cipher = do
+        sz <- case cipherKeySize cipher of
+            KeySizeRange low high -> choose (low, high)
+            KeySizeFixed v -> return v
+            KeySizeEnum l -> elements l
+        Key . B.pack <$> replicateM sz arbitrary
 
 -- | Generate an arbitrary valid IV for a specific block cipher
 generateIv :: BlockCipher a => Gen (IV a)
 generateIv = ivFromCipher undefined
-  where ivFromCipher :: BlockCipher a => a -> Gen (IV a)
-        ivFromCipher cipher = fromJust . makeIV . B.pack <$> replicateM (blockSize cipher) arbitrary
+  where
+    ivFromCipher :: BlockCipher a => a -> Gen (IV a)
+    ivFromCipher cipher = fromJust . makeIV . B.pack <$> replicateM (blockSize cipher) arbitrary
 
 -- | Generate an arbitrary valid IV for AEAD for a specific block cipher
 generateIvAEAD :: Gen B.ByteString
-generateIvAEAD = choose (12,90) >>= \sz -> (B.pack <$> replicateM sz arbitrary)
+generateIvAEAD = choose (12, 90) >>= \sz -> (B.pack <$> replicateM sz arbitrary)
 
 -- | Generate a plaintext multiple of blocksize bytes
 generatePlaintextMultipleBS :: BlockCipher a => Gen (PlaintextBS a)
-generatePlaintextMultipleBS = choose (1,128) >>= \size -> replicateM (size * 16) arbitrary >>= return . PlaintextBS . B.pack
+generatePlaintextMultipleBS =
+    choose (1, 128) >>= \size -> replicateM (size * 16) arbitrary >>= return . PlaintextBS . B.pack
 
 -- | Generate any sized plaintext
 generatePlaintext :: Gen (Plaintext a)
-generatePlaintext = choose (0,324) >>= \size -> replicateM size arbitrary >>= return . Plaintext . B.pack
+generatePlaintext =
+    choose (0, 324) >>= \size -> replicateM size arbitrary >>= return . Plaintext . B.pack
 
 instance BlockCipher a => Arbitrary (ECBUnit a) where
-    arbitrary = ECBUnit <$> generateKey
-                        <*> generatePlaintextMultipleBS
+    arbitrary =
+        ECBUnit
+            <$> generateKey
+            <*> generatePlaintextMultipleBS
 
 instance BlockCipher a => Arbitrary (CBCUnit a) where
-    arbitrary = CBCUnit <$> generateKey
-                        <*> generateIv
-                        <*> generatePlaintextMultipleBS
+    arbitrary =
+        CBCUnit
+            <$> generateKey
+            <*> generateIv
+            <*> generatePlaintextMultipleBS
 
 instance BlockCipher a => Arbitrary (CFBUnit a) where
-    arbitrary = CFBUnit <$> generateKey
-                        <*> generateIv
-                        <*> generatePlaintextMultipleBS
+    arbitrary =
+        CFBUnit
+            <$> generateKey
+            <*> generateIv
+            <*> generatePlaintextMultipleBS
 
 instance BlockCipher a => Arbitrary (CFB8Unit a) where
     arbitrary = CFB8Unit <$> generateKey <*> generateIv <*> generatePlaintext
 
 instance BlockCipher a => Arbitrary (CTRUnit a) where
-    arbitrary = CTRUnit <$> generateKey
-                        <*> generateIv
-                        <*> generatePlaintext
+    arbitrary =
+        CTRUnit
+            <$> generateKey
+            <*> generateIv
+            <*> generatePlaintext
 
 instance BlockCipher a => Arbitrary (XTSUnit a) where
-    arbitrary = XTSUnit <$> generateKey
-                        <*> generateKey
-                        <*> generateIv
-                        <*> generatePlaintextMultipleBS
+    arbitrary =
+        XTSUnit
+            <$> generateKey
+            <*> generateKey
+            <*> generateIv
+            <*> generatePlaintextMultipleBS
 
 instance BlockCipher a => Arbitrary (AEADUnit a) where
-    arbitrary = AEADUnit <$> generateKey
-                         <*> generateIvAEAD
-                         <*> generatePlaintext
-                         <*> generatePlaintext
+    arbitrary =
+        AEADUnit
+            <$> generateKey
+            <*> generateIvAEAD
+            <*> generatePlaintext
+            <*> generatePlaintext
 
 instance StreamCipher a => Arbitrary (StreamUnit a) where
-    arbitrary = StreamUnit <$> generateKey
-                           <*> generatePlaintext
+    arbitrary =
+        StreamUnit
+            <$> generateKey
+            <*> generatePlaintext
 
 testBlockCipherBasic :: BlockCipher a => a -> [TestTree]
-testBlockCipherBasic cipher = [ testProperty "ECB" ecbProp ]
-  where ecbProp = toTests cipher
-        toTests :: BlockCipher a => a -> (ECBUnit a -> Bool)
-        toTests _ = testProperty_ECB
-        testProperty_ECB (ECBUnit key (unPlaintextBS -> plaintext)) = withCtx key $ \ctx ->
-            plaintext `assertEq` ecbDecrypt ctx (ecbEncrypt ctx plaintext)
+testBlockCipherBasic cipher = [testProperty "ECB" ecbProp]
+  where
+    ecbProp = toTests cipher
+    toTests :: BlockCipher a => a -> (ECBUnit a -> Bool)
+    toTests _ = testProperty_ECB
+    testProperty_ECB (ECBUnit key (unPlaintextBS -> plaintext)) = withCtx key $ \ctx ->
+        plaintext `assertEq` ecbDecrypt ctx (ecbEncrypt ctx plaintext)
 
 testBlockCipherModes :: BlockCipher a => a -> [TestTree]
 testBlockCipherModes cipher =
     [ testProperty "CBC" cbcProp
     , testProperty "CFB" cfbProp
-    --, testProperty "CFB8" cfb8Prop
-    , testProperty "CTR" ctrProp
+    , -- , testProperty "CFB8" cfb8Prop
+      testProperty "CTR" ctrProp
     ]
-  where (cbcProp,cfbProp,ctrProp) = toTests cipher
-        toTests :: BlockCipher a
-                => a
-                -> ((CBCUnit a -> Bool), (CFBUnit a -> Bool), {-(CFB8Unit a -> Bool),-} (CTRUnit a -> Bool))
-        toTests _ = (testProperty_CBC
-                    ,testProperty_CFB
-                    --,testProperty_CFB8
-                    ,testProperty_CTR
-                    )
-        testProperty_CBC (CBCUnit key testIV (unPlaintextBS -> plaintext)) = withCtx key $ \ctx ->
-            plaintext `assertEq` cbcDecrypt ctx testIV (cbcEncrypt ctx testIV plaintext)
+  where
+    (cbcProp, cfbProp, ctrProp) = toTests cipher
+    toTests
+        :: BlockCipher a
+        => a
+        -> ( (CBCUnit a -> Bool)
+           , (CFBUnit a -> Bool {-(CFB8Unit a -> Bool),-})
+           , (CTRUnit a -> Bool)
+           )
+    toTests _ =
+        ( testProperty_CBC
+        , testProperty_CFB
+        , -- ,testProperty_CFB8
+          testProperty_CTR
+        )
+    testProperty_CBC (CBCUnit key testIV (unPlaintextBS -> plaintext)) = withCtx key $ \ctx ->
+        plaintext `assertEq` cbcDecrypt ctx testIV (cbcEncrypt ctx testIV plaintext)
 
-        testProperty_CFB (CFBUnit key testIV (unPlaintextBS -> plaintext)) = withCtx key $ \ctx ->
-            plaintext `assertEq` cfbDecrypt ctx testIV (cfbEncrypt ctx testIV plaintext)
+    testProperty_CFB (CFBUnit key testIV (unPlaintextBS -> plaintext)) = withCtx key $ \ctx ->
+        plaintext `assertEq` cfbDecrypt ctx testIV (cfbEncrypt ctx testIV plaintext)
 
-{-
-        testProperty_CFB8 (CFB8Unit (cipherInit -> ctx) testIV (unPlaintext -> plaintext)) =
-            plaintext `assertEq` cfb8Decrypt ctx testIV (cfb8Encrypt ctx testIV plaintext)
--}
+    {-
+            testProperty_CFB8 (CFB8Unit (cipherInit -> ctx) testIV (unPlaintext -> plaintext)) =
+                plaintext `assertEq` cfb8Decrypt ctx testIV (cfb8Encrypt ctx testIV plaintext)
+    -}
 
-        testProperty_CTR (CTRUnit key testIV (unPlaintext -> plaintext)) = withCtx key $ \ctx ->
-            plaintext `assertEq` ctrCombine ctx testIV (ctrCombine ctx testIV plaintext)
+    testProperty_CTR (CTRUnit key testIV (unPlaintext -> plaintext)) = withCtx key $ \ctx ->
+        plaintext `assertEq` ctrCombine ctx testIV (ctrCombine ctx testIV plaintext)
 
 testBlockCipherAEAD :: BlockCipher a => a -> [TestTree]
 testBlockCipherAEAD cipher =
@@ -398,30 +488,33 @@
     , testProperty "CWC" (aeadProp AEAD_CWC)
     , testProperty "GCM" (aeadProp AEAD_GCM)
     ]
-  where aeadProp = toTests cipher
-        toTests :: BlockCipher a => a -> (AEADMode -> AEADUnit a -> Bool)
-        toTests _ = testProperty_AEAD
-        testProperty_AEAD mode (AEADUnit key testIV (unPlaintext -> aad) (unPlaintext -> plaintext)) = withCtx key $ \ctx ->
-            case aeadInit mode' ctx iv' of
-                CryptoPassed iniAead ->
-                    let aead           = aeadAppendHeader iniAead aad
-                        (eText, aeadE) = aeadEncrypt aead plaintext
-                        (dText, aeadD) = aeadDecrypt aead eText
-                        eTag           = aeadFinalize aeadE (blockSize ctx)
-                        dTag           = aeadFinalize aeadD (blockSize ctx)
-                     in (plaintext `assertEq` dText) && (eTag `B.eq` dTag)
-                CryptoFailed err
-                    | err == CryptoError_AEADModeNotSupported -> True
-                    | otherwise                               -> error ("testProperty_AEAD: " ++ show err)
-            where (mode', iv') = updateCcmInputSize mode (B.length plaintext) testIV
-                  updateCcmInputSize aeadmode k iv = case aeadmode of
-                    AEAD_CCM _ m l -> (AEAD_CCM k m l, B.take 13 (iv <> (B.replicate 15 0)))
-                    aeadOther      -> (aeadOther, iv)
+  where
+    aeadProp = toTests cipher
+    toTests :: BlockCipher a => a -> (AEADMode -> AEADUnit a -> Bool)
+    toTests _ = testProperty_AEAD
+    testProperty_AEAD mode (AEADUnit key testIV (unPlaintext -> aad) (unPlaintext -> plaintext)) = withCtx key $ \ctx ->
+        case aeadInit mode' ctx iv' of
+            CryptoPassed iniAead ->
+                let aead = aeadAppendHeader iniAead aad
+                    (eText, aeadE) = aeadEncrypt aead plaintext
+                    (dText, aeadD) = aeadDecrypt aead eText
+                    eTag = aeadFinalize aeadE (blockSize ctx)
+                    dTag = aeadFinalize aeadD (blockSize ctx)
+                 in (plaintext `assertEq` dText) && (eTag `B.eq` dTag)
+            CryptoFailed err
+                | err == CryptoError_AEADModeNotSupported -> True
+                | otherwise ->
+                    error ("testProperty_AEAD: " ++ show err)
+      where
+        (mode', iv') = updateCcmInputSize mode (B.length plaintext) testIV
+        updateCcmInputSize aeadmode k iv = case aeadmode of
+            AEAD_CCM _ m l -> (AEAD_CCM k m l, B.take 13 (iv <> (B.replicate 15 0)))
+            aeadOther -> (aeadOther, iv)
 
 withCtx :: Cipher c => Key c -> (c -> a) -> a
 withCtx (Key key) f =
     case cipherInit key of
-        CryptoFailed e   -> error ("init failed: " ++ show e)
+        CryptoFailed e -> error ("init failed: " ++ show e)
         CryptoPassed ctx -> f ctx
 
 {-
@@ -440,19 +533,23 @@
 -- related to block cipher modes.
 testModes :: BlockCipher a => a -> [TestTree]
 testModes cipher =
-    [ testGroup "decrypt.encrypt==id"
---        (testBlockCipherBasic cipher ++ testBlockCipherModes cipher ++ testBlockCipherAEAD cipher ++ testBlockCipherXTS cipher)
-        (testBlockCipherBasic cipher ++ testBlockCipherModes cipher ++ testBlockCipherAEAD cipher)
+    [ testGroup
+        "decrypt.encrypt==id"
+        --        (testBlockCipherBasic cipher ++ testBlockCipherModes cipher ++ testBlockCipherAEAD cipher ++ testBlockCipherXTS cipher)
+        ( testBlockCipherBasic cipher
+            ++ testBlockCipherModes cipher
+            ++ testBlockCipherAEAD cipher
+        )
     ]
 
 -- | Test IV arithmetic (based on the cipher block size)
 testIvArith :: BlockCipher a => a -> [TestTree]
 testIvArith cipher =
     [ testCase "nullIV is null" $
-          True @=? B.all (== 0) (ivNull cipher)
+        True @=? B.all (== 0) (ivNull cipher)
     , testProperty "ivAdd is linear" $ \a b -> do
-          iv <- generateIvFromCipher cipher
-          return $ ivAdd iv (a + b) `propertyEq` ivAdd (ivAdd iv a) b
+        iv <- generateIvFromCipher cipher
+        return $ ivAdd iv (a + b) `propertyEq` ivAdd (ivAdd iv a) b
     ]
   where
     ivNull :: BlockCipher a => a -> IV a
@@ -464,15 +561,18 @@
         let n = blockSize c
         i <- choose (0, n)
         let zeros = Prelude.replicate (n - i) 0x00
-            ones  = Prelude.replicate i 0xFF
+            ones = Prelude.replicate i 0xFF
         return $ cipherMakeIV c (B.pack $ zeros ++ ones)
 
 -- | Return tests for a specific blockcipher and a list of KATs
 testBlockCipher :: BlockCipher a => KATs -> a -> TestTree
-testBlockCipher kats cipher = testGroup (cipherName cipher)
-    (  (if kats == defaultKATs  then [] else [testKATs kats cipher])
-    ++ testModes cipher ++ testIvArith cipher
-    )
+testBlockCipher kats cipher =
+    testGroup
+        (cipherName cipher)
+        ( (if kats == defaultKATs then [] else [testKATs kats cipher])
+            ++ testModes cipher
+            ++ testIvArith cipher
+        )
 
 cipherMakeKey :: Cipher cipher => cipher -> ByteString -> Key cipher
 cipherMakeKey _ bs = Key bs
@@ -482,7 +582,9 @@
 
 maybeGroup :: (String -> t -> [TestTree]) -> TestName -> [t] -> [TestTree]
 maybeGroup mkTest groupName l
-    | null l    = []
-    | otherwise = [testGroup groupName (concatMap (\(i, d) -> mkTest (show i) d) $ zip nbs l)]
-  where nbs :: [Int]
-        nbs = [0..]
+    | null l = []
+    | otherwise =
+        [testGroup groupName (concatMap (\(i, d) -> mkTest (show i) d) $ zip nbs l)]
+  where
+    nbs :: [Int]
+    nbs = [0 ..]
diff --git a/tests/ChaCha.hs b/tests/ChaCha.hs
--- a/tests/ChaCha.hs
+++ b/tests/ChaCha.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module ChaCha (tests) where
 
 import qualified Crypto.Cipher.ChaCha as ChaCha
@@ -6,7 +7,8 @@
 
 import qualified Data.ByteString as B
 
-b8_128_k0_i0 = "\xe2\x8a\x5f\xa4\xa6\x7f\x8c\x5d\xef\xed\x3e\x6f\xb7\x30\x34\x86\xaa\x84\x27\xd3\x14\x19\xa7\x29\x57\x2d\x77\x79\x53\x49\x11\x20\xb6\x4a\xb8\xe7\x2b\x8d\xeb\x85\xcd\x6a\xea\x7c\xb6\x08\x9a\x10\x18\x24\xbe\xeb\x08\x81\x4a\x42\x8a\xab\x1f\xa2\xc8\x16\x08\x1b\x8a\x26\xaf\x44\x8a\x1b\xa9\x06\x36\x8f\xd8\xc8\x38\x31\xc1\x8c\xec\x8c\xed\x81\x1a\x02\x8e\x67\x5b\x8d\x2b\xe8\xfc\xe0\x81\x16\x5c\xea\xe9\xf1\xd1\xb7\xa9\x75\x49\x77\x49\x48\x05\x69\xce\xb8\x3d\xe6\xa0\xa5\x87\xd4\x98\x4f\x19\x92\x5f\x5d\x33\x8e\x43\x0d"
+b8_128_k0_i0 =
+    "\xe2\x8a\x5f\xa4\xa6\x7f\x8c\x5d\xef\xed\x3e\x6f\xb7\x30\x34\x86\xaa\x84\x27\xd3\x14\x19\xa7\x29\x57\x2d\x77\x79\x53\x49\x11\x20\xb6\x4a\xb8\xe7\x2b\x8d\xeb\x85\xcd\x6a\xea\x7c\xb6\x08\x9a\x10\x18\x24\xbe\xeb\x08\x81\x4a\x42\x8a\xab\x1f\xa2\xc8\x16\x08\x1b\x8a\x26\xaf\x44\x8a\x1b\xa9\x06\x36\x8f\xd8\xc8\x38\x31\xc1\x8c\xec\x8c\xed\x81\x1a\x02\x8e\x67\x5b\x8d\x2b\xe8\xfc\xe0\x81\x16\x5c\xea\xe9\xf1\xd1\xb7\xa9\x75\x49\x77\x49\x48\x05\x69\xce\xb8\x3d\xe6\xa0\xa5\x87\xd4\x98\x4f\x19\x92\x5f\x5d\x33\x8e\x43\x0d"
 
 b12_128_k0_i0 =
     "\xe1\x04\x7b\xa9\x47\x6b\xf8\xff\x31\x2c\x01\xb4\x34\x5a\x7d\x8c\xa5\x79\x2b\x0a\xd4\x67\x31\x3f\x1d\xc4\x12\xb5\xfd\xce\x32\x41\x0d\xea\x8b\x68\xbd\x77\x4c\x36\xa9\x20\xf0\x92\xa0\x4d\x3f\x95\x27\x4f\xbe\xff\x97\xbc\x84\x91\xfc\xef\x37\xf8\x59\x70\xb4\x50\x1d\x43\xb6\x1a\x8f\x7e\x19\xfc\xed\xde\xf3\x68\xae\x6b\xfb\x11\x10\x1b\xd9\xfd\x3e\x4d\x12\x7d\xe3\x0d\xb2\xdb\x1b\x47\x2e\x76\x42\x68\x03\xa4\x5e\x15\xb9\x62\x75\x19\x86\xef\x1d\x9d\x50\xf5\x98\xa5\xdc\xdc\x9f\xa5\x29\xa2\x83\x57\x99\x1e\x78\x4e\xa2\x0f"
@@ -26,78 +28,137 @@
 -- XChaCha20 test vector from RFC draft: https://datatracker.ietf.org/doc/html/draft-arciszewski-xchacha
 
 xChaCha20_ExampleKAT = expected @=? fst (ChaCha.combine initState plaintext)
-    where iv = B.pack $ [0x40 .. 0x56] ++ [0x58]
-          key = B.pack [0x80 .. 0x9f]
-          initState = ChaCha.initializeX 20 key iv
-          plaintext :: B.ByteString
-          plaintext = "The dhole (pronounced \"dole\") is also known as the Asiatic wild dog, red dog, and whistling dog. It is about the size of a German shepherd but looks more like a long-legged fox. This highly elusive and skilled jumper is classified with wolves, coyotes, jackals, and foxes in the taxonomic family Canidae."
-          expected :: B.ByteString
-          expected = "\x45\x59\xab\xba\x4e\x48\xc1\x61\x02\xe8\xbb\x2c\x05\xe6\x94\x7f\x50\xa7\x86\xde\x16\x2f\x9b\x0b\x7e\x59\x2a\x9b\x53\xd0\xd4\xe9\x8d\x8d\x64\x10\xd5\x40\xa1\xa6\x37\x5b\x26\xd8\x0d\xac\xe4\xfa\xb5\x23\x84\xc7\x31\xac\xbf\x16\xa5\x92\x3c\x0c\x48\xd3\x57\x5d\x4d\x0d\x2c\x67\x3b\x66\x6f\xaa\x73\x10\x61\x27\x77\x01\x09\x3a\x6b\xf7\xa1\x58\xa8\x86\x42\x92\xa4\x1c\x48\xe3\xa9\xb4\xc0\xda\xec\xe0\xf8\xd9\x8d\x0d\x7e\x05\xb3\x7a\x30\x7b\xbb\x66\x33\x31\x64\xec\x9e\x1b\x24\xea\x0d\x6c\x3f\xfd\xdc\xec\x4f\x68\xe7\x44\x30\x56\x19\x3a\x03\xc8\x10\xe1\x13\x44\xca\x06\xd8\xed\x8a\x2b\xfb\x1e\x8d\x48\xcf\xa6\xbc\x0e\xb4\xe2\x46\x4b\x74\x81\x42\x40\x7c\x9f\x43\x1a\xee\x76\x99\x60\xe1\x5b\xa8\xb9\x68\x90\x46\x6e\xf2\x45\x75\x99\x85\x23\x85\xc6\x61\xf7\x52\xce\x20\xf9\xda\x0c\x09\xab\x6b\x19\xdf\x74\xe7\x6a\x95\x96\x74\x46\xf8\xd0\xfd\x41\x5e\x7b\xee\x2a\x12\xa1\x14\xc2\x0e\xb5\x29\x2a\xe7\xa3\x49\xae\x57\x78\x20\xd5\x52\x0a\x1f\x3f\xb6\x2a\x17\xce\x6a\x7e\x68\xfa\x7c\x79\x11\x1d\x88\x60\x92\x0b\xc0\x48\xef\x43\xfe\x84\x48\x6c\xcb\x87\xc2\x5f\x0a\xe0\x45\xf0\xcc\xe1\xe7\x98\x9a\x9a\xa2\x20\xa2\x8b\xdd\x48\x27\xe7\x51\xa2\x4a\x6d\x5c\x62\xd7\x90\xa6\x63\x93\xb9\x31\x11\xc1\xa5\x5d\xd7\x42\x1a\x10\x18\x49\x74\xc7\xc5"
-
+  where
+    iv = B.pack $ [0x40 .. 0x56] ++ [0x58]
+    key = B.pack [0x80 .. 0x9f]
+    initState = ChaCha.initializeX 20 key iv
+    plaintext :: B.ByteString
+    plaintext =
+        "The dhole (pronounced \"dole\") is also known as the Asiatic wild dog, red dog, and whistling dog. It is about the size of a German shepherd but looks more like a long-legged fox. This highly elusive and skilled jumper is classified with wolves, coyotes, jackals, and foxes in the taxonomic family Canidae."
+    expected :: B.ByteString
+    expected =
+        "\x45\x59\xab\xba\x4e\x48\xc1\x61\x02\xe8\xbb\x2c\x05\xe6\x94\x7f\x50\xa7\x86\xde\x16\x2f\x9b\x0b\x7e\x59\x2a\x9b\x53\xd0\xd4\xe9\x8d\x8d\x64\x10\xd5\x40\xa1\xa6\x37\x5b\x26\xd8\x0d\xac\xe4\xfa\xb5\x23\x84\xc7\x31\xac\xbf\x16\xa5\x92\x3c\x0c\x48\xd3\x57\x5d\x4d\x0d\x2c\x67\x3b\x66\x6f\xaa\x73\x10\x61\x27\x77\x01\x09\x3a\x6b\xf7\xa1\x58\xa8\x86\x42\x92\xa4\x1c\x48\xe3\xa9\xb4\xc0\xda\xec\xe0\xf8\xd9\x8d\x0d\x7e\x05\xb3\x7a\x30\x7b\xbb\x66\x33\x31\x64\xec\x9e\x1b\x24\xea\x0d\x6c\x3f\xfd\xdc\xec\x4f\x68\xe7\x44\x30\x56\x19\x3a\x03\xc8\x10\xe1\x13\x44\xca\x06\xd8\xed\x8a\x2b\xfb\x1e\x8d\x48\xcf\xa6\xbc\x0e\xb4\xe2\x46\x4b\x74\x81\x42\x40\x7c\x9f\x43\x1a\xee\x76\x99\x60\xe1\x5b\xa8\xb9\x68\x90\x46\x6e\xf2\x45\x75\x99\x85\x23\x85\xc6\x61\xf7\x52\xce\x20\xf9\xda\x0c\x09\xab\x6b\x19\xdf\x74\xe7\x6a\x95\x96\x74\x46\xf8\xd0\xfd\x41\x5e\x7b\xee\x2a\x12\xa1\x14\xc2\x0e\xb5\x29\x2a\xe7\xa3\x49\xae\x57\x78\x20\xd5\x52\x0a\x1f\x3f\xb6\x2a\x17\xce\x6a\x7e\x68\xfa\x7c\x79\x11\x1d\x88\x60\x92\x0b\xc0\x48\xef\x43\xfe\x84\x48\x6c\xcb\x87\xc2\x5f\x0a\xe0\x45\xf0\xcc\xe1\xe7\x98\x9a\x9a\xa2\x20\xa2\x8b\xdd\x48\x27\xe7\x51\xa2\x4a\x6d\x5c\x62\xd7\x90\xa6\x63\x93\xb9\x31\x11\xc1\xa5\x5d\xd7\x42\x1a\x10\x18\x49\x74\xc7\xc5"
 
-data Vector = Vector Int -- rounds
-                     ByteString -- key
-                     ByteString -- nonce
-    deriving (Show,Eq)
+rfc8439A2_1 = cipher @=? cipher'
+  where
+    key :: ByteString
+    key =
+        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+    nonce :: ByteString
+    nonce = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+    plain :: ByteString
+    plain =
+        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+    cipher :: ByteString
+    cipher =
+        "\x76\xb8\xe0\xad\xa0\xf1\x3d\x90\x40\x5d\x6a\xe5\x53\x86\xbd\x28\xbd\xd2\x19\xb8\xa0\x8d\xed\x1a\xa8\x36\xef\xcc\x8b\x77\x0d\xc7\xda\x41\x59\x7c\x51\x57\x48\x8d\x77\x24\xe0\x3f\xb8\xd8\x4a\x37\x6a\x43\xb8\xf4\x15\x18\xa1\x1c\xc3\x87\xb6\x69\xb2\xee\x65\x86"
+    cipher' = fst $ ChaCha.combine (ChaCha.initialize 20 key nonce) plain
 
-instance Arbitrary Vector where
-    arbitrary = Vector 20 <$> arbitraryBS 16 <*> arbitraryBS 12
+rfc8439A2_2 = cipher @=? cipher'
+  where
+    key :: ByteString
+    key =
+        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
+    nonce :: ByteString
+    nonce = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02"
+    plain :: ByteString
+    plain =
+        "\x41\x6e\x79\x20\x73\x75\x62\x6d\x69\x73\x73\x69\x6f\x6e\x20\x74\x6f\x20\x74\x68\x65\x20\x49\x45\x54\x46\x20\x69\x6e\x74\x65\x6e\x64\x65\x64\x20\x62\x79\x20\x74\x68\x65\x20\x43\x6f\x6e\x74\x72\x69\x62\x75\x74\x6f\x72\x20\x66\x6f\x72\x20\x70\x75\x62\x6c\x69\x63\x61\x74\x69\x6f\x6e\x20\x61\x73\x20\x61\x6c\x6c\x20\x6f\x72\x20\x70\x61\x72\x74\x20\x6f\x66\x20\x61\x6e\x20\x49\x45\x54\x46\x20\x49\x6e\x74\x65\x72\x6e\x65\x74\x2d\x44\x72\x61\x66\x74\x20\x6f\x72\x20\x52\x46\x43\x20\x61\x6e\x64\x20\x61\x6e\x79\x20\x73\x74\x61\x74\x65\x6d\x65\x6e\x74\x20\x6d\x61\x64\x65\x20\x77\x69\x74\x68\x69\x6e\x20\x74\x68\x65\x20\x63\x6f\x6e\x74\x65\x78\x74\x20\x6f\x66\x20\x61\x6e\x20\x49\x45\x54\x46\x20\x61\x63\x74\x69\x76\x69\x74\x79\x20\x69\x73\x20\x63\x6f\x6e\x73\x69\x64\x65\x72\x65\x64\x20\x61\x6e\x20\x22\x49\x45\x54\x46\x20\x43\x6f\x6e\x74\x72\x69\x62\x75\x74\x69\x6f\x6e\x22\x2e\x20\x53\x75\x63\x68\x20\x73\x74\x61\x74\x65\x6d\x65\x6e\x74\x73\x20\x69\x6e\x63\x6c\x75\x64\x65\x20\x6f\x72\x61\x6c\x20\x73\x74\x61\x74\x65\x6d\x65\x6e\x74\x73\x20\x69\x6e\x20\x49\x45\x54\x46\x20\x73\x65\x73\x73\x69\x6f\x6e\x73\x2c\x20\x61\x73\x20\x77\x65\x6c\x6c\x20\x61\x73\x20\x77\x72\x69\x74\x74\x65\x6e\x20\x61\x6e\x64\x20\x65\x6c\x65\x63\x74\x72\x6f\x6e\x69\x63\x20\x63\x6f\x6d\x6d\x75\x6e\x69\x63\x61\x74\x69\x6f\x6e\x73\x20\x6d\x61\x64\x65\x20\x61\x74\x20\x61\x6e\x79\x20\x74\x69\x6d\x65\x20\x6f\x72\x20\x70\x6c\x61\x63\x65\x2c\x20\x77\x68\x69\x63\x68\x20\x61\x72\x65\x20\x61\x64\x64\x72\x65\x73\x73\x65\x64\x20\x74\x6f"
+    cipher :: ByteString
+    cipher =
+        "\xa3\xfb\xf0\x7d\xf3\xfa\x2f\xde\x4f\x37\x6c\xa2\x3e\x82\x73\x70\x41\x60\x5d\x9f\x4f\x4f\x57\xbd\x8c\xff\x2c\x1d\x4b\x79\x55\xec\x2a\x97\x94\x8b\xd3\x72\x29\x15\xc8\xf3\xd3\x37\xf7\xd3\x70\x05\x0e\x9e\x96\xd6\x47\xb7\xc3\x9f\x56\xe0\x31\xca\x5e\xb6\x25\x0d\x40\x42\xe0\x27\x85\xec\xec\xfa\x4b\x4b\xb5\xe8\xea\xd0\x44\x0e\x20\xb6\xe8\xdb\x09\xd8\x81\xa7\xc6\x13\x2f\x42\x0e\x52\x79\x50\x42\xbd\xfa\x77\x73\xd8\xa9\x05\x14\x47\xb3\x29\x1c\xe1\x41\x1c\x68\x04\x65\x55\x2a\xa6\xc4\x05\xb7\x76\x4d\x5e\x87\xbe\xa8\x5a\xd0\x0f\x84\x49\xed\x8f\x72\xd0\xd6\x62\xab\x05\x26\x91\xca\x66\x42\x4b\xc8\x6d\x2d\xf8\x0e\xa4\x1f\x43\xab\xf9\x37\xd3\x25\x9d\xc4\xb2\xd0\xdf\xb4\x8a\x6c\x91\x39\xdd\xd7\xf7\x69\x66\xe9\x28\xe6\x35\x55\x3b\xa7\x6c\x5c\x87\x9d\x7b\x35\xd4\x9e\xb2\xe6\x2b\x08\x71\xcd\xac\x63\x89\x39\xe2\x5e\x8a\x1e\x0e\xf9\xd5\x28\x0f\xa8\xca\x32\x8b\x35\x1c\x3c\x76\x59\x89\xcb\xcf\x3d\xaa\x8b\x6c\xcc\x3a\xaf\x9f\x39\x79\xc9\x2b\x37\x20\xfc\x88\xdc\x95\xed\x84\xa1\xbe\x05\x9c\x64\x99\xb9\xfd\xa2\x36\xe7\xe8\x18\xb0\x4b\x0b\xc3\x9c\x1e\x87\x6b\x19\x3b\xfe\x55\x69\x75\x3f\x88\x12\x8c\xc0\x8a\xaa\x9b\x63\xd1\xa1\x6f\x80\xef\x25\x54\xd7\x18\x9c\x41\x1f\x58\x69\xca\x52\xc5\xb8\x3f\xa3\x6f\xf2\x16\xb9\xc1\xd3\x00\x62\xbe\xbc\xfd\x2d\xc5\xbc\xe0\x91\x19\x34\xfd\xa7\x9a\x86\xf6\xe6\x98\xce\xd7\x59\xc3\xff\x9b\x64\x77\x33\x8f\x3d\xa4\xf9\xcd\x85\x14\xea\x99\x82\xcc\xaf\xb3\x41\xb2\x38\x4d\xd9\x02\xf3\xd1\xab\x7a\xc6\x1d\xd2\x9c\x6f\x21\xba\x5b\x86\x2f\x37\x30\xe3\x7c\xfd\xc4\xfd\x80\x6c\x22\xf2\x21"
+    cipher' =
+        fst $
+            ChaCha.combine (ChaCha.setCounter32 1 (ChaCha.initialize 20 key nonce)) plain
 
-tests = testGroup "ChaCha"
-    [ testCase "8-128-K0-I0"  (chachaRunSimple b8_128_k0_i0 8 16 8)
-    , testCase "12-128-K0-I0" (chachaRunSimple b12_128_k0_i0 12 16 8)
-    , testCase "20-128-K0-I0" (chachaRunSimple b20_128_k0_i0 20 16 8)
-    , testCase "8-256-K0-I0"  (chachaRunSimple b8_256_k0_i0 8 32 8)
-    , testCase "12-256-K0-I0" (chachaRunSimple b12_256_k0_i0 12 32 8)
-    , testCase "20-256-K0-I0" (chachaRunSimple b20_256_k0_i0 20 32 8)
-    , testCase "XChaCha20 example KAT" xChaCha20_ExampleKAT
-    , testProperty "generate-combine" chachaGenerateCombine
-    , testProperty "chunking-generate" chachaGenerateChunks
-    , testProperty "chunking-combine" chachaCombineChunks
-    ]
-  where chachaRunSimple expected rounds klen nonceLen =
-            let chacha = ChaCha.initialize rounds (B.replicate klen 0) (B.replicate nonceLen 0)
-             in expected @=? fst (ChaCha.generate chacha (B.length expected))
+rfc8439A2_3 = cipher @=? cipher'
+  where
+    key :: ByteString
+    key =
+        "\x1c\x92\x40\xa5\xeb\x55\xd3\x8a\xf3\x33\x88\x86\x04\xf6\xb5\xf0\x47\x39\x17\xc1\x40\x2b\x80\x09\x9d\xca\x5c\xbc\x20\x70\x75\xc0"
+    nonce :: ByteString
+    nonce = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02"
+    plain :: ByteString
+    plain =
+        "\x27\x54\x77\x61\x73\x20\x62\x72\x69\x6c\x6c\x69\x67\x2c\x20\x61\x6e\x64\x20\x74\x68\x65\x20\x73\x6c\x69\x74\x68\x79\x20\x74\x6f\x76\x65\x73\x0a\x44\x69\x64\x20\x67\x79\x72\x65\x20\x61\x6e\x64\x20\x67\x69\x6d\x62\x6c\x65\x20\x69\x6e\x20\x74\x68\x65\x20\x77\x61\x62\x65\x3a\x0a\x41\x6c\x6c\x20\x6d\x69\x6d\x73\x79\x20\x77\x65\x72\x65\x20\x74\x68\x65\x20\x62\x6f\x72\x6f\x67\x6f\x76\x65\x73\x2c\x0a\x41\x6e\x64\x20\x74\x68\x65\x20\x6d\x6f\x6d\x65\x20\x72\x61\x74\x68\x73\x20\x6f\x75\x74\x67\x72\x61\x62\x65\x2e"
+    cipher :: ByteString
+    cipher =
+        "\x62\xe6\x34\x7f\x95\xed\x87\xa4\x5f\xfa\xe7\x42\x6f\x27\xa1\xdf\x5f\xb6\x91\x10\x04\x4c\x0d\x73\x11\x8e\xff\xa9\x5b\x01\xe5\xcf\x16\x6d\x3d\xf2\xd7\x21\xca\xf9\xb2\x1e\x5f\xb1\x4c\x61\x68\x71\xfd\x84\xc5\x4f\x9d\x65\xb2\x83\x19\x6c\x7f\xe4\xf6\x05\x53\xeb\xf3\x9c\x64\x02\xc4\x22\x34\xe3\x2a\x35\x6b\x3e\x76\x43\x12\xa6\x1a\x55\x32\x05\x57\x16\xea\xd6\x96\x25\x68\xf8\x7d\x3f\x3f\x77\x04\xc6\xa8\xd1\xbc\xd1\xbf\x4d\x50\xd6\x15\x4b\x6d\xa7\x31\xb1\x87\xb5\x8d\xfd\x72\x8a\xfa\x36\x75\x7a\x79\x7a\xc1\x88\xd1"
+    cipher' =
+        fst $
+            ChaCha.combine (ChaCha.setCounter32 42 (ChaCha.initialize 20 key nonce)) plain
 
-        chachaGenerateChunks :: ChunkingLen -> Vector -> Bool
-        chachaGenerateChunks (ChunkingLen ckLen) (Vector rounds key iv) =
-            let initChaCha    = ChaCha.initialize rounds key iv
-                nbBytes       = 1048
-                (expected,_)  = ChaCha.generate initChaCha nbBytes
-                chunks        = loop nbBytes ckLen initChaCha
-             in expected `propertyEq` B.concat chunks
+data Vector
+    = Vector
+        Int -- rounds
+        ByteString -- key
+        ByteString -- nonce
+    deriving (Show, Eq)
 
-          where loop n []     chacha = loop n ckLen chacha
-                loop 0 _      _      = []
-                loop n (x:xs) chacha =
-                    let len       = min x n
-                        (c, next) = ChaCha.generate chacha len
-                     in c : loop (n - len) xs next
+instance Arbitrary Vector where
+    arbitrary = Vector 20 <$> arbitraryBS 16 <*> arbitraryBS 12
 
-        chachaGenerateCombine :: ChunkingLen0_127 -> Vector -> Int0_2901 -> Bool
-        chachaGenerateCombine (ChunkingLen0_127 ckLen) (Vector rounds key iv) (Int0_2901 nbBytes) =
-            let initChaCha    = ChaCha.initialize rounds key iv
-             in loop nbBytes ckLen initChaCha
-          where loop n []     chacha = loop n ckLen chacha
-                loop 0 _      _     = True
-                loop n (x:xs) chacha =
-                    let len        = min x n
-                        (c1, next) = ChaCha.generate chacha len
-                        (c2, _)    = ChaCha.combine chacha (B.replicate len 0)
-                     in if c1 == c2 then loop (n - len) xs next else False
+tests =
+    testGroup
+        "ChaCha"
+        [ testCase "8-128-K0-I0" (chachaRunSimple b8_128_k0_i0 8 16 8)
+        , testCase "12-128-K0-I0" (chachaRunSimple b12_128_k0_i0 12 16 8)
+        , testCase "20-128-K0-I0" (chachaRunSimple b20_128_k0_i0 20 16 8)
+        , testCase "8-256-K0-I0" (chachaRunSimple b8_256_k0_i0 8 32 8)
+        , testCase "12-256-K0-I0" (chachaRunSimple b12_256_k0_i0 12 32 8)
+        , testCase "20-256-K0-I0" (chachaRunSimple b20_256_k0_i0 20 32 8)
+        , testCase "XChaCha20 example KAT" xChaCha20_ExampleKAT
+        , testCase "RFC 8439 A2 #1 ChaCha20" rfc8439A2_1
+        , testCase "RFC 8439 A2 #2 ChaCha20" rfc8439A2_2
+        , testCase "RFC 8439 A2 #3 ChaCha20" rfc8439A2_3
+        , testProperty "generate-combine" chachaGenerateCombine
+        , testProperty "chunking-generate" chachaGenerateChunks
+        , testProperty "chunking-combine" chachaCombineChunks
+        ]
+  where
+    chachaRunSimple expected rounds klen nonceLen =
+        let chacha = ChaCha.initialize rounds (B.replicate klen 0) (B.replicate nonceLen 0)
+         in expected @=? fst (ChaCha.generate chacha (B.length expected))
 
+    chachaGenerateChunks :: ChunkingLen -> Vector -> Bool
+    chachaGenerateChunks (ChunkingLen ckLen) (Vector rounds key iv) =
+        let initChaCha = ChaCha.initialize rounds key iv
+            nbBytes = 1048
+            (expected, _) = ChaCha.generate initChaCha nbBytes
+            chunks = loop nbBytes ckLen initChaCha
+         in expected `propertyEq` B.concat chunks
+      where
+        loop n [] chacha = loop n ckLen chacha
+        loop 0 _ _ = []
+        loop n (x : xs) chacha =
+            let len = min x n
+                (c, next) = ChaCha.generate chacha len
+             in c : loop (n - len) xs next
 
-        chachaCombineChunks :: ChunkingLen0_127 -> Vector -> ArbitraryBS0_2901 -> Bool
-        chachaCombineChunks (ChunkingLen0_127 ckLen) (Vector rounds key iv) (ArbitraryBS0_2901 wholebs) =
-            let initChaCha    = ChaCha.initialize rounds key iv
-                (expected,_)  = ChaCha.combine initChaCha wholebs
-                chunks        = loop wholebs ckLen initChaCha
-             in expected `propertyEq` B.concat chunks
+    chachaGenerateCombine :: ChunkingLen0_127 -> Vector -> Int0_2901 -> Bool
+    chachaGenerateCombine (ChunkingLen0_127 ckLen) (Vector rounds key iv) (Int0_2901 nbBytes) =
+        let initChaCha = ChaCha.initialize rounds key iv
+         in loop nbBytes ckLen initChaCha
+      where
+        loop n [] chacha = loop n ckLen chacha
+        loop 0 _ _ = True
+        loop n (x : xs) chacha =
+            let len = min x n
+                (c1, next) = ChaCha.generate chacha len
+                (c2, _) = ChaCha.combine chacha (B.replicate len 0)
+             in if c1 == c2 then loop (n - len) xs next else False
 
-          where loop bs []     chacha = loop bs ckLen chacha
-                loop bs (x:xs) chacha
-                    | B.null bs = []
-                    | otherwise =
-                        let (bs1, bs2) = B.splitAt (min x (B.length bs)) bs
-                            (c, next)  = ChaCha.combine chacha bs1
-                         in c : loop bs2 xs next
+    chachaCombineChunks :: ChunkingLen0_127 -> Vector -> ArbitraryBS0_2901 -> Bool
+    chachaCombineChunks (ChunkingLen0_127 ckLen) (Vector rounds key iv) (ArbitraryBS0_2901 wholebs) =
+        let initChaCha = ChaCha.initialize rounds key iv
+            (expected, _) = ChaCha.combine initChaCha wholebs
+            chunks = loop wholebs ckLen initChaCha
+         in expected `propertyEq` B.concat chunks
+      where
+        loop bs [] chacha = loop bs ckLen chacha
+        loop bs (x : xs) chacha
+            | B.null bs = []
+            | otherwise =
+                let (bs1, bs2) = B.splitAt (min x (B.length bs)) bs
+                    (c, next) = ChaCha.combine chacha bs1
+                 in c : loop bs2 xs next
diff --git a/tests/ChaChaPoly1305.hs b/tests/ChaChaPoly1305.hs
--- a/tests/ChaChaPoly1305.hs
+++ b/tests/ChaChaPoly1305.hs
@@ -1,89 +1,169 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module ChaChaPoly1305 where
 
-import qualified Crypto.Cipher.ChaChaPoly1305 as AEAD
-import Imports
+import qualified Crypto.Cipher.ChaChaPoly1305 as CP
+import Crypto.Cipher.Types
 import Crypto.Error
+import Imports
 import Poly1305 ()
 
-import qualified Data.ByteString as B
 import qualified Data.ByteArray as B (convert)
+import qualified Data.ByteString as B
 
-plaintext, aad, key, iv, ivX, ciphertext, ciphertextX, tag, tagX, nonce1, nonce2, nonce3, nonce4, nonce5, nonce6, nonce7, nonce8, nonce9, nonce10 :: B.ByteString
-plaintext = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it."
+plaintext
+    , aad
+    , key
+    , iv
+    , ivX
+    , ciphertext
+    , ciphertextX
+    , tag
+    , tagX
+    , nonce1
+    , nonce2
+    , nonce3
+    , nonce4
+    , nonce5
+    , nonce6
+    , nonce7
+    , nonce8
+    , nonce9
+    , nonce10
+        :: B.ByteString
+plaintext =
+    "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it."
 aad = "\x50\x51\x52\x53\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
-key = "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
+key =
+    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
 iv = "\x40\x41\x42\x43\x44\x45\x46\x47"
 ivX = B.pack [0x40 .. 0x57]
 constant = "\x07\x00\x00\x00"
-ciphertext = "\xd3\x1a\x8d\x34\x64\x8e\x60\xdb\x7b\x86\xaf\xbc\x53\xef\x7e\xc2\xa4\xad\xed\x51\x29\x6e\x08\xfe\xa9\xe2\xb5\xa7\x36\xee\x62\xd6\x3d\xbe\xa4\x5e\x8c\xa9\x67\x12\x82\xfa\xfb\x69\xda\x92\x72\x8b\x1a\x71\xde\x0a\x9e\x06\x0b\x29\x05\xd6\xa5\xb6\x7e\xcd\x3b\x36\x92\xdd\xbd\x7f\x2d\x77\x8b\x8c\x98\x03\xae\xe3\x28\x09\x1b\x58\xfa\xb3\x24\xe4\xfa\xd6\x75\x94\x55\x85\x80\x8b\x48\x31\xd7\xbc\x3f\xf4\xde\xf0\x8e\x4b\x7a\x9d\xe5\x76\xd2\x65\x86\xce\xc6\x4b\x61\x16"
-ciphertextX = "\xbd\x6d\x17\x9d\x3e\x83\xd4\x3b\x95\x76\x57\x94\x93\xc0\xe9\x39\x57\x2a\x17\x00\x25\x2b\xfa\xcc\xbe\xd2\x90\x2c\x21\x39\x6c\xbb\x73\x1c\x7f\x1b\x0b\x4a\xa6\x44\x0b\xf3\xa8\x2f\x4e\xda\x7e\x39\xae\x64\xc6\x70\x8c\x54\xc2\x16\xcb\x96\xb7\x2e\x12\x13\xb4\x52\x2f\x8c\x9b\xa4\x0d\xb5\xd9\x45\xb1\x1b\x69\xb9\x82\xc1\xbb\x9e\x3f\x3f\xac\x2b\xc3\x69\x48\x8f\x76\xb2\x38\x35\x65\xd3\xff\xf9\x21\xf9\x66\x4c\x97\x63\x7d\xa9\x76\x88\x12\xf6\x15\xc6\x8b\x13\xb5\x2e"
+ciphertext =
+    "\xd3\x1a\x8d\x34\x64\x8e\x60\xdb\x7b\x86\xaf\xbc\x53\xef\x7e\xc2\xa4\xad\xed\x51\x29\x6e\x08\xfe\xa9\xe2\xb5\xa7\x36\xee\x62\xd6\x3d\xbe\xa4\x5e\x8c\xa9\x67\x12\x82\xfa\xfb\x69\xda\x92\x72\x8b\x1a\x71\xde\x0a\x9e\x06\x0b\x29\x05\xd6\xa5\xb6\x7e\xcd\x3b\x36\x92\xdd\xbd\x7f\x2d\x77\x8b\x8c\x98\x03\xae\xe3\x28\x09\x1b\x58\xfa\xb3\x24\xe4\xfa\xd6\x75\x94\x55\x85\x80\x8b\x48\x31\xd7\xbc\x3f\xf4\xde\xf0\x8e\x4b\x7a\x9d\xe5\x76\xd2\x65\x86\xce\xc6\x4b\x61\x16"
+ciphertextX =
+    "\xbd\x6d\x17\x9d\x3e\x83\xd4\x3b\x95\x76\x57\x94\x93\xc0\xe9\x39\x57\x2a\x17\x00\x25\x2b\xfa\xcc\xbe\xd2\x90\x2c\x21\x39\x6c\xbb\x73\x1c\x7f\x1b\x0b\x4a\xa6\x44\x0b\xf3\xa8\x2f\x4e\xda\x7e\x39\xae\x64\xc6\x70\x8c\x54\xc2\x16\xcb\x96\xb7\x2e\x12\x13\xb4\x52\x2f\x8c\x9b\xa4\x0d\xb5\xd9\x45\xb1\x1b\x69\xb9\x82\xc1\xbb\x9e\x3f\x3f\xac\x2b\xc3\x69\x48\x8f\x76\xb2\x38\x35\x65\xd3\xff\xf9\x21\xf9\x66\x4c\x97\x63\x7d\xa9\x76\x88\x12\xf6\x15\xc6\x8b\x13\xb5\x2e"
 tag = "\x1a\xe1\x0b\x59\x4f\x09\xe2\x6a\x7e\x90\x2e\xcb\xd0\x60\x06\x91"
 tagX = "\xc0\x87\x59\x24\xc1\xc7\x98\x79\x47\xde\xaf\xd8\x78\x0a\xcf\x49"
-nonce1  = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-nonce2  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-nonce3  = "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-nonce4  = "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-nonce5  = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
-nonce6  = "\x00\x00\x00\x00\x00\x00\x00\x00"
-nonce7  = "\x01\x00\x00\x00\x00\x00\x00\x00"
-nonce8  = "\xff\x00\x00\x00\x00\x00\x00\x00"
-nonce9  = "\x00\x01\x00\x00\x00\x00\x00\x00"
+nonce1 = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+nonce2 = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+nonce3 = "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+nonce4 = "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+nonce5 = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
+nonce6 = "\x00\x00\x00\x00\x00\x00\x00\x00"
+nonce7 = "\x01\x00\x00\x00\x00\x00\x00\x00"
+nonce8 = "\xff\x00\x00\x00\x00\x00\x00\x00"
+nonce9 = "\x00\x01\x00\x00\x00\x00\x00\x00"
 nonce10 = "\xff\xff\xff\xff\xff\xff\xff\xff"
 
-tests = testGroup "ChaChaPoly1305"
-    [ testCase "V1" runEncrypt
-    , testCase "V1-decrypt" runDecrypt
-    , testCase "V1-extended" runEncryptX
-    , testCase "V1-extended-decrypt" runDecryptX
-    , testCase "nonce increment" runNonceInc
-    ]
-  where runEncrypt =
-            let ini                 = throwCryptoError $ AEAD.initialize key (throwCryptoError $ AEAD.nonce8 constant iv)
-                afterAAD            = AEAD.finalizeAAD (AEAD.appendAAD aad ini)
-                (out, afterEncrypt) = AEAD.encrypt plaintext afterAAD
-                outtag              = AEAD.finalize afterEncrypt
-             in propertyHoldCase [ eqTest "ciphertext" ciphertext out
-                                 , eqTest "tag" tag (B.convert outtag)
-                                 ]
-        runEncryptX =
-            let ini                 = throwCryptoError $ AEAD.initializeX key (throwCryptoError $ AEAD.nonce24 ivX)
-                afterAAD            = AEAD.finalizeAAD (AEAD.appendAAD aad ini)
-                (out, afterEncrypt) = AEAD.encrypt plaintext afterAAD
-                outtag              = AEAD.finalize afterEncrypt
-             in propertyHoldCase [ eqTest "ciphertext" ciphertextX out
-                                 , eqTest "tag" tagX (B.convert outtag)
-                                 ]
+a5key :: ByteString
+a5key =
+    "\x1c\x92\x40\xa5\xeb\x55\xd3\x8a\xf3\x33\x88\x86\x04\xf6\xb5\xf0\x47\x39\x17\xc1\x40\x2b\x80\x09\x9d\xca\x5c\xbc\x20\x70\x75\xc0"
 
-        runDecrypt =
-            let ini                 = throwCryptoError $ AEAD.initialize key (throwCryptoError $ AEAD.nonce8 constant iv)
-                afterAAD            = AEAD.finalizeAAD (AEAD.appendAAD aad ini)
-                (out, afterDecrypt) = AEAD.decrypt ciphertext afterAAD
-                outtag              = AEAD.finalize afterDecrypt
-             in propertyHoldCase [ eqTest "plaintext" plaintext out
-                                 , eqTest "tag" tag (B.convert outtag)
-                                 ]
+a5nonce :: ByteString
+a5nonce = "\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08"
 
-        runDecryptX =
-            let ini                 = throwCryptoError $ AEAD.initializeX key (throwCryptoError $ AEAD.nonce24 ivX)
-                afterAAD            = AEAD.finalizeAAD (AEAD.appendAAD aad ini)
-                (out, afterDecrypt) = AEAD.decrypt ciphertextX afterAAD
-                outtag              = AEAD.finalize afterDecrypt
-             in propertyHoldCase [ eqTest "plaintext" plaintext out
-                                 , eqTest "tag" tagX (B.convert outtag)
-                                 ]
+a5aad :: ByteString
+a5aad = "\xf3\x33\x88\x86\x00\x00\x00\x00\x00\x00\x4e\x91"
 
-        runNonceInc =
-            let n1  = throwCryptoError . AEAD.nonce12 $ nonce1
-                n3  = throwCryptoError . AEAD.nonce12 $ nonce3
-                n5  = throwCryptoError . AEAD.nonce12 $ nonce5
-                n6  = throwCryptoError . AEAD.nonce8 constant $ nonce6
-                n8  = throwCryptoError . AEAD.nonce8 constant $ nonce8
-                n10 = throwCryptoError . AEAD.nonce8 constant $ nonce10
-            in propertyHoldCase [ eqTest "nonce12a" nonce2 $ B.convert . AEAD.incrementNonce $ n1
-                                , eqTest "nonce12b" nonce4 $ B.convert . AEAD.incrementNonce $ n3
-                                , eqTest "nonce12c" nonce1 $ B.convert . AEAD.incrementNonce $ n5
-                                , eqTest "nonce8a" (B.concat [constant, nonce7]) $ B.convert . AEAD.incrementNonce $ n6
-                                , eqTest "nonce8b" (B.concat [constant, nonce9]) $ B.convert . AEAD.incrementNonce $ n8
-                                , eqTest "nonce8c" (B.concat [constant, nonce6]) $ B.convert . AEAD.incrementNonce $ n10
-                                ]
+a5cipher :: ByteString
+a5cipher =
+    "\x64\xa0\x86\x15\x75\x86\x1a\xf4\x60\xf0\x62\xc7\x9b\xe6\x43\xbd\x5e\x80\x5c\xfd\x34\x5c\xf3\x89\xf1\x08\x67\x0a\xc7\x6c\x8c\xb2\x4c\x6c\xfc\x18\x75\x5d\x43\xee\xa0\x9e\xe9\x4e\x38\x2d\x26\xb0\xbd\xb7\xb7\x3c\x32\x1b\x01\x00\xd4\xf0\x3b\x7f\x35\x58\x94\xcf\x33\x2f\x83\x0e\x71\x0b\x97\xce\x98\xc8\xa8\x4a\xbd\x0b\x94\x81\x14\xad\x17\x6e\x00\x8d\x33\xbd\x60\xf9\x82\xb1\xff\x37\xc8\x55\x97\x97\xa0\x6e\xf4\xf0\xef\x61\xc1\x86\x32\x4e\x2b\x35\x06\x38\x36\x06\x90\x7b\x6a\x7c\x02\xb0\xf9\xf6\x15\x7b\x53\xc8\x67\xe4\xb9\x16\x6c\x76\x7b\x80\x4d\x46\xa5\x9b\x52\x16\xcd\xe7\xa4\xe9\x90\x40\xc5\xa4\x04\x33\x22\x5e\xe2\x82\xa1\xb0\xa0\x6c\x52\x3e\xaf\x45\x34\xd7\xf8\x3f\xa1\x15\x5b\x00\x47\x71\x8c\xbc\x54\x6a\x0d\x07\x2b\x04\xb3\x56\x4e\xea\x1b\x42\x22\x73\xf5\x48\x27\x1a\x0b\xb2\x31\x60\x53\xfa\x76\x99\x19\x55\xeb\xd6\x31\x59\x43\x4e\xce\xbb\x4e\x46\x6d\xae\x5a\x10\x73\xa6\x72\x76\x27\x09\x7a\x10\x49\xe6\x17\xd9\x1d\x36\x10\x94\xfa\x68\xf0\xff\x77\x98\x71\x30\x30\x5b\xea\xba\x2e\xda\x04\xdf\x99\x7b\x71\x4d\x6c\x6f\x2c\x29\xa6\xad\x5c\xb4\x02\x2b\x02\x70\x9b"
+
+a5plain :: ByteString
+a5plain =
+    "\x49\x6e\x74\x65\x72\x6e\x65\x74\x2d\x44\x72\x61\x66\x74\x73\x20\x61\x72\x65\x20\x64\x72\x61\x66\x74\x20\x64\x6f\x63\x75\x6d\x65\x6e\x74\x73\x20\x76\x61\x6c\x69\x64\x20\x66\x6f\x72\x20\x61\x20\x6d\x61\x78\x69\x6d\x75\x6d\x20\x6f\x66\x20\x73\x69\x78\x20\x6d\x6f\x6e\x74\x68\x73\x20\x61\x6e\x64\x20\x6d\x61\x79\x20\x62\x65\x20\x75\x70\x64\x61\x74\x65\x64\x2c\x20\x72\x65\x70\x6c\x61\x63\x65\x64\x2c\x20\x6f\x72\x20\x6f\x62\x73\x6f\x6c\x65\x74\x65\x64\x20\x62\x79\x20\x6f\x74\x68\x65\x72\x20\x64\x6f\x63\x75\x6d\x65\x6e\x74\x73\x20\x61\x74\x20\x61\x6e\x79\x20\x74\x69\x6d\x65\x2e\x20\x49\x74\x20\x69\x73\x20\x69\x6e\x61\x70\x70\x72\x6f\x70\x72\x69\x61\x74\x65\x20\x74\x6f\x20\x75\x73\x65\x20\x49\x6e\x74\x65\x72\x6e\x65\x74\x2d\x44\x72\x61\x66\x74\x73\x20\x61\x73\x20\x72\x65\x66\x65\x72\x65\x6e\x63\x65\x20\x6d\x61\x74\x65\x72\x69\x61\x6c\x20\x6f\x72\x20\x74\x6f\x20\x63\x69\x74\x65\x20\x74\x68\x65\x6d\x20\x6f\x74\x68\x65\x72\x20\x74\x68\x61\x6e\x20\x61\x73\x20\x2f\xe2\x80\x9c\x77\x6f\x72\x6b\x20\x69\x6e\x20\x70\x72\x6f\x67\x72\x65\x73\x73\x2e\x2f\xe2\x80\x9d"
+
+a5tag :: ByteString
+a5tag = "\xee\xad\x9d\x67\x89\x0c\xbb\x22\x39\x23\x36\xfe\xa1\x85\x1f\x38"
+
+rfc8439encrypt = a5cipher @=? ct
+  where
+    ct = case CP.aeadChacha20poly1305Init a5key a5nonce of
+        CryptoPassed st -> snd $ aeadSimpleEncrypt st a5aad a5plain 16
+        _ -> "dummy"
+
+rfc8439decrypt = Just a5plain @=? mpt
+  where
+    mpt = case CP.aeadChacha20poly1305Init a5key a5nonce of
+        CryptoPassed st -> aeadSimpleDecrypt st a5aad a5cipher (AuthTag $ B.convert a5tag)
+        _ -> Nothing
+
+tests =
+    testGroup
+        "ChaChaPoly1305"
+        [ testCase "V1" runEncrypt
+        , testCase "V1-decrypt" runDecrypt
+        , testCase "V1-extended" runEncryptX
+        , testCase "V1-extended-decrypt" runDecryptX
+        , testCase "nonce increment" runNonceInc
+        , testCase "RFC8439 A5 enc" rfc8439encrypt
+        , testCase "RFC8439 A5 dec" rfc8439decrypt
+        ]
+  where
+    runEncrypt =
+        let ini =
+                throwCryptoError $
+                    CP.initialize key (throwCryptoError $ CP.nonce8 constant iv)
+            afterAAD = CP.finalizeAAD (CP.appendAAD aad ini)
+            (out, afterEncrypt) = CP.encrypt plaintext afterAAD
+            outtag = CP.finalize afterEncrypt
+         in propertyHoldCase
+                [ eqTest "ciphertext" ciphertext out
+                , eqTest "tag" tag (B.convert outtag)
+                ]
+    runEncryptX =
+        let ini =
+                throwCryptoError $ CP.initializeX key (throwCryptoError $ CP.nonce24 ivX)
+            afterAAD = CP.finalizeAAD (CP.appendAAD aad ini)
+            (out, afterEncrypt) = CP.encrypt plaintext afterAAD
+            outtag = CP.finalize afterEncrypt
+         in propertyHoldCase
+                [ eqTest "ciphertext" ciphertextX out
+                , eqTest "tag" tagX (B.convert outtag)
+                ]
+
+    runDecrypt =
+        let ini =
+                throwCryptoError $
+                    CP.initialize key (throwCryptoError $ CP.nonce8 constant iv)
+            afterAAD = CP.finalizeAAD (CP.appendAAD aad ini)
+            (out, afterDecrypt) = CP.decrypt ciphertext afterAAD
+            outtag = CP.finalize afterDecrypt
+         in propertyHoldCase
+                [ eqTest "plaintext" plaintext out
+                , eqTest "tag" tag (B.convert outtag)
+                ]
+
+    runDecryptX =
+        let ini =
+                throwCryptoError $ CP.initializeX key (throwCryptoError $ CP.nonce24 ivX)
+            afterAAD = CP.finalizeAAD (CP.appendAAD aad ini)
+            (out, afterDecrypt) = CP.decrypt ciphertextX afterAAD
+            outtag = CP.finalize afterDecrypt
+         in propertyHoldCase
+                [ eqTest "plaintext" plaintext out
+                , eqTest "tag" tagX (B.convert outtag)
+                ]
+
+    runNonceInc =
+        let n1 = throwCryptoError . CP.nonce12 $ nonce1
+            n3 = throwCryptoError . CP.nonce12 $ nonce3
+            n5 = throwCryptoError . CP.nonce12 $ nonce5
+            n6 = throwCryptoError . CP.nonce8 constant $ nonce6
+            n8 = throwCryptoError . CP.nonce8 constant $ nonce8
+            n10 = throwCryptoError . CP.nonce8 constant $ nonce10
+         in propertyHoldCase
+                [ eqTest "nonce12a" nonce2 $ B.convert . CP.incrementNonce $ n1
+                , eqTest "nonce12b" nonce4 $ B.convert . CP.incrementNonce $ n3
+                , eqTest "nonce12c" nonce1 $ B.convert . CP.incrementNonce $ n5
+                , eqTest "nonce8a" (B.concat [constant, nonce7]) $
+                    B.convert . CP.incrementNonce $
+                        n6
+                , eqTest "nonce8b" (B.concat [constant, nonce9]) $
+                    B.convert . CP.incrementNonce $
+                        n8
+                , eqTest "nonce8c" (B.concat [constant, nonce6]) $
+                    B.convert . CP.incrementNonce $
+                        n10
+                ]
diff --git a/tests/ECC.hs b/tests/ECC.hs
--- a/tests/ECC.hs
+++ b/tests/ECC.hs
@@ -1,343 +1,399 @@
 {-# LANGUAGE ExistentialQuantification #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE OverloadedStrings #-}
+
 module ECC (tests) where
 
-import           Crypto.Error
+import Data.Either
+
 import qualified Crypto.ECC as ECC
+import Crypto.Error
 
-import           Data.ByteArray.Encoding
+import Data.ByteArray.Encoding
 
 import Imports
 
-data Curve = forall curve. (ECC.EllipticCurveDH curve, Show curve, Eq (ECC.Point curve)) => Curve curve
+data Curve
+    = forall curve.
+        (ECC.EllipticCurveDH curve, Show curve, Eq (ECC.Point curve)) =>
+      Curve curve
 
 instance Show Curve where
     showsPrec d (Curve curve) = showsPrec d curve
 
 instance Arbitrary Curve where
-    arbitrary = elements
-        [ Curve ECC.Curve_P256R1
-        , Curve ECC.Curve_P384R1
-        , Curve ECC.Curve_P521R1
-        , Curve ECC.Curve_X25519
-        , Curve ECC.Curve_X448
-        ]
+    arbitrary =
+        elements
+            [ Curve ECC.Curve_P256R1
+            , Curve ECC.Curve_P384R1
+            , Curve ECC.Curve_P521R1
+            , Curve ECC.Curve_X25519
+            , Curve ECC.Curve_X448
+            ]
 
-data CurveArith = forall curve. (ECC.EllipticCurveBasepointArith curve, Show curve) => CurveArith curve
+data CurveArith
+    = forall curve. (ECC.EllipticCurveBasepointArith curve, Show curve) => CurveArith curve
 
 instance Show CurveArith where
     showsPrec d (CurveArith curve) = showsPrec d curve
 
 instance Arbitrary CurveArith where
-    arbitrary = elements
-        [ CurveArith ECC.Curve_P256R1
-        , CurveArith ECC.Curve_P384R1
-        , CurveArith ECC.Curve_P521R1
-        , CurveArith ECC.Curve_Edwards25519
-        ]
+    arbitrary =
+        elements
+            [ CurveArith ECC.Curve_P256R1
+            , CurveArith ECC.Curve_P384R1
+            , CurveArith ECC.Curve_P521R1
+            , CurveArith ECC.Curve_Edwards25519
+            ]
 
 data VectorPoint = VectorPoint
     { vpCurve :: Curve
-    , vpHex   :: ByteString
+    , vpHex :: ByteString
     , vpError :: Maybe CryptoError
     }
 
+vectorsPoint :: [VectorPoint]
 vectorsPoint =
     [ VectorPoint
         { vpCurve = Curve ECC.Curve_P256R1
-        , vpHex   = ""
+        , vpHex = ""
         , vpError = Just CryptoError_PointSizeInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P256R1
-        , vpHex   = "00"
+        , vpHex = "00"
         , vpError = Just CryptoError_PointFormatInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P256R1
-        , vpHex   = "0408edd7b50085a952172228aca391beebe9ba942a0ae9eb15bcc8d50795d1a5505221c7b9b3bb4310f165fc3ac3114339db8170ceae6697e0f9736698b33551b8"
+        , vpHex =
+            "0408edd7b50085a952172228aca391beebe9ba942a0ae9eb15bcc8d50795d1a5505221c7b9b3bb4310f165fc3ac3114339db8170ceae6697e0f9736698b33551b8"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P256R1
-        , vpHex   = "04216f25b00717d46deef3402628f6abf265bfa12aea515ae8f100ce415e251e72cd5cd8f47f613a0f4e0f4f9410dd9c85c149cffcb320c2d52bf550a397ec92e5"
+        , vpHex =
+            "04216f25b00717d46deef3402628f6abf265bfa12aea515ae8f100ce415e251e72cd5cd8f47f613a0f4e0f4f9410dd9c85c149cffcb320c2d52bf550a397ec92e5"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P256R1
-        , vpHex   = "0421eba6080610926609bb8d52afd3331ed1b07e0ba4c1441a118b62497d3e85f39a50c865027cdd84298cdf094b7818f2a65ae59f46c971a32ab4ea3c2c93c959"
+        , vpHex =
+            "0421eba6080610926609bb8d52afd3331ed1b07e0ba4c1441a118b62497d3e85f39a50c865027cdd84298cdf094b7818f2a65ae59f46c971a32ab4ea3c2c93c959"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P256R1
-        , vpHex   = "0400d7fc4050dfe73475502d5d1fadc105d7725508f48da2cd4729bf191fd6490a0001a16f417a27530e756efeb4a228f02db878072b9f833e99a2821d85fa78fc"
+        , vpHex =
+            "0400d7fc4050dfe73475502d5d1fadc105d7725508f48da2cd4729bf191fd6490a0001a16f417a27530e756efeb4a228f02db878072b9f833e99a2821d85fa78fc"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P256R1
-        , vpHex   = "040000fc4050dfe73475502d5d1fadc105d7725508f48da2cd4729bf191fd6490a0001a16f417a27530e756efeb4a228f02db878072b9f833e99a2821d85fa78fc"
+        , vpHex =
+            "040000fc4050dfe73475502d5d1fadc105d7725508f48da2cd4729bf191fd6490a0001a16f417a27530e756efeb4a228f02db878072b9f833e99a2821d85fa78fc"
         , vpError = Just CryptoError_PointCoordinatesInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P256R1
-        , vpHex   = "04d7fc4050dfe73475502d5d1fadc105d7725508f48da2cd4729bf191fd6490a01a16f417a27530e756efeb4a228f02db878072b9f833e99a2821d85fa78fc"
+        , vpHex =
+            "04d7fc4050dfe73475502d5d1fadc105d7725508f48da2cd4729bf191fd6490a01a16f417a27530e756efeb4a228f02db878072b9f833e99a2821d85fa78fc"
         , vpError = Just CryptoError_PublicKeySizeInvalid -- tests leading zeros
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P256R1
-        , vpHex   = "040000d7fc4050dfe73475502d5d1fadc105d7725508f48da2cd4729bf191fd6490a000001a16f417a27530e756efeb4a228f02db878072b9f833e99a2821d85fa78fc"
+        , vpHex =
+            "040000d7fc4050dfe73475502d5d1fadc105d7725508f48da2cd4729bf191fd6490a000001a16f417a27530e756efeb4a228f02db878072b9f833e99a2821d85fa78fc"
         , vpError = Just CryptoError_PublicKeySizeInvalid -- tests leading zeros
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P384R1
-        , vpHex   = ""
+        , vpHex = ""
         , vpError = Just CryptoError_PointSizeInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P384R1
-        , vpHex   = "00"
+        , vpHex = "00"
         , vpError = Just CryptoError_PointFormatInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P384R1
-        , vpHex   = "0409281a103fb1773445e16eec86adb095e32928ccc9c806bd210c649712813bdb6cab40163a8cb163b578ea8dda5eb32cfb5208ebf0d31a6c590fa92f5a61f32dbc0d518b166ea5a9adf9dd21c1bd09932ca21c6a5725ca89542ac57b6a9eca6f"
+        , vpHex =
+            "0409281a103fb1773445e16eec86adb095e32928ccc9c806bd210c649712813bdb6cab40163a8cb163b578ea8dda5eb32cfb5208ebf0d31a6c590fa92f5a61f32dbc0d518b166ea5a9adf9dd21c1bd09932ca21c6a5725ca89542ac57b6a9eca6f"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P384R1
-        , vpHex   = "040c7b3fb575c1db7bc61fe7a456cc34a8289f41e167938a56e5ba2787723f3de2c645112705e13ed24f477730173935ca4e0ff468e7e0acf78a9f59dadff8193a0e23789eb3737730c089b27a0f94de7d95b8db4466d017fb21a5710d6ca85775"
+        , vpHex =
+            "040c7b3fb575c1db7bc61fe7a456cc34a8289f41e167938a56e5ba2787723f3de2c645112705e13ed24f477730173935ca4e0ff468e7e0acf78a9f59dadff8193a0e23789eb3737730c089b27a0f94de7d95b8db4466d017fb21a5710d6ca85775"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P384R1
-        , vpHex   = "0438e7705220b60460194be63d21c8945be2a211957168fa60f26b2ad4e8f5cd96a7779e7edff4deda9ded63243c2127e273d4444edaaba03b79b6caafc5033432af13776f851c0c7e1080c60d7ee3b61740720ab98461813dab5fb8c31bfa9ed9"
+        , vpHex =
+            "0438e7705220b60460194be63d21c8945be2a211957168fa60f26b2ad4e8f5cd96a7779e7edff4deda9ded63243c2127e273d4444edaaba03b79b6caafc5033432af13776f851c0c7e1080c60d7ee3b61740720ab98461813dab5fb8c31bfa9ed9"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P384R1
-        , vpHex   = "04000836bf09614bf5b3c0ffe9b0822a2cc109a90b13d4d3510ce14f766e7d90875ec4bc8d6bee11fc1fdf97473a67884c00b1e2685367bdb846c95181b0f35a35cfbee04451122cc55a1e363acaa6c002e71b0b6ff7d0f5dc830a32f0e5086189"
+        , vpHex =
+            "04000836bf09614bf5b3c0ffe9b0822a2cc109a90b13d4d3510ce14f766e7d90875ec4bc8d6bee11fc1fdf97473a67884c00b1e2685367bdb846c95181b0f35a35cfbee04451122cc55a1e363acaa6c002e71b0b6ff7d0f5dc830a32f0e5086189"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P384R1
-        , vpHex   = "04000036bf09614bf5b3c0ffe9b0822a2cc109a90b13d4d3510ce14f766e7d90875ec4bc8d6bee11fc1fdf97473a67884c00b1e2685367bdb846c95181b0f35a35cfbee04451122cc55a1e363acaa6c002e71b0b6ff7d0f5dc830a32f0e5086189"
+        , vpHex =
+            "04000036bf09614bf5b3c0ffe9b0822a2cc109a90b13d4d3510ce14f766e7d90875ec4bc8d6bee11fc1fdf97473a67884c00b1e2685367bdb846c95181b0f35a35cfbee04451122cc55a1e363acaa6c002e71b0b6ff7d0f5dc830a32f0e5086189"
         , vpError = Just CryptoError_PointCoordinatesInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P384R1
-        , vpHex   = "040836bf09614bf5b3c0ffe9b0822a2cc109a90b13d4d3510ce14f766e7d90875ec4bc8d6bee11fc1fdf97473a67884cb1e2685367bdb846c95181b0f35a35cfbee04451122cc55a1e363acaa6c002e71b0b6ff7d0f5dc830a32f0e5086189"
+        , vpHex =
+            "040836bf09614bf5b3c0ffe9b0822a2cc109a90b13d4d3510ce14f766e7d90875ec4bc8d6bee11fc1fdf97473a67884cb1e2685367bdb846c95181b0f35a35cfbee04451122cc55a1e363acaa6c002e71b0b6ff7d0f5dc830a32f0e5086189"
         , vpError = Nothing -- ignores leading zeros
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P384R1
-        , vpHex   = "0400000836bf09614bf5b3c0ffe9b0822a2cc109a90b13d4d3510ce14f766e7d90875ec4bc8d6bee11fc1fdf97473a67884c0000b1e2685367bdb846c95181b0f35a35cfbee04451122cc55a1e363acaa6c002e71b0b6ff7d0f5dc830a32f0e5086189"
+        , vpHex =
+            "0400000836bf09614bf5b3c0ffe9b0822a2cc109a90b13d4d3510ce14f766e7d90875ec4bc8d6bee11fc1fdf97473a67884c0000b1e2685367bdb846c95181b0f35a35cfbee04451122cc55a1e363acaa6c002e71b0b6ff7d0f5dc830a32f0e5086189"
         , vpError = Nothing -- ignores leading zeros
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P521R1
-        , vpHex   = ""
+        , vpHex = ""
         , vpError = Just CryptoError_PointSizeInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P521R1
-        , vpHex   = "00"
+        , vpHex = "00"
         , vpError = Just CryptoError_PointFormatInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P521R1
-        , vpHex   = "04000ce5c207335134567026063743df82c1b551a009cf616471f0e23fa9767a50cc7f8771ef13a65c49ce7e1cd1ac3ad721dcc3ddd35f98ae5d380a0832f87a9f0ca4012914911d6bea7f3c481d694fb1645be27c7b66b09b28e261f8030b3fb8206f6a95f6ad73db755765b64f592a799234f8f451cb787abe95b1a54991a799ad0d69da"
+        , vpHex =
+            "04000ce5c207335134567026063743df82c1b551a009cf616471f0e23fa9767a50cc7f8771ef13a65c49ce7e1cd1ac3ad721dcc3ddd35f98ae5d380a0832f87a9f0ca4012914911d6bea7f3c481d694fb1645be27c7b66b09b28e261f8030b3fb8206f6a95f6ad73db755765b64f592a799234f8f451cb787abe95b1a54991a799ad0d69da"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P521R1
-        , vpHex   = "04003a5e6c1ce3a6a323757005da17b357db991bd1ad835e6201411f458b5c2edb3c66786b727b7e15fbad7dd74a4b0eb542183b5242e5952061cb85e7229353eb0dc300aac2dbd5232d582481ba7a59a993eb04c4466a1b17ba0015b65c616ce8703e70880969d8d58e633acb29c3ca017eb1b88649387b867466090ce1a57c2b4f8376bb"
+        , vpHex =
+            "04003a5e6c1ce3a6a323757005da17b357db991bd1ad835e6201411f458b5c2edb3c66786b727b7e15fbad7dd74a4b0eb542183b5242e5952061cb85e7229353eb0dc300aac2dbd5232d582481ba7a59a993eb04c4466a1b17ba0015b65c616ce8703e70880969d8d58e633acb29c3ca017eb1b88649387b867466090ce1a57c2b4f8376bb"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P521R1
-        , vpHex   = "04003e0659fe9498695a3d8c88b8e25fa8133c30ab10eccbe9094344c99924f89fb69d9b3acf03bf438328f9cba55fa28a05be9a7e18780706b3728abfee2592aeb86d0001ea5ff64f2ca7a6453c79f80550e971843e073f4f8fec75bad2e52a4483ebf1f16f43d0de27e1967ea22f9722527652fa74439fdc03a569fba29e2d6f7c012db6"
+        , vpHex =
+            "04003e0659fe9498695a3d8c88b8e25fa8133c30ab10eccbe9094344c99924f89fb69d9b3acf03bf438328f9cba55fa28a05be9a7e18780706b3728abfee2592aeb86d0001ea5ff64f2ca7a6453c79f80550e971843e073f4f8fec75bad2e52a4483ebf1f16f43d0de27e1967ea22f9722527652fa74439fdc03a569fba29e2d6f7c012db6"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P521R1
-        , vpHex   = "040043f91fd92d9ccd6d5584b265a2a775d222f4a41ff98190677d985e0889737cbe631d525835fe04faffcdebeccb783538280f4600ae82347b0470583abd9def306000a2e9bdc34f42b134517fc1e961befea0affd1f9666361a039192082a892dd722931d5865b62b69d7369e74895120e540cb10030cccb6049d809fbcf3f54537b378"
+        , vpHex =
+            "040043f91fd92d9ccd6d5584b265a2a775d222f4a41ff98190677d985e0889737cbe631d525835fe04faffcdebeccb783538280f4600ae82347b0470583abd9def306000a2e9bdc34f42b134517fc1e961befea0affd1f9666361a039192082a892dd722931d5865b62b69d7369e74895120e540cb10030cccb6049d809fbcf3f54537b378"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P521R1
-        , vpHex   = "040000f91fd92d9ccd6d5584b265a2a775d222f4a41ff98190677d985e0889737cbe631d525835fe04faffcdebeccb783538280f4600ae82347b0470583abd9def306000a2e9bdc34f42b134517fc1e961befea0affd1f9666361a039192082a892dd722931d5865b62b69d7369e74895120e540cb10030cccb6049d809fbcf3f54537b378"
+        , vpHex =
+            "040000f91fd92d9ccd6d5584b265a2a775d222f4a41ff98190677d985e0889737cbe631d525835fe04faffcdebeccb783538280f4600ae82347b0470583abd9def306000a2e9bdc34f42b134517fc1e961befea0affd1f9666361a039192082a892dd722931d5865b62b69d7369e74895120e540cb10030cccb6049d809fbcf3f54537b378"
         , vpError = Just CryptoError_PointCoordinatesInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P521R1
-        , vpHex   = "0443f91fd92d9ccd6d5584b265a2a775d222f4a41ff98190677d985e0889737cbe631d525835fe04faffcdebeccb783538280f4600ae82347b0470583abd9def3060a2e9bdc34f42b134517fc1e961befea0affd1f9666361a039192082a892dd722931d5865b62b69d7369e74895120e540cb10030cccb6049d809fbcf3f54537b378"
+        , vpHex =
+            "0443f91fd92d9ccd6d5584b265a2a775d222f4a41ff98190677d985e0889737cbe631d525835fe04faffcdebeccb783538280f4600ae82347b0470583abd9def3060a2e9bdc34f42b134517fc1e961befea0affd1f9666361a039192082a892dd722931d5865b62b69d7369e74895120e540cb10030cccb6049d809fbcf3f54537b378"
         , vpError = Nothing -- ignores leading zeros
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_P521R1
-        , vpHex   = "04000043f91fd92d9ccd6d5584b265a2a775d222f4a41ff98190677d985e0889737cbe631d525835fe04faffcdebeccb783538280f4600ae82347b0470583abd9def30600000a2e9bdc34f42b134517fc1e961befea0affd1f9666361a039192082a892dd722931d5865b62b69d7369e74895120e540cb10030cccb6049d809fbcf3f54537b378"
+        , vpHex =
+            "04000043f91fd92d9ccd6d5584b265a2a775d222f4a41ff98190677d985e0889737cbe631d525835fe04faffcdebeccb783538280f4600ae82347b0470583abd9def30600000a2e9bdc34f42b134517fc1e961befea0affd1f9666361a039192082a892dd722931d5865b62b69d7369e74895120e540cb10030cccb6049d809fbcf3f54537b378"
         , vpError = Nothing -- ignores leading zeros
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = ""
+        , vpHex = ""
         , vpError = Just CryptoError_PublicKeySizeInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "22cd98c65fb50db3be0d6d359456c0cd3516952a6e7229ff672893944f703f10"
+        , vpHex = "22cd98c65fb50db3be0d6d359456c0cd3516952a6e7229ff672893944f703f10"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "23cd98c65fb50db3be0d6d359456c0cd3516952a6e7229ff672893944f703f10"
+        , vpHex = "23cd98c65fb50db3be0d6d359456c0cd3516952a6e7229ff672893944f703f10"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "0023cd98c65fb50db3be0d6d359456c0cd3516952a6e7229ff672893944f703f10"
+        , vpHex = "0023cd98c65fb50db3be0d6d359456c0cd3516952a6e7229ff672893944f703f10"
         , vpError = Just CryptoError_PublicKeySizeInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X448
-        , vpHex   = ""
+        , vpHex = ""
         , vpError = Just CryptoError_PublicKeySizeInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X448
-        , vpHex   = "2b162c2fef165ecbb203e40975ae4424f0f8db25ab582cb96b2e5ffe90a31798b35480b594c99dc32b437e61a74f792d8ecf5fc3e8cfeb75"
+        , vpHex =
+            "2b162c2fef165ecbb203e40975ae4424f0f8db25ab582cb96b2e5ffe90a31798b35480b594c99dc32b437e61a74f792d8ecf5fc3e8cfeb75"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X448
-        , vpHex   = "2c162c2fef165ecbb203e40975ae4424f0f8db25ab582cb96b2e5ffe90a31798b35480b594c99dc32b437e61a74f792d8ecf5fc3e8cfeb75"
+        , vpHex =
+            "2c162c2fef165ecbb203e40975ae4424f0f8db25ab582cb96b2e5ffe90a31798b35480b594c99dc32b437e61a74f792d8ecf5fc3e8cfeb75"
         , vpError = Nothing
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X448
-        , vpHex   = "002c162c2fef165ecbb203e40975ae4424f0f8db25ab582cb96b2e5ffe90a31798b35480b594c99dc32b437e61a74f792d8ecf5fc3e8cfeb75"
+        , vpHex =
+            "002c162c2fef165ecbb203e40975ae4424f0f8db25ab582cb96b2e5ffe90a31798b35480b594c99dc32b437e61a74f792d8ecf5fc3e8cfeb75"
         , vpError = Just CryptoError_PublicKeySizeInvalid
         }
     ]
 
+vectorsWeakPoint :: [VectorPoint]
 vectorsWeakPoint =
     [ VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "0000000000000000000000000000000000000000000000000000000000000000"
+        , vpHex = "0000000000000000000000000000000000000000000000000000000000000000"
         , vpError = Just CryptoError_ScalarMultiplicationInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "0100000000000000000000000000000000000000000000000000000000000000"
+        , vpHex = "0100000000000000000000000000000000000000000000000000000000000000"
         , vpError = Just CryptoError_ScalarMultiplicationInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "e0eb7a7c3b41b8ae1656e3faf19fc46ada098deb9c32b1fd866205165f49b800"
+        , vpHex = "e0eb7a7c3b41b8ae1656e3faf19fc46ada098deb9c32b1fd866205165f49b800"
         , vpError = Just CryptoError_ScalarMultiplicationInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "5f9c95bca3508c24b1d0b1559c83ef5b04445cc4581c8e86d8224eddd09f1157"
+        , vpHex = "5f9c95bca3508c24b1d0b1559c83ef5b04445cc4581c8e86d8224eddd09f1157"
         , vpError = Just CryptoError_ScalarMultiplicationInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f"
+        , vpHex = "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f"
         , vpError = Just CryptoError_ScalarMultiplicationInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f"
+        , vpHex = "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f"
         , vpError = Just CryptoError_ScalarMultiplicationInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X25519
-        , vpHex   = "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f"
+        , vpHex = "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f"
         , vpError = Just CryptoError_ScalarMultiplicationInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X448
-        , vpHex   = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
+        , vpHex =
+            "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
         , vpError = Just CryptoError_ScalarMultiplicationInvalid
         }
     , VectorPoint
         { vpCurve = Curve ECC.Curve_X448
-        , vpHex   = "0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
+        , vpHex =
+            "0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
         , vpError = Just CryptoError_ScalarMultiplicationInvalid
         }
     ]
 
 vpEncodedPoint :: VectorPoint -> ByteString
-vpEncodedPoint vector = let Right bs = convertFromBase Base16 (vpHex vector) in bs
+vpEncodedPoint vector = fromRight (error "vpEncodedPoint") $ convertFromBase Base16 (vpHex vector)
 
 cryptoError :: CryptoFailable a -> Maybe CryptoError
 cryptoError = onCryptoFailure Just (const Nothing)
 
+doPointDecodeTest :: Show p => p -> VectorPoint -> TestTree
 doPointDecodeTest i vector =
     case vpCurve vector of
         Curve curve ->
             let prx = Just curve -- using Maybe as Proxy
-             in testCase (show i) (vpError vector @=? cryptoError (ECC.decodePoint prx $ vpEncodedPoint vector))
+             in testCase
+                    (show i)
+                    (vpError vector @=? cryptoError (ECC.decodePoint prx $ vpEncodedPoint vector))
 
+doWeakPointECDHTest :: Show p => p -> VectorPoint -> TestTree
 doWeakPointECDHTest i vector =
     case vpCurve vector of
         Curve curve -> testCase (show i) $ do
             let prx = Just curve -- using Maybe as Proxy
-                CryptoPassed public = ECC.decodePoint prx $ vpEncodedPoint vector
+                public = throwCryptoError $ ECC.decodePoint prx $ vpEncodedPoint vector
             keyPair <- ECC.curveGenerateKeyPair prx
-            vpError vector @=? cryptoError (ECC.ecdh prx (ECC.keypairGetPrivate keyPair) public)
+            vpError vector
+                @=? cryptoError (ECC.ecdh prx (ECC.keypairGetPrivate keyPair) public)
 
-tests = testGroup "ECC"
-    [ testGroup "decodePoint" $ zipWith doPointDecodeTest [katZero..] vectorsPoint
-    , testGroup "ECDH weak points" $ zipWith doWeakPointECDHTest [katZero..] vectorsWeakPoint
-    , testGroup "property"
-        [ testProperty "decodePoint.encodePoint==id" $ \testDRG (Curve curve) ->
-            let prx = Just curve -- using Maybe as Proxy
-                keyPair = withTestDRG testDRG $ ECC.curveGenerateKeyPair prx
-                p1 = ECC.keypairGetPublic keyPair
-                bs = ECC.encodePoint prx p1 :: ByteString
-                p2 = ECC.decodePoint prx bs
-             in CryptoPassed p1 == p2
-        , localOption (QuickCheckTests 20) $ testProperty "ECDH commutes" $ \testDRG (Curve curve) ->
-            let prx = Just curve -- using Maybe as Proxy
-                (alice, bob) = withTestDRG testDRG $
-                                   (,) <$> ECC.curveGenerateKeyPair prx
-                                       <*> ECC.curveGenerateKeyPair prx
-                aliceShared  = ECC.ecdh    prx (ECC.keypairGetPrivate alice) (ECC.keypairGetPublic bob)
-                bobShared    = ECC.ecdh    prx (ECC.keypairGetPrivate bob) (ECC.keypairGetPublic alice)
-                aliceShared' = ECC.ecdhRaw prx (ECC.keypairGetPrivate alice) (ECC.keypairGetPublic bob)
-                bobShared'   = ECC.ecdhRaw prx (ECC.keypairGetPrivate bob) (ECC.keypairGetPublic alice)
-             in aliceShared == bobShared && aliceShared == CryptoPassed aliceShared'
-                                         && bobShared   == CryptoPassed bobShared'
-        , testProperty "decodeScalar.encodeScalar==id" $ \testDRG (CurveArith curve) ->
-            let prx = Just curve -- using Maybe as Proxy
-                s1 = withTestDRG testDRG $ ECC.curveGenerateScalar prx
-                bs = ECC.encodeScalar prx s1 :: ByteString
-                s2 = ECC.decodeScalar prx bs
-             in CryptoPassed s1 == s2
-        , testProperty "scalarFromInteger.scalarToInteger==id" $ \testDRG (CurveArith curve) ->
-            let prx = Just curve -- using Maybe as Proxy
-                s1 = withTestDRG testDRG $ ECC.curveGenerateScalar prx
-                bs = ECC.scalarToInteger prx s1
-                s2 = ECC.scalarFromInteger prx bs
-             in CryptoPassed s1 == s2
-        , localOption (QuickCheckTests 20) $ testProperty "(a + b).P = a.P + b.P" $ \testDRG (CurveArith curve) ->
-            let prx = Just curve -- using Maybe as Proxy
-                (s, a, b) = withTestDRG testDRG $
-                                (,,) <$> ECC.curveGenerateScalar prx
-                                     <*> ECC.curveGenerateScalar prx
-                                     <*> ECC.curveGenerateScalar prx
-                p = ECC.pointBaseSmul prx s
-             in ECC.pointSmul prx (ECC.scalarAdd prx a b) p == ECC.pointAdd prx (ECC.pointSmul prx a p) (ECC.pointSmul prx b p)
-        , localOption (QuickCheckTests 20) $ testProperty "(a * b).P = a.(b.P)" $ \testDRG (CurveArith curve) ->
-            let prx = Just curve -- using Maybe as Proxy
-                (s, a, b) = withTestDRG testDRG $
-                                (,,) <$> ECC.curveGenerateScalar prx
-                                     <*> ECC.curveGenerateScalar prx
-                                     <*> ECC.curveGenerateScalar prx
-                p = ECC.pointBaseSmul prx s
-             in ECC.pointSmul prx (ECC.scalarMul prx a b) p == ECC.pointSmul prx a (ECC.pointSmul prx b p)
+tests :: TestTree
+tests =
+    testGroup
+        "ECC"
+        [ testGroup "decodePoint" $ zipWith doPointDecodeTest [katZero ..] vectorsPoint
+        , testGroup "ECDH weak points" $
+            zipWith doWeakPointECDHTest [katZero ..] vectorsWeakPoint
+        , testGroup
+            "property"
+            [ testProperty "decodePoint.encodePoint==id" $ \testDRG (Curve curve) ->
+                let prx = Just curve -- using Maybe as Proxy
+                    keyPair = withTestDRG testDRG $ ECC.curveGenerateKeyPair prx
+                    p1 = ECC.keypairGetPublic keyPair
+                    bs = ECC.encodePoint prx p1 :: ByteString
+                    p2 = ECC.decodePoint prx bs
+                 in CryptoPassed p1 == p2
+            , localOption (QuickCheckTests 20) $ testProperty "ECDH commutes" $ \testDRG (Curve curve) ->
+                let prx = Just curve -- using Maybe as Proxy
+                    (alice, bob) =
+                        withTestDRG testDRG $
+                            (,)
+                                <$> ECC.curveGenerateKeyPair prx
+                                <*> ECC.curveGenerateKeyPair prx
+                    aliceShared = ECC.ecdh prx (ECC.keypairGetPrivate alice) (ECC.keypairGetPublic bob)
+                    bobShared = ECC.ecdh prx (ECC.keypairGetPrivate bob) (ECC.keypairGetPublic alice)
+                    aliceShared' = ECC.ecdhRaw prx (ECC.keypairGetPrivate alice) (ECC.keypairGetPublic bob)
+                    bobShared' = ECC.ecdhRaw prx (ECC.keypairGetPrivate bob) (ECC.keypairGetPublic alice)
+                 in aliceShared == bobShared
+                        && aliceShared == CryptoPassed aliceShared'
+                        && bobShared == CryptoPassed bobShared'
+            , testProperty "decodeScalar.encodeScalar==id" $ \testDRG (CurveArith curve) ->
+                let prx = Just curve -- using Maybe as Proxy
+                    s1 = withTestDRG testDRG $ ECC.curveGenerateScalar prx
+                    bs = ECC.encodeScalar prx s1 :: ByteString
+                    s2 = ECC.decodeScalar prx bs
+                 in CryptoPassed s1 == s2
+            , testProperty "scalarFromInteger.scalarToInteger==id" $ \testDRG (CurveArith curve) ->
+                let prx = Just curve -- using Maybe as Proxy
+                    s1 = withTestDRG testDRG $ ECC.curveGenerateScalar prx
+                    bs = ECC.scalarToInteger prx s1
+                    s2 = ECC.scalarFromInteger prx bs
+                 in CryptoPassed s1 == s2
+            , localOption (QuickCheckTests 20) $ testProperty "(a + b).P = a.P + b.P" $ \testDRG (CurveArith curve) ->
+                let prx = Just curve -- using Maybe as Proxy
+                    (s, a, b) =
+                        withTestDRG testDRG $
+                            (,,)
+                                <$> ECC.curveGenerateScalar prx
+                                <*> ECC.curveGenerateScalar prx
+                                <*> ECC.curveGenerateScalar prx
+                    p = ECC.pointBaseSmul prx s
+                 in ECC.pointSmul prx (ECC.scalarAdd prx a b) p
+                        == ECC.pointAdd prx (ECC.pointSmul prx a p) (ECC.pointSmul prx b p)
+            , localOption (QuickCheckTests 20) $ testProperty "(a * b).P = a.(b.P)" $ \testDRG (CurveArith curve) ->
+                let prx = Just curve -- using Maybe as Proxy
+                    (s, a, b) =
+                        withTestDRG testDRG $
+                            (,,)
+                                <$> ECC.curveGenerateScalar prx
+                                <*> ECC.curveGenerateScalar prx
+                                <*> ECC.curveGenerateScalar prx
+                    p = ECC.pointBaseSmul prx s
+                 in ECC.pointSmul prx (ECC.scalarMul prx a b) p
+                        == ECC.pointSmul prx a (ECC.pointSmul prx b p)
+            ]
         ]
-    ]
diff --git a/tests/ECC/Edwards25519.hs b/tests/ECC/Edwards25519.hs
--- a/tests/ECC/Edwards25519.hs
+++ b/tests/ECC/Edwards25519.hs
@@ -1,21 +1,24 @@
 {-# LANGUAGE OverloadedStrings #-}
-module ECC.Edwards25519 ( tests ) where
 
-import           Crypto.Error
-import           Crypto.ECC.Edwards25519
+module ECC.Edwards25519 (tests) where
+
+import Crypto.ECC.Edwards25519
+import Crypto.Error
 import qualified Data.ByteString as B
-import           Data.Word (Word8)
-import           Imports
+import Data.Word (Word8)
+import Imports
 
 instance Arbitrary Scalar where
-    arbitrary = fmap (throwCryptoError . scalarDecodeLong)
-                     (arbitraryBS 64)
+    arbitrary =
+        fmap
+            (throwCryptoError . scalarDecodeLong)
+            (arbitraryBS 64)
 
 smallScalar :: Word8 -> Scalar
 smallScalar = throwCryptoError . scalarDecodeLong . B.singleton
 
 newtype PrimeOrder = PrimeOrder Point
-    deriving Show
+    deriving (Show)
 
 -- points in the prime-order subgroup
 instance Arbitrary PrimeOrder where
@@ -23,101 +26,121 @@
 
 -- arbitrary curve point, including points with a torsion component
 instance Arbitrary Point where
-    arbitrary = do a <- arbitrary
-                   b <- elements $ map smallScalar [0 .. 7]
-                   return (pointsMulVarTime a b torsion8)
+    arbitrary = do
+        a <- arbitrary
+        b <- elements $ map smallScalar [0 .. 7]
+        return (pointsMulVarTime a b torsion8)
 
 -- an 8-torsion point
 torsion8 :: Point
-torsion8 = throwCryptoError $ pointDecode ("\199\ETBjp=M\216O\186<\vv\r\DLEg\SI* S\250,9\204\198N\199\253w\146\172\ETXz" :: ByteString)
+torsion8 =
+    throwCryptoError $
+        pointDecode
+            ( "\199\ETBjp=M\216O\186<\vv\r\DLEg\SI* S\250,9\204\198N\199\253w\146\172\ETXz"
+                :: ByteString
+            )
 
-tests = testGroup "ECC.Edwards25519"
-    [ testGroup "vectors"
-        [ testCase "11*G"         $ p011 @=? toPoint s011
-        , testCase "123*G"        $ p123 @=? toPoint s123
-        , testCase "134*G"        $ p134 @=? toPoint s134
-        , testCase "123*G + 11*G" $ p134 @=? pointAdd p123 p011
-        ]
-    , testGroup "scalar arithmetic"
-        [ testProperty "scalarDecodeLong.scalarEncode==id" $ \s ->
-            let bs = scalarEncode s :: ByteString
-                ss = scalarDecodeLong bs
-             in CryptoPassed s `propertyEq` ss
-        , testCase "curve order" $ s0 @=? sN
-        , testProperty "addition with zero" $ \s ->
-            propertyHold [ eqTest "zero left"  s (scalarAdd s0 s)
-                         , eqTest "zero right" s (scalarAdd s s0)
-                         ]
-        , testProperty "addition associative" $ \sa sb sc ->
-            scalarAdd sa (scalarAdd sb sc) === scalarAdd (scalarAdd sa sb) sc
-        , testProperty "addition commutative" $ \sa sb ->
-            scalarAdd sa sb === scalarAdd sb sa
-        , testProperty "multiplication with zero" $ \s ->
-            propertyHold [ eqTest "zero left"  s0 (scalarMul s0 s)
-                         , eqTest "zero right" s0 (scalarMul s s0)
-                         ]
-        , testProperty "multiplication with one" $ \s ->
-            propertyHold [ eqTest "one left"  s (scalarMul s1 s)
-                         , eqTest "one right" s (scalarMul s s1)
-                         ]
-        , testProperty "multiplication associative" $ \sa sb sc ->
-            scalarMul sa (scalarMul sb sc) === scalarMul (scalarMul sa sb) sc
-        , testProperty "multiplication commutative" $ \sa sb ->
-            scalarMul sa sb === scalarMul sb sa
-        , testProperty "multiplication distributive" $ \sa sb sc ->
-            propertyHold [ eqTest "distributive left"  ((sa `scalarMul` sb) `scalarAdd` (sa `scalarMul` sc))
-                                                       (sa `scalarMul` (sb `scalarAdd` sc))
-                         , eqTest "distributive right" ((sb `scalarMul` sa) `scalarAdd` (sc `scalarMul` sa))
-                                                       ((sb `scalarAdd` sc) `scalarMul` sa)
-                         ]
-        ]
-    , testGroup "point arithmetic"
-        [ testProperty "pointDecode.pointEncode==id" $ \p ->
-            let bs = pointEncode p :: ByteString
-                p' = pointDecode bs
-             in CryptoPassed p `propertyEq` p'
-        , testProperty "pointEncode.pointDecode==id" $ \p ->
-            let b  = pointEncode p :: ByteString
-                p' = pointDecode b
-                b' = pointEncode `fmap` p'
-             in CryptoPassed b `propertyEq` b'
-        , testProperty "addition with identity" $ \p ->
-            propertyHold [ eqTest "identity left"  p (pointAdd p0 p)
-                         , eqTest "identity right" p (pointAdd p p0)
-                         ]
-        , testProperty "addition associative" $ \pa pb pc ->
-            pointAdd pa (pointAdd pb pc) === pointAdd (pointAdd pa pb) pc
-        , testProperty "addition commutative" $ \pa pb ->
-            pointAdd pa pb === pointAdd pb pa
-        , testProperty "negation" $ \p ->
-            p0 `propertyEq` pointAdd p (pointNegate p)
-        , testProperty "doubling" $ \p ->
-            pointAdd p p `propertyEq` pointDouble p
-        , testProperty "multiplication by cofactor" $ \p ->
-            pointMul s8 p `propertyEq` pointMulByCofactor p
-        , testProperty "prime order" $ \(PrimeOrder p) ->
-            True `propertyEq` pointHasPrimeOrder p
-        , testCase "8-torsion point" $ do
-            assertBool "mul by 4" $ p0 /= pointMul s4 torsion8
-            assertBool "mul by 8" $ p0 == pointMul s8 torsion8
-        , testProperty "scalarmult with zero" $ \p ->
-            p0 `propertyEq` pointMul s0 p
-        , testProperty "scalarmult with one" $ \p ->
-            p `propertyEq` pointMul s1 p
-        , testProperty "scalarmult with two" $ \p ->
-            pointDouble p `propertyEq` pointMul s2 p
-        , testProperty "scalarmult with curve order - 1" $ \p ->
-            pointHasPrimeOrder p === (pointNegate p == pointMul sI p)
-        , testProperty "scalarmult commutative" $ \a b ->
-            pointMul a (toPoint b) === pointMul b (toPoint a)
-        , testProperty "scalarmult distributive" $ \x y (PrimeOrder p) ->
-            let pR = pointMul x p `pointAdd` pointMul y p
-             in pR `propertyEq` pointMul (x `scalarAdd` y) p
-        , testProperty "double scalarmult" $ \n1 n2 p ->
-            let pR = pointAdd (toPoint n1) (pointMul n2 p)
-             in pR `propertyEq` pointsMulVarTime n1 n2 p
+tests =
+    testGroup
+        "ECC.Edwards25519"
+        [ testGroup
+            "vectors"
+            [ testCase "11*G" $ p011 @=? toPoint s011
+            , testCase "123*G" $ p123 @=? toPoint s123
+            , testCase "134*G" $ p134 @=? toPoint s134
+            , testCase "123*G + 11*G" $ p134 @=? pointAdd p123 p011
+            ]
+        , testGroup
+            "scalar arithmetic"
+            [ testProperty "scalarDecodeLong.scalarEncode==id" $ \s ->
+                let bs = scalarEncode s :: ByteString
+                    ss = scalarDecodeLong bs
+                 in CryptoPassed s `propertyEq` ss
+            , testCase "curve order" $ s0 @=? sN
+            , testProperty "addition with zero" $ \s ->
+                propertyHold
+                    [ eqTest "zero left" s (scalarAdd s0 s)
+                    , eqTest "zero right" s (scalarAdd s s0)
+                    ]
+            , testProperty "addition associative" $ \sa sb sc ->
+                scalarAdd sa (scalarAdd sb sc) === scalarAdd (scalarAdd sa sb) sc
+            , testProperty "addition commutative" $ \sa sb ->
+                scalarAdd sa sb === scalarAdd sb sa
+            , testProperty "multiplication with zero" $ \s ->
+                propertyHold
+                    [ eqTest "zero left" s0 (scalarMul s0 s)
+                    , eqTest "zero right" s0 (scalarMul s s0)
+                    ]
+            , testProperty "multiplication with one" $ \s ->
+                propertyHold
+                    [ eqTest "one left" s (scalarMul s1 s)
+                    , eqTest "one right" s (scalarMul s s1)
+                    ]
+            , testProperty "multiplication associative" $ \sa sb sc ->
+                scalarMul sa (scalarMul sb sc) === scalarMul (scalarMul sa sb) sc
+            , testProperty "multiplication commutative" $ \sa sb ->
+                scalarMul sa sb === scalarMul sb sa
+            , testProperty "multiplication distributive" $ \sa sb sc ->
+                propertyHold
+                    [ eqTest
+                        "distributive left"
+                        ((sa `scalarMul` sb) `scalarAdd` (sa `scalarMul` sc))
+                        (sa `scalarMul` (sb `scalarAdd` sc))
+                    , eqTest
+                        "distributive right"
+                        ((sb `scalarMul` sa) `scalarAdd` (sc `scalarMul` sa))
+                        ((sb `scalarAdd` sc) `scalarMul` sa)
+                    ]
+            ]
+        , testGroup
+            "point arithmetic"
+            [ testProperty "pointDecode.pointEncode==id" $ \p ->
+                let bs = pointEncode p :: ByteString
+                    p' = pointDecode bs
+                 in CryptoPassed p `propertyEq` p'
+            , testProperty "pointEncode.pointDecode==id" $ \p ->
+                let b = pointEncode p :: ByteString
+                    p' = pointDecode b
+                    b' = pointEncode `fmap` p'
+                 in CryptoPassed b `propertyEq` b'
+            , testProperty "addition with identity" $ \p ->
+                propertyHold
+                    [ eqTest "identity left" p (pointAdd p0 p)
+                    , eqTest "identity right" p (pointAdd p p0)
+                    ]
+            , testProperty "addition associative" $ \pa pb pc ->
+                pointAdd pa (pointAdd pb pc) === pointAdd (pointAdd pa pb) pc
+            , testProperty "addition commutative" $ \pa pb ->
+                pointAdd pa pb === pointAdd pb pa
+            , testProperty "negation" $ \p ->
+                p0 `propertyEq` pointAdd p (pointNegate p)
+            , testProperty "doubling" $ \p ->
+                pointAdd p p `propertyEq` pointDouble p
+            , testProperty "multiplication by cofactor" $ \p ->
+                pointMul s8 p `propertyEq` pointMulByCofactor p
+            , testProperty "prime order" $ \(PrimeOrder p) ->
+                True `propertyEq` pointHasPrimeOrder p
+            , testCase "8-torsion point" $ do
+                assertBool "mul by 4" $ p0 /= pointMul s4 torsion8
+                assertBool "mul by 8" $ p0 == pointMul s8 torsion8
+            , testProperty "scalarmult with zero" $ \p ->
+                p0 `propertyEq` pointMul s0 p
+            , testProperty "scalarmult with one" $ \p ->
+                p `propertyEq` pointMul s1 p
+            , testProperty "scalarmult with two" $ \p ->
+                pointDouble p `propertyEq` pointMul s2 p
+            , testProperty "scalarmult with curve order - 1" $ \p ->
+                pointHasPrimeOrder p === (pointNegate p == pointMul sI p)
+            , testProperty "scalarmult commutative" $ \a b ->
+                pointMul a (toPoint b) === pointMul b (toPoint a)
+            , testProperty "scalarmult distributive" $ \x y (PrimeOrder p) ->
+                let pR = pointMul x p `pointAdd` pointMul y p
+                 in pR `propertyEq` pointMul (x `scalarAdd` y) p
+            , testProperty "double scalarmult" $ \n1 n2 p ->
+                let pR = pointAdd (toPoint n1) (pointMul n2 p)
+                 in pR `propertyEq` pointsMulVarTime n1 n2 p
+            ]
         ]
-    ]
   where
     p0 = toPoint s0
     s0 = smallScalar 0
@@ -125,23 +148,48 @@
     s2 = smallScalar 2
     s4 = smallScalar 4
     s8 = smallScalar 8
-    sI = throwCryptoError $ scalarDecodeLong ("\236\211\245\\\SUBc\DC2X\214\156\247\162\222\249\222\DC4\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\DLE" :: ByteString)
-    sN = throwCryptoError $ scalarDecodeLong ("\237\211\245\\\SUBc\DC2X\214\156\247\162\222\249\222\DC4\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\DLE" :: ByteString)
+    sI =
+        throwCryptoError $
+            scalarDecodeLong
+                ( "\236\211\245\\\SUBc\DC2X\214\156\247\162\222\249\222\DC4\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\DLE"
+                    :: ByteString
+                )
+    sN =
+        throwCryptoError $
+            scalarDecodeLong
+                ( "\237\211\245\\\SUBc\DC2X\214\156\247\162\222\249\222\DC4\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\DLE"
+                    :: ByteString
+                )
 
     s011 = throwCryptoError $ scalarDecodeLong ("\011" :: ByteString)
     s123 = throwCryptoError $ scalarDecodeLong ("\123" :: ByteString)
     s134 = throwCryptoError $ scalarDecodeLong ("\134" :: ByteString)
 
-    p011 = throwCryptoError $ pointDecode ("\x13\x37\x03\x6a\xc3\x2d\x8f\x30\xd4\x58\x9c\x3c\x1c\x59\x58\x12\xce\x0f\xff\x40\xe3\x7c\x6f\x5a\x97\xab\x21\x3f\x31\x82\x90\xad" :: ByteString)
-    p123 = throwCryptoError $ pointDecode ("\xc4\xb8\x00\xc8\x70\x10\xf9\x46\x83\x03\xde\xea\x87\x65\x03\xe8\x86\xbf\xde\x19\x00\xe9\xe8\x46\xfd\x4c\x3c\xd0\x9c\x1c\xbc\x9f" :: ByteString)
-    p134 = throwCryptoError $ pointDecode ("\x51\x20\xab\xe0\x3c\xa2\xaf\x66\xc7\x7c\xa3\x20\xf0\xb2\x1f\xb5\x56\xf6\xb6\x5f\xdd\x7e\x32\x64\xc1\x4a\x30\xd9\x7b\xf7\xa7\x6f" :: ByteString)
+    p011 =
+        throwCryptoError $
+            pointDecode
+                ( "\x13\x37\x03\x6a\xc3\x2d\x8f\x30\xd4\x58\x9c\x3c\x1c\x59\x58\x12\xce\x0f\xff\x40\xe3\x7c\x6f\x5a\x97\xab\x21\x3f\x31\x82\x90\xad"
+                    :: ByteString
+                )
+    p123 =
+        throwCryptoError $
+            pointDecode
+                ( "\xc4\xb8\x00\xc8\x70\x10\xf9\x46\x83\x03\xde\xea\x87\x65\x03\xe8\x86\xbf\xde\x19\x00\xe9\xe8\x46\xfd\x4c\x3c\xd0\x9c\x1c\xbc\x9f"
+                    :: ByteString
+                )
+    p134 =
+        throwCryptoError $
+            pointDecode
+                ( "\x51\x20\xab\xe0\x3c\xa2\xaf\x66\xc7\x7c\xa3\x20\xf0\xb2\x1f\xb5\x56\xf6\xb6\x5f\xdd\x7e\x32\x64\xc1\x4a\x30\xd9\x7b\xf7\xa7\x6f"
+                    :: ByteString
+                )
 
-    -- Using <http://cr.yp.to/python/py>:
-    --
-    -- >>> import ed25519
-    -- >>> encodepoint(scalarmult(B, 11)).encode('hex')
-    -- '1337036ac32d8f30d4589c3c1c595812ce0fff40e37c6f5a97ab213f318290ad'
-    -- >>> encodepoint(scalarmult(B, 123)).encode('hex')
-    -- 'c4b800c87010f9468303deea876503e886bfde1900e9e846fd4c3cd09c1cbc9f'
-    -- >>> encodepoint(scalarmult(B, 134)).encode('hex')
-    -- '5120abe03ca2af66c77ca320f0b21fb556f6b65fdd7e3264c14a30d97bf7a76f'
+-- Using <http://cr.yp.to/python/py>:
+--
+-- >>> import ed25519
+-- >>> encodepoint(scalarmult(B, 11)).encode('hex')
+-- '1337036ac32d8f30d4589c3c1c595812ce0fff40e37c6f5a97ab213f318290ad'
+-- >>> encodepoint(scalarmult(B, 123)).encode('hex')
+-- 'c4b800c87010f9468303deea876503e886bfde1900e9e846fd4c3cd09c1cbc9f'
+-- >>> encodepoint(scalarmult(B, 134)).encode('hex')
+-- '5120abe03ca2af66c77ca320f0b21fb556f6b65fdd7e3264c14a30d97bf7a76f'
diff --git a/tests/ECDSA.hs b/tests/ECDSA.hs
--- a/tests/ECDSA.hs
+++ b/tests/ECDSA.hs
@@ -1,61 +1,132 @@
 {-# LANGUAGE ExistentialQuantification #-}
 {-# LANGUAGE FlexibleContexts #-}
+
 module ECDSA (tests) where
 
 import qualified Crypto.ECC as ECDSA
+import Crypto.Error
+import Crypto.Hash
 import qualified Crypto.PubKey.ECC.ECDSA as ECC
+import qualified Crypto.PubKey.ECC.Generate as ECC
 import qualified Crypto.PubKey.ECC.Types as ECC
 import qualified Crypto.PubKey.ECDSA as ECDSA
-import Crypto.Hash.Algorithms
-import Crypto.Error
 import qualified Data.ByteString as B
+import Data.Maybe
 
 import Imports
 
-data Curve = forall curve. (ECDSA.EllipticCurveECDSA curve, Show (ECDSA.Scalar curve)) => Curve curve ECC.Curve ECC.CurveName
+data Curve
+    = forall curve.
+        (ECDSA.EllipticCurveECDSA curve, Show (ECDSA.Scalar curve)) =>
+      Curve curve ECC.Curve ECC.CurveName
 
 instance Show Curve where
     showsPrec d (Curve _ _ name) = showsPrec d name
 
 instance Arbitrary Curve where
-    arbitrary = elements
-        [ makeCurve ECDSA.Curve_P256R1 ECC.SEC_p256r1
-        , makeCurve ECDSA.Curve_P384R1 ECC.SEC_p384r1
-        , makeCurve ECDSA.Curve_P521R1 ECC.SEC_p521r1
-        ]
+    arbitrary =
+        elements
+            [ makeCurve ECDSA.Curve_P256R1 ECC.SEC_p256r1
+            , makeCurve ECDSA.Curve_P384R1 ECC.SEC_p384r1
+            , makeCurve ECDSA.Curve_P521R1 ECC.SEC_p521r1
+            ]
       where
         makeCurve c name = Curve c (ECC.getCurveByName name) name
 
+arbitraryScalar :: ECC.Curve -> Gen Integer
 arbitraryScalar curve = choose (1, n - 1)
-  where n = ECC.ecc_n (ECC.common_curve curve)
+  where
+    n = ECC.ecc_n (ECC.common_curve curve)
 
-sigECCToECDSA :: ECDSA.EllipticCurveECDSA curve
-              => proxy curve -> ECC.Signature -> ECDSA.Signature curve
-sigECCToECDSA prx (ECC.Signature r s) =
-    ECDSA.Signature (throwCryptoError $ ECDSA.scalarFromInteger prx r)
-                    (throwCryptoError $ ECDSA.scalarFromInteger prx s)
+sigECDSAtoECC
+    :: ECDSA.EllipticCurveECDSA curve
+    => proxy curve -> ECDSA.Signature curve -> ECC.Signature
+sigECDSAtoECC prx (ECDSA.Signature r s) = ECC.Signature (ECDSA.scalarToInteger prx r) (ECDSA.scalarToInteger prx s)
 
-tests = localOption (QuickCheckTests 5) $ testGroup "ECDSA"
-    [ testProperty "SHA1"   $ propertyECDSA SHA1
-    , testProperty "SHA224" $ propertyECDSA SHA224
-    , testProperty "SHA256" $ propertyECDSA SHA256
-    , testProperty "SHA384" $ propertyECDSA SHA384
-    , testProperty "SHA512" $ propertyECDSA SHA512
-    ]
+normalizeECC :: ECC.Curve -> ECC.Signature -> ECC.Signature
+normalizeECC curve (ECC.Signature r s)
+    | s <= n `div` 2 = ECC.Signature r s
+    | otherwise = ECC.Signature r (n - s)
   where
+    n = ECC.ecc_n $ ECC.common_curve curve
+
+testRecover :: ECC.CurveName -> TestTree
+testRecover name = testProperty (show name) $ \(ArbitraryBS0_2901 msg) -> do
+    let curve = ECC.getCurveByName name
+    let n = ECC.ecc_n $ ECC.common_curve curve
+    k <- choose (1, n - 1)
+    d <- choose (1, n - 1)
+    let key = ECC.PrivateKey curve d
+    let digest = hashWith SHA256 msg
+    let pub =
+            ECC.signExtendedDigestWith k key digest >>= \signature -> ECC.recoverDigest curve signature digest
+    pure $
+        propertyHold
+            [eqTest "recovery" (Just $ ECC.generateQ curve d) (ECC.public_q <$> pub)]
+
+testNormalize :: ECC.CurveName -> TestTree
+testNormalize name = testProperty (show name) $ \(ArbitraryBS0_2901 msg) -> do
+    let curve = ECC.getCurveByName name
+    let n = ECC.ecc_n $ ECC.common_curve curve
+    k <- choose (1, n - 1)
+    d <- choose (1, n - 1)
+    let key = ECC.PrivateKey curve d
+    let digest = hashWith SHA256 msg
+    let check =
+            ECC.signExtendedDigestWith k key digest >>= \s -> pure $ ECC.sign_s (ECC.signature s) <= n `div` 2
+    pure $ propertyHold [eqTest "normalized" (Just True) check]
+
+tests :: TestTree
+tests =
+    testGroup
+        "ECDSA"
+        [ localOption (QuickCheckTests 5) $
+            testGroup
+                "verification"
+                [ testProperty "SHA1" $ propertyECDSA SHA1
+                , testProperty "SHA224" $ propertyECDSA SHA224
+                , testProperty "SHA256" $ propertyECDSA SHA256
+                , testProperty "SHA384" $ propertyECDSA SHA384
+                , testProperty "SHA512" $ propertyECDSA SHA512
+                ]
+        , testGroup
+            "recovery"
+            [ localOption (QuickCheckTests 100) $ testRecover ECC.SEC_p128r1
+            , localOption (QuickCheckTests 100) $ testRecover ECC.SEC_p128r2
+            , localOption (QuickCheckTests 100) $ testRecover ECC.SEC_p256k1
+            , localOption (QuickCheckTests 100) $ testRecover ECC.SEC_p256r1
+            , localOption (QuickCheckTests 50) $ testRecover ECC.SEC_t131r1
+            , localOption (QuickCheckTests 50) $ testRecover ECC.SEC_t131r2
+            , localOption (QuickCheckTests 20) $ testRecover ECC.SEC_t233k1
+            , localOption (QuickCheckTests 20) $ testRecover ECC.SEC_t233r1
+            ]
+        , testGroup
+            "normalize"
+            [ localOption (QuickCheckTests 100) $ testNormalize ECC.SEC_p128r1
+            , localOption (QuickCheckTests 100) $ testNormalize ECC.SEC_p128r2
+            , localOption (QuickCheckTests 100) $ testNormalize ECC.SEC_p256k1
+            , localOption (QuickCheckTests 100) $ testNormalize ECC.SEC_p256r1
+            , localOption (QuickCheckTests 50) $ testNormalize ECC.SEC_t131r1
+            , localOption (QuickCheckTests 50) $ testNormalize ECC.SEC_t131r2
+            , localOption (QuickCheckTests 20) $ testNormalize ECC.SEC_t233k1
+            , localOption (QuickCheckTests 20) $ testNormalize ECC.SEC_t233r1
+            ]
+        ]
+  where
     propertyECDSA hashAlg (Curve c curve _) (ArbitraryBS0_2901 msg) = do
-        d    <- arbitraryScalar curve
+        d <- arbitraryScalar curve
         kECC <- arbitraryScalar curve
-        let privECC   = ECC.PrivateKey curve d
-            prx       = Just c -- using Maybe as Proxy
-            kECDSA    = throwCryptoError $ ECDSA.scalarFromInteger prx kECC
+        let privECC = ECC.PrivateKey curve d
+            prx = Just c -- using Maybe as Proxy
+            kECDSA = throwCryptoError $ ECDSA.scalarFromInteger prx kECC
             privECDSA = throwCryptoError $ ECDSA.scalarFromInteger prx d
-            pubECDSA  = ECDSA.toPublic prx privECDSA
-            Just sigECC   = ECC.signWith kECC privECC hashAlg msg
-            Just sigECDSA = ECDSA.signWith prx kECDSA privECDSA hashAlg msg
-            sigECDSA' = sigECCToECDSA prx sigECC
+            pubECDSA = ECDSA.toPublic prx privECDSA
+            sigECC = fromJust $ ECC.signWith kECC privECC hashAlg msg
+            sigECDSA = fromJust $ ECDSA.signWith prx kECDSA privECDSA hashAlg msg
             msg' = msg `B.append` B.singleton 42
-        return $ propertyHold [ eqTest "signature" sigECDSA sigECDSA'
-                              , eqTest "verification" True (ECDSA.verify prx hashAlg pubECDSA sigECDSA' msg)
-                              , eqTest "alteration"  False (ECDSA.verify prx hashAlg pubECDSA sigECDSA msg')
-                              ]
+        return $
+            propertyHold
+                [ eqTest "signature" sigECC $ normalizeECC curve $ sigECDSAtoECC prx sigECDSA
+                , eqTest "verification" True (ECDSA.verify prx hashAlg pubECDSA sigECDSA msg)
+                , eqTest "alteration" False (ECDSA.verify prx hashAlg pubECDSA sigECDSA msg')
+                ]
diff --git a/tests/Hash.hs b/tests/Hash.hs
--- a/tests/Hash.hs
+++ b/tests/Hash.hs
@@ -1,217 +1,428 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE ExistentialQuantification #-}
 {-# LANGUAGE DataKinds #-}
-module Hash
-    ( tests
-    ) where
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE OverloadedStrings #-}
 
+module Hash (
+    tests,
+) where
+
 import Crypto.Hash
 
+import Data.ByteArray (convert)
+import qualified Data.ByteArray.Encoding as B (Base (..), convertToBase)
 import qualified Data.ByteString as B
-import           Data.ByteArray (convert)
-import qualified Data.ByteArray.Encoding as B (convertToBase, Base(..))
-import           GHC.TypeLits
+import GHC.TypeLits
 import Imports
 
-v0,v1,v2 :: ByteString
+v0, v1, v2 :: ByteString
 v0 = ""
 v1 = "The quick brown fox jumps over the lazy dog"
 v2 = "The quick brown fox jumps over the lazy cog"
-vectors = [ v0, v1, v2 ]
+vectors = [v0, v1, v2]
 
 instance Arbitrary ByteString where
     arbitrary = B.pack `fmap` arbitrary
 
-data HashAlg = forall alg . HashAlgorithm alg => HashAlg alg
+data HashAlg = forall alg. HashAlgorithm alg => HashAlg alg
 
-expected :: [ (String, HashAlg, [ByteString]) ]
-expected = [
-    ("MD2", HashAlg MD2, [
-        "8350e5a3e24c153df2275c9f80692773",
-        "03d85a0d629d2c442e987525319fc471",
-        "6b890c9292668cdbbfda00a4ebf31f05" ]),
-    ("MD4", HashAlg MD4, [
-        "31d6cfe0d16ae931b73c59d7e0c089c0",
-        "1bee69a46ba811185c194762abaeae90",
-        "b86e130ce7028da59e672d56ad0113df" ]),
-    ("MD5", HashAlg MD5, [
-        "d41d8cd98f00b204e9800998ecf8427e",
-        "9e107d9d372bb6826bd81d3542a419d6",
-        "1055d3e698d289f2af8663725127bd4b" ]),
-    ("SHA1", HashAlg SHA1, [
-        "da39a3ee5e6b4b0d3255bfef95601890afd80709",
-        "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
-        "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3" ]),
-    ("SHA224", HashAlg SHA224, [
-        "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f",
-        "730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525",
-        "fee755f44a55f20fb3362cdc3c493615b3cb574ed95ce610ee5b1e9b" ]),
-    ("SHA256", HashAlg SHA256, [
-        "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-        "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592",
-        "e4c4d8f3bf76b692de791a173e05321150f7a345b46484fe427f6acc7ecc81be" ]),
-    ("SHA384", HashAlg SHA384, [
-        "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b",
-        "ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1",
-        "098cea620b0978caa5f0befba6ddcf22764bea977e1c70b3483edfdf1de25f4b40d6cea3cadf00f809d422feb1f0161b" ]),
-    ("SHA512", HashAlg SHA512, [
-        "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
-        "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6",
-        "3eeee1d0e11733ef152a6c29503b3ae20c4f1f3cda4cb26f1bc1a41f91c7fe4ab3bd86494049e201c4bd5155f31ecb7a3c8606843c4cc8dfcab7da11c8ae5045" ]),
-    ("SHA512/224", HashAlg SHA512t_224, [
-        "6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4",
-        "944cd2847fb54558d4775db0485a50003111c8e5daa63fe722c6aa37",
-        "2b9d6565a7e40f780ba8ab7c8dcf41e3ed3b77997f4c55aa987eede5" ]),
-    ("SHA512/256", HashAlg SHA512t_256, [
-        "c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a",
-        "dd9d67b371519c339ed8dbd25af90e976a1eeefd4ad3d889005e532fc5bef04d",
-        "cc8d255a7f2f38fd50388fd1f65ea7910835c5c1e73da46fba01ea50d5dd76fb" ]),
-    ("RIPEMD160", HashAlg RIPEMD160, [
-        "9c1185a5c5e9fc54612808977ee8f548b2258d31",
-        "37f332f68db77bd9d7edd4969571ad671cf9dd3b",
-        "132072df690933835eb8b6ad0b77e7b6f14acad7" ]),
-    ("Tiger", HashAlg Tiger, [
-        "3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3",
-        "6d12a41e72e644f017b6f0e2f7b44c6285f06dd5d2c5b075",
-        "a8f04b0f7201a0d728101c9d26525b31764a3493fcd8458f" ])
-{-
-    , ("Skein256-160", HashAlg Skein256_160, [
-        "ff800bed6d2044ee9d604a674e3fda50d9b24a72",
-        "3265703c166aa3e0d7da070b9cf1b1a5953f0a77",
-        "17b29aa1424b3ec022505bd215ff73fd2e6d1e5a" ])
--}
-    , ("Skein256-256", HashAlg Skein256_256, [
-        "c8877087da56e072870daa843f176e9453115929094c3a40c463a196c29bf7ba",
-        "c0fbd7d779b20f0a4614a66697f9e41859eaf382f14bf857e8cdb210adb9b3fe",
-        "fb2f2f2deed0e1dd7ee2b91cee34e2d1c22072e1f5eaee288c35a0723eb653cd" ])
-{-
-    , ("Skein512-160", HashAlg Skein512_160, [
-        "49daf1ccebb3544bc93cb5019ba91b0eea8876ee",
-        "826325ee55a6dd18c3b2dbbc9c10420f5475975e",
-        "7544ec7a35712ec953f02b0d0c86641cae4eb6e5" ])
--}
-    , ("Skein512-384", HashAlg Skein512_384, [
-        "dd5aaf4589dc227bd1eb7bc68771f5baeaa3586ef6c7680167a023ec8ce26980f06c4082c488b4ac9ef313f8cbe70808",
-        "f814c107f3465e7c54048a5503547deddc377264f05c706b0d19db4847b354855ee52ab6a785c238c9e710d848542041",
-        "e06520eeadc1d0a44fee1d2492547499c1e58526387c8b9c53905e5edb79f9840575cbf844e21b1ad1ea126dd8a8ca6f" ])
-    , ("Skein512-512", HashAlg Skein512_512, [
-        "bc5b4c50925519c290cc634277ae3d6257212395cba733bbad37a4af0fa06af41fca7903d06564fea7a2d3730dbdb80c1f85562dfcc070334ea4d1d9e72cba7a",
-        "94c2ae036dba8783d0b3f7d6cc111ff810702f5c77707999be7e1c9486ff238a7044de734293147359b4ac7e1d09cd247c351d69826b78dcddd951f0ef912713",
-        "7f81113575e4b4d3441940e87aca331e6d63d103fe5107f29cd877af0d0f5e0ea34164258c60da5190189d0872e63a96596d2ef25e709099842da71d64111e0f" ])
-{-
-    , ("Skein512-896", HashAlg Skein512_896, [
-        "b95175236c83a459ce7ec6c12b761a838b22d750e765b3fdaa892201b2aa714bc3d1d887dd64028bbf177c1dd11baa09c6c4ddb598fd07d6a8c131a09fc5b958e2999a8006754b25abe3bf8492b7eabec70e52e04e5ac867df2393c573f16eee3244554f1d2b724f2c0437c62007f770",
-        "3265708553e7d146e5c7bcbc97b3e9e9f5b53a5e4af53612bdd6454da4fa7b13d413184fe34ed57b6574be10e389d0ec4b1d2b1dd2c80e0257d5a76b2cd86a19a27b1bcb3cc24d911b5dc5ee74d19ad558fd85b5f024e99f56d1d3199f1f9f88ed85fab9f945f11cf9fc00e94e3ca4c7",
-        "3d23d3db9be719bbd2119f8402a28f38d8225faa79d5b68b80738c64a82004aafc7a840cd6dd9bced6644fa894a3d8d7d2ee89525fd1956a2db052c4c2f8d2111c91ef46b0997540d42bcf384826af1a5ef6510077f52d0574cf2b46f1b6a5dad07ed40f3d21a13ca2d079fa602ff02d" ])
--}
-    , ("Whirlpool", HashAlg Whirlpool, [
-        "19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3",
-        "b97de512e91e3828b40d2b0fdce9ceb3c4a71f9bea8d88e75c4fa854df36725fd2b52eb6544edcacd6f8beddfea403cb55ae31f03ad62a5ef54e42ee82c3fb35",
-        "dce81fc695cfea3d7e1446509238daf89f24cc61896f2d265927daa70f2108f8902f0dfd68be085d5abb9fcd2e482c1dc24f2fabf81f40b73495cad44d7360d3"])
-    , ("Keccak-224", HashAlg Keccak_224, [
-        "f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd",
-        "310aee6b30c47350576ac2873fa89fd190cdc488442f3ef654cf23fe",
-        "0b27ff3b732133287f6831e2af47cf342b7ef1f3fcdee248811090cd" ])
-    , ("Keccak-256", HashAlg Keccak_256, [
-        "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
-        "4d741b6f1eb29cb2a9b9911c82f56fa8d73b04959d3d9d222895df6c0b28aa15",
-        "ed6c07f044d7573cc53bf1276f8cba3dac497919597a45b4599c8f73e22aa334" ])
-    , ("Keccak-384", HashAlg Keccak_384, [
-        "2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff",
-        "283990fa9d5fb731d786c5bbee94ea4db4910f18c62c03d173fc0a5e494422e8a0b3da7574dae7fa0baf005e504063b3",
-        "1cc515e1812491058d8b8b226fd85045e746b4937a58b0111b6b7a39dd431b6295bd6b6d05e01e225586b4dab3cbb87a" ])
-    , ("Keccak-512", HashAlg Keccak_512, [
-        "0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e",
-        "d135bb84d0439dbac432247ee573a23ea7d3c9deb2a968eb31d47c4fb45f1ef4422d6c531b5b9bd6f449ebcc449ea94d0a8f05f62130fda612da53c79659f609",
-        "10f8caabb5b179861da5e447d34b84d604e3eb81830880e1c2135ffc94580a47cb21f6243ec0053d58b1124d13af2090033659075ee718e0f111bb3f69fb24cf" ])
-    , ("SHA3-224", HashAlg SHA3_224, [
-        "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7",
-        "d15dadceaa4d5d7bb3b48f446421d542e08ad8887305e28d58335795",
-        "b770eb6ac3ac52bd2f9e8dc186d6b604e7c3b7ffc8bd9220b0078ced" ])
-    , ("SHA3-256", HashAlg SHA3_256, [
-        "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a",
-        "69070dda01975c8c120c3aada1b282394e7f032fa9cf32f4cb2259a0897dfc04",
-        "cc80b0b13ba89613d93f02ee7ccbe72ee26c6edfe577f22e63a1380221caedbc" ])
-    , ("SHA3-384", HashAlg SHA3_384, [
-        "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004",
-        "7063465e08a93bce31cd89d2e3ca8f602498696e253592ed26f07bf7e703cf328581e1471a7ba7ab119b1a9ebdf8be41",
-        "e414797403c7d01ab64b41e90df4165d59b7f147e4292ba2da336acba242fd651949eb1cfff7e9012e134b40981842e1" ])
-    , ("SHA3-512", HashAlg SHA3_512, [
-        "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26",
-        "01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450",
-        "28e361fe8c56e617caa56c28c7c36e5c13be552b77081be82b642f08bb7ef085b9a81910fe98269386b9aacfd2349076c9506126e198f6f6ad44c12017ca77b1" ])
-    , ("Blake2b-160", HashAlg Blake2b_160, [
-        "3345524abf6bbe1809449224b5972c41790b6cf2",
-        "3c523ed102ab45a37d54f5610d5a983162fde84f",
-        "a3d365b5fba5d36fbb19c03b7fde496058969c5a" ])
-    , ("Blake2b-224", HashAlg Blake2b_224, [
-        "836cc68931c2e4e3e838602eca1902591d216837bafddfe6f0c8cb07",
-        "477c3985751dd4d1b8c93827ea5310b33bb02a26463a050dffd3e857",
-        "a4a1b6851be66891a3deff406c4d7556879ebf952407450755f90eb6" ])
-    , ("Blake2b-256", HashAlg Blake2b_256, [
-        "0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8",
-        "01718cec35cd3d796dd00020e0bfecb473ad23457d063b75eff29c0ffa2e58a9",
-        "036c13096926b3dfccfe3f233bd1b2f583b818b8b15c01be65af69238e900b2c" ])
-    , ("Blake2b-384", HashAlg Blake2b_384, [
-        "b32811423377f52d7862286ee1a72ee540524380fda1724a6f25d7978c6fd3244a6caf0498812673c5e05ef583825100",
-        "b7c81b228b6bd912930e8f0b5387989691c1cee1e65aade4da3b86a3c9f678fc8018f6ed9e2906720c8d2a3aeda9c03d",
-        "927a1f297873cbe887a93b2183c4e2eba53966ba92c6db8b87029a1d8c673471d09740676cced79c5016838973f630c3" ])
-    , ("Blake2b-512", HashAlg Blake2b_512, [
-        "786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce",
-        "a8add4bdddfd93e4877d2746e62817b116364a1fa7bc148d95090bc7333b3673f82401cf7aa2e4cb1ecd90296e3f14cb5413f8ed77be73045b13914cdcd6a918",
-        "af438eea5d8cdb209336a7e85bf58090dc21b49d823f89a7d064c119f127bd361af9c7d109edda0f0e91bdce078d1d86b8e6f25727c98f6d3bb6f50acb2dd376" ])
-    , ("Blake2s-160", HashAlg Blake2s_160, [
-        "354c9c33f735962418bdacb9479873429c34916f",
-        "5a604fec9713c369e84b0ed68daed7d7504ef240",
-        "759bef6d041bcbd861b8b51baaece6c8fffd0acf" ])
-    , ("Blake2s-224", HashAlg Blake2s_224, [
-        "1fa1291e65248b37b3433475b2a0dd63d54a11ecc4e3e034e7bc1ef4",
-        "e4e5cb6c7cae41982b397bf7b7d2d9d1949823ae78435326e8db4912",
-        "e220025fd46a9a635c3f7f60bb96a84c01019ac0817f5901e7eeaa2c" ])
-    , ("Blake2s-256", HashAlg Blake2s_256, [
-        "69217a3079908094e11121d042354a7c1f55b6482ca1a51e1b250dfd1ed0eef9",
-        "606beeec743ccbeff6cbcdf5d5302aa855c256c29b88c8ed331ea1a6bf3c8812",
-        "94662583a600a12dff357c0a6f1b514a710ef0f587a38e8d2e4d7f67e9c81667" ])
-    , ("SHAKE128_4096", HashAlg (SHAKE128 :: SHAKE128 4096), [
-        "7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef263cb1eea988004b93103cfb0aeefd2a686e01fa4a58e8a3639ca8a1e3f9ae57e235b8cc873c23dc62b8d260169afa2f75ab916a58d974918835d25e6a435085b2badfd6dfaac359a5efbb7bcc4b59d538df9a04302e10c8bc1cbf1a0b3a5120ea17cda7cfad765f5623474d368ccca8af0007cd9f5e4c849f167a580b14aabdefaee7eef47cb0fca9767be1fda69419dfb927e9df07348b196691abaeb580b32def58538b8d23f87732ea63b02b4fa0f4873360e2841928cd60dd4cee8cc0d4c922a96188d032675c8ac850933c7aff1533b94c834adbb69c6115bad4692d8619f90b0cdf8a7b9c264029ac185b70b83f2801f2f4b3f70c593ea3aeeb613a7f1b1de33fd75081f592305f2e4526edc09631b10958f464d889f31ba010250fda7f1368ec2967fc84ef2ae9aff268e0b1700affc6820b523a3d917135f2dff2ee06bfe72b3124721d4a26c04e53a75e30e73a7a9c4a95d91c55d495e9f51dd0b5e9d83c6d5e8ce803aa62b8d654db53d09b8dcff273cdfeb573fad8bcd45578bec2e770d01efde86e721a3f7c6cce275dabe6e2143f1af18da7efddc4c7b70b5e345db93cc936bea323491ccb38a388f546a9ff00dd4e1300b9b2153d2041d205b443e41b45a653f2a5c4492c1add544512dda2529833462b71a41a45be97290b6f",
-        "f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66eb5585ec6f86021cacf272c798bcf97d368b886b18fec3a571f096086a523717a3732d50db2b0b7998b4117ae66a761ccf1847a1616f4c07d5178d0d965f9feba351420f8bfb6f5ab9a0cb102568eabf3dfa4e22279f8082dce8143eb78235a1a54914ab71abb07f2f3648468370b9fbb071e074f1c030a4030225f40c39480339f3dc71d0f04f71326de1381674cc89e259e219927fae8ea2799a03da862a55afafe670957a2af3318d919d0a3358f3b891236d6a8e8d19999d1076b529968faefbd880d77bb300829dca87e9c8e4c28e0800ff37490a5bd8c36c0b0bdb2701a5d58d03378b9dbd384389e3ef0fd4003b08998fd3f32fe1a0810fc0eccaad94bca8dd83b34559c333f0b16dfc2896ed87b30ba14c81f87cd8b4bb6317db89b0e7e94c0616f9a665fba5b0e6fb3549c9d7b68e66d08a86eb2faec05cc462a771806b93cc38b0a4feb9935c6c8945da6a589891ba5ee99753cfdd38e1abc7147fd74b7c7d1ce0609b6680a2e18888d84949b6e6cf6a2aa4113535aaee079459e3f257b569a9450523c41f5b5ba4b79b3ba5949140a74bb048de0657d04954bdd71dae76f61e2a1f88aecb91cfa5b36c1bf3350a798dc4dcf48628effe3a0c5340c756bd922f78d0e36ef7df12ce78c179cc721ad087e15ea496bf5f60b21b5822d",
-        "22fd225fb8f2c8d0d2097e1f8d38b6a9e619d39664dad3795f0336fda544d305e1be56a9953ecd6e4bec14b622f53da492eccbe257b9af84775a6bdf81aab6b1ba3492149b7ce4ea402c56e343939f78b9a9727193269798420c9323a9eb1fa63006e1482fcf15e3696aa1ae5cb66eb8aad4ac6041ca0b576b78785ad95bc5fb6f8a420ba9e1726552c0f2b97050ae69fc018d3f63b3a812a2d39ef64b8ae368472dec4341511b02cf77363c74f216055d5905412bc2bf57b4010b1bdce2882cb28fc7e4d470ed05219fc4d1ce11d11e10db369c807cd71891653638956b2f9d176e116188aff2fbb8519d9ad8c3fb52fa8bb4a0413364e89d9f9d7db627f2a2288babedcc314a19e45c6b7fb93b16a15d9953ff619ab4d523c481552588f711b450f854c858ebcb8cf49492d6240a753bde2109c486cac666bdba767c6e9254cc723f67855534c34d08ed486c67c1b8dd288c6010ce8e6c1c9b7f927acf4d71ee99729cee55ecec544245d0b51b31dd78eb99c2723e8ba5cf92ac7720e8933d9fd3596b90073f6980c5ed3f1cbfada26bdb6946e72391198e3d1cedebdba092324500e32b8e04e32550f6dd6c4befafa95acc206c5708300d2a8df2765751102f9738a1449c4c0d588f0076d0c1a5ee445eb85c97ada5837d5dc1d34ea081c8411d64a4d9ce9279bfe9feb25696cf741c705ed46f171e2239216d6c45dc8d15" ])
-    , ("SHAKE256_4096", HashAlg (SHAKE256 :: SHAKE256 4096), [
-        "46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be141e96616fb13957692cc7edd0b45ae3dc07223c8e92937bef84bc0eab862853349ec75546f58fb7c2775c38462c5010d846c185c15111e595522a6bcd16cf86f3d122109e3b1fdd943b6aec468a2d621a7c06c6a957c62b54dafc3be87567d677231395f6147293b68ceab7a9e0c58d864e8efde4e1b9a46cbe854713672f5caaae314ed9083dab4b099f8e300f01b8650f1f4b1d8fcf3f3cb53fb8e9eb2ea203bdc970f50ae55428a91f7f53ac266b28419c3778a15fd248d339ede785fb7f5a1aaa96d313eacc890936c173cdcd0fab882c45755feb3aed96d477ff96390bf9a66d1368b208e21f7c10d04a3dbd4e360633e5db4b602601c14cea737db3dcf722632cc77851cbdde2aaf0a33a07b373445df490cc8fc1e4160ff118378f11f0477de055a81a9eda57a4a2cfb0c83929d310912f729ec6cfa36c6ac6a75837143045d791cc85eff5b21932f23861bcf23a52b5da67eaf7baae0f5fb1369db78f3ac45f8c4ac5671d85735cdddb09d2b1e34a1fc066ff4a162cb263d6541274ae2fcc865f618abe27c124cd8b074ccd516301b91875824d09958f341ef274bdab0bae316339894304e35877b0c28a9b1fd166c796b9cc258a064a8f57e27f2a",
-        "2f671343d9b2e1604dc9dcf0753e5fe15c7c64a0d283cbbf722d411a0e36f6ca1d01d1369a23539cd80f7c054b6e5daf9c962cad5b8ed5bd11998b40d5734442bed798f6e5c915bd8bb07e0188d0a55c1290074f1c287af06352299184492cbdec9acba737ee292e5adaa445547355e72a03a3bac3aac770fe5d6b66600ff15d37d5b4789994ea2aeb097f550aa5e88e4d8ff0ba07b88c1c88573063f5d96df820abc2abd177ab037f351c375e553af917132cf2f563c79a619e1bb76e8e2266b0c5617d695f2c496a25f4073b6840c1833757ebb386f16757a8e16a21e9355e9b248f3b33be672da700266be99b8f8725e8ab06075f0219e655ebc188976364b7db139390d34a6ea67b4b223229183a94cf455ece91fdaf5b9c707fa4b40ec39816c1120c7aaaf47920977be900e6b9ca4b8940e192b927c475bd58e836f512ae3e52924e36ff8e9b1d0251047770a5e465905622b1f159be121ab93819c5e5c6dae299ac73bf1c4ed4a1e2c7fa3caa1039b05e94c9f993d04feb272b6e00bb0276939cf746c42936831fc8f2b4cb0cf94808ae0af405ce4bc67d1e7acfc6fd6590d3de91f795df5aaf57e2cee1845a303d0ea564be3f1299acdce67efe0d62cfc6d6829ff4ecc0a05153c24696c4d34c076453827e796f3062f94f62f4528b7cfc870f0dcd615b7c97b95da4b9be5830e8b3f66cce71e0f622c771994443e2",
-        "fffcaac0606c0edb7bc0d15f033accb68538159016e5ae8470bf9ebea89fa6c9fcc3e027d94f7f967b7246346bd9f6b8084e45a057b976847c4db03bf383c834054866f6a8282a497368c46e1852fc09e20f22c45607a27c8b2a4798ebefada54f8d3795b9f07606b1cd6e41f90d765480ef5c0d5790659cf1d210adfd412378b92e1dd9bd7fd95a1a66677fc6baa0e3a53c9031c1fb59cbad9f5dc5881a3c8e25c80ecb1abf0971488ada1f533dcbf8d37031335378574b8d3fad61159c9fae28caa543b3072ce308d369be340e78c6edc664cc6dde9b2f0a4ad2e60ce9c8b1e5722b8d5b73d0962b74fb9ed86307a180f53933339f9d56d3b345c2a0e98fcf5de7754f3845f6be30089f0e142ad4602f18abdc750bda7c91c3f32872e66640db46045ab4c276b379f1b834c2cbb1bd8601305649ec6b3bf20618695136dee6541492d1d985ea1fb765fd7a559e810eba30f2f710233ae5a411b94ddcaa01a08f1c31320d111c0714422cd5e987c9a76fc865de34003ab12664081be8017d23d977f2bf4ed9e3ce09ea3d64bb4ae8ebfa9d0721f57841008c297e2f455a0441a2bd618ca379dbd239a21e410defb4001b1e11f87e36bf894c222f76f12ddcc3771bbb17d5c0dfd86d89a3e13e084f6dc1c4762bcd393c1757db7afb1434221569e7ddaaffd6318253ec3df8cf5f826b81896d6474ee06a2e30ccc8c6a96bdd5" ])
-    , ("Blake2b 160", HashAlg (Blake2b :: Blake2b 160), [
-        "3345524abf6bbe1809449224b5972c41790b6cf2",
-        "3c523ed102ab45a37d54f5610d5a983162fde84f",
-        "a3d365b5fba5d36fbb19c03b7fde496058969c5a" ])
-    , ("Blake2b 224", HashAlg (Blake2b :: Blake2b 224), [
-        "836cc68931c2e4e3e838602eca1902591d216837bafddfe6f0c8cb07",
-        "477c3985751dd4d1b8c93827ea5310b33bb02a26463a050dffd3e857",
-        "a4a1b6851be66891a3deff406c4d7556879ebf952407450755f90eb6" ])
-    , ("Blake2b 256", HashAlg (Blake2b :: Blake2b 256), [
-        "0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8",
-        "01718cec35cd3d796dd00020e0bfecb473ad23457d063b75eff29c0ffa2e58a9",
-        "036c13096926b3dfccfe3f233bd1b2f583b818b8b15c01be65af69238e900b2c" ])
-    , ("Blake2b 384", HashAlg (Blake2b :: Blake2b 384), [
-        "b32811423377f52d7862286ee1a72ee540524380fda1724a6f25d7978c6fd3244a6caf0498812673c5e05ef583825100",
-        "b7c81b228b6bd912930e8f0b5387989691c1cee1e65aade4da3b86a3c9f678fc8018f6ed9e2906720c8d2a3aeda9c03d",
-        "927a1f297873cbe887a93b2183c4e2eba53966ba92c6db8b87029a1d8c673471d09740676cced79c5016838973f630c3" ])
-    , ("Blake2b 512", HashAlg (Blake2b :: Blake2b 512), [
-        "786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce",
-        "a8add4bdddfd93e4877d2746e62817b116364a1fa7bc148d95090bc7333b3673f82401cf7aa2e4cb1ecd90296e3f14cb5413f8ed77be73045b13914cdcd6a918",
-        "af438eea5d8cdb209336a7e85bf58090dc21b49d823f89a7d064c119f127bd361af9c7d109edda0f0e91bdce078d1d86b8e6f25727c98f6d3bb6f50acb2dd376" ])
-    , ("Blake2s 160", HashAlg (Blake2s :: Blake2s 160), [
-        "354c9c33f735962418bdacb9479873429c34916f",
-        "5a604fec9713c369e84b0ed68daed7d7504ef240",
-        "759bef6d041bcbd861b8b51baaece6c8fffd0acf" ])
-    , ("Blake2s 224", HashAlg (Blake2s :: Blake2s 224), [
-        "1fa1291e65248b37b3433475b2a0dd63d54a11ecc4e3e034e7bc1ef4",
-        "e4e5cb6c7cae41982b397bf7b7d2d9d1949823ae78435326e8db4912",
-        "e220025fd46a9a635c3f7f60bb96a84c01019ac0817f5901e7eeaa2c" ])
-    , ("Blake2s 256", HashAlg (Blake2s ::Blake2s 256), [
-        "69217a3079908094e11121d042354a7c1f55b6482ca1a51e1b250dfd1ed0eef9",
-        "606beeec743ccbeff6cbcdf5d5302aa855c256c29b88c8ed331ea1a6bf3c8812",
-        "94662583a600a12dff357c0a6f1b514a710ef0f587a38e8d2e4d7f67e9c81667" ])
+expected :: [(String, HashAlg, [ByteString])]
+expected =
+    [
+        ( "MD2"
+        , HashAlg MD2
+        ,
+            [ "8350e5a3e24c153df2275c9f80692773"
+            , "03d85a0d629d2c442e987525319fc471"
+            , "6b890c9292668cdbbfda00a4ebf31f05"
+            ]
+        )
+    ,
+        ( "MD4"
+        , HashAlg MD4
+        ,
+            [ "31d6cfe0d16ae931b73c59d7e0c089c0"
+            , "1bee69a46ba811185c194762abaeae90"
+            , "b86e130ce7028da59e672d56ad0113df"
+            ]
+        )
+    ,
+        ( "MD5"
+        , HashAlg MD5
+        ,
+            [ "d41d8cd98f00b204e9800998ecf8427e"
+            , "9e107d9d372bb6826bd81d3542a419d6"
+            , "1055d3e698d289f2af8663725127bd4b"
+            ]
+        )
+    ,
+        ( "SHA1"
+        , HashAlg SHA1
+        ,
+            [ "da39a3ee5e6b4b0d3255bfef95601890afd80709"
+            , "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"
+            , "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3"
+            ]
+        )
+    ,
+        ( "SHA224"
+        , HashAlg SHA224
+        ,
+            [ "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f"
+            , "730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525"
+            , "fee755f44a55f20fb3362cdc3c493615b3cb574ed95ce610ee5b1e9b"
+            ]
+        )
+    ,
+        ( "SHA256"
+        , HashAlg SHA256
+        ,
+            [ "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
+            , "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"
+            , "e4c4d8f3bf76b692de791a173e05321150f7a345b46484fe427f6acc7ecc81be"
+            ]
+        )
+    ,
+        ( "SHA384"
+        , HashAlg SHA384
+        ,
+            [ "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"
+            , "ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1"
+            , "098cea620b0978caa5f0befba6ddcf22764bea977e1c70b3483edfdf1de25f4b40d6cea3cadf00f809d422feb1f0161b"
+            ]
+        )
+    ,
+        ( "SHA512"
+        , HashAlg SHA512
+        ,
+            [ "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
+            , "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6"
+            , "3eeee1d0e11733ef152a6c29503b3ae20c4f1f3cda4cb26f1bc1a41f91c7fe4ab3bd86494049e201c4bd5155f31ecb7a3c8606843c4cc8dfcab7da11c8ae5045"
+            ]
+        )
+    ,
+        ( "SHA512/224"
+        , HashAlg SHA512t_224
+        ,
+            [ "6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4"
+            , "944cd2847fb54558d4775db0485a50003111c8e5daa63fe722c6aa37"
+            , "2b9d6565a7e40f780ba8ab7c8dcf41e3ed3b77997f4c55aa987eede5"
+            ]
+        )
+    ,
+        ( "SHA512/256"
+        , HashAlg SHA512t_256
+        ,
+            [ "c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a"
+            , "dd9d67b371519c339ed8dbd25af90e976a1eeefd4ad3d889005e532fc5bef04d"
+            , "cc8d255a7f2f38fd50388fd1f65ea7910835c5c1e73da46fba01ea50d5dd76fb"
+            ]
+        )
+    ,
+        ( "RIPEMD160"
+        , HashAlg RIPEMD160
+        ,
+            [ "9c1185a5c5e9fc54612808977ee8f548b2258d31"
+            , "37f332f68db77bd9d7edd4969571ad671cf9dd3b"
+            , "132072df690933835eb8b6ad0b77e7b6f14acad7"
+            ]
+        )
+    ,
+        ( "Tiger"
+        , HashAlg Tiger
+        ,
+            [ "3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3"
+            , "6d12a41e72e644f017b6f0e2f7b44c6285f06dd5d2c5b075"
+            , "a8f04b0f7201a0d728101c9d26525b31764a3493fcd8458f"
+            ]
+        )
+    , {-
+          , ("Skein256-160", HashAlg Skein256_160, [
+              "ff800bed6d2044ee9d604a674e3fda50d9b24a72",
+              "3265703c166aa3e0d7da070b9cf1b1a5953f0a77",
+              "17b29aa1424b3ec022505bd215ff73fd2e6d1e5a" ])
+      -}
+
+        ( "Skein256-256"
+        , HashAlg Skein256_256
+        ,
+            [ "c8877087da56e072870daa843f176e9453115929094c3a40c463a196c29bf7ba"
+            , "c0fbd7d779b20f0a4614a66697f9e41859eaf382f14bf857e8cdb210adb9b3fe"
+            , "fb2f2f2deed0e1dd7ee2b91cee34e2d1c22072e1f5eaee288c35a0723eb653cd"
+            ]
+        )
+    , {-
+          , ("Skein512-160", HashAlg Skein512_160, [
+              "49daf1ccebb3544bc93cb5019ba91b0eea8876ee",
+              "826325ee55a6dd18c3b2dbbc9c10420f5475975e",
+              "7544ec7a35712ec953f02b0d0c86641cae4eb6e5" ])
+      -}
+
+        ( "Skein512-384"
+        , HashAlg Skein512_384
+        ,
+            [ "dd5aaf4589dc227bd1eb7bc68771f5baeaa3586ef6c7680167a023ec8ce26980f06c4082c488b4ac9ef313f8cbe70808"
+            , "f814c107f3465e7c54048a5503547deddc377264f05c706b0d19db4847b354855ee52ab6a785c238c9e710d848542041"
+            , "e06520eeadc1d0a44fee1d2492547499c1e58526387c8b9c53905e5edb79f9840575cbf844e21b1ad1ea126dd8a8ca6f"
+            ]
+        )
+    ,
+        ( "Skein512-512"
+        , HashAlg Skein512_512
+        ,
+            [ "bc5b4c50925519c290cc634277ae3d6257212395cba733bbad37a4af0fa06af41fca7903d06564fea7a2d3730dbdb80c1f85562dfcc070334ea4d1d9e72cba7a"
+            , "94c2ae036dba8783d0b3f7d6cc111ff810702f5c77707999be7e1c9486ff238a7044de734293147359b4ac7e1d09cd247c351d69826b78dcddd951f0ef912713"
+            , "7f81113575e4b4d3441940e87aca331e6d63d103fe5107f29cd877af0d0f5e0ea34164258c60da5190189d0872e63a96596d2ef25e709099842da71d64111e0f"
+            ]
+        )
+    , {-
+          , ("Skein512-896", HashAlg Skein512_896, [
+              "b95175236c83a459ce7ec6c12b761a838b22d750e765b3fdaa892201b2aa714bc3d1d887dd64028bbf177c1dd11baa09c6c4ddb598fd07d6a8c131a09fc5b958e2999a8006754b25abe3bf8492b7eabec70e52e04e5ac867df2393c573f16eee3244554f1d2b724f2c0437c62007f770",
+              "3265708553e7d146e5c7bcbc97b3e9e9f5b53a5e4af53612bdd6454da4fa7b13d413184fe34ed57b6574be10e389d0ec4b1d2b1dd2c80e0257d5a76b2cd86a19a27b1bcb3cc24d911b5dc5ee74d19ad558fd85b5f024e99f56d1d3199f1f9f88ed85fab9f945f11cf9fc00e94e3ca4c7",
+              "3d23d3db9be719bbd2119f8402a28f38d8225faa79d5b68b80738c64a82004aafc7a840cd6dd9bced6644fa894a3d8d7d2ee89525fd1956a2db052c4c2f8d2111c91ef46b0997540d42bcf384826af1a5ef6510077f52d0574cf2b46f1b6a5dad07ed40f3d21a13ca2d079fa602ff02d" ])
+      -}
+
+        ( "Whirlpool"
+        , HashAlg Whirlpool
+        ,
+            [ "19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3"
+            , "b97de512e91e3828b40d2b0fdce9ceb3c4a71f9bea8d88e75c4fa854df36725fd2b52eb6544edcacd6f8beddfea403cb55ae31f03ad62a5ef54e42ee82c3fb35"
+            , "dce81fc695cfea3d7e1446509238daf89f24cc61896f2d265927daa70f2108f8902f0dfd68be085d5abb9fcd2e482c1dc24f2fabf81f40b73495cad44d7360d3"
+            ]
+        )
+    ,
+        ( "Keccak-224"
+        , HashAlg Keccak_224
+        ,
+            [ "f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd"
+            , "310aee6b30c47350576ac2873fa89fd190cdc488442f3ef654cf23fe"
+            , "0b27ff3b732133287f6831e2af47cf342b7ef1f3fcdee248811090cd"
+            ]
+        )
+    ,
+        ( "Keccak-256"
+        , HashAlg Keccak_256
+        ,
+            [ "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
+            , "4d741b6f1eb29cb2a9b9911c82f56fa8d73b04959d3d9d222895df6c0b28aa15"
+            , "ed6c07f044d7573cc53bf1276f8cba3dac497919597a45b4599c8f73e22aa334"
+            ]
+        )
+    ,
+        ( "Keccak-384"
+        , HashAlg Keccak_384
+        ,
+            [ "2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff"
+            , "283990fa9d5fb731d786c5bbee94ea4db4910f18c62c03d173fc0a5e494422e8a0b3da7574dae7fa0baf005e504063b3"
+            , "1cc515e1812491058d8b8b226fd85045e746b4937a58b0111b6b7a39dd431b6295bd6b6d05e01e225586b4dab3cbb87a"
+            ]
+        )
+    ,
+        ( "Keccak-512"
+        , HashAlg Keccak_512
+        ,
+            [ "0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e"
+            , "d135bb84d0439dbac432247ee573a23ea7d3c9deb2a968eb31d47c4fb45f1ef4422d6c531b5b9bd6f449ebcc449ea94d0a8f05f62130fda612da53c79659f609"
+            , "10f8caabb5b179861da5e447d34b84d604e3eb81830880e1c2135ffc94580a47cb21f6243ec0053d58b1124d13af2090033659075ee718e0f111bb3f69fb24cf"
+            ]
+        )
+    ,
+        ( "SHA3-224"
+        , HashAlg SHA3_224
+        ,
+            [ "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7"
+            , "d15dadceaa4d5d7bb3b48f446421d542e08ad8887305e28d58335795"
+            , "b770eb6ac3ac52bd2f9e8dc186d6b604e7c3b7ffc8bd9220b0078ced"
+            ]
+        )
+    ,
+        ( "SHA3-256"
+        , HashAlg SHA3_256
+        ,
+            [ "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a"
+            , "69070dda01975c8c120c3aada1b282394e7f032fa9cf32f4cb2259a0897dfc04"
+            , "cc80b0b13ba89613d93f02ee7ccbe72ee26c6edfe577f22e63a1380221caedbc"
+            ]
+        )
+    ,
+        ( "SHA3-384"
+        , HashAlg SHA3_384
+        ,
+            [ "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004"
+            , "7063465e08a93bce31cd89d2e3ca8f602498696e253592ed26f07bf7e703cf328581e1471a7ba7ab119b1a9ebdf8be41"
+            , "e414797403c7d01ab64b41e90df4165d59b7f147e4292ba2da336acba242fd651949eb1cfff7e9012e134b40981842e1"
+            ]
+        )
+    ,
+        ( "SHA3-512"
+        , HashAlg SHA3_512
+        ,
+            [ "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26"
+            , "01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450"
+            , "28e361fe8c56e617caa56c28c7c36e5c13be552b77081be82b642f08bb7ef085b9a81910fe98269386b9aacfd2349076c9506126e198f6f6ad44c12017ca77b1"
+            ]
+        )
+    ,
+        ( "Blake2b-160"
+        , HashAlg Blake2b_160
+        ,
+            [ "3345524abf6bbe1809449224b5972c41790b6cf2"
+            , "3c523ed102ab45a37d54f5610d5a983162fde84f"
+            , "a3d365b5fba5d36fbb19c03b7fde496058969c5a"
+            ]
+        )
+    ,
+        ( "Blake2b-224"
+        , HashAlg Blake2b_224
+        ,
+            [ "836cc68931c2e4e3e838602eca1902591d216837bafddfe6f0c8cb07"
+            , "477c3985751dd4d1b8c93827ea5310b33bb02a26463a050dffd3e857"
+            , "a4a1b6851be66891a3deff406c4d7556879ebf952407450755f90eb6"
+            ]
+        )
+    ,
+        ( "Blake2b-256"
+        , HashAlg Blake2b_256
+        ,
+            [ "0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8"
+            , "01718cec35cd3d796dd00020e0bfecb473ad23457d063b75eff29c0ffa2e58a9"
+            , "036c13096926b3dfccfe3f233bd1b2f583b818b8b15c01be65af69238e900b2c"
+            ]
+        )
+    ,
+        ( "Blake2b-384"
+        , HashAlg Blake2b_384
+        ,
+            [ "b32811423377f52d7862286ee1a72ee540524380fda1724a6f25d7978c6fd3244a6caf0498812673c5e05ef583825100"
+            , "b7c81b228b6bd912930e8f0b5387989691c1cee1e65aade4da3b86a3c9f678fc8018f6ed9e2906720c8d2a3aeda9c03d"
+            , "927a1f297873cbe887a93b2183c4e2eba53966ba92c6db8b87029a1d8c673471d09740676cced79c5016838973f630c3"
+            ]
+        )
+    ,
+        ( "Blake2b-512"
+        , HashAlg Blake2b_512
+        ,
+            [ "786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce"
+            , "a8add4bdddfd93e4877d2746e62817b116364a1fa7bc148d95090bc7333b3673f82401cf7aa2e4cb1ecd90296e3f14cb5413f8ed77be73045b13914cdcd6a918"
+            , "af438eea5d8cdb209336a7e85bf58090dc21b49d823f89a7d064c119f127bd361af9c7d109edda0f0e91bdce078d1d86b8e6f25727c98f6d3bb6f50acb2dd376"
+            ]
+        )
+    ,
+        ( "Blake2s-160"
+        , HashAlg Blake2s_160
+        ,
+            [ "354c9c33f735962418bdacb9479873429c34916f"
+            , "5a604fec9713c369e84b0ed68daed7d7504ef240"
+            , "759bef6d041bcbd861b8b51baaece6c8fffd0acf"
+            ]
+        )
+    ,
+        ( "Blake2s-224"
+        , HashAlg Blake2s_224
+        ,
+            [ "1fa1291e65248b37b3433475b2a0dd63d54a11ecc4e3e034e7bc1ef4"
+            , "e4e5cb6c7cae41982b397bf7b7d2d9d1949823ae78435326e8db4912"
+            , "e220025fd46a9a635c3f7f60bb96a84c01019ac0817f5901e7eeaa2c"
+            ]
+        )
+    ,
+        ( "Blake2s-256"
+        , HashAlg Blake2s_256
+        ,
+            [ "69217a3079908094e11121d042354a7c1f55b6482ca1a51e1b250dfd1ed0eef9"
+            , "606beeec743ccbeff6cbcdf5d5302aa855c256c29b88c8ed331ea1a6bf3c8812"
+            , "94662583a600a12dff357c0a6f1b514a710ef0f587a38e8d2e4d7f67e9c81667"
+            ]
+        )
+    ,
+        ( "SHAKE128_4096"
+        , HashAlg (SHAKE128 :: SHAKE128 4096)
+        ,
+            [ "7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef263cb1eea988004b93103cfb0aeefd2a686e01fa4a58e8a3639ca8a1e3f9ae57e235b8cc873c23dc62b8d260169afa2f75ab916a58d974918835d25e6a435085b2badfd6dfaac359a5efbb7bcc4b59d538df9a04302e10c8bc1cbf1a0b3a5120ea17cda7cfad765f5623474d368ccca8af0007cd9f5e4c849f167a580b14aabdefaee7eef47cb0fca9767be1fda69419dfb927e9df07348b196691abaeb580b32def58538b8d23f87732ea63b02b4fa0f4873360e2841928cd60dd4cee8cc0d4c922a96188d032675c8ac850933c7aff1533b94c834adbb69c6115bad4692d8619f90b0cdf8a7b9c264029ac185b70b83f2801f2f4b3f70c593ea3aeeb613a7f1b1de33fd75081f592305f2e4526edc09631b10958f464d889f31ba010250fda7f1368ec2967fc84ef2ae9aff268e0b1700affc6820b523a3d917135f2dff2ee06bfe72b3124721d4a26c04e53a75e30e73a7a9c4a95d91c55d495e9f51dd0b5e9d83c6d5e8ce803aa62b8d654db53d09b8dcff273cdfeb573fad8bcd45578bec2e770d01efde86e721a3f7c6cce275dabe6e2143f1af18da7efddc4c7b70b5e345db93cc936bea323491ccb38a388f546a9ff00dd4e1300b9b2153d2041d205b443e41b45a653f2a5c4492c1add544512dda2529833462b71a41a45be97290b6f"
+            , "f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66eb5585ec6f86021cacf272c798bcf97d368b886b18fec3a571f096086a523717a3732d50db2b0b7998b4117ae66a761ccf1847a1616f4c07d5178d0d965f9feba351420f8bfb6f5ab9a0cb102568eabf3dfa4e22279f8082dce8143eb78235a1a54914ab71abb07f2f3648468370b9fbb071e074f1c030a4030225f40c39480339f3dc71d0f04f71326de1381674cc89e259e219927fae8ea2799a03da862a55afafe670957a2af3318d919d0a3358f3b891236d6a8e8d19999d1076b529968faefbd880d77bb300829dca87e9c8e4c28e0800ff37490a5bd8c36c0b0bdb2701a5d58d03378b9dbd384389e3ef0fd4003b08998fd3f32fe1a0810fc0eccaad94bca8dd83b34559c333f0b16dfc2896ed87b30ba14c81f87cd8b4bb6317db89b0e7e94c0616f9a665fba5b0e6fb3549c9d7b68e66d08a86eb2faec05cc462a771806b93cc38b0a4feb9935c6c8945da6a589891ba5ee99753cfdd38e1abc7147fd74b7c7d1ce0609b6680a2e18888d84949b6e6cf6a2aa4113535aaee079459e3f257b569a9450523c41f5b5ba4b79b3ba5949140a74bb048de0657d04954bdd71dae76f61e2a1f88aecb91cfa5b36c1bf3350a798dc4dcf48628effe3a0c5340c756bd922f78d0e36ef7df12ce78c179cc721ad087e15ea496bf5f60b21b5822d"
+            , "22fd225fb8f2c8d0d2097e1f8d38b6a9e619d39664dad3795f0336fda544d305e1be56a9953ecd6e4bec14b622f53da492eccbe257b9af84775a6bdf81aab6b1ba3492149b7ce4ea402c56e343939f78b9a9727193269798420c9323a9eb1fa63006e1482fcf15e3696aa1ae5cb66eb8aad4ac6041ca0b576b78785ad95bc5fb6f8a420ba9e1726552c0f2b97050ae69fc018d3f63b3a812a2d39ef64b8ae368472dec4341511b02cf77363c74f216055d5905412bc2bf57b4010b1bdce2882cb28fc7e4d470ed05219fc4d1ce11d11e10db369c807cd71891653638956b2f9d176e116188aff2fbb8519d9ad8c3fb52fa8bb4a0413364e89d9f9d7db627f2a2288babedcc314a19e45c6b7fb93b16a15d9953ff619ab4d523c481552588f711b450f854c858ebcb8cf49492d6240a753bde2109c486cac666bdba767c6e9254cc723f67855534c34d08ed486c67c1b8dd288c6010ce8e6c1c9b7f927acf4d71ee99729cee55ecec544245d0b51b31dd78eb99c2723e8ba5cf92ac7720e8933d9fd3596b90073f6980c5ed3f1cbfada26bdb6946e72391198e3d1cedebdba092324500e32b8e04e32550f6dd6c4befafa95acc206c5708300d2a8df2765751102f9738a1449c4c0d588f0076d0c1a5ee445eb85c97ada5837d5dc1d34ea081c8411d64a4d9ce9279bfe9feb25696cf741c705ed46f171e2239216d6c45dc8d15"
+            ]
+        )
+    ,
+        ( "SHAKE256_4096"
+        , HashAlg (SHAKE256 :: SHAKE256 4096)
+        ,
+            [ "46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be141e96616fb13957692cc7edd0b45ae3dc07223c8e92937bef84bc0eab862853349ec75546f58fb7c2775c38462c5010d846c185c15111e595522a6bcd16cf86f3d122109e3b1fdd943b6aec468a2d621a7c06c6a957c62b54dafc3be87567d677231395f6147293b68ceab7a9e0c58d864e8efde4e1b9a46cbe854713672f5caaae314ed9083dab4b099f8e300f01b8650f1f4b1d8fcf3f3cb53fb8e9eb2ea203bdc970f50ae55428a91f7f53ac266b28419c3778a15fd248d339ede785fb7f5a1aaa96d313eacc890936c173cdcd0fab882c45755feb3aed96d477ff96390bf9a66d1368b208e21f7c10d04a3dbd4e360633e5db4b602601c14cea737db3dcf722632cc77851cbdde2aaf0a33a07b373445df490cc8fc1e4160ff118378f11f0477de055a81a9eda57a4a2cfb0c83929d310912f729ec6cfa36c6ac6a75837143045d791cc85eff5b21932f23861bcf23a52b5da67eaf7baae0f5fb1369db78f3ac45f8c4ac5671d85735cdddb09d2b1e34a1fc066ff4a162cb263d6541274ae2fcc865f618abe27c124cd8b074ccd516301b91875824d09958f341ef274bdab0bae316339894304e35877b0c28a9b1fd166c796b9cc258a064a8f57e27f2a"
+            , "2f671343d9b2e1604dc9dcf0753e5fe15c7c64a0d283cbbf722d411a0e36f6ca1d01d1369a23539cd80f7c054b6e5daf9c962cad5b8ed5bd11998b40d5734442bed798f6e5c915bd8bb07e0188d0a55c1290074f1c287af06352299184492cbdec9acba737ee292e5adaa445547355e72a03a3bac3aac770fe5d6b66600ff15d37d5b4789994ea2aeb097f550aa5e88e4d8ff0ba07b88c1c88573063f5d96df820abc2abd177ab037f351c375e553af917132cf2f563c79a619e1bb76e8e2266b0c5617d695f2c496a25f4073b6840c1833757ebb386f16757a8e16a21e9355e9b248f3b33be672da700266be99b8f8725e8ab06075f0219e655ebc188976364b7db139390d34a6ea67b4b223229183a94cf455ece91fdaf5b9c707fa4b40ec39816c1120c7aaaf47920977be900e6b9ca4b8940e192b927c475bd58e836f512ae3e52924e36ff8e9b1d0251047770a5e465905622b1f159be121ab93819c5e5c6dae299ac73bf1c4ed4a1e2c7fa3caa1039b05e94c9f993d04feb272b6e00bb0276939cf746c42936831fc8f2b4cb0cf94808ae0af405ce4bc67d1e7acfc6fd6590d3de91f795df5aaf57e2cee1845a303d0ea564be3f1299acdce67efe0d62cfc6d6829ff4ecc0a05153c24696c4d34c076453827e796f3062f94f62f4528b7cfc870f0dcd615b7c97b95da4b9be5830e8b3f66cce71e0f622c771994443e2"
+            , "fffcaac0606c0edb7bc0d15f033accb68538159016e5ae8470bf9ebea89fa6c9fcc3e027d94f7f967b7246346bd9f6b8084e45a057b976847c4db03bf383c834054866f6a8282a497368c46e1852fc09e20f22c45607a27c8b2a4798ebefada54f8d3795b9f07606b1cd6e41f90d765480ef5c0d5790659cf1d210adfd412378b92e1dd9bd7fd95a1a66677fc6baa0e3a53c9031c1fb59cbad9f5dc5881a3c8e25c80ecb1abf0971488ada1f533dcbf8d37031335378574b8d3fad61159c9fae28caa543b3072ce308d369be340e78c6edc664cc6dde9b2f0a4ad2e60ce9c8b1e5722b8d5b73d0962b74fb9ed86307a180f53933339f9d56d3b345c2a0e98fcf5de7754f3845f6be30089f0e142ad4602f18abdc750bda7c91c3f32872e66640db46045ab4c276b379f1b834c2cbb1bd8601305649ec6b3bf20618695136dee6541492d1d985ea1fb765fd7a559e810eba30f2f710233ae5a411b94ddcaa01a08f1c31320d111c0714422cd5e987c9a76fc865de34003ab12664081be8017d23d977f2bf4ed9e3ce09ea3d64bb4ae8ebfa9d0721f57841008c297e2f455a0441a2bd618ca379dbd239a21e410defb4001b1e11f87e36bf894c222f76f12ddcc3771bbb17d5c0dfd86d89a3e13e084f6dc1c4762bcd393c1757db7afb1434221569e7ddaaffd6318253ec3df8cf5f826b81896d6474ee06a2e30ccc8c6a96bdd5"
+            ]
+        )
+    ,
+        ( "Blake2b 160"
+        , HashAlg (Blake2b :: Blake2b 160)
+        ,
+            [ "3345524abf6bbe1809449224b5972c41790b6cf2"
+            , "3c523ed102ab45a37d54f5610d5a983162fde84f"
+            , "a3d365b5fba5d36fbb19c03b7fde496058969c5a"
+            ]
+        )
+    ,
+        ( "Blake2b 224"
+        , HashAlg (Blake2b :: Blake2b 224)
+        ,
+            [ "836cc68931c2e4e3e838602eca1902591d216837bafddfe6f0c8cb07"
+            , "477c3985751dd4d1b8c93827ea5310b33bb02a26463a050dffd3e857"
+            , "a4a1b6851be66891a3deff406c4d7556879ebf952407450755f90eb6"
+            ]
+        )
+    ,
+        ( "Blake2b 256"
+        , HashAlg (Blake2b :: Blake2b 256)
+        ,
+            [ "0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8"
+            , "01718cec35cd3d796dd00020e0bfecb473ad23457d063b75eff29c0ffa2e58a9"
+            , "036c13096926b3dfccfe3f233bd1b2f583b818b8b15c01be65af69238e900b2c"
+            ]
+        )
+    ,
+        ( "Blake2b 384"
+        , HashAlg (Blake2b :: Blake2b 384)
+        ,
+            [ "b32811423377f52d7862286ee1a72ee540524380fda1724a6f25d7978c6fd3244a6caf0498812673c5e05ef583825100"
+            , "b7c81b228b6bd912930e8f0b5387989691c1cee1e65aade4da3b86a3c9f678fc8018f6ed9e2906720c8d2a3aeda9c03d"
+            , "927a1f297873cbe887a93b2183c4e2eba53966ba92c6db8b87029a1d8c673471d09740676cced79c5016838973f630c3"
+            ]
+        )
+    ,
+        ( "Blake2b 512"
+        , HashAlg (Blake2b :: Blake2b 512)
+        ,
+            [ "786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce"
+            , "a8add4bdddfd93e4877d2746e62817b116364a1fa7bc148d95090bc7333b3673f82401cf7aa2e4cb1ecd90296e3f14cb5413f8ed77be73045b13914cdcd6a918"
+            , "af438eea5d8cdb209336a7e85bf58090dc21b49d823f89a7d064c119f127bd361af9c7d109edda0f0e91bdce078d1d86b8e6f25727c98f6d3bb6f50acb2dd376"
+            ]
+        )
+    ,
+        ( "Blake2s 160"
+        , HashAlg (Blake2s :: Blake2s 160)
+        ,
+            [ "354c9c33f735962418bdacb9479873429c34916f"
+            , "5a604fec9713c369e84b0ed68daed7d7504ef240"
+            , "759bef6d041bcbd861b8b51baaece6c8fffd0acf"
+            ]
+        )
+    ,
+        ( "Blake2s 224"
+        , HashAlg (Blake2s :: Blake2s 224)
+        ,
+            [ "1fa1291e65248b37b3433475b2a0dd63d54a11ecc4e3e034e7bc1ef4"
+            , "e4e5cb6c7cae41982b397bf7b7d2d9d1949823ae78435326e8db4912"
+            , "e220025fd46a9a635c3f7f60bb96a84c01019ac0817f5901e7eeaa2c"
+            ]
+        )
+    ,
+        ( "Blake2s 256"
+        , HashAlg (Blake2s :: Blake2s 256)
+        ,
+            [ "69217a3079908094e11121d042354a7c1f55b6482ca1a51e1b250dfd1ed0eef9"
+            , "606beeec743ccbeff6cbcdf5d5302aa855c256c29b88c8ed331ea1a6bf3c8812"
+            , "94662583a600a12dff357c0a6f1b514a710ef0f587a38e8d2e4d7f67e9c81667"
+            ]
+        )
     ]
 
 runhash :: HashAlg -> ByteString -> ByteString
@@ -219,11 +430,12 @@
 
 runhashinc :: HashAlg -> [ByteString] -> ByteString
 runhashinc (HashAlg hashAlg) v = B.convertToBase B.Base16 $ hashinc $ v
-  where hashinc = hashFinalize . foldl hashUpdate (hashInitWith hashAlg)
+  where
+    hashinc = hashFinalize . foldl hashUpdate (hashInitWith hashAlg)
 
-data HashPrefixAlg = forall alg . HashAlgorithmPrefix alg => HashPrefixAlg alg
+data HashPrefixAlg = forall alg. HashAlgorithmPrefix alg => HashPrefixAlg alg
 
-expectedPrefix :: [ (String, HashPrefixAlg) ]
+expectedPrefix :: [(String, HashPrefixAlg)]
 expectedPrefix =
     [ ("MD5", HashPrefixAlg MD5)
     , ("SHA1", HashPrefixAlg SHA1)
@@ -242,12 +454,12 @@
 makeTestAlg (name, hashAlg, results) =
     testGroup name $ concatMap maketest (zip3 is vectors results)
   where
-        is :: [Int]
-        is = [1..]
+    is :: [Int]
+    is = [1 ..]
 
-        maketest (i, v, r) =
-            [ testCase (show i) (r @=? runhash hashAlg v)
-            ]
+    maketest (i, v, r) =
+        [ testCase (show i) (r @=? runhash hashAlg v)
+        ]
 
 makeTestChunk (hashName, hashAlg, _) =
     [ testProperty hashName $ \ckLen (ArbitraryBS0_2901 inp) ->
@@ -278,16 +490,20 @@
     hashEmpty _ = hash B.empty
 
     xof n = case someNatVal n of
-                Nothing          -> error ("invalid Nat: " ++ show n)
-                Just (SomeNat p) -> convert (hashEmpty p)
+        Nothing -> error ("invalid Nat: " ++ show n)
+        Just (SomeNat p) -> convert (hashEmpty p)
 
-tests = testGroup "hash"
-    [ testGroup "KATs" (map makeTestAlg expected)
-    , testGroup "Chunking" (concatMap makeTestChunk expected)
-    , testGroup "Prefix" (concatMap makeTestPrefix expectedPrefix)
-    , testGroup "Hybrid" (concatMap makeTestHybrid expectedPrefix)
-    , testGroup "Truncating"
-        [ testGroup "SHAKE128"
-            (zipWith makeTestSHAKE128Truncation [1..] shake128TruncationBytes)
+tests =
+    testGroup
+        "hash"
+        [ testGroup "KATs" (map makeTestAlg expected)
+        , testGroup "Chunking" (concatMap makeTestChunk expected)
+        , testGroup "Prefix" (concatMap makeTestPrefix expectedPrefix)
+        , testGroup "Hybrid" (concatMap makeTestHybrid expectedPrefix)
+        , testGroup
+            "Truncating"
+            [ testGroup
+                "SHAKE128"
+                (zipWith makeTestSHAKE128Truncation [1 ..] shake128TruncationBytes)
+            ]
         ]
-    ]
diff --git a/tests/Imports.hs b/tests/Imports.hs
--- a/tests/Imports.hs
+++ b/tests/Imports.hs
@@ -1,20 +1,22 @@
-module Imports
-    (
+module Imports (
     -- * Individual Types
-      Word16, Word32, Word64
-    , ByteString
+    Word16,
+    Word32,
+    Word64,
+    ByteString,
+
     -- * Modules
-    , module X
-    ) where
+    module X,
+) where
 
-import Data.Word (Word16, Word32, Word64)
 import Data.ByteString (ByteString)
+import Data.Word (Word16, Word32, Word64)
 
 import Control.Applicative as X
 import Control.Monad as X
+import Data.ByteString.Char8 as X ()
 import Data.Foldable as X (foldl')
 import Data.Monoid as X
-import Data.ByteString.Char8 as X ()
 
 import Test.Tasty as X
 import Test.Tasty.HUnit as X
diff --git a/tests/KAT_AES.hs b/tests/KAT_AES.hs
--- a/tests/KAT_AES.hs
+++ b/tests/KAT_AES.hs
@@ -1,19 +1,20 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_AES (tests) where
 
-import Imports
 import BlockCipher
-import Data.Maybe
-import Crypto.Cipher.Types
 import qualified Crypto.Cipher.AES as AES
+import Crypto.Cipher.Types
 import qualified Data.ByteString as B
+import Data.Maybe
+import Imports
 
-import qualified KAT_AES.KATECB as KATECB
 import qualified KAT_AES.KATCBC as KATCBC
-import qualified KAT_AES.KATXTS as KATXTS
-import qualified KAT_AES.KATGCM as KATGCM
 import qualified KAT_AES.KATCCM as KATCCM
+import qualified KAT_AES.KATECB as KATECB
+import qualified KAT_AES.KATGCM as KATGCM
 import qualified KAT_AES.KATOCB3 as KATOCB3
+import qualified KAT_AES.KATXTS as KATXTS
 
 {-
 instance Show AES.AES where
@@ -24,75 +25,105 @@
     arbitrary = AES.initAES . B.pack <$> replicateM 16 arbitrary
 -}
 
-toKatECB (k,p,c) = KAT_ECB { ecbKey = k, ecbPlaintext = p, ecbCiphertext = c }
-toKatCBC (k,iv,p,c) = KAT_CBC { cbcKey = k, cbcIV = iv, cbcPlaintext = p, cbcCiphertext = c }
-toKatXTS (k1,k2,iv,p,_,c) = KAT_XTS { xtsKey1 = k1, xtsKey2 = k2, xtsIV = iv, xtsPlaintext = p, xtsCiphertext = c }
-toKatAEAD mode (k,iv,h,p,c,taglen,tag) =
-    KAT_AEAD { aeadMode       = mode
-             , aeadKey        = k
-             , aeadIV         = iv
-             , aeadHeader     = h
-             , aeadPlaintext  = p
-             , aeadCiphertext = c
-             , aeadTaglen     = taglen
-             , aeadTag        = tag
-             }
+toKatECB (k, p, c) = KAT_ECB{ecbKey = k, ecbPlaintext = p, ecbCiphertext = c}
+toKatCBC (k, iv, p, c) = KAT_CBC{cbcKey = k, cbcIV = iv, cbcPlaintext = p, cbcCiphertext = c}
+toKatXTS (k1, k2, iv, p, _, c) =
+    KAT_XTS
+        { xtsKey1 = k1
+        , xtsKey2 = k2
+        , xtsIV = iv
+        , xtsPlaintext = p
+        , xtsCiphertext = c
+        }
+toKatAEAD mode (k, iv, h, p, c, taglen, tag) =
+    KAT_AEAD
+        { aeadMode = mode
+        , aeadKey = k
+        , aeadIV = iv
+        , aeadHeader = h
+        , aeadPlaintext = p
+        , aeadCiphertext = c
+        , aeadTaglen = taglen
+        , aeadTag = tag
+        }
 toKatGCM = toKatAEAD AEAD_GCM
 toKatOCB = toKatAEAD AEAD_OCB
 
-toKatCCM (k,iv,h,i,o,m) =
-  KAT_AEAD { aeadMode = AEAD_CCM (B.length i) (ccmMVal m) CCM_L2
-           , aeadKey  = k
-           , aeadIV   = iv
-           , aeadHeader = h
-           , aeadPlaintext = i
-           , aeadCiphertext = ct
-           , aeadTaglen = m
-           , aeadTag = at
-           }
-  where ccmMVal x = fromMaybe (error $ "unsupported CCM tag length: " ++ show x) $
-                        lookup x [ (4, CCM_M4), (6, CCM_M6), (8, CCM_M8), (10, CCM_M10)
-                                 , (12, CCM_M12), (14, CCM_M14), (16, CCM_M16)
-                                 ]
-        ctWithTag = B.drop (B.length h) o
-        (ct, at)  = B.splitAt (B.length ctWithTag - m) ctWithTag
+toKatCCM (k, iv, h, i, o, m) =
+    KAT_AEAD
+        { aeadMode = AEAD_CCM (B.length i) (ccmMVal m) CCM_L2
+        , aeadKey = k
+        , aeadIV = iv
+        , aeadHeader = h
+        , aeadPlaintext = i
+        , aeadCiphertext = ct
+        , aeadTaglen = m
+        , aeadTag = at
+        }
+  where
+    ccmMVal x =
+        fromMaybe (error $ "unsupported CCM tag length: " ++ show x) $
+            lookup
+                x
+                [ (4, CCM_M4)
+                , (6, CCM_M6)
+                , (8, CCM_M8)
+                , (10, CCM_M10)
+                , (12, CCM_M12)
+                , (14, CCM_M14)
+                , (16, CCM_M16)
+                ]
+    ctWithTag = B.drop (B.length h) o
+    (ct, at) = B.splitAt (B.length ctWithTag - m) ctWithTag
 
-kats128 = defaultKATs
-    { kat_ECB  = map toKatECB KATECB.vectors_aes128_enc
-    , kat_CBC  = map toKatCBC KATCBC.vectors_aes128_enc
-    , kat_CFB  = [ KAT_CFB { cfbKey        = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c"
-                           , cfbIV         = "\xC8\xA6\x45\x37\xA0\xB3\xA9\x3F\xCD\xE3\xCD\xAD\x9F\x1C\xE5\x8B"
-                           , cfbPlaintext  = "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
-                           , cfbCiphertext = "\x26\x75\x1f\x67\xa3\xcb\xb1\x40\xb1\x80\x8c\xf1\x87\xa4\xf4\xdf"
-                           }
-                 ]
-    , kat_XTS  = map toKatXTS KATXTS.vectors_aes128_enc
-    , kat_AEAD = map toKatGCM KATGCM.vectors_aes128_enc ++
-                 map toKatOCB KATOCB3.vectors_aes128_enc ++
-                 map toKatCCM KATCCM.vectors_aes128_enc
-    }
+kats128 =
+    defaultKATs
+        { kat_ECB = map toKatECB KATECB.vectors_aes128_enc
+        , kat_CBC = map toKatCBC KATCBC.vectors_aes128_enc
+        , kat_CFB =
+            [ KAT_CFB
+                { cfbKey =
+                    "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c"
+                , cfbIV =
+                    "\xC8\xA6\x45\x37\xA0\xB3\xA9\x3F\xCD\xE3\xCD\xAD\x9F\x1C\xE5\x8B"
+                , cfbPlaintext =
+                    "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+                , cfbCiphertext =
+                    "\x26\x75\x1f\x67\xa3\xcb\xb1\x40\xb1\x80\x8c\xf1\x87\xa4\xf4\xdf"
+                }
+            ]
+        , kat_XTS = map toKatXTS KATXTS.vectors_aes128_enc
+        , kat_AEAD =
+            map toKatGCM KATGCM.vectors_aes128_enc
+                ++ map toKatOCB KATOCB3.vectors_aes128_enc
+                ++ map toKatCCM KATCCM.vectors_aes128_enc
+        }
 
-kats192 = defaultKATs
-    { kat_ECB  = map toKatECB KATECB.vectors_aes192_enc
-    , kat_CBC  = map toKatCBC KATCBC.vectors_aes192_enc
-    }
+kats192 =
+    defaultKATs
+        { kat_ECB = map toKatECB KATECB.vectors_aes192_enc
+        , kat_CBC = map toKatCBC KATCBC.vectors_aes192_enc
+        }
 
-kats256 = defaultKATs
-    { kat_ECB  = map toKatECB KATECB.vectors_aes256_enc
-    , kat_CBC  = map toKatCBC KATCBC.vectors_aes256_enc
-    , kat_XTS  = map toKatXTS KATXTS.vectors_aes256_enc
-    , kat_AEAD = map toKatGCM KATGCM.vectors_aes256_enc
-    }
+kats256 =
+    defaultKATs
+        { kat_ECB = map toKatECB KATECB.vectors_aes256_enc
+        , kat_CBC = map toKatCBC KATCBC.vectors_aes256_enc
+        , kat_XTS = map toKatXTS KATXTS.vectors_aes256_enc
+        , kat_AEAD = map toKatGCM KATGCM.vectors_aes256_enc
+        }
 
-tests = testGroup "AES"
-    [ testBlockCipher kats128 (undefined :: AES.AES128)
-    , testBlockCipher kats192 (undefined :: AES.AES192)
-    , testBlockCipher kats256 (undefined :: AES.AES256)
-{-
-    , testProperty "genCtr" $ \(key, iv1) ->
-        let (bs1, iv2)    = AES.genCounter key iv1 32
-            (bs2, iv3)    = AES.genCounter key iv2 32
-            (bsAll, iv3') = AES.genCounter key iv1 64
-         in (B.concat [bs1,bs2] == bsAll && iv3 == iv3')
--}
-    ]
+tests =
+    testGroup
+        "AES"
+        [ testBlockCipher kats128 (undefined :: AES.AES128)
+        , testBlockCipher kats192 (undefined :: AES.AES192)
+        , testBlockCipher kats256 (undefined :: AES.AES256)
+        {-
+            , testProperty "genCtr" $ \(key, iv1) ->
+                let (bs1, iv2)    = AES.genCounter key iv1 32
+                    (bs2, iv3)    = AES.genCounter key iv2 32
+                    (bsAll, iv3') = AES.genCounter key iv1 64
+                 in (B.concat [bs1,bs2] == bsAll && iv3 == iv3')
+        -}
+        ]
diff --git a/tests/KAT_AES/KATCBC.hs b/tests/KAT_AES/KATCBC.hs
--- a/tests/KAT_AES/KATCBC.hs
+++ b/tests/KAT_AES/KATCBC.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_AES.KATCBC where
 
 import qualified Data.ByteString as B
@@ -6,102 +7,454 @@
 
 type KATCBC = (B.ByteString, B.ByteString, B.ByteString, B.ByteString)
 
-vectors_aes128_enc, vectors_aes128_dec
-                  , vectors_aes192_enc, vectors_aes192_dec
-                  , vectors_aes256_enc, vectors_aes256_dec :: [KATCBC]
+vectors_aes128_enc
+    , vectors_aes128_dec
+    , vectors_aes192_enc
+    , vectors_aes192_dec
+    , vectors_aes256_enc
+    , vectors_aes256_dec
+        :: [KATCBC]
 vectors_aes128_enc =
     [
-        ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x66\xe9\x4b\xd4\xef\x8a\x2c\x3b\x88\x4c\xfa\x59\xca\x34\x2b\x2e")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xb6\xae\xaf\xfa\x75\x2d\xc0\x8b\x51\x63\x97\x31\x76\x1a\xed\x00")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xcb\x64\xcf\x3f\x42\x2a\xe8\x4b\xb9\x0e\x3a\xb4\xdb\xa7\xbd\x86")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xe5\xb5\x07\x7f\x93\x46\x46\x2c\x62\xa0\x75\xc0\xc7\x08\xee\x96")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xe1\x4d\x5d\x0e\xe2\x77\x15\xdf\x08\xb4\x15\x2b\xa2\x3d\xa8\xe0")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x5e\x77\xe5\x9f\x8f\x85\x94\x34\x89\xa2\x41\x49\xc7\x5f\x4e\xc9")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x8f\x42\xc2\x4b\xee\x6e\x63\x47\x2b\x16\x5a\xa9\x41\x31\x2f\x7c")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xb0\xea\x4a\xc0\xd2\x5c\xcd\x7c\x82\xcb\x8a\x30\x68\xc6\xfe\x2e")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\xe1\x4d\x5d\x0e\xe2\x77\x15\xdf\x08\xb4\x15\x2b\xa2\x3d\xa8\xe0")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x17\xd6\x14\xf3\x79\xa9\x35\x90\x77\xe9\x55\x77\xfd\x31\xc2\x0a")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x8f\x42\xc2\x4b\xee\x6e\x63\x47\x2b\x16\x5a\xa9\x41\x31\x2f\x7c")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\xe5\xb5\x07\x7f\x93\x46\x46\x2c\x62\xa0\x75\xc0\xc7\x08\xee\x96")
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x66\xe9\x4b\xd4\xef\x8a\x2c\x3b\x88\x4c\xfa\x59\xca\x34\x2b\x2e"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xb6\xae\xaf\xfa\x75\x2d\xc0\x8b\x51\x63\x97\x31\x76\x1a\xed\x00"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xcb\x64\xcf\x3f\x42\x2a\xe8\x4b\xb9\x0e\x3a\xb4\xdb\xa7\xbd\x86"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xe5\xb5\x07\x7f\x93\x46\x46\x2c\x62\xa0\x75\xc0\xc7\x08\xee\x96"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xe1\x4d\x5d\x0e\xe2\x77\x15\xdf\x08\xb4\x15\x2b\xa2\x3d\xa8\xe0"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x5e\x77\xe5\x9f\x8f\x85\x94\x34\x89\xa2\x41\x49\xc7\x5f\x4e\xc9"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x8f\x42\xc2\x4b\xee\x6e\x63\x47\x2b\x16\x5a\xa9\x41\x31\x2f\x7c"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xb0\xea\x4a\xc0\xd2\x5c\xcd\x7c\x82\xcb\x8a\x30\x68\xc6\xfe\x2e"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\xe1\x4d\x5d\x0e\xe2\x77\x15\xdf\x08\xb4\x15\x2b\xa2\x3d\xa8\xe0"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x17\xd6\x14\xf3\x79\xa9\x35\x90\x77\xe9\x55\x77\xfd\x31\xc2\x0a"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x8f\x42\xc2\x4b\xee\x6e\x63\x47\x2b\x16\x5a\xa9\x41\x31\x2f\x7c"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\xe5\xb5\x07\x7f\x93\x46\x46\x2c\x62\xa0\x75\xc0\xc7\x08\xee\x96"
+        )
     ]
-
 vectors_aes192_enc =
     [
-        ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xaa\xe0\x69\x92\xac\xbf\x52\xa3\xe8\xf4\xa9\x6e\xc9\x30\x0b\xd7")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x5f\x88\xef\x3f\xbd\xeb\xf2\xe4\xe2\x66\x65\x12\xd3\xbc\xb7\x0f")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xdb\x42\xf5\x1c\xd2\x0e\xca\xd2\x9e\xb0\x13\x2b\x0f\xaa\x4b\x85")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xda\xb4\x01\x5f\x98\x70\x25\xeb\xb8\xa8\x5f\x3c\x7f\x73\x70\x19")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xcf\x1e\xce\x3c\x44\xb0\x78\xfb\x27\xcb\x0a\x3e\x07\x1b\x08\x20")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x98\xb8\x95\xa1\x45\xca\x4e\x0b\xf8\x3e\x69\x32\x81\xc1\xa0\x97")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xf2\xf0\xae\xd8\xcd\xc9\x21\xca\x4b\x55\x84\x5d\xa4\x15\x21\xc2")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x5e\xea\x4b\x13\xdd\xd9\x17\x12\xb0\x14\xe2\x82\x2d\x18\x76\xfb")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\xcf\x1e\xce\x3c\x44\xb0\x78\xfb\x27\xcb\x0a\x3e\x07\x1b\x08\x20")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\xeb\x8c\x17\x30\x90\xc7\x5b\x77\xd6\x72\xb4\x57\xa7\x78\xd9\xd0")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\xf2\xf0\xae\xd8\xcd\xc9\x21\xca\x4b\x55\x84\x5d\xa4\x15\x21\xc2")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\xda\xb4\x01\x5f\x98\x70\x25\xeb\xb8\xa8\x5f\x3c\x7f\x73\x70\x19")
-
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xaa\xe0\x69\x92\xac\xbf\x52\xa3\xe8\xf4\xa9\x6e\xc9\x30\x0b\xd7"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x5f\x88\xef\x3f\xbd\xeb\xf2\xe4\xe2\x66\x65\x12\xd3\xbc\xb7\x0f"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xdb\x42\xf5\x1c\xd2\x0e\xca\xd2\x9e\xb0\x13\x2b\x0f\xaa\x4b\x85"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xda\xb4\x01\x5f\x98\x70\x25\xeb\xb8\xa8\x5f\x3c\x7f\x73\x70\x19"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xcf\x1e\xce\x3c\x44\xb0\x78\xfb\x27\xcb\x0a\x3e\x07\x1b\x08\x20"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x98\xb8\x95\xa1\x45\xca\x4e\x0b\xf8\x3e\x69\x32\x81\xc1\xa0\x97"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xf2\xf0\xae\xd8\xcd\xc9\x21\xca\x4b\x55\x84\x5d\xa4\x15\x21\xc2"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x5e\xea\x4b\x13\xdd\xd9\x17\x12\xb0\x14\xe2\x82\x2d\x18\x76\xfb"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\xcf\x1e\xce\x3c\x44\xb0\x78\xfb\x27\xcb\x0a\x3e\x07\x1b\x08\x20"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\xeb\x8c\x17\x30\x90\xc7\x5b\x77\xd6\x72\xb4\x57\xa7\x78\xd9\xd0"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\xf2\xf0\xae\xd8\xcd\xc9\x21\xca\x4b\x55\x84\x5d\xa4\x15\x21\xc2"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\xda\xb4\x01\x5f\x98\x70\x25\xeb\xb8\xa8\x5f\x3c\x7f\x73\x70\x19"
+        )
     ]
-
 vectors_aes256_enc =
     [
-        ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xdc\x95\xc0\x78\xa2\x40\x89\x89\xad\x48\xa2\x14\x92\x84\x20\x87")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x72\x98\xca\xa5\x65\x03\x1e\xad\xc6\xce\x23\xd2\x3e\xa6\x63\x78")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xf4\x35\xa1\x11\xa3\xe4\xa1\x94\x49\x19\xf9\x12\xc5\xa2\x41\xde")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x91\xc0\x87\x62\x87\x6d\xcc\xf9\xba\x20\x4a\x33\x76\x8f\xa5\xfe")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x7b\xc3\x02\x6c\xd7\x37\x10\x3e\x62\x90\x2b\xcd\x18\xfb\x01\x63")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x9c\xac\x94\xc6\xb4\x85\x61\xf8\xff\xaa\xa7\x86\x16\xba\x48\x92")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\xf9\xc7\x44\x4b\xb0\xcc\x80\x6c\x7c\x39\xee\x22\x11\xf1\x46")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x6d\xed\xd0\xa3\xe6\x94\xa0\xde\x65\x1d\x68\xa6\xb5\x5a\x64\xa2")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x7b\xc3\x02\x6c\xd7\x37\x10\x3e\x62\x90\x2b\xcd\x18\xfb\x01\x63")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x62\xae\x12\xf3\x24\xbf\xea\x08\xd5\xf6\x75\xb5\x13\x02\x6b\xbf")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x00\xf9\xc7\x44\x4b\xb0\xcc\x80\x6c\x7c\x39\xee\x22\x11\xf1\x46")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x91\xc0\x87\x62\x87\x6d\xcc\xf9\xba\x20\x4a\x33\x76\x8f\xa5\xfe")
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xdc\x95\xc0\x78\xa2\x40\x89\x89\xad\x48\xa2\x14\x92\x84\x20\x87"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x72\x98\xca\xa5\x65\x03\x1e\xad\xc6\xce\x23\xd2\x3e\xa6\x63\x78"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xf4\x35\xa1\x11\xa3\xe4\xa1\x94\x49\x19\xf9\x12\xc5\xa2\x41\xde"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x91\xc0\x87\x62\x87\x6d\xcc\xf9\xba\x20\x4a\x33\x76\x8f\xa5\xfe"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x7b\xc3\x02\x6c\xd7\x37\x10\x3e\x62\x90\x2b\xcd\x18\xfb\x01\x63"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x9c\xac\x94\xc6\xb4\x85\x61\xf8\xff\xaa\xa7\x86\x16\xba\x48\x92"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\xf9\xc7\x44\x4b\xb0\xcc\x80\x6c\x7c\x39\xee\x22\x11\xf1\x46"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x6d\xed\xd0\xa3\xe6\x94\xa0\xde\x65\x1d\x68\xa6\xb5\x5a\x64\xa2"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x7b\xc3\x02\x6c\xd7\x37\x10\x3e\x62\x90\x2b\xcd\x18\xfb\x01\x63"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x62\xae\x12\xf3\x24\xbf\xea\x08\xd5\xf6\x75\xb5\x13\x02\x6b\xbf"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x00\xf9\xc7\x44\x4b\xb0\xcc\x80\x6c\x7c\x39\xee\x22\x11\xf1\x46"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x91\xc0\x87\x62\x87\x6d\xcc\xf9\xba\x20\x4a\x33\x76\x8f\xa5\xfe"
+        )
     ]
-
 vectors_aes128_dec =
     [
-        ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x14\x0f\x0f\x10\x11\xb5\x22\x3d\x79\x58\x77\x17\xff\xd9\xec\x3a")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x33\x08\x32\x40\xd6\x5c\xbc\x72\xaa\x0b\x44\xf3\xe1\x9e\xa9\x5a")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x65\x0a\x42\xa0\x3c\x4b\x93\xa4\xb7\x43\xdc\x9e\x9c\xf4\xc0\x9b")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x80\xcd\x20\xe1\xbd\x89\x3c\x5e\xe4\x20\x76\x85\xb0\x9a\x0e\x3e")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x15\x0e\x0e\x11\x10\xb4\x23\x3c\x78\x59\x76\x16\xfe\xd8\xed\x3b")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x32\x09\x33\x41\xd7\x5d\xbd\x73\xab\x0a\x45\xf2\xe0\x9f\xa8\x5b")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x64\x0b\x43\xa1\x3d\x4a\x92\xa5\xb6\x42\xdd\x9f\x9d\xf5\xc1\x9a")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x81\xcc\x21\xe0\xbc\x88\x3d\x5f\xe5\x21\x77\x84\xb1\x9b\x0f\x3f")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\xf5\x06\x41\x7e\x6a\x8f\xbc\x32\xdd\xa5\x52\x73\xbf\x9f\x4d\x5c")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\xbf\x6d\x28\xac\x20\xc9\x1d\x65\xa9\xd4\xb0\x96\xc2\xd5\xa5\x09")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x5f\x2a\x46\xab\x8d\xb9\x5b\x22\x15\xfe\x1a\xa4\xdd\x69\x59\x26")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x71\x9b\x21\xb5\x39\x7c\x2f\x16\x7c\x8b\x45\x22\xb5\x20\xec\x2e")
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x14\x0f\x0f\x10\x11\xb5\x22\x3d\x79\x58\x77\x17\xff\xd9\xec\x3a"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x33\x08\x32\x40\xd6\x5c\xbc\x72\xaa\x0b\x44\xf3\xe1\x9e\xa9\x5a"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x65\x0a\x42\xa0\x3c\x4b\x93\xa4\xb7\x43\xdc\x9e\x9c\xf4\xc0\x9b"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x80\xcd\x20\xe1\xbd\x89\x3c\x5e\xe4\x20\x76\x85\xb0\x9a\x0e\x3e"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x15\x0e\x0e\x11\x10\xb4\x23\x3c\x78\x59\x76\x16\xfe\xd8\xed\x3b"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x32\x09\x33\x41\xd7\x5d\xbd\x73\xab\x0a\x45\xf2\xe0\x9f\xa8\x5b"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x64\x0b\x43\xa1\x3d\x4a\x92\xa5\xb6\x42\xdd\x9f\x9d\xf5\xc1\x9a"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x81\xcc\x21\xe0\xbc\x88\x3d\x5f\xe5\x21\x77\x84\xb1\x9b\x0f\x3f"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\xf5\x06\x41\x7e\x6a\x8f\xbc\x32\xdd\xa5\x52\x73\xbf\x9f\x4d\x5c"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\xbf\x6d\x28\xac\x20\xc9\x1d\x65\xa9\xd4\xb0\x96\xc2\xd5\xa5\x09"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x5f\x2a\x46\xab\x8d\xb9\x5b\x22\x15\xfe\x1a\xa4\xdd\x69\x59\x26"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x71\x9b\x21\xb5\x39\x7c\x2f\x16\x7c\x8b\x45\x22\xb5\x20\xec\x2e"
+        )
     ]
-
 vectors_aes192_dec =
     [
-        ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x13\x46\x0e\x87\xa8\xfc\x02\x3e\xf2\x50\x1a\xfe\x7f\xf5\x1c\x51")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x91\x75\x27\xfc\xd4\xa0\x6f\x32\x27\x29\x90\x14\xca\xde\xd4\x1a")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x29\x64\x80\xb6\xa5\xd6\xcf\xb3\x78\x3f\x21\x6b\x80\x31\x3d\xb3")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xbc\xa5\x06\x07\xd0\x67\x30\x85\x2d\x3a\x50\x4b\x68\x0a\x19\xcc")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x12\x47\x0f\x86\xa9\xfd\x03\x3f\xf3\x51\x1b\xff\x7e\xf4\x1d\x50")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x90\x74\x26\xfd\xd5\xa1\x6e\x33\x26\x28\x91\x15\xcb\xdf\xd5\x1b")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x28\x65\x81\xb7\xa4\xd7\xce\xb2\x79\x3e\x20\x6a\x81\x30\x3c\xb2")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xbd\xa4\x07\x06\xd1\x66\x31\x84\x2c\x3b\x51\x4a\x69\x0b\x18\xcd")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x38\xf9\xf9\xd1\x7e\x2c\x82\xaf\xdc\xed\x68\x03\xb6\x31\x46\x3e")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x35\x4e\xc1\x01\x0f\x17\x50\x5e\x63\x37\x40\x4b\x9a\xf2\xc0\x5c")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\xa7\x7c\xc9\xd1\x4f\x44\xf7\xf7\xcc\x45\x80\x83\x19\xb7\xa4\x71")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\xf9\x1d\xb1\x13\x0b\xd1\xc0\x66\x9f\xfa\xc2\x0e\xbe\xdd\xcb\xca")
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x13\x46\x0e\x87\xa8\xfc\x02\x3e\xf2\x50\x1a\xfe\x7f\xf5\x1c\x51"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x91\x75\x27\xfc\xd4\xa0\x6f\x32\x27\x29\x90\x14\xca\xde\xd4\x1a"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x29\x64\x80\xb6\xa5\xd6\xcf\xb3\x78\x3f\x21\x6b\x80\x31\x3d\xb3"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xbc\xa5\x06\x07\xd0\x67\x30\x85\x2d\x3a\x50\x4b\x68\x0a\x19\xcc"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x12\x47\x0f\x86\xa9\xfd\x03\x3f\xf3\x51\x1b\xff\x7e\xf4\x1d\x50"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x90\x74\x26\xfd\xd5\xa1\x6e\x33\x26\x28\x91\x15\xcb\xdf\xd5\x1b"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x28\x65\x81\xb7\xa4\xd7\xce\xb2\x79\x3e\x20\x6a\x81\x30\x3c\xb2"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xbd\xa4\x07\x06\xd1\x66\x31\x84\x2c\x3b\x51\x4a\x69\x0b\x18\xcd"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x38\xf9\xf9\xd1\x7e\x2c\x82\xaf\xdc\xed\x68\x03\xb6\x31\x46\x3e"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x35\x4e\xc1\x01\x0f\x17\x50\x5e\x63\x37\x40\x4b\x9a\xf2\xc0\x5c"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\xa7\x7c\xc9\xd1\x4f\x44\xf7\xf7\xcc\x45\x80\x83\x19\xb7\xa4\x71"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\xf9\x1d\xb1\x13\x0b\xd1\xc0\x66\x9f\xfa\xc2\x0e\xbe\xdd\xcb\xca"
+        )
     ]
-
 vectors_aes256_dec =
     [
-        ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x67\x67\x1c\xe1\xfa\x91\xdd\xeb\x0f\x8f\xbb\xb3\x66\xb5\x31\xb4")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x7b\xd3\xfb\x90\x65\x56\x9f\x39\x8b\x09\xcb\x93\x4b\x1e\x01\x23")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xda\xa8\xbf\x5c\xde\x2e\x52\x45\x5f\xa3\xb3\xfe\x33\x32\x47\xca")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x83\x24\xdc\xb4\x30\x12\x73\x6c\xed\x58\xab\x8f\x4b\x05\xca\x0b")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x66\x66\x1d\xe0\xfb\x90\xdc\xea\x0e\x8e\xba\xb2\x67\xb4\x30\xb5")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x7a\xd2\xfa\x91\x64\x57\x9e\x38\x8a\x08\xca\x92\x4a\x1f\x00\x22")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\xdb\xa9\xbe\x5d\xdf\x2f\x53\x44\x5e\xa2\xb2\xff\x32\x33\x46\xcb")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x82\x25\xdd\xb5\x31\x13\x72\x6d\xec\x59\xaa\x8e\x4a\x04\xcb\x0a")
-        , ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x68\xe9\x07\x16\xe3\x66\x1b\x1d\xb1\x89\x74\xb0\x9c\x46\x47\xe4")
-        , ("\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01","\x7f\xb9\xeb\xa4\xd3\x5f\x70\x40\xab\x52\xec\xd2\x3b\x48\xb7\x6e")
-        , ("\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02","\x6c\x58\x0f\x41\x82\x36\xbc\xff\x64\x1d\xac\xa7\x3e\x34\x11\x18")
-        , ("\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03","\x3f\x62\xd6\x8c\xb1\xf7\x62\x28\xa4\xc3\x82\x4f\x8b\x24\xe7\x4b")
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x67\x67\x1c\xe1\xfa\x91\xdd\xeb\x0f\x8f\xbb\xb3\x66\xb5\x31\xb4"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x7b\xd3\xfb\x90\x65\x56\x9f\x39\x8b\x09\xcb\x93\x4b\x1e\x01\x23"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xda\xa8\xbf\x5c\xde\x2e\x52\x45\x5f\xa3\xb3\xfe\x33\x32\x47\xca"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x83\x24\xdc\xb4\x30\x12\x73\x6c\xed\x58\xab\x8f\x4b\x05\xca\x0b"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x66\x66\x1d\xe0\xfb\x90\xdc\xea\x0e\x8e\xba\xb2\x67\xb4\x30\xb5"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x7a\xd2\xfa\x91\x64\x57\x9e\x38\x8a\x08\xca\x92\x4a\x1f\x00\x22"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\xdb\xa9\xbe\x5d\xdf\x2f\x53\x44\x5e\xa2\xb2\xff\x32\x33\x46\xcb"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x82\x25\xdd\xb5\x31\x13\x72\x6d\xec\x59\xaa\x8e\x4a\x04\xcb\x0a"
+        )
+    ,
+        ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x68\xe9\x07\x16\xe3\x66\x1b\x1d\xb1\x89\x74\xb0\x9c\x46\x47\xe4"
+        )
+    ,
+        ( "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , "\x7f\xb9\xeb\xa4\xd3\x5f\x70\x40\xab\x52\xec\xd2\x3b\x48\xb7\x6e"
+        )
+    ,
+        ( "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x6c\x58\x0f\x41\x82\x36\xbc\xff\x64\x1d\xac\xa7\x3e\x34\x11\x18"
+        )
+    ,
+        ( "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+        , "\x3f\x62\xd6\x8c\xb1\xf7\x62\x28\xa4\xc3\x82\x4f\x8b\x24\xe7\x4b"
+        )
     ]
diff --git a/tests/KAT_AES/KATCCM.hs b/tests/KAT_AES/KATCCM.hs
--- a/tests/KAT_AES/KATCCM.hs
+++ b/tests/KAT_AES/KATCCM.hs
@@ -1,155 +1,205 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_AES.KATCCM where
 
 import qualified Data.ByteString as B
 
 -- (key, iv, header, in, out+atag, taglen)
-type KATCCM = (B.ByteString, B.ByteString, B.ByteString, B.ByteString, B.ByteString, Int)
+type KATCCM =
+    (B.ByteString, B.ByteString, B.ByteString, B.ByteString, B.ByteString, Int)
 
 vectors_aes128_enc :: [KATCCM]
 vectors_aes128_enc =
-  [ ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x03\x02\x01\x00\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
-    , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x58\x8c\x97\x9a\x61\xc6\x63\xd2\xf0\x66\xd0\xc2\xc0\xf9\x89\x80\x6d\x5f\x6b\x61\xda\xc3\x84\x17\xe8\xd1\x2c\xfd\xf9\x26\xe0"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x04\x03\x02\x01\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
-    , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x72\xc9\x1a\x36\xe1\x35\xf8\xcf\x29\x1c\xa8\x94\x08\x5c\x87\xe3\xcc\x15\xc4\x39\xc9\xe4\x3a\x3b\xa0\x91\xd5\x6e\x10\x40\x09\x16"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x05\x04\x03\x02\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
-    , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x51\xb1\xe5\xf4\x4a\x19\x7d\x1d\xa4\x6b\x0f\x8e\x2d\x28\x2a\xe8\x71\xe8\x38\xbb\x64\xda\x85\x96\x57\x4a\xda\xa7\x6f\xbd\x9f\xb0\xc5"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x06\x05\x04\x03\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
-    , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\xa2\x8c\x68\x65\x93\x9a\x9a\x79\xfa\xaa\x5c\x4c\x2a\x9d\x4a\x91\xcd\xac\x8c\x96\xc8\x61\xb9\xc9\xe6\x1e\xf1"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x07\x06\x05\x04\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
-    , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb\x9d\x4e\x13\x12\x53\x65\x8a\xd8\x6e\xbd\xca\x3e\x51\xe8\x3f\x07\x7d\x9c\x2d\x93"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x08\x07\x06\x05\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
-    , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x6f\xc1\xb0\x11\xf0\x06\x56\x8b\x51\x71\xa4\x2d\x95\x3d\x46\x9b\x25\x70\xa4\xbd\x87\x40\x5a\x04\x43\xac\x91\xcb\x94"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x09\x08\x07\x06\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
-    , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x01\x35\xd1\xb2\xc9\x5f\x41\xd5\xd1\xd4\xfe\xc1\x85\xd1\x66\xb8\x09\x4e\x99\x9d\xfe\xd9\x6c\x04\x8c\x56\x60\x2c\x97\xac\xbb\x74\x90"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x0a\x09\x08\x07\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
-    , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x7b\x75\x39\x9a\xc0\x83\x1d\xd2\xf0\xbb\xd7\x58\x79\xa2\xfd\x8f\x6c\xae\x6b\x6c\xd9\xb7\xdb\x24\xc1\x7b\x44\x33\xf4\x34\x96\x3f\x34\xb4"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x0b\x0a\x09\x08\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
-    , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x82\x53\x1a\x60\xcc\x24\x94\x5a\x4b\x82\x79\x18\x1a\xb5\xc8\x4d\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1\x97\xea\x9c\x07\xe5\x6b\x5e\xb1\x7e\x5f\x4e"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x0c\x0b\x0a\x09\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
-    , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x07\x34\x25\x94\x15\x77\x85\x15\x2b\x07\x40\x98\x33\x0a\xbb\x14\x1b\x94\x7b\x56\x6a\xa9\x40\x6b\x4d\x99\x99\x88\xdd"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x0d\x0c\x0b\x0a\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
-    , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x67\x6b\xb2\x03\x80\xb0\xe3\x01\xe8\xab\x79\x59\x0a\x39\x6d\xa7\x8b\x83\x49\x34\xf5\x3a\xa2\xe9\x10\x7a\x8b\x6c\x02\x2c"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
-    , {- iv  = -} "\x00\x00\x00\x0e\x0d\x0c\x0b\xa0\xa1\xa2\xa3\xa4\xa5"
-    , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
-    , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
-    , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\xc0\xff\xa0\xd6\xf0\x5b\xdb\x67\xf2\x4d\x43\xa4\x33\x8d\x2a\xa4\xbe\xd7\xb2\x0e\x43\xcd\x1a\xa3\x16\x62\xe7\xad\x65\xd6\xdb"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x41\x2b\x4e\xa9\xcd\xbe\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\x0b\xe1\xa8\x8b\xac\xe0\x18\xb1"
-    , {- in  = -} "\x08\xe8\xcf\x97\xd8\x20\xea\x25\x84\x60\xe9\x6a\xd9\xcf\x52\x89\x05\x4d\x89\x5c\xea\xc4\x7c"
-    , {- out = -} "\x0b\xe1\xa8\x8b\xac\xe0\x18\xb1\x4c\xb9\x7f\x86\xa2\xa4\x68\x9a\x87\x79\x47\xab\x80\x91\xef\x53\x86\xa6\xff\xbd\xd0\x80\xf8\xe7\x8c\xf7\xcb\x0c\xdd\xd7\xb3"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x33\x56\x8e\xf7\xb2\x63\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb"
-    , {- in  = -} "\x90\x20\xea\x6f\x91\xbd\xd8\x5a\xfa\x00\x39\xba\x4b\xaf\xf9\xbf\xb7\x9c\x70\x28\x94\x9c\xd0\xec"
-    , {- out = -} "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa\xa0\x72\x6c\x55\xd3\x78\x06\x12\x98\xc8\x5c\x92\x81\x4a\xbc\x33\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x10\x3f\xe4\x13\x36\x71\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\xaa\x6c\xfa\x36\xca\xe8\x6b\x40"
-    , {- in  = -} "\xb9\x16\xe0\xea\xcc\x1c\x00\xd7\xdc\xec\x68\xec\x0b\x3b\xbb\x1a\x02\xde\x8a\x2d\x1a\xa3\x46\x13\x2e"
-    , {- out = -} "\xaa\x6c\xfa\x36\xca\xe8\x6b\x40\xb1\xd2\x3a\x22\x20\xdd\xc0\xac\x90\x0d\x9a\xa0\x3c\x61\xfc\xf4\xa5\x59\xa4\x41\x77\x67\x08\x97\x08\xa7\x76\x79\x6e\xdb\x72\x35\x06"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x76\x4c\x63\xb8\x05\x8e\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\xd0\xd0\x73\x5c\x53\x1e\x1b\xec\xf0\x49\xc2\x44"
-    , {- in  = -} "\x12\xda\xac\x56\x30\xef\xa5\x39\x6f\x77\x0c\xe1\xa6\x6b\x21\xf7\xb2\x10\x1c"
-    , {- out = -} "\xd0\xd0\x73\x5c\x53\x1e\x1b\xec\xf0\x49\xc2\x44\x14\xd2\x53\xc3\x96\x7b\x70\x60\x9b\x7c\xbb\x7c\x49\x91\x60\x28\x32\x45\x26\x9a\x6f\x49\x97\x5b\xca\xde\xaf"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\xf8\xb6\x78\x09\x4e\x3b\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\x77\xb6\x0f\x01\x1c\x03\xe1\x52\x58\x99\xbc\xae"
-    , {- in  = -} "\xe8\x8b\x6a\x46\xc7\x8d\x63\xe5\x2e\xb8\xc5\x46\xef\xb5\xde\x6f\x75\xe9\xcc\x0d"
-    , {- out = -} "\x77\xb6\x0f\x01\x1c\x03\xe1\x52\x58\x99\xbc\xae\x55\x45\xff\x1a\x08\x5e\xe2\xef\xbf\x52\xb2\xe0\x4b\xee\x1e\x23\x36\xc7\x3e\x3f\x76\x2c\x0c\x77\x44\xfe\x7e\x3c"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\xd5\x60\x91\x2d\x3f\x70\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81\x20\xea\x60\xc0"
-    , {- in  = -} "\x64\x35\xac\xba\xfb\x11\xa8\x2e\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9\x3a\x80\x3b\xa8\x7f"
-    , {- out = -} "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81\x20\xea\x60\xc0\x00\x97\x69\xec\xab\xdf\x48\x62\x55\x94\xc5\x92\x51\xe6\x03\x57\x22\x67\x5e\x04\xc8\x47\x09\x9e\x5a\xe0\x70\x45\x51"
-    , {-  M  = -} 8)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x42\xff\xf8\xf1\x95\x1c\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8"
-    , {- in  = -} "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01\x8e\x5e\x67\x01\xc9\x17\x87\x65\x98\x09\xd6\x7d\xbe\xdd\x18"
-    , {- out = -} "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8\xbc\x21\x8d\xaa\x94\x74\x27\xb6\xdb\x38\x6a\x99\xac\x1a\xef\x23\xad\xe0\xb5\x29\x39\xcb\x6a\x63\x7c\xf9\xbe\xc2\x40\x88\x97\xc6\xba"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x92\x0f\x40\xe5\x6c\xdc\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\x74\xa0\xeb\xc9\x06\x9f\x5b\x37"
-    , {- in  = -} "\x17\x61\x43\x3c\x37\xc5\xa3\x5f\xc1\xf3\x9f\x40\x63\x02\xeb\x90\x7c\x61\x63\xbe\x38\xc9\x84\x37"
-    , {- out = -} "\x74\xa0\xeb\xc9\x06\x9f\x5b\x37\x58\x10\xe6\xfd\x25\x87\x40\x22\xe8\x03\x61\xa4\x78\xe3\xe9\xcf\x48\x4a\xb0\x4f\x44\x7e\xff\xf6\xf0\xa4\x77\xcc\x2f\xc9\xbf\x54\x89\x44"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x27\xca\x0c\x71\x20\xbc\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\x44\xa3\xaa\x3a\xae\x64\x75\xca"
-    , {- in  = -} "\xa4\x34\xa8\xe5\x85\x00\xc6\xe4\x15\x30\x53\x88\x62\xd6\x86\xea\x9e\x81\x30\x1b\x5a\xe4\x22\x6b\xfa"
-    , {- out = -} "\x44\xa3\xaa\x3a\xae\x64\x75\xca\xf2\xbe\xed\x7b\xc5\x09\x8e\x83\xfe\xb5\xb3\x16\x08\xf8\xe2\x9c\x38\x81\x9a\x89\xc8\xe7\x76\xf1\x54\x4d\x41\x51\xa4\xed\x3a\x8b\x87\xb9\xce"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x5b\x8c\xcb\xcd\x9a\xf8\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\xec\x46\xbb\x63\xb0\x25\x20\xc3\x3c\x49\xfd\x70"
-    , {- in  = -} "\xb9\x6b\x49\xe2\x1d\x62\x17\x41\x63\x28\x75\xdb\x7f\x6c\x92\x43\xd2\xd7\xc2"
-    , {- out = -} "\xec\x46\xbb\x63\xb0\x25\x20\xc3\x3c\x49\xfd\x70\x31\xd7\x50\xa0\x9d\xa3\xed\x7f\xdd\xd4\x9a\x20\x32\xaa\xbf\x17\xec\x8e\xbf\x7d\x22\xc8\x08\x8c\x66\x6b\xe5\xc1\x97"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x3e\xbe\x94\x04\x4b\x9a\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\x47\xa6\x5a\xc7\x8b\x3d\x59\x42\x27\xe8\x5e\x71"
-    , {- in  = -} "\xe2\xfc\xfb\xb8\x80\x44\x2c\x73\x1b\xf9\x51\x67\xc8\xff\xd7\x89\x5e\x33\x70\x76"
-    , {- out = -} "\x47\xa6\x5a\xc7\x8b\x3d\x59\x42\x27\xe8\x5e\x71\xe8\x82\xf1\xdb\xd3\x8c\xe3\xed\xa7\xc2\x3f\x04\xdd\x65\x07\x1e\xb4\x13\x42\xac\xdf\x7e\x00\xdc\xce\xc7\xae\x52\x98\x7d"
-    , {-  M  = -} 10)
-  , ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
-    , {- iv  = -} "\x00\x8d\x49\x3b\x30\xae\x8b\x3c\x96\x96\x76\x6c\xfa"
-    , {- hdr = -} "\x6e\x37\xa6\xef\x54\x6d\x95\x5d\x34\xab\x60\x59"
-    , {- in  = -} "\xab\xf2\x1c\x0b\x02\xfe\xb8\x8f\x85\x6d\xf4\xa3\x73\x81\xbc\xe3\xcc\x12\x85\x17\xd4"
-    , {- out = -} "\x6e\x37\xa6\xef\x54\x6d\x95\x5d\x34\xab\x60\x59\xf3\x29\x05\xb8\x8a\x64\x1b\x04\xb9\xc9\xff\xb5\x8c\xc3\x90\x90\x0f\x3d\xa1\x2a\xb1\x6d\xce\x9e\x82\xef\xa1\x6d\xa6\x20\x59"
-    , {-  M  = -} 10)
-  ]
+    [
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x03\x02\x01\x00\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x58\x8c\x97\x9a\x61\xc6\x63\xd2\xf0\x66\xd0\xc2\xc0\xf9\x89\x80\x6d\x5f\x6b\x61\xda\xc3\x84\x17\xe8\xd1\x2c\xfd\xf9\x26\xe0"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x04\x03\x02\x01\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x72\xc9\x1a\x36\xe1\x35\xf8\xcf\x29\x1c\xa8\x94\x08\x5c\x87\xe3\xcc\x15\xc4\x39\xc9\xe4\x3a\x3b\xa0\x91\xd5\x6e\x10\x40\x09\x16"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x05\x04\x03\x02\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x51\xb1\xe5\xf4\x4a\x19\x7d\x1d\xa4\x6b\x0f\x8e\x2d\x28\x2a\xe8\x71\xe8\x38\xbb\x64\xda\x85\x96\x57\x4a\xda\xa7\x6f\xbd\x9f\xb0\xc5"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x06\x05\x04\x03\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
+        , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\xa2\x8c\x68\x65\x93\x9a\x9a\x79\xfa\xaa\x5c\x4c\x2a\x9d\x4a\x91\xcd\xac\x8c\x96\xc8\x61\xb9\xc9\xe6\x1e\xf1"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x07\x06\x05\x04\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
+        , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb\x9d\x4e\x13\x12\x53\x65\x8a\xd8\x6e\xbd\xca\x3e\x51\xe8\x3f\x07\x7d\x9c\x2d\x93"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x08\x07\x06\x05\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
+        , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x6f\xc1\xb0\x11\xf0\x06\x56\x8b\x51\x71\xa4\x2d\x95\x3d\x46\x9b\x25\x70\xa4\xbd\x87\x40\x5a\x04\x43\xac\x91\xcb\x94"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x09\x08\x07\x06\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x01\x35\xd1\xb2\xc9\x5f\x41\xd5\xd1\xd4\xfe\xc1\x85\xd1\x66\xb8\x09\x4e\x99\x9d\xfe\xd9\x6c\x04\x8c\x56\x60\x2c\x97\xac\xbb\x74\x90"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x0a\x09\x08\x07\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x7b\x75\x39\x9a\xc0\x83\x1d\xd2\xf0\xbb\xd7\x58\x79\xa2\xfd\x8f\x6c\xae\x6b\x6c\xd9\xb7\xdb\x24\xc1\x7b\x44\x33\xf4\x34\x96\x3f\x34\xb4"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x0b\x0a\x09\x08\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , {- in  = -} "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x82\x53\x1a\x60\xcc\x24\x94\x5a\x4b\x82\x79\x18\x1a\xb5\xc8\x4d\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1\x97\xea\x9c\x07\xe5\x6b\x5e\xb1\x7e\x5f\x4e"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x0c\x0b\x0a\x09\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
+        , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x07\x34\x25\x94\x15\x77\x85\x15\x2b\x07\x40\x98\x33\x0a\xbb\x14\x1b\x94\x7b\x56\x6a\xa9\x40\x6b\x4d\x99\x99\x88\xdd"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x0d\x0c\x0b\x0a\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
+        , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x67\x6b\xb2\x03\x80\xb0\xe3\x01\xe8\xab\x79\x59\x0a\x39\x6d\xa7\x8b\x83\x49\x34\xf5\x3a\xa2\xe9\x10\x7a\x8b\x6c\x02\x2c"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+        , {- iv  = -} "\x00\x00\x00\x0e\x0d\x0c\x0b\xa0\xa1\xa2\xa3\xa4\xa5"
+        , {- hdr = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
+        , {- in  = -} "\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
+        , {- out = -} "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\xc0\xff\xa0\xd6\xf0\x5b\xdb\x67\xf2\x4d\x43\xa4\x33\x8d\x2a\xa4\xbe\xd7\xb2\x0e\x43\xcd\x1a\xa3\x16\x62\xe7\xad\x65\xd6\xdb"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x41\x2b\x4e\xa9\xcd\xbe\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\x0b\xe1\xa8\x8b\xac\xe0\x18\xb1"
+        , {- in  = -} "\x08\xe8\xcf\x97\xd8\x20\xea\x25\x84\x60\xe9\x6a\xd9\xcf\x52\x89\x05\x4d\x89\x5c\xea\xc4\x7c"
+        , {- out = -} "\x0b\xe1\xa8\x8b\xac\xe0\x18\xb1\x4c\xb9\x7f\x86\xa2\xa4\x68\x9a\x87\x79\x47\xab\x80\x91\xef\x53\x86\xa6\xff\xbd\xd0\x80\xf8\xe7\x8c\xf7\xcb\x0c\xdd\xd7\xb3"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x33\x56\x8e\xf7\xb2\x63\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb"
+        , {- in  = -} "\x90\x20\xea\x6f\x91\xbd\xd8\x5a\xfa\x00\x39\xba\x4b\xaf\xf9\xbf\xb7\x9c\x70\x28\x94\x9c\xd0\xec"
+        , {- out = -} "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa\xa0\x72\x6c\x55\xd3\x78\x06\x12\x98\xc8\x5c\x92\x81\x4a\xbc\x33\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x10\x3f\xe4\x13\x36\x71\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\xaa\x6c\xfa\x36\xca\xe8\x6b\x40"
+        , {- in  = -} "\xb9\x16\xe0\xea\xcc\x1c\x00\xd7\xdc\xec\x68\xec\x0b\x3b\xbb\x1a\x02\xde\x8a\x2d\x1a\xa3\x46\x13\x2e"
+        , {- out = -} "\xaa\x6c\xfa\x36\xca\xe8\x6b\x40\xb1\xd2\x3a\x22\x20\xdd\xc0\xac\x90\x0d\x9a\xa0\x3c\x61\xfc\xf4\xa5\x59\xa4\x41\x77\x67\x08\x97\x08\xa7\x76\x79\x6e\xdb\x72\x35\x06"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x76\x4c\x63\xb8\x05\x8e\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\xd0\xd0\x73\x5c\x53\x1e\x1b\xec\xf0\x49\xc2\x44"
+        , {- in  = -} "\x12\xda\xac\x56\x30\xef\xa5\x39\x6f\x77\x0c\xe1\xa6\x6b\x21\xf7\xb2\x10\x1c"
+        , {- out = -} "\xd0\xd0\x73\x5c\x53\x1e\x1b\xec\xf0\x49\xc2\x44\x14\xd2\x53\xc3\x96\x7b\x70\x60\x9b\x7c\xbb\x7c\x49\x91\x60\x28\x32\x45\x26\x9a\x6f\x49\x97\x5b\xca\xde\xaf"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\xf8\xb6\x78\x09\x4e\x3b\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\x77\xb6\x0f\x01\x1c\x03\xe1\x52\x58\x99\xbc\xae"
+        , {- in  = -} "\xe8\x8b\x6a\x46\xc7\x8d\x63\xe5\x2e\xb8\xc5\x46\xef\xb5\xde\x6f\x75\xe9\xcc\x0d"
+        , {- out = -} "\x77\xb6\x0f\x01\x1c\x03\xe1\x52\x58\x99\xbc\xae\x55\x45\xff\x1a\x08\x5e\xe2\xef\xbf\x52\xb2\xe0\x4b\xee\x1e\x23\x36\xc7\x3e\x3f\x76\x2c\x0c\x77\x44\xfe\x7e\x3c"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\xd5\x60\x91\x2d\x3f\x70\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81\x20\xea\x60\xc0"
+        , {- in  = -} "\x64\x35\xac\xba\xfb\x11\xa8\x2e\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9\x3a\x80\x3b\xa8\x7f"
+        , {- out = -} "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81\x20\xea\x60\xc0\x00\x97\x69\xec\xab\xdf\x48\x62\x55\x94\xc5\x92\x51\xe6\x03\x57\x22\x67\x5e\x04\xc8\x47\x09\x9e\x5a\xe0\x70\x45\x51"
+        , {-  M  = -} 8
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x42\xff\xf8\xf1\x95\x1c\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8"
+        , {- in  = -} "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01\x8e\x5e\x67\x01\xc9\x17\x87\x65\x98\x09\xd6\x7d\xbe\xdd\x18"
+        , {- out = -} "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8\xbc\x21\x8d\xaa\x94\x74\x27\xb6\xdb\x38\x6a\x99\xac\x1a\xef\x23\xad\xe0\xb5\x29\x39\xcb\x6a\x63\x7c\xf9\xbe\xc2\x40\x88\x97\xc6\xba"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x92\x0f\x40\xe5\x6c\xdc\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\x74\xa0\xeb\xc9\x06\x9f\x5b\x37"
+        , {- in  = -} "\x17\x61\x43\x3c\x37\xc5\xa3\x5f\xc1\xf3\x9f\x40\x63\x02\xeb\x90\x7c\x61\x63\xbe\x38\xc9\x84\x37"
+        , {- out = -} "\x74\xa0\xeb\xc9\x06\x9f\x5b\x37\x58\x10\xe6\xfd\x25\x87\x40\x22\xe8\x03\x61\xa4\x78\xe3\xe9\xcf\x48\x4a\xb0\x4f\x44\x7e\xff\xf6\xf0\xa4\x77\xcc\x2f\xc9\xbf\x54\x89\x44"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x27\xca\x0c\x71\x20\xbc\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\x44\xa3\xaa\x3a\xae\x64\x75\xca"
+        , {- in  = -} "\xa4\x34\xa8\xe5\x85\x00\xc6\xe4\x15\x30\x53\x88\x62\xd6\x86\xea\x9e\x81\x30\x1b\x5a\xe4\x22\x6b\xfa"
+        , {- out = -} "\x44\xa3\xaa\x3a\xae\x64\x75\xca\xf2\xbe\xed\x7b\xc5\x09\x8e\x83\xfe\xb5\xb3\x16\x08\xf8\xe2\x9c\x38\x81\x9a\x89\xc8\xe7\x76\xf1\x54\x4d\x41\x51\xa4\xed\x3a\x8b\x87\xb9\xce"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x5b\x8c\xcb\xcd\x9a\xf8\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\xec\x46\xbb\x63\xb0\x25\x20\xc3\x3c\x49\xfd\x70"
+        , {- in  = -} "\xb9\x6b\x49\xe2\x1d\x62\x17\x41\x63\x28\x75\xdb\x7f\x6c\x92\x43\xd2\xd7\xc2"
+        , {- out = -} "\xec\x46\xbb\x63\xb0\x25\x20\xc3\x3c\x49\xfd\x70\x31\xd7\x50\xa0\x9d\xa3\xed\x7f\xdd\xd4\x9a\x20\x32\xaa\xbf\x17\xec\x8e\xbf\x7d\x22\xc8\x08\x8c\x66\x6b\xe5\xc1\x97"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x3e\xbe\x94\x04\x4b\x9a\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\x47\xa6\x5a\xc7\x8b\x3d\x59\x42\x27\xe8\x5e\x71"
+        , {- in  = -} "\xe2\xfc\xfb\xb8\x80\x44\x2c\x73\x1b\xf9\x51\x67\xc8\xff\xd7\x89\x5e\x33\x70\x76"
+        , {- out = -} "\x47\xa6\x5a\xc7\x8b\x3d\x59\x42\x27\xe8\x5e\x71\xe8\x82\xf1\xdb\xd3\x8c\xe3\xed\xa7\xc2\x3f\x04\xdd\x65\x07\x1e\xb4\x13\x42\xac\xdf\x7e\x00\xdc\xce\xc7\xae\x52\x98\x7d"
+        , {-  M  = -} 10
+        )
+    ,
+        ( {- key = -} "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3\x25\xa7\x62\x36\xdf\x93\xcc\x6b"
+        , {- iv  = -} "\x00\x8d\x49\x3b\x30\xae\x8b\x3c\x96\x96\x76\x6c\xfa"
+        , {- hdr = -} "\x6e\x37\xa6\xef\x54\x6d\x95\x5d\x34\xab\x60\x59"
+        , {- in  = -} "\xab\xf2\x1c\x0b\x02\xfe\xb8\x8f\x85\x6d\xf4\xa3\x73\x81\xbc\xe3\xcc\x12\x85\x17\xd4"
+        , {- out = -} "\x6e\x37\xa6\xef\x54\x6d\x95\x5d\x34\xab\x60\x59\xf3\x29\x05\xb8\x8a\x64\x1b\x04\xb9\xc9\xff\xb5\x8c\xc3\x90\x90\x0f\x3d\xa1\x2a\xb1\x6d\xce\x9e\x82\xef\xa1\x6d\xa6\x20\x59"
+        , {-  M  = -} 10
+        )
+    ]
diff --git a/tests/KAT_AES/KATECB.hs b/tests/KAT_AES/KATECB.hs
--- a/tests/KAT_AES/KATECB.hs
+++ b/tests/KAT_AES/KATECB.hs
@@ -4,145 +4,717 @@
 
 vectors_aes128_enc =
     [
-      ( B.pack [0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3,0x74,0xcf,0x86,0x7c,0xfb,0x47,0x38,0x59]
-      , B.replicate 16 0
-      , B.pack [0x6d,0x25,0x1e,0x69,0x44,0xb0,0x51,0xe0,0x4e,0xaa,0x6f,0xb4,0xdb,0xf7,0x84,0x65]
-      )
-    , ( B.replicate 16 0
-      , B.replicate 16 0
-      , B.pack [0x66,0xe9,0x4b,0xd4,0xef,0x8a,0x2c,0x3b,0x88,0x4c,0xfa,0x59,0xca,0x34,0x2b,0x2e]
-      )
-    , ( B.replicate 16 0
-      , B.replicate 16 1
-      , B.pack [0xe1,0x4d,0x5d,0x0e,0xe2,0x77,0x15,0xdf,0x08,0xb4,0x15,0x2b,0xa2,0x3d,0xa8,0xe0]
-      )
-    , ( B.replicate 16 1
-      , B.replicate 16 2
-      , B.pack [0x17,0xd6,0x14,0xf3,0x79,0xa9,0x35,0x90,0x77,0xe9,0x55,0x77,0xfd,0x31,0xc2,0x0a]
-      )
-    , ( B.replicate 16 2
-      , B.replicate 16 1
-      , B.pack [0x8f,0x42,0xc2,0x4b,0xee,0x6e,0x63,0x47,0x2b,0x16,0x5a,0xa9,0x41,0x31,0x2f,0x7c]
-      )
-    , ( B.replicate 16 3
-      , B.replicate 16 2
-      , B.pack [0x90,0x98,0x85,0xe4,0x77,0xbc,0x20,0xf5,0x8a,0x66,0x97,0x1d,0xa0,0xbc,0x75,0xe3]
-      )
+        ( B.pack
+            [ 0x10
+            , 0xa5
+            , 0x88
+            , 0x69
+            , 0xd7
+            , 0x4b
+            , 0xe5
+            , 0xa3
+            , 0x74
+            , 0xcf
+            , 0x86
+            , 0x7c
+            , 0xfb
+            , 0x47
+            , 0x38
+            , 0x59
+            ]
+        , B.replicate 16 0
+        , B.pack
+            [ 0x6d
+            , 0x25
+            , 0x1e
+            , 0x69
+            , 0x44
+            , 0xb0
+            , 0x51
+            , 0xe0
+            , 0x4e
+            , 0xaa
+            , 0x6f
+            , 0xb4
+            , 0xdb
+            , 0xf7
+            , 0x84
+            , 0x65
+            ]
+        )
+    ,
+        ( B.replicate 16 0
+        , B.replicate 16 0
+        , B.pack
+            [ 0x66
+            , 0xe9
+            , 0x4b
+            , 0xd4
+            , 0xef
+            , 0x8a
+            , 0x2c
+            , 0x3b
+            , 0x88
+            , 0x4c
+            , 0xfa
+            , 0x59
+            , 0xca
+            , 0x34
+            , 0x2b
+            , 0x2e
+            ]
+        )
+    ,
+        ( B.replicate 16 0
+        , B.replicate 16 1
+        , B.pack
+            [ 0xe1
+            , 0x4d
+            , 0x5d
+            , 0x0e
+            , 0xe2
+            , 0x77
+            , 0x15
+            , 0xdf
+            , 0x08
+            , 0xb4
+            , 0x15
+            , 0x2b
+            , 0xa2
+            , 0x3d
+            , 0xa8
+            , 0xe0
+            ]
+        )
+    ,
+        ( B.replicate 16 1
+        , B.replicate 16 2
+        , B.pack
+            [ 0x17
+            , 0xd6
+            , 0x14
+            , 0xf3
+            , 0x79
+            , 0xa9
+            , 0x35
+            , 0x90
+            , 0x77
+            , 0xe9
+            , 0x55
+            , 0x77
+            , 0xfd
+            , 0x31
+            , 0xc2
+            , 0x0a
+            ]
+        )
+    ,
+        ( B.replicate 16 2
+        , B.replicate 16 1
+        , B.pack
+            [ 0x8f
+            , 0x42
+            , 0xc2
+            , 0x4b
+            , 0xee
+            , 0x6e
+            , 0x63
+            , 0x47
+            , 0x2b
+            , 0x16
+            , 0x5a
+            , 0xa9
+            , 0x41
+            , 0x31
+            , 0x2f
+            , 0x7c
+            ]
+        )
+    ,
+        ( B.replicate 16 3
+        , B.replicate 16 2
+        , B.pack
+            [ 0x90
+            , 0x98
+            , 0x85
+            , 0xe4
+            , 0x77
+            , 0xbc
+            , 0x20
+            , 0xf5
+            , 0x8a
+            , 0x66
+            , 0x97
+            , 0x1d
+            , 0xa0
+            , 0xbc
+            , 0x75
+            , 0xe3
+            ]
+        )
     ]
 
 vectors_aes192_enc =
     [
-      ( B.replicate 24 0
-      , B.replicate 16 0
-      , B.pack [0xaa,0xe0,0x69,0x92,0xac,0xbf,0x52,0xa3,0xe8,0xf4,0xa9,0x6e,0xc9,0x30,0x0b,0xd7]
-      )
-    , ( B.replicate 24 0
-      , B.replicate 16 1
-      , B.pack [0xcf,0x1e,0xce,0x3c,0x44,0xb0,0x78,0xfb,0x27,0xcb,0x0a,0x3e,0x07,0x1b,0x08,0x20]
-      )
-    , ( B.replicate 24 1
-      , B.replicate 16 2
-      , B.pack [0xeb,0x8c,0x17,0x30,0x90,0xc7,0x5b,0x77,0xd6,0x72,0xb4,0x57,0xa7,0x78,0xd9,0xd0]
-      )
-    , ( B.replicate 24 2
-      , B.replicate 16 1
-      , B.pack [0xf2,0xf0,0xae,0xd8,0xcd,0xc9,0x21,0xca,0x4b,0x55,0x84,0x5d,0xa4,0x15,0x21,0xc2]
-      )
-    , ( B.replicate 24 3
-      , B.replicate 16 2
-      , B.pack [0xca,0xcc,0x30,0x79,0xe4,0xb7,0x95,0x27,0x63,0xd2,0x55,0xd6,0x34,0x10,0x46,0x14]
-      )
+        ( B.replicate 24 0
+        , B.replicate 16 0
+        , B.pack
+            [ 0xaa
+            , 0xe0
+            , 0x69
+            , 0x92
+            , 0xac
+            , 0xbf
+            , 0x52
+            , 0xa3
+            , 0xe8
+            , 0xf4
+            , 0xa9
+            , 0x6e
+            , 0xc9
+            , 0x30
+            , 0x0b
+            , 0xd7
+            ]
+        )
+    ,
+        ( B.replicate 24 0
+        , B.replicate 16 1
+        , B.pack
+            [ 0xcf
+            , 0x1e
+            , 0xce
+            , 0x3c
+            , 0x44
+            , 0xb0
+            , 0x78
+            , 0xfb
+            , 0x27
+            , 0xcb
+            , 0x0a
+            , 0x3e
+            , 0x07
+            , 0x1b
+            , 0x08
+            , 0x20
+            ]
+        )
+    ,
+        ( B.replicate 24 1
+        , B.replicate 16 2
+        , B.pack
+            [ 0xeb
+            , 0x8c
+            , 0x17
+            , 0x30
+            , 0x90
+            , 0xc7
+            , 0x5b
+            , 0x77
+            , 0xd6
+            , 0x72
+            , 0xb4
+            , 0x57
+            , 0xa7
+            , 0x78
+            , 0xd9
+            , 0xd0
+            ]
+        )
+    ,
+        ( B.replicate 24 2
+        , B.replicate 16 1
+        , B.pack
+            [ 0xf2
+            , 0xf0
+            , 0xae
+            , 0xd8
+            , 0xcd
+            , 0xc9
+            , 0x21
+            , 0xca
+            , 0x4b
+            , 0x55
+            , 0x84
+            , 0x5d
+            , 0xa4
+            , 0x15
+            , 0x21
+            , 0xc2
+            ]
+        )
+    ,
+        ( B.replicate 24 3
+        , B.replicate 16 2
+        , B.pack
+            [ 0xca
+            , 0xcc
+            , 0x30
+            , 0x79
+            , 0xe4
+            , 0xb7
+            , 0x95
+            , 0x27
+            , 0x63
+            , 0xd2
+            , 0x55
+            , 0xd6
+            , 0x34
+            , 0x10
+            , 0x46
+            , 0x14
+            ]
+        )
     ]
 
 vectors_aes256_enc =
-    [ ( B.replicate 32 0
-      , B.replicate 16 0
-      , B.pack [0xdc,0x95,0xc0,0x78,0xa2,0x40,0x89,0x89,0xad,0x48,0xa2,0x14,0x92,0x84,0x20,0x87]
-      )
-    , ( B.replicate 32 0
-      , B.replicate 16 1
-      , B.pack [0x7b,0xc3,0x02,0x6c,0xd7,0x37,0x10,0x3e,0x62,0x90,0x2b,0xcd,0x18,0xfb,0x01,0x63]
-      )
-    , ( B.replicate 32 1
-      , B.replicate 16 2
-      , B.pack [0x62,0xae,0x12,0xf3,0x24,0xbf,0xea,0x08,0xd5,0xf6,0x75,0xb5,0x13,0x02,0x6b,0xbf]
-      )
-    , ( B.replicate 32 2
-      , B.replicate 16 1
-      , B.pack [0x00,0xf9,0xc7,0x44,0x4b,0xb0,0xcc,0x80,0x6c,0x7c,0x39,0xee,0x22,0x11,0xf1,0x46]
-      )
-    , ( B.replicate 32 3
-      , B.replicate 16 2
-      , B.pack [0xb4,0x05,0x87,0x3e,0xa0,0x76,0x1b,0x9c,0xa9,0x9f,0x70,0xb0,0x16,0x16,0xce,0xb1]
-      )
+    [
+        ( B.replicate 32 0
+        , B.replicate 16 0
+        , B.pack
+            [ 0xdc
+            , 0x95
+            , 0xc0
+            , 0x78
+            , 0xa2
+            , 0x40
+            , 0x89
+            , 0x89
+            , 0xad
+            , 0x48
+            , 0xa2
+            , 0x14
+            , 0x92
+            , 0x84
+            , 0x20
+            , 0x87
+            ]
+        )
+    ,
+        ( B.replicate 32 0
+        , B.replicate 16 1
+        , B.pack
+            [ 0x7b
+            , 0xc3
+            , 0x02
+            , 0x6c
+            , 0xd7
+            , 0x37
+            , 0x10
+            , 0x3e
+            , 0x62
+            , 0x90
+            , 0x2b
+            , 0xcd
+            , 0x18
+            , 0xfb
+            , 0x01
+            , 0x63
+            ]
+        )
+    ,
+        ( B.replicate 32 1
+        , B.replicate 16 2
+        , B.pack
+            [ 0x62
+            , 0xae
+            , 0x12
+            , 0xf3
+            , 0x24
+            , 0xbf
+            , 0xea
+            , 0x08
+            , 0xd5
+            , 0xf6
+            , 0x75
+            , 0xb5
+            , 0x13
+            , 0x02
+            , 0x6b
+            , 0xbf
+            ]
+        )
+    ,
+        ( B.replicate 32 2
+        , B.replicate 16 1
+        , B.pack
+            [ 0x00
+            , 0xf9
+            , 0xc7
+            , 0x44
+            , 0x4b
+            , 0xb0
+            , 0xcc
+            , 0x80
+            , 0x6c
+            , 0x7c
+            , 0x39
+            , 0xee
+            , 0x22
+            , 0x11
+            , 0xf1
+            , 0x46
+            ]
+        )
+    ,
+        ( B.replicate 32 3
+        , B.replicate 16 2
+        , B.pack
+            [ 0xb4
+            , 0x05
+            , 0x87
+            , 0x3e
+            , 0xa0
+            , 0x76
+            , 0x1b
+            , 0x9c
+            , 0xa9
+            , 0x9f
+            , 0x70
+            , 0xb0
+            , 0x16
+            , 0x16
+            , 0xce
+            , 0xb1
+            ]
+        )
     ]
 
 vectors_aes128_dec =
-    [ ( B.replicate 16 0
-      , B.replicate 16 0
-      , B.pack [0x14,0x0f,0x0f,0x10,0x11,0xb5,0x22,0x3d,0x79,0x58,0x77,0x17,0xff,0xd9,0xec,0x3a]
-      )
-    , ( B.replicate 16 0
-      , B.replicate 16 1
-      , B.pack [0x15,0x6d,0x0f,0x85,0x75,0xd5,0x33,0x07,0x52,0xf8,0x4a,0xf2,0x72,0xff,0x30,0x50]
-      )
-    , ( B.replicate 16 1
-      , B.replicate 16 2
-      , B.pack [0x34,0x37,0xd6,0xe2,0x31,0xd7,0x02,0x41,0x9b,0x51,0xb4,0x94,0x72,0x71,0xb6,0x11]
-      )
-    , ( B.replicate 16 2
-      , B.replicate 16 1
-      , B.pack [0xe3,0xcd,0xe2,0x37,0xc8,0xf2,0xd9,0x7b,0x8d,0x79,0xf9,0x17,0x1d,0x4b,0xda,0xc1]
-      )
-    , ( B.replicate 16 3
-      , B.replicate 16 2
-      , B.pack [0x5b,0x94,0xaa,0xed,0xd7,0x83,0x99,0x8c,0xd5,0x15,0x35,0x35,0x18,0xcc,0x45,0xe2]
-      )
+    [
+        ( B.replicate 16 0
+        , B.replicate 16 0
+        , B.pack
+            [ 0x14
+            , 0x0f
+            , 0x0f
+            , 0x10
+            , 0x11
+            , 0xb5
+            , 0x22
+            , 0x3d
+            , 0x79
+            , 0x58
+            , 0x77
+            , 0x17
+            , 0xff
+            , 0xd9
+            , 0xec
+            , 0x3a
+            ]
+        )
+    ,
+        ( B.replicate 16 0
+        , B.replicate 16 1
+        , B.pack
+            [ 0x15
+            , 0x6d
+            , 0x0f
+            , 0x85
+            , 0x75
+            , 0xd5
+            , 0x33
+            , 0x07
+            , 0x52
+            , 0xf8
+            , 0x4a
+            , 0xf2
+            , 0x72
+            , 0xff
+            , 0x30
+            , 0x50
+            ]
+        )
+    ,
+        ( B.replicate 16 1
+        , B.replicate 16 2
+        , B.pack
+            [ 0x34
+            , 0x37
+            , 0xd6
+            , 0xe2
+            , 0x31
+            , 0xd7
+            , 0x02
+            , 0x41
+            , 0x9b
+            , 0x51
+            , 0xb4
+            , 0x94
+            , 0x72
+            , 0x71
+            , 0xb6
+            , 0x11
+            ]
+        )
+    ,
+        ( B.replicate 16 2
+        , B.replicate 16 1
+        , B.pack
+            [ 0xe3
+            , 0xcd
+            , 0xe2
+            , 0x37
+            , 0xc8
+            , 0xf2
+            , 0xd9
+            , 0x7b
+            , 0x8d
+            , 0x79
+            , 0xf9
+            , 0x17
+            , 0x1d
+            , 0x4b
+            , 0xda
+            , 0xc1
+            ]
+        )
+    ,
+        ( B.replicate 16 3
+        , B.replicate 16 2
+        , B.pack
+            [ 0x5b
+            , 0x94
+            , 0xaa
+            , 0xed
+            , 0xd7
+            , 0x83
+            , 0x99
+            , 0x8c
+            , 0xd5
+            , 0x15
+            , 0x35
+            , 0x35
+            , 0x18
+            , 0xcc
+            , 0x45
+            , 0xe2
+            ]
+        )
     ]
 
 vectors_aes192_dec =
     [
-      ( B.replicate 24 0
-      , B.replicate 16 0
-      , B.pack [0x13,0x46,0x0e,0x87,0xa8,0xfc,0x02,0x3e,0xf2,0x50,0x1a,0xfe,0x7f,0xf5,0x1c,0x51]
-      )
-    , ( B.replicate 24 0
-      , B.replicate 16 1
-      , B.pack [0x92,0x17,0x07,0xc3,0x3d,0x1c,0xc5,0x96,0x7d,0xa5,0x1d,0xbb,0xb0,0x66,0xb2,0x6c]
-      )
-    , ( B.replicate 24 1
-      , B.replicate 16 2
-      , B.pack [0xee,0x92,0x97,0xc6,0xba,0xe8,0x26,0x4d,0xff,0x08,0x0e,0xbb,0x1e,0x74,0x11,0xc1]
-      )
-    , ( B.replicate 24 2
-      , B.replicate 16 1
-      , B.pack [0x49,0x67,0xdf,0x70,0xd2,0x9e,0x9a,0x7f,0x5d,0x7c,0xb9,0xc1,0x20,0xc3,0x8a,0x71]
-      )
-    , ( B.replicate 24 3
-      , B.replicate 16 2
-      , B.pack [0x74,0x38,0x62,0x42,0x6b,0x56,0x7f,0xd5,0xf0,0x1d,0x1b,0x59,0x56,0x01,0x26,0x29]
-      )
+        ( B.replicate 24 0
+        , B.replicate 16 0
+        , B.pack
+            [ 0x13
+            , 0x46
+            , 0x0e
+            , 0x87
+            , 0xa8
+            , 0xfc
+            , 0x02
+            , 0x3e
+            , 0xf2
+            , 0x50
+            , 0x1a
+            , 0xfe
+            , 0x7f
+            , 0xf5
+            , 0x1c
+            , 0x51
+            ]
+        )
+    ,
+        ( B.replicate 24 0
+        , B.replicate 16 1
+        , B.pack
+            [ 0x92
+            , 0x17
+            , 0x07
+            , 0xc3
+            , 0x3d
+            , 0x1c
+            , 0xc5
+            , 0x96
+            , 0x7d
+            , 0xa5
+            , 0x1d
+            , 0xbb
+            , 0xb0
+            , 0x66
+            , 0xb2
+            , 0x6c
+            ]
+        )
+    ,
+        ( B.replicate 24 1
+        , B.replicate 16 2
+        , B.pack
+            [ 0xee
+            , 0x92
+            , 0x97
+            , 0xc6
+            , 0xba
+            , 0xe8
+            , 0x26
+            , 0x4d
+            , 0xff
+            , 0x08
+            , 0x0e
+            , 0xbb
+            , 0x1e
+            , 0x74
+            , 0x11
+            , 0xc1
+            ]
+        )
+    ,
+        ( B.replicate 24 2
+        , B.replicate 16 1
+        , B.pack
+            [ 0x49
+            , 0x67
+            , 0xdf
+            , 0x70
+            , 0xd2
+            , 0x9e
+            , 0x9a
+            , 0x7f
+            , 0x5d
+            , 0x7c
+            , 0xb9
+            , 0xc1
+            , 0x20
+            , 0xc3
+            , 0x8a
+            , 0x71
+            ]
+        )
+    ,
+        ( B.replicate 24 3
+        , B.replicate 16 2
+        , B.pack
+            [ 0x74
+            , 0x38
+            , 0x62
+            , 0x42
+            , 0x6b
+            , 0x56
+            , 0x7f
+            , 0xd5
+            , 0xf0
+            , 0x1d
+            , 0x1b
+            , 0x59
+            , 0x56
+            , 0x01
+            , 0x26
+            , 0x29
+            ]
+        )
     ]
 
 vectors_aes256_dec =
-    [ ( B.replicate 32 0
-      , B.replicate 16 0
-      , B.pack [0x67,0x67,0x1c,0xe1,0xfa,0x91,0xdd,0xeb,0x0f,0x8f,0xbb,0xb3,0x66,0xb5,0x31,0xb4]
-      )
-    , ( B.replicate 32 0
-      , B.replicate 16 1
-      , B.pack [0xcc,0x09,0x21,0xa3,0xc5,0xca,0x17,0xf7,0x48,0xb7,0xc2,0x7b,0x73,0xba,0x87,0xa2]
-      )
-    , ( B.replicate 32 1
-      , B.replicate 16 2
-      , B.pack [0xc0,0x4b,0x27,0x90,0x1a,0x50,0xcf,0xfa,0xf1,0xbb,0x88,0x9f,0xc0,0x92,0x5e,0x14]
-      )
-    , ( B.replicate 32 2
-      , B.replicate 16 1
-      , B.pack [0x24,0x61,0x53,0x5d,0x16,0x1c,0x15,0x39,0x88,0x32,0x77,0x29,0xc5,0x8c,0xc0,0x3a]
-      )
-    , ( B.replicate 32 3
-      , B.replicate 16 2
-      , B.pack [0x30,0xc9,0x1c,0xce,0xfe,0x89,0x30,0xcf,0xff,0x31,0xdb,0xcc,0xfc,0x11,0xc5,0x23]
-      )
+    [
+        ( B.replicate 32 0
+        , B.replicate 16 0
+        , B.pack
+            [ 0x67
+            , 0x67
+            , 0x1c
+            , 0xe1
+            , 0xfa
+            , 0x91
+            , 0xdd
+            , 0xeb
+            , 0x0f
+            , 0x8f
+            , 0xbb
+            , 0xb3
+            , 0x66
+            , 0xb5
+            , 0x31
+            , 0xb4
+            ]
+        )
+    ,
+        ( B.replicate 32 0
+        , B.replicate 16 1
+        , B.pack
+            [ 0xcc
+            , 0x09
+            , 0x21
+            , 0xa3
+            , 0xc5
+            , 0xca
+            , 0x17
+            , 0xf7
+            , 0x48
+            , 0xb7
+            , 0xc2
+            , 0x7b
+            , 0x73
+            , 0xba
+            , 0x87
+            , 0xa2
+            ]
+        )
+    ,
+        ( B.replicate 32 1
+        , B.replicate 16 2
+        , B.pack
+            [ 0xc0
+            , 0x4b
+            , 0x27
+            , 0x90
+            , 0x1a
+            , 0x50
+            , 0xcf
+            , 0xfa
+            , 0xf1
+            , 0xbb
+            , 0x88
+            , 0x9f
+            , 0xc0
+            , 0x92
+            , 0x5e
+            , 0x14
+            ]
+        )
+    ,
+        ( B.replicate 32 2
+        , B.replicate 16 1
+        , B.pack
+            [ 0x24
+            , 0x61
+            , 0x53
+            , 0x5d
+            , 0x16
+            , 0x1c
+            , 0x15
+            , 0x39
+            , 0x88
+            , 0x32
+            , 0x77
+            , 0x29
+            , 0xc5
+            , 0x8c
+            , 0xc0
+            , 0x3a
+            ]
+        )
+    ,
+        ( B.replicate 32 3
+        , B.replicate 16 2
+        , B.pack
+            [ 0x30
+            , 0xc9
+            , 0x1c
+            , 0xce
+            , 0xfe
+            , 0x89
+            , 0x30
+            , 0xcf
+            , 0xff
+            , 0x31
+            , 0xdb
+            , 0xcc
+            , 0xfc
+            , 0x11
+            , 0xc5
+            , 0x23
+            ]
+        )
     ]
diff --git a/tests/KAT_AES/KATGCM.hs b/tests/KAT_AES/KATGCM.hs
--- a/tests/KAT_AES/KATGCM.hs
+++ b/tests/KAT_AES/KATGCM.hs
@@ -1,69 +1,91 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_AES.KATGCM where
 
 import qualified Data.ByteString as B
 import Data.ByteString.Char8 ()
 
 -- (key, iv, aad, input, out, taglen, tag)
-type KATGCM = (B.ByteString, B.ByteString, B.ByteString, B.ByteString, B.ByteString, Int, B.ByteString)
+type KATGCM =
+    ( B.ByteString
+    , B.ByteString
+    , B.ByteString
+    , B.ByteString
+    , B.ByteString
+    , Int
+    , B.ByteString
+    )
 
 vectors_aes128_enc :: [KATGCM]
 vectors_aes128_enc =
     [ -- vectors 0
-        ( {-key = -}"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-iv = -}"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-aad = -}""
-        , {-input = -}""
-        , {-out = -}""
-        , {-taglen = -}16
-        , {-tag = -}"\x58\xe2\xfc\xce\xfa\x7e\x30\x61\x36\x7f\x1d\x57\xa4\xe7\x45\x5a")
-    -- vectors 1
-    ,   ( {-key = -}"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-iv = -}"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-aad = -}"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
-        , {-input = -}"\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a"
-        , {-out = -}"\x09\x82\xd0\xc4\x6a\xbc\xa9\x98\xf9\x22\xc8\xb3\x7b\xb8\xf4\x72\xfd\x9f\xa0\xa1\x43\x41\x53\x29\xfd\xf7\x83\xf5\x9e\x81\xcb\xea"
-        , {-taglen = -}16
-        , {-tag = -}"\x28\x50\x64\x2f\xa8\x8b\xab\x21\x2a\x67\x1a\x97\x48\x69\xa5\x6c")
 
-    -- vectors 2
-    ,   ( {-key = -}"\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-iv = -}"\xff\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-aad = -}"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
-        , {-input = -}"\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a"
-        , {-out = -}"\x1c\xa3\xb5\x41\x39\x6f\x19\x7a\x91\x2d\x27\x15\x70\xd1\xf5\x76\xde\xf1\xbe\x84\x42\x2a\xbb\xbe\x0b\x2d\x91\x21\x82\xbf\x7f\x17"
-        , {-taglen = -}16
-        , {-tag = -}"\x15\x2a\x05\xbb\x7e\x13\x5d\xbe\x93\x7f\xa0\x54\x7a\x8e\x74\xb6")
-    -- vectors 3
-    ,   ( {-key = -}"\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-iv = -}"\xff\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-aad = -}"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
-        , {-input = -}"\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a"
-        , {-out = -}"\xda\x35\xf6\x0a\x65\xc2\xa4\x6c\xb6\x6e\xb6\xf8\x1f\x0b\x9c\x74\x53\x4c\x97\x70\x36\xf7\xdf\x05\x6d\x00\xfe\xbf\xb4\xcb\xf5\x27"
-        , {-taglen = -}16
-        , {-tag = -}"\xb7\x76\x7c\x3b\x9e\xf1\xe2\xcb\xc9\x11\xf1\x9a\xdc\xfa\x35\x0d")
-    ,   ( {-key = -}"\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-iv = -}"\xff\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-aad = -}"\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76"
-        , {-input = -}"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-        , {-out = -}"\xe4\x42\xf8\xc4\xc6\x67\x84\x86\x4a\x5a\x6e\xc7\xe0\xca\x68\xac\x16\xbc\x5b\xbf\xf7\xd5\xf3\xfa\xf3\xb2\xcb\xb0\xa2\x14\xa1\x81"
-        , {-taglen = -}16
-        , {-tag = -}"\x5f\x63\xb8\xeb\x1d\x6f\xa8\x7a\xeb\x39\xa5\xf6\xd7\xed\xc3\x13")
-    ,   ( {-key = -}"\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-iv = -}"\xff\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-aad = -}"\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76"
-        , {-input = -}"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-        , {-out = -}"\xe4\x42\xf8\xc4\xc6\x67\x84\x86\x4a\x5a\x6e\xc7\xe0\xca\x68\xac\x16\xbc\x5b\xbf\xf7\xd5\xf3\xfa\xf3\xb2\xcb\xb0\xa2\x14\xa1"
-        , {-taglen = -}16
-        , {-tag = -}"\x94\xd1\x47\xc3\xa2\xca\x93\xe9\x66\x93\x1e\x3b\xb3\xbb\x67\x01")
-    -- vector 6 tests 32-bit counter wrapping
-    ,   ( {-key = -}"\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , {-iv = -}"\xe8\x38\x84\x1d\x75\xae\x33\xb5\x4b\x51\x57\x89\xc9\x5f\xbe\x65"
-        , {-aad = -}"\x54\x68\x65\x20\x66\x69\x76\x65\x20\x62\x6f\x78\x69\x6e\x67\x20\x77\x69\x7a\x61\x72\x64\x73\x20\x6a\x75\x6d\x70\x20\x71\x75\x69\x63\x6b\x6c\x79\x2e"
-        , {-input = -}"\x54\x68\x65\x20\x71\x75\x69\x63\x6b\x20\x62\x72\x6f\x77\x6e\x20\x66\x6f\x78\x20\x6a\x75\x6d\x70\x73\x20\x6f\x76\x65\x72\x20\x74\x68\x65\x20\x6c\x61\x7a\x79\x20\x64\x6f\x67"
-        , {-out = -}"\x82\x31\x9e\x5a\x6a\x7f\x43\xd0\x42\x8c\xf1\x01\xcf\x0c\x75\xf1\x5d\xda\x4f\xa1\x28\x95\xcd\xd7\x7b\xd5\x42\x68\x2f\xcd\x10\x1b\x0c\x75\x05\x54\xf4\x2f\x2b\xf6\x69\x96\x29"
-        , {-taglen = -}16
-        , {-tag = -}"\x9a\xfa\xf4\xea\xae\x2e\x6f\x40\x00\xf4\x89\x77\xd0\x1e\xd5\x14")
+        ( {-key = -} "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-iv = -} "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-aad = -} ""
+        , {-input = -} ""
+        , {-out = -} ""
+        , {-taglen = -} 16
+        , {-tag = -} "\x58\xe2\xfc\xce\xfa\x7e\x30\x61\x36\x7f\x1d\x57\xa4\xe7\x45\x5a"
+        )
+    , -- vectors 1
+
+        ( {-key = -} "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-iv = -} "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-aad = -} "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , {-input = -} "\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a"
+        , {-out = -} "\x09\x82\xd0\xc4\x6a\xbc\xa9\x98\xf9\x22\xc8\xb3\x7b\xb8\xf4\x72\xfd\x9f\xa0\xa1\x43\x41\x53\x29\xfd\xf7\x83\xf5\x9e\x81\xcb\xea"
+        , {-taglen = -} 16
+        , {-tag = -} "\x28\x50\x64\x2f\xa8\x8b\xab\x21\x2a\x67\x1a\x97\x48\x69\xa5\x6c"
+        )
+    , -- vectors 2
+
+        ( {-key = -} "\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-iv = -} "\xff\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-aad = -} "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , {-input = -} "\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a"
+        , {-out = -} "\x1c\xa3\xb5\x41\x39\x6f\x19\x7a\x91\x2d\x27\x15\x70\xd1\xf5\x76\xde\xf1\xbe\x84\x42\x2a\xbb\xbe\x0b\x2d\x91\x21\x82\xbf\x7f\x17"
+        , {-taglen = -} 16
+        , {-tag = -} "\x15\x2a\x05\xbb\x7e\x13\x5d\xbe\x93\x7f\xa0\x54\x7a\x8e\x74\xb6"
+        )
+    , -- vectors 3
+
+        ( {-key = -} "\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-iv = -} "\xff\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-aad = -} "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+        , {-input = -} "\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a"
+        , {-out = -} "\xda\x35\xf6\x0a\x65\xc2\xa4\x6c\xb6\x6e\xb6\xf8\x1f\x0b\x9c\x74\x53\x4c\x97\x70\x36\xf7\xdf\x05\x6d\x00\xfe\xbf\xb4\xcb\xf5\x27"
+        , {-taglen = -} 16
+        , {-tag = -} "\xb7\x76\x7c\x3b\x9e\xf1\xe2\xcb\xc9\x11\xf1\x9a\xdc\xfa\x35\x0d"
+        )
+    ,
+        ( {-key = -} "\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-iv = -} "\xff\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-aad = -} "\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76"
+        , {-input = -} "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+        , {-out = -} "\xe4\x42\xf8\xc4\xc6\x67\x84\x86\x4a\x5a\x6e\xc7\xe0\xca\x68\xac\x16\xbc\x5b\xbf\xf7\xd5\xf3\xfa\xf3\xb2\xcb\xb0\xa2\x14\xa1\x81"
+        , {-taglen = -} 16
+        , {-tag = -} "\x5f\x63\xb8\xeb\x1d\x6f\xa8\x7a\xeb\x39\xa5\xf6\xd7\xed\xc3\x13"
+        )
+    ,
+        ( {-key = -} "\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-iv = -} "\xff\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-aad = -} "\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76\x76"
+        , {-input = -} "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+        , {-out = -} "\xe4\x42\xf8\xc4\xc6\x67\x84\x86\x4a\x5a\x6e\xc7\xe0\xca\x68\xac\x16\xbc\x5b\xbf\xf7\xd5\xf3\xfa\xf3\xb2\xcb\xb0\xa2\x14\xa1"
+        , {-taglen = -} 16
+        , {-tag = -} "\x94\xd1\x47\xc3\xa2\xca\x93\xe9\x66\x93\x1e\x3b\xb3\xbb\x67\x01"
+        )
+    , -- vector 6 tests 32-bit counter wrapping
+
+        ( {-key = -} "\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , {-iv = -} "\xe8\x38\x84\x1d\x75\xae\x33\xb5\x4b\x51\x57\x89\xc9\x5f\xbe\x65"
+        , {-aad = -} "\x54\x68\x65\x20\x66\x69\x76\x65\x20\x62\x6f\x78\x69\x6e\x67\x20\x77\x69\x7a\x61\x72\x64\x73\x20\x6a\x75\x6d\x70\x20\x71\x75\x69\x63\x6b\x6c\x79\x2e"
+        , {-input = -} "\x54\x68\x65\x20\x71\x75\x69\x63\x6b\x20\x62\x72\x6f\x77\x6e\x20\x66\x6f\x78\x20\x6a\x75\x6d\x70\x73\x20\x6f\x76\x65\x72\x20\x74\x68\x65\x20\x6c\x61\x7a\x79\x20\x64\x6f\x67"
+        , {-out = -} "\x82\x31\x9e\x5a\x6a\x7f\x43\xd0\x42\x8c\xf1\x01\xcf\x0c\x75\xf1\x5d\xda\x4f\xa1\x28\x95\xcd\xd7\x7b\xd5\x42\x68\x2f\xcd\x10\x1b\x0c\x75\x05\x54\xf4\x2f\x2b\xf6\x69\x96\x29"
+        , {-taglen = -} 16
+        , {-tag = -} "\x9a\xfa\xf4\xea\xae\x2e\x6f\x40\x00\xf4\x89\x77\xd0\x1e\xd5\x14"
+        )
     ]
 
 vectors_aes256_enc :: [KATGCM]
@@ -75,15 +97,19 @@
         , ""
         , ""
         , 16
-        , "\xbd\xc1\xac\x88\x4d\x33\x24\x57\xa1\xd2\x66\x4f\x16\x8c\x76\xf0")
-    ,   ( "\x78\xdc\x4e\x0a\xaf\x52\xd9\x35\xc3\xc0\x1e\xea\x57\x42\x8f\x00\xca\x1f\xd4\x75\xf5\xda\x86\xa4\x9c\x8d\xd7\x3d\x68\xc8\xe2\x23"
+        , "\xbd\xc1\xac\x88\x4d\x33\x24\x57\xa1\xd2\x66\x4f\x16\x8c\x76\xf0"
+        )
+    ,
+        ( "\x78\xdc\x4e\x0a\xaf\x52\xd9\x35\xc3\xc0\x1e\xea\x57\x42\x8f\x00\xca\x1f\xd4\x75\xf5\xda\x86\xa4\x9c\x8d\xd7\x3d\x68\xc8\xe2\x23"
         , "\xd7\x9c\xf2\x2d\x50\x4c\xc7\x93\xc3\xfb\x6c\x8a"
         , "\xb9\x6b\xaa\x8c\x1c\x75\xa6\x71\xbf\xb2\xd0\x8d\x06\xbe\x5f\x36"
         , ""
         , ""
         , 16
-        , "\x3e\x5d\x48\x6a\xa2\xe3\x0b\x22\xe0\x40\xb8\x57\x23\xa0\x6e\x76")
-    ,   ( "\xc3\xf1\x05\x86\xf2\x46\xaa\xca\xdc\xce\x37\x01\x44\x17\x70\xc0\x3c\xfe\xc9\x40\xaf\xe1\x90\x8c\x4c\x53\x7d\xf4\xe0\x1c\x50\xa0"
+        , "\x3e\x5d\x48\x6a\xa2\xe3\x0b\x22\xe0\x40\xb8\x57\x23\xa0\x6e\x76"
+        )
+    ,
+        ( "\xc3\xf1\x05\x86\xf2\x46\xaa\xca\xdc\xce\x37\x01\x44\x17\x70\xc0\x3c\xfe\xc9\x40\xaf\xe1\x90\x8c\x4c\x53\x7d\xf4\xe0\x1c\x50\xa0"
         , "\x4f\x52\xfa\xa1\xfa\x67\xa0\xe5\xf4\x19\x64\x52"
         , "\x46\xf9\xa2\x2b\x4e\x52\xe1\x52\x65\x13\xa9\x52\xdb\xee\x3b\x91\xf6\x95\x95\x50\x1e\x01\x77\xd5\x0f\xf3\x64\x63\x85\x88\xc0\x8d\x92\xfa\xb8\xc5\x8a\x96\x9b\xdc\xc8\x4c\x46\x8d\x84\x98\xc4\xf0\x63\x92\xb9\x9e\xd5\xe0\xc4\x84\x50\x7f\xc4\x8d\xc1\x8d\x87\xc4\x0e\x2e\xd8\x48\xb4\x31\x50\xbe\x9d\x36\xf1\x4c\xf2\xce\xf1\x31\x0b\xa4\xa7\x45\xad\xcc\x7b\xdc\x41\xf6"
         , "\x79\xd9\x7e\xa3\xa2\xed\xd6\x50\x45\x82\x1e\xa7\x45\xa4\x47\x42"
diff --git a/tests/KAT_AES/KATOCB3.hs b/tests/KAT_AES/KATOCB3.hs
--- a/tests/KAT_AES/KATOCB3.hs
+++ b/tests/KAT_AES/KATOCB3.hs
@@ -1,46 +1,69 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_AES.KATOCB3 where
 
 import qualified Data.ByteString as B
 import Data.ByteString.Char8 ()
 
 -- (key, iv, aad, input, out, taglen, tag)
-type KATOCB3 = (B.ByteString, B.ByteString, B.ByteString, B.ByteString, B.ByteString, Int, B.ByteString)
+type KATOCB3 =
+    ( B.ByteString
+    , B.ByteString
+    , B.ByteString
+    , B.ByteString
+    , B.ByteString
+    , Int
+    , B.ByteString
+    )
 
-key1   = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+key1 = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
 nonce1 = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
 
 vectors_aes128_enc :: [KATOCB3]
 vectors_aes128_enc =
-    [ ( {-key = -} key1
-      , {-iv = -} nonce1
-      , {-aad = -}""
-      , {-input = -}""
-      , {-out = -}""
-      , {-taglen = -} 16
-      , {-tag = -} "\x19\x7b\x9c\x3c\x44\x1d\x3c\x83\xea\xfb\x2b\xef\x63\x3b\x91\x82")
-    , ( key1, nonce1
-      , "\x00\x01\x02\x03\x04\x05\x06\x07"
-      , "\x00\x01\x02\x03\x04\x05\x06\x07"
-      , "\x92\xb6\x57\x13\x0a\x74\xb8\x5a"
-      , 16
-      , "\x16\xdc\x76\xa4\x6d\x47\xe1\xea\xd5\x37\x20\x9e\x8a\x96\xd1\x4e")
-    , ( key1, nonce1
-      , "\x00\x01\x02\x03\x04\x05\x06\x07"
-      , ""
-      , ""
-      , 16
-      , "\x98\xb9\x15\x52\xc8\xc0\x09\x18\x50\x44\xe3\x0a\x6e\xb2\xfe\x21")
-    , ( key1, nonce1
-      , ""
-      , "\x00\x01\x02\x03\x04\x05\x06\x07"
-      , "\x92\xb6\x57\x13\x0a\x74\xb8\x5a"
-      , 16
-      , "\x97\x1e\xff\xca\xe1\x9a\xd4\x71\x6f\x88\xe8\x7b\x87\x1f\xbe\xed")
-    , ( key1, nonce1
-      , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
-      , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
-      , "\xbe\xa5\xe8\x79\x8d\xbe\x71\x10\x03\x1c\x14\x4d\xa0\xb2\x61\x22"
-      , 16
-      , "\x77\x6c\x99\x24\xd6\x72\x3a\x1f\xc4\x52\x45\x32\xac\x3e\x5b\xeb")
+    [
+        ( {-key = -} key1
+        , {-iv = -} nonce1
+        , {-aad = -} ""
+        , {-input = -} ""
+        , {-out = -} ""
+        , {-taglen = -} 16
+        , {-tag = -} "\x19\x7b\x9c\x3c\x44\x1d\x3c\x83\xea\xfb\x2b\xef\x63\x3b\x91\x82"
+        )
+    ,
+        ( key1
+        , nonce1
+        , "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , "\x92\xb6\x57\x13\x0a\x74\xb8\x5a"
+        , 16
+        , "\x16\xdc\x76\xa4\x6d\x47\xe1\xea\xd5\x37\x20\x9e\x8a\x96\xd1\x4e"
+        )
+    ,
+        ( key1
+        , nonce1
+        , "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , ""
+        , ""
+        , 16
+        , "\x98\xb9\x15\x52\xc8\xc0\x09\x18\x50\x44\xe3\x0a\x6e\xb2\xfe\x21"
+        )
+    ,
+        ( key1
+        , nonce1
+        , ""
+        , "\x00\x01\x02\x03\x04\x05\x06\x07"
+        , "\x92\xb6\x57\x13\x0a\x74\xb8\x5a"
+        , 16
+        , "\x97\x1e\xff\xca\xe1\x9a\xd4\x71\x6f\x88\xe8\x7b\x87\x1f\xbe\xed"
+        )
+    ,
+        ( key1
+        , nonce1
+        , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+        , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+        , "\xbe\xa5\xe8\x79\x8d\xbe\x71\x10\x03\x1c\x14\x4d\xa0\xb2\x61\x22"
+        , 16
+        , "\x77\x6c\x99\x24\xd6\x72\x3a\x1f\xc4\x52\x45\x32\xac\x3e\x5b\xeb"
+        )
     ]
diff --git a/tests/KAT_AES/KATXTS.hs b/tests/KAT_AES/KATXTS.hs
--- a/tests/KAT_AES/KATXTS.hs
+++ b/tests/KAT_AES/KATXTS.hs
@@ -1,12 +1,24 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_AES.KATXTS where
 
 import qualified Data.ByteString as B
 import Data.ByteString.Char8 ()
 
-type KATXTS = (B.ByteString, B.ByteString, B.ByteString, B.ByteString, B.ByteString, B.ByteString)
+type KATXTS =
+    ( B.ByteString
+    , B.ByteString
+    , B.ByteString
+    , B.ByteString
+    , B.ByteString
+    , B.ByteString
+    )
 
-vectors_aes128_enc, vectors_aes128_dec, vectors_aes256_enc, vectors_aes256_dec :: [KATXTS]
+vectors_aes128_enc
+    , vectors_aes128_dec
+    , vectors_aes256_enc
+    , vectors_aes256_dec
+        :: [KATXTS]
 vectors_aes128_enc =
     [
         ( "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@@ -41,10 +53,8 @@
         , "\x27\xa7\x47\x9b\xef\xa1\xd4\x76\x48\x9f\x30\x8c\xd4\xcf\xa6\xe2\xa9\x6e\x4b\xbe\x32\x08\xff\x25\x28\x7d\xd3\x81\x96\x16\xe8\x9c\xc7\x8c\xf7\xf5\xe5\x43\x44\x5f\x83\x33\xd8\xfa\x7f\x56\x00\x00\x05\x27\x9f\xa5\xd8\xb5\xe4\xad\x40\xe7\x36\xdd\xb4\xd3\x54\x12\x32\x80\x63\xfd\x2a\xab\x53\xe5\xea\x1e\x0a\x9f\x33\x25\x00\xa5\xdf\x94\x87\xd0\x7a\x5c\x92\xcc\x51\x2c\x88\x66\xc7\xe8\x60\xce\x93\xfd\xf1\x66\xa2\x49\x12\xb4\x22\x97\x61\x46\xae\x20\xce\x84\x6b\xb7\xdc\x9b\xa9\x4a\x76\x7a\xae\xf2\x0c\x0d\x61\xad\x02\x65\x5e\xa9\x2d\xc4\xc4\xe4\x1a\x89\x52\xc6\x51\xd3\x31\x74\xbe\x51\xa1\x0c\x42\x11\x10\xe6\xd8\x15\x88\xed\xe8\x21\x03\xa2\x52\xd8\xa7\x50\xe8\x76\x8d\xef\xff\xed\x91\x22\x81\x0a\xae\xb9\x9f\x91\x72\xaf\x82\xb6\x04\xdc\x4b\x8e\x51\xbc\xb0\x82\x35\xa6\xf4\x34\x13\x32\xe4\xca\x60\x48\x2a\x4b\xa1\xa0\x3b\x3e\x65\x00\x8f\xc5\xda\x76\xb7\x0b\xf1\x69\x0d\xb4\xea\xe2\x9c\x5f\x1b\xad\xd0\x3c\x5c\xcf\x2a\x55\xd7\x05\xdd\xcd\x86\xd4\x49\x51\x1c\xeb\x7e\xc3\x0b\xf1\x2b\x1f\xa3\x5b\x91\x3f\x9f\x74\x7a\x8a\xfd\x1b\x13\x0e\x94\xbf\xf9\x4e\xff\xd0\x1a\x91\x73\x5c\xa1\x72\x6a\xcd\x0b\x19\x7c\x4e\x5b\x03\x39\x36\x97\xe1\x26\x82\x6f\xb6\xbb\xde\x8e\xcc\x1e\x08\x29\x85\x16\xe2\xc9\xed\x03\xff\x3c\x1b\x78\x60\xf6\xde\x76\xd4\xce\xcd\x94\xc8\x11\x98\x55\xef\x52\x97\xca\x67\xe9\xf3\xe7\xff\x72\xb1\xe9\x97\x85\xca\x0a\x7e\x77\x20\xc5\xb3\x6d\xc6\xd7\x2c\xac\x95\x74\xc8\xcb\xbc\x2f\x80\x1e\x23\xe5\x6f\xd3\x44\xb0\x7f\x22\x15\x4b\xeb\xa0\xf0\x8c\xe8\x89\x1e\x64\x3e\xd9\x95\xc9\x4d\x9a\x69\xc9\xf1\xb5\xf4\x99\x02\x7a\x78\x57\x2a\xee\xbd\x74\xd2\x0c\xc3\x98\x81\xc2\x13\xee\x77\x0b\x10\x10\xe4\xbe\xa7\x18\x84\x69\x77\xae\x11\x9f\x7a\x02\x3a\xb5\x8c\xca\x0a\xd7\x52\xaf\xe6\x56\xbb\x3c\x17\x25\x6a\x9f\x6e\x9b\xf1\x9f\xdd\x5a\x38\xfc\x82\xbb\xe8\x72\xc5\x53\x9e\xdb\x60\x9e\xf4\xf7\x9c\x20\x3e\xbb\x14\x0f\x2e\x58\x3c\xb2\xad\x15\xb4\xaa\x5b\x65\x50\x16\xa8\x44\x92\x77\xdb\xd4\x77\xef\x2c\x8d\x6c\x01\x7d\xb7\x38\xb1\x8d\xeb\x4a\x42\x7d\x19\x23\xce\x3f\xf2\x62\x73\x57\x79\xa4\x18\xf2\x0a\x28\x2d\xf9\x20\x14\x7b\xea\xbe\x42\x1e\xe5\x31\x9d\x05\x68"
         )
     ]
-
 vectors_aes128_dec =
     []
-
 vectors_aes256_enc =
     [
         ( "\x27\x18\x28\x18\x28\x45\x90\x45\x23\x53\x60\x28\x74\x71\x35\x26\x62\x49\x77\x57\x24\x70\x93\x69\x99\x59\x57\x49\x66\x96\x76\x27"
@@ -55,5 +65,4 @@
         , "\x1c\x3b\x3a\x10\x2f\x77\x03\x86\xe4\x83\x6c\x99\xe3\x70\xcf\x9b\xea\x00\x80\x3f\x5e\x48\x23\x57\xa4\xae\x12\xd4\x14\xa3\xe6\x3b\x5d\x31\xe2\x76\xf8\xfe\x4a\x8d\x66\xb3\x17\xf9\xac\x68\x3f\x44\x68\x0a\x86\xac\x35\xad\xfc\x33\x45\xbe\xfe\xcb\x4b\xb1\x88\xfd\x57\x76\x92\x6c\x49\xa3\x09\x5e\xb1\x08\xfd\x10\x98\xba\xec\x70\xaa\xa6\x69\x99\xa7\x2a\x82\xf2\x7d\x84\x8b\x21\xd4\xa7\x41\xb0\xc5\xcd\x4d\x5f\xff\x9d\xac\x89\xae\xba\x12\x29\x61\xd0\x3a\x75\x71\x23\xe9\x87\x0f\x8a\xcf\x10\x00\x02\x08\x87\x89\x14\x29\xca\x2a\x3e\x7a\x7d\x7d\xf7\xb1\x03\x55\x16\x5c\x8b\x9a\x6d\x0a\x7d\xe8\xb0\x62\xc4\x50\x0d\xc4\xcd\x12\x0c\x0f\x74\x18\xda\xe3\xd0\xb5\x78\x1c\x34\x80\x3f\xa7\x54\x21\xc7\x90\xdf\xe1\xde\x18\x34\xf2\x80\xd7\x66\x7b\x32\x7f\x6c\x8c\xd7\x55\x7e\x12\xac\x3a\x0f\x93\xec\x05\xc5\x2e\x04\x93\xef\x31\xa1\x2d\x3d\x92\x60\xf7\x9a\x28\x9d\x6a\x37\x9b\xc7\x0c\x50\x84\x14\x73\xd1\xa8\xcc\x81\xec\x58\x3e\x96\x45\xe0\x7b\x8d\x96\x70\x65\x5b\xa5\xbb\xcf\xec\xc6\xdc\x39\x66\x38\x0a\xd8\xfe\xcb\x17\xb6\xba\x02\x46\x9a\x02\x0a\x84\xe1\x8e\x8f\x84\x25\x20\x70\xc1\x3e\x9f\x1f\x28\x9b\xe5\x4f\xbc\x48\x14\x57\x77\x8f\x61\x60\x15\xe1\x32\x7a\x02\xb1\x40\xf1\x50\x5e\xb3\x09\x32\x6d\x68\x37\x8f\x83\x74\x59\x5c\x84\x9d\x84\xf4\xc3\x33\xec\x44\x23\x88\x51\x43\xcb\x47\xbd\x71\xc5\xed\xae\x9b\xe6\x9a\x2f\xfe\xce\xb1\xbe\xc9\xde\x24\x4f\xbe\x15\x99\x2b\x11\xb7\x7c\x04\x0f\x12\xbd\x8f\x6a\x97\x5a\x44\xa0\xf9\x0c\x29\xa9\xab\xc3\xd4\xd8\x93\x92\x72\x84\xc5\x87\x54\xcc\xe2\x94\x52\x9f\x86\x14\xdc\xd2\xab\xa9\x91\x92\x5f\xed\xc4\xae\x74\xff\xac\x6e\x33\x3b\x93\xeb\x4a\xff\x04\x79\xda\x9a\x41\x0e\x44\x50\xe0\xdd\x7a\xe4\xc6\xe2\x91\x09\x00\x57\x5d\xa4\x01\xfc\x07\x05\x9f\x64\x5e\x8b\x7e\x9b\xfd\xef\x33\x94\x30\x54\xff\x84\x01\x14\x93\xc2\x7b\x34\x29\xea\xed\xb4\xed\x53\x76\x44\x1a\x77\xed\x43\x85\x1a\xd7\x7f\x16\xf5\x41\xdf\xd2\x69\xd5\x0d\x6a\x5f\x14\xfb\x0a\xab\x1c\xbb\x4c\x15\x50\xbe\x97\xf7\xab\x40\x66\x19\x3c\x4c\xaa\x77\x3d\xad\x38\x01\x4b\xd2\x09\x2f\xa7\x55\xc8\x24\xbb\x5e\x54\xc4\xf3\x6f\xfd\xa9\xfc\xea\x70\xb9\xc6\xe6\x93\xe1\x48\xc1\x51"
         )
     ]
-
 vectors_aes256_dec = []
diff --git a/tests/KAT_AESGCMSIV.hs b/tests/KAT_AESGCMSIV.hs
--- a/tests/KAT_AESGCMSIV.hs
+++ b/tests/KAT_AESGCMSIV.hs
@@ -2,12 +2,13 @@
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE Rank2Types #-}
 {-# LANGUAGE RecordWildCards #-}
+
 module KAT_AESGCMSIV (tests) where
 
 import Imports
 
-import Data.Proxy
 import qualified Data.ByteArray as B
+import Data.Proxy
 
 import Crypto.Cipher.AES
 import Crypto.Cipher.AESGCMSIV
@@ -15,11 +16,11 @@
 import Crypto.Error
 
 data Vector c = Vector
-    { vecPlaintext  :: ByteString
-    , vecAAD        :: ByteString
-    , vecKey        :: ByteString
-    , vecNonce      :: ByteString
-    , vecTag        :: ByteString
+    { vecPlaintext :: ByteString
+    , vecAAD :: ByteString
+    , vecKey :: ByteString
+    , vecNonce :: ByteString
+    , vecTag :: ByteString
     , vecCiphertext :: ByteString
     }
 
@@ -29,412 +30,576 @@
 vectors128 :: [Vector AES128]
 vectors128 =
     [ Vector
-        { vecPlaintext  = ""
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xdc\x20\xe2\xd8\x3f\x25\x70\x5b\xb4\x9e\x43\x9e\xca\x56\xde\x25"
+        { vecPlaintext = ""
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xdc\x20\xe2\xd8\x3f\x25\x70\x5b\xb4\x9e\x43\x9e\xca\x56\xde\x25"
         , vecCiphertext = ""
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x57\x87\x82\xff\xf6\x01\x3b\x81\x5b\x28\x7c\x22\x49\x3a\x36\x4c"
+        { vecPlaintext = "\x01\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x57\x87\x82\xff\xf6\x01\x3b\x81\x5b\x28\x7c\x22\x49\x3a\x36\x4c"
         , vecCiphertext = "\xb5\xd8\x39\x33\x0a\xc7\xb7\x86"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xa4\x97\x8d\xb3\x57\x39\x1a\x0b\xc4\xfd\xec\x8b\x0d\x10\x66\x39"
+        { vecPlaintext = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xa4\x97\x8d\xb3\x57\x39\x1a\x0b\xc4\xfd\xec\x8b\x0d\x10\x66\x39"
         , vecCiphertext = "\x73\x23\xea\x61\xd0\x59\x32\x26\x00\x47\xd9\x42"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x30\x3a\xaf\x90\xf6\xfe\x21\x19\x9c\x60\x68\x57\x74\x37\xa0\xc4"
-        , vecCiphertext = "\x74\x3f\x7c\x80\x77\xab\x25\xf8\x62\x4e\x2e\x94\x85\x79\xcf\x77"
+        { vecPlaintext =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x30\x3a\xaf\x90\xf6\xfe\x21\x19\x9c\x60\x68\x57\x74\x37\xa0\xc4"
+        , vecCiphertext =
+            "\x74\x3f\x7c\x80\x77\xab\x25\xf8\x62\x4e\x2e\x94\x85\x79\xcf\x77"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x1a\x8e\x45\xdc\xd4\x57\x8c\x66\x7c\xd8\x68\x47\xbf\x61\x55\xff"
-        , vecCiphertext = "\x84\xe0\x7e\x62\xba\x83\xa6\x58\x54\x17\x24\x5d\x7e\xc4\x13\xa9\xfe\x42\x7d\x63\x15\xc0\x9b\x57\xce\x45\xf2\xe3\x93\x6a\x94\x45"
+        { vecPlaintext =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x1a\x8e\x45\xdc\xd4\x57\x8c\x66\x7c\xd8\x68\x47\xbf\x61\x55\xff"
+        , vecCiphertext =
+            "\x84\xe0\x7e\x62\xba\x83\xa6\x58\x54\x17\x24\x5d\x7e\xc4\x13\xa9\xfe\x42\x7d\x63\x15\xc0\x9b\x57\xce\x45\xf2\xe3\x93\x6a\x94\x45"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x5e\x6e\x31\x1d\xbf\x39\x5d\x35\xb0\xfe\x39\xc2\x71\x43\x88\xf8"
-        , vecCiphertext = "\x3f\xd2\x4c\xe1\xf5\xa6\x7b\x75\xbf\x23\x51\xf1\x81\xa4\x75\xc7\xb8\x00\xa5\xb4\xd3\xdc\xf7\x01\x06\xb1\xee\xa8\x2f\xa1\xd6\x4d\xf4\x2b\xf7\x22\x61\x22\xfa\x92\xe1\x7a\x40\xee\xaa\xc1\x20\x1b"
+        { vecPlaintext =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x5e\x6e\x31\x1d\xbf\x39\x5d\x35\xb0\xfe\x39\xc2\x71\x43\x88\xf8"
+        , vecCiphertext =
+            "\x3f\xd2\x4c\xe1\xf5\xa6\x7b\x75\xbf\x23\x51\xf1\x81\xa4\x75\xc7\xb8\x00\xa5\xb4\xd3\xdc\xf7\x01\x06\xb1\xee\xa8\x2f\xa1\xd6\x4d\xf4\x2b\xf7\x22\x61\x22\xfa\x92\xe1\x7a\x40\xee\xaa\xc1\x20\x1b"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x8a\x26\x3d\xd3\x17\xaa\x88\xd5\x6b\xdf\x39\x36\xdb\xa7\x5b\xb8"
-        , vecCiphertext = "\x24\x33\x66\x8f\x10\x58\x19\x0f\x6d\x43\xe3\x60\xf4\xf3\x5c\xd8\xe4\x75\x12\x7c\xfc\xa7\x02\x8e\xa8\xab\x5c\x20\xf7\xab\x2a\xf0\x25\x16\xa2\xbd\xcb\xc0\x8d\x52\x1b\xe3\x7f\xf2\x8c\x15\x2b\xba\x36\x69\x7f\x25\xb4\xcd\x16\x9c\x65\x90\xd1\xdd\x39\x56\x6d\x3f"
+        { vecPlaintext =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x8a\x26\x3d\xd3\x17\xaa\x88\xd5\x6b\xdf\x39\x36\xdb\xa7\x5b\xb8"
+        , vecCiphertext =
+            "\x24\x33\x66\x8f\x10\x58\x19\x0f\x6d\x43\xe3\x60\xf4\xf3\x5c\xd8\xe4\x75\x12\x7c\xfc\xa7\x02\x8e\xa8\xab\x5c\x20\xf7\xab\x2a\xf0\x25\x16\xa2\xbd\xcb\xc0\x8d\x52\x1b\xe3\x7f\xf2\x8c\x15\x2b\xba\x36\x69\x7f\x25\xb4\xcd\x16\x9c\x65\x90\xd1\xdd\x39\x56\x6d\x3f"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x3b\x0a\x1a\x25\x60\x96\x9c\xdf\x79\x0d\x99\x75\x9a\xbd\x15\x08"
+        { vecPlaintext = "\x02\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x3b\x0a\x1a\x25\x60\x96\x9c\xdf\x79\x0d\x99\x75\x9a\xbd\x15\x08"
         , vecCiphertext = "\x1e\x6d\xab\xa3\x56\x69\xf4\x27"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x08\x29\x9c\x51\x02\x74\x5a\xaa\x3a\x0c\x46\x9f\xad\x9e\x07\x5a"
+        { vecPlaintext = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x08\x29\x9c\x51\x02\x74\x5a\xaa\x3a\x0c\x46\x9f\xad\x9e\x07\x5a"
         , vecCiphertext = "\x29\x6c\x78\x89\xfd\x99\xf4\x19\x17\xf4\x46\x20"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x8f\x89\x36\xec\x03\x9e\x4e\x4b\xb9\x7e\xbd\x8c\x44\x57\x44\x1f"
-        , vecCiphertext = "\xe2\xb0\xc5\xda\x79\xa9\x01\xc1\x74\x5f\x70\x05\x25\xcb\x33\x5b"
+        { vecPlaintext =
+            "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x8f\x89\x36\xec\x03\x9e\x4e\x4b\xb9\x7e\xbd\x8c\x44\x57\x44\x1f"
+        , vecCiphertext =
+            "\xe2\xb0\xc5\xda\x79\xa9\x01\xc1\x74\x5f\x70\x05\x25\xcb\x33\x5b"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xe6\xaf\x6a\x7f\x87\x28\x7d\xa0\x59\xa7\x16\x84\xed\x34\x98\xe1"
-        , vecCiphertext = "\x62\x00\x48\xef\x3c\x1e\x73\xe5\x7e\x02\xbb\x85\x62\xc4\x16\xa3\x19\xe7\x3e\x4c\xaa\xc8\xe9\x6a\x1e\xcb\x29\x33\x14\x5a\x1d\x71"
+        { vecPlaintext =
+            "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xe6\xaf\x6a\x7f\x87\x28\x7d\xa0\x59\xa7\x16\x84\xed\x34\x98\xe1"
+        , vecCiphertext =
+            "\x62\x00\x48\xef\x3c\x1e\x73\xe5\x7e\x02\xbb\x85\x62\xc4\x16\xa3\x19\xe7\x3e\x4c\xaa\xc8\xe9\x6a\x1e\xcb\x29\x33\x14\x5a\x1d\x71"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x6a\x8c\xc3\x86\x5f\x76\x89\x7c\x2e\x4b\x24\x5c\xf3\x1c\x51\xf2"
-        , vecCiphertext = "\x50\xc8\x30\x3e\xa9\x39\x25\xd6\x40\x90\xd0\x7b\xd1\x09\xdf\xd9\x51\x5a\x5a\x33\x43\x10\x19\xc1\x7d\x93\x46\x59\x99\xa8\xb0\x05\x32\x01\xd7\x23\x12\x0a\x85\x62\xb8\x38\xcd\xff\x25\xbf\x9d\x1e"
+        { vecPlaintext =
+            "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x6a\x8c\xc3\x86\x5f\x76\x89\x7c\x2e\x4b\x24\x5c\xf3\x1c\x51\xf2"
+        , vecCiphertext =
+            "\x50\xc8\x30\x3e\xa9\x39\x25\xd6\x40\x90\xd0\x7b\xd1\x09\xdf\xd9\x51\x5a\x5a\x33\x43\x10\x19\xc1\x7d\x93\x46\x59\x99\xa8\xb0\x05\x32\x01\xd7\x23\x12\x0a\x85\x62\xb8\x38\xcd\xff\x25\xbf\x9d\x1e"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xcd\xc4\x6a\xe4\x75\x56\x3d\xe0\x37\x00\x1e\xf8\x4a\xe2\x17\x44"
-        , vecCiphertext = "\x2f\x5c\x64\x05\x9d\xb5\x5e\xe0\xfb\x84\x7e\xd5\x13\x00\x37\x46\xac\xa4\xe6\x1c\x71\x1b\x5d\xe2\xe7\xa7\x7f\xfd\x02\xda\x42\xfe\xec\x60\x19\x10\xd3\x46\x7b\xb8\xb3\x6e\xbb\xae\xbc\xe5\xfb\xa3\x0d\x36\xc9\x5f\x48\xa3\xe7\x98\x0f\x0e\x7a\xc2\x99\x33\x2a\x80"
+        { vecPlaintext =
+            "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xcd\xc4\x6a\xe4\x75\x56\x3d\xe0\x37\x00\x1e\xf8\x4a\xe2\x17\x44"
+        , vecCiphertext =
+            "\x2f\x5c\x64\x05\x9d\xb5\x5e\xe0\xfb\x84\x7e\xd5\x13\x00\x37\x46\xac\xa4\xe6\x1c\x71\x1b\x5d\xe2\xe7\xa7\x7f\xfd\x02\xda\x42\xfe\xec\x60\x19\x10\xd3\x46\x7b\xb8\xb3\x6e\xbb\xae\xbc\xe5\xfb\xa3\x0d\x36\xc9\x5f\x48\xa3\xe7\x98\x0f\x0e\x7a\xc2\x99\x33\x2a\x80"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00"
-        , vecAAD        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x07\xeb\x1f\x84\xfb\x28\xf8\xcb\x73\xde\x8e\x99\xe2\xf4\x8a\x14"
+        { vecPlaintext = "\x02\x00\x00\x00"
+        , vecAAD = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x07\xeb\x1f\x84\xfb\x28\xf8\xcb\x73\xde\x8e\x99\xe2\xf4\x8a\x14"
         , vecCiphertext = "\xa8\xfe\x3e\x87"
         }
     , Vector
-        { vecPlaintext  = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00"
-        , vecAAD        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x24\xaf\xc9\x80\x5e\x97\x6f\x45\x1e\x6d\x87\xf6\xfe\x10\x65\x14"
-        , vecCiphertext = "\x6b\xb0\xfe\xcf\x5d\xed\x9b\x77\xf9\x02\xc7\xd5\xda\x23\x6a\x43\x91\xdd\x02\x97"
+        { vecPlaintext =
+            "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00"
+        , vecAAD =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x24\xaf\xc9\x80\x5e\x97\x6f\x45\x1e\x6d\x87\xf6\xfe\x10\x65\x14"
+        , vecCiphertext =
+            "\x6b\xb0\xfe\xcf\x5d\xed\x9b\x77\xf9\x02\xc7\xd5\xda\x23\x6a\x43\x91\xdd\x02\x97"
         }
     , Vector
-        { vecPlaintext  = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00"
-        , vecAAD        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xbf\xf9\xb2\xef\x00\xfb\x47\x92\x0c\xc7\x2a\x0c\x0f\x13\xb9\xfd"
-        , vecCiphertext = "\x44\xd0\xaa\xf6\xfb\x2f\x1f\x34\xad\xd5\xe8\x06\x4e\x83\xe1\x2a\x2a\xda"
+        { vecPlaintext =
+            "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00"
+        , vecAAD =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xbf\xf9\xb2\xef\x00\xfb\x47\x92\x0c\xc7\x2a\x0c\x0f\x13\xb9\xfd"
+        , vecCiphertext =
+            "\x44\xd0\xaa\xf6\xfb\x2f\x1f\x34\xad\xd5\xe8\x06\x4e\x83\xe1\x2a\x2a\xda"
         }
     , Vector
-        { vecPlaintext  = ""
-        , vecAAD        = ""
-        , vecKey        = "\xe6\x60\x21\xd5\xeb\x8e\x4f\x40\x66\xd4\xad\xb9\xc3\x35\x60\xe4"
-        , vecNonce      = "\xf4\x6e\x44\xbb\x3d\xa0\x01\x5c\x94\xf7\x08\x87"
-        , vecTag        = "\xa4\x19\x4b\x79\x07\x1b\x01\xa8\x7d\x65\xf7\x06\xe3\x94\x95\x78"
+        { vecPlaintext = ""
+        , vecAAD = ""
+        , vecKey =
+            "\xe6\x60\x21\xd5\xeb\x8e\x4f\x40\x66\xd4\xad\xb9\xc3\x35\x60\xe4"
+        , vecNonce = "\xf4\x6e\x44\xbb\x3d\xa0\x01\x5c\x94\xf7\x08\x87"
+        , vecTag =
+            "\xa4\x19\x4b\x79\x07\x1b\x01\xa8\x7d\x65\xf7\x06\xe3\x94\x95\x78"
         , vecCiphertext = ""
         }
     , Vector
-        { vecPlaintext  = "\x7a\x80\x6c"
-        , vecAAD        = "\x46\xbb\x91\xc3\xc5"
-        , vecKey        = "\x36\x86\x42\x00\xe0\xea\xf5\x28\x4d\x88\x4a\x0e\x77\xd3\x16\x46"
-        , vecNonce      = "\xba\xe8\xe3\x7f\xc8\x34\x41\xb1\x60\x34\x56\x6b"
-        , vecTag        = "\x71\x1b\xd8\x5b\xc1\xe4\xd3\xe0\xa4\x62\xe0\x74\xee\xa4\x28\xa8"
+        { vecPlaintext = "\x7a\x80\x6c"
+        , vecAAD = "\x46\xbb\x91\xc3\xc5"
+        , vecKey =
+            "\x36\x86\x42\x00\xe0\xea\xf5\x28\x4d\x88\x4a\x0e\x77\xd3\x16\x46"
+        , vecNonce = "\xba\xe8\xe3\x7f\xc8\x34\x41\xb1\x60\x34\x56\x6b"
+        , vecTag =
+            "\x71\x1b\xd8\x5b\xc1\xe4\xd3\xe0\xa4\x62\xe0\x74\xee\xa4\x28\xa8"
         , vecCiphertext = "\xaf\x60\xeb"
         }
     , Vector
-        { vecPlaintext  = "\xbd\xc6\x6f\x14\x65\x45"
-        , vecAAD        = "\xfc\x88\x0c\x94\xa9\x51\x98\x87\x42\x96"
-        , vecKey        = "\xae\xdb\x64\xa6\xc5\x90\xbc\x84\xd1\xa5\xe2\x69\xe4\xb4\x78\x01"
-        , vecNonce      = "\xaf\xc0\x57\x7e\x34\x69\x9b\x9e\x67\x1f\xdd\x4f"
-        , vecTag        = "\xd6\xa9\xc4\x55\x45\xcf\xc1\x1f\x03\xad\x74\x3d\xba\x20\xf9\x66"
+        { vecPlaintext = "\xbd\xc6\x6f\x14\x65\x45"
+        , vecAAD = "\xfc\x88\x0c\x94\xa9\x51\x98\x87\x42\x96"
+        , vecKey =
+            "\xae\xdb\x64\xa6\xc5\x90\xbc\x84\xd1\xa5\xe2\x69\xe4\xb4\x78\x01"
+        , vecNonce = "\xaf\xc0\x57\x7e\x34\x69\x9b\x9e\x67\x1f\xdd\x4f"
+        , vecTag =
+            "\xd6\xa9\xc4\x55\x45\xcf\xc1\x1f\x03\xad\x74\x3d\xba\x20\xf9\x66"
         , vecCiphertext = "\xbb\x93\xa3\xe3\x4d\x3c"
         }
     , Vector
-        { vecPlaintext  = "\x11\x77\x44\x1f\x19\x54\x95\x86\x0f"
-        , vecAAD        = "\x04\x67\x87\xf3\xea\x22\xc1\x27\xaa\xf1\x95\xd1\x89\x47\x28"
-        , vecKey        = "\xd5\xcc\x1f\xd1\x61\x32\x0b\x69\x20\xce\x07\x78\x7f\x86\x74\x3b"
-        , vecNonce      = "\x27\x5d\x1a\xb3\x2f\x6d\x1f\x04\x34\xd8\x84\x8c"
-        , vecTag        = "\x1d\x02\xfd\x0c\xd1\x74\xc8\x4f\xc5\xda\xe2\xf6\x0f\x52\xfd\x2b"
+        { vecPlaintext = "\x11\x77\x44\x1f\x19\x54\x95\x86\x0f"
+        , vecAAD = "\x04\x67\x87\xf3\xea\x22\xc1\x27\xaa\xf1\x95\xd1\x89\x47\x28"
+        , vecKey =
+            "\xd5\xcc\x1f\xd1\x61\x32\x0b\x69\x20\xce\x07\x78\x7f\x86\x74\x3b"
+        , vecNonce = "\x27\x5d\x1a\xb3\x2f\x6d\x1f\x04\x34\xd8\x84\x8c"
+        , vecTag =
+            "\x1d\x02\xfd\x0c\xd1\x74\xc8\x4f\xc5\xda\xe2\xf6\x0f\x52\xfd\x2b"
         , vecCiphertext = "\x4f\x37\x28\x1f\x7a\xd1\x29\x49\xd0"
         }
     , Vector
-        { vecPlaintext  = "\x9f\x57\x2c\x61\x4b\x47\x45\x91\x44\x74\xe7\xc7"
-        , vecAAD        = "\xc9\x88\x2e\x53\x86\xfd\x9f\x92\xec\x48\x9c\x8f\xde\x2b\xe2\xcf\x97\xe7\x4e\x93"
-        , vecKey        = "\xb3\xfe\xd1\x47\x3c\x52\x8b\x84\x26\xa5\x82\x99\x59\x29\xa1\x49"
-        , vecNonce      = "\x9e\x9a\xd8\x78\x0c\x8d\x63\xd0\xab\x41\x49\xc0"
-        , vecTag        = "\xc1\xdc\x2f\x87\x1f\xb7\x56\x1d\xa1\x28\x6e\x65\x5e\x24\xb7\xb0"
+        { vecPlaintext = "\x9f\x57\x2c\x61\x4b\x47\x45\x91\x44\x74\xe7\xc7"
+        , vecAAD =
+            "\xc9\x88\x2e\x53\x86\xfd\x9f\x92\xec\x48\x9c\x8f\xde\x2b\xe2\xcf\x97\xe7\x4e\x93"
+        , vecKey =
+            "\xb3\xfe\xd1\x47\x3c\x52\x8b\x84\x26\xa5\x82\x99\x59\x29\xa1\x49"
+        , vecNonce = "\x9e\x9a\xd8\x78\x0c\x8d\x63\xd0\xab\x41\x49\xc0"
+        , vecTag =
+            "\xc1\xdc\x2f\x87\x1f\xb7\x56\x1d\xa1\x28\x6e\x65\x5e\x24\xb7\xb0"
         , vecCiphertext = "\xf5\x46\x73\xc5\xdd\xf7\x10\xc7\x45\x64\x1c\x8b"
         }
     , Vector
-        { vecPlaintext  = "\x0d\x8c\x84\x51\x17\x80\x82\x35\x5c\x9e\x94\x0f\xea\x2f\x58"
-        , vecAAD        = "\x29\x50\xa7\x0d\x5a\x1d\xb2\x31\x6f\xd5\x68\x37\x8d\xa1\x07\xb5\x2b\x0d\xa5\x52\x10\xcc\x1c\x1b\x0a"
-        , vecKey        = "\x2d\x4e\xd8\x7d\xa4\x41\x02\x95\x2e\xf9\x4b\x02\xb8\x05\x24\x9b"
-        , vecNonce      = "\xac\x80\xe6\xf6\x14\x55\xbf\xac\x83\x08\xa2\xd4"
-        , vecTag        = "\x83\xb3\x44\x9b\x9f\x39\x55\x2d\xe9\x9d\xc2\x14\xa1\x19\x0b\x0b"
+        { vecPlaintext = "\x0d\x8c\x84\x51\x17\x80\x82\x35\x5c\x9e\x94\x0f\xea\x2f\x58"
+        , vecAAD =
+            "\x29\x50\xa7\x0d\x5a\x1d\xb2\x31\x6f\xd5\x68\x37\x8d\xa1\x07\xb5\x2b\x0d\xa5\x52\x10\xcc\x1c\x1b\x0a"
+        , vecKey =
+            "\x2d\x4e\xd8\x7d\xa4\x41\x02\x95\x2e\xf9\x4b\x02\xb8\x05\x24\x9b"
+        , vecNonce = "\xac\x80\xe6\xf6\x14\x55\xbf\xac\x83\x08\xa2\xd4"
+        , vecTag =
+            "\x83\xb3\x44\x9b\x9f\x39\x55\x2d\xe9\x9d\xc2\x14\xa1\x19\x0b\x0b"
         , vecCiphertext = "\xc9\xff\x54\x5e\x07\xb8\x8a\x01\x5f\x05\xb2\x74\x54\x0a\xa1"
         }
     , Vector
-        { vecPlaintext  = "\x6b\x3d\xb4\xda\x3d\x57\xaa\x94\x84\x2b\x98\x03\xa9\x6e\x07\xfb\x6d\xe7"
-        , vecAAD        = "\x18\x60\xf7\x62\xeb\xfb\xd0\x82\x84\xe4\x21\x70\x2d\xe0\xde\x18\xba\xa9\xc9\x59\x62\x91\xb0\x84\x66\xf3\x7d\xe2\x1c\x7f"
-        , vecKey        = "\xbd\xe3\xb2\xf2\x04\xd1\xe9\xf8\xb0\x6b\xc4\x7f\x97\x45\xb3\xd1"
-        , vecNonce      = "\xae\x06\x55\x6f\xb6\xaa\x78\x90\xbe\xbc\x18\xfe"
-        , vecTag        = "\x3e\x37\x70\x94\xf0\x47\x09\xf6\x4d\x7b\x98\x53\x10\xa4\xdb\x84"
-        , vecCiphertext = "\x62\x98\xb2\x96\xe2\x4e\x8c\xc3\x5d\xce\x0b\xed\x48\x4b\x7f\x30\xd5\x80"
+        { vecPlaintext =
+            "\x6b\x3d\xb4\xda\x3d\x57\xaa\x94\x84\x2b\x98\x03\xa9\x6e\x07\xfb\x6d\xe7"
+        , vecAAD =
+            "\x18\x60\xf7\x62\xeb\xfb\xd0\x82\x84\xe4\x21\x70\x2d\xe0\xde\x18\xba\xa9\xc9\x59\x62\x91\xb0\x84\x66\xf3\x7d\xe2\x1c\x7f"
+        , vecKey =
+            "\xbd\xe3\xb2\xf2\x04\xd1\xe9\xf8\xb0\x6b\xc4\x7f\x97\x45\xb3\xd1"
+        , vecNonce = "\xae\x06\x55\x6f\xb6\xaa\x78\x90\xbe\xbc\x18\xfe"
+        , vecTag =
+            "\x3e\x37\x70\x94\xf0\x47\x09\xf6\x4d\x7b\x98\x53\x10\xa4\xdb\x84"
+        , vecCiphertext =
+            "\x62\x98\xb2\x96\xe2\x4e\x8c\xc3\x5d\xce\x0b\xed\x48\x4b\x7f\x30\xd5\x80"
         }
     , Vector
-        { vecPlaintext  = "\xe4\x2a\x3c\x02\xc2\x5b\x64\x86\x9e\x14\x6d\x7b\x23\x39\x87\xbd\xdf\xc2\x40\x87\x1d"
-        , vecAAD        = "\x75\x76\xf7\x02\x8e\xc6\xeb\x5e\xa7\xe2\x98\x34\x2a\x94\xd4\xb2\x02\xb3\x70\xef\x97\x68\xec\x65\x61\xc4\xfe\x6b\x7e\x72\x96\xfa\x85\x9c\x21"
-        , vecKey        = "\xf9\x01\xcf\xe8\xa6\x96\x15\xa9\x3f\xdf\x7a\x98\xca\xd4\x81\x79"
-        , vecNonce      = "\x62\x45\x70\x9f\xb1\x88\x53\xf6\x8d\x83\x36\x40"
-        , vecTag        = "\x2d\x15\x50\x6c\x84\xa9\xed\xd6\x5e\x13\xe9\xd2\x4a\x2a\x6e\x70"
-        , vecCiphertext = "\x39\x1c\xc3\x28\xd4\x84\xa4\xf4\x64\x06\x18\x1b\xcd\x62\xef\xd9\xb3\xee\x19\x7d\x05"
+        { vecPlaintext =
+            "\xe4\x2a\x3c\x02\xc2\x5b\x64\x86\x9e\x14\x6d\x7b\x23\x39\x87\xbd\xdf\xc2\x40\x87\x1d"
+        , vecAAD =
+            "\x75\x76\xf7\x02\x8e\xc6\xeb\x5e\xa7\xe2\x98\x34\x2a\x94\xd4\xb2\x02\xb3\x70\xef\x97\x68\xec\x65\x61\xc4\xfe\x6b\x7e\x72\x96\xfa\x85\x9c\x21"
+        , vecKey =
+            "\xf9\x01\xcf\xe8\xa6\x96\x15\xa9\x3f\xdf\x7a\x98\xca\xd4\x81\x79"
+        , vecNonce = "\x62\x45\x70\x9f\xb1\x88\x53\xf6\x8d\x83\x36\x40"
+        , vecTag =
+            "\x2d\x15\x50\x6c\x84\xa9\xed\xd6\x5e\x13\xe9\xd2\x4a\x2a\x6e\x70"
+        , vecCiphertext =
+            "\x39\x1c\xc3\x28\xd4\x84\xa4\xf4\x64\x06\x18\x1b\xcd\x62\xef\xd9\xb3\xee\x19\x7d\x05"
         }
     ]
 
 vectors256 :: [Vector AES256]
 vectors256 =
     [ Vector
-        { vecPlaintext  = ""
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x07\xf5\xf4\x16\x9b\xbf\x55\xa8\x40\x0c\xd4\x7e\xa6\xfd\x40\x0f"
+        { vecPlaintext = ""
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x07\xf5\xf4\x16\x9b\xbf\x55\xa8\x40\x0c\xd4\x7e\xa6\xfd\x40\x0f"
         , vecCiphertext = ""
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x84\x31\x22\x13\x0f\x73\x64\xb7\x61\xe0\xb9\x74\x27\xe3\xdf\x28"
+        { vecPlaintext = "\x01\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x84\x31\x22\x13\x0f\x73\x64\xb7\x61\xe0\xb9\x74\x27\xe3\xdf\x28"
         , vecCiphertext = "\xc2\xef\x32\x8e\x5c\x71\xc8\x3b"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x8c\xa5\x0d\xa9\xae\x65\x59\xe4\x8f\xd1\x0f\x6e\x5c\x9c\xa1\x7e"
+        { vecPlaintext = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x8c\xa5\x0d\xa9\xae\x65\x59\xe4\x8f\xd1\x0f\x6e\x5c\x9c\xa1\x7e"
         , vecCiphertext = "\x9a\xab\x2a\xeb\x3f\xaa\x0a\x34\xae\xa8\xe2\xb1"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xc9\xea\xc6\xfa\x70\x09\x42\x70\x2e\x90\x86\x23\x83\xc6\xc3\x66"
-        , vecCiphertext = "\x85\xa0\x1b\x63\x02\x5b\xa1\x9b\x7f\xd3\xdd\xfc\x03\x3b\x3e\x76"
+        { vecPlaintext =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xc9\xea\xc6\xfa\x70\x09\x42\x70\x2e\x90\x86\x23\x83\xc6\xc3\x66"
+        , vecCiphertext =
+            "\x85\xa0\x1b\x63\x02\x5b\xa1\x9b\x7f\xd3\xdd\xfc\x03\x3b\x3e\x76"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xe8\x19\xe6\x3a\xbc\xd0\x20\xb0\x06\xa9\x76\x39\x76\x32\xeb\x5d"
-        , vecCiphertext = "\x4a\x6a\x9d\xb4\xc8\xc6\x54\x92\x01\xb9\xed\xb5\x30\x06\xcb\xa8\x21\xec\x9c\xf8\x50\x94\x8a\x7c\x86\xc6\x8a\xc7\x53\x9d\x02\x7f"
+        { vecPlaintext =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xe8\x19\xe6\x3a\xbc\xd0\x20\xb0\x06\xa9\x76\x39\x76\x32\xeb\x5d"
+        , vecCiphertext =
+            "\x4a\x6a\x9d\xb4\xc8\xc6\x54\x92\x01\xb9\xed\xb5\x30\x06\xcb\xa8\x21\xec\x9c\xf8\x50\x94\x8a\x7c\x86\xc6\x8a\xc7\x53\x9d\x02\x7f"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x79\x0b\xc9\x68\x80\xa9\x9b\xa8\x04\xbd\x12\xc0\xe6\xa2\x2c\xc4"
-        , vecCiphertext = "\xc0\x0d\x12\x18\x93\xa9\xfa\x60\x3f\x48\xcc\xc1\xca\x3c\x57\xce\x74\x99\x24\x5e\xa0\x04\x6d\xb1\x6c\x53\xc7\xc6\x6f\xe7\x17\xe3\x9c\xf6\xc7\x48\x83\x7b\x61\xf6\xee\x3a\xdc\xee\x17\x53\x4e\xd5"
+        { vecPlaintext =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x79\x0b\xc9\x68\x80\xa9\x9b\xa8\x04\xbd\x12\xc0\xe6\xa2\x2c\xc4"
+        , vecCiphertext =
+            "\xc0\x0d\x12\x18\x93\xa9\xfa\x60\x3f\x48\xcc\xc1\xca\x3c\x57\xce\x74\x99\x24\x5e\xa0\x04\x6d\xb1\x6c\x53\xc7\xc6\x6f\xe7\x17\xe3\x9c\xf6\xc7\x48\x83\x7b\x61\xf6\xee\x3a\xdc\xee\x17\x53\x4e\xd5"
         }
     , Vector
-        { vecPlaintext  = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x11\x28\x64\xc2\x69\xfc\x0d\x9d\x88\xc6\x1f\xa4\x7e\x39\xaa\x08"
-        , vecCiphertext = "\xc2\xd5\x16\x0a\x1f\x86\x83\x83\x49\x10\xac\xda\xfc\x41\xfb\xb1\x63\x2d\x4a\x35\x3e\x8b\x90\x5e\xc9\xa5\x49\x9a\xc3\x4f\x96\xc7\xe1\x04\x9e\xb0\x80\x88\x38\x91\xa4\xdb\x8c\xaa\xa1\xf9\x9d\xd0\x04\xd8\x04\x87\x54\x07\x35\x23\x4e\x37\x44\x51\x2c\x6f\x90\xce"
+        { vecPlaintext =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x11\x28\x64\xc2\x69\xfc\x0d\x9d\x88\xc6\x1f\xa4\x7e\x39\xaa\x08"
+        , vecCiphertext =
+            "\xc2\xd5\x16\x0a\x1f\x86\x83\x83\x49\x10\xac\xda\xfc\x41\xfb\xb1\x63\x2d\x4a\x35\x3e\x8b\x90\x5e\xc9\xa5\x49\x9a\xc3\x4f\x96\xc7\xe1\x04\x9e\xb0\x80\x88\x38\x91\xa4\xdb\x8c\xaa\xa1\xf9\x9d\xd0\x04\xd8\x04\x87\x54\x07\x35\x23\x4e\x37\x44\x51\x2c\x6f\x90\xce"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x91\x21\x3f\x26\x7e\x3b\x45\x2f\x02\xd0\x1a\xe3\x3e\x4e\xc8\x54"
+        { vecPlaintext = "\x02\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x91\x21\x3f\x26\x7e\x3b\x45\x2f\x02\xd0\x1a\xe3\x3e\x4e\xc8\x54"
         , vecCiphertext = "\x1d\xe2\x29\x67\x23\x7a\x81\x32"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xc1\xa4\xa1\x9a\xe8\x00\x94\x1c\xcd\xc5\x7c\xc8\x41\x3c\x27\x7f"
+        { vecPlaintext = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xc1\xa4\xa1\x9a\xe8\x00\x94\x1c\xcd\xc5\x7c\xc8\x41\x3c\x27\x7f"
         , vecCiphertext = "\x16\x3d\x6f\x9c\xc1\xb3\x46\xcd\x45\x3a\x2e\x4c"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xb2\x92\xd2\x8f\xf6\x11\x89\xe8\xe4\x9f\x38\x75\xef\x91\xaf\xf7"
-        , vecCiphertext = "\xc9\x15\x45\x82\x3c\xc2\x4f\x17\xdb\xb0\xe9\xe8\x07\xd5\xec\x17"
+        { vecPlaintext =
+            "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xb2\x92\xd2\x8f\xf6\x11\x89\xe8\xe4\x9f\x38\x75\xef\x91\xaf\xf7"
+        , vecCiphertext =
+            "\xc9\x15\x45\x82\x3c\xc2\x4f\x17\xdb\xb0\xe9\xe8\x07\xd5\xec\x17"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xae\xa1\xba\xd1\x27\x02\xe1\x96\x56\x04\x37\x4a\xab\x96\xdb\xbc"
-        , vecCiphertext = "\x07\xda\xd3\x64\xbf\xc2\xb9\xda\x89\x11\x6d\x7b\xef\x6d\xaa\xaf\x6f\x25\x55\x10\xaa\x65\x4f\x92\x0a\xc8\x1b\x94\xe8\xba\xd3\x65"
+        { vecPlaintext =
+            "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xae\xa1\xba\xd1\x27\x02\xe1\x96\x56\x04\x37\x4a\xab\x96\xdb\xbc"
+        , vecCiphertext =
+            "\x07\xda\xd3\x64\xbf\xc2\xb9\xda\x89\x11\x6d\x7b\xef\x6d\xaa\xaf\x6f\x25\x55\x10\xaa\x65\x4f\x92\x0a\xc8\x1b\x94\xe8\xba\xd3\x65"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x03\x33\x27\x42\xb2\x28\xc6\x47\x17\x36\x16\xcf\xd4\x4c\x54\xeb"
-        , vecCiphertext = "\xc6\x7a\x1f\x0f\x56\x7a\x51\x98\xaa\x1f\xcc\x8e\x3f\x21\x31\x43\x36\xf7\xf5\x1c\xa8\xb1\xaf\x61\xfe\xac\x35\xa8\x64\x16\xfa\x47\xfb\xca\x3b\x5f\x74\x9c\xdf\x56\x45\x27\xf2\x31\x4f\x42\xfe\x25"
+        { vecPlaintext =
+            "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x03\x33\x27\x42\xb2\x28\xc6\x47\x17\x36\x16\xcf\xd4\x4c\x54\xeb"
+        , vecCiphertext =
+            "\xc6\x7a\x1f\x0f\x56\x7a\x51\x98\xaa\x1f\xcc\x8e\x3f\x21\x31\x43\x36\xf7\xf5\x1c\xa8\xb1\xaf\x61\xfe\xac\x35\xa8\x64\x16\xfa\x47\xfb\xca\x3b\x5f\x74\x9c\xdf\x56\x45\x27\xf2\x31\x4f\x42\xfe\x25"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = "\x01"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x5b\xde\x02\x85\x03\x7c\x5d\xe8\x1e\x5b\x57\x0a\x04\x9b\x62\xa0"
-        , vecCiphertext = "\x67\xfd\x45\xe1\x26\xbf\xb9\xa7\x99\x30\xc4\x3a\xad\x2d\x36\x96\x7d\x3f\x0e\x4d\x21\x7c\x1e\x55\x1f\x59\x72\x78\x70\xbe\xef\xc9\x8c\xb9\x33\xa8\xfc\xe9\xde\x88\x7b\x1e\x40\x79\x99\x88\xdb\x1f\xc3\xf9\x18\x80\xed\x40\x5b\x2d\xd2\x98\x31\x88\x58\x46\x7c\x89"
+        { vecPlaintext =
+            "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = "\x01"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x5b\xde\x02\x85\x03\x7c\x5d\xe8\x1e\x5b\x57\x0a\x04\x9b\x62\xa0"
+        , vecCiphertext =
+            "\x67\xfd\x45\xe1\x26\xbf\xb9\xa7\x99\x30\xc4\x3a\xad\x2d\x36\x96\x7d\x3f\x0e\x4d\x21\x7c\x1e\x55\x1f\x59\x72\x78\x70\xbe\xef\xc9\x8c\xb9\x33\xa8\xfc\xe9\xde\x88\x7b\x1e\x40\x79\x99\x88\xdb\x1f\xc3\xf9\x18\x80\xed\x40\x5b\x2d\xd2\x98\x31\x88\x58\x46\x7c\x89"
         }
     , Vector
-        { vecPlaintext  = "\x02\x00\x00\x00"
-        , vecAAD        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\x18\x35\xe5\x17\x74\x1d\xfd\xdc\xcf\xa0\x7f\xa4\x66\x1b\x74\xcf"
+        { vecPlaintext = "\x02\x00\x00\x00"
+        , vecAAD = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\x18\x35\xe5\x17\x74\x1d\xfd\xdc\xcf\xa0\x7f\xa4\x66\x1b\x74\xcf"
         , vecCiphertext = "\x22\xb3\xf4\xcd"
         }
     , Vector
-        { vecPlaintext  = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00"
-        , vecAAD        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xb8\x79\xad\x97\x6d\x82\x42\xac\xc1\x88\xab\x59\xca\xbf\xe3\x07"
-        , vecCiphertext = "\x43\xdd\x01\x63\xcd\xb4\x8f\x9f\xe3\x21\x2b\xf6\x1b\x20\x19\x76\x06\x7f\x34\x2b"
+        { vecPlaintext =
+            "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00"
+        , vecAAD =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xb8\x79\xad\x97\x6d\x82\x42\xac\xc1\x88\xab\x59\xca\xbf\xe3\x07"
+        , vecCiphertext =
+            "\x43\xdd\x01\x63\xcd\xb4\x8f\x9f\xe3\x21\x2b\xf6\x1b\x20\x19\x76\x06\x7f\x34\x2b"
         }
     , Vector
-        { vecPlaintext  = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00"
-        , vecAAD        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00"
-        , vecKey        = "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xcf\xcd\xf5\x04\x21\x12\xaa\x29\x68\x5c\x91\x2f\xc2\x05\x65\x43"
-        , vecCiphertext = "\x46\x24\x01\x72\x4b\x5c\xe6\x58\x8d\x5a\x54\xaa\xe5\x37\x55\x13\xa0\x75"
+        { vecPlaintext =
+            "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00"
+        , vecAAD =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00"
+        , vecKey =
+            "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xcf\xcd\xf5\x04\x21\x12\xaa\x29\x68\x5c\x91\x2f\xc2\x05\x65\x43"
+        , vecCiphertext =
+            "\x46\x24\x01\x72\x4b\x5c\xe6\x58\x8d\x5a\x54\xaa\xe5\x37\x55\x13\xa0\x75"
         }
     , Vector
-        { vecPlaintext  = ""
-        , vecAAD        = ""
-        , vecKey        = "\xe6\x60\x21\xd5\xeb\x8e\x4f\x40\x66\xd4\xad\xb9\xc3\x35\x60\xe4\xf4\x6e\x44\xbb\x3d\xa0\x01\x5c\x94\xf7\x08\x87\x36\x86\x42\x00"
-        , vecNonce      = "\xe0\xea\xf5\x28\x4d\x88\x4a\x0e\x77\xd3\x16\x46"
-        , vecTag        = "\x16\x9f\xbb\x2f\xbf\x38\x9a\x99\x5f\x63\x90\xaf\x22\x22\x8a\x62"
+        { vecPlaintext = ""
+        , vecAAD = ""
+        , vecKey =
+            "\xe6\x60\x21\xd5\xeb\x8e\x4f\x40\x66\xd4\xad\xb9\xc3\x35\x60\xe4\xf4\x6e\x44\xbb\x3d\xa0\x01\x5c\x94\xf7\x08\x87\x36\x86\x42\x00"
+        , vecNonce = "\xe0\xea\xf5\x28\x4d\x88\x4a\x0e\x77\xd3\x16\x46"
+        , vecTag =
+            "\x16\x9f\xbb\x2f\xbf\x38\x9a\x99\x5f\x63\x90\xaf\x22\x22\x8a\x62"
         , vecCiphertext = ""
         }
     , Vector
-        { vecPlaintext  = "\x67\x1f\xdd"
-        , vecAAD        = "\x4f\xbd\xc6\x6f\x14"
-        , vecKey        = "\xba\xe8\xe3\x7f\xc8\x34\x41\xb1\x60\x34\x56\x6b\x7a\x80\x6c\x46\xbb\x91\xc3\xc5\xae\xdb\x64\xa6\xc5\x90\xbc\x84\xd1\xa5\xe2\x69"
-        , vecNonce      = "\xe4\xb4\x78\x01\xaf\xc0\x57\x7e\x34\x69\x9b\x9e"
-        , vecTag        = "\x93\xda\x9b\xb8\x13\x33\xae\xe0\xc7\x85\xb2\x40\xd3\x19\x71\x9d"
+        { vecPlaintext = "\x67\x1f\xdd"
+        , vecAAD = "\x4f\xbd\xc6\x6f\x14"
+        , vecKey =
+            "\xba\xe8\xe3\x7f\xc8\x34\x41\xb1\x60\x34\x56\x6b\x7a\x80\x6c\x46\xbb\x91\xc3\xc5\xae\xdb\x64\xa6\xc5\x90\xbc\x84\xd1\xa5\xe2\x69"
+        , vecNonce = "\xe4\xb4\x78\x01\xaf\xc0\x57\x7e\x34\x69\x9b\x9e"
+        , vecTag =
+            "\x93\xda\x9b\xb8\x13\x33\xae\xe0\xc7\x85\xb2\x40\xd3\x19\x71\x9d"
         , vecCiphertext = "\x0e\xac\xcb"
         }
     , Vector
-        { vecPlaintext  = "\x19\x54\x95\x86\x0f\x04"
-        , vecAAD        = "\x67\x87\xf3\xea\x22\xc1\x27\xaa\xf1\x95"
-        , vecKey        = "\x65\x45\xfc\x88\x0c\x94\xa9\x51\x98\x87\x42\x96\xd5\xcc\x1f\xd1\x61\x32\x0b\x69\x20\xce\x07\x78\x7f\x86\x74\x3b\x27\x5d\x1a\xb3"
-        , vecNonce      = "\x2f\x6d\x1f\x04\x34\xd8\x84\x8c\x11\x77\x44\x1f"
-        , vecTag        = "\x6b\x62\xb8\x4d\xc4\x0c\x84\x63\x6a\x5e\xc1\x20\x20\xec\x8c\x2c"
+        { vecPlaintext = "\x19\x54\x95\x86\x0f\x04"
+        , vecAAD = "\x67\x87\xf3\xea\x22\xc1\x27\xaa\xf1\x95"
+        , vecKey =
+            "\x65\x45\xfc\x88\x0c\x94\xa9\x51\x98\x87\x42\x96\xd5\xcc\x1f\xd1\x61\x32\x0b\x69\x20\xce\x07\x78\x7f\x86\x74\x3b\x27\x5d\x1a\xb3"
+        , vecNonce = "\x2f\x6d\x1f\x04\x34\xd8\x84\x8c\x11\x77\x44\x1f"
+        , vecTag =
+            "\x6b\x62\xb8\x4d\xc4\x0c\x84\x63\x6a\x5e\xc1\x20\x20\xec\x8c\x2c"
         , vecCiphertext = "\xa2\x54\xda\xd4\xf3\xf9"
         }
     , Vector
-        { vecPlaintext  = "\xc9\x88\x2e\x53\x86\xfd\x9f\x92\xec"
-        , vecAAD        = "\x48\x9c\x8f\xde\x2b\xe2\xcf\x97\xe7\x4e\x93\x2d\x4e\xd8\x7d"
-        , vecKey        = "\xd1\x89\x47\x28\xb3\xfe\xd1\x47\x3c\x52\x8b\x84\x26\xa5\x82\x99\x59\x29\xa1\x49\x9e\x9a\xd8\x78\x0c\x8d\x63\xd0\xab\x41\x49\xc0"
-        , vecNonce      = "\x9f\x57\x2c\x61\x4b\x47\x45\x91\x44\x74\xe7\xc7"
-        , vecTag        = "\xc0\xfd\x3d\xc6\x62\x8d\xfe\x55\xeb\xb0\xb9\xfb\x22\x95\xc8\xc2"
+        { vecPlaintext = "\xc9\x88\x2e\x53\x86\xfd\x9f\x92\xec"
+        , vecAAD = "\x48\x9c\x8f\xde\x2b\xe2\xcf\x97\xe7\x4e\x93\x2d\x4e\xd8\x7d"
+        , vecKey =
+            "\xd1\x89\x47\x28\xb3\xfe\xd1\x47\x3c\x52\x8b\x84\x26\xa5\x82\x99\x59\x29\xa1\x49\x9e\x9a\xd8\x78\x0c\x8d\x63\xd0\xab\x41\x49\xc0"
+        , vecNonce = "\x9f\x57\x2c\x61\x4b\x47\x45\x91\x44\x74\xe7\xc7"
+        , vecTag =
+            "\xc0\xfd\x3d\xc6\x62\x8d\xfe\x55\xeb\xb0\xb9\xfb\x22\x95\xc8\xc2"
         , vecCiphertext = "\x0d\xf9\xe3\x08\x67\x82\x44\xc4\x4b"
         }
     , Vector
-        { vecPlaintext  = "\x1d\xb2\x31\x6f\xd5\x68\x37\x8d\xa1\x07\xb5\x2b"
-        , vecAAD        = "\x0d\xa5\x52\x10\xcc\x1c\x1b\x0a\xbd\xe3\xb2\xf2\x04\xd1\xe9\xf8\xb0\x6b\xc4\x7f"
-        , vecKey        = "\xa4\x41\x02\x95\x2e\xf9\x4b\x02\xb8\x05\x24\x9b\xac\x80\xe6\xf6\x14\x55\xbf\xac\x83\x08\xa2\xd4\x0d\x8c\x84\x51\x17\x80\x82\x35"
-        , vecNonce      = "\x5c\x9e\x94\x0f\xea\x2f\x58\x29\x50\xa7\x0d\x5a"
-        , vecTag        = "\x40\x40\x99\xc2\x58\x7f\x64\x97\x9f\x21\x82\x67\x06\xd4\x97\xd5"
+        { vecPlaintext = "\x1d\xb2\x31\x6f\xd5\x68\x37\x8d\xa1\x07\xb5\x2b"
+        , vecAAD =
+            "\x0d\xa5\x52\x10\xcc\x1c\x1b\x0a\xbd\xe3\xb2\xf2\x04\xd1\xe9\xf8\xb0\x6b\xc4\x7f"
+        , vecKey =
+            "\xa4\x41\x02\x95\x2e\xf9\x4b\x02\xb8\x05\x24\x9b\xac\x80\xe6\xf6\x14\x55\xbf\xac\x83\x08\xa2\xd4\x0d\x8c\x84\x51\x17\x80\x82\x35"
+        , vecNonce = "\x5c\x9e\x94\x0f\xea\x2f\x58\x29\x50\xa7\x0d\x5a"
+        , vecTag =
+            "\x40\x40\x99\xc2\x58\x7f\x64\x97\x9f\x21\x82\x67\x06\xd4\x97\xd5"
         , vecCiphertext = "\x8d\xbe\xb9\xf7\x25\x5b\xf5\x76\x9d\xd5\x66\x92"
         }
     , Vector
-        { vecPlaintext  = "\x21\x70\x2d\xe0\xde\x18\xba\xa9\xc9\x59\x62\x91\xb0\x84\x66"
-        , vecAAD        = "\xf3\x7d\xe2\x1c\x7f\xf9\x01\xcf\xe8\xa6\x96\x15\xa9\x3f\xdf\x7a\x98\xca\xd4\x81\x79\x62\x45\x70\x9f"
-        , vecKey        = "\x97\x45\xb3\xd1\xae\x06\x55\x6f\xb6\xaa\x78\x90\xbe\xbc\x18\xfe\x6b\x3d\xb4\xda\x3d\x57\xaa\x94\x84\x2b\x98\x03\xa9\x6e\x07\xfb"
-        , vecNonce      = "\x6d\xe7\x18\x60\xf7\x62\xeb\xfb\xd0\x82\x84\xe4"
-        , vecTag        = "\xb3\x08\x0d\x28\xf6\xeb\xb5\xd3\x64\x8c\xe9\x7b\xd5\xba\x67\xfd"
+        { vecPlaintext = "\x21\x70\x2d\xe0\xde\x18\xba\xa9\xc9\x59\x62\x91\xb0\x84\x66"
+        , vecAAD =
+            "\xf3\x7d\xe2\x1c\x7f\xf9\x01\xcf\xe8\xa6\x96\x15\xa9\x3f\xdf\x7a\x98\xca\xd4\x81\x79\x62\x45\x70\x9f"
+        , vecKey =
+            "\x97\x45\xb3\xd1\xae\x06\x55\x6f\xb6\xaa\x78\x90\xbe\xbc\x18\xfe\x6b\x3d\xb4\xda\x3d\x57\xaa\x94\x84\x2b\x98\x03\xa9\x6e\x07\xfb"
+        , vecNonce = "\x6d\xe7\x18\x60\xf7\x62\xeb\xfb\xd0\x82\x84\xe4"
+        , vecTag =
+            "\xb3\x08\x0d\x28\xf6\xeb\xb5\xd3\x64\x8c\xe9\x7b\xd5\xba\x67\xfd"
         , vecCiphertext = "\x79\x35\x76\xdf\xa5\xc0\xf8\x87\x29\xa7\xed\x3c\x2f\x1b\xff"
         }
     , Vector
-        { vecPlaintext  = "\xb2\x02\xb3\x70\xef\x97\x68\xec\x65\x61\xc4\xfe\x6b\x7e\x72\x96\xfa\x85"
-        , vecAAD        = "\x9c\x21\x59\x05\x8b\x1f\x0f\xe9\x14\x33\xa5\xbd\xc2\x0e\x21\x4e\xab\x7f\xec\xef\x44\x54\xa1\x0e\xf0\x65\x7d\xf2\x1a\xc7"
-        , vecKey        = "\xb1\x88\x53\xf6\x8d\x83\x36\x40\xe4\x2a\x3c\x02\xc2\x5b\x64\x86\x9e\x14\x6d\x7b\x23\x39\x87\xbd\xdf\xc2\x40\x87\x1d\x75\x76\xf7"
-        , vecNonce      = "\x02\x8e\xc6\xeb\x5e\xa7\xe2\x98\x34\x2a\x94\xd4"
-        , vecTag        = "\x45\x4f\xc2\xa1\x54\xfe\xa9\x1f\x83\x63\xa3\x9f\xec\x7d\x0a\x49"
-        , vecCiphertext = "\x85\x7e\x16\xa6\x49\x15\xa7\x87\x63\x76\x87\xdb\x4a\x95\x19\x63\x5c\xdd"
+        { vecPlaintext =
+            "\xb2\x02\xb3\x70\xef\x97\x68\xec\x65\x61\xc4\xfe\x6b\x7e\x72\x96\xfa\x85"
+        , vecAAD =
+            "\x9c\x21\x59\x05\x8b\x1f\x0f\xe9\x14\x33\xa5\xbd\xc2\x0e\x21\x4e\xab\x7f\xec\xef\x44\x54\xa1\x0e\xf0\x65\x7d\xf2\x1a\xc7"
+        , vecKey =
+            "\xb1\x88\x53\xf6\x8d\x83\x36\x40\xe4\x2a\x3c\x02\xc2\x5b\x64\x86\x9e\x14\x6d\x7b\x23\x39\x87\xbd\xdf\xc2\x40\x87\x1d\x75\x76\xf7"
+        , vecNonce = "\x02\x8e\xc6\xeb\x5e\xa7\xe2\x98\x34\x2a\x94\xd4"
+        , vecTag =
+            "\x45\x4f\xc2\xa1\x54\xfe\xa9\x1f\x83\x63\xa3\x9f\xec\x7d\x0a\x49"
+        , vecCiphertext =
+            "\x85\x7e\x16\xa6\x49\x15\xa7\x87\x63\x76\x87\xdb\x4a\x95\x19\x63\x5c\xdd"
         }
     , Vector
-        { vecPlaintext  = "\xce\xd5\x32\xce\x41\x59\xb0\x35\x27\x7d\x4d\xfb\xb7\xdb\x62\x96\x8b\x13\xcd\x4e\xec"
-        , vecAAD        = "\x73\x43\x20\xcc\xc9\xd9\xbb\xbb\x19\xcb\x81\xb2\xaf\x4e\xcb\xc3\xe7\x28\x34\x32\x1f\x7a\xa0\xf7\x0b\x72\x82\xb4\xf3\x3d\xf2\x3f\x16\x75\x41"
-        , vecKey        = "\x3c\x53\x5d\xe1\x92\xea\xed\x38\x22\xa2\xfb\xbe\x2c\xa9\xdf\xc8\x82\x55\xe1\x4a\x66\x1b\x8a\xa8\x2c\xc5\x42\x36\x09\x3b\xbc\x23"
-        , vecNonce      = "\x68\x80\x89\xe5\x55\x40\xdb\x18\x72\x50\x4e\x1c"
-        , vecTag        = "\x9d\x6c\x70\x29\x67\x5b\x89\xea\xf4\xba\x1d\xed\x1a\x28\x65\x94"
-        , vecCiphertext = "\x62\x66\x60\xc2\x6e\xa6\x61\x2f\xb1\x7a\xd9\x1e\x8e\x76\x76\x39\xed\xd6\xc9\xfa\xee"
+        { vecPlaintext =
+            "\xce\xd5\x32\xce\x41\x59\xb0\x35\x27\x7d\x4d\xfb\xb7\xdb\x62\x96\x8b\x13\xcd\x4e\xec"
+        , vecAAD =
+            "\x73\x43\x20\xcc\xc9\xd9\xbb\xbb\x19\xcb\x81\xb2\xaf\x4e\xcb\xc3\xe7\x28\x34\x32\x1f\x7a\xa0\xf7\x0b\x72\x82\xb4\xf3\x3d\xf2\x3f\x16\x75\x41"
+        , vecKey =
+            "\x3c\x53\x5d\xe1\x92\xea\xed\x38\x22\xa2\xfb\xbe\x2c\xa9\xdf\xc8\x82\x55\xe1\x4a\x66\x1b\x8a\xa8\x2c\xc5\x42\x36\x09\x3b\xbc\x23"
+        , vecNonce = "\x68\x80\x89\xe5\x55\x40\xdb\x18\x72\x50\x4e\x1c"
+        , vecTag =
+            "\x9d\x6c\x70\x29\x67\x5b\x89\xea\xf4\xba\x1d\xed\x1a\x28\x65\x94"
+        , vecCiphertext =
+            "\x62\x66\x60\xc2\x6e\xa6\x61\x2f\xb1\x7a\xd9\x1e\x8e\x76\x76\x39\xed\xd6\xc9\xfa\xee"
         }
     ]
 
 vectorsWrap256 :: [Vector AES256]
 vectorsWrap256 =
     [ Vector
-        { vecPlaintext  = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4d\xb9\x23\xdc\x79\x3e\xe6\x49\x7c\x76\xdc\xc0\x3a\x98\xe1\x08"
-        , vecAAD        = ""
-        , vecKey        = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecCiphertext = "\xf3\xf8\x0f\x2c\xf0\xcb\x2d\xd9\xc5\x98\x4f\xcd\xa9\x08\x45\x6c\xc5\x37\x70\x3b\x5b\xa7\x03\x24\xa6\x79\x3a\x7b\xf2\x18\xd3\xea"
+        { vecPlaintext =
+            "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4d\xb9\x23\xdc\x79\x3e\xe6\x49\x7c\x76\xdc\xc0\x3a\x98\xe1\x08"
+        , vecAAD = ""
+        , vecKey =
+            "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecCiphertext =
+            "\xf3\xf8\x0f\x2c\xf0\xcb\x2d\xd9\xc5\x98\x4f\xcd\xa9\x08\x45\x6c\xc5\x37\x70\x3b\x5b\xa7\x03\x24\xa6\x79\x3a\x7b\xf2\x18\xd3\xea"
         }
     , Vector
-        { vecPlaintext  = "\xeb\x36\x40\x27\x7c\x7f\xfd\x13\x03\xc7\xa5\x42\xd0\x2d\x3e\x4c\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecAAD        = ""
-        , vecKey        = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecNonce      = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecTag        = "\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        , vecCiphertext = "\x18\xce\x4f\x0b\x8c\xb4\xd0\xca\xc6\x5f\xea\x8f\x79\x25\x7b\x20\x88\x8e\x53\xe7\x22\x99\xe5\x6d"
+        { vecPlaintext =
+            "\xeb\x36\x40\x27\x7c\x7f\xfd\x13\x03\xc7\xa5\x42\xd0\x2d\x3e\x4c\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecAAD = ""
+        , vecKey =
+            "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecNonce = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecTag =
+            "\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+        , vecCiphertext =
+            "\x18\xce\x4f\x0b\x8c\xb4\xd0\xca\xc6\x5f\xea\x8f\x79\x25\x7b\x20\x88\x8e\x53\xe7\x22\x99\xe5\x6d"
         }
     ]
 
@@ -442,27 +607,32 @@
 makeEncryptionTest i vec@Vector{..} =
     testCase (show i) $
         (t, vecCiphertext) @=? encrypt (vecCipher vec) n vecAAD vecPlaintext
-  where t = AuthTag (B.convert vecTag)
-        n = throwCryptoError (nonce vecNonce)
+  where
+    t = AuthTag (B.convert vecTag)
+    n = throwCryptoError (nonce vecNonce)
 
 makeDecryptionTest :: BlockCipher128 aes => Int -> Vector aes -> TestTree
 makeDecryptionTest i vec@Vector{..} =
     testCase (show i) $
         Just vecPlaintext @=? decrypt (vecCipher vec) n vecAAD vecCiphertext t
-  where t = AuthTag (B.convert vecTag)
-        n = throwCryptoError (nonce vecNonce)
+  where
+    t = AuthTag (B.convert vecTag)
+    n = throwCryptoError (nonce vecNonce)
 
-katTests :: TestName
-         -> (forall c . BlockCipher128 c => Int -> Vector c -> TestTree)
-         -> TestTree
-katTests name makeTest = testGroup name
-    [ testGroup "AES128" $ zipWith makeTest [1..] vectors128
-    , testGroup "AES256" $ zipWith makeTest [1..] vectors256
-    , testGroup "CounterWrap" $ zipWith makeTest [1..] vectorsWrap256
-    ]
+katTests
+    :: TestName
+    -> (forall c. BlockCipher128 c => Int -> Vector c -> TestTree)
+    -> TestTree
+katTests name makeTest =
+    testGroup
+        name
+        [ testGroup "AES128" $ zipWith makeTest [1 ..] vectors128
+        , testGroup "AES256" $ zipWith makeTest [1 ..] vectors256
+        , testGroup "CounterWrap" $ zipWith makeTest [1 ..] vectorsWrap256
+        ]
 
 newtype Key c = Key ByteString
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance Arbitrary (Key AES128) where
     arbitrary = Key <$> arbitraryBS 16
@@ -473,22 +643,31 @@
 instance Arbitrary Nonce where
     arbitrary = throwCryptoError . nonce <$> arbitraryBS 12
 
-encDecTest :: BlockCipher128 c
-           => Proxy c -> Key c -> Nonce
-           -> ArbitraryBS0_2901 -> ArbitraryBS0_2901 -> Property
+encDecTest
+    :: BlockCipher128 c
+    => Proxy c
+    -> Key c
+    -> Nonce
+    -> ArbitraryBS0_2901
+    -> ArbitraryBS0_2901
+    -> Property
 encDecTest prx (Key key) iv (ArbitraryBS0_2901 aad) (ArbitraryBS0_2901 input) =
     let c = throwCryptoError (cipherInit key) `asProxyTypeOf` prx
         (tag, ciphertext) = encrypt c iv aad input
      in decrypt c iv aad ciphertext tag === Just input
 
 tests :: TestTree
-tests = testGroup "AES-GCM-SIV"
-    [ testGroup "KATs"
-        [ katTests "encrypt" makeEncryptionTest
-        , katTests "decrypt" makeDecryptionTest
-        ]
-    , testGroup "properties"
-        [ testProperty "AES128" $ encDecTest (Proxy :: Proxy AES128)
-        , testProperty "AES256" $ encDecTest (Proxy :: Proxy AES256)
+tests =
+    testGroup
+        "AES-GCM-SIV"
+        [ testGroup
+            "KATs"
+            [ katTests "encrypt" makeEncryptionTest
+            , katTests "decrypt" makeDecryptionTest
+            ]
+        , testGroup
+            "properties"
+            [ testProperty "AES128" $ encDecTest (Proxy :: Proxy AES128)
+            , testProperty "AES256" $ encDecTest (Proxy :: Proxy AES256)
+            ]
         ]
-    ]
diff --git a/tests/KAT_AFIS.hs b/tests/KAT_AFIS.hs
--- a/tests/KAT_AFIS.hs
+++ b/tests/KAT_AFIS.hs
@@ -1,31 +1,35 @@
-{-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE OverloadedStrings #-}
+
 module KAT_AFIS (tests) where
 
 import Imports
 
+import qualified Crypto.Data.AFIS as AFIS
 import Crypto.Hash
 import Crypto.Random
-import qualified Crypto.Data.AFIS as AFIS
 import qualified Data.ByteString as B
 
-mergeVec :: [ (Int, SHA1, B.ByteString, B.ByteString) ]
+mergeVec :: [(Int, SHA1, B.ByteString, B.ByteString)]
 mergeVec =
-    [ (3
-      , SHA1
-      , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
-      , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\xd4\x76\xc8\x58\xbd\xf0\x15\xbe\x9f\x40\xe3\x65\x20\x1c\x9c\xb8\xd8\x1c\x16\x64"
-      )
-    , (3
-      , SHA1
-      , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17"
-      , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\xd6\x75\xc8\x59\xbb\xf7\x11\xbb\x95\x4b\xeb\x6c\x2e\x13\x90\xb5\xca\x0f\x06\x75\x17\x70\x39\x28"
-      )
+    [
+        ( 3
+        , SHA1
+        , "\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02"
+        , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\xd4\x76\xc8\x58\xbd\xf0\x15\xbe\x9f\x40\xe3\x65\x20\x1c\x9c\xb8\xd8\x1c\x16\x64"
+        )
+    ,
+        ( 3
+        , SHA1
+        , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17"
+        , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\xd6\x75\xc8\x59\xbb\xf7\x11\xbb\x95\x4b\xeb\x6c\x2e\x13\x90\xb5\xca\x0f\x06\x75\x17\x70\x39\x28"
+        )
     ]
 
-mergeKATs = zipWith toProp mergeVec [(0 :: Int)..]
-  where toProp (nbExpands, hashAlg, expected, dat) i =
-            testCase ("merge " ++ show i) (expected @=? AFIS.merge hashAlg nbExpands dat)
+mergeKATs = zipWith toProp mergeVec [(0 :: Int) ..]
+  where
+    toProp (nbExpands, hashAlg, expected, dat) i =
+        testCase ("merge " ++ show i) (expected @=? AFIS.merge hashAlg nbExpands dat)
 
 data AFISParams = AFISParams B.ByteString Int SHA1 ChaChaDRG
 
@@ -33,12 +37,19 @@
     show (AFISParams dat expand _ _) = "data: " ++ show dat ++ " expanded: " ++ show expand
 
 instance Arbitrary AFISParams where
-    arbitrary = AFISParams <$> arbitraryBSof 3 46 <*> choose (2,2) <*> elements [SHA1] <*> arbitrary
+    arbitrary =
+        AFISParams
+            <$> arbitraryBSof 3 46
+            <*> choose (2, 2)
+            <*> elements [SHA1]
+            <*> arbitrary
 
 instance Arbitrary ChaChaDRG where
     arbitrary = drgNewTest <$> arbitrary
 
-tests = testGroup "AFIS"
-    [ testGroup "KAT merge" mergeKATs
-    , testProperty "merge.split == id" $ \(AFISParams bs e hf rng) -> bs == (AFIS.merge hf e $ fst (AFIS.split hf rng e bs))
-    ]
+tests =
+    testGroup
+        "AFIS"
+        [ testGroup "KAT merge" mergeKATs
+        , testProperty "merge.split == id" $ \(AFISParams bs e hf rng) -> bs == (AFIS.merge hf e $ fst (AFIS.split hf rng e bs))
+        ]
diff --git a/tests/KAT_Argon2.hs b/tests/KAT_Argon2.hs
--- a/tests/KAT_Argon2.hs
+++ b/tests/KAT_Argon2.hs
@@ -1,29 +1,34 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_Argon2 (tests) where
 
-import           Crypto.Error
+import Crypto.Error
 import qualified Crypto.KDF.Argon2 as Argon2
 import qualified Data.ByteString as B
-import           Imports
+import Imports
 
 data KDFVector = KDFVector
-    { kdfPass      :: ByteString
-    , kdfSalt      :: ByteString
-    , kdfOptions   :: Argon2.Options
-    , kdfResult    :: ByteString
+    { kdfPass :: ByteString
+    , kdfSalt :: ByteString
+    , kdfOptions :: Argon2.Options
+    , kdfResult :: ByteString
     }
 
 argon2i_13 :: Argon2.TimeCost -> Argon2.MemoryCost -> Argon2.Options
-argon2i_13 iters memory = Argon2.Options
-    { Argon2.iterations  = iters
-    , Argon2.memory      = memory
-    , Argon2.parallelism = 1
-    , Argon2.variant     = Argon2.Argon2i
-    , Argon2.version     = Argon2.Version13
-    }
+argon2i_13 iters memory =
+    Argon2.Options
+        { Argon2.iterations = iters
+        , Argon2.memory = memory
+        , Argon2.parallelism = 1
+        , Argon2.variant = Argon2.Argon2i
+        , Argon2.version = Argon2.Version13
+        }
 
 vectors =
-    [ KDFVector "password" "somesalt" (argon2i_13 2 65536)
+    [ KDFVector
+        "password"
+        "somesalt"
+        (argon2i_13 2 65536)
         "\xc1\x62\x88\x32\x14\x7d\x97\x20\xc5\xbd\x1c\xfd\x61\x36\x70\x78\x72\x9f\x6d\xfb\x6f\x8f\xea\x9f\xf9\x81\x58\xe0\xd7\x81\x6e\xd0"
     ]
 
@@ -31,12 +36,17 @@
 kdfTests = zipWith toKDFTest is vectors
   where
     toKDFTest i v =
-        testCase (show i)
-            (CryptoPassed (kdfResult v) @=? Argon2.hash (kdfOptions v) (kdfPass v) (kdfSalt v) (B.length $ kdfResult v))
+        testCase
+            (show i)
+            ( CryptoPassed (kdfResult v)
+                @=? Argon2.hash (kdfOptions v) (kdfPass v) (kdfSalt v) (B.length $ kdfResult v)
+            )
 
     is :: [Int]
-    is = [1..]
+    is = [1 ..]
 
-tests = testGroup "Argon2"
-    [ testGroup "KATs" kdfTests
-    ]
+tests =
+    testGroup
+        "Argon2"
+        [ testGroup "KATs" kdfTests
+        ]
diff --git a/tests/KAT_Blake2.hs b/tests/KAT_Blake2.hs
--- a/tests/KAT_Blake2.hs
+++ b/tests/KAT_Blake2.hs
@@ -1,20 +1,20 @@
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE RecordWildCards #-}
+
 module KAT_Blake2 (tests) where
 
-import           Crypto.Hash (digestFromByteString)
-import           Crypto.Hash.Algorithms
+import Crypto.Hash (digestFromByteString)
+import Crypto.Hash.Algorithms
 import qualified Crypto.MAC.KeyedBlake2 as KB
 
 import qualified Data.ByteString as B
 
 import Imports
 
-
 data MACVector hash = MACVector
     { macMessage :: ByteString
-    , macKey    :: ByteString
+    , macKey :: ByteString
     , macResult :: KB.KeyedBlake2 hash
     }
 
@@ -24,87 +24,114 @@
 digest :: KB.HashBlake2 hash => ByteString -> KB.KeyedBlake2 hash
 digest = maybe (error "cannot get digest") KB.KeyedBlake2 . digestFromByteString
 
-
 -- From: https://github.com/BLAKE2/BLAKE2/blob/master/testvectors/
 vectorsBlake2bKAT :: [MACVector (Blake2b 512)]
 vectorsBlake2bKAT =
     [ MACVector
         { macMessage = ""
-        , macKey     = fixedKey
-        , macResult  = digest "\x10\xeb\xb6\x77\x00\xb1\x86\x8e\xfb\x44\x17\x98\x7a\xcf\x46\x90\xae\x9d\x97\x2f\xb7\xa5\x90\xc2\xf0\x28\x71\x79\x9a\xaa\x47\x86\xb5\xe9\x96\xe8\xf0\xf4\xeb\x98\x1f\xc2\x14\xb0\x05\xf4\x2d\x2f\xf4\x23\x34\x99\x39\x16\x53\xdf\x7a\xef\xcb\xc1\x3f\xc5\x15\x68"
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x10\xeb\xb6\x77\x00\xb1\x86\x8e\xfb\x44\x17\x98\x7a\xcf\x46\x90\xae\x9d\x97\x2f\xb7\xa5\x90\xc2\xf0\x28\x71\x79\x9a\xaa\x47\x86\xb5\xe9\x96\xe8\xf0\xf4\xeb\x98\x1f\xc2\x14\xb0\x05\xf4\x2d\x2f\xf4\x23\x34\x99\x39\x16\x53\xdf\x7a\xef\xcb\xc1\x3f\xc5\x15\x68"
         }
     , MACVector
         { macMessage = "\x00"
-        , macKey     = fixedKey
-        , macResult  = digest "\x96\x1f\x6d\xd1\xe4\xdd\x30\xf6\x39\x01\x69\x0c\x51\x2e\x78\xe4\xb4\x5e\x47\x42\xed\x19\x7c\x3c\x5e\x45\xc5\x49\xfd\x25\xf2\xe4\x18\x7b\x0b\xc9\xfe\x30\x49\x2b\x16\xb0\xd0\xbc\x4e\xf9\xb0\xf3\x4c\x70\x03\xfa\xc0\x9a\x5e\xf1\x53\x2e\x69\x43\x02\x34\xce\xbd"
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x96\x1f\x6d\xd1\xe4\xdd\x30\xf6\x39\x01\x69\x0c\x51\x2e\x78\xe4\xb4\x5e\x47\x42\xed\x19\x7c\x3c\x5e\x45\xc5\x49\xfd\x25\xf2\xe4\x18\x7b\x0b\xc9\xfe\x30\x49\x2b\x16\xb0\xd0\xbc\x4e\xf9\xb0\xf3\x4c\x70\x03\xfa\xc0\x9a\x5e\xf1\x53\x2e\x69\x43\x02\x34\xce\xbd"
         }
     , MACVector
-        { macMessage = B.pack [ 0x00 .. 0xfe ]
-        , macKey     = fixedKey
-        , macResult  = digest "\x14\x27\x09\xd6\x2e\x28\xfc\xcc\xd0\xaf\x97\xfa\xd0\xf8\x46\x5b\x97\x1e\x82\x20\x1d\xc5\x10\x70\xfa\xa0\x37\x2a\xa4\x3e\x92\x48\x4b\xe1\xc1\xe7\x3b\xa1\x09\x06\xd5\xd1\x85\x3d\xb6\xa4\x10\x6e\x0a\x7b\xf9\x80\x0d\x37\x3d\x6d\xee\x2d\x46\xd6\x2e\xf2\xa4\x61"
+        { macMessage = B.pack [0x00 .. 0xfe]
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x14\x27\x09\xd6\x2e\x28\xfc\xcc\xd0\xaf\x97\xfa\xd0\xf8\x46\x5b\x97\x1e\x82\x20\x1d\xc5\x10\x70\xfa\xa0\x37\x2a\xa4\x3e\x92\x48\x4b\xe1\xc1\xe7\x3b\xa1\x09\x06\xd5\xd1\x85\x3d\xb6\xa4\x10\x6e\x0a\x7b\xf9\x80\x0d\x37\x3d\x6d\xee\x2d\x46\xd6\x2e\xf2\xa4\x61"
         }
     ]
-    where fixedKey = B.pack [ 0x00 .. 0x3f ]
+  where
+    fixedKey = B.pack [0x00 .. 0x3f]
 
 vectorsBlake2bpKAT :: [MACVector (Blake2bp 512)]
 vectorsBlake2bpKAT =
     [ MACVector
         { macMessage = ""
-        , macKey     = fixedKey
-        , macResult  = digest "\x9d\x94\x61\x07\x3e\x4e\xb6\x40\xa2\x55\x35\x7b\x83\x9f\x39\x4b\x83\x8c\x6f\xf5\x7c\x9b\x68\x6a\x3f\x76\x10\x7c\x10\x66\x72\x8f\x3c\x99\x56\xbd\x78\x5c\xbc\x3b\xf7\x9d\xc2\xab\x57\x8c\x5a\x0c\x06\x3b\x9d\x9c\x40\x58\x48\xde\x1d\xbe\x82\x1c\xd0\x5c\x94\x0a"
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x9d\x94\x61\x07\x3e\x4e\xb6\x40\xa2\x55\x35\x7b\x83\x9f\x39\x4b\x83\x8c\x6f\xf5\x7c\x9b\x68\x6a\x3f\x76\x10\x7c\x10\x66\x72\x8f\x3c\x99\x56\xbd\x78\x5c\xbc\x3b\xf7\x9d\xc2\xab\x57\x8c\x5a\x0c\x06\x3b\x9d\x9c\x40\x58\x48\xde\x1d\xbe\x82\x1c\xd0\x5c\x94\x0a"
         }
     , MACVector
         { macMessage = "\x00"
-        , macKey     = fixedKey
-        , macResult  = digest "\xff\x8e\x90\xa3\x7b\x94\x62\x39\x32\xc5\x9f\x75\x59\xf2\x60\x35\x02\x9c\x37\x67\x32\xcb\x14\xd4\x16\x02\x00\x1c\xbb\x73\xad\xb7\x92\x93\xa2\xdb\xda\x5f\x60\x70\x30\x25\x14\x4d\x15\x8e\x27\x35\x52\x95\x96\x25\x1c\x73\xc0\x34\x5c\xa6\xfc\xcb\x1f\xb1\xe9\x7e"
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\xff\x8e\x90\xa3\x7b\x94\x62\x39\x32\xc5\x9f\x75\x59\xf2\x60\x35\x02\x9c\x37\x67\x32\xcb\x14\xd4\x16\x02\x00\x1c\xbb\x73\xad\xb7\x92\x93\xa2\xdb\xda\x5f\x60\x70\x30\x25\x14\x4d\x15\x8e\x27\x35\x52\x95\x96\x25\x1c\x73\xc0\x34\x5c\xa6\xfc\xcb\x1f\xb1\xe9\x7e"
         }
     , MACVector
-        { macMessage = B.pack [ 0x00 .. 0xfe ]
-        , macKey     = fixedKey
-        , macResult  = digest "\x96\xfb\xcb\xb6\x0b\xd3\x13\xb8\x84\x50\x33\xe5\xbc\x05\x8a\x38\x02\x74\x38\x57\x2d\x7e\x79\x57\xf3\x68\x4f\x62\x68\xaa\xdd\x3a\xd0\x8d\x21\x76\x7e\xd6\x87\x86\x85\x33\x1b\xa9\x85\x71\x48\x7e\x12\x47\x0a\xad\x66\x93\x26\x71\x6e\x46\x66\x7f\x69\xf8\xd7\xe8"
+        { macMessage = B.pack [0x00 .. 0xfe]
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x96\xfb\xcb\xb6\x0b\xd3\x13\xb8\x84\x50\x33\xe5\xbc\x05\x8a\x38\x02\x74\x38\x57\x2d\x7e\x79\x57\xf3\x68\x4f\x62\x68\xaa\xdd\x3a\xd0\x8d\x21\x76\x7e\xd6\x87\x86\x85\x33\x1b\xa9\x85\x71\x48\x7e\x12\x47\x0a\xad\x66\x93\x26\x71\x6e\x46\x66\x7f\x69\xf8\xd7\xe8"
         }
     ]
-    where fixedKey = B.pack [ 0x00 .. 0x3f ]
+  where
+    fixedKey = B.pack [0x00 .. 0x3f]
 
 vectorsBlake2sKAT :: [MACVector (Blake2s 256)]
 vectorsBlake2sKAT =
     [ MACVector
         { macMessage = ""
-        , macKey     = fixedKey
-        , macResult  = digest "\x48\xa8\x99\x7d\xa4\x07\x87\x6b\x3d\x79\xc0\xd9\x23\x25\xad\x3b\x89\xcb\xb7\x54\xd8\x6a\xb7\x1a\xee\x04\x7a\xd3\x45\xfd\x2c\x49"
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x48\xa8\x99\x7d\xa4\x07\x87\x6b\x3d\x79\xc0\xd9\x23\x25\xad\x3b\x89\xcb\xb7\x54\xd8\x6a\xb7\x1a\xee\x04\x7a\xd3\x45\xfd\x2c\x49"
         }
     , MACVector
         { macMessage = "\x00"
-        , macKey     = fixedKey
-        , macResult  = digest "\x40\xd1\x5f\xee\x7c\x32\x88\x30\x16\x6a\xc3\xf9\x18\x65\x0f\x80\x7e\x7e\x01\xe1\x77\x25\x8c\xdc\x0a\x39\xb1\x1f\x59\x80\x66\xf1"
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x40\xd1\x5f\xee\x7c\x32\x88\x30\x16\x6a\xc3\xf9\x18\x65\x0f\x80\x7e\x7e\x01\xe1\x77\x25\x8c\xdc\x0a\x39\xb1\x1f\x59\x80\x66\xf1"
         }
     , MACVector
-        { macMessage = B.pack [ 0x00 .. 0xfe ]
-        , macKey     = fixedKey
-        , macResult  = digest "\x3f\xb7\x35\x06\x1a\xbc\x51\x9d\xfe\x97\x9e\x54\xc1\xee\x5b\xfa\xd0\xa9\xd8\x58\xb3\x31\x5b\xad\x34\xbd\xe9\x99\xef\xd7\x24\xdd"
+        { macMessage = B.pack [0x00 .. 0xfe]
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x3f\xb7\x35\x06\x1a\xbc\x51\x9d\xfe\x97\x9e\x54\xc1\xee\x5b\xfa\xd0\xa9\xd8\x58\xb3\x31\x5b\xad\x34\xbd\xe9\x99\xef\xd7\x24\xdd"
         }
     ]
-    where fixedKey = B.pack [ 0x00 .. 0x1f ]
+  where
+    fixedKey = B.pack [0x00 .. 0x1f]
 
 vectorsBlake2spKAT :: [MACVector (Blake2sp 256)]
 vectorsBlake2spKAT =
     [ MACVector
         { macMessage = ""
-        , macKey     = fixedKey
-        , macResult  = digest "\x71\x5c\xb1\x38\x95\xae\xb6\x78\xf6\x12\x41\x60\xbf\xf2\x14\x65\xb3\x0f\x4f\x68\x74\x19\x3f\xc8\x51\xb4\x62\x10\x43\xf0\x9c\xc6"
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x71\x5c\xb1\x38\x95\xae\xb6\x78\xf6\x12\x41\x60\xbf\xf2\x14\x65\xb3\x0f\x4f\x68\x74\x19\x3f\xc8\x51\xb4\x62\x10\x43\xf0\x9c\xc6"
         }
     , MACVector
         { macMessage = "\x00"
-        , macKey     = fixedKey
-        , macResult  = digest "\x40\x57\x8f\xfa\x52\xbf\x51\xae\x18\x66\xf4\x28\x4d\x3a\x15\x7f\xc1\xbc\xd3\x6a\xc1\x3c\xbd\xcb\x03\x77\xe4\xd0\xcd\x0b\x66\x03"
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x40\x57\x8f\xfa\x52\xbf\x51\xae\x18\x66\xf4\x28\x4d\x3a\x15\x7f\xc1\xbc\xd3\x6a\xc1\x3c\xbd\xcb\x03\x77\xe4\xd0\xcd\x0b\x66\x03"
         }
     , MACVector
-        { macMessage = B.pack [ 0x00 .. 0xfe ]
-        , macKey     = fixedKey
-        , macResult  = digest "\x0c\x8a\x36\x59\x7d\x74\x61\xc6\x3a\x94\x73\x28\x21\xc9\x41\x85\x6c\x66\x83\x76\x60\x6c\x86\xa5\x2d\xe0\xee\x41\x04\xc6\x15\xdb"
+        { macMessage = B.pack [0x00 .. 0xfe]
+        , macKey = fixedKey
+        , macResult =
+            digest
+                "\x0c\x8a\x36\x59\x7d\x74\x61\xc6\x3a\x94\x73\x28\x21\xc9\x41\x85\x6c\x66\x83\x76\x60\x6c\x86\xa5\x2d\xe0\xee\x41\x04\xc6\x15\xdb"
         }
     ]
-    where fixedKey = B.pack [ 0x00 .. 0x1f ]
+  where
+    fixedKey = B.pack [0x00 .. 0x1f]
 
 macTests :: [TestTree]
 macTests =
@@ -113,16 +140,20 @@
     , testGroup "Blake2s_512" (concatMap toMACTest $ zip is vectorsBlake2sKAT)
     , testGroup "Blake2sp_512" (concatMap toMACTest $ zip is vectorsBlake2spKAT)
     ]
-    where toMACTest (i, MACVector{..}) =
-            [ testCase (show i) (macResult @=? KB.keyedBlake2 macKey macMessage)
-            , testCase ("incr-" ++ show i) (macResult @=?
-                        KB.finalize (KB.update (KB.initialize macKey) macMessage))
-            ]
-          is :: [Int]
-          is = [1..]
+  where
+    toMACTest (i, MACVector{..}) =
+        [ testCase (show i) (macResult @=? KB.keyedBlake2 macKey macMessage)
+        , testCase
+            ("incr-" ++ show i)
+            ( macResult
+                @=? KB.finalize (KB.update (KB.initialize macKey) macMessage)
+            )
+        ]
+    is :: [Int]
+    is = [1 ..]
 
 data MacIncremental a = MacIncremental ByteString ByteString (KB.KeyedBlake2 a)
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance KB.HashBlake2 a => Arbitrary (MacIncremental a) where
     arbitrary = do
@@ -130,13 +161,14 @@
         msg <- arbitraryBSof 1 99
         return $ MacIncremental key msg (KB.keyedBlake2 key msg)
 
-data MacIncrementalList a = MacIncrementalList ByteString [ByteString] (KB.KeyedBlake2 a)
-    deriving (Show,Eq)
+data MacIncrementalList a
+    = MacIncrementalList ByteString [ByteString] (KB.KeyedBlake2 a)
+    deriving (Show, Eq)
 
 instance KB.HashBlake2 a => Arbitrary (MacIncrementalList a) where
     arbitrary = do
         key <- arbitraryBSof 32 64
-        msgs <- choose (1,20) >>= \n -> replicateM n (arbitraryBSof 1 99)
+        msgs <- choose (1, 20) >>= \n -> replicateM n (arbitraryBSof 1 99)
         return $ MacIncrementalList key msgs (KB.keyedBlake2 key (B.concat msgs))
 
 macIncrementalTests :: [TestTree]
@@ -147,20 +179,25 @@
     , testIncrProperties "Blake2sp_256" (Blake2sp :: Blake2sp 256)
     ]
   where
-        testIncrProperties :: KB.HashBlake2 a => TestName -> a -> TestTree
-        testIncrProperties name a = testGroup name
+    testIncrProperties :: KB.HashBlake2 a => TestName -> a -> TestTree
+    testIncrProperties name a =
+        testGroup
+            name
             [ testProperty "list-one" (prop_inc0 a)
             , testProperty "list-multi" (prop_inc1 a)
             ]
 
-        prop_inc0 :: KB.HashBlake2 a => a -> MacIncremental a -> Bool
-        prop_inc0 _ (MacIncremental secret msg result) =
-            result `assertEq` KB.finalize (KB.update (KB.initialize secret) msg)
+    prop_inc0 :: KB.HashBlake2 a => a -> MacIncremental a -> Bool
+    prop_inc0 _ (MacIncremental secret msg result) =
+        result `assertEq` KB.finalize (KB.update (KB.initialize secret) msg)
 
-        prop_inc1 :: KB.HashBlake2 a => a -> MacIncrementalList a -> Bool
-        prop_inc1 _ (MacIncrementalList secret msgs result) =
-            result `assertEq` KB.finalize (foldl' KB.update (KB.initialize secret) msgs)
+    prop_inc1 :: KB.HashBlake2 a => a -> MacIncrementalList a -> Bool
+    prop_inc1 _ (MacIncrementalList secret msgs result) =
+        result `assertEq` KB.finalize (foldl' KB.update (KB.initialize secret) msgs)
 
-tests = testGroup "Blake2"
-    [ testGroup "KATs" macTests
-    , testGroup "properties" macIncrementalTests ]
+tests =
+    testGroup
+        "Blake2"
+        [ testGroup "KATs" macTests
+        , testGroup "properties" macIncrementalTests
+        ]
diff --git a/tests/KAT_Blowfish.hs b/tests/KAT_Blowfish.hs
--- a/tests/KAT_Blowfish.hs
+++ b/tests/KAT_Blowfish.hs
@@ -1,47 +1,151 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_Blowfish where
 
+import BlockCipher
 import Crypto.Cipher.Blowfish
 import Imports ()
-import BlockCipher
 
-vectors_ecb = -- key plaintext cipher
-    [ KAT_ECB "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x4E\xF9\x97\x45\x61\x98\xDD\x78"
-    , KAT_ECB "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x51\x86\x6F\xD5\xB8\x5E\xCB\x8A"
-    , KAT_ECB "\x30\x00\x00\x00\x00\x00\x00\x00" "\x10\x00\x00\x00\x00\x00\x00\x01" "\x7D\x85\x6F\x9A\x61\x30\x63\xF2"
-    , KAT_ECB "\x11\x11\x11\x11\x11\x11\x11\x11" "\x11\x11\x11\x11\x11\x11\x11\x11" "\x24\x66\xDD\x87\x8B\x96\x3C\x9D"
-    , KAT_ECB "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x11\x11\x11\x11\x11\x11\x11\x11" "\x61\xF9\xC3\x80\x22\x81\xB0\x96"
-    , KAT_ECB "\x11\x11\x11\x11\x11\x11\x11\x11" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x7D\x0C\xC6\x30\xAF\xDA\x1E\xC7"
-    , KAT_ECB "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x4E\xF9\x97\x45\x61\x98\xDD\x78"
-    , KAT_ECB "\xFE\xDC\xBA\x98\x76\x54\x32\x10" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x0A\xCE\xAB\x0F\xC6\xA0\xA2\x8D"
-    , KAT_ECB "\x7C\xA1\x10\x45\x4A\x1A\x6E\x57" "\x01\xA1\xD6\xD0\x39\x77\x67\x42" "\x59\xC6\x82\x45\xEB\x05\x28\x2B"
-    , KAT_ECB "\x01\x31\xD9\x61\x9D\xC1\x37\x6E" "\x5C\xD5\x4C\xA8\x3D\xEF\x57\xDA" "\xB1\xB8\xCC\x0B\x25\x0F\x09\xA0"
-    , KAT_ECB "\x07\xA1\x13\x3E\x4A\x0B\x26\x86" "\x02\x48\xD4\x38\x06\xF6\x71\x72" "\x17\x30\xE5\x77\x8B\xEA\x1D\xA4"
-    , KAT_ECB "\x38\x49\x67\x4C\x26\x02\x31\x9E" "\x51\x45\x4B\x58\x2D\xDF\x44\x0A" "\xA2\x5E\x78\x56\xCF\x26\x51\xEB"
-    , KAT_ECB "\x04\xB9\x15\xBA\x43\xFE\xB5\xB6" "\x42\xFD\x44\x30\x59\x57\x7F\xA2" "\x35\x38\x82\xB1\x09\xCE\x8F\x1A"
-    , KAT_ECB "\x01\x13\xB9\x70\xFD\x34\xF2\xCE" "\x05\x9B\x5E\x08\x51\xCF\x14\x3A" "\x48\xF4\xD0\x88\x4C\x37\x99\x18"
-    , KAT_ECB "\x01\x70\xF1\x75\x46\x8F\xB5\xE6" "\x07\x56\xD8\xE0\x77\x47\x61\xD2" "\x43\x21\x93\xB7\x89\x51\xFC\x98"
-    , KAT_ECB "\x43\x29\x7F\xAD\x38\xE3\x73\xFE" "\x76\x25\x14\xB8\x29\xBF\x48\x6A" "\x13\xF0\x41\x54\xD6\x9D\x1A\xE5"
-    , KAT_ECB "\x07\xA7\x13\x70\x45\xDA\x2A\x16" "\x3B\xDD\x11\x90\x49\x37\x28\x02" "\x2E\xED\xDA\x93\xFF\xD3\x9C\x79"
-    , KAT_ECB "\x04\x68\x91\x04\xC2\xFD\x3B\x2F" "\x26\x95\x5F\x68\x35\xAF\x60\x9A" "\xD8\x87\xE0\x39\x3C\x2D\xA6\xE3"
-    , KAT_ECB "\x37\xD0\x6B\xB5\x16\xCB\x75\x46" "\x16\x4D\x5E\x40\x4F\x27\x52\x32" "\x5F\x99\xD0\x4F\x5B\x16\x39\x69"
-    , KAT_ECB "\x1F\x08\x26\x0D\x1A\xC2\x46\x5E" "\x6B\x05\x6E\x18\x75\x9F\x5C\xCA" "\x4A\x05\x7A\x3B\x24\xD3\x97\x7B"
-    , KAT_ECB "\x58\x40\x23\x64\x1A\xBA\x61\x76" "\x00\x4B\xD6\xEF\x09\x17\x60\x62" "\x45\x20\x31\xC1\xE4\xFA\xDA\x8E"
-    , KAT_ECB "\x02\x58\x16\x16\x46\x29\xB0\x07" "\x48\x0D\x39\x00\x6E\xE7\x62\xF2" "\x75\x55\xAE\x39\xF5\x9B\x87\xBD"
-    , KAT_ECB "\x49\x79\x3E\xBC\x79\xB3\x25\x8F" "\x43\x75\x40\xC8\x69\x8F\x3C\xFA" "\x53\xC5\x5F\x9C\xB4\x9F\xC0\x19"
-    , KAT_ECB "\x4F\xB0\x5E\x15\x15\xAB\x73\xA7" "\x07\x2D\x43\xA0\x77\x07\x52\x92" "\x7A\x8E\x7B\xFA\x93\x7E\x89\xA3"
-    , KAT_ECB "\x49\xE9\x5D\x6D\x4C\xA2\x29\xBF" "\x02\xFE\x55\x77\x81\x17\xF1\x2A" "\xCF\x9C\x5D\x7A\x49\x86\xAD\xB5"
-    , KAT_ECB "\x01\x83\x10\xDC\x40\x9B\x26\xD6" "\x1D\x9D\x5C\x50\x18\xF7\x28\xC2" "\xD1\xAB\xB2\x90\x65\x8B\xC7\x78"
-    , KAT_ECB "\x1C\x58\x7F\x1C\x13\x92\x4F\xEF" "\x30\x55\x32\x28\x6D\x6F\x29\x5A" "\x55\xCB\x37\x74\xD1\x3E\xF2\x01"
-    , KAT_ECB "\x01\x01\x01\x01\x01\x01\x01\x01" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\xFA\x34\xEC\x48\x47\xB2\x68\xB2"
-    , KAT_ECB "\x1F\x1F\x1F\x1F\x0E\x0E\x0E\x0E" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\xA7\x90\x79\x51\x08\xEA\x3C\xAE"
-    , KAT_ECB "\xE0\xFE\xE0\xFE\xF1\xFE\xF1\xFE" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\xC3\x9E\x07\x2D\x9F\xAC\x63\x1D"
-    , KAT_ECB "\x00\x00\x00\x00\x00\x00\x00\x00" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x01\x49\x33\xE0\xCD\xAF\xF6\xE4"
-    , KAT_ECB "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x00\x00\x00\x00\x00\x00\x00\x00" "\xF2\x1E\x9A\x77\xB7\x1C\x49\xBC"
-    , KAT_ECB "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x24\x59\x46\x88\x57\x54\x36\x9A"
-    , KAT_ECB "\xFE\xDC\xBA\x98\x76\x54\x32\x10" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x6B\x5C\x5A\x9C\x5D\x9E\x0A\x5A"
+vectors_ecb =
+    -- key plaintext cipher
+    [ KAT_ECB
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\x4E\xF9\x97\x45\x61\x98\xDD\x78"
+    , KAT_ECB
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\x51\x86\x6F\xD5\xB8\x5E\xCB\x8A"
+    , KAT_ECB
+        "\x30\x00\x00\x00\x00\x00\x00\x00"
+        "\x10\x00\x00\x00\x00\x00\x00\x01"
+        "\x7D\x85\x6F\x9A\x61\x30\x63\xF2"
+    , KAT_ECB
+        "\x11\x11\x11\x11\x11\x11\x11\x11"
+        "\x11\x11\x11\x11\x11\x11\x11\x11"
+        "\x24\x66\xDD\x87\x8B\x96\x3C\x9D"
+    , KAT_ECB
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x11\x11\x11\x11\x11\x11\x11\x11"
+        "\x61\xF9\xC3\x80\x22\x81\xB0\x96"
+    , KAT_ECB
+        "\x11\x11\x11\x11\x11\x11\x11\x11"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x7D\x0C\xC6\x30\xAF\xDA\x1E\xC7"
+    , KAT_ECB
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\x4E\xF9\x97\x45\x61\x98\xDD\x78"
+    , KAT_ECB
+        "\xFE\xDC\xBA\x98\x76\x54\x32\x10"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x0A\xCE\xAB\x0F\xC6\xA0\xA2\x8D"
+    , KAT_ECB
+        "\x7C\xA1\x10\x45\x4A\x1A\x6E\x57"
+        "\x01\xA1\xD6\xD0\x39\x77\x67\x42"
+        "\x59\xC6\x82\x45\xEB\x05\x28\x2B"
+    , KAT_ECB
+        "\x01\x31\xD9\x61\x9D\xC1\x37\x6E"
+        "\x5C\xD5\x4C\xA8\x3D\xEF\x57\xDA"
+        "\xB1\xB8\xCC\x0B\x25\x0F\x09\xA0"
+    , KAT_ECB
+        "\x07\xA1\x13\x3E\x4A\x0B\x26\x86"
+        "\x02\x48\xD4\x38\x06\xF6\x71\x72"
+        "\x17\x30\xE5\x77\x8B\xEA\x1D\xA4"
+    , KAT_ECB
+        "\x38\x49\x67\x4C\x26\x02\x31\x9E"
+        "\x51\x45\x4B\x58\x2D\xDF\x44\x0A"
+        "\xA2\x5E\x78\x56\xCF\x26\x51\xEB"
+    , KAT_ECB
+        "\x04\xB9\x15\xBA\x43\xFE\xB5\xB6"
+        "\x42\xFD\x44\x30\x59\x57\x7F\xA2"
+        "\x35\x38\x82\xB1\x09\xCE\x8F\x1A"
+    , KAT_ECB
+        "\x01\x13\xB9\x70\xFD\x34\xF2\xCE"
+        "\x05\x9B\x5E\x08\x51\xCF\x14\x3A"
+        "\x48\xF4\xD0\x88\x4C\x37\x99\x18"
+    , KAT_ECB
+        "\x01\x70\xF1\x75\x46\x8F\xB5\xE6"
+        "\x07\x56\xD8\xE0\x77\x47\x61\xD2"
+        "\x43\x21\x93\xB7\x89\x51\xFC\x98"
+    , KAT_ECB
+        "\x43\x29\x7F\xAD\x38\xE3\x73\xFE"
+        "\x76\x25\x14\xB8\x29\xBF\x48\x6A"
+        "\x13\xF0\x41\x54\xD6\x9D\x1A\xE5"
+    , KAT_ECB
+        "\x07\xA7\x13\x70\x45\xDA\x2A\x16"
+        "\x3B\xDD\x11\x90\x49\x37\x28\x02"
+        "\x2E\xED\xDA\x93\xFF\xD3\x9C\x79"
+    , KAT_ECB
+        "\x04\x68\x91\x04\xC2\xFD\x3B\x2F"
+        "\x26\x95\x5F\x68\x35\xAF\x60\x9A"
+        "\xD8\x87\xE0\x39\x3C\x2D\xA6\xE3"
+    , KAT_ECB
+        "\x37\xD0\x6B\xB5\x16\xCB\x75\x46"
+        "\x16\x4D\x5E\x40\x4F\x27\x52\x32"
+        "\x5F\x99\xD0\x4F\x5B\x16\x39\x69"
+    , KAT_ECB
+        "\x1F\x08\x26\x0D\x1A\xC2\x46\x5E"
+        "\x6B\x05\x6E\x18\x75\x9F\x5C\xCA"
+        "\x4A\x05\x7A\x3B\x24\xD3\x97\x7B"
+    , KAT_ECB
+        "\x58\x40\x23\x64\x1A\xBA\x61\x76"
+        "\x00\x4B\xD6\xEF\x09\x17\x60\x62"
+        "\x45\x20\x31\xC1\xE4\xFA\xDA\x8E"
+    , KAT_ECB
+        "\x02\x58\x16\x16\x46\x29\xB0\x07"
+        "\x48\x0D\x39\x00\x6E\xE7\x62\xF2"
+        "\x75\x55\xAE\x39\xF5\x9B\x87\xBD"
+    , KAT_ECB
+        "\x49\x79\x3E\xBC\x79\xB3\x25\x8F"
+        "\x43\x75\x40\xC8\x69\x8F\x3C\xFA"
+        "\x53\xC5\x5F\x9C\xB4\x9F\xC0\x19"
+    , KAT_ECB
+        "\x4F\xB0\x5E\x15\x15\xAB\x73\xA7"
+        "\x07\x2D\x43\xA0\x77\x07\x52\x92"
+        "\x7A\x8E\x7B\xFA\x93\x7E\x89\xA3"
+    , KAT_ECB
+        "\x49\xE9\x5D\x6D\x4C\xA2\x29\xBF"
+        "\x02\xFE\x55\x77\x81\x17\xF1\x2A"
+        "\xCF\x9C\x5D\x7A\x49\x86\xAD\xB5"
+    , KAT_ECB
+        "\x01\x83\x10\xDC\x40\x9B\x26\xD6"
+        "\x1D\x9D\x5C\x50\x18\xF7\x28\xC2"
+        "\xD1\xAB\xB2\x90\x65\x8B\xC7\x78"
+    , KAT_ECB
+        "\x1C\x58\x7F\x1C\x13\x92\x4F\xEF"
+        "\x30\x55\x32\x28\x6D\x6F\x29\x5A"
+        "\x55\xCB\x37\x74\xD1\x3E\xF2\x01"
+    , KAT_ECB
+        "\x01\x01\x01\x01\x01\x01\x01\x01"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\xFA\x34\xEC\x48\x47\xB2\x68\xB2"
+    , KAT_ECB
+        "\x1F\x1F\x1F\x1F\x0E\x0E\x0E\x0E"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\xA7\x90\x79\x51\x08\xEA\x3C\xAE"
+    , KAT_ECB
+        "\xE0\xFE\xE0\xFE\xF1\xFE\xF1\xFE"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\xC3\x9E\x07\x2D\x9F\xAC\x63\x1D"
+    , KAT_ECB
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\x01\x49\x33\xE0\xCD\xAF\xF6\xE4"
+    , KAT_ECB
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\xF2\x1E\x9A\x77\xB7\x1C\x49\xBC"
+    , KAT_ECB
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\x24\x59\x46\x88\x57\x54\x36\x9A"
+    , KAT_ECB
+        "\xFE\xDC\xBA\x98\x76\x54\x32\x10"
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\x6B\x5C\x5A\x9C\x5D\x9E\x0A\x5A"
     ]
 
-kats = defaultKATs { kat_ECB = vectors_ecb }
+kats = defaultKATs{kat_ECB = vectors_ecb}
 
 tests = testBlockCipher kats (undefined :: Blowfish64)
diff --git a/tests/KAT_CAST5.hs b/tests/KAT_CAST5.hs
--- a/tests/KAT_CAST5.hs
+++ b/tests/KAT_CAST5.hs
@@ -1,15 +1,26 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_CAST5 (tests) where
 
 import BlockCipher
 import qualified Crypto.Cipher.CAST5 as CAST5
 
-vectors_ecb = -- key plaintext ciphertext
-    [ KAT_ECB "\x01\x23\x45\x67\x12\x34\x56\x78\x23\x45\x67\x89\x34\x56\x78\x9A" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x23\x8B\x4F\xE5\x84\x7E\x44\xB2"
-    , KAT_ECB "\x01\x23\x45\x67\x12\x34\x56\x78\x23\x45"                         "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\xEB\x6A\x71\x1A\x2C\x02\x27\x1B"
-    , KAT_ECB "\x01\x23\x45\x67\x12"                                             "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x7A\xC8\x16\xD1\x6E\x9B\x30\x2E"
+vectors_ecb =
+    -- key plaintext ciphertext
+    [ KAT_ECB
+        "\x01\x23\x45\x67\x12\x34\x56\x78\x23\x45\x67\x89\x34\x56\x78\x9A"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x23\x8B\x4F\xE5\x84\x7E\x44\xB2"
+    , KAT_ECB
+        "\x01\x23\x45\x67\x12\x34\x56\x78\x23\x45"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\xEB\x6A\x71\x1A\x2C\x02\x27\x1B"
+    , KAT_ECB
+        "\x01\x23\x45\x67\x12"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x7A\xC8\x16\xD1\x6E\x9B\x30\x2E"
     ]
 
-kats = defaultKATs { kat_ECB = vectors_ecb }
+kats = defaultKATs{kat_ECB = vectors_ecb}
 
 tests = testBlockCipher kats (undefined :: CAST5.CAST5)
diff --git a/tests/KAT_CMAC.hs b/tests/KAT_CMAC.hs
--- a/tests/KAT_CMAC.hs
+++ b/tests/KAT_CMAC.hs
@@ -1,26 +1,31 @@
-
 module KAT_CMAC (tests) where
 
+import Crypto.Cipher.AES (AES128, AES192, AES256)
+import Crypto.Cipher.TripleDES (DES_EDE2, DES_EDE3)
+import Crypto.Cipher.Types (
+    BlockCipher,
+    Cipher,
+    blockSize,
+    cipherInit,
+    ecbEncrypt,
+ )
+import Crypto.Error (eitherCryptoError)
 import qualified Crypto.MAC.CMAC as CMAC
-import           Crypto.Cipher.Types (Cipher, cipherInit, BlockCipher, ecbEncrypt, blockSize)
-import           Crypto.Error (eitherCryptoError)
-import           Crypto.Cipher.AES (AES128, AES192, AES256)
-import           Crypto.Cipher.TripleDES (DES_EDE3, DES_EDE2)
 
-import           Imports
+import Imports
 
-import           Data.Char (digitToInt)
-import qualified Data.ByteString as BS
 import qualified Data.ByteArray as B
-
+import qualified Data.ByteString as BS
+import Data.Char (digitToInt)
 
 hxs :: String -> ByteString
-hxs = BS.pack . rec' where
+hxs = BS.pack . rec'
+  where
     dtoW8 = fromIntegral . digitToInt
-    rec' (' ':xs)  =  rec' xs
-    rec' (x:y:xs)  =  dtoW8 x * 16 + dtoW8 y : rec' xs
-    rec' [_]       =  error "hxs: invalid hex pattern."
-    rec' []        =  []
+    rec' (' ' : xs) = rec' xs
+    rec' (x : y : xs) = dtoW8 x * 16 + dtoW8 y : rec' xs
+    rec' [_] = error "hxs: invalid hex pattern."
+    rec' [] = []
 
 unsafeCipher :: Cipher k => ByteString -> k
 unsafeCipher = either (error . show) id . eitherCryptoError . cipherInit
@@ -36,11 +41,11 @@
 
 msg512 :: ByteString
 msg512 =
-  hxs $
-  "6bc1bee2 2e409f96 e93d7e11 7393172a" ++
-  "ae2d8a57 1e03ac9c 9eb76fac 45af8e51" ++
-  "30c81c46 a35ce411 e5fbc119 1a0a52ef" ++
-  "f69f2445 df4f9b17 ad2b417b e66c3710"
+    hxs $
+        "6bc1bee2 2e409f96 e93d7e11 7393172a"
+            ++ "ae2d8a57 1e03ac9c 9eb76fac 45af8e51"
+            ++ "30c81c46 a35ce411 e5fbc119 1a0a52ef"
+            ++ "f69f2445 df4f9b17 ad2b417b e66c3710"
 
 msg320 :: ByteString
 msg320 = BS.take 40 msg512
@@ -65,146 +70,148 @@
 
 gAES128 :: TestTree
 gAES128 =
-    igroup "aes128"
-    [ ecb0 aes128key @?=  hxs "7df76b0c 1ab899b3 3e42f047 b91b546f"
-    , aes128k1 @?=        hxs "fbeed618 35713366 7c85e08f 7236a8de"
-    , aes128k2 @?=        hxs "f7ddac30 6ae266cc f90bc11e e46d513b"
-
-    , bsCMAC aes128key msg0
-      @?=                 hxs "bb1d6929 e9593728 7fa37d12 9b756746"
-    , bsCMAC aes128key msg128
-      @?=                 hxs "070a16b4 6b4d4144 f79bdd9d d04a287c"
-    , bsCMAC aes128key msg320
-      @?=                 hxs "dfa66747 de9ae630 30ca3261 1497c827"
-    , bsCMAC aes128key msg512
-      @?=                 hxs "51f0bebf 7e3b9d92 fc497417 79363cfe"
-    ]
+    igroup
+        "aes128"
+        [ ecb0 aes128key @?= hxs "7df76b0c 1ab899b3 3e42f047 b91b546f"
+        , aes128k1 @?= hxs "fbeed618 35713366 7c85e08f 7236a8de"
+        , aes128k2 @?= hxs "f7ddac30 6ae266cc f90bc11e e46d513b"
+        , bsCMAC aes128key msg0
+            @?= hxs "bb1d6929 e9593728 7fa37d12 9b756746"
+        , bsCMAC aes128key msg128
+            @?= hxs "070a16b4 6b4d4144 f79bdd9d d04a287c"
+        , bsCMAC aes128key msg320
+            @?= hxs "dfa66747 de9ae630 30ca3261 1497c827"
+        , bsCMAC aes128key msg512
+            @?= hxs "51f0bebf 7e3b9d92 fc497417 79363cfe"
+        ]
   where
     aes128key :: AES128
     aes128key =
-        unsafeCipher $ hxs
-        "2b7e1516 28aed2a6 abf71588 09cf4f3c"
+        unsafeCipher $
+            hxs
+                "2b7e1516 28aed2a6 abf71588 09cf4f3c"
 
     aes128k1, aes128k2 :: ByteString
     (aes128k1, aes128k2) = CMAC.subKeys aes128key
 
-
 gAES192 :: TestTree
 gAES192 =
-    igroup "aes192"
-    [ ecb0 aes192key @?=  hxs "22452d8e 49a8a593 9f7321ce ea6d514b"
-    , aes192k1 @?=        hxs "448a5b1c 93514b27 3ee6439d d4daa296"
-    , aes192k2 @?=        hxs "8914b639 26a2964e 7dcc873b a9b5452c"
-
-    , bsCMAC aes192key msg0
-      @?=                 hxs "d17ddf46 adaacde5 31cac483 de7a9367"
-    , bsCMAC aes192key msg128
-      @?=                 hxs "9e99a7bf 31e71090 0662f65e 617c5184"
-    , bsCMAC aes192key msg320
-      @?=                 hxs "8a1de5be 2eb31aad 089a82e6 ee908b0e"
-    , bsCMAC aes192key msg512
-      @?=                 hxs "a1d5df0e ed790f79 4d775896 59f39a11"
-    ]
+    igroup
+        "aes192"
+        [ ecb0 aes192key @?= hxs "22452d8e 49a8a593 9f7321ce ea6d514b"
+        , aes192k1 @?= hxs "448a5b1c 93514b27 3ee6439d d4daa296"
+        , aes192k2 @?= hxs "8914b639 26a2964e 7dcc873b a9b5452c"
+        , bsCMAC aes192key msg0
+            @?= hxs "d17ddf46 adaacde5 31cac483 de7a9367"
+        , bsCMAC aes192key msg128
+            @?= hxs "9e99a7bf 31e71090 0662f65e 617c5184"
+        , bsCMAC aes192key msg320
+            @?= hxs "8a1de5be 2eb31aad 089a82e6 ee908b0e"
+        , bsCMAC aes192key msg512
+            @?= hxs "a1d5df0e ed790f79 4d775896 59f39a11"
+        ]
   where
     aes192key :: AES192
     aes192key =
         unsafeCipher . hxs $
-        "8e73b0f7 da0e6452 c810f32b 809079e5" ++
-        "62f8ead2 522c6b7b"
+            "8e73b0f7 da0e6452 c810f32b 809079e5"
+                ++ "62f8ead2 522c6b7b"
 
     aes192k1, aes192k2 :: ByteString
     (aes192k1, aes192k2) = CMAC.subKeys aes192key
 
 gAES256 :: TestTree
 gAES256 =
-    igroup "aes256"
-    [ ecb0 aes256key @?=  hxs "e568f681 94cf76d6 174d4cc0 4310a854"
-    , aes256k1 @?=        hxs "cad1ed03 299eedac 2e9a9980 8621502f"
-    , aes256k2 @?=        hxs "95a3da06 533ddb58 5d353301 0c42a0d9"
-
-    , bsCMAC aes256key msg0
-      @?=                 hxs "028962f6 1b7bf89e fc6b551f 4667d983"
-    , bsCMAC aes256key msg128
-      @?=                 hxs "28a7023f 452e8f82 bd4bf28d 8c37c35c"
-    , bsCMAC aes256key msg320
-      @?=                 hxs "aaf3d8f1 de5640c2 32f5b169 b9c911e6"
-    , bsCMAC aes256key msg512
-      @?=                 hxs "e1992190 549f6ed5 696a2c05 6c315410"
-    ]
+    igroup
+        "aes256"
+        [ ecb0 aes256key @?= hxs "e568f681 94cf76d6 174d4cc0 4310a854"
+        , aes256k1 @?= hxs "cad1ed03 299eedac 2e9a9980 8621502f"
+        , aes256k2 @?= hxs "95a3da06 533ddb58 5d353301 0c42a0d9"
+        , bsCMAC aes256key msg0
+            @?= hxs "028962f6 1b7bf89e fc6b551f 4667d983"
+        , bsCMAC aes256key msg128
+            @?= hxs "28a7023f 452e8f82 bd4bf28d 8c37c35c"
+        , bsCMAC aes256key msg320
+            @?= hxs "aaf3d8f1 de5640c2 32f5b169 b9c911e6"
+        , bsCMAC aes256key msg512
+            @?= hxs "e1992190 549f6ed5 696a2c05 6c315410"
+        ]
   where
     aes256key :: AES256
     aes256key =
         unsafeCipher . hxs $
-        "603deb10 15ca71be 2b73aef0 857d7781" ++
-        "1f352c07 3b6108d7 2d9810a3 0914dff4"
+            "603deb10 15ca71be 2b73aef0 857d7781"
+                ++ "1f352c07 3b6108d7 2d9810a3 0914dff4"
 
     aes256k1, aes256k2 :: ByteString
     (aes256k1, aes256k2) = CMAC.subKeys aes256key
 
 gTDEA3 :: TestTree
 gTDEA3 =
-    igroup "Three Key TDEA"
-    [ ecb0 tdea3key @?=  hxs "c8cc74e9 8a7329a2"
-    , tdea3k1 @?=        hxs "9198e9d3 14e6535f"
-    , tdea3k2 @?=        hxs "2331d3a6 29cca6a5"
-
-    , bsCMAC tdea3key msg0
-      @?=                hxs "b7a688e1 22ffaf95"
-    , bsCMAC tdea3key msg64
-      @?=                hxs "8e8f2931 36283797"
-    , bsCMAC tdea3key msg160
-      @?=                hxs "743ddbe0 ce2dc2ed"
-    , bsCMAC tdea3key msg256
-      @?=                hxs "33e6b109 2400eae5"
-    ]
+    igroup
+        "Three Key TDEA"
+        [ ecb0 tdea3key @?= hxs "c8cc74e9 8a7329a2"
+        , tdea3k1 @?= hxs "9198e9d3 14e6535f"
+        , tdea3k2 @?= hxs "2331d3a6 29cca6a5"
+        , bsCMAC tdea3key msg0
+            @?= hxs "b7a688e1 22ffaf95"
+        , bsCMAC tdea3key msg64
+            @?= hxs "8e8f2931 36283797"
+        , bsCMAC tdea3key msg160
+            @?= hxs "743ddbe0 ce2dc2ed"
+        , bsCMAC tdea3key msg256
+            @?= hxs "33e6b109 2400eae5"
+        ]
   where
     tdea3key :: DES_EDE3
     tdea3key =
         unsafeCipher . hxs $
-        "8aa83bf8 cbda1062" ++
-        "0bc1bf19 fbb6cd58" ++
-        "bc313d4a 371ca8b5"
+            "8aa83bf8 cbda1062"
+                ++ "0bc1bf19 fbb6cd58"
+                ++ "bc313d4a 371ca8b5"
 
     tdea3k1, tdea3k2 :: ByteString
     (tdea3k1, tdea3k2) = CMAC.subKeys tdea3key
 
 gTDEA2 :: TestTree
 gTDEA2 =
-    igroup "Two Key TDEA"
-    [ ecb0 tdea2key @?=  hxs "c7679b9f 6b8d7d7a"
-    , tdea2k1 @?=        hxs "8ecf373e d71afaef"
-    , tdea2k2 @?=        hxs "1d9e6e7d ae35f5c5"
-
-    , bsCMAC tdea2key msg0
-      @?=                hxs "bd2ebf9a 3ba00361"
-    , bsCMAC tdea2key msg64
-      @?=                hxs "4ff2ab81 3c53ce83"
-    , bsCMAC tdea2key msg160
-      @?=                hxs "62dd1b47 1902bd4e"
-    , bsCMAC tdea2key msg256
-      @?=                hxs "31b1e431 dabc4eb8"
-    ]
+    igroup
+        "Two Key TDEA"
+        [ ecb0 tdea2key @?= hxs "c7679b9f 6b8d7d7a"
+        , tdea2k1 @?= hxs "8ecf373e d71afaef"
+        , tdea2k2 @?= hxs "1d9e6e7d ae35f5c5"
+        , bsCMAC tdea2key msg0
+            @?= hxs "bd2ebf9a 3ba00361"
+        , bsCMAC tdea2key msg64
+            @?= hxs "4ff2ab81 3c53ce83"
+        , bsCMAC tdea2key msg160
+            @?= hxs "62dd1b47 1902bd4e"
+        , bsCMAC tdea2key msg256
+            @?= hxs "31b1e431 dabc4eb8"
+        ]
   where
     tdea2key :: DES_EDE2
     tdea2key =
-          unsafeCipher . hxs $
-          "4cf15134 a2850dd5" ++
-          "8a3d10ba 80570d38"
+        unsafeCipher . hxs $
+            "4cf15134 a2850dd5"
+                ++ "8a3d10ba 80570d38"
 
     tdea2k1, tdea2k2 :: ByteString
     (tdea2k1, tdea2k2) = CMAC.subKeys tdea2key
 
 igroup :: TestName -> [Assertion] -> TestTree
-igroup nm = testGroup nm . zipWith (flip ($)) [1..] . map icase
+igroup nm = testGroup nm . zipWith (flip ($)) [1 ..] . map icase
   where
     icase c i = testCase (show (i :: Int)) c
 
 nistVectors :: TestTree
 nistVectors =
-    testGroup "KAT - NIST test vectors"
-    [ gAES128, gAES192, gAES256, gTDEA3, gTDEA2 ]
+    testGroup
+        "KAT - NIST test vectors"
+        [gAES128, gAES192, gAES256, gTDEA3, gTDEA2]
 
 tests :: TestTree
 tests =
-    testGroup "CMAC"
-    [ nistVectors ]
+    testGroup
+        "CMAC"
+        [nistVectors]
diff --git a/tests/KAT_Camellia.hs b/tests/KAT_Camellia.hs
--- a/tests/KAT_Camellia.hs
+++ b/tests/KAT_Camellia.hs
@@ -2,33 +2,246 @@
 {-# LANGUAGE ViewPatterns #-}
 {-# OPTIONS_GHC -fno-warn-unused-binds #-}
 {-# OPTIONS_GHC -fno-warn-unused-matches #-}
+
 module KAT_Camellia (tests) where
 
-import Imports ()
 import BlockCipher
+import Imports ()
 
-import qualified Data.ByteString as B
 import Crypto.Cipher.Camellia
+import qualified Data.ByteString as B
 
 vectors_camellia128 =
-    [ KAT_ECB (B.replicate 16 0) (B.replicate 16 0) (B.pack [0x3d,0x02,0x80,0x25,0xb1,0x56,0x32,0x7c,0x17,0xf7,0x62,0xc1,0xf2,0xcb,0xca,0x71])
-    , KAT_ECB (B.pack [0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10])
-              (B.pack [0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10])
-              (B.pack [0x67,0x67,0x31,0x38,0x54,0x96,0x69,0x73,0x08,0x57,0x06,0x56,0x48,0xea,0xbe,0x43])
+    [ KAT_ECB
+        (B.replicate 16 0)
+        (B.replicate 16 0)
+        ( B.pack
+            [ 0x3d
+            , 0x02
+            , 0x80
+            , 0x25
+            , 0xb1
+            , 0x56
+            , 0x32
+            , 0x7c
+            , 0x17
+            , 0xf7
+            , 0x62
+            , 0xc1
+            , 0xf2
+            , 0xcb
+            , 0xca
+            , 0x71
+            ]
+        )
+    , KAT_ECB
+        ( B.pack
+            [ 0x01
+            , 0x23
+            , 0x45
+            , 0x67
+            , 0x89
+            , 0xab
+            , 0xcd
+            , 0xef
+            , 0xfe
+            , 0xdc
+            , 0xba
+            , 0x98
+            , 0x76
+            , 0x54
+            , 0x32
+            , 0x10
+            ]
+        )
+        ( B.pack
+            [ 0x01
+            , 0x23
+            , 0x45
+            , 0x67
+            , 0x89
+            , 0xab
+            , 0xcd
+            , 0xef
+            , 0xfe
+            , 0xdc
+            , 0xba
+            , 0x98
+            , 0x76
+            , 0x54
+            , 0x32
+            , 0x10
+            ]
+        )
+        ( B.pack
+            [ 0x67
+            , 0x67
+            , 0x31
+            , 0x38
+            , 0x54
+            , 0x96
+            , 0x69
+            , 0x73
+            , 0x08
+            , 0x57
+            , 0x06
+            , 0x56
+            , 0x48
+            , 0xea
+            , 0xbe
+            , 0x43
+            ]
+        )
     ]
 
 vectors_camellia192 =
-    [ KAT_ECB (B.pack [0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77]) (B.pack [0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10]) (B.pack [0xb4,0x99,0x34,0x01,0xb3,0xe9,0x96,0xf8,0x4e,0xe5,0xce,0xe7,0xd7,0x9b,0x09,0xb9])
+    [ KAT_ECB
+        ( B.pack
+            [ 0x01
+            , 0x23
+            , 0x45
+            , 0x67
+            , 0x89
+            , 0xab
+            , 0xcd
+            , 0xef
+            , 0xfe
+            , 0xdc
+            , 0xba
+            , 0x98
+            , 0x76
+            , 0x54
+            , 0x32
+            , 0x10
+            , 0x00
+            , 0x11
+            , 0x22
+            , 0x33
+            , 0x44
+            , 0x55
+            , 0x66
+            , 0x77
+            ]
+        )
+        ( B.pack
+            [ 0x01
+            , 0x23
+            , 0x45
+            , 0x67
+            , 0x89
+            , 0xab
+            , 0xcd
+            , 0xef
+            , 0xfe
+            , 0xdc
+            , 0xba
+            , 0x98
+            , 0x76
+            , 0x54
+            , 0x32
+            , 0x10
+            ]
+        )
+        ( B.pack
+            [ 0xb4
+            , 0x99
+            , 0x34
+            , 0x01
+            , 0xb3
+            , 0xe9
+            , 0x96
+            , 0xf8
+            , 0x4e
+            , 0xe5
+            , 0xce
+            , 0xe7
+            , 0xd7
+            , 0x9b
+            , 0x09
+            , 0xb9
+            ]
+        )
     ]
 
 vectors_camellia256 =
-    [ KAT_ECB (B.pack [0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10 ,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff])
-              (B.pack [0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10])
-              (B.pack [0x9a,0xcc,0x23,0x7d,0xff,0x16,0xd7,0x6c,0x20,0xef,0x7c,0x91,0x9e,0x3a,0x75,0x09])
+    [ KAT_ECB
+        ( B.pack
+            [ 0x01
+            , 0x23
+            , 0x45
+            , 0x67
+            , 0x89
+            , 0xab
+            , 0xcd
+            , 0xef
+            , 0xfe
+            , 0xdc
+            , 0xba
+            , 0x98
+            , 0x76
+            , 0x54
+            , 0x32
+            , 0x10
+            , 0x00
+            , 0x11
+            , 0x22
+            , 0x33
+            , 0x44
+            , 0x55
+            , 0x66
+            , 0x77
+            , 0x88
+            , 0x99
+            , 0xaa
+            , 0xbb
+            , 0xcc
+            , 0xdd
+            , 0xee
+            , 0xff
+            ]
+        )
+        ( B.pack
+            [ 0x01
+            , 0x23
+            , 0x45
+            , 0x67
+            , 0x89
+            , 0xab
+            , 0xcd
+            , 0xef
+            , 0xfe
+            , 0xdc
+            , 0xba
+            , 0x98
+            , 0x76
+            , 0x54
+            , 0x32
+            , 0x10
+            ]
+        )
+        ( B.pack
+            [ 0x9a
+            , 0xcc
+            , 0x23
+            , 0x7d
+            , 0xff
+            , 0x16
+            , 0xd7
+            , 0x6c
+            , 0x20
+            , 0xef
+            , 0x7c
+            , 0x91
+            , 0x9e
+            , 0x3a
+            , 0x75
+            , 0x09
+            ]
+        )
     ]
 
-kats128 = defaultKATs { kat_ECB = vectors_camellia128 }
-kats192 = defaultKATs { kat_ECB = vectors_camellia192 }
-kats256 = defaultKATs { kat_ECB = vectors_camellia256 }
+kats128 = defaultKATs{kat_ECB = vectors_camellia128}
+kats192 = defaultKATs{kat_ECB = vectors_camellia192}
+kats256 = defaultKATs{kat_ECB = vectors_camellia256}
 
 tests = testBlockCipher kats128 (undefined :: Camellia128)
diff --git a/tests/KAT_Curve25519.hs b/tests/KAT_Curve25519.hs
--- a/tests/KAT_Curve25519.hs
+++ b/tests/KAT_Curve25519.hs
@@ -1,25 +1,50 @@
 {-# LANGUAGE OverloadedStrings #-}
-module KAT_Curve25519 ( tests ) where
 
-import           Crypto.Error
+module KAT_Curve25519 (tests) where
+
+import Crypto.Error
 import qualified Crypto.PubKey.Curve25519 as Curve25519
-import           Data.ByteArray as B
-import           Imports
+import Data.ByteArray as B
+import Imports
 
-alicePrivate = throwCryptoError $ Curve25519.secretKey ("\x77\x07\x6d\x0a\x73\x18\xa5\x7d\x3c\x16\xc1\x72\x51\xb2\x66\x45\xdf\x4c\x2f\x87\xeb\xc0\x99\x2a\xb1\x77\xfb\xa5\x1d\xb9\x2c\x2a" :: ByteString)
-alicePublic  = throwCryptoError $ Curve25519.publicKey ("\x85\x20\xf0\x09\x89\x30\xa7\x54\x74\x8b\x7d\xdc\xb4\x3e\xf7\x5a\x0d\xbf\x3a\x0d\x26\x38\x1a\xf4\xeb\xa4\xa9\x8e\xaa\x9b\x4e\x6a" :: ByteString)
-bobPrivate   = throwCryptoError $ Curve25519.secretKey ("\x5d\xab\x08\x7e\x62\x4a\x8a\x4b\x79\xe1\x7f\x8b\x83\x80\x0e\xe6\x6f\x3b\xb1\x29\x26\x18\xb6\xfd\x1c\x2f\x8b\x27\xff\x88\xe0\xeb" :: ByteString)
-bobPublic    = throwCryptoError $ Curve25519.publicKey ("\xde\x9e\xdb\x7d\x7b\x7d\xc1\xb4\xd3\x5b\x61\xc2\xec\xe4\x35\x37\x3f\x83\x43\xc8\x5b\x78\x67\x4d\xad\xfc\x7e\x14\x6f\x88\x2b\x4f" :: ByteString)
-aliceMultBob = "\x4a\x5d\x9d\x5b\xa4\xce\x2d\xe1\x72\x8e\x3b\xf4\x80\x35\x0f\x25\xe0\x7e\x21\xc9\x47\xd1\x9e\x33\x76\xf0\x9b\x3c\x1e\x16\x17\x42" :: ByteString
+alicePrivate =
+    throwCryptoError $
+        Curve25519.secretKey
+            ( "\x77\x07\x6d\x0a\x73\x18\xa5\x7d\x3c\x16\xc1\x72\x51\xb2\x66\x45\xdf\x4c\x2f\x87\xeb\xc0\x99\x2a\xb1\x77\xfb\xa5\x1d\xb9\x2c\x2a"
+                :: ByteString
+            )
+alicePublic =
+    throwCryptoError $
+        Curve25519.publicKey
+            ( "\x85\x20\xf0\x09\x89\x30\xa7\x54\x74\x8b\x7d\xdc\xb4\x3e\xf7\x5a\x0d\xbf\x3a\x0d\x26\x38\x1a\xf4\xeb\xa4\xa9\x8e\xaa\x9b\x4e\x6a"
+                :: ByteString
+            )
+bobPrivate =
+    throwCryptoError $
+        Curve25519.secretKey
+            ( "\x5d\xab\x08\x7e\x62\x4a\x8a\x4b\x79\xe1\x7f\x8b\x83\x80\x0e\xe6\x6f\x3b\xb1\x29\x26\x18\xb6\xfd\x1c\x2f\x8b\x27\xff\x88\xe0\xeb"
+                :: ByteString
+            )
+bobPublic =
+    throwCryptoError $
+        Curve25519.publicKey
+            ( "\xde\x9e\xdb\x7d\x7b\x7d\xc1\xb4\xd3\x5b\x61\xc2\xec\xe4\x35\x37\x3f\x83\x43\xc8\x5b\x78\x67\x4d\xad\xfc\x7e\x14\x6f\x88\x2b\x4f"
+                :: ByteString
+            )
+aliceMultBob =
+    "\x4a\x5d\x9d\x5b\xa4\xce\x2d\xe1\x72\x8e\x3b\xf4\x80\x35\x0f\x25\xe0\x7e\x21\xc9\x47\xd1\x9e\x33\x76\xf0\x9b\x3c\x1e\x16\x17\x42"
+        :: ByteString
 
 katTests :: [TestTree]
 katTests =
     [ testCase "0" (aliceMultBob @=? B.convert (Curve25519.dh alicePublic bobPrivate))
     , testCase "1" (aliceMultBob @=? B.convert (Curve25519.dh bobPublic alicePrivate))
-    , testCase "2" (alicePublic  @=? Curve25519.toPublic alicePrivate)
-    , testCase "3" (bobPublic    @=? Curve25519.toPublic bobPrivate)
+    , testCase "2" (alicePublic @=? Curve25519.toPublic alicePrivate)
+    , testCase "3" (bobPublic @=? Curve25519.toPublic bobPrivate)
     ]
 
-tests = testGroup "Curve25519"
-    [ testGroup "KATs" katTests
-    ]
+tests =
+    testGroup
+        "Curve25519"
+        [ testGroup "KATs" katTests
+        ]
diff --git a/tests/KAT_Curve448.hs b/tests/KAT_Curve448.hs
--- a/tests/KAT_Curve448.hs
+++ b/tests/KAT_Curve448.hs
@@ -1,25 +1,50 @@
 {-# LANGUAGE OverloadedStrings #-}
-module KAT_Curve448 ( tests ) where
 
-import           Crypto.Error
+module KAT_Curve448 (tests) where
+
+import Crypto.Error
 import qualified Crypto.PubKey.Curve448 as Curve448
-import           Data.ByteArray as B
-import           Imports
+import Data.ByteArray as B
+import Imports
 
-alicePrivate = throwCryptoError $ Curve448.secretKey ("\x9a\x8f\x49\x25\xd1\x51\x9f\x57\x75\xcf\x46\xb0\x4b\x58\x00\xd4\xee\x9e\xe8\xba\xe8\xbc\x55\x65\xd4\x98\xc2\x8d\xd9\xc9\xba\xf5\x74\xa9\x41\x97\x44\x89\x73\x91\x00\x63\x82\xa6\xf1\x27\xab\x1d\x9a\xc2\xd8\xc0\xa5\x98\x72\x6b" :: ByteString)
-alicePublic  = throwCryptoError $ Curve448.publicKey ("\x9b\x08\xf7\xcc\x31\xb7\xe3\xe6\x7d\x22\xd5\xae\xa1\x21\x07\x4a\x27\x3b\xd2\xb8\x3d\xe0\x9c\x63\xfa\xa7\x3d\x2c\x22\xc5\xd9\xbb\xc8\x36\x64\x72\x41\xd9\x53\xd4\x0c\x5b\x12\xda\x88\x12\x0d\x53\x17\x7f\x80\xe5\x32\xc4\x1f\xa0" :: ByteString)
-bobPrivate   = throwCryptoError $ Curve448.secretKey ("\x1c\x30\x6a\x7a\xc2\xa0\xe2\xe0\x99\x0b\x29\x44\x70\xcb\xa3\x39\xe6\x45\x37\x72\xb0\x75\x81\x1d\x8f\xad\x0d\x1d\x69\x27\xc1\x20\xbb\x5e\xe8\x97\x2b\x0d\x3e\x21\x37\x4c\x9c\x92\x1b\x09\xd1\xb0\x36\x6f\x10\xb6\x51\x73\x99\x2d" :: ByteString)
-bobPublic    = throwCryptoError $ Curve448.publicKey ("\x3e\xb7\xa8\x29\xb0\xcd\x20\xf5\xbc\xfc\x0b\x59\x9b\x6f\xec\xcf\x6d\xa4\x62\x71\x07\xbd\xb0\xd4\xf3\x45\xb4\x30\x27\xd8\xb9\x72\xfc\x3e\x34\xfb\x42\x32\xa1\x3c\xa7\x06\xdc\xb5\x7a\xec\x3d\xae\x07\xbd\xc1\xc6\x7b\xf3\x36\x09" :: ByteString)
-aliceMultBob = "\x07\xff\xf4\x18\x1a\xc6\xcc\x95\xec\x1c\x16\xa9\x4a\x0f\x74\xd1\x2d\xa2\x32\xce\x40\xa7\x75\x52\x28\x1d\x28\x2b\xb6\x0c\x0b\x56\xfd\x24\x64\xc3\x35\x54\x39\x36\x52\x1c\x24\x40\x30\x85\xd5\x9a\x44\x9a\x50\x37\x51\x4a\x87\x9d" :: ByteString
+alicePrivate =
+    throwCryptoError $
+        Curve448.secretKey
+            ( "\x9a\x8f\x49\x25\xd1\x51\x9f\x57\x75\xcf\x46\xb0\x4b\x58\x00\xd4\xee\x9e\xe8\xba\xe8\xbc\x55\x65\xd4\x98\xc2\x8d\xd9\xc9\xba\xf5\x74\xa9\x41\x97\x44\x89\x73\x91\x00\x63\x82\xa6\xf1\x27\xab\x1d\x9a\xc2\xd8\xc0\xa5\x98\x72\x6b"
+                :: ByteString
+            )
+alicePublic =
+    throwCryptoError $
+        Curve448.publicKey
+            ( "\x9b\x08\xf7\xcc\x31\xb7\xe3\xe6\x7d\x22\xd5\xae\xa1\x21\x07\x4a\x27\x3b\xd2\xb8\x3d\xe0\x9c\x63\xfa\xa7\x3d\x2c\x22\xc5\xd9\xbb\xc8\x36\x64\x72\x41\xd9\x53\xd4\x0c\x5b\x12\xda\x88\x12\x0d\x53\x17\x7f\x80\xe5\x32\xc4\x1f\xa0"
+                :: ByteString
+            )
+bobPrivate =
+    throwCryptoError $
+        Curve448.secretKey
+            ( "\x1c\x30\x6a\x7a\xc2\xa0\xe2\xe0\x99\x0b\x29\x44\x70\xcb\xa3\x39\xe6\x45\x37\x72\xb0\x75\x81\x1d\x8f\xad\x0d\x1d\x69\x27\xc1\x20\xbb\x5e\xe8\x97\x2b\x0d\x3e\x21\x37\x4c\x9c\x92\x1b\x09\xd1\xb0\x36\x6f\x10\xb6\x51\x73\x99\x2d"
+                :: ByteString
+            )
+bobPublic =
+    throwCryptoError $
+        Curve448.publicKey
+            ( "\x3e\xb7\xa8\x29\xb0\xcd\x20\xf5\xbc\xfc\x0b\x59\x9b\x6f\xec\xcf\x6d\xa4\x62\x71\x07\xbd\xb0\xd4\xf3\x45\xb4\x30\x27\xd8\xb9\x72\xfc\x3e\x34\xfb\x42\x32\xa1\x3c\xa7\x06\xdc\xb5\x7a\xec\x3d\xae\x07\xbd\xc1\xc6\x7b\xf3\x36\x09"
+                :: ByteString
+            )
+aliceMultBob =
+    "\x07\xff\xf4\x18\x1a\xc6\xcc\x95\xec\x1c\x16\xa9\x4a\x0f\x74\xd1\x2d\xa2\x32\xce\x40\xa7\x75\x52\x28\x1d\x28\x2b\xb6\x0c\x0b\x56\xfd\x24\x64\xc3\x35\x54\x39\x36\x52\x1c\x24\x40\x30\x85\xd5\x9a\x44\x9a\x50\x37\x51\x4a\x87\x9d"
+        :: ByteString
 
 katTests :: [TestTree]
 katTests =
     [ testCase "0" (aliceMultBob @=? B.convert (Curve448.dh alicePublic bobPrivate))
     , testCase "1" (aliceMultBob @=? B.convert (Curve448.dh bobPublic alicePrivate))
-    , testCase "2" (alicePublic  @=? Curve448.toPublic alicePrivate)
-    , testCase "3" (bobPublic    @=? Curve448.toPublic bobPrivate)
+    , testCase "2" (alicePublic @=? Curve448.toPublic alicePrivate)
+    , testCase "3" (bobPublic @=? Curve448.toPublic bobPrivate)
     ]
 
-tests = testGroup "Curve448"
-    [ testGroup "KATs" katTests
-    ]
+tests =
+    testGroup
+        "Curve448"
+        [ testGroup "KATs" katTests
+        ]
diff --git a/tests/KAT_DES.hs b/tests/KAT_DES.hs
--- a/tests/KAT_DES.hs
+++ b/tests/KAT_DES.hs
@@ -1,49 +1,154 @@
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE ViewPatterns #-}
+
 module KAT_DES (tests) where
 
-import Imports
 import BlockCipher
 import qualified Crypto.Cipher.DES as DES
+import Imports
 
-vectors_ecb = -- key plaintext ciphertext
-    [ KAT_ECB "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x8C\xA6\x4D\xE9\xC1\xB1\x23\xA7"
-    , KAT_ECB "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x73\x59\xB2\x16\x3E\x4E\xDC\x58"
-    , KAT_ECB "\x30\x00\x00\x00\x00\x00\x00\x00" "\x10\x00\x00\x00\x00\x00\x00\x01" "\x95\x8E\x6E\x62\x7A\x05\x55\x7B"
-    , KAT_ECB "\x11\x11\x11\x11\x11\x11\x11\x11" "\x11\x11\x11\x11\x11\x11\x11\x11" "\xF4\x03\x79\xAB\x9E\x0E\xC5\x33"
-    , KAT_ECB "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x11\x11\x11\x11\x11\x11\x11\x11" "\x17\x66\x8D\xFC\x72\x92\x53\x2D"
-    , KAT_ECB "\x11\x11\x11\x11\x11\x11\x11\x11" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x8A\x5A\xE1\xF8\x1A\xB8\xF2\xDD"
-    , KAT_ECB "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x8C\xA6\x4D\xE9\xC1\xB1\x23\xA7"
-    , KAT_ECB "\xFE\xDC\xBA\x98\x76\x54\x32\x10" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\xED\x39\xD9\x50\xFA\x74\xBC\xC4"
-    , KAT_ECB "\x7C\xA1\x10\x45\x4A\x1A\x6E\x57" "\x01\xA1\xD6\xD0\x39\x77\x67\x42" "\x69\x0F\x5B\x0D\x9A\x26\x93\x9B"
-    , KAT_ECB "\x01\x31\xD9\x61\x9D\xC1\x37\x6E" "\x5C\xD5\x4C\xA8\x3D\xEF\x57\xDA" "\x7A\x38\x9D\x10\x35\x4B\xD2\x71"
-    , KAT_ECB "\x07\xA1\x13\x3E\x4A\x0B\x26\x86" "\x02\x48\xD4\x38\x06\xF6\x71\x72" "\x86\x8E\xBB\x51\xCA\xB4\x59\x9A"
-    , KAT_ECB "\x38\x49\x67\x4C\x26\x02\x31\x9E" "\x51\x45\x4B\x58\x2D\xDF\x44\x0A" "\x71\x78\x87\x6E\x01\xF1\x9B\x2A"
-    , KAT_ECB "\x04\xB9\x15\xBA\x43\xFE\xB5\xB6" "\x42\xFD\x44\x30\x59\x57\x7F\xA2" "\xAF\x37\xFB\x42\x1F\x8C\x40\x95"
-    , KAT_ECB "\x01\x13\xB9\x70\xFD\x34\xF2\xCE" "\x05\x9B\x5E\x08\x51\xCF\x14\x3A" "\x86\xA5\x60\xF1\x0E\xC6\xD8\x5B"
-    , KAT_ECB "\x01\x70\xF1\x75\x46\x8F\xB5\xE6" "\x07\x56\xD8\xE0\x77\x47\x61\xD2" "\x0C\xD3\xDA\x02\x00\x21\xDC\x09"
-    , KAT_ECB "\x43\x29\x7F\xAD\x38\xE3\x73\xFE" "\x76\x25\x14\xB8\x29\xBF\x48\x6A" "\xEA\x67\x6B\x2C\xB7\xDB\x2B\x7A"
-    , KAT_ECB "\x07\xA7\x13\x70\x45\xDA\x2A\x16" "\x3B\xDD\x11\x90\x49\x37\x28\x02" "\xDF\xD6\x4A\x81\x5C\xAF\x1A\x0F"
-    , KAT_ECB "\x04\x68\x91\x04\xC2\xFD\x3B\x2F" "\x26\x95\x5F\x68\x35\xAF\x60\x9A" "\x5C\x51\x3C\x9C\x48\x86\xC0\x88"
-    , KAT_ECB "\x37\xD0\x6B\xB5\x16\xCB\x75\x46" "\x16\x4D\x5E\x40\x4F\x27\x52\x32" "\x0A\x2A\xEE\xAE\x3F\xF4\xAB\x77"
-    , KAT_ECB "\x1F\x08\x26\x0D\x1A\xC2\x46\x5E" "\x6B\x05\x6E\x18\x75\x9F\x5C\xCA" "\xEF\x1B\xF0\x3E\x5D\xFA\x57\x5A"
-    , KAT_ECB "\x58\x40\x23\x64\x1A\xBA\x61\x76" "\x00\x4B\xD6\xEF\x09\x17\x60\x62" "\x88\xBF\x0D\xB6\xD7\x0D\xEE\x56"
-    , KAT_ECB "\x02\x58\x16\x16\x46\x29\xB0\x07" "\x48\x0D\x39\x00\x6E\xE7\x62\xF2" "\xA1\xF9\x91\x55\x41\x02\x0B\x56"
-    , KAT_ECB "\x49\x79\x3E\xBC\x79\xB3\x25\x8F" "\x43\x75\x40\xC8\x69\x8F\x3C\xFA" "\x6F\xBF\x1C\xAF\xCF\xFD\x05\x56"
-    , KAT_ECB "\x4F\xB0\x5E\x15\x15\xAB\x73\xA7" "\x07\x2D\x43\xA0\x77\x07\x52\x92" "\x2F\x22\xE4\x9B\xAB\x7C\xA1\xAC"
-    , KAT_ECB "\x49\xE9\x5D\x6D\x4C\xA2\x29\xBF" "\x02\xFE\x55\x77\x81\x17\xF1\x2A" "\x5A\x6B\x61\x2C\xC2\x6C\xCE\x4A"
-    , KAT_ECB "\x01\x83\x10\xDC\x40\x9B\x26\xD6" "\x1D\x9D\x5C\x50\x18\xF7\x28\xC2" "\x5F\x4C\x03\x8E\xD1\x2B\x2E\x41"
-    , KAT_ECB "\x1C\x58\x7F\x1C\x13\x92\x4F\xEF" "\x30\x55\x32\x28\x6D\x6F\x29\x5A" "\x63\xFA\xC0\xD0\x34\xD9\xF7\x93"
-    , KAT_ECB "\x01\x01\x01\x01\x01\x01\x01\x01" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x61\x7B\x3A\x0C\xE8\xF0\x71\x00"
-    , KAT_ECB "\x1F\x1F\x1F\x1F\x0E\x0E\x0E\x0E" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\xDB\x95\x86\x05\xF8\xC8\xC6\x06"
-    , KAT_ECB "\xE0\xFE\xE0\xFE\xF1\xFE\xF1\xFE" "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\xED\xBF\xD1\xC6\x6C\x29\xCC\xC7"
-    , KAT_ECB "\x00\x00\x00\x00\x00\x00\x00\x00" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x35\x55\x50\xB2\x15\x0E\x24\x51"
-    , KAT_ECB "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x00\x00\x00\x00\x00\x00\x00\x00" "\xCA\xAA\xAF\x4D\xEA\xF1\xDB\xAE"
-    , KAT_ECB "\x01\x23\x45\x67\x89\xAB\xCD\xEF" "\x00\x00\x00\x00\x00\x00\x00\x00" "\xD5\xD4\x4F\xF7\x20\x68\x3D\x0D"
-    , KAT_ECB "\xFE\xDC\xBA\x98\x76\x54\x32\x10" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\x2A\x2B\xB0\x08\xDF\x97\xC2\xF2"
+vectors_ecb =
+    -- key plaintext ciphertext
+    [ KAT_ECB
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\x8C\xA6\x4D\xE9\xC1\xB1\x23\xA7"
+    , KAT_ECB
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\x73\x59\xB2\x16\x3E\x4E\xDC\x58"
+    , KAT_ECB
+        "\x30\x00\x00\x00\x00\x00\x00\x00"
+        "\x10\x00\x00\x00\x00\x00\x00\x01"
+        "\x95\x8E\x6E\x62\x7A\x05\x55\x7B"
+    , KAT_ECB
+        "\x11\x11\x11\x11\x11\x11\x11\x11"
+        "\x11\x11\x11\x11\x11\x11\x11\x11"
+        "\xF4\x03\x79\xAB\x9E\x0E\xC5\x33"
+    , KAT_ECB
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x11\x11\x11\x11\x11\x11\x11\x11"
+        "\x17\x66\x8D\xFC\x72\x92\x53\x2D"
+    , KAT_ECB
+        "\x11\x11\x11\x11\x11\x11\x11\x11"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x8A\x5A\xE1\xF8\x1A\xB8\xF2\xDD"
+    , KAT_ECB
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\x8C\xA6\x4D\xE9\xC1\xB1\x23\xA7"
+    , KAT_ECB
+        "\xFE\xDC\xBA\x98\x76\x54\x32\x10"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\xED\x39\xD9\x50\xFA\x74\xBC\xC4"
+    , KAT_ECB
+        "\x7C\xA1\x10\x45\x4A\x1A\x6E\x57"
+        "\x01\xA1\xD6\xD0\x39\x77\x67\x42"
+        "\x69\x0F\x5B\x0D\x9A\x26\x93\x9B"
+    , KAT_ECB
+        "\x01\x31\xD9\x61\x9D\xC1\x37\x6E"
+        "\x5C\xD5\x4C\xA8\x3D\xEF\x57\xDA"
+        "\x7A\x38\x9D\x10\x35\x4B\xD2\x71"
+    , KAT_ECB
+        "\x07\xA1\x13\x3E\x4A\x0B\x26\x86"
+        "\x02\x48\xD4\x38\x06\xF6\x71\x72"
+        "\x86\x8E\xBB\x51\xCA\xB4\x59\x9A"
+    , KAT_ECB
+        "\x38\x49\x67\x4C\x26\x02\x31\x9E"
+        "\x51\x45\x4B\x58\x2D\xDF\x44\x0A"
+        "\x71\x78\x87\x6E\x01\xF1\x9B\x2A"
+    , KAT_ECB
+        "\x04\xB9\x15\xBA\x43\xFE\xB5\xB6"
+        "\x42\xFD\x44\x30\x59\x57\x7F\xA2"
+        "\xAF\x37\xFB\x42\x1F\x8C\x40\x95"
+    , KAT_ECB
+        "\x01\x13\xB9\x70\xFD\x34\xF2\xCE"
+        "\x05\x9B\x5E\x08\x51\xCF\x14\x3A"
+        "\x86\xA5\x60\xF1\x0E\xC6\xD8\x5B"
+    , KAT_ECB
+        "\x01\x70\xF1\x75\x46\x8F\xB5\xE6"
+        "\x07\x56\xD8\xE0\x77\x47\x61\xD2"
+        "\x0C\xD3\xDA\x02\x00\x21\xDC\x09"
+    , KAT_ECB
+        "\x43\x29\x7F\xAD\x38\xE3\x73\xFE"
+        "\x76\x25\x14\xB8\x29\xBF\x48\x6A"
+        "\xEA\x67\x6B\x2C\xB7\xDB\x2B\x7A"
+    , KAT_ECB
+        "\x07\xA7\x13\x70\x45\xDA\x2A\x16"
+        "\x3B\xDD\x11\x90\x49\x37\x28\x02"
+        "\xDF\xD6\x4A\x81\x5C\xAF\x1A\x0F"
+    , KAT_ECB
+        "\x04\x68\x91\x04\xC2\xFD\x3B\x2F"
+        "\x26\x95\x5F\x68\x35\xAF\x60\x9A"
+        "\x5C\x51\x3C\x9C\x48\x86\xC0\x88"
+    , KAT_ECB
+        "\x37\xD0\x6B\xB5\x16\xCB\x75\x46"
+        "\x16\x4D\x5E\x40\x4F\x27\x52\x32"
+        "\x0A\x2A\xEE\xAE\x3F\xF4\xAB\x77"
+    , KAT_ECB
+        "\x1F\x08\x26\x0D\x1A\xC2\x46\x5E"
+        "\x6B\x05\x6E\x18\x75\x9F\x5C\xCA"
+        "\xEF\x1B\xF0\x3E\x5D\xFA\x57\x5A"
+    , KAT_ECB
+        "\x58\x40\x23\x64\x1A\xBA\x61\x76"
+        "\x00\x4B\xD6\xEF\x09\x17\x60\x62"
+        "\x88\xBF\x0D\xB6\xD7\x0D\xEE\x56"
+    , KAT_ECB
+        "\x02\x58\x16\x16\x46\x29\xB0\x07"
+        "\x48\x0D\x39\x00\x6E\xE7\x62\xF2"
+        "\xA1\xF9\x91\x55\x41\x02\x0B\x56"
+    , KAT_ECB
+        "\x49\x79\x3E\xBC\x79\xB3\x25\x8F"
+        "\x43\x75\x40\xC8\x69\x8F\x3C\xFA"
+        "\x6F\xBF\x1C\xAF\xCF\xFD\x05\x56"
+    , KAT_ECB
+        "\x4F\xB0\x5E\x15\x15\xAB\x73\xA7"
+        "\x07\x2D\x43\xA0\x77\x07\x52\x92"
+        "\x2F\x22\xE4\x9B\xAB\x7C\xA1\xAC"
+    , KAT_ECB
+        "\x49\xE9\x5D\x6D\x4C\xA2\x29\xBF"
+        "\x02\xFE\x55\x77\x81\x17\xF1\x2A"
+        "\x5A\x6B\x61\x2C\xC2\x6C\xCE\x4A"
+    , KAT_ECB
+        "\x01\x83\x10\xDC\x40\x9B\x26\xD6"
+        "\x1D\x9D\x5C\x50\x18\xF7\x28\xC2"
+        "\x5F\x4C\x03\x8E\xD1\x2B\x2E\x41"
+    , KAT_ECB
+        "\x1C\x58\x7F\x1C\x13\x92\x4F\xEF"
+        "\x30\x55\x32\x28\x6D\x6F\x29\x5A"
+        "\x63\xFA\xC0\xD0\x34\xD9\xF7\x93"
+    , KAT_ECB
+        "\x01\x01\x01\x01\x01\x01\x01\x01"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x61\x7B\x3A\x0C\xE8\xF0\x71\x00"
+    , KAT_ECB
+        "\x1F\x1F\x1F\x1F\x0E\x0E\x0E\x0E"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\xDB\x95\x86\x05\xF8\xC8\xC6\x06"
+    , KAT_ECB
+        "\xE0\xFE\xE0\xFE\xF1\xFE\xF1\xFE"
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\xED\xBF\xD1\xC6\x6C\x29\xCC\xC7"
+    , KAT_ECB
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\x35\x55\x50\xB2\x15\x0E\x24\x51"
+    , KAT_ECB
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\xCA\xAA\xAF\x4D\xEA\xF1\xDB\xAE"
+    , KAT_ECB
+        "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
+        "\x00\x00\x00\x00\x00\x00\x00\x00"
+        "\xD5\xD4\x4F\xF7\x20\x68\x3D\x0D"
+    , KAT_ECB
+        "\xFE\xDC\xBA\x98\x76\x54\x32\x10"
+        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
+        "\x2A\x2B\xB0\x08\xDF\x97\xC2\xF2"
     ]
 
-kats = defaultKATs { kat_ECB = vectors_ecb }
+kats = defaultKATs{kat_ECB = vectors_ecb}
 
-tests = localOption (QuickCheckTests 5)
-      $ testBlockCipher kats (undefined :: DES.DES)
+tests =
+    localOption (QuickCheckTests 5) $
+        testBlockCipher kats (undefined :: DES.DES)
diff --git a/tests/KAT_Ed25519.hs b/tests/KAT_Ed25519.hs
--- a/tests/KAT_Ed25519.hs
+++ b/tests/KAT_Ed25519.hs
@@ -1,72 +1,91 @@
-{-# LANGUAGE BangPatterns      #-}
+{-# LANGUAGE BangPatterns #-}
 {-# LANGUAGE OverloadedStrings #-}
-module KAT_Ed25519 ( tests ) where
 
-import           Crypto.Error
+module KAT_Ed25519 (tests) where
+
+import Crypto.Error
 import qualified Crypto.PubKey.Ed25519 as Ed25519
-import           Imports
+import Imports
 
 data Vec = Vec
     { vecSec :: ByteString
     , vecPub :: ByteString
     , vecMsg :: ByteString
     , vecSig :: ByteString
-    } deriving (Show,Eq)
+    }
+    deriving (Show, Eq)
 
 vectors =
     [ Vec
-        { vecSec = "\x9d\x61\xb1\x9d\xef\xfd\x5a\x60\xba\x84\x4a\xf4\x92\xec\x2c\xc4\x44\x49\xc5\x69\x7b\x32\x69\x19\x70\x3b\xac\x03\x1c\xae\x7f\x60"
-        , vecPub = "\xd7\x5a\x98\x01\x82\xb1\x0a\xb7\xd5\x4b\xfe\xd3\xc9\x64\x07\x3a\x0e\xe1\x72\xf3\xda\xa6\x23\x25\xaf\x02\x1a\x68\xf7\x07\x51\x1a"
+        { vecSec =
+            "\x9d\x61\xb1\x9d\xef\xfd\x5a\x60\xba\x84\x4a\xf4\x92\xec\x2c\xc4\x44\x49\xc5\x69\x7b\x32\x69\x19\x70\x3b\xac\x03\x1c\xae\x7f\x60"
+        , vecPub =
+            "\xd7\x5a\x98\x01\x82\xb1\x0a\xb7\xd5\x4b\xfe\xd3\xc9\x64\x07\x3a\x0e\xe1\x72\xf3\xda\xa6\x23\x25\xaf\x02\x1a\x68\xf7\x07\x51\x1a"
         , vecMsg = ""
-        , vecSig = "\xe5\x56\x43\x00\xc3\x60\xac\x72\x90\x86\xe2\xcc\x80\x6e\x82\x8a\x84\x87\x7f\x1e\xb8\xe5\xd9\x74\xd8\x73\xe0\x65\x22\x49\x01\x55\x5f\xb8\x82\x15\x90\xa3\x3b\xac\xc6\x1e\x39\x70\x1c\xf9\xb4\x6b\xd2\x5b\xf5\xf0\x59\x5b\xbe\x24\x65\x51\x41\x43\x8e\x7a\x10\x0b"
+        , vecSig =
+            "\xe5\x56\x43\x00\xc3\x60\xac\x72\x90\x86\xe2\xcc\x80\x6e\x82\x8a\x84\x87\x7f\x1e\xb8\xe5\xd9\x74\xd8\x73\xe0\x65\x22\x49\x01\x55\x5f\xb8\x82\x15\x90\xa3\x3b\xac\xc6\x1e\x39\x70\x1c\xf9\xb4\x6b\xd2\x5b\xf5\xf0\x59\x5b\xbe\x24\x65\x51\x41\x43\x8e\x7a\x10\x0b"
         }
     , Vec
-        { vecSec = "\x4c\xcd\x08\x9b\x28\xff\x96\xda\x9d\xb6\xc3\x46\xec\x11\x4e\x0f\x5b\x8a\x31\x9f\x35\xab\xa6\x24\xda\x8c\xf6\xed\x4f\xb8\xa6\xfb"
-        , vecPub = "\x3d\x40\x17\xc3\xe8\x43\x89\x5a\x92\xb7\x0a\xa7\x4d\x1b\x7e\xbc\x9c\x98\x2c\xcf\x2e\xc4\x96\x8c\xc0\xcd\x55\xf1\x2a\xf4\x66\x0c"
+        { vecSec =
+            "\x4c\xcd\x08\x9b\x28\xff\x96\xda\x9d\xb6\xc3\x46\xec\x11\x4e\x0f\x5b\x8a\x31\x9f\x35\xab\xa6\x24\xda\x8c\xf6\xed\x4f\xb8\xa6\xfb"
+        , vecPub =
+            "\x3d\x40\x17\xc3\xe8\x43\x89\x5a\x92\xb7\x0a\xa7\x4d\x1b\x7e\xbc\x9c\x98\x2c\xcf\x2e\xc4\x96\x8c\xc0\xcd\x55\xf1\x2a\xf4\x66\x0c"
         , vecMsg = "\x72"
-        , vecSig = "\x92\xa0\x09\xa9\xf0\xd4\xca\xb8\x72\x0e\x82\x0b\x5f\x64\x25\x40\xa2\xb2\x7b\x54\x16\x50\x3f\x8f\xb3\x76\x22\x23\xeb\xdb\x69\xda\x08\x5a\xc1\xe4\x3e\x15\x99\x6e\x45\x8f\x36\x13\xd0\xf1\x1d\x8c\x38\x7b\x2e\xae\xb4\x30\x2a\xee\xb0\x0d\x29\x16\x12\xbb\x0c\x00"
+        , vecSig =
+            "\x92\xa0\x09\xa9\xf0\xd4\xca\xb8\x72\x0e\x82\x0b\x5f\x64\x25\x40\xa2\xb2\x7b\x54\x16\x50\x3f\x8f\xb3\x76\x22\x23\xeb\xdb\x69\xda\x08\x5a\xc1\xe4\x3e\x15\x99\x6e\x45\x8f\x36\x13\xd0\xf1\x1d\x8c\x38\x7b\x2e\xae\xb4\x30\x2a\xee\xb0\x0d\x29\x16\x12\xbb\x0c\x00"
         }
     , Vec
-        { vecSec = "\xc5\xaa\x8d\xf4\x3f\x9f\x83\x7b\xed\xb7\x44\x2f\x31\xdc\xb7\xb1\x66\xd3\x85\x35\x07\x6f\x09\x4b\x85\xce\x3a\x2e\x0b\x44\x58\xf7"
-        , vecPub = "\xfc\x51\xcd\x8e\x62\x18\xa1\xa3\x8d\xa4\x7e\xd0\x02\x30\xf0\x58\x08\x16\xed\x13\xba\x33\x03\xac\x5d\xeb\x91\x15\x48\x90\x80\x25"
+        { vecSec =
+            "\xc5\xaa\x8d\xf4\x3f\x9f\x83\x7b\xed\xb7\x44\x2f\x31\xdc\xb7\xb1\x66\xd3\x85\x35\x07\x6f\x09\x4b\x85\xce\x3a\x2e\x0b\x44\x58\xf7"
+        , vecPub =
+            "\xfc\x51\xcd\x8e\x62\x18\xa1\xa3\x8d\xa4\x7e\xd0\x02\x30\xf0\x58\x08\x16\xed\x13\xba\x33\x03\xac\x5d\xeb\x91\x15\x48\x90\x80\x25"
         , vecMsg = "\xaf\x82"
-        , vecSig = "\x62\x91\xd6\x57\xde\xec\x24\x02\x48\x27\xe6\x9c\x3a\xbe\x01\xa3\x0c\xe5\x48\xa2\x84\x74\x3a\x44\x5e\x36\x80\xd7\xdb\x5a\xc3\xac\x18\xff\x9b\x53\x8d\x16\xf2\x90\xae\x67\xf7\x60\x98\x4d\xc6\x59\x4a\x7c\x15\xe9\x71\x6e\xd2\x8d\xc0\x27\xbe\xce\xea\x1e\xc4\x0a"
+        , vecSig =
+            "\x62\x91\xd6\x57\xde\xec\x24\x02\x48\x27\xe6\x9c\x3a\xbe\x01\xa3\x0c\xe5\x48\xa2\x84\x74\x3a\x44\x5e\x36\x80\xd7\xdb\x5a\xc3\xac\x18\xff\x9b\x53\x8d\x16\xf2\x90\xae\x67\xf7\x60\x98\x4d\xc6\x59\x4a\x7c\x15\xe9\x71\x6e\xd2\x8d\xc0\x27\xbe\xce\xea\x1e\xc4\x0a"
         }
     , Vec
-        { vecSec = "\xf5\xe5\x76\x7c\xf1\x53\x31\x95\x17\x63\x0f\x22\x68\x76\xb8\x6c\x81\x60\xcc\x58\x3b\xc0\x13\x74\x4c\x6b\xf2\x55\xf5\xcc\x0e\xe5"
-        , vecPub = "\x27\x81\x17\xfc\x14\x4c\x72\x34\x0f\x67\xd0\xf2\x31\x6e\x83\x86\xce\xff\xbf\x2b\x24\x28\xc9\xc5\x1f\xef\x7c\x59\x7f\x1d\x42\x6e"
-        , vecMsg = "\x08\xb8\xb2\xb7\x33\x42\x42\x43\x76\x0f\xe4\x26\xa4\xb5\x49\x08\x63\x21\x10\xa6\x6c\x2f\x65\x91\xea\xbd\x33\x45\xe3\xe4\xeb\x98\xfa\x6e\x26\x4b\xf0\x9e\xfe\x12\xee\x50\xf8\xf5\x4e\x9f\x77\xb1\xe3\x55\xf6\xc5\x05\x44\xe2\x3f\xb1\x43\x3d\xdf\x73\xbe\x84\xd8\x79\xde\x7c\x00\x46\xdc\x49\x96\xd9\xe7\x73\xf4\xbc\x9e\xfe\x57\x38\x82\x9a\xdb\x26\xc8\x1b\x37\xc9\x3a\x1b\x27\x0b\x20\x32\x9d\x65\x86\x75\xfc\x6e\xa5\x34\xe0\x81\x0a\x44\x32\x82\x6b\xf5\x8c\x94\x1e\xfb\x65\xd5\x7a\x33\x8b\xbd\x2e\x26\x64\x0f\x89\xff\xbc\x1a\x85\x8e\xfc\xb8\x55\x0e\xe3\xa5\xe1\x99\x8b\xd1\x77\xe9\x3a\x73\x63\xc3\x44\xfe\x6b\x19\x9e\xe5\xd0\x2e\x82\xd5\x22\xc4\xfe\xba\x15\x45\x2f\x80\x28\x8a\x82\x1a\x57\x91\x16\xec\x6d\xad\x2b\x3b\x31\x0d\xa9\x03\x40\x1a\xa6\x21\x00\xab\x5d\x1a\x36\x55\x3e\x06\x20\x3b\x33\x89\x0c\xc9\xb8\x32\xf7\x9e\xf8\x05\x60\xcc\xb9\xa3\x9c\xe7\x67\x96\x7e\xd6\x28\xc6\xad\x57\x3c\xb1\x16\xdb\xef\xef\xd7\x54\x99\xda\x96\xbd\x68\xa8\xa9\x7b\x92\x8a\x8b\xbc\x10\x3b\x66\x21\xfc\xde\x2b\xec\xa1\x23\x1d\x20\x6b\xe6\xcd\x9e\xc7\xaf\xf6\xf6\xc9\x4f\xcd\x72\x04\xed\x34\x55\xc6\x8c\x83\xf4\xa4\x1d\xa4\xaf\x2b\x74\xef\x5c\x53\xf1\xd8\xac\x70\xbd\xcb\x7e\xd1\x85\xce\x81\xbd\x84\x35\x9d\x44\x25\x4d\x95\x62\x9e\x98\x55\xa9\x4a\x7c\x19\x58\xd1\xf8\xad\xa5\xd0\x53\x2e\xd8\xa5\xaa\x3f\xb2\xd1\x7b\xa7\x0e\xb6\x24\x8e\x59\x4e\x1a\x22\x97\xac\xbb\xb3\x9d\x50\x2f\x1a\x8c\x6e\xb6\xf1\xce\x22\xb3\xde\x1a\x1f\x40\xcc\x24\x55\x41\x19\xa8\x31\xa9\xaa\xd6\x07\x9c\xad\x88\x42\x5d\xe6\xbd\xe1\xa9\x18\x7e\xbb\x60\x92\xcf\x67\xbf\x2b\x13\xfd\x65\xf2\x70\x88\xd7\x8b\x7e\x88\x3c\x87\x59\xd2\xc4\xf5\xc6\x5a\xdb\x75\x53\x87\x8a\xd5\x75\xf9\xfa\xd8\x78\xe8\x0a\x0c\x9b\xa6\x3b\xcb\xcc\x27\x32\xe6\x94\x85\xbb\xc9\xc9\x0b\xfb\xd6\x24\x81\xd9\x08\x9b\xec\xcf\x80\xcf\xe2\xdf\x16\xa2\xcf\x65\xbd\x92\xdd\x59\x7b\x07\x07\xe0\x91\x7a\xf4\x8b\xbb\x75\xfe\xd4\x13\xd2\x38\xf5\x55\x5a\x7a\x56\x9d\x80\xc3\x41\x4a\x8d\x08\x59\xdc\x65\xa4\x61\x28\xba\xb2\x7a\xf8\x7a\x71\x31\x4f\x31\x8c\x78\x2b\x23\xeb\xfe\x80\x8b\x82\xb0\xce\x26\x40\x1d\x2e\x22\xf0\x4d\x83\xd1\x25\x5d\xc5\x1a\xdd\xd3\xb7\x5a\x2b\x1a\xe0\x78\x45\x04\xdf\x54\x3a\xf8\x96\x9b\xe3\xea\x70\x82\xff\x7f\xc9\x88\x8c\x14\x4d\xa2\xaf\x58\x42\x9e\xc9\x60\x31\xdb\xca\xd3\xda\xd9\xaf\x0d\xcb\xaa\xaf\x26\x8c\xb8\xfc\xff\xea\xd9\x4f\x3c\x7c\xa4\x95\xe0\x56\xa9\xb4\x7a\xcd\xb7\x51\xfb\x73\xe6\x66\xc6\xc6\x55\xad\xe8\x29\x72\x97\xd0\x7a\xd1\xba\x5e\x43\xf1\xbc\xa3\x23\x01\x65\x13\x39\xe2\x29\x04\xcc\x8c\x42\xf5\x8c\x30\xc0\x4a\xaf\xdb\x03\x8d\xda\x08\x47\xdd\x98\x8d\xcd\xa6\xf3\xbf\xd1\x5c\x4b\x4c\x45\x25\x00\x4a\xa0\x6e\xef\xf8\xca\x61\x78\x3a\xac\xec\x57\xfb\x3d\x1f\x92\xb0\xfe\x2f\xd1\xa8\x5f\x67\x24\x51\x7b\x65\xe6\x14\xad\x68\x08\xd6\xf6\xee\x34\xdf\xf7\x31\x0f\xdc\x82\xae\xbf\xd9\x04\xb0\x1e\x1d\xc5\x4b\x29\x27\x09\x4b\x2d\xb6\x8d\x6f\x90\x3b\x68\x40\x1a\xde\xbf\x5a\x7e\x08\xd7\x8f\xf4\xef\x5d\x63\x65\x3a\x65\x04\x0c\xf9\xbf\xd4\xac\xa7\x98\x4a\x74\xd3\x71\x45\x98\x67\x80\xfc\x0b\x16\xac\x45\x16\x49\xde\x61\x88\xa7\xdb\xdf\x19\x1f\x64\xb5\xfc\x5e\x2a\xb4\x7b\x57\xf7\xf7\x27\x6c\xd4\x19\xc1\x7a\x3c\xa8\xe1\xb9\x39\xae\x49\xe4\x88\xac\xba\x6b\x96\x56\x10\xb5\x48\x01\x09\xc8\xb1\x7b\x80\xe1\xb7\xb7\x50\xdf\xc7\x59\x8d\x5d\x50\x11\xfd\x2d\xcc\x56\x00\xa3\x2e\xf5\xb5\x2a\x1e\xcc\x82\x0e\x30\x8a\xa3\x42\x72\x1a\xac\x09\x43\xbf\x66\x86\xb6\x4b\x25\x79\x37\x65\x04\xcc\xc4\x93\xd9\x7e\x6a\xed\x3f\xb0\xf9\xcd\x71\xa4\x3d\xd4\x97\xf0\x1f\x17\xc0\xe2\xcb\x37\x97\xaa\x2a\x2f\x25\x66\x56\x16\x8e\x6c\x49\x6a\xfc\x5f\xb9\x32\x46\xf6\xb1\x11\x63\x98\xa3\x46\xf1\xa6\x41\xf3\xb0\x41\xe9\x89\xf7\x91\x4f\x90\xcc\x2c\x7f\xff\x35\x78\x76\xe5\x06\xb5\x0d\x33\x4b\xa7\x7c\x22\x5b\xc3\x07\xba\x53\x71\x52\xf3\xf1\x61\x0e\x4e\xaf\xe5\x95\xf6\xd9\xd9\x0d\x11\xfa\xa9\x33\xa1\x5e\xf1\x36\x95\x46\x86\x8a\x7f\x3a\x45\xa9\x67\x68\xd4\x0f\xd9\xd0\x34\x12\xc0\x91\xc6\x31\x5c\xf4\xfd\xe7\xcb\x68\x60\x69\x37\x38\x0d\xb2\xea\xaa\x70\x7b\x4c\x41\x85\xc3\x2e\xdd\xcd\xd3\x06\x70\x5e\x4d\xc1\xff\xc8\x72\xee\xee\x47\x5a\x64\xdf\xac\x86\xab\xa4\x1c\x06\x18\x98\x3f\x87\x41\xc5\xef\x68\xd3\xa1\x01\xe8\xa3\xb8\xca\xc6\x0c\x90\x5c\x15\xfc\x91\x08\x40\xb9\x4c\x00\xa0\xb9\xd0"
-        , vecSig = "\x0a\xab\x4c\x90\x05\x01\xb3\xe2\x4d\x7c\xdf\x46\x63\x32\x6a\x3a\x87\xdf\x5e\x48\x43\xb2\xcb\xdb\x67\xcb\xf6\xe4\x60\xfe\xc3\x50\xaa\x53\x71\xb1\x50\x8f\x9f\x45\x28\xec\xea\x23\xc4\x36\xd9\x4b\x5e\x8f\xcd\x4f\x68\x1e\x30\xa6\xac\x00\xa9\x70\x4a\x18\x8a\x03"
+        { vecSec =
+            "\xf5\xe5\x76\x7c\xf1\x53\x31\x95\x17\x63\x0f\x22\x68\x76\xb8\x6c\x81\x60\xcc\x58\x3b\xc0\x13\x74\x4c\x6b\xf2\x55\xf5\xcc\x0e\xe5"
+        , vecPub =
+            "\x27\x81\x17\xfc\x14\x4c\x72\x34\x0f\x67\xd0\xf2\x31\x6e\x83\x86\xce\xff\xbf\x2b\x24\x28\xc9\xc5\x1f\xef\x7c\x59\x7f\x1d\x42\x6e"
+        , vecMsg =
+            "\x08\xb8\xb2\xb7\x33\x42\x42\x43\x76\x0f\xe4\x26\xa4\xb5\x49\x08\x63\x21\x10\xa6\x6c\x2f\x65\x91\xea\xbd\x33\x45\xe3\xe4\xeb\x98\xfa\x6e\x26\x4b\xf0\x9e\xfe\x12\xee\x50\xf8\xf5\x4e\x9f\x77\xb1\xe3\x55\xf6\xc5\x05\x44\xe2\x3f\xb1\x43\x3d\xdf\x73\xbe\x84\xd8\x79\xde\x7c\x00\x46\xdc\x49\x96\xd9\xe7\x73\xf4\xbc\x9e\xfe\x57\x38\x82\x9a\xdb\x26\xc8\x1b\x37\xc9\x3a\x1b\x27\x0b\x20\x32\x9d\x65\x86\x75\xfc\x6e\xa5\x34\xe0\x81\x0a\x44\x32\x82\x6b\xf5\x8c\x94\x1e\xfb\x65\xd5\x7a\x33\x8b\xbd\x2e\x26\x64\x0f\x89\xff\xbc\x1a\x85\x8e\xfc\xb8\x55\x0e\xe3\xa5\xe1\x99\x8b\xd1\x77\xe9\x3a\x73\x63\xc3\x44\xfe\x6b\x19\x9e\xe5\xd0\x2e\x82\xd5\x22\xc4\xfe\xba\x15\x45\x2f\x80\x28\x8a\x82\x1a\x57\x91\x16\xec\x6d\xad\x2b\x3b\x31\x0d\xa9\x03\x40\x1a\xa6\x21\x00\xab\x5d\x1a\x36\x55\x3e\x06\x20\x3b\x33\x89\x0c\xc9\xb8\x32\xf7\x9e\xf8\x05\x60\xcc\xb9\xa3\x9c\xe7\x67\x96\x7e\xd6\x28\xc6\xad\x57\x3c\xb1\x16\xdb\xef\xef\xd7\x54\x99\xda\x96\xbd\x68\xa8\xa9\x7b\x92\x8a\x8b\xbc\x10\x3b\x66\x21\xfc\xde\x2b\xec\xa1\x23\x1d\x20\x6b\xe6\xcd\x9e\xc7\xaf\xf6\xf6\xc9\x4f\xcd\x72\x04\xed\x34\x55\xc6\x8c\x83\xf4\xa4\x1d\xa4\xaf\x2b\x74\xef\x5c\x53\xf1\xd8\xac\x70\xbd\xcb\x7e\xd1\x85\xce\x81\xbd\x84\x35\x9d\x44\x25\x4d\x95\x62\x9e\x98\x55\xa9\x4a\x7c\x19\x58\xd1\xf8\xad\xa5\xd0\x53\x2e\xd8\xa5\xaa\x3f\xb2\xd1\x7b\xa7\x0e\xb6\x24\x8e\x59\x4e\x1a\x22\x97\xac\xbb\xb3\x9d\x50\x2f\x1a\x8c\x6e\xb6\xf1\xce\x22\xb3\xde\x1a\x1f\x40\xcc\x24\x55\x41\x19\xa8\x31\xa9\xaa\xd6\x07\x9c\xad\x88\x42\x5d\xe6\xbd\xe1\xa9\x18\x7e\xbb\x60\x92\xcf\x67\xbf\x2b\x13\xfd\x65\xf2\x70\x88\xd7\x8b\x7e\x88\x3c\x87\x59\xd2\xc4\xf5\xc6\x5a\xdb\x75\x53\x87\x8a\xd5\x75\xf9\xfa\xd8\x78\xe8\x0a\x0c\x9b\xa6\x3b\xcb\xcc\x27\x32\xe6\x94\x85\xbb\xc9\xc9\x0b\xfb\xd6\x24\x81\xd9\x08\x9b\xec\xcf\x80\xcf\xe2\xdf\x16\xa2\xcf\x65\xbd\x92\xdd\x59\x7b\x07\x07\xe0\x91\x7a\xf4\x8b\xbb\x75\xfe\xd4\x13\xd2\x38\xf5\x55\x5a\x7a\x56\x9d\x80\xc3\x41\x4a\x8d\x08\x59\xdc\x65\xa4\x61\x28\xba\xb2\x7a\xf8\x7a\x71\x31\x4f\x31\x8c\x78\x2b\x23\xeb\xfe\x80\x8b\x82\xb0\xce\x26\x40\x1d\x2e\x22\xf0\x4d\x83\xd1\x25\x5d\xc5\x1a\xdd\xd3\xb7\x5a\x2b\x1a\xe0\x78\x45\x04\xdf\x54\x3a\xf8\x96\x9b\xe3\xea\x70\x82\xff\x7f\xc9\x88\x8c\x14\x4d\xa2\xaf\x58\x42\x9e\xc9\x60\x31\xdb\xca\xd3\xda\xd9\xaf\x0d\xcb\xaa\xaf\x26\x8c\xb8\xfc\xff\xea\xd9\x4f\x3c\x7c\xa4\x95\xe0\x56\xa9\xb4\x7a\xcd\xb7\x51\xfb\x73\xe6\x66\xc6\xc6\x55\xad\xe8\x29\x72\x97\xd0\x7a\xd1\xba\x5e\x43\xf1\xbc\xa3\x23\x01\x65\x13\x39\xe2\x29\x04\xcc\x8c\x42\xf5\x8c\x30\xc0\x4a\xaf\xdb\x03\x8d\xda\x08\x47\xdd\x98\x8d\xcd\xa6\xf3\xbf\xd1\x5c\x4b\x4c\x45\x25\x00\x4a\xa0\x6e\xef\xf8\xca\x61\x78\x3a\xac\xec\x57\xfb\x3d\x1f\x92\xb0\xfe\x2f\xd1\xa8\x5f\x67\x24\x51\x7b\x65\xe6\x14\xad\x68\x08\xd6\xf6\xee\x34\xdf\xf7\x31\x0f\xdc\x82\xae\xbf\xd9\x04\xb0\x1e\x1d\xc5\x4b\x29\x27\x09\x4b\x2d\xb6\x8d\x6f\x90\x3b\x68\x40\x1a\xde\xbf\x5a\x7e\x08\xd7\x8f\xf4\xef\x5d\x63\x65\x3a\x65\x04\x0c\xf9\xbf\xd4\xac\xa7\x98\x4a\x74\xd3\x71\x45\x98\x67\x80\xfc\x0b\x16\xac\x45\x16\x49\xde\x61\x88\xa7\xdb\xdf\x19\x1f\x64\xb5\xfc\x5e\x2a\xb4\x7b\x57\xf7\xf7\x27\x6c\xd4\x19\xc1\x7a\x3c\xa8\xe1\xb9\x39\xae\x49\xe4\x88\xac\xba\x6b\x96\x56\x10\xb5\x48\x01\x09\xc8\xb1\x7b\x80\xe1\xb7\xb7\x50\xdf\xc7\x59\x8d\x5d\x50\x11\xfd\x2d\xcc\x56\x00\xa3\x2e\xf5\xb5\x2a\x1e\xcc\x82\x0e\x30\x8a\xa3\x42\x72\x1a\xac\x09\x43\xbf\x66\x86\xb6\x4b\x25\x79\x37\x65\x04\xcc\xc4\x93\xd9\x7e\x6a\xed\x3f\xb0\xf9\xcd\x71\xa4\x3d\xd4\x97\xf0\x1f\x17\xc0\xe2\xcb\x37\x97\xaa\x2a\x2f\x25\x66\x56\x16\x8e\x6c\x49\x6a\xfc\x5f\xb9\x32\x46\xf6\xb1\x11\x63\x98\xa3\x46\xf1\xa6\x41\xf3\xb0\x41\xe9\x89\xf7\x91\x4f\x90\xcc\x2c\x7f\xff\x35\x78\x76\xe5\x06\xb5\x0d\x33\x4b\xa7\x7c\x22\x5b\xc3\x07\xba\x53\x71\x52\xf3\xf1\x61\x0e\x4e\xaf\xe5\x95\xf6\xd9\xd9\x0d\x11\xfa\xa9\x33\xa1\x5e\xf1\x36\x95\x46\x86\x8a\x7f\x3a\x45\xa9\x67\x68\xd4\x0f\xd9\xd0\x34\x12\xc0\x91\xc6\x31\x5c\xf4\xfd\xe7\xcb\x68\x60\x69\x37\x38\x0d\xb2\xea\xaa\x70\x7b\x4c\x41\x85\xc3\x2e\xdd\xcd\xd3\x06\x70\x5e\x4d\xc1\xff\xc8\x72\xee\xee\x47\x5a\x64\xdf\xac\x86\xab\xa4\x1c\x06\x18\x98\x3f\x87\x41\xc5\xef\x68\xd3\xa1\x01\xe8\xa3\xb8\xca\xc6\x0c\x90\x5c\x15\xfc\x91\x08\x40\xb9\x4c\x00\xa0\xb9\xd0"
+        , vecSig =
+            "\x0a\xab\x4c\x90\x05\x01\xb3\xe2\x4d\x7c\xdf\x46\x63\x32\x6a\x3a\x87\xdf\x5e\x48\x43\xb2\xcb\xdb\x67\xcb\xf6\xe4\x60\xfe\xc3\x50\xaa\x53\x71\xb1\x50\x8f\x9f\x45\x28\xec\xea\x23\xc4\x36\xd9\x4b\x5e\x8f\xcd\x4f\x68\x1e\x30\xa6\xac\x00\xa9\x70\x4a\x18\x8a\x03"
         }
     , Vec
-        { vecSec = "\x83\x3f\xe6\x24\x09\x23\x7b\x9d\x62\xec\x77\x58\x75\x20\x91\x1e\x9a\x75\x9c\xec\x1d\x19\x75\x5b\x7d\xa9\x01\xb9\x6d\xca\x3d\x42"
-        , vecPub = "\xec\x17\x2b\x93\xad\x5e\x56\x3b\xf4\x93\x2c\x70\xe1\x24\x50\x34\xc3\x54\x67\xef\x2e\xfd\x4d\x64\xeb\xf8\x19\x68\x34\x67\xe2\xbf"
-        , vecMsg = "\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41\x31\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a\x21\x92\x99\x2a\x27\x4f\xc1\xa8\x36\xba\x3c\x23\xa3\xfe\xeb\xbd\x45\x4d\x44\x23\x64\x3c\xe8\x0e\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f"
-        , vecSig = "\xdc\x2a\x44\x59\xe7\x36\x96\x33\xa5\x2b\x1b\xf2\x77\x83\x9a\x00\x20\x10\x09\xa3\xef\xbf\x3e\xcb\x69\xbe\xa2\x18\x6c\x26\xb5\x89\x09\x35\x1f\xc9\xac\x90\xb3\xec\xfd\xfb\xc7\xc6\x64\x31\xe0\x30\x3d\xca\x17\x9c\x13\x8a\xc1\x7a\xd9\xbe\xf1\x17\x73\x31\xa7\x04"
+        { vecSec =
+            "\x83\x3f\xe6\x24\x09\x23\x7b\x9d\x62\xec\x77\x58\x75\x20\x91\x1e\x9a\x75\x9c\xec\x1d\x19\x75\x5b\x7d\xa9\x01\xb9\x6d\xca\x3d\x42"
+        , vecPub =
+            "\xec\x17\x2b\x93\xad\x5e\x56\x3b\xf4\x93\x2c\x70\xe1\x24\x50\x34\xc3\x54\x67\xef\x2e\xfd\x4d\x64\xeb\xf8\x19\x68\x34\x67\xe2\xbf"
+        , vecMsg =
+            "\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41\x31\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a\x21\x92\x99\x2a\x27\x4f\xc1\xa8\x36\xba\x3c\x23\xa3\xfe\xeb\xbd\x45\x4d\x44\x23\x64\x3c\xe8\x0e\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f"
+        , vecSig =
+            "\xdc\x2a\x44\x59\xe7\x36\x96\x33\xa5\x2b\x1b\xf2\x77\x83\x9a\x00\x20\x10\x09\xa3\xef\xbf\x3e\xcb\x69\xbe\xa2\x18\x6c\x26\xb5\x89\x09\x35\x1f\xc9\xac\x90\xb3\xec\xfd\xfb\xc7\xc6\x64\x31\xe0\x30\x3d\xca\x17\x9c\x13\x8a\xc1\x7a\xd9\xbe\xf1\x17\x73\x31\xa7\x04"
         }
     ]
 
-
 doPublicKeyTest i vec = testCase (show i) (pub @=? Ed25519.toPublic sec)
   where
-        !pub = throwCryptoError $ Ed25519.publicKey (vecPub vec)
-        !sec = throwCryptoError $ Ed25519.secretKey (vecSec vec)
+    !pub = throwCryptoError $ Ed25519.publicKey (vecPub vec)
+    !sec = throwCryptoError $ Ed25519.secretKey (vecSec vec)
 
 doSignatureTest i vec = testCase (show i) (sig @=? Ed25519.sign sec pub (vecMsg vec))
   where
-        !sig = throwCryptoError $ Ed25519.signature (vecSig vec)
-        !pub = throwCryptoError $ Ed25519.publicKey (vecPub vec)
-        !sec = throwCryptoError $ Ed25519.secretKey (vecSec vec)
+    !sig = throwCryptoError $ Ed25519.signature (vecSig vec)
+    !pub = throwCryptoError $ Ed25519.publicKey (vecPub vec)
+    !sec = throwCryptoError $ Ed25519.secretKey (vecSec vec)
 
 doVerifyTest i vec = testCase (show i) (True @=? Ed25519.verify pub (vecMsg vec) sig)
   where
-        !sig = throwCryptoError $ Ed25519.signature (vecSig vec)
-        !pub = throwCryptoError $ Ed25519.publicKey (vecPub vec)
-
+    !sig = throwCryptoError $ Ed25519.signature (vecSig vec)
+    !pub = throwCryptoError $ Ed25519.publicKey (vecPub vec)
 
-tests = testGroup "Ed25519"
-    [ testCase  "gen secretkey" (Ed25519.generateSecretKey *> pure ())
-    , testGroup "gen publickey" $ zipWith doPublicKeyTest [katZero..] vectors
-    , testGroup "gen signature" $ zipWith doSignatureTest [katZero..] vectors
-    , testGroup "verify sig" $ zipWith doVerifyTest [katZero..] vectors
-    ]
+tests =
+    testGroup
+        "Ed25519"
+        [ testCase "gen secretkey" (Ed25519.generateSecretKey *> pure ())
+        , testGroup "gen publickey" $ zipWith doPublicKeyTest [katZero ..] vectors
+        , testGroup "gen signature" $ zipWith doSignatureTest [katZero ..] vectors
+        , testGroup "verify sig" $ zipWith doVerifyTest [katZero ..] vectors
+        ]
diff --git a/tests/KAT_Ed448.hs b/tests/KAT_Ed448.hs
--- a/tests/KAT_Ed448.hs
+++ b/tests/KAT_Ed448.hs
@@ -1,90 +1,119 @@
-{-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE BangPatterns #-}
-module KAT_Ed448 ( tests ) where
+{-# LANGUAGE OverloadedStrings #-}
 
-import           Crypto.Error
+module KAT_Ed448 (tests) where
+
+import Crypto.Error
 import qualified Crypto.PubKey.Ed448 as Ed448
-import           Imports
+import Imports
 
 data Vec = Vec
     { vecSec :: ByteString
     , vecPub :: ByteString
     , vecMsg :: ByteString
     , vecSig :: ByteString
-    } deriving (Show,Eq)
+    }
+    deriving (Show, Eq)
 
 vectors =
     [ Vec
-        { vecSec = "\x6c\x82\xa5\x62\xcb\x80\x8d\x10\xd6\x32\xbe\x89\xc8\x51\x3e\xbf\x6c\x92\x9f\x34\xdd\xfa\x8c\x9f\x63\xc9\x96\x0e\xf6\xe3\x48\xa3\x52\x8c\x8a\x3f\xcc\x2f\x04\x4e\x39\xa3\xfc\x5b\x94\x49\x2f\x8f\x03\x2e\x75\x49\xa2\x00\x98\xf9\x5b"
-        , vecPub = "\x5f\xd7\x44\x9b\x59\xb4\x61\xfd\x2c\xe7\x87\xec\x61\x6a\xd4\x6a\x1d\xa1\x34\x24\x85\xa7\x0e\x1f\x8a\x0e\xa7\x5d\x80\xe9\x67\x78\xed\xf1\x24\x76\x9b\x46\xc7\x06\x1b\xd6\x78\x3d\xf1\xe5\x0f\x6c\xd1\xfa\x1a\xbe\xaf\xe8\x25\x61\x80"
+        { vecSec =
+            "\x6c\x82\xa5\x62\xcb\x80\x8d\x10\xd6\x32\xbe\x89\xc8\x51\x3e\xbf\x6c\x92\x9f\x34\xdd\xfa\x8c\x9f\x63\xc9\x96\x0e\xf6\xe3\x48\xa3\x52\x8c\x8a\x3f\xcc\x2f\x04\x4e\x39\xa3\xfc\x5b\x94\x49\x2f\x8f\x03\x2e\x75\x49\xa2\x00\x98\xf9\x5b"
+        , vecPub =
+            "\x5f\xd7\x44\x9b\x59\xb4\x61\xfd\x2c\xe7\x87\xec\x61\x6a\xd4\x6a\x1d\xa1\x34\x24\x85\xa7\x0e\x1f\x8a\x0e\xa7\x5d\x80\xe9\x67\x78\xed\xf1\x24\x76\x9b\x46\xc7\x06\x1b\xd6\x78\x3d\xf1\xe5\x0f\x6c\xd1\xfa\x1a\xbe\xaf\xe8\x25\x61\x80"
         , vecMsg = ""
-        , vecSig = "\x53\x3a\x37\xf6\xbb\xe4\x57\x25\x1f\x02\x3c\x0d\x88\xf9\x76\xae\x2d\xfb\x50\x4a\x84\x3e\x34\xd2\x07\x4f\xd8\x23\xd4\x1a\x59\x1f\x2b\x23\x3f\x03\x4f\x62\x82\x81\xf2\xfd\x7a\x22\xdd\xd4\x7d\x78\x28\xc5\x9b\xd0\xa2\x1b\xfd\x39\x80\xff\x0d\x20\x28\xd4\xb1\x8a\x9d\xf6\x3e\x00\x6c\x5d\x1c\x2d\x34\x5b\x92\x5d\x8d\xc0\x0b\x41\x04\x85\x2d\xb9\x9a\xc5\xc7\xcd\xda\x85\x30\xa1\x13\xa0\xf4\xdb\xb6\x11\x49\xf0\x5a\x73\x63\x26\x8c\x71\xd9\x58\x08\xff\x2e\x65\x26\x00"
+        , vecSig =
+            "\x53\x3a\x37\xf6\xbb\xe4\x57\x25\x1f\x02\x3c\x0d\x88\xf9\x76\xae\x2d\xfb\x50\x4a\x84\x3e\x34\xd2\x07\x4f\xd8\x23\xd4\x1a\x59\x1f\x2b\x23\x3f\x03\x4f\x62\x82\x81\xf2\xfd\x7a\x22\xdd\xd4\x7d\x78\x28\xc5\x9b\xd0\xa2\x1b\xfd\x39\x80\xff\x0d\x20\x28\xd4\xb1\x8a\x9d\xf6\x3e\x00\x6c\x5d\x1c\x2d\x34\x5b\x92\x5d\x8d\xc0\x0b\x41\x04\x85\x2d\xb9\x9a\xc5\xc7\xcd\xda\x85\x30\xa1\x13\xa0\xf4\xdb\xb6\x11\x49\xf0\x5a\x73\x63\x26\x8c\x71\xd9\x58\x08\xff\x2e\x65\x26\x00"
         }
     , Vec
-        { vecSec = "\xc4\xea\xb0\x5d\x35\x70\x07\xc6\x32\xf3\xdb\xb4\x84\x89\x92\x4d\x55\x2b\x08\xfe\x0c\x35\x3a\x0d\x4a\x1f\x00\xac\xda\x2c\x46\x3a\xfb\xea\x67\xc5\xe8\xd2\x87\x7c\x5e\x3b\xc3\x97\xa6\x59\x94\x9e\xf8\x02\x1e\x95\x4e\x0a\x12\x27\x4e"
-        , vecPub = "\x43\xba\x28\xf4\x30\xcd\xff\x45\x6a\xe5\x31\x54\x5f\x7e\xcd\x0a\xc8\x34\xa5\x5d\x93\x58\xc0\x37\x2b\xfa\x0c\x6c\x67\x98\xc0\x86\x6a\xea\x01\xeb\x00\x74\x28\x02\xb8\x43\x8e\xa4\xcb\x82\x16\x9c\x23\x51\x60\x62\x7b\x4c\x3a\x94\x80"
+        { vecSec =
+            "\xc4\xea\xb0\x5d\x35\x70\x07\xc6\x32\xf3\xdb\xb4\x84\x89\x92\x4d\x55\x2b\x08\xfe\x0c\x35\x3a\x0d\x4a\x1f\x00\xac\xda\x2c\x46\x3a\xfb\xea\x67\xc5\xe8\xd2\x87\x7c\x5e\x3b\xc3\x97\xa6\x59\x94\x9e\xf8\x02\x1e\x95\x4e\x0a\x12\x27\x4e"
+        , vecPub =
+            "\x43\xba\x28\xf4\x30\xcd\xff\x45\x6a\xe5\x31\x54\x5f\x7e\xcd\x0a\xc8\x34\xa5\x5d\x93\x58\xc0\x37\x2b\xfa\x0c\x6c\x67\x98\xc0\x86\x6a\xea\x01\xeb\x00\x74\x28\x02\xb8\x43\x8e\xa4\xcb\x82\x16\x9c\x23\x51\x60\x62\x7b\x4c\x3a\x94\x80"
         , vecMsg = "\x03"
-        , vecSig = "\x26\xb8\xf9\x17\x27\xbd\x62\x89\x7a\xf1\x5e\x41\xeb\x43\xc3\x77\xef\xb9\xc6\x10\xd4\x8f\x23\x35\xcb\x0b\xd0\x08\x78\x10\xf4\x35\x25\x41\xb1\x43\xc4\xb9\x81\xb7\xe1\x8f\x62\xde\x8c\xcd\xf6\x33\xfc\x1b\xf0\x37\xab\x7c\xd7\x79\x80\x5e\x0d\xbc\xc0\xaa\xe1\xcb\xce\xe1\xaf\xb2\xe0\x27\xdf\x36\xbc\x04\xdc\xec\xbf\x15\x43\x36\xc1\x9f\x0a\xf7\xe0\xa6\x47\x29\x05\xe7\x99\xf1\x95\x3d\x2a\x0f\xf3\x34\x8a\xb2\x1a\xa4\xad\xaf\xd1\xd2\x34\x44\x1c\xf8\x07\xc0\x3a\x00"
+        , vecSig =
+            "\x26\xb8\xf9\x17\x27\xbd\x62\x89\x7a\xf1\x5e\x41\xeb\x43\xc3\x77\xef\xb9\xc6\x10\xd4\x8f\x23\x35\xcb\x0b\xd0\x08\x78\x10\xf4\x35\x25\x41\xb1\x43\xc4\xb9\x81\xb7\xe1\x8f\x62\xde\x8c\xcd\xf6\x33\xfc\x1b\xf0\x37\xab\x7c\xd7\x79\x80\x5e\x0d\xbc\xc0\xaa\xe1\xcb\xce\xe1\xaf\xb2\xe0\x27\xdf\x36\xbc\x04\xdc\xec\xbf\x15\x43\x36\xc1\x9f\x0a\xf7\xe0\xa6\x47\x29\x05\xe7\x99\xf1\x95\x3d\x2a\x0f\xf3\x34\x8a\xb2\x1a\xa4\xad\xaf\xd1\xd2\x34\x44\x1c\xf8\x07\xc0\x3a\x00"
         }
     , Vec
-        { vecSec = "\xcd\x23\xd2\x4f\x71\x42\x74\xe7\x44\x34\x32\x37\xb9\x32\x90\xf5\x11\xf6\x42\x5f\x98\xe6\x44\x59\xff\x20\x3e\x89\x85\x08\x3f\xfd\xf6\x05\x00\x55\x3a\xbc\x0e\x05\xcd\x02\x18\x4b\xdb\x89\xc4\xcc\xd6\x7e\x18\x79\x51\x26\x7e\xb3\x28"
-        , vecPub = "\xdc\xea\x9e\x78\xf3\x5a\x1b\xf3\x49\x9a\x83\x1b\x10\xb8\x6c\x90\xaa\xc0\x1c\xd8\x4b\x67\xa0\x10\x9b\x55\xa3\x6e\x93\x28\xb1\xe3\x65\xfc\xe1\x61\xd7\x1c\xe7\x13\x1a\x54\x3e\xa4\xcb\x5f\x7e\x9f\x1d\x8b\x00\x69\x64\x47\x00\x14\x00"
+        { vecSec =
+            "\xcd\x23\xd2\x4f\x71\x42\x74\xe7\x44\x34\x32\x37\xb9\x32\x90\xf5\x11\xf6\x42\x5f\x98\xe6\x44\x59\xff\x20\x3e\x89\x85\x08\x3f\xfd\xf6\x05\x00\x55\x3a\xbc\x0e\x05\xcd\x02\x18\x4b\xdb\x89\xc4\xcc\xd6\x7e\x18\x79\x51\x26\x7e\xb3\x28"
+        , vecPub =
+            "\xdc\xea\x9e\x78\xf3\x5a\x1b\xf3\x49\x9a\x83\x1b\x10\xb8\x6c\x90\xaa\xc0\x1c\xd8\x4b\x67\xa0\x10\x9b\x55\xa3\x6e\x93\x28\xb1\xe3\x65\xfc\xe1\x61\xd7\x1c\xe7\x13\x1a\x54\x3e\xa4\xcb\x5f\x7e\x9f\x1d\x8b\x00\x69\x64\x47\x00\x14\x00"
         , vecMsg = "\x0c\x3e\x54\x40\x74\xec\x63\xb0\x26\x5e\x0c"
-        , vecSig = "\x1f\x0a\x88\x88\xce\x25\xe8\xd4\x58\xa2\x11\x30\x87\x9b\x84\x0a\x90\x89\xd9\x99\xaa\xba\x03\x9e\xaf\x3e\x3a\xfa\x09\x0a\x09\xd3\x89\xdb\xa8\x2c\x4f\xf2\xae\x8a\xc5\xcd\xfb\x7c\x55\xe9\x4d\x5d\x96\x1a\x29\xfe\x01\x09\x94\x1e\x00\xb8\xdb\xde\xea\x6d\x3b\x05\x10\x68\xdf\x72\x54\xc0\xcd\xc1\x29\xcb\xe6\x2d\xb2\xdc\x95\x7d\xbb\x47\xb5\x1f\xd3\xf2\x13\xfb\x86\x98\xf0\x64\x77\x42\x50\xa5\x02\x89\x61\xc9\xbf\x8f\xfd\x97\x3f\xe5\xd5\xc2\x06\x49\x2b\x14\x0e\x00"
+        , vecSig =
+            "\x1f\x0a\x88\x88\xce\x25\xe8\xd4\x58\xa2\x11\x30\x87\x9b\x84\x0a\x90\x89\xd9\x99\xaa\xba\x03\x9e\xaf\x3e\x3a\xfa\x09\x0a\x09\xd3\x89\xdb\xa8\x2c\x4f\xf2\xae\x8a\xc5\xcd\xfb\x7c\x55\xe9\x4d\x5d\x96\x1a\x29\xfe\x01\x09\x94\x1e\x00\xb8\xdb\xde\xea\x6d\x3b\x05\x10\x68\xdf\x72\x54\xc0\xcd\xc1\x29\xcb\xe6\x2d\xb2\xdc\x95\x7d\xbb\x47\xb5\x1f\xd3\xf2\x13\xfb\x86\x98\xf0\x64\x77\x42\x50\xa5\x02\x89\x61\xc9\xbf\x8f\xfd\x97\x3f\xe5\xd5\xc2\x06\x49\x2b\x14\x0e\x00"
         }
     , Vec
-        { vecSec = "\x25\x8c\xdd\x4a\xda\x32\xed\x9c\x9f\xf5\x4e\x63\x75\x6a\xe5\x82\xfb\x8f\xab\x2a\xc7\x21\xf2\xc8\xe6\x76\xa7\x27\x68\x51\x3d\x93\x9f\x63\xdd\xdb\x55\x60\x91\x33\xf2\x9a\xdf\x86\xec\x99\x29\xdc\xcb\x52\xc1\xc5\xfd\x2f\xf7\xe2\x1b"
-        , vecPub = "\x3b\xa1\x6d\xa0\xc6\xf2\xcc\x1f\x30\x18\x77\x40\x75\x6f\x5e\x79\x8d\x6b\xc5\xfc\x01\x5d\x7c\x63\xcc\x95\x10\xee\x3f\xd4\x4a\xdc\x24\xd8\xe9\x68\xb6\xe4\x6e\x6f\x94\xd1\x9b\x94\x53\x61\x72\x6b\xd7\x5e\x14\x9e\xf0\x98\x17\xf5\x80"
+        { vecSec =
+            "\x25\x8c\xdd\x4a\xda\x32\xed\x9c\x9f\xf5\x4e\x63\x75\x6a\xe5\x82\xfb\x8f\xab\x2a\xc7\x21\xf2\xc8\xe6\x76\xa7\x27\x68\x51\x3d\x93\x9f\x63\xdd\xdb\x55\x60\x91\x33\xf2\x9a\xdf\x86\xec\x99\x29\xdc\xcb\x52\xc1\xc5\xfd\x2f\xf7\xe2\x1b"
+        , vecPub =
+            "\x3b\xa1\x6d\xa0\xc6\xf2\xcc\x1f\x30\x18\x77\x40\x75\x6f\x5e\x79\x8d\x6b\xc5\xfc\x01\x5d\x7c\x63\xcc\x95\x10\xee\x3f\xd4\x4a\xdc\x24\xd8\xe9\x68\xb6\xe4\x6e\x6f\x94\xd1\x9b\x94\x53\x61\x72\x6b\xd7\x5e\x14\x9e\xf0\x98\x17\xf5\x80"
         , vecMsg = "\x64\xa6\x5f\x3c\xde\xdc\xdd\x66\x81\x1e\x29\x15"
-        , vecSig = "\x7e\xee\xab\x7c\x4e\x50\xfb\x79\x9b\x41\x8e\xe5\xe3\x19\x7f\xf6\xbf\x15\xd4\x3a\x14\xc3\x43\x89\xb5\x9d\xd1\xa7\xb1\xb8\x5b\x4a\xe9\x04\x38\xac\xa6\x34\xbe\xa4\x5e\x3a\x26\x95\xf1\x27\x0f\x07\xfd\xcd\xf7\xc6\x2b\x8e\xfe\xaf\x00\xb4\x5c\x2c\x96\xba\x45\x7e\xb1\xa8\xbf\x07\x5a\x3d\xb2\x8e\x5c\x24\xf6\xb9\x23\xed\x4a\xd7\x47\xc3\xc9\xe0\x3c\x70\x79\xef\xb8\x7c\xb1\x10\xd3\xa9\x98\x61\xe7\x20\x03\xcb\xae\x6d\x6b\x8b\x82\x7e\x4e\x6c\x14\x30\x64\xff\x3c\x00"
+        , vecSig =
+            "\x7e\xee\xab\x7c\x4e\x50\xfb\x79\x9b\x41\x8e\xe5\xe3\x19\x7f\xf6\xbf\x15\xd4\x3a\x14\xc3\x43\x89\xb5\x9d\xd1\xa7\xb1\xb8\x5b\x4a\xe9\x04\x38\xac\xa6\x34\xbe\xa4\x5e\x3a\x26\x95\xf1\x27\x0f\x07\xfd\xcd\xf7\xc6\x2b\x8e\xfe\xaf\x00\xb4\x5c\x2c\x96\xba\x45\x7e\xb1\xa8\xbf\x07\x5a\x3d\xb2\x8e\x5c\x24\xf6\xb9\x23\xed\x4a\xd7\x47\xc3\xc9\xe0\x3c\x70\x79\xef\xb8\x7c\xb1\x10\xd3\xa9\x98\x61\xe7\x20\x03\xcb\xae\x6d\x6b\x8b\x82\x7e\x4e\x6c\x14\x30\x64\xff\x3c\x00"
         }
     , Vec
-        { vecSec = "\x7e\xf4\xe8\x45\x44\x23\x67\x52\xfb\xb5\x6b\x8f\x31\xa2\x3a\x10\xe4\x28\x14\xf5\xf5\x5c\xa0\x37\xcd\xcc\x11\xc6\x4c\x9a\x3b\x29\x49\xc1\xbb\x60\x70\x03\x14\x61\x17\x32\xa6\xc2\xfe\xa9\x8e\xeb\xc0\x26\x6a\x11\xa9\x39\x70\x10\x0e"
-        , vecPub = "\xb3\xda\x07\x9b\x0a\xa4\x93\xa5\x77\x20\x29\xf0\x46\x7b\xae\xbe\xe5\xa8\x11\x2d\x9d\x3a\x22\x53\x23\x61\xda\x29\x4f\x7b\xb3\x81\x5c\x5d\xc5\x9e\x17\x6b\x4d\x9f\x38\x1c\xa0\x93\x8e\x13\xc6\xc0\x7b\x17\x4b\xe6\x5d\xfa\x57\x8e\x80"
+        { vecSec =
+            "\x7e\xf4\xe8\x45\x44\x23\x67\x52\xfb\xb5\x6b\x8f\x31\xa2\x3a\x10\xe4\x28\x14\xf5\xf5\x5c\xa0\x37\xcd\xcc\x11\xc6\x4c\x9a\x3b\x29\x49\xc1\xbb\x60\x70\x03\x14\x61\x17\x32\xa6\xc2\xfe\xa9\x8e\xeb\xc0\x26\x6a\x11\xa9\x39\x70\x10\x0e"
+        , vecPub =
+            "\xb3\xda\x07\x9b\x0a\xa4\x93\xa5\x77\x20\x29\xf0\x46\x7b\xae\xbe\xe5\xa8\x11\x2d\x9d\x3a\x22\x53\x23\x61\xda\x29\x4f\x7b\xb3\x81\x5c\x5d\xc5\x9e\x17\x6b\x4d\x9f\x38\x1c\xa0\x93\x8e\x13\xc6\xc0\x7b\x17\x4b\xe6\x5d\xfa\x57\x8e\x80"
         , vecMsg = "\x64\xa6\x5f\x3c\xde\xdc\xdd\x66\x81\x1e\x29\x15\xe7"
-        , vecSig = "\x6a\x12\x06\x6f\x55\x33\x1b\x6c\x22\xac\xd5\xd5\xbf\xc5\xd7\x12\x28\xfb\xda\x80\xae\x8d\xec\x26\xbd\xd3\x06\x74\x3c\x50\x27\xcb\x48\x90\x81\x0c\x16\x2c\x02\x74\x68\x67\x5e\xcf\x64\x5a\x83\x17\x6c\x0d\x73\x23\xa2\xcc\xde\x2d\x80\xef\xe5\xa1\x26\x8e\x8a\xca\x1d\x6f\xbc\x19\x4d\x3f\x77\xc4\x49\x86\xeb\x4a\xb4\x17\x79\x19\xad\x8b\xec\x33\xeb\x47\xbb\xb5\xfc\x6e\x28\x19\x6f\xd1\xca\xf5\x6b\x4e\x7e\x0b\xa5\x51\x92\x34\xd0\x47\x15\x5a\xc7\x27\xa1\x05\x31\x00"
+        , vecSig =
+            "\x6a\x12\x06\x6f\x55\x33\x1b\x6c\x22\xac\xd5\xd5\xbf\xc5\xd7\x12\x28\xfb\xda\x80\xae\x8d\xec\x26\xbd\xd3\x06\x74\x3c\x50\x27\xcb\x48\x90\x81\x0c\x16\x2c\x02\x74\x68\x67\x5e\xcf\x64\x5a\x83\x17\x6c\x0d\x73\x23\xa2\xcc\xde\x2d\x80\xef\xe5\xa1\x26\x8e\x8a\xca\x1d\x6f\xbc\x19\x4d\x3f\x77\xc4\x49\x86\xeb\x4a\xb4\x17\x79\x19\xad\x8b\xec\x33\xeb\x47\xbb\xb5\xfc\x6e\x28\x19\x6f\xd1\xca\xf5\x6b\x4e\x7e\x0b\xa5\x51\x92\x34\xd0\x47\x15\x5a\xc7\x27\xa1\x05\x31\x00"
         }
     , Vec
-        { vecSec = "\xd6\x5d\xf3\x41\xad\x13\xe0\x08\x56\x76\x88\xba\xed\xda\x8e\x9d\xcd\xc1\x7d\xc0\x24\x97\x4e\xa5\xb4\x22\x7b\x65\x30\xe3\x39\xbf\xf2\x1f\x99\xe6\x8c\xa6\x96\x8f\x3c\xca\x6d\xfe\x0f\xb9\xf4\xfa\xb4\xfa\x13\x5d\x55\x42\xea\x3f\x01"
-        , vecPub = "\xdf\x97\x05\xf5\x8e\xdb\xab\x80\x2c\x7f\x83\x63\xcf\xe5\x56\x0a\xb1\xc6\x13\x2c\x20\xa9\xf1\xdd\x16\x34\x83\xa2\x6f\x8a\xc5\x3a\x39\xd6\x80\x8b\xf4\xa1\xdf\xbd\x26\x1b\x09\x9b\xb0\x3b\x3f\xb5\x09\x06\xcb\x28\xbd\x8a\x08\x1f\x00"
-        , vecMsg = "\xbd\x0f\x6a\x37\x47\xcd\x56\x1b\xdd\xdf\x46\x40\xa3\x32\x46\x1a\x4a\x30\xa1\x2a\x43\x4c\xd0\xbf\x40\xd7\x66\xd9\xc6\xd4\x58\xe5\x51\x22\x04\xa3\x0c\x17\xd1\xf5\x0b\x50\x79\x63\x1f\x64\xeb\x31\x12\x18\x2d\xa3\x00\x58\x35\x46\x11\x13\x71\x8d\x1a\x5e\xf9\x44"
-        , vecSig = "\x55\x4b\xc2\x48\x08\x60\xb4\x9e\xab\x85\x32\xd2\xa5\x33\xb7\xd5\x78\xef\x47\x3e\xeb\x58\xc9\x8b\xb2\xd0\xe1\xce\x48\x8a\x98\xb1\x8d\xfd\xe9\xb9\xb9\x07\x75\xe6\x7f\x47\xd4\xa1\xc3\x48\x20\x58\xef\xc9\xf4\x0d\x2c\xa0\x33\xa0\x80\x1b\x63\xd4\x5b\x3b\x72\x2e\xf5\x52\xba\xd3\xb4\xcc\xb6\x67\xda\x35\x01\x92\xb6\x1c\x50\x8c\xf7\xb6\xb5\xad\xad\xc2\xc8\xd9\xa4\x46\xef\x00\x3f\xb0\x5c\xba\x5f\x30\xe8\x8e\x36\xec\x27\x03\xb3\x49\xca\x22\x9c\x26\x70\x83\x39\x00"
+        { vecSec =
+            "\xd6\x5d\xf3\x41\xad\x13\xe0\x08\x56\x76\x88\xba\xed\xda\x8e\x9d\xcd\xc1\x7d\xc0\x24\x97\x4e\xa5\xb4\x22\x7b\x65\x30\xe3\x39\xbf\xf2\x1f\x99\xe6\x8c\xa6\x96\x8f\x3c\xca\x6d\xfe\x0f\xb9\xf4\xfa\xb4\xfa\x13\x5d\x55\x42\xea\x3f\x01"
+        , vecPub =
+            "\xdf\x97\x05\xf5\x8e\xdb\xab\x80\x2c\x7f\x83\x63\xcf\xe5\x56\x0a\xb1\xc6\x13\x2c\x20\xa9\xf1\xdd\x16\x34\x83\xa2\x6f\x8a\xc5\x3a\x39\xd6\x80\x8b\xf4\xa1\xdf\xbd\x26\x1b\x09\x9b\xb0\x3b\x3f\xb5\x09\x06\xcb\x28\xbd\x8a\x08\x1f\x00"
+        , vecMsg =
+            "\xbd\x0f\x6a\x37\x47\xcd\x56\x1b\xdd\xdf\x46\x40\xa3\x32\x46\x1a\x4a\x30\xa1\x2a\x43\x4c\xd0\xbf\x40\xd7\x66\xd9\xc6\xd4\x58\xe5\x51\x22\x04\xa3\x0c\x17\xd1\xf5\x0b\x50\x79\x63\x1f\x64\xeb\x31\x12\x18\x2d\xa3\x00\x58\x35\x46\x11\x13\x71\x8d\x1a\x5e\xf9\x44"
+        , vecSig =
+            "\x55\x4b\xc2\x48\x08\x60\xb4\x9e\xab\x85\x32\xd2\xa5\x33\xb7\xd5\x78\xef\x47\x3e\xeb\x58\xc9\x8b\xb2\xd0\xe1\xce\x48\x8a\x98\xb1\x8d\xfd\xe9\xb9\xb9\x07\x75\xe6\x7f\x47\xd4\xa1\xc3\x48\x20\x58\xef\xc9\xf4\x0d\x2c\xa0\x33\xa0\x80\x1b\x63\xd4\x5b\x3b\x72\x2e\xf5\x52\xba\xd3\xb4\xcc\xb6\x67\xda\x35\x01\x92\xb6\x1c\x50\x8c\xf7\xb6\xb5\xad\xad\xc2\xc8\xd9\xa4\x46\xef\x00\x3f\xb0\x5c\xba\x5f\x30\xe8\x8e\x36\xec\x27\x03\xb3\x49\xca\x22\x9c\x26\x70\x83\x39\x00"
         }
     , Vec
-        { vecSec = "\x2e\xc5\xfe\x3c\x17\x04\x5a\xbd\xb1\x36\xa5\xe6\xa9\x13\xe3\x2a\xb7\x5a\xe6\x8b\x53\xd2\xfc\x14\x9b\x77\xe5\x04\x13\x2d\x37\x56\x9b\x7e\x76\x6b\xa7\x4a\x19\xbd\x61\x62\x34\x3a\x21\xc8\x59\x0a\xa9\xce\xbc\xa9\x01\x4c\x63\x6d\xf5"
-        , vecPub = "\x79\x75\x6f\x01\x4d\xcf\xe2\x07\x9f\x5d\xd9\xe7\x18\xbe\x41\x71\xe2\xef\x24\x86\xa0\x8f\x25\x18\x6f\x6b\xff\x43\xa9\x93\x6b\x9b\xfe\x12\x40\x2b\x08\xae\x65\x79\x8a\x3d\x81\xe2\x2e\x9e\xc8\x0e\x76\x90\x86\x2e\xf3\xd4\xed\x3a\x00"
-        , vecMsg = "\x15\x77\x75\x32\xb0\xbd\xd0\xd1\x38\x9f\x63\x6c\x5f\x6b\x9b\xa7\x34\xc9\x0a\xf5\x72\x87\x7e\x2d\x27\x2d\xd0\x78\xaa\x1e\x56\x7c\xfa\x80\xe1\x29\x28\xbb\x54\x23\x30\xe8\x40\x9f\x31\x74\x50\x41\x07\xec\xd5\xef\xac\x61\xae\x75\x04\xda\xbe\x2a\x60\x2e\xde\x89\xe5\xcc\xa6\x25\x7a\x7c\x77\xe2\x7a\x70\x2b\x3a\xe3\x9f\xc7\x69\xfc\x54\xf2\x39\x5a\xe6\xa1\x17\x8c\xab\x47\x38\xe5\x43\x07\x2f\xc1\xc1\x77\xfe\x71\xe9\x2e\x25\xbf\x03\xe4\xec\xb7\x2f\x47\xb6\x4d\x04\x65\xaa\xea\x4c\x7f\xad\x37\x25\x36\xc8\xba\x51\x6a\x60\x39\xc3\xc2\xa3\x9f\x0e\x4d\x83\x2b\xe4\x32\xdf\xa9\xa7\x06\xa6\xe5\xc7\xe1\x9f\x39\x79\x64\xca\x42\x58\x00\x2f\x7c\x05\x41\xb5\x90\x31\x6d\xbc\x56\x22\xb6\xb2\xa6\xfe\x7a\x4a\xbf\xfd\x96\x10\x5e\xca\x76\xea\x7b\x98\x81\x6a\xf0\x74\x8c\x10\xdf\x04\x8c\xe0\x12\xd9\x01\x01\x5a\x51\xf1\x89\xf3\x88\x81\x45\xc0\x36\x50\xaa\x23\xce\x89\x4c\x3b\xd8\x89\xe0\x30\xd5\x65\x07\x1c\x59\xf4\x09\xa9\x98\x1b\x51\x87\x8f\xd6\xfc\x11\x06\x24\xdc\xbc\xde\x0b\xf7\xa6\x9c\xcc\xe3\x8f\xab\xdf\x86\xf3\xbe\xf6\x04\x48\x19\xde\x11"
-        , vecSig = "\xc6\x50\xdd\xbb\x06\x01\xc1\x9c\xa1\x14\x39\xe1\x64\x0d\xd9\x31\xf4\x3c\x51\x8e\xa5\xbe\xa7\x0d\x3d\xcd\xe5\xf4\x19\x1f\xe5\x3f\x00\xcf\x96\x65\x46\xb7\x2b\xcc\x7d\x58\xbe\x2b\x9b\xad\xef\x28\x74\x39\x54\xe3\xa4\x4a\x23\xf8\x80\xe8\xd4\xf1\xcf\xce\x2d\x7a\x61\x45\x2d\x26\xda\x05\x89\x6f\x0a\x50\xda\x66\xa2\x39\xa8\xa1\x88\xb6\xd8\x25\xb3\x30\x5a\xd7\x7b\x73\xfb\xac\x08\x36\xec\xc6\x09\x87\xfd\x08\x52\x7c\x1a\x8e\x80\xd5\x82\x3e\x65\xca\xfe\x2a\x3d\x00"
+        { vecSec =
+            "\x2e\xc5\xfe\x3c\x17\x04\x5a\xbd\xb1\x36\xa5\xe6\xa9\x13\xe3\x2a\xb7\x5a\xe6\x8b\x53\xd2\xfc\x14\x9b\x77\xe5\x04\x13\x2d\x37\x56\x9b\x7e\x76\x6b\xa7\x4a\x19\xbd\x61\x62\x34\x3a\x21\xc8\x59\x0a\xa9\xce\xbc\xa9\x01\x4c\x63\x6d\xf5"
+        , vecPub =
+            "\x79\x75\x6f\x01\x4d\xcf\xe2\x07\x9f\x5d\xd9\xe7\x18\xbe\x41\x71\xe2\xef\x24\x86\xa0\x8f\x25\x18\x6f\x6b\xff\x43\xa9\x93\x6b\x9b\xfe\x12\x40\x2b\x08\xae\x65\x79\x8a\x3d\x81\xe2\x2e\x9e\xc8\x0e\x76\x90\x86\x2e\xf3\xd4\xed\x3a\x00"
+        , vecMsg =
+            "\x15\x77\x75\x32\xb0\xbd\xd0\xd1\x38\x9f\x63\x6c\x5f\x6b\x9b\xa7\x34\xc9\x0a\xf5\x72\x87\x7e\x2d\x27\x2d\xd0\x78\xaa\x1e\x56\x7c\xfa\x80\xe1\x29\x28\xbb\x54\x23\x30\xe8\x40\x9f\x31\x74\x50\x41\x07\xec\xd5\xef\xac\x61\xae\x75\x04\xda\xbe\x2a\x60\x2e\xde\x89\xe5\xcc\xa6\x25\x7a\x7c\x77\xe2\x7a\x70\x2b\x3a\xe3\x9f\xc7\x69\xfc\x54\xf2\x39\x5a\xe6\xa1\x17\x8c\xab\x47\x38\xe5\x43\x07\x2f\xc1\xc1\x77\xfe\x71\xe9\x2e\x25\xbf\x03\xe4\xec\xb7\x2f\x47\xb6\x4d\x04\x65\xaa\xea\x4c\x7f\xad\x37\x25\x36\xc8\xba\x51\x6a\x60\x39\xc3\xc2\xa3\x9f\x0e\x4d\x83\x2b\xe4\x32\xdf\xa9\xa7\x06\xa6\xe5\xc7\xe1\x9f\x39\x79\x64\xca\x42\x58\x00\x2f\x7c\x05\x41\xb5\x90\x31\x6d\xbc\x56\x22\xb6\xb2\xa6\xfe\x7a\x4a\xbf\xfd\x96\x10\x5e\xca\x76\xea\x7b\x98\x81\x6a\xf0\x74\x8c\x10\xdf\x04\x8c\xe0\x12\xd9\x01\x01\x5a\x51\xf1\x89\xf3\x88\x81\x45\xc0\x36\x50\xaa\x23\xce\x89\x4c\x3b\xd8\x89\xe0\x30\xd5\x65\x07\x1c\x59\xf4\x09\xa9\x98\x1b\x51\x87\x8f\xd6\xfc\x11\x06\x24\xdc\xbc\xde\x0b\xf7\xa6\x9c\xcc\xe3\x8f\xab\xdf\x86\xf3\xbe\xf6\x04\x48\x19\xde\x11"
+        , vecSig =
+            "\xc6\x50\xdd\xbb\x06\x01\xc1\x9c\xa1\x14\x39\xe1\x64\x0d\xd9\x31\xf4\x3c\x51\x8e\xa5\xbe\xa7\x0d\x3d\xcd\xe5\xf4\x19\x1f\xe5\x3f\x00\xcf\x96\x65\x46\xb7\x2b\xcc\x7d\x58\xbe\x2b\x9b\xad\xef\x28\x74\x39\x54\xe3\xa4\x4a\x23\xf8\x80\xe8\xd4\xf1\xcf\xce\x2d\x7a\x61\x45\x2d\x26\xda\x05\x89\x6f\x0a\x50\xda\x66\xa2\x39\xa8\xa1\x88\xb6\xd8\x25\xb3\x30\x5a\xd7\x7b\x73\xfb\xac\x08\x36\xec\xc6\x09\x87\xfd\x08\x52\x7c\x1a\x8e\x80\xd5\x82\x3e\x65\xca\xfe\x2a\x3d\x00"
         }
     , Vec
-        { vecSec = "\x87\x2d\x09\x37\x80\xf5\xd3\x73\x0d\xf7\xc2\x12\x66\x4b\x37\xb8\xa0\xf2\x4f\x56\x81\x0d\xaa\x83\x82\xcd\x4f\xa3\xf7\x76\x34\xec\x44\xdc\x54\xf1\xc2\xed\x9b\xea\x86\xfa\xfb\x76\x32\xd8\xbe\x19\x9e\xa1\x65\xf5\xad\x55\xdd\x9c\xe8"
-        , vecPub = "\xa8\x1b\x2e\x8a\x70\xa5\xac\x94\xff\xdb\xcc\x9b\xad\xfc\x3f\xeb\x08\x01\xf2\x58\x57\x8b\xb1\x14\xad\x44\xec\xe1\xec\x0e\x79\x9d\xa0\x8e\xff\xb8\x1c\x5d\x68\x5c\x0c\x56\xf6\x4e\xec\xae\xf8\xcd\xf1\x1c\xc3\x87\x37\x83\x8c\xf4\x00"
-        , vecMsg = "\x6d\xdf\x80\x2e\x1a\xae\x49\x86\x93\x5f\x7f\x98\x1b\xa3\xf0\x35\x1d\x62\x73\xc0\xa0\xc2\x2c\x9c\x0e\x83\x39\x16\x8e\x67\x54\x12\xa3\xde\xbf\xaf\x43\x5e\xd6\x51\x55\x80\x07\xdb\x43\x84\xb6\x50\xfc\xc0\x7e\x3b\x58\x6a\x27\xa4\xf7\xa0\x0a\xc8\xa6\xfe\xc2\xcd\x86\xae\x4b\xf1\x57\x0c\x41\xe6\xa4\x0c\x93\x1d\xb2\x7b\x2f\xaa\x15\xa8\xce\xdd\x52\xcf\xf7\x36\x2c\x4e\x6e\x23\xda\xec\x0f\xbc\x3a\x79\xb6\x80\x6e\x31\x6e\xfc\xc7\xb6\x81\x19\xbf\x46\xbc\x76\xa2\x60\x67\xa5\x3f\x29\x6d\xaf\xdb\xdc\x11\xc7\x7f\x77\x77\xe9\x72\x66\x0c\xf4\xb6\xa9\xb3\x69\xa6\x66\x5f\x02\xe0\xcc\x9b\x6e\xdf\xad\x13\x6b\x4f\xab\xe7\x23\xd2\x81\x3d\xb3\x13\x6c\xfd\xe9\xb6\xd0\x44\x32\x2f\xee\x29\x47\x95\x2e\x03\x1b\x73\xab\x5c\x60\x33\x49\xb3\x07\xbd\xc2\x7b\xc6\xcb\x8b\x8b\xbd\x7b\xd3\x23\x21\x9b\x80\x33\xa5\x81\xb5\x9e\xad\xeb\xb0\x9b\x3c\x4f\x3d\x22\x77\xd4\xf0\x34\x36\x24\xac\xc8\x17\x80\x47\x28\xb2\x5a\xb7\x97\x17\x2b\x4c\x5c\x21\xa2\x2f\x9c\x78\x39\xd6\x43\x00\x23\x2e\xb6\x6e\x53\xf3\x1c\x72\x3f\xa3\x7f\xe3\x87\xc7\xd3\xe5\x0b\xdf\x98\x13\xa3\x0e\x5b\xb1\x2c\xf4\xcd\x93\x0c\x40\xcf\xb4\xe1\xfc\x62\x25\x92\xa4\x95\x88\x79\x44\x94\xd5\x6d\x24\xea\x4b\x40\xc8\x9f\xc0\x59\x6c\xc9\xeb\xb9\x61\xc8\xcb\x10\xad\xde\x97\x6a\x5d\x60\x2b\x1c\x3f\x85\xb9\xb9\xa0\x01\xed\x3c\x6a\x4d\x3b\x14\x37\xf5\x20\x96\xcd\x19\x56\xd0\x42\xa5\x97\xd5\x61\xa5\x96\xec\xd3\xd1\x73\x5a\x8d\x57\x0e\xa0\xec\x27\x22\x5a\x2c\x4a\xaf\xf2\x63\x06\xd1\x52\x6c\x1a\xf3\xca\x6d\x9c\xf5\xa2\xc9\x8f\x47\xe1\xc4\x6d\xb9\xa3\x32\x34\xcf\xd4\xd8\x1f\x2c\x98\x53\x8a\x09\xeb\xe7\x69\x98\xd0\xd8\xfd\x25\x99\x7c\x7d\x25\x5c\x6d\x66\xec\xe6\xfa\x56\xf1\x11\x44\x95\x0f\x02\x77\x95\xe6\x53\x00\x8f\x4b\xd7\xca\x2d\xee\x85\xd8\xe9\x0f\x3d\xc3\x15\x13\x0c\xe2\xa0\x03\x75\xa3\x18\xc7\xc3\xd9\x7b\xe2\xc8\xce\x5b\x6d\xb4\x1a\x62\x54\xff\x26\x4f\xa6\x15\x5b\xae\xe3\xb0\x77\x3c\x0f\x49\x7c\x57\x3f\x19\xbb\x4f\x42\x40\x28\x1f\x0b\x1f\x4f\x7b\xe8\x57\xa4\xe5\x9d\x41\x6c\x06\xb4\xc5\x0f\xa0\x9e\x18\x10\xdd\xc6\xb1\x46\x7b\xae\xac\x5a\x36\x68\xd1\x1b\x6e\xca\xa9\x01\x44\x00\x16\xf3\x89\xf8\x0a\xcc\x4d\xb9\x77\x02\x5e\x7f\x59\x24\x38\x8c\x7e\x34\x0a\x73\x2e\x55\x44\x40\xe7\x65\x70\xf8\xdd\x71\xb7\xd6\x40\xb3\x45\x0d\x1f\xd5\xf0\x41\x0a\x18\xf9\xa3\x49\x4f\x70\x7c\x71\x7b\x79\xb4\xbf\x75\xc9\x84\x00\xb0\x96\xb2\x16\x53\xb5\xd2\x17\xcf\x35\x65\xc9\x59\x74\x56\xf7\x07\x03\x49\x7a\x07\x87\x63\x82\x9b\xc0\x1b\xb1\xcb\xc8\xfa\x04\xea\xdc\x9a\x6e\x3f\x66\x99\x58\x7a\x9e\x75\xc9\x4e\x5b\xab\x00\x36\xe0\xb2\xe7\x11\x39\x2c\xff\x00\x47\xd0\xd6\xb0\x5b\xd2\xa5\x88\xbc\x10\x97\x18\x95\x42\x59\xf1\xd8\x66\x78\xa5\x79\xa3\x12\x0f\x19\xcf\xb2\x96\x3f\x17\x7a\xeb\x70\xf2\xd4\x84\x48\x26\x26\x2e\x51\xb8\x02\x71\x27\x20\x68\xef\x5b\x38\x56\xfa\x85\x35\xaa\x2a\x88\xb2\xd4\x1f\x2a\x0e\x2f\xda\x76\x24\xc2\x85\x02\x72\xac\x4a\x2f\x56\x1f\x8f\x2f\x7a\x31\x8b\xfd\x5c\xaf\x96\x96\x14\x9e\x4a\xc8\x24\xad\x34\x60\x53\x8f\xdc\x25\x42\x1b\xee\xc2\xcc\x68\x18\x16\x2d\x06\xbb\xed\x0c\x40\xa3\x87\x19\x23\x49\xdb\x67\xa1\x18\xba\xda\x6c\xd5\xab\x01\x40\xee\x27\x32\x04\xf6\x28\xaa\xd1\xc1\x35\xf7\x70\x27\x9a\x65\x1e\x24\xd8\xc1\x4d\x75\xa6\x05\x9d\x76\xb9\x6a\x6f\xd8\x57\xde\xf5\xe0\xb3\x54\xb2\x7a\xb9\x37\xa5\x81\x5d\x16\xb5\xfa\xe4\x07\xff\x18\x22\x2c\x6d\x1e\xd2\x63\xbe\x68\xc9\x5f\x32\xd9\x08\xbd\x89\x5c\xd7\x62\x07\xae\x72\x64\x87\x56\x7f\x9a\x67\xda\xd7\x9a\xbe\xc3\x16\xf6\x83\xb1\x7f\x2d\x02\xbf\x07\xe0\xac\x8b\x5b\xc6\x16\x2c\xf9\x46\x97\xb3\xc2\x7c\xd1\xfe\xa4\x9b\x27\xf2\x3b\xa2\x90\x18\x71\x96\x25\x06\x52\x0c\x39\x2d\xa8\xb6\xad\x0d\x99\xf7\x01\x3f\xbc\x06\xc2\xc1\x7a\x56\x95\x00\xc8\xa7\x69\x64\x81\xc1\xcd\x33\xe9\xb1\x4e\x40\xb8\x2e\x79\xa5\xf5\xdb\x82\x57\x1b\xa9\x7b\xae\x3a\xd3\xe0\x47\x95\x15\xbb\x0e\x2b\x0f\x3b\xfc\xd1\xfd\x33\x03\x4e\xfc\x62\x45\xed\xdd\x7e\xe2\x08\x6d\xda\xe2\x60\x0d\x8c\xa7\x3e\x21\x4e\x8c\x2b\x0b\xdb\x2b\x04\x7c\x6a\x46\x4a\x56\x2e\xd7\x7b\x73\xd2\xd8\x41\xc4\xb3\x49\x73\x55\x12\x57\x71\x3b\x75\x36\x32\xef\xba\x34\x81\x69\xab\xc9\x0a\x68\xf4\x26\x11\xa4\x01\x26\xd7\xcb\x21\xb5\x86\x95\x56\x81\x86\xf7\xe5\x69\xd2\xff\x0f\x9e\x74\x5d\x04\x87\xdd\x2e\xb9\x97\xca\xfc\x5a\xbf\x9d\xd1\x02\xe6\x2f\xf6\x6c\xba\x87"
-        , vecSig = "\xe3\x01\x34\x5a\x41\xa3\x9a\x4d\x72\xff\xf8\xdf\x69\xc9\x80\x75\xa0\xcc\x08\x2b\x80\x2f\xc9\xb2\xb6\xbc\x50\x3f\x92\x6b\x65\xbd\xdf\x7f\x4c\x8f\x1c\xb4\x9f\x63\x96\xaf\xc8\xa7\x0a\xbe\x6d\x8a\xef\x0d\xb4\x78\xd4\xc6\xb2\x97\x00\x76\xc6\xa0\x48\x4f\xe7\x6d\x76\xb3\xa9\x76\x25\xd7\x9f\x1c\xe2\x40\xe7\xc5\x76\x75\x0d\x29\x55\x28\x28\x6f\x71\x9b\x41\x3d\xe9\xad\xa3\xe8\xeb\x78\xed\x57\x36\x03\xce\x30\xd8\xbb\x76\x17\x85\xdc\x30\xdb\xc3\x20\x86\x9e\x1a\x00"
+        { vecSec =
+            "\x87\x2d\x09\x37\x80\xf5\xd3\x73\x0d\xf7\xc2\x12\x66\x4b\x37\xb8\xa0\xf2\x4f\x56\x81\x0d\xaa\x83\x82\xcd\x4f\xa3\xf7\x76\x34\xec\x44\xdc\x54\xf1\xc2\xed\x9b\xea\x86\xfa\xfb\x76\x32\xd8\xbe\x19\x9e\xa1\x65\xf5\xad\x55\xdd\x9c\xe8"
+        , vecPub =
+            "\xa8\x1b\x2e\x8a\x70\xa5\xac\x94\xff\xdb\xcc\x9b\xad\xfc\x3f\xeb\x08\x01\xf2\x58\x57\x8b\xb1\x14\xad\x44\xec\xe1\xec\x0e\x79\x9d\xa0\x8e\xff\xb8\x1c\x5d\x68\x5c\x0c\x56\xf6\x4e\xec\xae\xf8\xcd\xf1\x1c\xc3\x87\x37\x83\x8c\xf4\x00"
+        , vecMsg =
+            "\x6d\xdf\x80\x2e\x1a\xae\x49\x86\x93\x5f\x7f\x98\x1b\xa3\xf0\x35\x1d\x62\x73\xc0\xa0\xc2\x2c\x9c\x0e\x83\x39\x16\x8e\x67\x54\x12\xa3\xde\xbf\xaf\x43\x5e\xd6\x51\x55\x80\x07\xdb\x43\x84\xb6\x50\xfc\xc0\x7e\x3b\x58\x6a\x27\xa4\xf7\xa0\x0a\xc8\xa6\xfe\xc2\xcd\x86\xae\x4b\xf1\x57\x0c\x41\xe6\xa4\x0c\x93\x1d\xb2\x7b\x2f\xaa\x15\xa8\xce\xdd\x52\xcf\xf7\x36\x2c\x4e\x6e\x23\xda\xec\x0f\xbc\x3a\x79\xb6\x80\x6e\x31\x6e\xfc\xc7\xb6\x81\x19\xbf\x46\xbc\x76\xa2\x60\x67\xa5\x3f\x29\x6d\xaf\xdb\xdc\x11\xc7\x7f\x77\x77\xe9\x72\x66\x0c\xf4\xb6\xa9\xb3\x69\xa6\x66\x5f\x02\xe0\xcc\x9b\x6e\xdf\xad\x13\x6b\x4f\xab\xe7\x23\xd2\x81\x3d\xb3\x13\x6c\xfd\xe9\xb6\xd0\x44\x32\x2f\xee\x29\x47\x95\x2e\x03\x1b\x73\xab\x5c\x60\x33\x49\xb3\x07\xbd\xc2\x7b\xc6\xcb\x8b\x8b\xbd\x7b\xd3\x23\x21\x9b\x80\x33\xa5\x81\xb5\x9e\xad\xeb\xb0\x9b\x3c\x4f\x3d\x22\x77\xd4\xf0\x34\x36\x24\xac\xc8\x17\x80\x47\x28\xb2\x5a\xb7\x97\x17\x2b\x4c\x5c\x21\xa2\x2f\x9c\x78\x39\xd6\x43\x00\x23\x2e\xb6\x6e\x53\xf3\x1c\x72\x3f\xa3\x7f\xe3\x87\xc7\xd3\xe5\x0b\xdf\x98\x13\xa3\x0e\x5b\xb1\x2c\xf4\xcd\x93\x0c\x40\xcf\xb4\xe1\xfc\x62\x25\x92\xa4\x95\x88\x79\x44\x94\xd5\x6d\x24\xea\x4b\x40\xc8\x9f\xc0\x59\x6c\xc9\xeb\xb9\x61\xc8\xcb\x10\xad\xde\x97\x6a\x5d\x60\x2b\x1c\x3f\x85\xb9\xb9\xa0\x01\xed\x3c\x6a\x4d\x3b\x14\x37\xf5\x20\x96\xcd\x19\x56\xd0\x42\xa5\x97\xd5\x61\xa5\x96\xec\xd3\xd1\x73\x5a\x8d\x57\x0e\xa0\xec\x27\x22\x5a\x2c\x4a\xaf\xf2\x63\x06\xd1\x52\x6c\x1a\xf3\xca\x6d\x9c\xf5\xa2\xc9\x8f\x47\xe1\xc4\x6d\xb9\xa3\x32\x34\xcf\xd4\xd8\x1f\x2c\x98\x53\x8a\x09\xeb\xe7\x69\x98\xd0\xd8\xfd\x25\x99\x7c\x7d\x25\x5c\x6d\x66\xec\xe6\xfa\x56\xf1\x11\x44\x95\x0f\x02\x77\x95\xe6\x53\x00\x8f\x4b\xd7\xca\x2d\xee\x85\xd8\xe9\x0f\x3d\xc3\x15\x13\x0c\xe2\xa0\x03\x75\xa3\x18\xc7\xc3\xd9\x7b\xe2\xc8\xce\x5b\x6d\xb4\x1a\x62\x54\xff\x26\x4f\xa6\x15\x5b\xae\xe3\xb0\x77\x3c\x0f\x49\x7c\x57\x3f\x19\xbb\x4f\x42\x40\x28\x1f\x0b\x1f\x4f\x7b\xe8\x57\xa4\xe5\x9d\x41\x6c\x06\xb4\xc5\x0f\xa0\x9e\x18\x10\xdd\xc6\xb1\x46\x7b\xae\xac\x5a\x36\x68\xd1\x1b\x6e\xca\xa9\x01\x44\x00\x16\xf3\x89\xf8\x0a\xcc\x4d\xb9\x77\x02\x5e\x7f\x59\x24\x38\x8c\x7e\x34\x0a\x73\x2e\x55\x44\x40\xe7\x65\x70\xf8\xdd\x71\xb7\xd6\x40\xb3\x45\x0d\x1f\xd5\xf0\x41\x0a\x18\xf9\xa3\x49\x4f\x70\x7c\x71\x7b\x79\xb4\xbf\x75\xc9\x84\x00\xb0\x96\xb2\x16\x53\xb5\xd2\x17\xcf\x35\x65\xc9\x59\x74\x56\xf7\x07\x03\x49\x7a\x07\x87\x63\x82\x9b\xc0\x1b\xb1\xcb\xc8\xfa\x04\xea\xdc\x9a\x6e\x3f\x66\x99\x58\x7a\x9e\x75\xc9\x4e\x5b\xab\x00\x36\xe0\xb2\xe7\x11\x39\x2c\xff\x00\x47\xd0\xd6\xb0\x5b\xd2\xa5\x88\xbc\x10\x97\x18\x95\x42\x59\xf1\xd8\x66\x78\xa5\x79\xa3\x12\x0f\x19\xcf\xb2\x96\x3f\x17\x7a\xeb\x70\xf2\xd4\x84\x48\x26\x26\x2e\x51\xb8\x02\x71\x27\x20\x68\xef\x5b\x38\x56\xfa\x85\x35\xaa\x2a\x88\xb2\xd4\x1f\x2a\x0e\x2f\xda\x76\x24\xc2\x85\x02\x72\xac\x4a\x2f\x56\x1f\x8f\x2f\x7a\x31\x8b\xfd\x5c\xaf\x96\x96\x14\x9e\x4a\xc8\x24\xad\x34\x60\x53\x8f\xdc\x25\x42\x1b\xee\xc2\xcc\x68\x18\x16\x2d\x06\xbb\xed\x0c\x40\xa3\x87\x19\x23\x49\xdb\x67\xa1\x18\xba\xda\x6c\xd5\xab\x01\x40\xee\x27\x32\x04\xf6\x28\xaa\xd1\xc1\x35\xf7\x70\x27\x9a\x65\x1e\x24\xd8\xc1\x4d\x75\xa6\x05\x9d\x76\xb9\x6a\x6f\xd8\x57\xde\xf5\xe0\xb3\x54\xb2\x7a\xb9\x37\xa5\x81\x5d\x16\xb5\xfa\xe4\x07\xff\x18\x22\x2c\x6d\x1e\xd2\x63\xbe\x68\xc9\x5f\x32\xd9\x08\xbd\x89\x5c\xd7\x62\x07\xae\x72\x64\x87\x56\x7f\x9a\x67\xda\xd7\x9a\xbe\xc3\x16\xf6\x83\xb1\x7f\x2d\x02\xbf\x07\xe0\xac\x8b\x5b\xc6\x16\x2c\xf9\x46\x97\xb3\xc2\x7c\xd1\xfe\xa4\x9b\x27\xf2\x3b\xa2\x90\x18\x71\x96\x25\x06\x52\x0c\x39\x2d\xa8\xb6\xad\x0d\x99\xf7\x01\x3f\xbc\x06\xc2\xc1\x7a\x56\x95\x00\xc8\xa7\x69\x64\x81\xc1\xcd\x33\xe9\xb1\x4e\x40\xb8\x2e\x79\xa5\xf5\xdb\x82\x57\x1b\xa9\x7b\xae\x3a\xd3\xe0\x47\x95\x15\xbb\x0e\x2b\x0f\x3b\xfc\xd1\xfd\x33\x03\x4e\xfc\x62\x45\xed\xdd\x7e\xe2\x08\x6d\xda\xe2\x60\x0d\x8c\xa7\x3e\x21\x4e\x8c\x2b\x0b\xdb\x2b\x04\x7c\x6a\x46\x4a\x56\x2e\xd7\x7b\x73\xd2\xd8\x41\xc4\xb3\x49\x73\x55\x12\x57\x71\x3b\x75\x36\x32\xef\xba\x34\x81\x69\xab\xc9\x0a\x68\xf4\x26\x11\xa4\x01\x26\xd7\xcb\x21\xb5\x86\x95\x56\x81\x86\xf7\xe5\x69\xd2\xff\x0f\x9e\x74\x5d\x04\x87\xdd\x2e\xb9\x97\xca\xfc\x5a\xbf\x9d\xd1\x02\xe6\x2f\xf6\x6c\xba\x87"
+        , vecSig =
+            "\xe3\x01\x34\x5a\x41\xa3\x9a\x4d\x72\xff\xf8\xdf\x69\xc9\x80\x75\xa0\xcc\x08\x2b\x80\x2f\xc9\xb2\xb6\xbc\x50\x3f\x92\x6b\x65\xbd\xdf\x7f\x4c\x8f\x1c\xb4\x9f\x63\x96\xaf\xc8\xa7\x0a\xbe\x6d\x8a\xef\x0d\xb4\x78\xd4\xc6\xb2\x97\x00\x76\xc6\xa0\x48\x4f\xe7\x6d\x76\xb3\xa9\x76\x25\xd7\x9f\x1c\xe2\x40\xe7\xc5\x76\x75\x0d\x29\x55\x28\x28\x6f\x71\x9b\x41\x3d\xe9\xad\xa3\xe8\xeb\x78\xed\x57\x36\x03\xce\x30\xd8\xbb\x76\x17\x85\xdc\x30\xdb\xc3\x20\x86\x9e\x1a\x00"
         }
     ]
 
-
 doPublicKeyTest i vec = testCase (show i) (pub @=? Ed448.toPublic sec)
   where
-        !pub = throwCryptoError $ Ed448.publicKey (vecPub vec)
-        !sec = throwCryptoError $ Ed448.secretKey (vecSec vec)
+    !pub = throwCryptoError $ Ed448.publicKey (vecPub vec)
+    !sec = throwCryptoError $ Ed448.secretKey (vecSec vec)
 
 doSignatureTest i vec = testCase (show i) (sig @=? Ed448.sign sec pub (vecMsg vec))
   where
-        !sig = throwCryptoError $ Ed448.signature (vecSig vec)
-        !pub = throwCryptoError $ Ed448.publicKey (vecPub vec)
-        !sec = throwCryptoError $ Ed448.secretKey (vecSec vec)
+    !sig = throwCryptoError $ Ed448.signature (vecSig vec)
+    !pub = throwCryptoError $ Ed448.publicKey (vecPub vec)
+    !sec = throwCryptoError $ Ed448.secretKey (vecSec vec)
 
 doVerifyTest i vec = testCase (show i) (True @=? Ed448.verify pub (vecMsg vec) sig)
   where
-        !sig = throwCryptoError $ Ed448.signature (vecSig vec)
-        !pub = throwCryptoError $ Ed448.publicKey (vecPub vec)
-
+    !sig = throwCryptoError $ Ed448.signature (vecSig vec)
+    !pub = throwCryptoError $ Ed448.publicKey (vecPub vec)
 
-tests = testGroup "Ed448"
-    [ testCase  "gen secretkey" (Ed448.generateSecretKey *> pure ())
-    , testGroup "gen publickey" $ zipWith doPublicKeyTest [katZero..] vectors
-    , testGroup "gen signature" $ zipWith doSignatureTest [katZero..] vectors
-    , testGroup "verify sig" $ zipWith doVerifyTest [katZero..] vectors
-    ]
+tests =
+    testGroup
+        "Ed448"
+        [ testCase "gen secretkey" (Ed448.generateSecretKey *> pure ())
+        , testGroup "gen publickey" $ zipWith doPublicKeyTest [katZero ..] vectors
+        , testGroup "gen signature" $ zipWith doSignatureTest [katZero ..] vectors
+        , testGroup "verify sig" $ zipWith doVerifyTest [katZero ..] vectors
+        ]
diff --git a/tests/KAT_EdDSA.hs b/tests/KAT_EdDSA.hs
--- a/tests/KAT_EdDSA.hs
+++ b/tests/KAT_EdDSA.hs
@@ -3,20 +3,24 @@
 {-# LANGUAGE GADTs #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE RecordWildCards #-}
-module KAT_EdDSA ( tests ) where
+{-# LANGUAGE TypeOperators #-}
 
-import           Crypto.Error
-import           Crypto.ECC
-import           Crypto.Hash.Algorithms
-import           Crypto.Hash.IO
+module KAT_EdDSA (tests) where
+
+import Crypto.ECC
+import Crypto.Error
+import Crypto.Hash.Algorithms
+import Crypto.Hash.IO
 import qualified Crypto.PubKey.EdDSA as EdDSA
-import           Imports
+import Imports
 
-data Vec = forall curve hash .
-           ( EdDSA.EllipticCurveEdDSA curve
-           , HashAlgorithm hash
-           , HashDigestSize hash ~ EdDSA.CurveDigestSize curve
-           ) => Vec
+data Vec
+    = forall curve hash.
+      ( EdDSA.EllipticCurveEdDSA curve
+      , HashAlgorithm hash
+      , HashDigestSize hash ~ EdDSA.CurveDigestSize curve
+      ) =>
+    Vec
     { vecPrx :: Maybe curve
     , vecAlg :: hash
     , vecSec :: ByteString
@@ -29,78 +33,107 @@
     [ Vec
         { vecPrx = Just Curve_Edwards25519
         , vecAlg = SHA512
-        , vecSec = "\x9d\x61\xb1\x9d\xef\xfd\x5a\x60\xba\x84\x4a\xf4\x92\xec\x2c\xc4\x44\x49\xc5\x69\x7b\x32\x69\x19\x70\x3b\xac\x03\x1c\xae\x7f\x60"
-        , vecPub = "\xd7\x5a\x98\x01\x82\xb1\x0a\xb7\xd5\x4b\xfe\xd3\xc9\x64\x07\x3a\x0e\xe1\x72\xf3\xda\xa6\x23\x25\xaf\x02\x1a\x68\xf7\x07\x51\x1a"
+        , vecSec =
+            "\x9d\x61\xb1\x9d\xef\xfd\x5a\x60\xba\x84\x4a\xf4\x92\xec\x2c\xc4\x44\x49\xc5\x69\x7b\x32\x69\x19\x70\x3b\xac\x03\x1c\xae\x7f\x60"
+        , vecPub =
+            "\xd7\x5a\x98\x01\x82\xb1\x0a\xb7\xd5\x4b\xfe\xd3\xc9\x64\x07\x3a\x0e\xe1\x72\xf3\xda\xa6\x23\x25\xaf\x02\x1a\x68\xf7\x07\x51\x1a"
         , vecMsg = ""
-        , vecSig = "\xe5\x56\x43\x00\xc3\x60\xac\x72\x90\x86\xe2\xcc\x80\x6e\x82\x8a\x84\x87\x7f\x1e\xb8\xe5\xd9\x74\xd8\x73\xe0\x65\x22\x49\x01\x55\x5f\xb8\x82\x15\x90\xa3\x3b\xac\xc6\x1e\x39\x70\x1c\xf9\xb4\x6b\xd2\x5b\xf5\xf0\x59\x5b\xbe\x24\x65\x51\x41\x43\x8e\x7a\x10\x0b"
+        , vecSig =
+            "\xe5\x56\x43\x00\xc3\x60\xac\x72\x90\x86\xe2\xcc\x80\x6e\x82\x8a\x84\x87\x7f\x1e\xb8\xe5\xd9\x74\xd8\x73\xe0\x65\x22\x49\x01\x55\x5f\xb8\x82\x15\x90\xa3\x3b\xac\xc6\x1e\x39\x70\x1c\xf9\xb4\x6b\xd2\x5b\xf5\xf0\x59\x5b\xbe\x24\x65\x51\x41\x43\x8e\x7a\x10\x0b"
         }
     , Vec
         { vecPrx = Just Curve_Edwards25519
         , vecAlg = SHA512
-        , vecSec = "\x4c\xcd\x08\x9b\x28\xff\x96\xda\x9d\xb6\xc3\x46\xec\x11\x4e\x0f\x5b\x8a\x31\x9f\x35\xab\xa6\x24\xda\x8c\xf6\xed\x4f\xb8\xa6\xfb"
-        , vecPub = "\x3d\x40\x17\xc3\xe8\x43\x89\x5a\x92\xb7\x0a\xa7\x4d\x1b\x7e\xbc\x9c\x98\x2c\xcf\x2e\xc4\x96\x8c\xc0\xcd\x55\xf1\x2a\xf4\x66\x0c"
+        , vecSec =
+            "\x4c\xcd\x08\x9b\x28\xff\x96\xda\x9d\xb6\xc3\x46\xec\x11\x4e\x0f\x5b\x8a\x31\x9f\x35\xab\xa6\x24\xda\x8c\xf6\xed\x4f\xb8\xa6\xfb"
+        , vecPub =
+            "\x3d\x40\x17\xc3\xe8\x43\x89\x5a\x92\xb7\x0a\xa7\x4d\x1b\x7e\xbc\x9c\x98\x2c\xcf\x2e\xc4\x96\x8c\xc0\xcd\x55\xf1\x2a\xf4\x66\x0c"
         , vecMsg = "\x72"
-        , vecSig = "\x92\xa0\x09\xa9\xf0\xd4\xca\xb8\x72\x0e\x82\x0b\x5f\x64\x25\x40\xa2\xb2\x7b\x54\x16\x50\x3f\x8f\xb3\x76\x22\x23\xeb\xdb\x69\xda\x08\x5a\xc1\xe4\x3e\x15\x99\x6e\x45\x8f\x36\x13\xd0\xf1\x1d\x8c\x38\x7b\x2e\xae\xb4\x30\x2a\xee\xb0\x0d\x29\x16\x12\xbb\x0c\x00"
+        , vecSig =
+            "\x92\xa0\x09\xa9\xf0\xd4\xca\xb8\x72\x0e\x82\x0b\x5f\x64\x25\x40\xa2\xb2\x7b\x54\x16\x50\x3f\x8f\xb3\x76\x22\x23\xeb\xdb\x69\xda\x08\x5a\xc1\xe4\x3e\x15\x99\x6e\x45\x8f\x36\x13\xd0\xf1\x1d\x8c\x38\x7b\x2e\xae\xb4\x30\x2a\xee\xb0\x0d\x29\x16\x12\xbb\x0c\x00"
         }
     , Vec
         { vecPrx = Just Curve_Edwards25519
         , vecAlg = SHA512
-        , vecSec = "\xc5\xaa\x8d\xf4\x3f\x9f\x83\x7b\xed\xb7\x44\x2f\x31\xdc\xb7\xb1\x66\xd3\x85\x35\x07\x6f\x09\x4b\x85\xce\x3a\x2e\x0b\x44\x58\xf7"
-        , vecPub = "\xfc\x51\xcd\x8e\x62\x18\xa1\xa3\x8d\xa4\x7e\xd0\x02\x30\xf0\x58\x08\x16\xed\x13\xba\x33\x03\xac\x5d\xeb\x91\x15\x48\x90\x80\x25"
+        , vecSec =
+            "\xc5\xaa\x8d\xf4\x3f\x9f\x83\x7b\xed\xb7\x44\x2f\x31\xdc\xb7\xb1\x66\xd3\x85\x35\x07\x6f\x09\x4b\x85\xce\x3a\x2e\x0b\x44\x58\xf7"
+        , vecPub =
+            "\xfc\x51\xcd\x8e\x62\x18\xa1\xa3\x8d\xa4\x7e\xd0\x02\x30\xf0\x58\x08\x16\xed\x13\xba\x33\x03\xac\x5d\xeb\x91\x15\x48\x90\x80\x25"
         , vecMsg = "\xaf\x82"
-        , vecSig = "\x62\x91\xd6\x57\xde\xec\x24\x02\x48\x27\xe6\x9c\x3a\xbe\x01\xa3\x0c\xe5\x48\xa2\x84\x74\x3a\x44\x5e\x36\x80\xd7\xdb\x5a\xc3\xac\x18\xff\x9b\x53\x8d\x16\xf2\x90\xae\x67\xf7\x60\x98\x4d\xc6\x59\x4a\x7c\x15\xe9\x71\x6e\xd2\x8d\xc0\x27\xbe\xce\xea\x1e\xc4\x0a"
+        , vecSig =
+            "\x62\x91\xd6\x57\xde\xec\x24\x02\x48\x27\xe6\x9c\x3a\xbe\x01\xa3\x0c\xe5\x48\xa2\x84\x74\x3a\x44\x5e\x36\x80\xd7\xdb\x5a\xc3\xac\x18\xff\x9b\x53\x8d\x16\xf2\x90\xae\x67\xf7\x60\x98\x4d\xc6\x59\x4a\x7c\x15\xe9\x71\x6e\xd2\x8d\xc0\x27\xbe\xce\xea\x1e\xc4\x0a"
         }
     , Vec
         { vecPrx = Just Curve_Edwards25519
         , vecAlg = SHA512
-        , vecSec = "\xf5\xe5\x76\x7c\xf1\x53\x31\x95\x17\x63\x0f\x22\x68\x76\xb8\x6c\x81\x60\xcc\x58\x3b\xc0\x13\x74\x4c\x6b\xf2\x55\xf5\xcc\x0e\xe5"
-        , vecPub = "\x27\x81\x17\xfc\x14\x4c\x72\x34\x0f\x67\xd0\xf2\x31\x6e\x83\x86\xce\xff\xbf\x2b\x24\x28\xc9\xc5\x1f\xef\x7c\x59\x7f\x1d\x42\x6e"
-        , vecMsg = "\x08\xb8\xb2\xb7\x33\x42\x42\x43\x76\x0f\xe4\x26\xa4\xb5\x49\x08\x63\x21\x10\xa6\x6c\x2f\x65\x91\xea\xbd\x33\x45\xe3\xe4\xeb\x98\xfa\x6e\x26\x4b\xf0\x9e\xfe\x12\xee\x50\xf8\xf5\x4e\x9f\x77\xb1\xe3\x55\xf6\xc5\x05\x44\xe2\x3f\xb1\x43\x3d\xdf\x73\xbe\x84\xd8\x79\xde\x7c\x00\x46\xdc\x49\x96\xd9\xe7\x73\xf4\xbc\x9e\xfe\x57\x38\x82\x9a\xdb\x26\xc8\x1b\x37\xc9\x3a\x1b\x27\x0b\x20\x32\x9d\x65\x86\x75\xfc\x6e\xa5\x34\xe0\x81\x0a\x44\x32\x82\x6b\xf5\x8c\x94\x1e\xfb\x65\xd5\x7a\x33\x8b\xbd\x2e\x26\x64\x0f\x89\xff\xbc\x1a\x85\x8e\xfc\xb8\x55\x0e\xe3\xa5\xe1\x99\x8b\xd1\x77\xe9\x3a\x73\x63\xc3\x44\xfe\x6b\x19\x9e\xe5\xd0\x2e\x82\xd5\x22\xc4\xfe\xba\x15\x45\x2f\x80\x28\x8a\x82\x1a\x57\x91\x16\xec\x6d\xad\x2b\x3b\x31\x0d\xa9\x03\x40\x1a\xa6\x21\x00\xab\x5d\x1a\x36\x55\x3e\x06\x20\x3b\x33\x89\x0c\xc9\xb8\x32\xf7\x9e\xf8\x05\x60\xcc\xb9\xa3\x9c\xe7\x67\x96\x7e\xd6\x28\xc6\xad\x57\x3c\xb1\x16\xdb\xef\xef\xd7\x54\x99\xda\x96\xbd\x68\xa8\xa9\x7b\x92\x8a\x8b\xbc\x10\x3b\x66\x21\xfc\xde\x2b\xec\xa1\x23\x1d\x20\x6b\xe6\xcd\x9e\xc7\xaf\xf6\xf6\xc9\x4f\xcd\x72\x04\xed\x34\x55\xc6\x8c\x83\xf4\xa4\x1d\xa4\xaf\x2b\x74\xef\x5c\x53\xf1\xd8\xac\x70\xbd\xcb\x7e\xd1\x85\xce\x81\xbd\x84\x35\x9d\x44\x25\x4d\x95\x62\x9e\x98\x55\xa9\x4a\x7c\x19\x58\xd1\xf8\xad\xa5\xd0\x53\x2e\xd8\xa5\xaa\x3f\xb2\xd1\x7b\xa7\x0e\xb6\x24\x8e\x59\x4e\x1a\x22\x97\xac\xbb\xb3\x9d\x50\x2f\x1a\x8c\x6e\xb6\xf1\xce\x22\xb3\xde\x1a\x1f\x40\xcc\x24\x55\x41\x19\xa8\x31\xa9\xaa\xd6\x07\x9c\xad\x88\x42\x5d\xe6\xbd\xe1\xa9\x18\x7e\xbb\x60\x92\xcf\x67\xbf\x2b\x13\xfd\x65\xf2\x70\x88\xd7\x8b\x7e\x88\x3c\x87\x59\xd2\xc4\xf5\xc6\x5a\xdb\x75\x53\x87\x8a\xd5\x75\xf9\xfa\xd8\x78\xe8\x0a\x0c\x9b\xa6\x3b\xcb\xcc\x27\x32\xe6\x94\x85\xbb\xc9\xc9\x0b\xfb\xd6\x24\x81\xd9\x08\x9b\xec\xcf\x80\xcf\xe2\xdf\x16\xa2\xcf\x65\xbd\x92\xdd\x59\x7b\x07\x07\xe0\x91\x7a\xf4\x8b\xbb\x75\xfe\xd4\x13\xd2\x38\xf5\x55\x5a\x7a\x56\x9d\x80\xc3\x41\x4a\x8d\x08\x59\xdc\x65\xa4\x61\x28\xba\xb2\x7a\xf8\x7a\x71\x31\x4f\x31\x8c\x78\x2b\x23\xeb\xfe\x80\x8b\x82\xb0\xce\x26\x40\x1d\x2e\x22\xf0\x4d\x83\xd1\x25\x5d\xc5\x1a\xdd\xd3\xb7\x5a\x2b\x1a\xe0\x78\x45\x04\xdf\x54\x3a\xf8\x96\x9b\xe3\xea\x70\x82\xff\x7f\xc9\x88\x8c\x14\x4d\xa2\xaf\x58\x42\x9e\xc9\x60\x31\xdb\xca\xd3\xda\xd9\xaf\x0d\xcb\xaa\xaf\x26\x8c\xb8\xfc\xff\xea\xd9\x4f\x3c\x7c\xa4\x95\xe0\x56\xa9\xb4\x7a\xcd\xb7\x51\xfb\x73\xe6\x66\xc6\xc6\x55\xad\xe8\x29\x72\x97\xd0\x7a\xd1\xba\x5e\x43\xf1\xbc\xa3\x23\x01\x65\x13\x39\xe2\x29\x04\xcc\x8c\x42\xf5\x8c\x30\xc0\x4a\xaf\xdb\x03\x8d\xda\x08\x47\xdd\x98\x8d\xcd\xa6\xf3\xbf\xd1\x5c\x4b\x4c\x45\x25\x00\x4a\xa0\x6e\xef\xf8\xca\x61\x78\x3a\xac\xec\x57\xfb\x3d\x1f\x92\xb0\xfe\x2f\xd1\xa8\x5f\x67\x24\x51\x7b\x65\xe6\x14\xad\x68\x08\xd6\xf6\xee\x34\xdf\xf7\x31\x0f\xdc\x82\xae\xbf\xd9\x04\xb0\x1e\x1d\xc5\x4b\x29\x27\x09\x4b\x2d\xb6\x8d\x6f\x90\x3b\x68\x40\x1a\xde\xbf\x5a\x7e\x08\xd7\x8f\xf4\xef\x5d\x63\x65\x3a\x65\x04\x0c\xf9\xbf\xd4\xac\xa7\x98\x4a\x74\xd3\x71\x45\x98\x67\x80\xfc\x0b\x16\xac\x45\x16\x49\xde\x61\x88\xa7\xdb\xdf\x19\x1f\x64\xb5\xfc\x5e\x2a\xb4\x7b\x57\xf7\xf7\x27\x6c\xd4\x19\xc1\x7a\x3c\xa8\xe1\xb9\x39\xae\x49\xe4\x88\xac\xba\x6b\x96\x56\x10\xb5\x48\x01\x09\xc8\xb1\x7b\x80\xe1\xb7\xb7\x50\xdf\xc7\x59\x8d\x5d\x50\x11\xfd\x2d\xcc\x56\x00\xa3\x2e\xf5\xb5\x2a\x1e\xcc\x82\x0e\x30\x8a\xa3\x42\x72\x1a\xac\x09\x43\xbf\x66\x86\xb6\x4b\x25\x79\x37\x65\x04\xcc\xc4\x93\xd9\x7e\x6a\xed\x3f\xb0\xf9\xcd\x71\xa4\x3d\xd4\x97\xf0\x1f\x17\xc0\xe2\xcb\x37\x97\xaa\x2a\x2f\x25\x66\x56\x16\x8e\x6c\x49\x6a\xfc\x5f\xb9\x32\x46\xf6\xb1\x11\x63\x98\xa3\x46\xf1\xa6\x41\xf3\xb0\x41\xe9\x89\xf7\x91\x4f\x90\xcc\x2c\x7f\xff\x35\x78\x76\xe5\x06\xb5\x0d\x33\x4b\xa7\x7c\x22\x5b\xc3\x07\xba\x53\x71\x52\xf3\xf1\x61\x0e\x4e\xaf\xe5\x95\xf6\xd9\xd9\x0d\x11\xfa\xa9\x33\xa1\x5e\xf1\x36\x95\x46\x86\x8a\x7f\x3a\x45\xa9\x67\x68\xd4\x0f\xd9\xd0\x34\x12\xc0\x91\xc6\x31\x5c\xf4\xfd\xe7\xcb\x68\x60\x69\x37\x38\x0d\xb2\xea\xaa\x70\x7b\x4c\x41\x85\xc3\x2e\xdd\xcd\xd3\x06\x70\x5e\x4d\xc1\xff\xc8\x72\xee\xee\x47\x5a\x64\xdf\xac\x86\xab\xa4\x1c\x06\x18\x98\x3f\x87\x41\xc5\xef\x68\xd3\xa1\x01\xe8\xa3\xb8\xca\xc6\x0c\x90\x5c\x15\xfc\x91\x08\x40\xb9\x4c\x00\xa0\xb9\xd0"
-        , vecSig = "\x0a\xab\x4c\x90\x05\x01\xb3\xe2\x4d\x7c\xdf\x46\x63\x32\x6a\x3a\x87\xdf\x5e\x48\x43\xb2\xcb\xdb\x67\xcb\xf6\xe4\x60\xfe\xc3\x50\xaa\x53\x71\xb1\x50\x8f\x9f\x45\x28\xec\xea\x23\xc4\x36\xd9\x4b\x5e\x8f\xcd\x4f\x68\x1e\x30\xa6\xac\x00\xa9\x70\x4a\x18\x8a\x03"
+        , vecSec =
+            "\xf5\xe5\x76\x7c\xf1\x53\x31\x95\x17\x63\x0f\x22\x68\x76\xb8\x6c\x81\x60\xcc\x58\x3b\xc0\x13\x74\x4c\x6b\xf2\x55\xf5\xcc\x0e\xe5"
+        , vecPub =
+            "\x27\x81\x17\xfc\x14\x4c\x72\x34\x0f\x67\xd0\xf2\x31\x6e\x83\x86\xce\xff\xbf\x2b\x24\x28\xc9\xc5\x1f\xef\x7c\x59\x7f\x1d\x42\x6e"
+        , vecMsg =
+            "\x08\xb8\xb2\xb7\x33\x42\x42\x43\x76\x0f\xe4\x26\xa4\xb5\x49\x08\x63\x21\x10\xa6\x6c\x2f\x65\x91\xea\xbd\x33\x45\xe3\xe4\xeb\x98\xfa\x6e\x26\x4b\xf0\x9e\xfe\x12\xee\x50\xf8\xf5\x4e\x9f\x77\xb1\xe3\x55\xf6\xc5\x05\x44\xe2\x3f\xb1\x43\x3d\xdf\x73\xbe\x84\xd8\x79\xde\x7c\x00\x46\xdc\x49\x96\xd9\xe7\x73\xf4\xbc\x9e\xfe\x57\x38\x82\x9a\xdb\x26\xc8\x1b\x37\xc9\x3a\x1b\x27\x0b\x20\x32\x9d\x65\x86\x75\xfc\x6e\xa5\x34\xe0\x81\x0a\x44\x32\x82\x6b\xf5\x8c\x94\x1e\xfb\x65\xd5\x7a\x33\x8b\xbd\x2e\x26\x64\x0f\x89\xff\xbc\x1a\x85\x8e\xfc\xb8\x55\x0e\xe3\xa5\xe1\x99\x8b\xd1\x77\xe9\x3a\x73\x63\xc3\x44\xfe\x6b\x19\x9e\xe5\xd0\x2e\x82\xd5\x22\xc4\xfe\xba\x15\x45\x2f\x80\x28\x8a\x82\x1a\x57\x91\x16\xec\x6d\xad\x2b\x3b\x31\x0d\xa9\x03\x40\x1a\xa6\x21\x00\xab\x5d\x1a\x36\x55\x3e\x06\x20\x3b\x33\x89\x0c\xc9\xb8\x32\xf7\x9e\xf8\x05\x60\xcc\xb9\xa3\x9c\xe7\x67\x96\x7e\xd6\x28\xc6\xad\x57\x3c\xb1\x16\xdb\xef\xef\xd7\x54\x99\xda\x96\xbd\x68\xa8\xa9\x7b\x92\x8a\x8b\xbc\x10\x3b\x66\x21\xfc\xde\x2b\xec\xa1\x23\x1d\x20\x6b\xe6\xcd\x9e\xc7\xaf\xf6\xf6\xc9\x4f\xcd\x72\x04\xed\x34\x55\xc6\x8c\x83\xf4\xa4\x1d\xa4\xaf\x2b\x74\xef\x5c\x53\xf1\xd8\xac\x70\xbd\xcb\x7e\xd1\x85\xce\x81\xbd\x84\x35\x9d\x44\x25\x4d\x95\x62\x9e\x98\x55\xa9\x4a\x7c\x19\x58\xd1\xf8\xad\xa5\xd0\x53\x2e\xd8\xa5\xaa\x3f\xb2\xd1\x7b\xa7\x0e\xb6\x24\x8e\x59\x4e\x1a\x22\x97\xac\xbb\xb3\x9d\x50\x2f\x1a\x8c\x6e\xb6\xf1\xce\x22\xb3\xde\x1a\x1f\x40\xcc\x24\x55\x41\x19\xa8\x31\xa9\xaa\xd6\x07\x9c\xad\x88\x42\x5d\xe6\xbd\xe1\xa9\x18\x7e\xbb\x60\x92\xcf\x67\xbf\x2b\x13\xfd\x65\xf2\x70\x88\xd7\x8b\x7e\x88\x3c\x87\x59\xd2\xc4\xf5\xc6\x5a\xdb\x75\x53\x87\x8a\xd5\x75\xf9\xfa\xd8\x78\xe8\x0a\x0c\x9b\xa6\x3b\xcb\xcc\x27\x32\xe6\x94\x85\xbb\xc9\xc9\x0b\xfb\xd6\x24\x81\xd9\x08\x9b\xec\xcf\x80\xcf\xe2\xdf\x16\xa2\xcf\x65\xbd\x92\xdd\x59\x7b\x07\x07\xe0\x91\x7a\xf4\x8b\xbb\x75\xfe\xd4\x13\xd2\x38\xf5\x55\x5a\x7a\x56\x9d\x80\xc3\x41\x4a\x8d\x08\x59\xdc\x65\xa4\x61\x28\xba\xb2\x7a\xf8\x7a\x71\x31\x4f\x31\x8c\x78\x2b\x23\xeb\xfe\x80\x8b\x82\xb0\xce\x26\x40\x1d\x2e\x22\xf0\x4d\x83\xd1\x25\x5d\xc5\x1a\xdd\xd3\xb7\x5a\x2b\x1a\xe0\x78\x45\x04\xdf\x54\x3a\xf8\x96\x9b\xe3\xea\x70\x82\xff\x7f\xc9\x88\x8c\x14\x4d\xa2\xaf\x58\x42\x9e\xc9\x60\x31\xdb\xca\xd3\xda\xd9\xaf\x0d\xcb\xaa\xaf\x26\x8c\xb8\xfc\xff\xea\xd9\x4f\x3c\x7c\xa4\x95\xe0\x56\xa9\xb4\x7a\xcd\xb7\x51\xfb\x73\xe6\x66\xc6\xc6\x55\xad\xe8\x29\x72\x97\xd0\x7a\xd1\xba\x5e\x43\xf1\xbc\xa3\x23\x01\x65\x13\x39\xe2\x29\x04\xcc\x8c\x42\xf5\x8c\x30\xc0\x4a\xaf\xdb\x03\x8d\xda\x08\x47\xdd\x98\x8d\xcd\xa6\xf3\xbf\xd1\x5c\x4b\x4c\x45\x25\x00\x4a\xa0\x6e\xef\xf8\xca\x61\x78\x3a\xac\xec\x57\xfb\x3d\x1f\x92\xb0\xfe\x2f\xd1\xa8\x5f\x67\x24\x51\x7b\x65\xe6\x14\xad\x68\x08\xd6\xf6\xee\x34\xdf\xf7\x31\x0f\xdc\x82\xae\xbf\xd9\x04\xb0\x1e\x1d\xc5\x4b\x29\x27\x09\x4b\x2d\xb6\x8d\x6f\x90\x3b\x68\x40\x1a\xde\xbf\x5a\x7e\x08\xd7\x8f\xf4\xef\x5d\x63\x65\x3a\x65\x04\x0c\xf9\xbf\xd4\xac\xa7\x98\x4a\x74\xd3\x71\x45\x98\x67\x80\xfc\x0b\x16\xac\x45\x16\x49\xde\x61\x88\xa7\xdb\xdf\x19\x1f\x64\xb5\xfc\x5e\x2a\xb4\x7b\x57\xf7\xf7\x27\x6c\xd4\x19\xc1\x7a\x3c\xa8\xe1\xb9\x39\xae\x49\xe4\x88\xac\xba\x6b\x96\x56\x10\xb5\x48\x01\x09\xc8\xb1\x7b\x80\xe1\xb7\xb7\x50\xdf\xc7\x59\x8d\x5d\x50\x11\xfd\x2d\xcc\x56\x00\xa3\x2e\xf5\xb5\x2a\x1e\xcc\x82\x0e\x30\x8a\xa3\x42\x72\x1a\xac\x09\x43\xbf\x66\x86\xb6\x4b\x25\x79\x37\x65\x04\xcc\xc4\x93\xd9\x7e\x6a\xed\x3f\xb0\xf9\xcd\x71\xa4\x3d\xd4\x97\xf0\x1f\x17\xc0\xe2\xcb\x37\x97\xaa\x2a\x2f\x25\x66\x56\x16\x8e\x6c\x49\x6a\xfc\x5f\xb9\x32\x46\xf6\xb1\x11\x63\x98\xa3\x46\xf1\xa6\x41\xf3\xb0\x41\xe9\x89\xf7\x91\x4f\x90\xcc\x2c\x7f\xff\x35\x78\x76\xe5\x06\xb5\x0d\x33\x4b\xa7\x7c\x22\x5b\xc3\x07\xba\x53\x71\x52\xf3\xf1\x61\x0e\x4e\xaf\xe5\x95\xf6\xd9\xd9\x0d\x11\xfa\xa9\x33\xa1\x5e\xf1\x36\x95\x46\x86\x8a\x7f\x3a\x45\xa9\x67\x68\xd4\x0f\xd9\xd0\x34\x12\xc0\x91\xc6\x31\x5c\xf4\xfd\xe7\xcb\x68\x60\x69\x37\x38\x0d\xb2\xea\xaa\x70\x7b\x4c\x41\x85\xc3\x2e\xdd\xcd\xd3\x06\x70\x5e\x4d\xc1\xff\xc8\x72\xee\xee\x47\x5a\x64\xdf\xac\x86\xab\xa4\x1c\x06\x18\x98\x3f\x87\x41\xc5\xef\x68\xd3\xa1\x01\xe8\xa3\xb8\xca\xc6\x0c\x90\x5c\x15\xfc\x91\x08\x40\xb9\x4c\x00\xa0\xb9\xd0"
+        , vecSig =
+            "\x0a\xab\x4c\x90\x05\x01\xb3\xe2\x4d\x7c\xdf\x46\x63\x32\x6a\x3a\x87\xdf\x5e\x48\x43\xb2\xcb\xdb\x67\xcb\xf6\xe4\x60\xfe\xc3\x50\xaa\x53\x71\xb1\x50\x8f\x9f\x45\x28\xec\xea\x23\xc4\x36\xd9\x4b\x5e\x8f\xcd\x4f\x68\x1e\x30\xa6\xac\x00\xa9\x70\x4a\x18\x8a\x03"
         }
     , Vec
         { vecPrx = Just Curve_Edwards25519
         , vecAlg = SHA512
-        , vecSec = "\x83\x3f\xe6\x24\x09\x23\x7b\x9d\x62\xec\x77\x58\x75\x20\x91\x1e\x9a\x75\x9c\xec\x1d\x19\x75\x5b\x7d\xa9\x01\xb9\x6d\xca\x3d\x42"
-        , vecPub = "\xec\x17\x2b\x93\xad\x5e\x56\x3b\xf4\x93\x2c\x70\xe1\x24\x50\x34\xc3\x54\x67\xef\x2e\xfd\x4d\x64\xeb\xf8\x19\x68\x34\x67\xe2\xbf"
-        , vecMsg = "\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41\x31\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a\x21\x92\x99\x2a\x27\x4f\xc1\xa8\x36\xba\x3c\x23\xa3\xfe\xeb\xbd\x45\x4d\x44\x23\x64\x3c\xe8\x0e\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f"
-        , vecSig = "\xdc\x2a\x44\x59\xe7\x36\x96\x33\xa5\x2b\x1b\xf2\x77\x83\x9a\x00\x20\x10\x09\xa3\xef\xbf\x3e\xcb\x69\xbe\xa2\x18\x6c\x26\xb5\x89\x09\x35\x1f\xc9\xac\x90\xb3\xec\xfd\xfb\xc7\xc6\x64\x31\xe0\x30\x3d\xca\x17\x9c\x13\x8a\xc1\x7a\xd9\xbe\xf1\x17\x73\x31\xa7\x04"
+        , vecSec =
+            "\x83\x3f\xe6\x24\x09\x23\x7b\x9d\x62\xec\x77\x58\x75\x20\x91\x1e\x9a\x75\x9c\xec\x1d\x19\x75\x5b\x7d\xa9\x01\xb9\x6d\xca\x3d\x42"
+        , vecPub =
+            "\xec\x17\x2b\x93\xad\x5e\x56\x3b\xf4\x93\x2c\x70\xe1\x24\x50\x34\xc3\x54\x67\xef\x2e\xfd\x4d\x64\xeb\xf8\x19\x68\x34\x67\xe2\xbf"
+        , vecMsg =
+            "\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41\x31\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a\x21\x92\x99\x2a\x27\x4f\xc1\xa8\x36\xba\x3c\x23\xa3\xfe\xeb\xbd\x45\x4d\x44\x23\x64\x3c\xe8\x0e\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f"
+        , vecSig =
+            "\xdc\x2a\x44\x59\xe7\x36\x96\x33\xa5\x2b\x1b\xf2\x77\x83\x9a\x00\x20\x10\x09\xa3\xef\xbf\x3e\xcb\x69\xbe\xa2\x18\x6c\x26\xb5\x89\x09\x35\x1f\xc9\xac\x90\xb3\xec\xfd\xfb\xc7\xc6\x64\x31\xe0\x30\x3d\xca\x17\x9c\x13\x8a\xc1\x7a\xd9\xbe\xf1\x17\x73\x31\xa7\x04"
         }
     , Vec
         { vecPrx = Just Curve_Edwards25519
         , vecAlg = Blake2b_512
-        , vecSec = "\x9d\x61\xb1\x9d\xef\xfd\x5a\x60\xba\x84\x4a\xf4\x92\xec\x2c\xc4\x44\x49\xc5\x69\x7b\x32\x69\x19\x70\x3b\xac\x03\x1c\xae\x7f\x60"
-        , vecPub = "\x78\xe6\x5b\xf3\x0f\x89\x3d\x32\xfc\x57\xef\x05\x1c\x34\x1b\xde\xde\x24\x25\x44\xfc\x2a\x21\x12\xf0\xfa\x2c\x7a\xfd\xeb\xc0\x2f"
+        , vecSec =
+            "\x9d\x61\xb1\x9d\xef\xfd\x5a\x60\xba\x84\x4a\xf4\x92\xec\x2c\xc4\x44\x49\xc5\x69\x7b\x32\x69\x19\x70\x3b\xac\x03\x1c\xae\x7f\x60"
+        , vecPub =
+            "\x78\xe6\x5b\xf3\x0f\x89\x3d\x32\xfc\x57\xef\x05\x1c\x34\x1b\xde\xde\x24\x25\x44\xfc\x2a\x21\x12\xf0\xfa\x2c\x7a\xfd\xeb\xc0\x2f"
         , vecMsg = ""
-        , vecSig = "\x99\xa5\x23\xbd\x46\x16\xc8\x16\x11\x44\xd6\xa9\x9d\x3c\x32\x40\x0c\xb4\xa3\x26\xf4\xd7\x9e\x30\x73\x40\xf6\xaf\xa1\x17\x50\xa0\x08\x5d\x7d\x84\x62\x6b\xc9\xe4\xb1\x53\xfc\x0e\x39\x6d\x15\xce\x44\xc3\x9b\xae\x45\x33\x80\x4d\xb1\xfe\x5b\x52\xf2\xb1\xb8\x05"
+        , vecSig =
+            "\x99\xa5\x23\xbd\x46\x16\xc8\x16\x11\x44\xd6\xa9\x9d\x3c\x32\x40\x0c\xb4\xa3\x26\xf4\xd7\x9e\x30\x73\x40\xf6\xaf\xa1\x17\x50\xa0\x08\x5d\x7d\x84\x62\x6b\xc9\xe4\xb1\x53\xfc\x0e\x39\x6d\x15\xce\x44\xc3\x9b\xae\x45\x33\x80\x4d\xb1\xfe\x5b\x52\xf2\xb1\xb8\x05"
         }
     , Vec
         { vecPrx = Just Curve_Edwards25519
         , vecAlg = Blake2b_512
-        , vecSec = "\x4c\xcd\x08\x9b\x28\xff\x96\xda\x9d\xb6\xc3\x46\xec\x11\x4e\x0f\x5b\x8a\x31\x9f\x35\xab\xa6\x24\xda\x8c\xf6\xed\x4f\xb8\xa6\xfb"
-        , vecPub = "\x5e\x71\x39\x2d\x91\xe6\xa5\x8f\xed\xeb\x08\x50\x36\x4f\x56\xcd\x15\x8a\x60\x44\x75\x57\xd7\x89\x03\x89\xc9\xb3\xd4\x57\x6d\x4d"
+        , vecSec =
+            "\x4c\xcd\x08\x9b\x28\xff\x96\xda\x9d\xb6\xc3\x46\xec\x11\x4e\x0f\x5b\x8a\x31\x9f\x35\xab\xa6\x24\xda\x8c\xf6\xed\x4f\xb8\xa6\xfb"
+        , vecPub =
+            "\x5e\x71\x39\x2d\x91\xe6\xa5\x8f\xed\xeb\x08\x50\x36\x4f\x56\xcd\x15\x8a\x60\x44\x75\x57\xd7\x89\x03\x89\xc9\xb3\xd4\x57\x6d\x4d"
         , vecMsg = "\x72"
-        , vecSig = "\x6d\xa7\x5e\x15\xb5\x70\x7f\x4d\xe5\xa1\x53\xc4\x8a\x5d\x83\x9f\xb8\x50\x74\xc3\x8a\xeb\x62\x85\x97\x7f\x03\xa1\x39\x77\x59\x7f\x97\x60\x69\xfd\xb9\x03\xf1\x83\x47\x4a\xaa\x5e\xd0\xcf\xe8\x78\xba\x8e\xf8\x68\xc5\xe4\x7c\xa3\xf9\x6c\xcf\xb3\xa8\x9b\x2a\x06"
+        , vecSig =
+            "\x6d\xa7\x5e\x15\xb5\x70\x7f\x4d\xe5\xa1\x53\xc4\x8a\x5d\x83\x9f\xb8\x50\x74\xc3\x8a\xeb\x62\x85\x97\x7f\x03\xa1\x39\x77\x59\x7f\x97\x60\x69\xfd\xb9\x03\xf1\x83\x47\x4a\xaa\x5e\xd0\xcf\xe8\x78\xba\x8e\xf8\x68\xc5\xe4\x7c\xa3\xf9\x6c\xcf\xb3\xa8\x9b\x2a\x06"
         }
     , Vec
         { vecPrx = Just Curve_Edwards25519
         , vecAlg = Blake2b_512
-        , vecSec = "\xc5\xaa\x8d\xf4\x3f\x9f\x83\x7b\xed\xb7\x44\x2f\x31\xdc\xb7\xb1\x66\xd3\x85\x35\x07\x6f\x09\x4b\x85\xce\x3a\x2e\x0b\x44\x58\xf7"
-        , vecPub = "\x8d\x53\xca\x70\xf0\xea\xb2\x3b\x91\x78\x34\x57\x85\xfc\xdb\x69\xed\x67\x23\xf8\x14\x8f\x7e\x33\x9e\x88\x65\x37\x00\xb7\x18\xda"
+        , vecSec =
+            "\xc5\xaa\x8d\xf4\x3f\x9f\x83\x7b\xed\xb7\x44\x2f\x31\xdc\xb7\xb1\x66\xd3\x85\x35\x07\x6f\x09\x4b\x85\xce\x3a\x2e\x0b\x44\x58\xf7"
+        , vecPub =
+            "\x8d\x53\xca\x70\xf0\xea\xb2\x3b\x91\x78\x34\x57\x85\xfc\xdb\x69\xed\x67\x23\xf8\x14\x8f\x7e\x33\x9e\x88\x65\x37\x00\xb7\x18\xda"
         , vecMsg = "\xaf\x82"
-        , vecSig = "\x7c\xc3\xc1\x38\x52\xbd\x12\xab\xf3\xce\x4c\xa8\xca\x28\x36\xcb\xf8\x6d\xa9\x6c\x46\x34\xc5\x0d\xf3\xfb\x80\xdc\x80\x9e\x29\xdb\x0e\x10\x9c\x36\x13\x53\x40\x7c\x12\x36\xa9\x04\xf6\x36\x86\x8a\xa3\x39\x77\xa9\x9d\x3f\x84\x45\x98\xdb\x15\x38\xb4\x29\x52\x03"
+        , vecSig =
+            "\x7c\xc3\xc1\x38\x52\xbd\x12\xab\xf3\xce\x4c\xa8\xca\x28\x36\xcb\xf8\x6d\xa9\x6c\x46\x34\xc5\x0d\xf3\xfb\x80\xdc\x80\x9e\x29\xdb\x0e\x10\x9c\x36\x13\x53\x40\x7c\x12\x36\xa9\x04\xf6\x36\x86\x8a\xa3\x39\x77\xa9\x9d\x3f\x84\x45\x98\xdb\x15\x38\xb4\x29\x52\x03"
         }
     , Vec
         { vecPrx = Just Curve_Edwards25519
         , vecAlg = Blake2b_512
-        , vecSec = "\xf5\xe5\x76\x7c\xf1\x53\x31\x95\x17\x63\x0f\x22\x68\x76\xb8\x6c\x81\x60\xcc\x58\x3b\xc0\x13\x74\x4c\x6b\xf2\x55\xf5\xcc\x0e\xe5"
-        , vecPub = "\x9e\x3c\xa4\x9b\xb2\xd9\xe3\x6b\x8f\x0c\x94\x4a\x7b\x1c\x29\x26\x45\xda\x87\xce\x6f\xa6\xb4\x28\x86\xe5\xd7\xc8\x68\x33\xa7\x14"
-        , vecMsg = "\x08\xb8\xb2\xb7\x33\x42\x42\x43\x76\x0f\xe4\x26\xa4\xb5\x49\x08\x63\x21\x10\xa6\x6c\x2f\x65\x91\xea\xbd\x33\x45\xe3\xe4\xeb\x98\xfa\x6e\x26\x4b\xf0\x9e\xfe\x12\xee\x50\xf8\xf5\x4e\x9f\x77\xb1\xe3\x55\xf6\xc5\x05\x44\xe2\x3f\xb1\x43\x3d\xdf\x73\xbe\x84\xd8\x79\xde\x7c\x00\x46\xdc\x49\x96\xd9\xe7\x73\xf4\xbc\x9e\xfe\x57\x38\x82\x9a\xdb\x26\xc8\x1b\x37\xc9\x3a\x1b\x27\x0b\x20\x32\x9d\x65\x86\x75\xfc\x6e\xa5\x34\xe0\x81\x0a\x44\x32\x82\x6b\xf5\x8c\x94\x1e\xfb\x65\xd5\x7a\x33\x8b\xbd\x2e\x26\x64\x0f\x89\xff\xbc\x1a\x85\x8e\xfc\xb8\x55\x0e\xe3\xa5\xe1\x99\x8b\xd1\x77\xe9\x3a\x73\x63\xc3\x44\xfe\x6b\x19\x9e\xe5\xd0\x2e\x82\xd5\x22\xc4\xfe\xba\x15\x45\x2f\x80\x28\x8a\x82\x1a\x57\x91\x16\xec\x6d\xad\x2b\x3b\x31\x0d\xa9\x03\x40\x1a\xa6\x21\x00\xab\x5d\x1a\x36\x55\x3e\x06\x20\x3b\x33\x89\x0c\xc9\xb8\x32\xf7\x9e\xf8\x05\x60\xcc\xb9\xa3\x9c\xe7\x67\x96\x7e\xd6\x28\xc6\xad\x57\x3c\xb1\x16\xdb\xef\xef\xd7\x54\x99\xda\x96\xbd\x68\xa8\xa9\x7b\x92\x8a\x8b\xbc\x10\x3b\x66\x21\xfc\xde\x2b\xec\xa1\x23\x1d\x20\x6b\xe6\xcd\x9e\xc7\xaf\xf6\xf6\xc9\x4f\xcd\x72\x04\xed\x34\x55\xc6\x8c\x83\xf4\xa4\x1d\xa4\xaf\x2b\x74\xef\x5c\x53\xf1\xd8\xac\x70\xbd\xcb\x7e\xd1\x85\xce\x81\xbd\x84\x35\x9d\x44\x25\x4d\x95\x62\x9e\x98\x55\xa9\x4a\x7c\x19\x58\xd1\xf8\xad\xa5\xd0\x53\x2e\xd8\xa5\xaa\x3f\xb2\xd1\x7b\xa7\x0e\xb6\x24\x8e\x59\x4e\x1a\x22\x97\xac\xbb\xb3\x9d\x50\x2f\x1a\x8c\x6e\xb6\xf1\xce\x22\xb3\xde\x1a\x1f\x40\xcc\x24\x55\x41\x19\xa8\x31\xa9\xaa\xd6\x07\x9c\xad\x88\x42\x5d\xe6\xbd\xe1\xa9\x18\x7e\xbb\x60\x92\xcf\x67\xbf\x2b\x13\xfd\x65\xf2\x70\x88\xd7\x8b\x7e\x88\x3c\x87\x59\xd2\xc4\xf5\xc6\x5a\xdb\x75\x53\x87\x8a\xd5\x75\xf9\xfa\xd8\x78\xe8\x0a\x0c\x9b\xa6\x3b\xcb\xcc\x27\x32\xe6\x94\x85\xbb\xc9\xc9\x0b\xfb\xd6\x24\x81\xd9\x08\x9b\xec\xcf\x80\xcf\xe2\xdf\x16\xa2\xcf\x65\xbd\x92\xdd\x59\x7b\x07\x07\xe0\x91\x7a\xf4\x8b\xbb\x75\xfe\xd4\x13\xd2\x38\xf5\x55\x5a\x7a\x56\x9d\x80\xc3\x41\x4a\x8d\x08\x59\xdc\x65\xa4\x61\x28\xba\xb2\x7a\xf8\x7a\x71\x31\x4f\x31\x8c\x78\x2b\x23\xeb\xfe\x80\x8b\x82\xb0\xce\x26\x40\x1d\x2e\x22\xf0\x4d\x83\xd1\x25\x5d\xc5\x1a\xdd\xd3\xb7\x5a\x2b\x1a\xe0\x78\x45\x04\xdf\x54\x3a\xf8\x96\x9b\xe3\xea\x70\x82\xff\x7f\xc9\x88\x8c\x14\x4d\xa2\xaf\x58\x42\x9e\xc9\x60\x31\xdb\xca\xd3\xda\xd9\xaf\x0d\xcb\xaa\xaf\x26\x8c\xb8\xfc\xff\xea\xd9\x4f\x3c\x7c\xa4\x95\xe0\x56\xa9\xb4\x7a\xcd\xb7\x51\xfb\x73\xe6\x66\xc6\xc6\x55\xad\xe8\x29\x72\x97\xd0\x7a\xd1\xba\x5e\x43\xf1\xbc\xa3\x23\x01\x65\x13\x39\xe2\x29\x04\xcc\x8c\x42\xf5\x8c\x30\xc0\x4a\xaf\xdb\x03\x8d\xda\x08\x47\xdd\x98\x8d\xcd\xa6\xf3\xbf\xd1\x5c\x4b\x4c\x45\x25\x00\x4a\xa0\x6e\xef\xf8\xca\x61\x78\x3a\xac\xec\x57\xfb\x3d\x1f\x92\xb0\xfe\x2f\xd1\xa8\x5f\x67\x24\x51\x7b\x65\xe6\x14\xad\x68\x08\xd6\xf6\xee\x34\xdf\xf7\x31\x0f\xdc\x82\xae\xbf\xd9\x04\xb0\x1e\x1d\xc5\x4b\x29\x27\x09\x4b\x2d\xb6\x8d\x6f\x90\x3b\x68\x40\x1a\xde\xbf\x5a\x7e\x08\xd7\x8f\xf4\xef\x5d\x63\x65\x3a\x65\x04\x0c\xf9\xbf\xd4\xac\xa7\x98\x4a\x74\xd3\x71\x45\x98\x67\x80\xfc\x0b\x16\xac\x45\x16\x49\xde\x61\x88\xa7\xdb\xdf\x19\x1f\x64\xb5\xfc\x5e\x2a\xb4\x7b\x57\xf7\xf7\x27\x6c\xd4\x19\xc1\x7a\x3c\xa8\xe1\xb9\x39\xae\x49\xe4\x88\xac\xba\x6b\x96\x56\x10\xb5\x48\x01\x09\xc8\xb1\x7b\x80\xe1\xb7\xb7\x50\xdf\xc7\x59\x8d\x5d\x50\x11\xfd\x2d\xcc\x56\x00\xa3\x2e\xf5\xb5\x2a\x1e\xcc\x82\x0e\x30\x8a\xa3\x42\x72\x1a\xac\x09\x43\xbf\x66\x86\xb6\x4b\x25\x79\x37\x65\x04\xcc\xc4\x93\xd9\x7e\x6a\xed\x3f\xb0\xf9\xcd\x71\xa4\x3d\xd4\x97\xf0\x1f\x17\xc0\xe2\xcb\x37\x97\xaa\x2a\x2f\x25\x66\x56\x16\x8e\x6c\x49\x6a\xfc\x5f\xb9\x32\x46\xf6\xb1\x11\x63\x98\xa3\x46\xf1\xa6\x41\xf3\xb0\x41\xe9\x89\xf7\x91\x4f\x90\xcc\x2c\x7f\xff\x35\x78\x76\xe5\x06\xb5\x0d\x33\x4b\xa7\x7c\x22\x5b\xc3\x07\xba\x53\x71\x52\xf3\xf1\x61\x0e\x4e\xaf\xe5\x95\xf6\xd9\xd9\x0d\x11\xfa\xa9\x33\xa1\x5e\xf1\x36\x95\x46\x86\x8a\x7f\x3a\x45\xa9\x67\x68\xd4\x0f\xd9\xd0\x34\x12\xc0\x91\xc6\x31\x5c\xf4\xfd\xe7\xcb\x68\x60\x69\x37\x38\x0d\xb2\xea\xaa\x70\x7b\x4c\x41\x85\xc3\x2e\xdd\xcd\xd3\x06\x70\x5e\x4d\xc1\xff\xc8\x72\xee\xee\x47\x5a\x64\xdf\xac\x86\xab\xa4\x1c\x06\x18\x98\x3f\x87\x41\xc5\xef\x68\xd3\xa1\x01\xe8\xa3\xb8\xca\xc6\x0c\x90\x5c\x15\xfc\x91\x08\x40\xb9\x4c\x00\xa0\xb9\xd0"
-        , vecSig = "\xd0\x39\x65\xac\x31\x6a\x20\xf5\xa4\x7a\xb2\xd6\x18\x5e\xb3\xf0\xae\xea\x9c\x2e\xb8\xab\xe9\x22\xe9\x6d\x31\x7b\x3b\xd0\xef\x02\xe8\xd4\x7f\xd9\x23\x84\xe2\x86\x15\xeb\x33\x14\xad\xbc\x71\xc4\x67\x59\x96\x09\x9e\x48\x4c\xeb\x16\x28\x47\xc4\x0c\x32\x44\x0e"
+        , vecSec =
+            "\xf5\xe5\x76\x7c\xf1\x53\x31\x95\x17\x63\x0f\x22\x68\x76\xb8\x6c\x81\x60\xcc\x58\x3b\xc0\x13\x74\x4c\x6b\xf2\x55\xf5\xcc\x0e\xe5"
+        , vecPub =
+            "\x9e\x3c\xa4\x9b\xb2\xd9\xe3\x6b\x8f\x0c\x94\x4a\x7b\x1c\x29\x26\x45\xda\x87\xce\x6f\xa6\xb4\x28\x86\xe5\xd7\xc8\x68\x33\xa7\x14"
+        , vecMsg =
+            "\x08\xb8\xb2\xb7\x33\x42\x42\x43\x76\x0f\xe4\x26\xa4\xb5\x49\x08\x63\x21\x10\xa6\x6c\x2f\x65\x91\xea\xbd\x33\x45\xe3\xe4\xeb\x98\xfa\x6e\x26\x4b\xf0\x9e\xfe\x12\xee\x50\xf8\xf5\x4e\x9f\x77\xb1\xe3\x55\xf6\xc5\x05\x44\xe2\x3f\xb1\x43\x3d\xdf\x73\xbe\x84\xd8\x79\xde\x7c\x00\x46\xdc\x49\x96\xd9\xe7\x73\xf4\xbc\x9e\xfe\x57\x38\x82\x9a\xdb\x26\xc8\x1b\x37\xc9\x3a\x1b\x27\x0b\x20\x32\x9d\x65\x86\x75\xfc\x6e\xa5\x34\xe0\x81\x0a\x44\x32\x82\x6b\xf5\x8c\x94\x1e\xfb\x65\xd5\x7a\x33\x8b\xbd\x2e\x26\x64\x0f\x89\xff\xbc\x1a\x85\x8e\xfc\xb8\x55\x0e\xe3\xa5\xe1\x99\x8b\xd1\x77\xe9\x3a\x73\x63\xc3\x44\xfe\x6b\x19\x9e\xe5\xd0\x2e\x82\xd5\x22\xc4\xfe\xba\x15\x45\x2f\x80\x28\x8a\x82\x1a\x57\x91\x16\xec\x6d\xad\x2b\x3b\x31\x0d\xa9\x03\x40\x1a\xa6\x21\x00\xab\x5d\x1a\x36\x55\x3e\x06\x20\x3b\x33\x89\x0c\xc9\xb8\x32\xf7\x9e\xf8\x05\x60\xcc\xb9\xa3\x9c\xe7\x67\x96\x7e\xd6\x28\xc6\xad\x57\x3c\xb1\x16\xdb\xef\xef\xd7\x54\x99\xda\x96\xbd\x68\xa8\xa9\x7b\x92\x8a\x8b\xbc\x10\x3b\x66\x21\xfc\xde\x2b\xec\xa1\x23\x1d\x20\x6b\xe6\xcd\x9e\xc7\xaf\xf6\xf6\xc9\x4f\xcd\x72\x04\xed\x34\x55\xc6\x8c\x83\xf4\xa4\x1d\xa4\xaf\x2b\x74\xef\x5c\x53\xf1\xd8\xac\x70\xbd\xcb\x7e\xd1\x85\xce\x81\xbd\x84\x35\x9d\x44\x25\x4d\x95\x62\x9e\x98\x55\xa9\x4a\x7c\x19\x58\xd1\xf8\xad\xa5\xd0\x53\x2e\xd8\xa5\xaa\x3f\xb2\xd1\x7b\xa7\x0e\xb6\x24\x8e\x59\x4e\x1a\x22\x97\xac\xbb\xb3\x9d\x50\x2f\x1a\x8c\x6e\xb6\xf1\xce\x22\xb3\xde\x1a\x1f\x40\xcc\x24\x55\x41\x19\xa8\x31\xa9\xaa\xd6\x07\x9c\xad\x88\x42\x5d\xe6\xbd\xe1\xa9\x18\x7e\xbb\x60\x92\xcf\x67\xbf\x2b\x13\xfd\x65\xf2\x70\x88\xd7\x8b\x7e\x88\x3c\x87\x59\xd2\xc4\xf5\xc6\x5a\xdb\x75\x53\x87\x8a\xd5\x75\xf9\xfa\xd8\x78\xe8\x0a\x0c\x9b\xa6\x3b\xcb\xcc\x27\x32\xe6\x94\x85\xbb\xc9\xc9\x0b\xfb\xd6\x24\x81\xd9\x08\x9b\xec\xcf\x80\xcf\xe2\xdf\x16\xa2\xcf\x65\xbd\x92\xdd\x59\x7b\x07\x07\xe0\x91\x7a\xf4\x8b\xbb\x75\xfe\xd4\x13\xd2\x38\xf5\x55\x5a\x7a\x56\x9d\x80\xc3\x41\x4a\x8d\x08\x59\xdc\x65\xa4\x61\x28\xba\xb2\x7a\xf8\x7a\x71\x31\x4f\x31\x8c\x78\x2b\x23\xeb\xfe\x80\x8b\x82\xb0\xce\x26\x40\x1d\x2e\x22\xf0\x4d\x83\xd1\x25\x5d\xc5\x1a\xdd\xd3\xb7\x5a\x2b\x1a\xe0\x78\x45\x04\xdf\x54\x3a\xf8\x96\x9b\xe3\xea\x70\x82\xff\x7f\xc9\x88\x8c\x14\x4d\xa2\xaf\x58\x42\x9e\xc9\x60\x31\xdb\xca\xd3\xda\xd9\xaf\x0d\xcb\xaa\xaf\x26\x8c\xb8\xfc\xff\xea\xd9\x4f\x3c\x7c\xa4\x95\xe0\x56\xa9\xb4\x7a\xcd\xb7\x51\xfb\x73\xe6\x66\xc6\xc6\x55\xad\xe8\x29\x72\x97\xd0\x7a\xd1\xba\x5e\x43\xf1\xbc\xa3\x23\x01\x65\x13\x39\xe2\x29\x04\xcc\x8c\x42\xf5\x8c\x30\xc0\x4a\xaf\xdb\x03\x8d\xda\x08\x47\xdd\x98\x8d\xcd\xa6\xf3\xbf\xd1\x5c\x4b\x4c\x45\x25\x00\x4a\xa0\x6e\xef\xf8\xca\x61\x78\x3a\xac\xec\x57\xfb\x3d\x1f\x92\xb0\xfe\x2f\xd1\xa8\x5f\x67\x24\x51\x7b\x65\xe6\x14\xad\x68\x08\xd6\xf6\xee\x34\xdf\xf7\x31\x0f\xdc\x82\xae\xbf\xd9\x04\xb0\x1e\x1d\xc5\x4b\x29\x27\x09\x4b\x2d\xb6\x8d\x6f\x90\x3b\x68\x40\x1a\xde\xbf\x5a\x7e\x08\xd7\x8f\xf4\xef\x5d\x63\x65\x3a\x65\x04\x0c\xf9\xbf\xd4\xac\xa7\x98\x4a\x74\xd3\x71\x45\x98\x67\x80\xfc\x0b\x16\xac\x45\x16\x49\xde\x61\x88\xa7\xdb\xdf\x19\x1f\x64\xb5\xfc\x5e\x2a\xb4\x7b\x57\xf7\xf7\x27\x6c\xd4\x19\xc1\x7a\x3c\xa8\xe1\xb9\x39\xae\x49\xe4\x88\xac\xba\x6b\x96\x56\x10\xb5\x48\x01\x09\xc8\xb1\x7b\x80\xe1\xb7\xb7\x50\xdf\xc7\x59\x8d\x5d\x50\x11\xfd\x2d\xcc\x56\x00\xa3\x2e\xf5\xb5\x2a\x1e\xcc\x82\x0e\x30\x8a\xa3\x42\x72\x1a\xac\x09\x43\xbf\x66\x86\xb6\x4b\x25\x79\x37\x65\x04\xcc\xc4\x93\xd9\x7e\x6a\xed\x3f\xb0\xf9\xcd\x71\xa4\x3d\xd4\x97\xf0\x1f\x17\xc0\xe2\xcb\x37\x97\xaa\x2a\x2f\x25\x66\x56\x16\x8e\x6c\x49\x6a\xfc\x5f\xb9\x32\x46\xf6\xb1\x11\x63\x98\xa3\x46\xf1\xa6\x41\xf3\xb0\x41\xe9\x89\xf7\x91\x4f\x90\xcc\x2c\x7f\xff\x35\x78\x76\xe5\x06\xb5\x0d\x33\x4b\xa7\x7c\x22\x5b\xc3\x07\xba\x53\x71\x52\xf3\xf1\x61\x0e\x4e\xaf\xe5\x95\xf6\xd9\xd9\x0d\x11\xfa\xa9\x33\xa1\x5e\xf1\x36\x95\x46\x86\x8a\x7f\x3a\x45\xa9\x67\x68\xd4\x0f\xd9\xd0\x34\x12\xc0\x91\xc6\x31\x5c\xf4\xfd\xe7\xcb\x68\x60\x69\x37\x38\x0d\xb2\xea\xaa\x70\x7b\x4c\x41\x85\xc3\x2e\xdd\xcd\xd3\x06\x70\x5e\x4d\xc1\xff\xc8\x72\xee\xee\x47\x5a\x64\xdf\xac\x86\xab\xa4\x1c\x06\x18\x98\x3f\x87\x41\xc5\xef\x68\xd3\xa1\x01\xe8\xa3\xb8\xca\xc6\x0c\x90\x5c\x15\xfc\x91\x08\x40\xb9\x4c\x00\xa0\xb9\xd0"
+        , vecSig =
+            "\xd0\x39\x65\xac\x31\x6a\x20\xf5\xa4\x7a\xb2\xd6\x18\x5e\xb3\xf0\xae\xea\x9c\x2e\xb8\xab\xe9\x22\xe9\x6d\x31\x7b\x3b\xd0\xef\x02\xe8\xd4\x7f\xd9\x23\x84\xe2\x86\x15\xeb\x33\x14\xad\xbc\x71\xc4\x67\x59\x96\x09\x9e\x48\x4c\xeb\x16\x28\x47\xc4\x0c\x32\x44\x0e"
         }
     ]
 
-
 doPublicKeyTest :: Int -> Vec -> TestTree
 doPublicKeyTest i Vec{..} =
     testCase (show i) (pub @=? EdDSA.toPublic vecPrx vecAlg sec)
@@ -123,9 +156,10 @@
     !sig = throwCryptoError $ EdDSA.signature vecPrx vecAlg vecSig
     !pub = throwCryptoError $ EdDSA.publicKey vecPrx vecAlg vecPub
 
-
-tests = testGroup "EdDSA"
-    [ testGroup "gen publickey" $ zipWith doPublicKeyTest [katZero..] vectors
-    , testGroup "gen signature" $ zipWith doSignatureTest [katZero..] vectors
-    , testGroup "verify sig" $ zipWith doVerifyTest [katZero..] vectors
-    ]
+tests =
+    testGroup
+        "EdDSA"
+        [ testGroup "gen publickey" $ zipWith doPublicKeyTest [katZero ..] vectors
+        , testGroup "gen signature" $ zipWith doSignatureTest [katZero ..] vectors
+        , testGroup "verify sig" $ zipWith doVerifyTest [katZero ..] vectors
+        ]
diff --git a/tests/KAT_HKDF.hs b/tests/KAT_HKDF.hs
--- a/tests/KAT_HKDF.hs
+++ b/tests/KAT_HKDF.hs
@@ -1,17 +1,17 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_HKDF (tests) where
 
+import Crypto.Hash (HashAlgorithm, SHA256 (..))
 import qualified Crypto.KDF.HKDF as HKDF
-import Crypto.Hash (SHA256(..), HashAlgorithm)
 import qualified Data.ByteString as B
 
 import Imports
 
-
 data KDFVector hash = KDFVector
-    { kdfIKM    :: ByteString
-    , kdfSalt   :: ByteString
-    , kdfInfo   :: ByteString
+    { kdfIKM :: ByteString
+    , kdfSalt :: ByteString
+    , kdfInfo :: ByteString
     , kdfResult :: ByteString
     }
 
@@ -19,33 +19,369 @@
 sha256KDFVectors =
     [ KDFVector
         "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
-        (B.pack [0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c])
+        ( B.pack
+            [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c]
+        )
         "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9"
         "\x3c\xb2\x5f\x25\xfa\xac\xd5\x7a\x90\x43\x4f\x64\xd0\x36\x2f\x2a\x2d\x2d\x0a\x90\xcf\x1a\x5a\x4c\x5d\xb0\x2d\x56\xec\xc4\xc5\xbf\x34\x00\x72\x08\xd5\xb8\x87\x18\x58\x65"
     , KDFVector
-        (B.pack [0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f])
-        (B.pack [0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf])
-        (B.pack [0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff])
-        (B.pack [0xb1,0x1e,0x39,0x8d,0xc8,0x03,0x27,0xa1,0xc8,0xe7,0xf7,0x8c,0x59,0x6a,0x49,0x34,0x4f,0x01,0x2e,0xda,0x2d,0x4e,0xfa,0xd8,0xa0,0x50,0xcc,0x4c,0x19,0xaf,0xa9,0x7c,0x59,0x04,0x5a,0x99,0xca,0xc7,0x82,0x72,0x71,0xcb,0x41,0xc6,0x5e,0x59,0x0e,0x09,0xda,0x32,0x75,0x60,0x0c,0x2f,0x09,0xb8,0x36,0x77,0x93,0xa9,0xac,0xa3,0xdb,0x71,0xcc,0x30,0xc5,0x81,0x79,0xec,0x3e,0x87,0xc1,0x4c,0x01,0xd5,0xc1,0xf3,0x43,0x4f,0x1d,0x87])
+        ( B.pack
+            [ 0x00
+            , 0x01
+            , 0x02
+            , 0x03
+            , 0x04
+            , 0x05
+            , 0x06
+            , 0x07
+            , 0x08
+            , 0x09
+            , 0x0a
+            , 0x0b
+            , 0x0c
+            , 0x0d
+            , 0x0e
+            , 0x0f
+            , 0x10
+            , 0x11
+            , 0x12
+            , 0x13
+            , 0x14
+            , 0x15
+            , 0x16
+            , 0x17
+            , 0x18
+            , 0x19
+            , 0x1a
+            , 0x1b
+            , 0x1c
+            , 0x1d
+            , 0x1e
+            , 0x1f
+            , 0x20
+            , 0x21
+            , 0x22
+            , 0x23
+            , 0x24
+            , 0x25
+            , 0x26
+            , 0x27
+            , 0x28
+            , 0x29
+            , 0x2a
+            , 0x2b
+            , 0x2c
+            , 0x2d
+            , 0x2e
+            , 0x2f
+            , 0x30
+            , 0x31
+            , 0x32
+            , 0x33
+            , 0x34
+            , 0x35
+            , 0x36
+            , 0x37
+            , 0x38
+            , 0x39
+            , 0x3a
+            , 0x3b
+            , 0x3c
+            , 0x3d
+            , 0x3e
+            , 0x3f
+            , 0x40
+            , 0x41
+            , 0x42
+            , 0x43
+            , 0x44
+            , 0x45
+            , 0x46
+            , 0x47
+            , 0x48
+            , 0x49
+            , 0x4a
+            , 0x4b
+            , 0x4c
+            , 0x4d
+            , 0x4e
+            , 0x4f
+            ]
+        )
+        ( B.pack
+            [ 0x60
+            , 0x61
+            , 0x62
+            , 0x63
+            , 0x64
+            , 0x65
+            , 0x66
+            , 0x67
+            , 0x68
+            , 0x69
+            , 0x6a
+            , 0x6b
+            , 0x6c
+            , 0x6d
+            , 0x6e
+            , 0x6f
+            , 0x70
+            , 0x71
+            , 0x72
+            , 0x73
+            , 0x74
+            , 0x75
+            , 0x76
+            , 0x77
+            , 0x78
+            , 0x79
+            , 0x7a
+            , 0x7b
+            , 0x7c
+            , 0x7d
+            , 0x7e
+            , 0x7f
+            , 0x80
+            , 0x81
+            , 0x82
+            , 0x83
+            , 0x84
+            , 0x85
+            , 0x86
+            , 0x87
+            , 0x88
+            , 0x89
+            , 0x8a
+            , 0x8b
+            , 0x8c
+            , 0x8d
+            , 0x8e
+            , 0x8f
+            , 0x90
+            , 0x91
+            , 0x92
+            , 0x93
+            , 0x94
+            , 0x95
+            , 0x96
+            , 0x97
+            , 0x98
+            , 0x99
+            , 0x9a
+            , 0x9b
+            , 0x9c
+            , 0x9d
+            , 0x9e
+            , 0x9f
+            , 0xa0
+            , 0xa1
+            , 0xa2
+            , 0xa3
+            , 0xa4
+            , 0xa5
+            , 0xa6
+            , 0xa7
+            , 0xa8
+            , 0xa9
+            , 0xaa
+            , 0xab
+            , 0xac
+            , 0xad
+            , 0xae
+            , 0xaf
+            ]
+        )
+        ( B.pack
+            [ 0xb0
+            , 0xb1
+            , 0xb2
+            , 0xb3
+            , 0xb4
+            , 0xb5
+            , 0xb6
+            , 0xb7
+            , 0xb8
+            , 0xb9
+            , 0xba
+            , 0xbb
+            , 0xbc
+            , 0xbd
+            , 0xbe
+            , 0xbf
+            , 0xc0
+            , 0xc1
+            , 0xc2
+            , 0xc3
+            , 0xc4
+            , 0xc5
+            , 0xc6
+            , 0xc7
+            , 0xc8
+            , 0xc9
+            , 0xca
+            , 0xcb
+            , 0xcc
+            , 0xcd
+            , 0xce
+            , 0xcf
+            , 0xd0
+            , 0xd1
+            , 0xd2
+            , 0xd3
+            , 0xd4
+            , 0xd5
+            , 0xd6
+            , 0xd7
+            , 0xd8
+            , 0xd9
+            , 0xda
+            , 0xdb
+            , 0xdc
+            , 0xdd
+            , 0xde
+            , 0xdf
+            , 0xe0
+            , 0xe1
+            , 0xe2
+            , 0xe3
+            , 0xe4
+            , 0xe5
+            , 0xe6
+            , 0xe7
+            , 0xe8
+            , 0xe9
+            , 0xea
+            , 0xeb
+            , 0xec
+            , 0xed
+            , 0xee
+            , 0xef
+            , 0xf0
+            , 0xf1
+            , 0xf2
+            , 0xf3
+            , 0xf4
+            , 0xf5
+            , 0xf6
+            , 0xf7
+            , 0xf8
+            , 0xf9
+            , 0xfa
+            , 0xfb
+            , 0xfc
+            , 0xfd
+            , 0xfe
+            , 0xff
+            ]
+        )
+        ( B.pack
+            [ 0xb1
+            , 0x1e
+            , 0x39
+            , 0x8d
+            , 0xc8
+            , 0x03
+            , 0x27
+            , 0xa1
+            , 0xc8
+            , 0xe7
+            , 0xf7
+            , 0x8c
+            , 0x59
+            , 0x6a
+            , 0x49
+            , 0x34
+            , 0x4f
+            , 0x01
+            , 0x2e
+            , 0xda
+            , 0x2d
+            , 0x4e
+            , 0xfa
+            , 0xd8
+            , 0xa0
+            , 0x50
+            , 0xcc
+            , 0x4c
+            , 0x19
+            , 0xaf
+            , 0xa9
+            , 0x7c
+            , 0x59
+            , 0x04
+            , 0x5a
+            , 0x99
+            , 0xca
+            , 0xc7
+            , 0x82
+            , 0x72
+            , 0x71
+            , 0xcb
+            , 0x41
+            , 0xc6
+            , 0x5e
+            , 0x59
+            , 0x0e
+            , 0x09
+            , 0xda
+            , 0x32
+            , 0x75
+            , 0x60
+            , 0x0c
+            , 0x2f
+            , 0x09
+            , 0xb8
+            , 0x36
+            , 0x77
+            , 0x93
+            , 0xa9
+            , 0xac
+            , 0xa3
+            , 0xdb
+            , 0x71
+            , 0xcc
+            , 0x30
+            , 0xc5
+            , 0x81
+            , 0x79
+            , 0xec
+            , 0x3e
+            , 0x87
+            , 0xc1
+            , 0x4c
+            , 0x01
+            , 0xd5
+            , 0xc1
+            , 0xf3
+            , 0x43
+            , 0x4f
+            , 0x1d
+            , 0x87
+            ]
+        )
     ]
 
 kdfTests :: [TestTree]
 kdfTests =
     [ testGroup "sha256" $ concatMap toKDFTest $ zip is sha256KDFVectors
     ]
-  where toKDFTest (i, kdfVector) =
-            [ testCase (show i) (t HKDF.extract kdfVector)
-            ]
-
-        t :: HashAlgorithm a => (ByteString -> ByteString -> HKDF.PRK a) -> KDFVector a -> Assertion
-        t ext v =
-            let prk = ext (kdfSalt v) (kdfIKM v)
-             in kdfResult v @=? HKDF.expand prk (kdfInfo v) (B.length $ kdfResult v)
+  where
+    toKDFTest (i, kdfVector) =
+        [ testCase (show i) (t HKDF.extract kdfVector)
+        ]
 
-        is :: [Int]
-        is = [1..]
+    t
+        :: HashAlgorithm a
+        => (ByteString -> ByteString -> HKDF.PRK a) -> KDFVector a -> Assertion
+    t ext v =
+        let prk = ext (kdfSalt v) (kdfIKM v)
+         in kdfResult v @=? HKDF.expand prk (kdfInfo v) (B.length $ kdfResult v)
 
+    is :: [Int]
+    is = [1 ..]
 
-tests = testGroup "HKDF"
-    [ testGroup "KATs" kdfTests
-    ]
+tests =
+    testGroup
+        "HKDF"
+        [ testGroup "KATs" kdfTests
+        ]
diff --git a/tests/KAT_HMAC.hs b/tests/KAT_HMAC.hs
--- a/tests/KAT_HMAC.hs
+++ b/tests/KAT_HMAC.hs
@@ -1,11 +1,23 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_HMAC (tests) where
 
+import Crypto.Hash (
+    HashAlgorithm,
+    Keccak_224 (..),
+    Keccak_256 (..),
+    Keccak_384 (..),
+    Keccak_512 (..),
+    MD5 (..),
+    SHA1 (..),
+    SHA256 (..),
+    SHA3_224 (..),
+    SHA3_256 (..),
+    SHA3_384 (..),
+    SHA3_512 (..),
+    digestFromByteString,
+ )
 import qualified Crypto.MAC.HMAC as HMAC
-import Crypto.Hash (MD5(..), SHA1(..), SHA256(..)
-                   , Keccak_224(..), Keccak_256(..), Keccak_384(..), Keccak_512(..)
-                   , SHA3_224(..), SHA3_256(..), SHA3_384(..), SHA3_512(..)
-                   , HashAlgorithm, digestFromByteString)
 import qualified Data.ByteString as B
 
 import Imports
@@ -27,69 +39,96 @@
 
 md5MACVectors :: [MACVector MD5]
 md5MACVectors =
-    [ MACVector B.empty B.empty $ digest "\x74\xe6\xf7\x29\x8a\x9c\x2d\x16\x89\x35\xf5\x8c\x00\x1b\xad\x88"
-    , MACVector "key"   v1      $ digest "\x80\x07\x07\x13\x46\x3e\x77\x49\xb9\x0c\x2d\xc2\x49\x11\xe2\x75"
+    [ MACVector B.empty B.empty $
+        digest "\x74\xe6\xf7\x29\x8a\x9c\x2d\x16\x89\x35\xf5\x8c\x00\x1b\xad\x88"
+    , MACVector "key" v1 $
+        digest "\x80\x07\x07\x13\x46\x3e\x77\x49\xb9\x0c\x2d\xc2\x49\x11\xe2\x75"
     ]
 
 sha1MACVectors :: [MACVector SHA1]
 sha1MACVectors =
-    [ MACVector B.empty B.empty $ digest "\xfb\xdb\x1d\x1b\x18\xaa\x6c\x08\x32\x4b\x7d\x64\xb7\x1f\xb7\x63\x70\x69\x0e\x1d"
-    , MACVector "key"   v1      $ digest "\xde\x7c\x9b\x85\xb8\xb7\x8a\xa6\xbc\x8a\x7a\x36\xf7\x0a\x90\x70\x1c\x9d\xb4\xd9"
+    [ MACVector B.empty B.empty $
+        digest
+            "\xfb\xdb\x1d\x1b\x18\xaa\x6c\x08\x32\x4b\x7d\x64\xb7\x1f\xb7\x63\x70\x69\x0e\x1d"
+    , MACVector "key" v1 $
+        digest
+            "\xde\x7c\x9b\x85\xb8\xb7\x8a\xa6\xbc\x8a\x7a\x36\xf7\x0a\x90\x70\x1c\x9d\xb4\xd9"
     ]
 
 sha256MACVectors :: [MACVector SHA256]
 sha256MACVectors =
-    [ MACVector B.empty B.empty $ digest "\xb6\x13\x67\x9a\x08\x14\xd9\xec\x77\x2f\x95\xd7\x78\xc3\x5f\xc5\xff\x16\x97\xc4\x93\x71\x56\x53\xc6\xc7\x12\x14\x42\x92\xc5\xad"
-    , MACVector "key"   v1      $ digest "\xf7\xbc\x83\xf4\x30\x53\x84\x24\xb1\x32\x98\xe6\xaa\x6f\xb1\x43\xef\x4d\x59\xa1\x49\x46\x17\x59\x97\x47\x9d\xbc\x2d\x1a\x3c\xd8"
+    [ MACVector B.empty B.empty $
+        digest
+            "\xb6\x13\x67\x9a\x08\x14\xd9\xec\x77\x2f\x95\xd7\x78\xc3\x5f\xc5\xff\x16\x97\xc4\x93\x71\x56\x53\xc6\xc7\x12\x14\x42\x92\xc5\xad"
+    , MACVector "key" v1 $
+        digest
+            "\xf7\xbc\x83\xf4\x30\x53\x84\x24\xb1\x32\x98\xe6\xaa\x6f\xb1\x43\xef\x4d\x59\xa1\x49\x46\x17\x59\x97\x47\x9d\xbc\x2d\x1a\x3c\xd8"
     ]
 
 keccak_key1 = "\x4a\x65\x66\x65"
-keccak_data1 = "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"
+keccak_data1 =
+    "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"
 
 keccak_224_MAC_Vectors :: [MACVector Keccak_224]
 keccak_224_MAC_Vectors =
-    [ MACVector keccak_key1 keccak_data1 $ digest "\xe8\x24\xfe\xc9\x6c\x07\x4f\x22\xf9\x92\x35\xbb\x94\x2d\xa1\x98\x26\x64\xab\x69\x2c\xa8\x50\x10\x53\xcb\xd4\x14"
+    [ MACVector keccak_key1 keccak_data1 $
+        digest
+            "\xe8\x24\xfe\xc9\x6c\x07\x4f\x22\xf9\x92\x35\xbb\x94\x2d\xa1\x98\x26\x64\xab\x69\x2c\xa8\x50\x10\x53\xcb\xd4\x14"
     ]
 
 keccak_256_MAC_Vectors :: [MACVector Keccak_256]
 keccak_256_MAC_Vectors =
-    [  MACVector keccak_key1 keccak_data1 $ digest "\xaa\x9a\xed\x44\x8c\x7a\xbc\x8b\x5e\x32\x6f\xfa\x6a\x01\xcd\xed\xf7\xb4\xb8\x31\x88\x14\x68\xc0\x44\xba\x8d\xd4\x56\x63\x69\xa1"
+    [ MACVector keccak_key1 keccak_data1 $
+        digest
+            "\xaa\x9a\xed\x44\x8c\x7a\xbc\x8b\x5e\x32\x6f\xfa\x6a\x01\xcd\xed\xf7\xb4\xb8\x31\x88\x14\x68\xc0\x44\xba\x8d\xd4\x56\x63\x69\xa1"
     ]
 
 keccak_384_MAC_Vectors :: [MACVector Keccak_384]
 keccak_384_MAC_Vectors =
-    [ MACVector keccak_key1 keccak_data1 $ digest "\x5a\xf5\xc9\xa7\x7a\x23\xa6\xa9\x3d\x80\x64\x9e\x56\x2a\xb7\x7f\x4f\x35\x52\xe3\xc5\xca\xff\xd9\x3b\xdf\x8b\x3c\xfc\x69\x20\xe3\x02\x3f\xc2\x67\x75\xd9\xdf\x1f\x3c\x94\x61\x31\x46\xad\x2c\x9d"
+    [ MACVector keccak_key1 keccak_data1 $
+        digest
+            "\x5a\xf5\xc9\xa7\x7a\x23\xa6\xa9\x3d\x80\x64\x9e\x56\x2a\xb7\x7f\x4f\x35\x52\xe3\xc5\xca\xff\xd9\x3b\xdf\x8b\x3c\xfc\x69\x20\xe3\x02\x3f\xc2\x67\x75\xd9\xdf\x1f\x3c\x94\x61\x31\x46\xad\x2c\x9d"
     ]
 
 keccak_512_MAC_Vectors :: [MACVector Keccak_512]
 keccak_512_MAC_Vectors =
-    [ MACVector keccak_key1 keccak_data1 $ digest "\xc2\x96\x2e\x5b\xbe\x12\x38\x00\x78\x52\xf7\x9d\x81\x4d\xbb\xec\xd4\x68\x2e\x6f\x09\x7d\x37\xa3\x63\x58\x7c\x03\xbf\xa2\xeb\x08\x59\xd8\xd9\xc7\x01\xe0\x4c\xec\xec\xfd\x3d\xd7\xbf\xd4\x38\xf2\x0b\x8b\x64\x8e\x01\xbf\x8c\x11\xd2\x68\x24\xb9\x6c\xeb\xbd\xcb"
+    [ MACVector keccak_key1 keccak_data1 $
+        digest
+            "\xc2\x96\x2e\x5b\xbe\x12\x38\x00\x78\x52\xf7\x9d\x81\x4d\xbb\xec\xd4\x68\x2e\x6f\x09\x7d\x37\xa3\x63\x58\x7c\x03\xbf\xa2\xeb\x08\x59\xd8\xd9\xc7\x01\xe0\x4c\xec\xec\xfd\x3d\xd7\xbf\xd4\x38\xf2\x0b\x8b\x64\x8e\x01\xbf\x8c\x11\xd2\x68\x24\xb9\x6c\xeb\xbd\xcb"
     ]
 
 sha3_key1 = "\x4a\x65\x66\x65"
-sha3_data1 = "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"
+sha3_data1 =
+    "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"
 
 sha3_224_MAC_Vectors :: [MACVector SHA3_224]
 sha3_224_MAC_Vectors =
-    [ MACVector sha3_key1 sha3_data1 $ digest "\x7f\xdb\x8d\xd8\x8b\xd2\xf6\x0d\x1b\x79\x86\x34\xad\x38\x68\x11\xc2\xcf\xc8\x5b\xfa\xf5\xd5\x2b\xba\xce\x5e\x66"
+    [ MACVector sha3_key1 sha3_data1 $
+        digest
+            "\x7f\xdb\x8d\xd8\x8b\xd2\xf6\x0d\x1b\x79\x86\x34\xad\x38\x68\x11\xc2\xcf\xc8\x5b\xfa\xf5\xd5\x2b\xba\xce\x5e\x66"
     ]
 
 sha3_256_MAC_Vectors :: [MACVector SHA3_256]
 sha3_256_MAC_Vectors =
-    [  MACVector sha3_key1 sha3_data1 $ digest "\xc7\xd4\x07\x2e\x78\x88\x77\xae\x35\x96\xbb\xb0\xda\x73\xb8\x87\xc9\x17\x1f\x93\x09\x5b\x29\x4a\xe8\x57\xfb\xe2\x64\x5e\x1b\xa5"
+    [ MACVector sha3_key1 sha3_data1 $
+        digest
+            "\xc7\xd4\x07\x2e\x78\x88\x77\xae\x35\x96\xbb\xb0\xda\x73\xb8\x87\xc9\x17\x1f\x93\x09\x5b\x29\x4a\xe8\x57\xfb\xe2\x64\x5e\x1b\xa5"
     ]
 
 sha3_384_MAC_Vectors :: [MACVector SHA3_384]
 sha3_384_MAC_Vectors =
-    [ MACVector sha3_key1 sha3_data1 $ digest "\xf1\x10\x1f\x8c\xbf\x97\x66\xfd\x67\x64\xd2\xed\x61\x90\x3f\x21\xca\x9b\x18\xf5\x7c\xf3\xe1\xa2\x3c\xa1\x35\x08\xa9\x32\x43\xce\x48\xc0\x45\xdc\x00\x7f\x26\xa2\x1b\x3f\x5e\x0e\x9d\xf4\xc2\x0a"
+    [ MACVector sha3_key1 sha3_data1 $
+        digest
+            "\xf1\x10\x1f\x8c\xbf\x97\x66\xfd\x67\x64\xd2\xed\x61\x90\x3f\x21\xca\x9b\x18\xf5\x7c\xf3\xe1\xa2\x3c\xa1\x35\x08\xa9\x32\x43\xce\x48\xc0\x45\xdc\x00\x7f\x26\xa2\x1b\x3f\x5e\x0e\x9d\xf4\xc2\x0a"
     ]
 
 sha3_512_MAC_Vectors :: [MACVector SHA3_512]
 sha3_512_MAC_Vectors =
-    [ MACVector sha3_key1 sha3_data1 $ digest "\x5a\x4b\xfe\xab\x61\x66\x42\x7c\x7a\x36\x47\xb7\x47\x29\x2b\x83\x84\x53\x7c\xdb\x89\xaf\xb3\xbf\x56\x65\xe4\xc5\xe7\x09\x35\x0b\x28\x7b\xae\xc9\x21\xfd\x7c\xa0\xee\x7a\x0c\x31\xd0\x22\xa9\x5e\x1f\xc9\x2b\xa9\xd7\x7d\xf8\x83\x96\x02\x75\xbe\xb4\xe6\x20\x24"
+    [ MACVector sha3_key1 sha3_data1 $
+        digest
+            "\x5a\x4b\xfe\xab\x61\x66\x42\x7c\x7a\x36\x47\xb7\x47\x29\x2b\x83\x84\x53\x7c\xdb\x89\xaf\xb3\xbf\x56\x65\xe4\xc5\xe7\x09\x35\x0b\x28\x7b\xae\xc9\x21\xfd\x7c\xa0\xee\x7a\x0c\x31\xd0\x22\xa9\x5e\x1f\xc9\x2b\xa9\xd7\x7d\xf8\x83\x96\x02\x75\xbe\xb4\xe6\x20\x24"
     ]
 
-
 macTests :: [TestTree]
 macTests =
     [ testGroup "md5" $ concatMap toMACTest $ zip is md5MACVectors
@@ -104,16 +143,23 @@
     , testGroup "sha3-384" $ concatMap toMACTest $ zip is sha3_384_MAC_Vectors
     , testGroup "sha3-512" $ concatMap toMACTest $ zip is sha3_512_MAC_Vectors
     ]
-    where toMACTest (i, macVector) =
-            [ testCase (show i) (macResult macVector @=? HMAC.hmac (macKey macVector) (macSecret macVector))
-            , testCase ("incr-" ++ show i) (macResult macVector @=?
-                        HMAC.finalize (HMAC.update (HMAC.initialize (macKey macVector)) (macSecret macVector)))
-            ]
-          is :: [Int]
-          is = [1..]
+  where
+    toMACTest (i, macVector) =
+        [ testCase
+            (show i)
+            (macResult macVector @=? HMAC.hmac (macKey macVector) (macSecret macVector))
+        , testCase
+            ("incr-" ++ show i)
+            ( macResult macVector
+                @=? HMAC.finalize
+                    (HMAC.update (HMAC.initialize (macKey macVector)) (macSecret macVector))
+            )
+        ]
+    is :: [Int]
+    is = [1 ..]
 
 data MacIncremental a = MacIncremental ByteString ByteString (HMAC.HMAC a)
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance HashAlgorithm a => Arbitrary (MacIncremental a) where
     arbitrary = do
@@ -122,12 +168,12 @@
         return $ MacIncremental key msg (HMAC.hmac key msg)
 
 data MacIncrementalList a = MacIncrementalList ByteString [ByteString] (HMAC.HMAC a)
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance HashAlgorithm a => Arbitrary (MacIncrementalList a) where
     arbitrary = do
-        key  <- arbitraryBSof 1 89
-        msgs <- choose (1,20) >>= \n -> replicateM n (arbitraryBSof 1 99)
+        key <- arbitraryBSof 1 89
+        msgs <- choose (1, 20) >>= \n -> replicateM n (arbitraryBSof 1 99)
         return $ MacIncrementalList key msgs (HMAC.hmac key (B.concat msgs))
 
 macIncrementalTests :: [TestTree]
@@ -141,21 +187,26 @@
     , testIncrProperties SHA3_512
     ]
   where
-        --testIncrProperties :: HashAlgorithm a => a -> [Property]
-        testIncrProperties a = testGroup (show a)
+    -- testIncrProperties :: HashAlgorithm a => a -> [Property]
+    testIncrProperties a =
+        testGroup
+            (show a)
             [ testProperty "list-one" (prop_inc0 a)
             , testProperty "list-multi" (prop_inc1 a)
             ]
 
-        prop_inc0 :: HashAlgorithm a => a -> MacIncremental a -> Bool
-        prop_inc0 _ (MacIncremental secret msg result) =
-            result `assertEq` HMAC.finalize (HMAC.update (HMAC.initialize secret) msg)
+    prop_inc0 :: HashAlgorithm a => a -> MacIncremental a -> Bool
+    prop_inc0 _ (MacIncremental secret msg result) =
+        result `assertEq` HMAC.finalize (HMAC.update (HMAC.initialize secret) msg)
 
-        prop_inc1 :: HashAlgorithm a => a -> MacIncrementalList a -> Bool
-        prop_inc1 _ (MacIncrementalList secret msgs result) =
-            result `assertEq` HMAC.finalize (foldl' HMAC.update (HMAC.initialize secret) msgs)
+    prop_inc1 :: HashAlgorithm a => a -> MacIncrementalList a -> Bool
+    prop_inc1 _ (MacIncrementalList secret msgs result) =
+        result
+            `assertEq` HMAC.finalize (foldl' HMAC.update (HMAC.initialize secret) msgs)
 
-tests = testGroup "HMAC"
-    [ testGroup "KATs" macTests
-    , testGroup "properties" macIncrementalTests
-    ]
+tests =
+    testGroup
+        "HMAC"
+        [ testGroup "KATs" macTests
+        , testGroup "properties" macIncrementalTests
+        ]
diff --git a/tests/KAT_KMAC.hs b/tests/KAT_KMAC.hs
--- a/tests/KAT_KMAC.hs
+++ b/tests/KAT_KMAC.hs
@@ -3,10 +3,15 @@
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE RecordWildCards #-}
+
 module KAT_KMAC (tests) where
 
-import           Crypto.Hash (SHAKE128(..), SHAKE256(..),
-                              HashAlgorithm, digestFromByteString)
+import Crypto.Hash (
+    HashAlgorithm,
+    SHAKE128 (..),
+    SHAKE256 (..),
+    digestFromByteString,
+ )
 import qualified Crypto.MAC.KMAC as KMAC
 
 import qualified Data.ByteString as B
@@ -15,7 +20,7 @@
 
 data MACVector hash = MACVector
     { macString :: ByteString
-    , macKey    :: ByteString
+    , macKey :: ByteString
     , macSecret :: ByteString
     , macResult :: KMAC.KMAC hash
     }
@@ -30,21 +35,27 @@
 vectors128 =
     [ MACVector
         { macString = ""
-        , macKey    = B.pack [ 0x40 .. 0x5f ]
-        , macSecret = B.pack [ 0x00 .. 0x03 ]
-        , macResult = digest "\xe5\x78\x0b\x0d\x3e\xa6\xf7\xd3\xa4\x29\xc5\x70\x6a\xa4\x3a\x00\xfa\xdb\xd7\xd4\x96\x28\x83\x9e\x31\x87\x24\x3f\x45\x6e\xe1\x4e"
+        , macKey = B.pack [0x40 .. 0x5f]
+        , macSecret = B.pack [0x00 .. 0x03]
+        , macResult =
+            digest
+                "\xe5\x78\x0b\x0d\x3e\xa6\xf7\xd3\xa4\x29\xc5\x70\x6a\xa4\x3a\x00\xfa\xdb\xd7\xd4\x96\x28\x83\x9e\x31\x87\x24\x3f\x45\x6e\xe1\x4e"
         }
     , MACVector
         { macString = "My Tagged Application"
-        , macKey    = B.pack [ 0x40 .. 0x5f ]
-        , macSecret = B.pack [ 0x00 .. 0x03 ]
-        , macResult = digest "\x3b\x1f\xba\x96\x3c\xd8\xb0\xb5\x9e\x8c\x1a\x6d\x71\x88\x8b\x71\x43\x65\x1a\xf8\xba\x0a\x70\x70\xc0\x97\x9e\x28\x11\x32\x4a\xa5"
+        , macKey = B.pack [0x40 .. 0x5f]
+        , macSecret = B.pack [0x00 .. 0x03]
+        , macResult =
+            digest
+                "\x3b\x1f\xba\x96\x3c\xd8\xb0\xb5\x9e\x8c\x1a\x6d\x71\x88\x8b\x71\x43\x65\x1a\xf8\xba\x0a\x70\x70\xc0\x97\x9e\x28\x11\x32\x4a\xa5"
         }
     , MACVector
         { macString = "My Tagged Application"
-        , macKey    = B.pack [ 0x40 .. 0x5f ]
-        , macSecret = B.pack [ 0x00 .. 0xc7 ]
-        , macResult = digest "\x1f\x5b\x4e\x6c\xca\x02\x20\x9e\x0d\xcb\x5c\xa6\x35\xb8\x9a\x15\xe2\x71\xec\xc7\x60\x07\x1d\xfd\x80\x5f\xaa\x38\xf9\x72\x92\x30"
+        , macKey = B.pack [0x40 .. 0x5f]
+        , macSecret = B.pack [0x00 .. 0xc7]
+        , macResult =
+            digest
+                "\x1f\x5b\x4e\x6c\xca\x02\x20\x9e\x0d\xcb\x5c\xa6\x35\xb8\x9a\x15\xe2\x71\xec\xc7\x60\x07\x1d\xfd\x80\x5f\xaa\x38\xf9\x72\x92\x30"
         }
     ]
 
@@ -52,21 +63,27 @@
 vectors256 =
     [ MACVector
         { macString = "My Tagged Application"
-        , macKey    = B.pack [ 0x40 .. 0x5f ]
-        , macSecret = B.pack [ 0x00 .. 0x03 ]
-        , macResult = digest "\x20\xc5\x70\xc3\x13\x46\xf7\x03\xc9\xac\x36\xc6\x1c\x03\xcb\x64\xc3\x97\x0d\x0c\xfc\x78\x7e\x9b\x79\x59\x9d\x27\x3a\x68\xd2\xf7\xf6\x9d\x4c\xc3\xde\x9d\x10\x4a\x35\x16\x89\xf2\x7c\xf6\xf5\x95\x1f\x01\x03\xf3\x3f\x4f\x24\x87\x10\x24\xd9\xc2\x77\x73\xa8\xdd"
+        , macKey = B.pack [0x40 .. 0x5f]
+        , macSecret = B.pack [0x00 .. 0x03]
+        , macResult =
+            digest
+                "\x20\xc5\x70\xc3\x13\x46\xf7\x03\xc9\xac\x36\xc6\x1c\x03\xcb\x64\xc3\x97\x0d\x0c\xfc\x78\x7e\x9b\x79\x59\x9d\x27\x3a\x68\xd2\xf7\xf6\x9d\x4c\xc3\xde\x9d\x10\x4a\x35\x16\x89\xf2\x7c\xf6\xf5\x95\x1f\x01\x03\xf3\x3f\x4f\x24\x87\x10\x24\xd9\xc2\x77\x73\xa8\xdd"
         }
     , MACVector
         { macString = ""
-        , macKey    = B.pack [ 0x40 .. 0x5f ]
-        , macSecret = B.pack [ 0x00 .. 0xc7 ]
-        , macResult = digest "\x75\x35\x8c\xf3\x9e\x41\x49\x4e\x94\x97\x07\x92\x7c\xee\x0a\xf2\x0a\x3f\xf5\x53\x90\x4c\x86\xb0\x8f\x21\xcc\x41\x4b\xcf\xd6\x91\x58\x9d\x27\xcf\x5e\x15\x36\x9c\xbb\xff\x8b\x9a\x4c\x2e\xb1\x78\x00\x85\x5d\x02\x35\xff\x63\x5d\xa8\x25\x33\xec\x6b\x75\x9b\x69"
+        , macKey = B.pack [0x40 .. 0x5f]
+        , macSecret = B.pack [0x00 .. 0xc7]
+        , macResult =
+            digest
+                "\x75\x35\x8c\xf3\x9e\x41\x49\x4e\x94\x97\x07\x92\x7c\xee\x0a\xf2\x0a\x3f\xf5\x53\x90\x4c\x86\xb0\x8f\x21\xcc\x41\x4b\xcf\xd6\x91\x58\x9d\x27\xcf\x5e\x15\x36\x9c\xbb\xff\x8b\x9a\x4c\x2e\xb1\x78\x00\x85\x5d\x02\x35\xff\x63\x5d\xa8\x25\x33\xec\x6b\x75\x9b\x69"
         }
     , MACVector
         { macString = "My Tagged Application"
-        , macKey    = B.pack [ 0x40 .. 0x5f ]
-        , macSecret = B.pack [ 0x00 .. 0xc7 ]
-        , macResult = digest "\xb5\x86\x18\xf7\x1f\x92\xe1\xd5\x6c\x1b\x8c\x55\xdd\xd7\xcd\x18\x8b\x97\xb4\xca\x4d\x99\x83\x1e\xb2\x69\x9a\x83\x7d\xa2\xe4\xd9\x70\xfb\xac\xfd\xe5\x00\x33\xae\xa5\x85\xf1\xa2\x70\x85\x10\xc3\x2d\x07\x88\x08\x01\xbd\x18\x28\x98\xfe\x47\x68\x76\xfc\x89\x65"
+        , macKey = B.pack [0x40 .. 0x5f]
+        , macSecret = B.pack [0x00 .. 0xc7]
+        , macResult =
+            digest
+                "\xb5\x86\x18\xf7\x1f\x92\xe1\xd5\x6c\x1b\x8c\x55\xdd\xd7\xcd\x18\x8b\x97\xb4\xca\x4d\x99\x83\x1e\xb2\x69\x9a\x83\x7d\xa2\xe4\xd9\x70\xfb\xac\xfd\xe5\x00\x33\xae\xa5\x85\xf1\xa2\x70\x85\x10\xc3\x2d\x07\x88\x08\x01\xbd\x18\x28\x98\xfe\x47\x68\x76\xfc\x89\x65"
         }
     ]
 
@@ -75,16 +92,20 @@
     [ testGroup "SHAKE128" (concatMap toMACTest $ zip is vectors128)
     , testGroup "SHAKE256" (concatMap toMACTest $ zip is vectors256)
     ]
-    where toMACTest (i, MACVector{..}) =
-            [ testCase (show i) (macResult @=? KMAC.kmac macString macKey macSecret)
-            , testCase ("incr-" ++ show i) (macResult @=?
-                        KMAC.finalize (KMAC.update (KMAC.initialize macString macKey) macSecret))
-            ]
-          is :: [Int]
-          is = [1..]
+  where
+    toMACTest (i, MACVector{..}) =
+        [ testCase (show i) (macResult @=? KMAC.kmac macString macKey macSecret)
+        , testCase
+            ("incr-" ++ show i)
+            ( macResult
+                @=? KMAC.finalize (KMAC.update (KMAC.initialize macString macKey) macSecret)
+            )
+        ]
+    is :: [Int]
+    is = [1 ..]
 
 data MacIncremental a = MacIncremental ByteString ByteString ByteString (KMAC.KMAC a)
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance KMAC.HashSHAKE a => Arbitrary (MacIncremental a) where
     arbitrary = do
@@ -93,14 +114,15 @@
         msg <- arbitraryBSof 1 99
         return $ MacIncremental str key msg (KMAC.kmac str key msg)
 
-data MacIncrementalList a = MacIncrementalList ByteString ByteString [ByteString] (KMAC.KMAC a)
-    deriving (Show,Eq)
+data MacIncrementalList a
+    = MacIncrementalList ByteString ByteString [ByteString] (KMAC.KMAC a)
+    deriving (Show, Eq)
 
 instance KMAC.HashSHAKE a => Arbitrary (MacIncrementalList a) where
     arbitrary = do
-        str  <- arbitraryBSof 0 49
-        key  <- arbitraryBSof 1 89
-        msgs <- choose (1,20) >>= \n -> replicateM n (arbitraryBSof 1 99)
+        str <- arbitraryBSof 0 49
+        key <- arbitraryBSof 1 89
+        msgs <- choose (1, 20) >>= \n -> replicateM n (arbitraryBSof 1 99)
         return $ MacIncrementalList str key msgs (KMAC.kmac str key (B.concat msgs))
 
 macIncrementalTests :: [TestTree]
@@ -109,21 +131,26 @@
     , testIncrProperties "SHAKE256_512" (SHAKE256 :: SHAKE256 512)
     ]
   where
-        testIncrProperties :: KMAC.HashSHAKE a => TestName -> a -> TestTree
-        testIncrProperties name a = testGroup name
+    testIncrProperties :: KMAC.HashSHAKE a => TestName -> a -> TestTree
+    testIncrProperties name a =
+        testGroup
+            name
             [ testProperty "list-one" (prop_inc0 a)
             , testProperty "list-multi" (prop_inc1 a)
             ]
 
-        prop_inc0 :: KMAC.HashSHAKE a => a -> MacIncremental a -> Bool
-        prop_inc0 _ (MacIncremental str secret msg result) =
-            result `assertEq` KMAC.finalize (KMAC.update (KMAC.initialize str secret) msg)
+    prop_inc0 :: KMAC.HashSHAKE a => a -> MacIncremental a -> Bool
+    prop_inc0 _ (MacIncremental str secret msg result) =
+        result `assertEq` KMAC.finalize (KMAC.update (KMAC.initialize str secret) msg)
 
-        prop_inc1 :: KMAC.HashSHAKE a => a -> MacIncrementalList a -> Bool
-        prop_inc1 _ (MacIncrementalList str secret msgs result) =
-            result `assertEq` KMAC.finalize (foldl' KMAC.update (KMAC.initialize str secret) msgs)
+    prop_inc1 :: KMAC.HashSHAKE a => a -> MacIncrementalList a -> Bool
+    prop_inc1 _ (MacIncrementalList str secret msgs result) =
+        result
+            `assertEq` KMAC.finalize (foldl' KMAC.update (KMAC.initialize str secret) msgs)
 
-tests = testGroup "KMAC"
-    [ testGroup "KATs" macTests
-    , testGroup "properties" macIncrementalTests
-    ]
+tests =
+    testGroup
+        "KMAC"
+        [ testGroup "KATs" macTests
+        , testGroup "properties" macIncrementalTests
+        ]
diff --git a/tests/KAT_MiyaguchiPreneel.hs b/tests/KAT_MiyaguchiPreneel.hs
--- a/tests/KAT_MiyaguchiPreneel.hs
+++ b/tests/KAT_MiyaguchiPreneel.hs
@@ -1,49 +1,55 @@
-
 module KAT_MiyaguchiPreneel (tests) where
 
-import           Crypto.Cipher.AES (AES128)
-import           Crypto.ConstructHash.MiyaguchiPreneel as MiyaguchiPreneel
+import Crypto.Cipher.AES (AES128)
+import Crypto.ConstructHash.MiyaguchiPreneel as MiyaguchiPreneel
 
-import           Imports
+import Imports
 
-import qualified Data.ByteString.Char8 as B8
 import qualified Data.ByteArray as B
 import Data.ByteArray.Encoding (Base (Base16), convertFromBase)
-
+import qualified Data.ByteString.Char8 as B8
 
 runMP128 :: ByteString -> ByteString
 runMP128 s = B.convert (MiyaguchiPreneel.compute s :: MiyaguchiPreneel AES128)
 
 hxs :: String -> ByteString
-hxs = either (error . ("hxs:" ++)) id . convertFromBase Base16
-      . B8.pack . filter (/= ' ')
+hxs =
+    either (error . ("hxs:" ++)) id
+        . convertFromBase Base16
+        . B8.pack
+        . filter (/= ' ')
 
 gAES128 :: TestTree
 gAES128 =
-  igroup "aes128"
-  [ runMP128  B8.empty
-    @?=       hxs "66e94bd4 ef8a2c3b 884cfa59 ca342b2e"
-  , runMP128 (hxs "01000000 00000000 00000000 00000000")
-    @?=       hxs "46711816 e91d6ff0 59bbbf2b f58e0fd3"
-  , runMP128 (hxs "00000000 00000000 00000000 00000001")
-    @?=       hxs "58e2fcce fa7e3061 367f1d57 a4e7455b"
-  , runMP128     (hxs $
-                  "00000000 00000000 00000000 00000000" ++
-                  "01")
-    @?=       hxs "a5ff35ae 097adf5d 646abf5e bf4c16f4"
-  ]
+    igroup
+        "aes128"
+        [ runMP128 B8.empty
+            @?= hxs "66e94bd4 ef8a2c3b 884cfa59 ca342b2e"
+        , runMP128 (hxs "01000000 00000000 00000000 00000000")
+            @?= hxs "46711816 e91d6ff0 59bbbf2b f58e0fd3"
+        , runMP128 (hxs "00000000 00000000 00000000 00000001")
+            @?= hxs "58e2fcce fa7e3061 367f1d57 a4e7455b"
+        , runMP128
+            ( hxs $
+                "00000000 00000000 00000000 00000000"
+                    ++ "01"
+            )
+            @?= hxs "a5ff35ae 097adf5d 646abf5e bf4c16f4"
+        ]
 
 igroup :: TestName -> [Assertion] -> TestTree
-igroup nm = testGroup nm . zipWith (flip ($)) [1..] . map icase
+igroup nm = testGroup nm . zipWith (flip ($)) [1 ..] . map icase
   where
     icase c i = testCase (show (i :: Int)) c
 
 vectors :: TestTree
 vectors =
-  testGroup "KATs"
-  [ gAES128 ]
+    testGroup
+        "KATs"
+        [gAES128]
 
 tests :: TestTree
 tests =
-    testGroup "MiyaguchiPreneel"
-    [ vectors ]
+    testGroup
+        "MiyaguchiPreneel"
+        [vectors]
diff --git a/tests/KAT_OTP.hs b/tests/KAT_OTP.hs
--- a/tests/KAT_OTP.hs
+++ b/tests/KAT_OTP.hs
@@ -1,12 +1,11 @@
 {-# LANGUAGE OverloadedStrings #-}
 
-
-module KAT_OTP
-    ( tests
-    )
+module KAT_OTP (
+    tests,
+)
 where
 
-import Crypto.Hash.Algorithms (SHA1(..), SHA256(..), SHA512(..))
+import Crypto.Hash.Algorithms (SHA1 (..), SHA256 (..), SHA512 (..))
 import Crypto.OTP
 import Imports
 
@@ -29,7 +28,7 @@
 -- different (see the errata, or the Java example code).
 totpSHA1Expected :: [(Word64, Word32)]
 totpSHA1Expected =
-    [ (59        , 94287082)
+    [ (59, 94287082)
     , (1111111109, 07081804)
     , (1111111111, 14050471)
     , (1234567890, 89005924)
@@ -39,7 +38,7 @@
 
 totpSHA256Expected :: [(Word64, Word32)]
 totpSHA256Expected =
-    [ (59        , 46119246)
+    [ (59, 46119246)
     , (1111111109, 68084774)
     , (1111111111, 67062674)
     , (1234567890, 91819424)
@@ -49,7 +48,7 @@
 
 totpSHA512Expected :: [(Word64, Word32)]
 totpSHA512Expected =
-    [ (59        , 90693936)
+    [ (59, 90693936)
     , (1111111109, 25091201)
     , (1111111111, 99943326)
     , (1234567890, 93441116)
@@ -57,45 +56,75 @@
     , (20000000000, 47863826)
     ]
 
-otpKey = "12345678901234567890" :: ByteString
-totpSHA256Key = "12345678901234567890123456789012" :: ByteString
-totpSHA512Key = "1234567890123456789012345678901234567890123456789012345678901234" :: ByteString
+otpKey :: ByteString
+otpKey = "12345678901234567890"
 
+totpSHA256Key :: ByteString
+totpSHA256Key = "12345678901234567890123456789012"
+
+totpSHA512Key :: ByteString
+totpSHA512Key =
+    "1234567890123456789012345678901234567890123456789012345678901234"
+
+makeKATs :: (Eq a, Show a) => (t -> a) -> [(t, a)] -> [TestTree]
 makeKATs otp expected = concatMap (makeTest otp) (zip3 is counts otps)
   where
     is :: [Int]
-    is = [1..]
+    is = [1 ..]
 
     counts = map fst expected
-    otps  = map snd expected
+    otps = map snd expected
 
+makeTest :: (Eq a1, Show a2, Show a1) => (t -> a1) -> (a2, t, a1) -> [TestTree]
 makeTest otp (i, count, password) =
     [ testCase (show i) (assertEqual "" password (otp count))
     ]
 
-Right totpSHA1Params = mkTOTPParams SHA1 0 30 OTP8 TwoSteps
-Right totpSHA256Params = mkTOTPParams SHA256 0 30 OTP8 TwoSteps
-Right totpSHA512Params = mkTOTPParams SHA512 0 30 OTP8 TwoSteps
+totpSHA1Params :: TOTPParams SHA1
+totpSHA1Params = case mkTOTPParams SHA1 0 30 OTP8 TwoSteps of
+    Right x -> x
+    _ -> error "totpSHA1Params"
 
+totpSHA256Params :: TOTPParams SHA256
+totpSHA256Params = case mkTOTPParams SHA256 0 30 OTP8 TwoSteps of
+    Right x -> x
+    _ -> error "totpSHA256Params"
+
+totpSHA512Params :: TOTPParams SHA512
+totpSHA512Params = case mkTOTPParams SHA512 0 30 OTP8 TwoSteps of
+    Right x -> x
+    _ -> error "totpSHA512Params"
+
 -- resynching with the expected value should just return the current counter + 1
+prop_resyncExpected :: Word64 -> Word16 -> Bool
 prop_resyncExpected ctr window = resynchronize SHA1 OTP6 window key ctr (otp, []) == Just (ctr + 1)
   where
     key = "1234" :: ByteString
     otp = hotp SHA1 OTP6 key ctr
 
-
-tests = testGroup "OTP"
-    [ testGroup "HOTP"
-        [ testGroup "KATs" (makeKATs (hotp SHA1 OTP6 otpKey) hotpExpected)
-        , testGroup "properties"
-            [ testProperty "resync-expected" prop_resyncExpected
+tests :: TestTree
+tests =
+    testGroup
+        "OTP"
+        [ testGroup
+            "HOTP"
+            [ testGroup "KATs" (makeKATs (hotp SHA1 OTP6 otpKey) hotpExpected)
+            , testGroup
+                "properties"
+                [ testProperty "resync-expected" prop_resyncExpected
+                ]
             ]
-        ]
-    , testGroup "TOTP"
-        [ testGroup "KATs"
-            [ testGroup "SHA1" (makeKATs (totp totpSHA1Params otpKey) totpSHA1Expected)
-            , testGroup "SHA256" (makeKATs (totp totpSHA256Params totpSHA256Key) totpSHA256Expected)
-            , testGroup "SHA512" (makeKATs (totp totpSHA512Params totpSHA512Key) totpSHA512Expected)
+        , testGroup
+            "TOTP"
+            [ testGroup
+                "KATs"
+                [ testGroup "SHA1" (makeKATs (totp totpSHA1Params otpKey) totpSHA1Expected)
+                , testGroup
+                    "SHA256"
+                    (makeKATs (totp totpSHA256Params totpSHA256Key) totpSHA256Expected)
+                , testGroup
+                    "SHA512"
+                    (makeKATs (totp totpSHA512Params totpSHA512Key) totpSHA512Expected)
+                ]
             ]
         ]
-    ]
diff --git a/tests/KAT_PBKDF2.hs b/tests/KAT_PBKDF2.hs
--- a/tests/KAT_PBKDF2.hs
+++ b/tests/KAT_PBKDF2.hs
@@ -3,7 +3,7 @@
 -- from <http://www.ietf.org/rfc/rfc6070.txt>
 module KAT_PBKDF2 (tests) where
 
-import Crypto.Hash (SHA1(..), SHA256(..), SHA512(..))
+import Crypto.Hash (SHA1 (..), SHA256 (..), SHA512 (..))
 import qualified Crypto.KDF.PBKDF2 as PBKDF2
 
 import Data.ByteString (ByteString)
@@ -14,76 +14,101 @@
 
 type VectParams = (ByteString, ByteString, Int, Int)
 
-vectors_hmac_sha1 :: [ (VectParams, ByteString) ]
+vectors_hmac_sha1 :: [(VectParams, ByteString)]
 vectors_hmac_sha1 =
     [
-        ( ("password","salt",2,20)
+        ( ("password", "salt", 2, 20)
         , "\xea\x6c\x01\x4d\xc7\x2d\x6f\x8c\xcd\x1e\xd9\x2a\xce\x1d\x41\xf0\xd8\xde\x89\x57"
         )
-    ,   ( ("password","salt",4096,20)
+    ,
+        ( ("password", "salt", 4096, 20)
         , "\x4b\x00\x79\x01\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26\xf7\x21\xd0\x65\xa4\x29\xc1"
         )
-
-    ,   ( ("passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt", 4096, 25)
+    ,
+        ( ("passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt", 4096, 25)
         , "\x3d\x2e\xec\x4f\xe4\x1c\x84\x9b\x80\xc8\xd8\x36\x62\xc0\xe4\x4a\x8b\x29\x1a\x96\x4c\xf2\xf0\x70\x38"
         )
-    ,   ( ("pass\0word", "sa\0lt", 4096, 16)
+    ,
+        ( ("pass\0word", "sa\0lt", 4096, 16)
         , "\x56\xfa\x6a\xa7\x55\x48\x09\x9d\xcc\x37\xd7\xf0\x34\x25\xe0\xc3"
         )
     ]
 
-vectors_hmac_sha256 :: [ (VectParams, ByteString) ]
+vectors_hmac_sha256 :: [(VectParams, ByteString)]
 vectors_hmac_sha256 =
-    [   ( ("password", "salt", 2, 32)
+    [
+        ( ("password", "salt", 2, 32)
         , "\xae\x4d\x0c\x95\xaf\x6b\x46\xd3\x2d\x0a\xdf\xf9\x28\xf0\x6d\xd0\x2a\x30\x3f\x8e\xf3\xc2\x51\xdf\xd6\xe2\xd8\x5a\x95\x47\x4c\x43"
         )
-    ,   ( ("passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt", 4096, 40)
+    ,
+        ( ("passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt", 4096, 40)
         , "\x34\x8c\x89\xdb\xcb\xd3\x2b\x2f\x32\xd8\x14\xb8\x11\x6e\x84\xcf\x2b\x17\x34\x7e\xbc\x18\x00\x18\x1c\x4e\x2a\x1f\xb8\xdd\x53\xe1\xc6\x35\x51\x8c\x7d\xac\x47\xe9"
         )
     ]
 
-vectors_hmac_sha512 :: [ (VectParams, ByteString) ]
+vectors_hmac_sha512 :: [(VectParams, ByteString)]
 vectors_hmac_sha512 =
-    [   ( ("password", "salt", 1, 32)
+    [
+        ( ("password", "salt", 1, 32)
         , "\x86\x7f\x70\xcf\x1a\xde\x02\xcf\xf3\x75\x25\x99\xa3\xa5\x3d\xc4\xaf\x34\xc7\xa6\x69\x81\x5a\xe5\xd5\x13\x55\x4e\x1c\x8c\xf2\x52"
         )
-    ,   ( ("password", "salt", 2, 32)
-        ,  "\xe1\xd9\xc1\x6a\xa6\x81\x70\x8a\x45\xf5\xc7\xc4\xe2\x15\xce\xb6\x6e\x01\x1a\x2e\x9f\x00\x40\x71\x3f\x18\xae\xfd\xb8\x66\xd5\x3c"
+    ,
+        ( ("password", "salt", 2, 32)
+        , "\xe1\xd9\xc1\x6a\xa6\x81\x70\x8a\x45\xf5\xc7\xc4\xe2\x15\xce\xb6\x6e\x01\x1a\x2e\x9f\x00\x40\x71\x3f\x18\xae\xfd\xb8\x66\xd5\x3c"
         )
-    ,   ( ("password", "salt", 4096, 32)
-        ,  "\xd1\x97\xb1\xb3\x3d\xb0\x14\x3e\x01\x8b\x12\xf3\xd1\xd1\x47\x9e\x6c\xde\xbd\xcc\x97\xc5\xc0\xf8\x7f\x69\x02\xe0\x72\xf4\x57\xb5"
+    ,
+        ( ("password", "salt", 4096, 32)
+        , "\xd1\x97\xb1\xb3\x3d\xb0\x14\x3e\x01\x8b\x12\xf3\xd1\xd1\x47\x9e\x6c\xde\xbd\xcc\x97\xc5\xc0\xf8\x7f\x69\x02\xe0\x72\xf4\x57\xb5"
         )
-    ,   ( ("passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt", 1, 72)
+    ,
+        ( ("passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt", 1, 72)
         , "n\x23\xf2\x76\x38\x08\x4b\x0f\x7e\xa1\x73\x4e\x0d\x98\x41\xf5\x5d\xd2\x9e\xa6\x0a\x83\x44\x66\xf3\x39\x6b\xac\x80\x1f\xac\x1e\xeb\x63\x80\x2f\x03\xa0\xb4\xac\xd7\x60\x3e\x36\x99\xc8\xb7\x44\x37\xbe\x83\xff\x01\xad\x7f\x55\xda\xc1\xef\x60\xf4\xd5\x64\x80\xc3\x5e\xe6\x8f\xd5\x2c\x69\x36"
         )
     ]
 
-
-tests = testGroup "PBKDF2"
-    [ testGroup "KATs-HMAC-SHA1" (katTests (PBKDF2.prfHMAC SHA1) vectors_hmac_sha1)
-    , testGroup "KATs-HMAC-SHA1 (fast)" (katTestFastPBKDF2_SHA1 vectors_hmac_sha1)
-    , testGroup "KATs-HMAC-SHA256" (katTests (PBKDF2.prfHMAC SHA256) vectors_hmac_sha256)
-    , testGroup "KATs-HMAC-SHA256 (fast)" (katTestFastPBKDF2_SHA256 vectors_hmac_sha256)
-    , testGroup "KATs-HMAC-SHA512" (katTests (PBKDF2.prfHMAC SHA512) vectors_hmac_sha512)
-    , testGroup "KATs-HMAC-SHA512 (fast)" (katTestFastPBKDF2_SHA512 vectors_hmac_sha512)
-    ]
-  where katTests prf = zipWith (toKatTest prf) is
-
-        toKatTest prf i ((pass, salt, iter, dkLen), output) =
-            testCase (show i) (output @=? PBKDF2.generate prf (PBKDF2.Parameters iter dkLen) pass salt)
+tests =
+    testGroup
+        "PBKDF2"
+        [ testGroup "KATs-HMAC-SHA1" (katTests (PBKDF2.prfHMAC SHA1) vectors_hmac_sha1)
+        , testGroup "KATs-HMAC-SHA1 (fast)" (katTestFastPBKDF2_SHA1 vectors_hmac_sha1)
+        , testGroup
+            "KATs-HMAC-SHA256"
+            (katTests (PBKDF2.prfHMAC SHA256) vectors_hmac_sha256)
+        , testGroup
+            "KATs-HMAC-SHA256 (fast)"
+            (katTestFastPBKDF2_SHA256 vectors_hmac_sha256)
+        , testGroup
+            "KATs-HMAC-SHA512"
+            (katTests (PBKDF2.prfHMAC SHA512) vectors_hmac_sha512)
+        , testGroup
+            "KATs-HMAC-SHA512 (fast)"
+            (katTestFastPBKDF2_SHA512 vectors_hmac_sha512)
+        ]
+  where
+    katTests prf = zipWith (toKatTest prf) is
 
-        katTestFastPBKDF2_SHA1 = zipWith toKatTestFastPBKDF2_SHA1 is
-        toKatTestFastPBKDF2_SHA1 i ((pass, salt, iter, dkLen), output) =
-            testCase (show i) (output @=? PBKDF2.fastPBKDF2_SHA1 (PBKDF2.Parameters iter dkLen) pass salt)
+    toKatTest prf i ((pass, salt, iter, dkLen), output) =
+        testCase
+            (show i)
+            (output @=? PBKDF2.generate prf (PBKDF2.Parameters iter dkLen) pass salt)
 
-        katTestFastPBKDF2_SHA256 = zipWith toKatTestFastPBKDF2_SHA256 is
-        toKatTestFastPBKDF2_SHA256 i ((pass, salt, iter, dkLen), output) =
-            testCase (show i) (output @=? PBKDF2.fastPBKDF2_SHA256 (PBKDF2.Parameters iter dkLen) pass salt)
+    katTestFastPBKDF2_SHA1 = zipWith toKatTestFastPBKDF2_SHA1 is
+    toKatTestFastPBKDF2_SHA1 i ((pass, salt, iter, dkLen), output) =
+        testCase
+            (show i)
+            (output @=? PBKDF2.fastPBKDF2_SHA1 (PBKDF2.Parameters iter dkLen) pass salt)
 
-        katTestFastPBKDF2_SHA512 = zipWith toKatTestFastPBKDF2_SHA512 is
-        toKatTestFastPBKDF2_SHA512 i ((pass, salt, iter, dkLen), output) =
-            testCase (show i) (output @=? PBKDF2.fastPBKDF2_SHA512 (PBKDF2.Parameters iter dkLen) pass salt)
+    katTestFastPBKDF2_SHA256 = zipWith toKatTestFastPBKDF2_SHA256 is
+    toKatTestFastPBKDF2_SHA256 i ((pass, salt, iter, dkLen), output) =
+        testCase
+            (show i)
+            (output @=? PBKDF2.fastPBKDF2_SHA256 (PBKDF2.Parameters iter dkLen) pass salt)
 
+    katTestFastPBKDF2_SHA512 = zipWith toKatTestFastPBKDF2_SHA512 is
+    toKatTestFastPBKDF2_SHA512 i ((pass, salt, iter, dkLen), output) =
+        testCase
+            (show i)
+            (output @=? PBKDF2.fastPBKDF2_SHA512 (PBKDF2.Parameters iter dkLen) pass salt)
 
-        is :: [Int]
-        is = [1..]
+    is :: [Int]
+    is = [1 ..]
diff --git a/tests/KAT_PubKey.hs b/tests/KAT_PubKey.hs
--- a/tests/KAT_PubKey.hs
+++ b/tests/KAT_PubKey.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_PubKey (tests) where
 
 import Test.Tasty
@@ -8,43 +9,49 @@
 import qualified Data.ByteString as B
 import Data.ByteString.Char8 ()
 
-import Crypto.PubKey.MaskGenFunction
 import Crypto.Hash
+import Crypto.PubKey.MaskGenFunction
 
-import KAT_PubKey.OAEP
-import KAT_PubKey.PSS
 import KAT_PubKey.DSA
 import KAT_PubKey.ECC
 import KAT_PubKey.ECDSA
+import KAT_PubKey.OAEP
+import qualified KAT_PubKey.P256 as P256
+import KAT_PubKey.PSS
 import KAT_PubKey.RSA
 import KAT_PubKey.Rabin
 import Utils
-import qualified KAT_PubKey.P256 as P256
 
-data VectorMgf = VectorMgf { seed :: ByteString
-                           , dbMask :: ByteString
-                           }
+data VectorMgf = VectorMgf
+    { seed :: ByteString
+    , dbMask :: ByteString
+    }
 
 doMGFTest i vmgf = testCase (show i) (dbMask vmgf @=? actual)
-    where actual = mgf1 SHA1 (seed vmgf) (B.length $ dbMask vmgf)
+  where
+    actual = mgf1 SHA1 (seed vmgf) (B.length $ dbMask vmgf)
 
 vectorsMGF =
     [ VectorMgf
-        { seed = "\xdf\x1a\x89\x6f\x9d\x8b\xc8\x16\xd9\x7c\xd7\xa2\xc4\x3b\xad\x54\x6f\xbe\x8c\xfe"
-        , dbMask = "\x66\xe4\x67\x2e\x83\x6a\xd1\x21\xba\x24\x4b\xed\x65\x76\xb8\x67\xd9\xa4\x47\xc2\x8a\x6e\x66\xa5\xb8\x7d\xee\x7f\xbc\x7e\x65\xaf\x50\x57\xf8\x6f\xae\x89\x84\xd9\xba\x7f\x96\x9a\xd6\xfe\x02\xa4\xd7\x5f\x74\x45\xfe\xfd\xd8\x5b\x6d\x3a\x47\x7c\x28\xd2\x4b\xa1\xe3\x75\x6f\x79\x2d\xd1\xdc\xe8\xca\x94\x44\x0e\xcb\x52\x79\xec\xd3\x18\x3a\x31\x1f\xc8\x97\x39\xa9\x66\x43\x13\x6e\x8b\x0f\x46\x5e\x87\xa4\x53\x5c\xd4\xc5\x9b\x10\x02\x8d"
+        { seed =
+            "\xdf\x1a\x89\x6f\x9d\x8b\xc8\x16\xd9\x7c\xd7\xa2\xc4\x3b\xad\x54\x6f\xbe\x8c\xfe"
+        , dbMask =
+            "\x66\xe4\x67\x2e\x83\x6a\xd1\x21\xba\x24\x4b\xed\x65\x76\xb8\x67\xd9\xa4\x47\xc2\x8a\x6e\x66\xa5\xb8\x7d\xee\x7f\xbc\x7e\x65\xaf\x50\x57\xf8\x6f\xae\x89\x84\xd9\xba\x7f\x96\x9a\xd6\xfe\x02\xa4\xd7\x5f\x74\x45\xfe\xfd\xd8\x5b\x6d\x3a\x47\x7c\x28\xd2\x4b\xa1\xe3\x75\x6f\x79\x2d\xd1\xdc\xe8\xca\x94\x44\x0e\xcb\x52\x79\xec\xd3\x18\x3a\x31\x1f\xc8\x97\x39\xa9\x66\x43\x13\x6e\x8b\x0f\x46\x5e\x87\xa4\x53\x5c\xd4\xc5\x9b\x10\x02\x8d"
         }
     ]
 
-tests = testGroup "PubKey"
-    [ testGroup "MGF1" $ zipWith doMGFTest [katZero..] vectorsMGF
-    , rsaTests
-    , pssTests
-    , oaepTests
-    , dsaTests
-    , eccTests
-    , ecdsaTests
-    , P256.tests
-    , rabinTests
-    ]
+tests =
+    testGroup
+        "PubKey"
+        [ testGroup "MGF1" $ zipWith doMGFTest [katZero ..] vectorsMGF
+        , rsaTests
+        , pssTests
+        , oaepTests
+        , dsaTests
+        , eccTests
+        , ecdsaTests
+        , P256.tests
+        , rabinTests
+        ]
 
---newKats = [ eccKatTests ]
+-- newKats = [ eccKatTests ]
diff --git a/tests/KAT_PubKey/DSA.hs b/tests/KAT_PubKey/DSA.hs
--- a/tests/KAT_PubKey/DSA.hs
+++ b/tests/KAT_PubKey/DSA.hs
@@ -1,8 +1,9 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_PubKey.DSA (dsaTests) where
 
-import qualified Crypto.PubKey.DSA as DSA
 import Crypto.Hash
+import qualified Crypto.PubKey.DSA as DSA
 
 import Imports
 
@@ -18,90 +19,110 @@
 
 vectorsSHA1 =
     [ VectorDSA
-        { msg = "\x3b\x46\x73\x6d\x55\x9b\xd4\xe0\xc2\xc1\xb2\x55\x3a\x33\xad\x3c\x6c\xf2\x3c\xac\x99\x8d\x3d\x0c\x0e\x8f\xa4\xb1\x9b\xca\x06\xf2\xf3\x86\xdb\x2d\xcf\xf9\xdc\xa4\xf4\x0a\xd8\xf5\x61\xff\xc3\x08\xb4\x6c\x5f\x31\xa7\x73\x5b\x5f\xa7\xe0\xf9\xe6\xcb\x51\x2e\x63\xd7\xee\xa0\x55\x38\xd6\x6a\x75\xcd\x0d\x42\x34\xb5\xcc\xf6\xc1\x71\x5c\xca\xaf\x9c\xdc\x0a\x22\x28\x13\x5f\x71\x6e\xe9\xbd\xee\x7f\xc1\x3e\xc2\x7a\x03\xa6\xd1\x1c\x5c\x5b\x36\x85\xf5\x19\x00\xb1\x33\x71\x53\xbc\x6c\x4e\x8f\x52\x92\x0c\x33\xfa\x37\xf4\xe7"
+        { msg =
+            "\x3b\x46\x73\x6d\x55\x9b\xd4\xe0\xc2\xc1\xb2\x55\x3a\x33\xad\x3c\x6c\xf2\x3c\xac\x99\x8d\x3d\x0c\x0e\x8f\xa4\xb1\x9b\xca\x06\xf2\xf3\x86\xdb\x2d\xcf\xf9\xdc\xa4\xf4\x0a\xd8\xf5\x61\xff\xc3\x08\xb4\x6c\x5f\x31\xa7\x73\x5b\x5f\xa7\xe0\xf9\xe6\xcb\x51\x2e\x63\xd7\xee\xa0\x55\x38\xd6\x6a\x75\xcd\x0d\x42\x34\xb5\xcc\xf6\xc1\x71\x5c\xca\xaf\x9c\xdc\x0a\x22\x28\x13\x5f\x71\x6e\xe9\xbd\xee\x7f\xc1\x3e\xc2\x7a\x03\xa6\xd1\x1c\x5c\x5b\x36\x85\xf5\x19\x00\xb1\x33\x71\x53\xbc\x6c\x4e\x8f\x52\x92\x0c\x33\xfa\x37\xf4\xe7"
         , x = 0xc53eae6d45323164c7d07af5715703744a63fc3a
-        , y = 0x313fd9ebca91574e1c2eebe1517c57e0c21b0209872140c5328761bbb2450b33f1b18b409ce9ab7c4cd8fda3391e8e34868357c199e16a6b2eba06d6749def791d79e95d3a4d09b24c392ad89dbf100995ae19c01062056bb14bce005e8731efde175f95b975089bdcdaea562b32786d96f5a31aedf75364008ad4fffebb970b
+        , y =
+            0x313fd9ebca91574e1c2eebe1517c57e0c21b0209872140c5328761bbb2450b33f1b18b409ce9ab7c4cd8fda3391e8e34868357c199e16a6b2eba06d6749def791d79e95d3a4d09b24c392ad89dbf100995ae19c01062056bb14bce005e8731efde175f95b975089bdcdaea562b32786d96f5a31aedf75364008ad4fffebb970b
         , k = 0x98cbcc4969d845e2461b5f66383dd503712bbcfa
         , r = 0x50ed0e810e3f1c7cb6ac62332058448bd8b284c0
         , s = 0xc6aded17216b46b7e4b6f2a97c1ad7cc3da83fde
         , pgq = dsaParams
         }
     , VectorDSA
-        { msg = "\xd2\xbc\xb5\x3b\x04\x4b\x3e\x2e\x4b\x61\xba\x2f\x91\xc0\x99\x5f\xb8\x3a\x6a\x97\x52\x5e\x66\x44\x1a\x3b\x48\x9d\x95\x94\x23\x8b\xc7\x40\xbd\xee\xa0\xf7\x18\xa7\x69\xc9\x77\xe2\xde\x00\x38\x77\xb5\xd7\xdc\x25\xb1\x82\xae\x53\x3d\xb3\x3e\x78\xf2\xc3\xff\x06\x45\xf2\x13\x7a\xbc\x13\x7d\x4e\x7d\x93\xcc\xf2\x4f\x60\xb1\x8a\x82\x0b\xc0\x7c\x7b\x4b\x5f\xe0\x8b\x4f\x9e\x7d\x21\xb2\x56\xc1\x8f\x3b\x9d\x49\xac\xc4\xf9\x3e\x2c\xe6\xf3\x75\x4c\x78\x07\x75\x7d\x2e\x11\x76\x04\x26\x12\xcb\x32\xfc\x3f\x4f\x70\x70\x0e\x25"
+        { msg =
+            "\xd2\xbc\xb5\x3b\x04\x4b\x3e\x2e\x4b\x61\xba\x2f\x91\xc0\x99\x5f\xb8\x3a\x6a\x97\x52\x5e\x66\x44\x1a\x3b\x48\x9d\x95\x94\x23\x8b\xc7\x40\xbd\xee\xa0\xf7\x18\xa7\x69\xc9\x77\xe2\xde\x00\x38\x77\xb5\xd7\xdc\x25\xb1\x82\xae\x53\x3d\xb3\x3e\x78\xf2\xc3\xff\x06\x45\xf2\x13\x7a\xbc\x13\x7d\x4e\x7d\x93\xcc\xf2\x4f\x60\xb1\x8a\x82\x0b\xc0\x7c\x7b\x4b\x5f\xe0\x8b\x4f\x9e\x7d\x21\xb2\x56\xc1\x8f\x3b\x9d\x49\xac\xc4\xf9\x3e\x2c\xe6\xf3\x75\x4c\x78\x07\x75\x7d\x2e\x11\x76\x04\x26\x12\xcb\x32\xfc\x3f\x4f\x70\x70\x0e\x25"
         , x = 0xe65131d73470f6ad2e5878bdc9bef536faf78831
-        , y = 0x29bdd759aaa62d4bf16b4861c81cf42eac2e1637b9ecba512bdbc13ac12a80ae8de2526b899ae5e4a231aef884197c944c732693a634d7659abc6975a773f8d3cd5a361fe2492386a3c09aaef12e4a7e73ad7dfc3637f7b093f2c40d6223a195c136adf2ea3fbf8704a675aa7817aa7ec7f9adfb2854d4e05c3ce7f76560313b
+        , y =
+            0x29bdd759aaa62d4bf16b4861c81cf42eac2e1637b9ecba512bdbc13ac12a80ae8de2526b899ae5e4a231aef884197c944c732693a634d7659abc6975a773f8d3cd5a361fe2492386a3c09aaef12e4a7e73ad7dfc3637f7b093f2c40d6223a195c136adf2ea3fbf8704a675aa7817aa7ec7f9adfb2854d4e05c3ce7f76560313b
         , k = 0x87256a64e98cf5be1034ecfa766f9d25d1ac7ceb
         , r = 0xa26c00b5750a2d27fe7435b93476b35438b4d8ab
         , s = 0x61c9bfcb2938755afa7dad1d1e07c6288617bf70
         , pgq = dsaParams
         }
     , VectorDSA
-        { msg = "\xd5\x43\x1e\x6b\x16\xfd\xae\x31\x48\x17\x42\xbd\x39\x47\x58\xbe\xb8\xe2\x4f\x31\x94\x7e\x19\xb7\xea\x7b\x45\x85\x21\x88\x22\x70\xc1\xf4\x31\x92\xaa\x05\x0f\x44\x85\x14\x5a\xf8\xf3\xf9\xc5\x14\x2d\x68\xb8\x50\x18\xd2\xec\x9c\xb7\xa3\x7b\xa1\x2e\xd2\x3e\x73\xb9\x5f\xd6\x80\xfb\xa3\xc6\x12\x65\xe9\xf5\xa0\xa0\x27\xd7\x0f\xad\x0c\x8a\xa0\x8a\x3c\xbf\xbe\x99\x01\x8d\x00\x45\x38\x61\x73\xe5\xfa\xe2\x25\xfa\xeb\xe0\xce\xf5\xdd\x45\x91\x0f\x40\x0a\x86\xc2\xbe\x4e\x15\x25\x2a\x16\xde\x41\x20\xa2\x67\xbe\x2b\x59\x4d"
+        { msg =
+            "\xd5\x43\x1e\x6b\x16\xfd\xae\x31\x48\x17\x42\xbd\x39\x47\x58\xbe\xb8\xe2\x4f\x31\x94\x7e\x19\xb7\xea\x7b\x45\x85\x21\x88\x22\x70\xc1\xf4\x31\x92\xaa\x05\x0f\x44\x85\x14\x5a\xf8\xf3\xf9\xc5\x14\x2d\x68\xb8\x50\x18\xd2\xec\x9c\xb7\xa3\x7b\xa1\x2e\xd2\x3e\x73\xb9\x5f\xd6\x80\xfb\xa3\xc6\x12\x65\xe9\xf5\xa0\xa0\x27\xd7\x0f\xad\x0c\x8a\xa0\x8a\x3c\xbf\xbe\x99\x01\x8d\x00\x45\x38\x61\x73\xe5\xfa\xe2\x25\xfa\xeb\xe0\xce\xf5\xdd\x45\x91\x0f\x40\x0a\x86\xc2\xbe\x4e\x15\x25\x2a\x16\xde\x41\x20\xa2\x67\xbe\x2b\x59\x4d"
         , x = 0x20bcabc6d9347a6e79b8e498c60c44a19c73258c
-        , y = 0x23b4f404aa3c575e550bb320fdb1a085cd396a10e5ebc6771da62f037cab19eacd67d8222b6344038c4f7af45f5e62b55480cbe2111154ca9697ca76d87b56944138084e74c6f90a05cf43660dff8b8b3fabfcab3f0e4416775fdf40055864be102b4587392e77752ed2aeb182ee4f70be4a291dbe77b84a44ee34007957b1e0
+        , y =
+            0x23b4f404aa3c575e550bb320fdb1a085cd396a10e5ebc6771da62f037cab19eacd67d8222b6344038c4f7af45f5e62b55480cbe2111154ca9697ca76d87b56944138084e74c6f90a05cf43660dff8b8b3fabfcab3f0e4416775fdf40055864be102b4587392e77752ed2aeb182ee4f70be4a291dbe77b84a44ee34007957b1e0
         , k = 0x7d9bcfc9225432de9860f605a38d389e291ca750
         , r = 0x3f0a4ad32f0816821b8affb518e9b599f35d57c2
         , s = 0xea06638f2b2fc9d1dfe99c2a492806b497e2b0ea
         , pgq = dsaParams
         }
     , VectorDSA
-        { msg = "\x85\x66\x2b\x69\x75\x50\xe4\x91\x5c\x29\xe3\x38\xb6\x24\xb9\x12\x84\x5d\x6d\x1a\x92\x0d\x9e\x4c\x16\x04\xdd\x47\xd6\x92\xbc\x7c\x0f\xfb\x95\xae\x61\x4e\x85\x2b\xeb\xaf\x15\x73\x75\x8a\xd0\x1c\x71\x3c\xac\x0b\x47\x6e\x2f\x12\x17\x45\xa3\xcf\xee\xff\xb2\x44\x1f\xf6\xab\xfb\x9b\xbe\xb9\x8a\xa6\x34\xca\x6f\xf5\x41\x94\x7d\xcc\x99\x27\x65\x9d\x44\xf9\x5c\x5f\xf9\x17\x0f\xdc\x3c\x86\x47\x3c\xb6\x01\xba\x31\xb4\x87\xfe\x59\x36\xba\xc5\xd9\xc6\x32\xcb\xcc\x3d\xb0\x62\x46\xba\x01\xc5\x5a\x03\x8d\x79\x7f\xe3\xf6\xc3"
+        { msg =
+            "\x85\x66\x2b\x69\x75\x50\xe4\x91\x5c\x29\xe3\x38\xb6\x24\xb9\x12\x84\x5d\x6d\x1a\x92\x0d\x9e\x4c\x16\x04\xdd\x47\xd6\x92\xbc\x7c\x0f\xfb\x95\xae\x61\x4e\x85\x2b\xeb\xaf\x15\x73\x75\x8a\xd0\x1c\x71\x3c\xac\x0b\x47\x6e\x2f\x12\x17\x45\xa3\xcf\xee\xff\xb2\x44\x1f\xf6\xab\xfb\x9b\xbe\xb9\x8a\xa6\x34\xca\x6f\xf5\x41\x94\x7d\xcc\x99\x27\x65\x9d\x44\xf9\x5c\x5f\xf9\x17\x0f\xdc\x3c\x86\x47\x3c\xb6\x01\xba\x31\xb4\x87\xfe\x59\x36\xba\xc5\xd9\xc6\x32\xcb\xcc\x3d\xb0\x62\x46\xba\x01\xc5\x5a\x03\x8d\x79\x7f\xe3\xf6\xc3"
         , x = 0x52d1fbe687aa0702a51a5bf9566bd51bd569424c
-        , y = 0x6bc36cb3fa61cecc157be08639a7ca9e3de073b8a0ff23574ce5ab0a867dfd60669a56e60d1c989b3af8c8a43f5695d503e3098963990e12b63566784171058eace85c728cd4c08224c7a6efea75dca20df461013c75f40acbc23799ebee7f3361336dadc4a56f305708667bfe602b8ea75a491a5cf0c06ebd6fdc7161e10497
+        , y =
+            0x6bc36cb3fa61cecc157be08639a7ca9e3de073b8a0ff23574ce5ab0a867dfd60669a56e60d1c989b3af8c8a43f5695d503e3098963990e12b63566784171058eace85c728cd4c08224c7a6efea75dca20df461013c75f40acbc23799ebee7f3361336dadc4a56f305708667bfe602b8ea75a491a5cf0c06ebd6fdc7161e10497
         , k = 0x960c211891c090d05454646ebac1bfe1f381e82b
         , r = 0x3bc29dee96957050ba438d1b3e17b02c1725d229
         , s = 0x0af879cf846c434e08fb6c63782f4d03e0d88865
         , pgq = dsaParams
         }
     , VectorDSA
-        { msg = "\x87\xb6\xe7\x5b\x9f\x8e\x99\xc4\xdd\x62\xad\xb6\x93\xdd\x58\x90\xed\xff\x1b\xd0\x02\x8f\x4e\xf8\x49\xdf\x0f\x1d\x2c\xe6\xb1\x81\xfc\x3a\x55\xae\xa6\xd0\xa1\xf0\xae\xca\xb8\xed\x9e\x24\x8a\x00\xe9\x6b\xe7\x94\xa7\xcf\xba\x12\x46\xef\xb7\x10\xef\x4b\x37\x47\x1c\xef\x0a\x1b\xcf\x55\xce\xbc\x8d\x5a\xd0\x71\x61\x2b\xd2\x37\xef\xed\xd5\x10\x23\x62\xdb\x07\xa1\xe2\xc7\xa6\xf1\x5e\x09\xfe\x64\xba\x42\xb6\x0a\x26\x28\xd8\x69\xae\x05\xef\x61\x1f\xe3\x8d\x9c\xe1\x5e\xee\xc9\xbb\x3d\xec\xc8\xdc\x17\x80\x9f\x3b\x6e\x95"
+        { msg =
+            "\x87\xb6\xe7\x5b\x9f\x8e\x99\xc4\xdd\x62\xad\xb6\x93\xdd\x58\x90\xed\xff\x1b\xd0\x02\x8f\x4e\xf8\x49\xdf\x0f\x1d\x2c\xe6\xb1\x81\xfc\x3a\x55\xae\xa6\xd0\xa1\xf0\xae\xca\xb8\xed\x9e\x24\x8a\x00\xe9\x6b\xe7\x94\xa7\xcf\xba\x12\x46\xef\xb7\x10\xef\x4b\x37\x47\x1c\xef\x0a\x1b\xcf\x55\xce\xbc\x8d\x5a\xd0\x71\x61\x2b\xd2\x37\xef\xed\xd5\x10\x23\x62\xdb\x07\xa1\xe2\xc7\xa6\xf1\x5e\x09\xfe\x64\xba\x42\xb6\x0a\x26\x28\xd8\x69\xae\x05\xef\x61\x1f\xe3\x8d\x9c\xe1\x5e\xee\xc9\xbb\x3d\xec\xc8\xdc\x17\x80\x9f\x3b\x6e\x95"
         , x = 0xc86a54ec5c4ec63d7332cf43ddb082a34ed6d5f5
-        , y = 0x014ac746d3605efcb8a2c7dae1f54682a262e27662b252c09478ce87d0aaa522d7c200043406016c0c42896d21750b15dbd57f9707ec37dcea5651781b67ad8d01f5099fe7584b353b641bb159cc717d8ceb18b66705e656f336f1214b34f0357e577ab83641969e311bf40bdcb3ffd5e0bb59419f229508d2f432cc2859ff75
+        , y =
+            0x014ac746d3605efcb8a2c7dae1f54682a262e27662b252c09478ce87d0aaa522d7c200043406016c0c42896d21750b15dbd57f9707ec37dcea5651781b67ad8d01f5099fe7584b353b641bb159cc717d8ceb18b66705e656f336f1214b34f0357e577ab83641969e311bf40bdcb3ffd5e0bb59419f229508d2f432cc2859ff75
         , k = 0x6c445cee68042553fbe63be61be4ddb99d8134af
         , r = 0x637e07a5770f3dc65e4506c68c770e5ef6b8ced3
         , s = 0x7dfc6f83e24f09745e01d3f7ae0ed1474e811d47
         , pgq = dsaParams
         }
     , VectorDSA
-        { msg = "\x22\x59\xee\xad\x2d\x6b\xbc\x76\xd4\x92\x13\xea\x0d\xc8\xb7\x35\x0a\x97\x69\x9f\x22\x34\x10\x44\xc3\x94\x07\x82\x36\x4a\xc9\xea\x68\x31\x79\xa4\x38\xa5\xea\x45\x99\x8d\xf9\x7c\x29\x72\xda\xe0\x38\x51\xf5\xbe\x23\xfa\x9f\x04\x18\x2e\x79\xdd\xb2\xb5\x6d\xc8\x65\x23\x93\xec\xb2\x7f\x3f\x3b\x7c\x8a\x8d\x76\x1a\x86\xb3\xb8\xf4\xd4\x1a\x07\xb4\xbe\x7d\x02\xfd\xde\xfc\x42\xb9\x28\x12\x4a\x5a\x45\xb9\xf4\x60\x90\x42\x20\x9b\x3a\x7f\x58\x5b\xd5\x14\xcc\x39\xc0\x0e\xff\xcc\x42\xc7\xfe\x70\xfa\x83\xed\xf8\xa3\x2b\xf4"
+        { msg =
+            "\x22\x59\xee\xad\x2d\x6b\xbc\x76\xd4\x92\x13\xea\x0d\xc8\xb7\x35\x0a\x97\x69\x9f\x22\x34\x10\x44\xc3\x94\x07\x82\x36\x4a\xc9\xea\x68\x31\x79\xa4\x38\xa5\xea\x45\x99\x8d\xf9\x7c\x29\x72\xda\xe0\x38\x51\xf5\xbe\x23\xfa\x9f\x04\x18\x2e\x79\xdd\xb2\xb5\x6d\xc8\x65\x23\x93\xec\xb2\x7f\x3f\x3b\x7c\x8a\x8d\x76\x1a\x86\xb3\xb8\xf4\xd4\x1a\x07\xb4\xbe\x7d\x02\xfd\xde\xfc\x42\xb9\x28\x12\x4a\x5a\x45\xb9\xf4\x60\x90\x42\x20\x9b\x3a\x7f\x58\x5b\xd5\x14\xcc\x39\xc0\x0e\xff\xcc\x42\xc7\xfe\x70\xfa\x83\xed\xf8\xa3\x2b\xf4"
         , x = 0xaee6f213b9903c8069387e64729a08999e5baf65
-        , y = 0x0fe74045d7b0d472411202831d4932396f242a9765e92be387fd81bbe38d845054528b348c03984179b8e505674cb79d88cc0d8d3e8d7392f9aa773b29c29e54a9e326406075d755c291fcedbcc577934c824af988250f64ed5685fce726cff65e92d708ae11cbfaa958ab8d8b15340a29a137b5b4357f7ed1c7a5190cbf98a4
+        , y =
+            0x0fe74045d7b0d472411202831d4932396f242a9765e92be387fd81bbe38d845054528b348c03984179b8e505674cb79d88cc0d8d3e8d7392f9aa773b29c29e54a9e326406075d755c291fcedbcc577934c824af988250f64ed5685fce726cff65e92d708ae11cbfaa958ab8d8b15340a29a137b5b4357f7ed1c7a5190cbf98a4
         , k = 0xe1704bae025942e2e63c6d76bab88da79640073a
         , r = 0x83366ba3fed93dfb38d541203ecbf81c363998e2
         , s = 0x1fe299c36a1332f23bf2e10a6c6a4e0d3cdd2bf4
         , pgq = dsaParams
-        } 
+        }
     , VectorDSA
-        { msg = "\x21\x9e\x8d\xf5\xbf\x88\x15\x90\x43\x0e\xce\x60\x82\x50\xf7\x67\x0d\xc5\x65\x37\x24\x93\x02\x42\x9e\x28\xec\xfe\xb9\xce\xaa\xa5\x49\x10\xa6\x94\x90\xf7\x65\xf3\xdf\x82\xe8\xb0\x1c\xd7\xd7\x6e\x56\x1d\x0f\x6c\xe2\x26\xef\x3c\xf7\x52\xca\xda\x6f\xeb\xdc\x5b\xf0\x0d\x67\x94\x7f\x92\xd4\x20\x51\x6b\x9e\x37\xc9\x6c\x8f\x1f\x2d\xa0\xb0\x75\x09\x7c\x3b\xda\x75\x8a\x8d\x91\xbd\x2e\xbe\x9c\x75\xcf\x14\x7f\x25\x4c\x25\x69\x63\xb3\x3b\x67\xd0\x2b\x6a\xa0\x9e\x7d\x74\x65\xd0\x38\xe5\x01\x95\xec\xe4\x18\x9b\x41\xe7\x68"
+        { msg =
+            "\x21\x9e\x8d\xf5\xbf\x88\x15\x90\x43\x0e\xce\x60\x82\x50\xf7\x67\x0d\xc5\x65\x37\x24\x93\x02\x42\x9e\x28\xec\xfe\xb9\xce\xaa\xa5\x49\x10\xa6\x94\x90\xf7\x65\xf3\xdf\x82\xe8\xb0\x1c\xd7\xd7\x6e\x56\x1d\x0f\x6c\xe2\x26\xef\x3c\xf7\x52\xca\xda\x6f\xeb\xdc\x5b\xf0\x0d\x67\x94\x7f\x92\xd4\x20\x51\x6b\x9e\x37\xc9\x6c\x8f\x1f\x2d\xa0\xb0\x75\x09\x7c\x3b\xda\x75\x8a\x8d\x91\xbd\x2e\xbe\x9c\x75\xcf\x14\x7f\x25\x4c\x25\x69\x63\xb3\x3b\x67\xd0\x2b\x6a\xa0\x9e\x7d\x74\x65\xd0\x38\xe5\x01\x95\xec\xe4\x18\x9b\x41\xe7\x68"
         , x = 0x699f1c07aa458c6786e770b40197235fe49cf21a
-        , y = 0x3a41b0678ff3c4dde20fa39772bac31a2f18bae4bedec9e12ee8e02e30e556b1a136013bef96b0d30b568233dcecc71e485ed75c922afb4d0654e709bee84993792130220e3005fdb06ebdfc0e2df163b5ec424e836465acd6d92e243c86f2b94b26b8d73bd9cf722c757e0b80b0af16f185de70e8ca850b1402d126ea60f309
+        , y =
+            0x3a41b0678ff3c4dde20fa39772bac31a2f18bae4bedec9e12ee8e02e30e556b1a136013bef96b0d30b568233dcecc71e485ed75c922afb4d0654e709bee84993792130220e3005fdb06ebdfc0e2df163b5ec424e836465acd6d92e243c86f2b94b26b8d73bd9cf722c757e0b80b0af16f185de70e8ca850b1402d126ea60f309
         , k = 0x5bbb795bfa5fa72191fed3434a08741410367491
         , r = 0x579761039ae0ddb81106bf4968e320083bbcb947
         , s = 0x503ea15dbac9dedeba917fa8e9f386b93aa30353
         , pgq = dsaParams
-        } 
+        }
     , VectorDSA
-        { msg = "\x2d\xa7\x9d\x06\x78\x85\xeb\x3c\xcf\x5e\x29\x3a\xe3\xb1\xd8\x22\x53\x22\x20\x3a\xbb\x5a\xdf\xde\x3b\x0f\x53\xbb\xe2\x4c\x4f\xe0\x01\x54\x1e\x11\x83\xd8\x70\xa9\x97\xf1\xf9\x46\x01\x00\xb5\xd7\x11\x92\x31\x80\x15\x43\x45\x28\x7a\x02\x14\xcf\x1c\xac\x37\xb7\xa4\x7d\xfb\xb2\xa0\xe8\xce\x49\x16\xf9\x4e\xbd\x6f\xa5\x4e\x31\x5b\x7a\x8e\xb5\xb6\x3c\xd9\x54\xc5\xba\x05\xc1\xbf\x7e\x33\xa4\xe8\xa1\x51\xf3\x2d\x28\x77\xb0\x17\x29\xc1\xad\x0e\x7c\x01\xbb\x8a\xe7\x23\xc9\x95\x18\x38\x03\xe4\x56\x36\x52\x0e\xa3\x8c\xa1"
+        { msg =
+            "\x2d\xa7\x9d\x06\x78\x85\xeb\x3c\xcf\x5e\x29\x3a\xe3\xb1\xd8\x22\x53\x22\x20\x3a\xbb\x5a\xdf\xde\x3b\x0f\x53\xbb\xe2\x4c\x4f\xe0\x01\x54\x1e\x11\x83\xd8\x70\xa9\x97\xf1\xf9\x46\x01\x00\xb5\xd7\x11\x92\x31\x80\x15\x43\x45\x28\x7a\x02\x14\xcf\x1c\xac\x37\xb7\xa4\x7d\xfb\xb2\xa0\xe8\xce\x49\x16\xf9\x4e\xbd\x6f\xa5\x4e\x31\x5b\x7a\x8e\xb5\xb6\x3c\xd9\x54\xc5\xba\x05\xc1\xbf\x7e\x33\xa4\xe8\xa1\x51\xf3\x2d\x28\x77\xb0\x17\x29\xc1\xad\x0e\x7c\x01\xbb\x8a\xe7\x23\xc9\x95\x18\x38\x03\xe4\x56\x36\x52\x0e\xa3\x8c\xa1"
         , x = 0xd6e08c20c82949ddba93ea81eb2fea8c595894dc
-        , y = 0x56f7272210f316c51af8bfc45a421fd4e9b1043853271b7e79f40936f0adcf262a86097aa86e19e6cb5307685d863dba761342db6c973b3849b1e060aca926f41fe07323601062515ae85f3172b8f34899c621d59fa21f73d5ae97a3deb5e840b25a18fd580862fd7b1cf416c7ae9fc5842a0197fdb0c5173ff4a4f102a8cf89
+        , y =
+            0x56f7272210f316c51af8bfc45a421fd4e9b1043853271b7e79f40936f0adcf262a86097aa86e19e6cb5307685d863dba761342db6c973b3849b1e060aca926f41fe07323601062515ae85f3172b8f34899c621d59fa21f73d5ae97a3deb5e840b25a18fd580862fd7b1cf416c7ae9fc5842a0197fdb0c5173ff4a4f102a8cf89
         , k = 0x6d72c30d4430959800740f2770651095d0c181c2
         , r = 0x5dd90d69add67a5fae138eec1aaff0229aa4afc4
         , s = 0x47f39c4db2387f10762f45b80dfd027906d7ef04
         , pgq = dsaParams
-        } 
+        }
     , VectorDSA
-        { msg = "\xba\x30\xd8\x5b\xe3\x57\xe7\xfb\x29\xf8\xa0\x7e\x1f\x12\x7b\xaa\xa2\x4b\x2e\xe0\x27\xf6\x4c\xb5\xef\xee\xc6\xaa\xea\xbc\xc7\x34\x5c\x5d\x55\x6e\xbf\x4b\xdc\x7a\x61\xc7\x7c\x7b\x7e\xa4\x3c\x73\xba\xbc\x18\xf7\xb4\x80\x77\x22\xda\x23\x9e\x45\xdd\xf2\x49\x84\x9c\xbb\xfe\x35\x07\x11\x2e\xbf\x87\xd7\xef\x56\x0c\x2e\x7d\x39\x1e\xd8\x42\x4f\x87\x10\xce\xa4\x16\x85\x14\x3e\x30\x06\xf8\x1b\x68\xfb\xb4\xd5\xf9\x64\x4c\x7c\xd1\x0f\x70\x92\xef\x24\x39\xb8\xd1\x8c\x0d\xf6\x55\xe0\x02\x89\x37\x2a\x41\x66\x38\x5d\x64\x0c"
+        { msg =
+            "\xba\x30\xd8\x5b\xe3\x57\xe7\xfb\x29\xf8\xa0\x7e\x1f\x12\x7b\xaa\xa2\x4b\x2e\xe0\x27\xf6\x4c\xb5\xef\xee\xc6\xaa\xea\xbc\xc7\x34\x5c\x5d\x55\x6e\xbf\x4b\xdc\x7a\x61\xc7\x7c\x7b\x7e\xa4\x3c\x73\xba\xbc\x18\xf7\xb4\x80\x77\x22\xda\x23\x9e\x45\xdd\xf2\x49\x84\x9c\xbb\xfe\x35\x07\x11\x2e\xbf\x87\xd7\xef\x56\x0c\x2e\x7d\x39\x1e\xd8\x42\x4f\x87\x10\xce\xa4\x16\x85\x14\x3e\x30\x06\xf8\x1b\x68\xfb\xb4\xd5\xf9\x64\x4c\x7c\xd1\x0f\x70\x92\xef\x24\x39\xb8\xd1\x8c\x0d\xf6\x55\xe0\x02\x89\x37\x2a\x41\x66\x38\x5d\x64\x0c"
         , x = 0x50018482864c1864e9db1f04bde8dbfd3875c76d
-        , y = 0x0942a5b7a72ab116ead29308cf658dfe3d55d5d61afed9e3836e64237f9d6884fdd827d2d5890c9a41ae88e7a69fc9f345ade9c480c6f08cff067c183214c227236cedb6dd1283ca2a602574e8327510221d4c27b162143b7002d8c726916826265937b87be9d5ec6d7bd28fb015f84e0ab730da7a4eaf4ef3174bf0a22a6392
+        , y =
+            0x0942a5b7a72ab116ead29308cf658dfe3d55d5d61afed9e3836e64237f9d6884fdd827d2d5890c9a41ae88e7a69fc9f345ade9c480c6f08cff067c183214c227236cedb6dd1283ca2a602574e8327510221d4c27b162143b7002d8c726916826265937b87be9d5ec6d7bd28fb015f84e0ab730da7a4eaf4ef3174bf0a22a6392
         , k = 0xdf3a9348f37b5d2d4c9176db266ae388f1fa7e0f
         , r = 0x448434b214eee38bde080f8ec433e8d19b3ddf0d
         , s = 0x0c02e881b777923fe0ea674f2621298e00199d5f
         , pgq = dsaParams
-        } 
+        }
     , VectorDSA
-        { msg = "\x83\x49\x9e\xfb\x06\xbb\x7f\xf0\x2f\xfb\x46\xc2\x78\xa5\xe9\x26\x30\xac\x5b\xc3\xf9\xe5\x3d\xd2\xe7\x8f\xf1\x5e\x36\x8c\x7e\x31\xaa\xd7\x7c\xf7\x71\xf3\x5f\xa0\x2d\x0b\x5f\x13\x52\x08\xa4\xaf\xdd\x86\x7b\xb2\xec\x26\xea\x2e\x7d\xd6\x4c\xde\xf2\x37\x50\x8a\x38\xb2\x7f\x39\xd8\xb2\x2d\x45\xca\xc5\xa6\x8a\x90\xb6\xea\x76\x05\x86\x45\xf6\x35\x6a\x93\x44\xd3\x6f\x00\xec\x66\x52\xea\xa4\xe9\xba\xe7\xb6\x94\xf9\xf1\xfc\x8c\x6c\x5e\x86\xfa\xdc\x7b\x27\xa2\x19\xb5\xc1\xb2\xae\x80\xa7\x25\xe5\xf6\x11\x65\xfe\x2e\xdc"
+        { msg =
+            "\x83\x49\x9e\xfb\x06\xbb\x7f\xf0\x2f\xfb\x46\xc2\x78\xa5\xe9\x26\x30\xac\x5b\xc3\xf9\xe5\x3d\xd2\xe7\x8f\xf1\x5e\x36\x8c\x7e\x31\xaa\xd7\x7c\xf7\x71\xf3\x5f\xa0\x2d\x0b\x5f\x13\x52\x08\xa4\xaf\xdd\x86\x7b\xb2\xec\x26\xea\x2e\x7d\xd6\x4c\xde\xf2\x37\x50\x8a\x38\xb2\x7f\x39\xd8\xb2\x2d\x45\xca\xc5\xa6\x8a\x90\xb6\xea\x76\x05\x86\x45\xf6\x35\x6a\x93\x44\xd3\x6f\x00\xec\x66\x52\xea\xa4\xe9\xba\xe7\xb6\x94\xf9\xf1\xfc\x8c\x6c\x5e\x86\xfa\xdc\x7b\x27\xa2\x19\xb5\xc1\xb2\xae\x80\xa7\x25\xe5\xf6\x11\x65\xfe\x2e\xdc"
         , x = 0xae56f66b0a9405b9cca54c60ec4a3bb5f8be7c3f
-        , y = 0xa01542c3da410dd57930ca724f0f507c4df43d553c7f69459939685941ceb95c7dcc3f175a403b359621c0d4328e98f15f330a63865baf3e7eb1604a0715e16eed64fd14b35d3a534259a6a7ddf888c4dbb5f51bbc6ed339e5bb2a239d5cfe2100ac8e2f9c16e536f25119ab435843af27dc33414a9e4602f96d7c94d6021cec
+        , y =
+            0xa01542c3da410dd57930ca724f0f507c4df43d553c7f69459939685941ceb95c7dcc3f175a403b359621c0d4328e98f15f330a63865baf3e7eb1604a0715e16eed64fd14b35d3a534259a6a7ddf888c4dbb5f51bbc6ed339e5bb2a239d5cfe2100ac8e2f9c16e536f25119ab435843af27dc33414a9e4602f96d7c94d6021cec
         , k = 0x8857ff301ad0169d164fa269977a116e070bac17
         , r = 0x8c2fab489c34672140415d41a65cef1e70192e23
         , s = 0x3df86a9e2efe944a1c7ea9c30cac331d00599a0e
@@ -110,7 +131,8 @@
     , VectorDSA -- 1024-bit example from RFC 6979 with SHA-1
         { msg = "sample"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x7BDB6B0FF756E1BB5D53583EF979082F9AD5BD5B
         , r = 0x2E1A0C2562B2912CAAF89186FB0F42001585DA55
         , s = 0x29EFB6B0AFF2D7A68EB70CA313022253B9A88DF5
@@ -119,7 +141,8 @@
     , VectorDSA -- 1024-bit example from RFC 6979 with SHA-1
         { msg = "test"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x5C842DF4F9E344EE09F056838B42C7A17F4A6433
         , r = 0x42AB2052FD43E123F0607F115052A67DCD9C5C77
         , s = 0x183916B0230D45B9931491D4C6B0BD2FB4AAF088
@@ -128,7 +151,8 @@
     , VectorDSA -- 2048-bit example from RFC 6979 with SHA-1
         { msg = "sample"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0x888FA6F7738A41BDC9846466ABDB8174C0338250AE50CE955CA16230F9CBD53E
         , r = 0x3A1B2DBD7489D6ED7E608FD036C83AF396E290DBD602408E8677DAABD6E7445A
         , s = 0xD26FCBA19FA3E3058FFC02CA1596CDBB6E0D20CB37B06054F7E36DED0CDBBCCF
@@ -137,17 +161,22 @@
     , VectorDSA -- 2048-bit example from RFC 6979 with SHA-1
         { msg = "test"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0x6EEA486F9D41A037B2C640BC5645694FF8FF4B98D066A25F76BE641CCB24BA4F
         , r = 0xC18270A93CFC6063F57A4DFA86024F700D980E4CF4E2CB65A504397273D98EA0
         , s = 0x414F22E5F31A8B6D33295C7539C1C1BA3A6160D7D68D50AC0D3A5BEAC2884FAA
         , pgq = rfc6979Params2048
         }
     ]
-    where -- (p,g,q)
-          dsaParams = DSA.Params
-            { DSA.params_p = 0xa8f9cd201e5e35d892f85f80e4db2599a5676a3b1d4f190330ed3256b26d0e80a0e49a8fffaaad2a24f472d2573241d4d6d6c7480c80b4c67bb4479c15ada7ea8424d2502fa01472e760241713dab025ae1b02e1703a1435f62ddf4ee4c1b664066eb22f2e3bf28bb70a2a76e4fd5ebe2d1229681b5b06439ac9c7e9d8bde283
-            , DSA.params_g = 0x2b3152ff6c62f14622b8f48e59f8af46883b38e79b8c74deeae9df131f8b856e3ad6c8455dab87cc0da8ac973417ce4f7878557d6cdf40b35b4a0ca3eb310c6a95d68ce284ad4e25ea28591611ee08b8444bd64b25f3f7c572410ddfb39cc728b9c936f85f419129869929cdb909a6a3a99bbe089216368171bd0ba81de4fe33
+  where
+    -- (p,g,q)
+    dsaParams =
+        DSA.Params
+            { DSA.params_p =
+                0xa8f9cd201e5e35d892f85f80e4db2599a5676a3b1d4f190330ed3256b26d0e80a0e49a8fffaaad2a24f472d2573241d4d6d6c7480c80b4c67bb4479c15ada7ea8424d2502fa01472e760241713dab025ae1b02e1703a1435f62ddf4ee4c1b664066eb22f2e3bf28bb70a2a76e4fd5ebe2d1229681b5b06439ac9c7e9d8bde283
+            , DSA.params_g =
+                0x2b3152ff6c62f14622b8f48e59f8af46883b38e79b8c74deeae9df131f8b856e3ad6c8455dab87cc0da8ac973417ce4f7878557d6cdf40b35b4a0ca3eb310c6a95d68ce284ad4e25ea28591611ee08b8444bd64b25f3f7c572410ddfb39cc728b9c936f85f419129869929cdb909a6a3a99bbe089216368171bd0ba81de4fe33
             , DSA.params_q = 0xf85f0f83ac4df7ea0cdf8f469bfeeaea14156495
             }
 
@@ -155,7 +184,8 @@
     [ VectorDSA
         { msg = "sample"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x562097C06782D60C3037BA7BE104774344687649
         , r = 0x4BC3B686AEA70145856814A6F1BB53346F02101E
         , s = 0x410697B92295D994D21EDD2F4ADA85566F6F94C1
@@ -164,7 +194,8 @@
     , VectorDSA
         { msg = "test"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x4598B8EFC1A53BC8AECD58D1ABBB0C0C71E67297
         , r = 0x6868E9964E36C1689F6037F91F28D5F2C30610F2
         , s = 0x49CEC3ACDC83018C5BD2674ECAAD35B8CD22940F
@@ -173,7 +204,8 @@
     , VectorDSA
         { msg = "sample"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0xBC372967702082E1AA4FCE892209F71AE4AD25A6DFD869334E6F153BD0C4D806
         , r = 0xDC9F4DEADA8D8FF588E98FED0AB690FFCE858DC8C79376450EB6B76C24537E2C
         , s = 0xA65A9C3BC7BABE286B195D5DA68616DA8D47FA0097F36DD19F517327DC848CEC
@@ -182,7 +214,8 @@
     , VectorDSA
         { msg = "test"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0x06BD4C05ED74719106223BE33F2D95DA6B3B541DAD7BFBD7AC508213B6DA6670
         , r = 0x272ABA31572F6CC55E30BF616B7A265312018DD325BE031BE0CC82AA17870EA3
         , s = 0xE9CC286A52CCE201586722D36D1E917EB96A4EBDB47932F9576AC645B3A60806
@@ -194,7 +227,8 @@
     [ VectorDSA
         { msg = "sample"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x519BA0546D0C39202A7D34D7DFA5E760B318BCFB
         , r = 0x81F2F5850BE5BC123C43F71A3033E9384611C545
         , s = 0x4CDD914B65EB6C66A8AAAD27299BEE6B035F5E89
@@ -203,7 +237,8 @@
     , VectorDSA
         { msg = "test"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x5A67592E8128E03A417B0484410FB72C0B630E1A
         , r = 0x22518C127299B0F6FDC9872B282B9E70D0790812
         , s = 0x6837EC18F150D55DE95B5E29BE7AF5D01E4FE160
@@ -212,7 +247,8 @@
     , VectorDSA
         { msg = "sample"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0x8926A27C40484216F052F4427CFD5647338B7B3939BC6573AF4333569D597C52
         , r = 0xEACE8BDBBE353C432A795D9EC556C6D021F7A03F42C36E9BC87E4AC7932CC809
         , s = 0x7081E175455F9247B812B74583E9E94F9EA79BD640DC962533B0680793A38D53
@@ -221,7 +257,8 @@
     , VectorDSA
         { msg = "test"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0x1D6CE6DDA1C5D37307839CD03AB0A5CBB18E60D800937D67DFB4479AAC8DEAD7
         , r = 0x8190012A1969F9957D56FCCAAD223186F423398D58EF5B3CEFD5A4146A4476F0
         , s = 0x7452A53F7075D417B4B013B278D1BB8BBD21863F5E7B1CEE679CF2188E1AB19E
@@ -233,7 +270,8 @@
     [ VectorDSA
         { msg = "sample"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x95897CD7BBB944AA932DBC579C1C09EB6FCFC595
         , r = 0x07F2108557EE0E3921BC1774F1CA9B410B4CE65A
         , s = 0x54DF70456C86FAC10FAB47C1949AB83F2C6F7595
@@ -242,7 +280,8 @@
     , VectorDSA
         { msg = "test"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x220156B761F6CA5E6C9F1B9CF9C24BE25F98CD89
         , r = 0x854CF929B58D73C3CBFDC421E8D5430CD6DB5E66
         , s = 0x91D0E0F53E22F898D158380676A871A157CDA622
@@ -251,7 +290,8 @@
     , VectorDSA
         { msg = "sample"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0xC345D5AB3DA0A5BCB7EC8F8FB7A7E96069E03B206371EF7D83E39068EC564920
         , r = 0xB2DA945E91858834FD9BF616EBAC151EDBC4B45D27D0DD4A7F6A22739F45C00B
         , s = 0x19048B63D9FD6BCA1D9BAE3664E1BCB97F7276C306130969F63F38FA8319021B
@@ -260,7 +300,8 @@
     , VectorDSA
         { msg = "test"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0x206E61F73DBE1B2DC8BE736B22B079E9DACD974DB00EEBBC5B64CAD39CF9F91C
         , r = 0x239E66DDBE8F8C230A3D071D601B6FFBDFB5901F94D444C6AF56F732BEB954BE
         , s = 0x6BD737513D5E72FE85D1C750E0F73921FE299B945AAD1C802F15C26A43D34961
@@ -272,7 +313,8 @@
     [ VectorDSA
         { msg = "sample"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x09ECE7CA27D0F5A4DD4E556C9DF1D21D28104F8B
         , r = 0x16C3491F9B8C3FBBDD5E7A7B667057F0D8EE8E1B
         , s = 0x02C36A127A7B89EDBB72E4FFBC71DABC7D4FC69C
@@ -281,7 +323,8 @@
     , VectorDSA
         { msg = "test"
         , x = 0x411602CB19A6CCC34494D79D98EF1E7ED5AF25F7
-        , y = 0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
+        , y =
+            0x5DF5E01DED31D0297E274E1691C192FE5868FEF9E19A84776454B100CF16F65392195A38B90523E2542EE61871C0440CB87C322FC4B4D2EC5E1E7EC766E1BE8D4CE935437DC11C3C8FD426338933EBFE739CB3465F4D3668C5E473508253B1E682F65CBDC4FAE93C2EA212390E54905A86E2223170B44EAA7DA5DD9FFCFB7F3B
         , k = 0x65D2C2EEB175E370F28C75BFCDC028D22C7DBE9C
         , r = 0x8EA47E475BA8AC6F2D821DA3BD212D11A3DEB9A0
         , s = 0x7C670C7AD72B6C050C109E1790008097125433E8
@@ -290,7 +333,8 @@
     , VectorDSA
         { msg = "sample"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0x5A12994431785485B3F5F067221517791B85A597B7A9436995C89ED0374668FC
         , r = 0x2016ED092DC5FB669B8EFB3D1F31A91EECB199879BE0CF78F02BA062CB4C942E
         , s = 0xD0C76F84B5F091E141572A639A4FB8C230807EEA7D55C8A154A224400AFF2351
@@ -299,7 +343,8 @@
     , VectorDSA
         { msg = "test"
         , x = 0x69C7548C21D0DFEA6B9A51C9EAD4E27C33D3B3F180316E5BCAB92C933F0E4DBC
-        , y = 0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
+        , y =
+            0x667098C654426C78D7F8201EAC6C203EF030D43605032C2F1FA937E5237DBD949F34A0A2564FE126DC8B715C5141802CE0979C8246463C40E6B6BDAA2513FA611728716C2E4FD53BC95B89E69949D96512E873B9C8F8DFD499CC312882561ADECB31F658E934C0C197F2C4D96B05CBAD67381E7B768891E4DA3843D24D94CDFB5126E9B8BF21E8358EE0E0A30EF13FD6A664C0DCE3731F7FB49A4845A4FD8254687972A2D382599C9BAC4E0ED7998193078913032558134976410B89D2C171D123AC35FD977219597AA7D15C1A9A428E59194F75C721EBCBCFAE44696A499AFA74E04299F132026601638CB87AB79190D4A0986315DA8EEC6561C938996BEADF
         , k = 0xAFF1651E4CD6036D57AA8B2A05CCF1A9D5A40166340ECBBDC55BE10B568AA0AA
         , r = 0x89EC4BB1400ECCFF8E7D9AA515CD1DE7803F2DAFF09693EE7FD1353E90A68307
         , s = 0xC9F0BDABCC0D880BB137A994CC7F3980CE91CC10FAF529FC46565B15CEA854E1
@@ -307,56 +352,83 @@
         }
     ]
 
-rfc6979Params1024 = DSA.Params
-    { DSA.params_p = 0x86F5CA03DCFEB225063FF830A0C769B9DD9D6153AD91D7CE27F787C43278B447E6533B86B18BED6E8A48B784A14C252C5BE0DBF60B86D6385BD2F12FB763ED8873ABFD3F5BA2E0A8C0A59082EAC056935E529DAF7C610467899C77ADEDFC846C881870B7B19B2B58F9BE0521A17002E3BDD6B86685EE90B3D9A1B02B782B1779
-    , DSA.params_g = 0x07B0F92546150B62514BB771E2A0C0CE387F03BDA6C56B505209FF25FD3C133D89BBCD97E904E09114D9A7DEFDEADFC9078EA544D2E401AEECC40BB9FBBF78FD87995A10A1C27CB7789B594BA7EFB5C4326A9FE59A070E136DB77175464ADCA417BE5DCE2F40D10A46A3A3943F26AB7FD9C0398FF8C76EE0A56826A8A88F1DBD
-    , DSA.params_q = 0x996F967F6C8E388D9E28D01E205FBA957A5698B1
-    }
+rfc6979Params1024 =
+    DSA.Params
+        { DSA.params_p =
+            0x86F5CA03DCFEB225063FF830A0C769B9DD9D6153AD91D7CE27F787C43278B447E6533B86B18BED6E8A48B784A14C252C5BE0DBF60B86D6385BD2F12FB763ED8873ABFD3F5BA2E0A8C0A59082EAC056935E529DAF7C610467899C77ADEDFC846C881870B7B19B2B58F9BE0521A17002E3BDD6B86685EE90B3D9A1B02B782B1779
+        , DSA.params_g =
+            0x07B0F92546150B62514BB771E2A0C0CE387F03BDA6C56B505209FF25FD3C133D89BBCD97E904E09114D9A7DEFDEADFC9078EA544D2E401AEECC40BB9FBBF78FD87995A10A1C27CB7789B594BA7EFB5C4326A9FE59A070E136DB77175464ADCA417BE5DCE2F40D10A46A3A3943F26AB7FD9C0398FF8C76EE0A56826A8A88F1DBD
+        , DSA.params_q = 0x996F967F6C8E388D9E28D01E205FBA957A5698B1
+        }
 
-rfc6979Params2048 = DSA.Params
-    { DSA.params_p = 0x9DB6FB5951B66BB6FE1E140F1D2CE5502374161FD6538DF1648218642F0B5C48C8F7A41AADFA187324B87674FA1822B00F1ECF8136943D7C55757264E5A1A44FFE012E9936E00C1D3E9310B01C7D179805D3058B2A9F4BB6F9716BFE6117C6B5B3CC4D9BE341104AD4A80AD6C94E005F4B993E14F091EB51743BF33050C38DE235567E1B34C3D6A5C0CEAA1A0F368213C3D19843D0B4B09DCB9FC72D39C8DE41F1BF14D4BB4563CA28371621CAD3324B6A2D392145BEBFAC748805236F5CA2FE92B871CD8F9C36D3292B5509CA8CAA77A2ADFC7BFD77DDA6F71125A7456FEA153E433256A2261C6A06ED3693797E7995FAD5AABBCFBE3EDA2741E375404AE25B
-    , DSA.params_g = 0x5C7FF6B06F8F143FE8288433493E4769C4D988ACE5BE25A0E24809670716C613D7B0CEE6932F8FAA7C44D2CB24523DA53FBE4F6EC3595892D1AA58C4328A06C46A15662E7EAA703A1DECF8BBB2D05DBE2EB956C142A338661D10461C0D135472085057F3494309FFA73C611F78B32ADBB5740C361C9F35BE90997DB2014E2EF5AA61782F52ABEB8BD6432C4DD097BC5423B285DAFB60DC364E8161F4A2A35ACA3A10B1C4D203CC76A470A33AFDCBDD92959859ABD8B56E1725252D78EAC66E71BA9AE3F1DD2487199874393CD4D832186800654760E1E34C09E4D155179F9EC0DC4473F996BDCE6EED1CABED8B6F116F7AD9CF505DF0F998E34AB27514B0FFE7
-    , DSA.params_q = 0xF2C3119374CE76C9356990B465374A17F23F9ED35089BD969F61C6DDE9998C1F
-    }
+rfc6979Params2048 =
+    DSA.Params
+        { DSA.params_p =
+            0x9DB6FB5951B66BB6FE1E140F1D2CE5502374161FD6538DF1648218642F0B5C48C8F7A41AADFA187324B87674FA1822B00F1ECF8136943D7C55757264E5A1A44FFE012E9936E00C1D3E9310B01C7D179805D3058B2A9F4BB6F9716BFE6117C6B5B3CC4D9BE341104AD4A80AD6C94E005F4B993E14F091EB51743BF33050C38DE235567E1B34C3D6A5C0CEAA1A0F368213C3D19843D0B4B09DCB9FC72D39C8DE41F1BF14D4BB4563CA28371621CAD3324B6A2D392145BEBFAC748805236F5CA2FE92B871CD8F9C36D3292B5509CA8CAA77A2ADFC7BFD77DDA6F71125A7456FEA153E433256A2261C6A06ED3693797E7995FAD5AABBCFBE3EDA2741E375404AE25B
+        , DSA.params_g =
+            0x5C7FF6B06F8F143FE8288433493E4769C4D988ACE5BE25A0E24809670716C613D7B0CEE6932F8FAA7C44D2CB24523DA53FBE4F6EC3595892D1AA58C4328A06C46A15662E7EAA703A1DECF8BBB2D05DBE2EB956C142A338661D10461C0D135472085057F3494309FFA73C611F78B32ADBB5740C361C9F35BE90997DB2014E2EF5AA61782F52ABEB8BD6432C4DD097BC5423B285DAFB60DC364E8161F4A2A35ACA3A10B1C4D203CC76A470A33AFDCBDD92959859ABD8B56E1725252D78EAC66E71BA9AE3F1DD2487199874393CD4D832186800654760E1E34C09E4D155179F9EC0DC4473F996BDCE6EED1CABED8B6F116F7AD9CF505DF0F998E34AB27514B0FFE7
+        , DSA.params_q =
+            0xF2C3119374CE76C9356990B465374A17F23F9ED35089BD969F61C6DDE9998C1F
+        }
 
 vectorToPrivate :: VectorDSA -> DSA.PrivateKey
-vectorToPrivate vector = DSA.PrivateKey
-    { DSA.private_x      = x vector
-    , DSA.private_params = pgq vector
-    }
+vectorToPrivate vector =
+    DSA.PrivateKey
+        { DSA.private_x = x vector
+        , DSA.private_params = pgq vector
+        }
 
 vectorToPublic :: VectorDSA -> DSA.PublicKey
-vectorToPublic vector = DSA.PublicKey
-    { DSA.public_y      = y vector
-    , DSA.public_params = pgq vector
-    }
+vectorToPublic vector =
+    DSA.PublicKey
+        { DSA.public_y = y vector
+        , DSA.public_params = pgq vector
+        }
 
 doSignatureTest hashAlg i vector = testCase (show i) (expected @=? actual)
-    where expected = Just $ DSA.Signature (r vector) (s vector)
-          actual   = DSA.signWith (k vector) (vectorToPrivate vector) hashAlg (msg vector)
+  where
+    expected = Just $ DSA.Signature (r vector) (s vector)
+    actual = DSA.signWith (k vector) (vectorToPrivate vector) hashAlg (msg vector)
 
 doVerifyTest hashAlg i vector = testCase (show i) (True @=? actual)
-    where actual = DSA.verify hashAlg (vectorToPublic vector) (DSA.Signature (r vector) (s vector)) (msg vector)
+  where
+    actual =
+        DSA.verify
+            hashAlg
+            (vectorToPublic vector)
+            (DSA.Signature (r vector) (s vector))
+            (msg vector)
 
-dsaTests = testGroup "DSA"
-    [ testGroup "SHA1"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA1) [katZero..] vectorsSHA1
-        , testGroup "verify" $ zipWith (doVerifyTest SHA1) [katZero..] vectorsSHA1
-        ]
-    , testGroup "SHA224"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA224) [katZero..] vectorsSHA224
-        , testGroup "verify" $ zipWith (doVerifyTest SHA224) [katZero..] vectorsSHA224
-        ]
-    , testGroup "SHA256"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA256) [katZero..] vectorsSHA256
-        , testGroup "verify" $ zipWith (doVerifyTest SHA256) [katZero..] vectorsSHA256
-        ]
-    , testGroup "SHA384"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA384) [katZero..] vectorsSHA384
-        , testGroup "verify" $ zipWith (doVerifyTest SHA384) [katZero..] vectorsSHA384
-        ]
-    , testGroup "SHA512"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA512) [katZero..] vectorsSHA512
-        , testGroup "verify" $ zipWith (doVerifyTest SHA512) [katZero..] vectorsSHA512
+dsaTests =
+    testGroup
+        "DSA"
+        [ testGroup
+            "SHA1"
+            [ testGroup "signature" $ zipWith (doSignatureTest SHA1) [katZero ..] vectorsSHA1
+            , testGroup "verify" $ zipWith (doVerifyTest SHA1) [katZero ..] vectorsSHA1
+            ]
+        , testGroup
+            "SHA224"
+            [ testGroup "signature" $
+                zipWith (doSignatureTest SHA224) [katZero ..] vectorsSHA224
+            , testGroup "verify" $ zipWith (doVerifyTest SHA224) [katZero ..] vectorsSHA224
+            ]
+        , testGroup
+            "SHA256"
+            [ testGroup "signature" $
+                zipWith (doSignatureTest SHA256) [katZero ..] vectorsSHA256
+            , testGroup "verify" $ zipWith (doVerifyTest SHA256) [katZero ..] vectorsSHA256
+            ]
+        , testGroup
+            "SHA384"
+            [ testGroup "signature" $
+                zipWith (doSignatureTest SHA384) [katZero ..] vectorsSHA384
+            , testGroup "verify" $ zipWith (doVerifyTest SHA384) [katZero ..] vectorsSHA384
+            ]
+        , testGroup
+            "SHA512"
+            [ testGroup "signature" $
+                zipWith (doSignatureTest SHA512) [katZero ..] vectorsSHA512
+            , testGroup "verify" $ zipWith (doVerifyTest SHA512) [katZero ..] vectorsSHA512
+            ]
         ]
-    ]
diff --git a/tests/KAT_PubKey/ECC.hs b/tests/KAT_PubKey/ECC.hs
--- a/tests/KAT_PubKey/ECC.hs
+++ b/tests/KAT_PubKey/ECC.hs
@@ -1,10 +1,13 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_PubKey.ECC (eccTests, eccKatTests) where
 
 import Control.Arrow (second)
 
-import qualified Crypto.PubKey.ECC.Types as ECC
+import Data.List
+
 import qualified Crypto.PubKey.ECC.Prim as ECC
+import qualified Crypto.PubKey.ECC.Types as ECC
 
 import Test.Tasty.KAT
 import Test.Tasty.KAT.FileLoader
@@ -12,131 +15,134 @@
 import Imports
 
 instance Arbitrary ECC.Curve where
-    arbitrary = ECC.getCurveByName <$> elements
-        [ ECC.SEC_p112r1
-        , ECC.SEC_p112r2
-        , ECC.SEC_p128r1
-        , ECC.SEC_p128r2
-        , ECC.SEC_p160k1
-        , ECC.SEC_p160r1
-        , ECC.SEC_p160r2
-        , ECC.SEC_p192k1
-        , ECC.SEC_p192r1
-        , ECC.SEC_p224k1
-        , ECC.SEC_p224r1
-        , ECC.SEC_p256k1
-        , ECC.SEC_p256r1
-        , ECC.SEC_p384r1
-        , ECC.SEC_p521r1
-        , ECC.SEC_t113r1
-        , ECC.SEC_t113r2
-        , ECC.SEC_t131r1
-        , ECC.SEC_t131r2
-        , ECC.SEC_t163k1
-        , ECC.SEC_t163r1
-        , ECC.SEC_t163r2
-        , ECC.SEC_t193r1
-        , ECC.SEC_t193r2
-        , ECC.SEC_t233k1
-        , ECC.SEC_t233r1
-        , ECC.SEC_t239k1
-        , ECC.SEC_t283k1
-        , ECC.SEC_t283r1
-        , ECC.SEC_t409k1
-        , ECC.SEC_t409r1
-        , ECC.SEC_t571k1
-        , ECC.SEC_t571r1
-        ]
+    arbitrary =
+        ECC.getCurveByName
+            <$> elements
+                [ ECC.SEC_p112r1
+                , ECC.SEC_p112r2
+                , ECC.SEC_p128r1
+                , ECC.SEC_p128r2
+                , ECC.SEC_p160k1
+                , ECC.SEC_p160r1
+                , ECC.SEC_p160r2
+                , ECC.SEC_p192k1
+                , ECC.SEC_p192r1
+                , ECC.SEC_p224k1
+                , ECC.SEC_p224r1
+                , ECC.SEC_p256k1
+                , ECC.SEC_p256r1
+                , ECC.SEC_p384r1
+                , ECC.SEC_p521r1
+                , ECC.SEC_t113r1
+                , ECC.SEC_t113r2
+                , ECC.SEC_t131r1
+                , ECC.SEC_t131r2
+                , ECC.SEC_t163k1
+                , ECC.SEC_t163r1
+                , ECC.SEC_t163r2
+                , ECC.SEC_t193r1
+                , ECC.SEC_t193r2
+                , ECC.SEC_t233k1
+                , ECC.SEC_t233r1
+                , ECC.SEC_t239k1
+                , ECC.SEC_t283k1
+                , ECC.SEC_t283r1
+                , ECC.SEC_t409k1
+                , ECC.SEC_t409r1
+                , ECC.SEC_t571k1
+                , ECC.SEC_t571r1
+                ]
 
 data VectorPoint = VectorPoint
     { curve :: ECC.Curve
-    , x     :: Integer
-    , y     :: Integer
+    , x :: Integer
+    , y :: Integer
     , valid :: Bool
     }
 
+vectorsPoint :: [VectorPoint]
 vectorsPoint =
     [ VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x     = 0x491c0c4761b0a4a147b5e4ce03a531546644f5d1e3d05e57
-        , y     = 0x6fa5addd47c5d6be3933fbff88f57a6c8ca0232c471965de
+        , x = 0x491c0c4761b0a4a147b5e4ce03a531546644f5d1e3d05e57
+        , y = 0x6fa5addd47c5d6be3933fbff88f57a6c8ca0232c471965de
         , valid = False -- point not on curve
         }
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x    = 0x646c22e8aa5f7833390e0399155ac198ae42470bba4fc834
-        , y    = 0x8d4afcfffd80e69a4d180178b37c44572495b7b267ee32a9
+        , x = 0x646c22e8aa5f7833390e0399155ac198ae42470bba4fc834
+        , y = 0x8d4afcfffd80e69a4d180178b37c44572495b7b267ee32a9
         , valid = True
         }
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x    = 0x4c6b9ea0dec92ecfff7799470be6a2277b9169daf45d54bb
-        , y    = 0xf0eab42826704f51b26ae98036e83230becb639dd1964627
+        , x = 0x4c6b9ea0dec92ecfff7799470be6a2277b9169daf45d54bb
+        , y = 0xf0eab42826704f51b26ae98036e83230becb639dd1964627
         , valid = False -- point not on curve
         }
-
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x    = 0x0673c8bb717b055c3d6f55c06acfcfb7260361ed3ec0f414
-        , y    = 0xba8b172826eb0b854026968d2338a180450a27906f6eddea
+        , x = 0x0673c8bb717b055c3d6f55c06acfcfb7260361ed3ec0f414
+        , y = 0xba8b172826eb0b854026968d2338a180450a27906f6eddea
         , valid = True
         }
-
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x    = 0x82c949295156192df0b52480e38c810751ac570daec460a3
-        , y    = 0x200057ada615c80b8ff256ce8d47f2562b74a438f1921ac3
+        , x = 0x82c949295156192df0b52480e38c810751ac570daec460a3
+        , y = 0x200057ada615c80b8ff256ce8d47f2562b74a438f1921ac3
         , valid = False -- point not on curve
         }
-
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x    = 0x284fbaa76ce0faae2ca4867d01092fa1ace5724cd12c8dd0
-        , y    = 0xe42af3dbf3206be3fcbcc3a7ccaf60c73dc29e7bb9b44fca
+        , x = 0x284fbaa76ce0faae2ca4867d01092fa1ace5724cd12c8dd0
+        , y = 0xe42af3dbf3206be3fcbcc3a7ccaf60c73dc29e7bb9b44fca
         , valid = True
         }
-
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x    = 0x1b574acd4fb0f60dde3e3b5f3f0e94211f95112e43cba6fd2
-        , y    = 0xbcc1b8a770f01a22e84d7f14e44932ffe094d8e3b1e6ac26
+        , x = 0x1b574acd4fb0f60dde3e3b5f3f0e94211f95112e43cba6fd2
+        , y = 0xbcc1b8a770f01a22e84d7f14e44932ffe094d8e3b1e6ac26
         , valid = False -- x or y out of range
         }
-
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x    = 0x16ba109f1f1bb44e0d05b80181c03412ea764a59601d17e9f
-        , y    = 0x0569a843dbb4e287db420d6b9fe30cd7b5d578b052315f56
+        , x = 0x16ba109f1f1bb44e0d05b80181c03412ea764a59601d17e9f
+        , y = 0x0569a843dbb4e287db420d6b9fe30cd7b5d578b052315f56
         , valid = False -- x or y out of range
         }
-
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x    = 0x1333308a7c833ede5189d25ea3525919c9bd16370d904938d
-        , y    = 0xb10fd01d67df75ff9b726c700c1b50596c9f0766ea56f80e
+        , x = 0x1333308a7c833ede5189d25ea3525919c9bd16370d904938d
+        , y = 0xb10fd01d67df75ff9b726c700c1b50596c9f0766ea56f80e
         , valid = False -- x or y out of range
         }
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x    = 0x9671ec444cff24c8a5be80b018fa505ed6109a731e88c91a
-        , y    = 0xfe79dae23008e46bf4230c895aab261a95845a77f06d0655
+        , x = 0x9671ec444cff24c8a5be80b018fa505ed6109a731e88c91a
+        , y = 0xfe79dae23008e46bf4230c895aab261a95845a77f06d0655
         , valid = True
         }
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x     = 0x158e8b6f0b14216bc52fe8897b4305d870ede70436a96741d
-        , y     = 0xfb3f970b19a313571a1a23be310923f85acc1cab0a157cbd
+        , x = 0x158e8b6f0b14216bc52fe8897b4305d870ede70436a96741d
+        , y = 0xfb3f970b19a313571a1a23be310923f85acc1cab0a157cbd
         , valid = False -- x or y out of range
         }
     , VectorPoint
         { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , x     = 0xace95b650c08f73dbb4fa7b4bbdebd6b809a25b28ed135ef
-        , y     = 0xe9b8679404166d1329dd539ad52aad9a1b6681f5f26bb9aa
+        , x = 0xace95b650c08f73dbb4fa7b4bbdebd6b809a25b28ed135ef
+        , y = 0xe9b8679404166d1329dd539ad52aad9a1b6681f5f26bb9aa
         , valid = False -- point not on curve
         }
     ]
 
-doPointValidTest i vector = testCase (show i) (valid vector @=? ECC.isPointValid (curve vector) (ECC.Point (x vector) (y vector)))
+doPointValidTest :: Show a => a -> VectorPoint -> TestTree
+doPointValidTest i vector =
+    testCase
+        (show i)
+        ( valid vector
+            @=? ECC.isPointValid (curve vector) (ECC.Point (x vector) (y vector))
+        )
 
 arbitraryPoint :: ECC.Curve -> Gen ECC.Point
 arbitraryPoint aCurve =
@@ -145,68 +151,85 @@
     n = ECC.ecc_n (ECC.common_curve aCurve)
     pointGen = ECC.pointBaseMul aCurve <$> choose (1, n - 1)
 
-eccTests = testGroup "ECC"
-    [ testGroup "valid-point" $ zipWith doPointValidTest [katZero..] vectorsPoint
-    , localOption (QuickCheckTests 20) $ testGroup "property"
-        [ testProperty "point-add" $ \aCurve (QAInteger r1) (QAInteger r2) ->
-            let curveN   = ECC.ecc_n . ECC.common_curve $ aCurve
-                curveGen = ECC.ecc_g . ECC.common_curve $ aCurve
-                p1       = ECC.pointMul aCurve r1 curveGen
-                p2       = ECC.pointMul aCurve r2 curveGen
-                pR       = ECC.pointMul aCurve ((r1 + r2) `mod` curveN) curveGen
-             in pR `propertyEq` ECC.pointAdd aCurve p1 p2
-        , testProperty "point-negate-add" $ \aCurve -> do
-            p <- arbitraryPoint aCurve
-            let o = ECC.pointAdd aCurve p (ECC.pointNegate aCurve p)
-            return $ ECC.PointO `propertyEq` o
-        , testProperty "point-negate-negate" $ \aCurve -> do
-            p <- arbitraryPoint aCurve
-            return $ p `propertyEq` ECC.pointNegate aCurve (ECC.pointNegate aCurve p)
-        , testProperty "point-mul-mul" $ \aCurve (QAInteger n1) (QAInteger n2) -> do
-            p <- arbitraryPoint aCurve
-            let pRes = ECC.pointMul aCurve (n1 * n2) p
-            let pDef = ECC.pointMul aCurve n1 (ECC.pointMul aCurve n2 p)
-            return $ pRes `propertyEq` pDef
-        , testProperty "double-scalar-mult" $ \aCurve (QAInteger n1) (QAInteger n2) -> do
-            p1 <- arbitraryPoint aCurve
-            p2 <- arbitraryPoint aCurve
-            let pRes = ECC.pointAddTwoMuls aCurve n1 p1 n2 p2
-            let pDef = ECC.pointAdd aCurve (ECC.pointMul aCurve n1 p1) (ECC.pointMul aCurve n2 p2)
-            return $ pRes `propertyEq` pDef
+eccTests :: TestTree
+eccTests =
+    testGroup
+        "ECC"
+        [ testGroup "valid-point" $ zipWith doPointValidTest [katZero ..] vectorsPoint
+        , localOption (QuickCheckTests 20) $
+            testGroup
+                "property"
+                [ testProperty "point-add" $ \aCurve (QAInteger r1) (QAInteger r2) ->
+                    let curveN = ECC.ecc_n . ECC.common_curve $ aCurve
+                        curveGen = ECC.ecc_g . ECC.common_curve $ aCurve
+                        p1 = ECC.pointMul aCurve r1 curveGen
+                        p2 = ECC.pointMul aCurve r2 curveGen
+                        pR = ECC.pointMul aCurve ((r1 + r2) `mod` curveN) curveGen
+                     in pR `propertyEq` ECC.pointAdd aCurve p1 p2
+                , testProperty "point-negate-add" $ \aCurve -> do
+                    p <- arbitraryPoint aCurve
+                    let o = ECC.pointAdd aCurve p (ECC.pointNegate aCurve p)
+                    return $ ECC.PointO `propertyEq` o
+                , testProperty "point-negate-negate" $ \aCurve -> do
+                    p <- arbitraryPoint aCurve
+                    return $ p `propertyEq` ECC.pointNegate aCurve (ECC.pointNegate aCurve p)
+                , testProperty "point-mul-mul" $ \aCurve (QAInteger n1) (QAInteger n2) -> do
+                    p <- arbitraryPoint aCurve
+                    let pRes = ECC.pointMul aCurve (n1 * n2) p
+                    let pDef = ECC.pointMul aCurve n1 (ECC.pointMul aCurve n2 p)
+                    return $ pRes `propertyEq` pDef
+                , testProperty "double-scalar-mult" $ \aCurve (QAInteger n1) (QAInteger n2) -> do
+                    p1 <- arbitraryPoint aCurve
+                    p2 <- arbitraryPoint aCurve
+                    let pRes = ECC.pointAddTwoMuls aCurve n1 p1 n2 p2
+                    let pDef = ECC.pointAdd aCurve (ECC.pointMul aCurve n1 p1) (ECC.pointMul aCurve n2 p2)
+                    return $ pRes `propertyEq` pDef
+                ]
         ]
-    ]
 
+eccKatTests :: IO TestTree
 eccKatTests = do
-    res <- testKatLoad "KATs/ECC-PKV.txt" (map (second (map toVector)) . katLoaderSimple)
-    return $ testKatDetailed {-Grouped-} "ECC/valid-point" res (\g vect -> do
-        let mCurve = ECC.getCurveByName <$> case g of
-                        "P-192" -> Just ECC.SEC_p192r1
-                        "P-224" -> Just ECC.SEC_p224r1
-                        "P-256" -> Just ECC.SEC_p256r1
-                        "P-384" -> Just ECC.SEC_p384r1
-                        "P-521" -> Just ECC.SEC_p521r1
-                        "B-163" -> Just ECC.SEC_t163r2
-                        "B-233" -> Just ECC.SEC_t233r1
-                        "B-283" -> Just ECC.SEC_t283r1
-                        "B-409" -> Just ECC.SEC_t409r1
-                        "B-571" -> Just ECC.SEC_t571r1
-                        ""      -> Nothing
-                        _       -> Nothing
-{-
-                        "K-163" -> Just ECC.SEC_t163k1
-                        "K-233" -> Just ECC.SEC_t233k1
-                        "K-283" -> Just ECC.SEC_t283k1
-                        "K-409" -> Just ECC.SEC_t409k1
-                        "K-571" -> Just ECC.SEC_t571k1
--}
-        case mCurve of
-            Nothing -> return True
-            Just c  -> do
-                return (ECC.isPointValid c (ECC.Point (x vect) (y vect)) == valid vect)
-        )
-
-  where toVector kvs =
-            case sequence $ map (flip lookup kvs) [ "Qx", "Qy", "Result" ] of
-                Just [qx,qy,res] -> VectorPoint undefined (valueHexInteger qx) (valueHexInteger qy) (head res /= 'F')
-                Just _           -> error ("ERROR: " ++ show kvs)
-                Nothing          -> error ("ERROR: " ++ show kvs) -- VectorPoint undefined 0 0 True
+    res <-
+        testKatLoad "KATs/ECC-PKV.txt" (map (second (map toVector)) . katLoaderSimple)
+    return $
+        testKatDetailed {-Grouped-}
+            "ECC/valid-point"
+            res
+            ( \g vect -> do
+                let mCurve =
+                        ECC.getCurveByName <$> case g of
+                            "P-192" -> Just ECC.SEC_p192r1
+                            "P-224" -> Just ECC.SEC_p224r1
+                            "P-256" -> Just ECC.SEC_p256r1
+                            "P-384" -> Just ECC.SEC_p384r1
+                            "P-521" -> Just ECC.SEC_p521r1
+                            "B-163" -> Just ECC.SEC_t163r2
+                            "B-233" -> Just ECC.SEC_t233r1
+                            "B-283" -> Just ECC.SEC_t283r1
+                            "B-409" -> Just ECC.SEC_t409r1
+                            "B-571" -> Just ECC.SEC_t571r1
+                            "" -> Nothing
+                            _ -> Nothing
+                {-
+                                        "K-163" -> Just ECC.SEC_t163k1
+                                        "K-233" -> Just ECC.SEC_t233k1
+                                        "K-283" -> Just ECC.SEC_t283k1
+                                        "K-409" -> Just ECC.SEC_t409k1
+                                        "K-571" -> Just ECC.SEC_t571k1
+                -}
+                case mCurve of
+                    Nothing -> return True
+                    Just c -> do
+                        return (ECC.isPointValid c (ECC.Point (x vect) (y vect)) == valid vect)
+            )
+  where
+    toVector kvs =
+        case sequence $ map (flip lookup kvs) ["Qx", "Qy", "Result"] of
+            Just [qx, qy, res] ->
+                VectorPoint
+                    undefined
+                    (valueHexInteger qx)
+                    (valueHexInteger qy)
+                    ("F" `isPrefixOf` res)
+            Just _ -> error ("ERROR: " ++ show kvs)
+            Nothing -> error ("ERROR: " ++ show kvs) -- VectorPoint undefined 0 0 True
diff --git a/tests/KAT_PubKey/ECDSA.hs b/tests/KAT_PubKey/ECDSA.hs
--- a/tests/KAT_PubKey/ECDSA.hs
+++ b/tests/KAT_PubKey/ECDSA.hs
@@ -1,521 +1,1636 @@
--- Test vectors for SHA1 are taken from GEC2: www.secg.org/collateral/gec2.pdf
--- Test vectors for SHA224, SHA256, SHA384, SHA512 are taken from RFC 6979
-{-# LANGUAGE OverloadedStrings #-}
-module KAT_PubKey.ECDSA (ecdsaTests) where
-
-import Crypto.Number.Serialize
-
-import qualified Crypto.PubKey.ECC.ECDSA as ECDSA
-import qualified Crypto.PubKey.ECC.Types as ECC
-import Crypto.Hash (SHA1(..), SHA224(..), SHA256(..), SHA384(..), SHA512(..))
-
-import Imports
-
-data VectorECDSA = VectorECDSA
-    { curve :: ECC.Curve
-    , msg   :: ByteString
-    , d     :: Integer
-    , q     :: ECC.Point
-    , k     :: Integer
-    , r     :: Integer
-    , s     :: Integer
-    }
-
-vectorsSHA1 =
-    [ VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p160r1
-        , msg   = "abc"
-        , d     = 971761939728640320549601132085879836204587084162
-        , q     = ECC.Point 466448783855397898016055842232266600516272889280
-                            1110706324081757720403272427311003102474457754220
-        , k     = 702232148019446860144825009548118511996283736794
-        , r     = 1176954224688105769566774212902092897866168635793
-        , s     = 299742580584132926933316745664091704165278518100
-        }
-    -- from official ECDSA KATs
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_t163k1
-        , msg   = i2osp 0xa2c1a03fdd00521bb08fc88d20344321977aaf637ef9d5470dd7d2c8628fc8d0d1f1d3587c6b3fd02386f8c13db341b14748a9475cc63baf065df64054b27d5c2cdf0f98e3bbb81d0b5dc94f8cdb87acf75720f6163de394c8c6af360bc1acb85b923a493b7b27cc111a257e36337bd94eb0fab9d5e633befb1ae7f1b244bfaa
-        , d     = 0x00000011f2626d90d26cb4c0379043b26e64107fc
-        , q     = ECC.Point 0x0389fa5ad7f8304325a8c060ef7dcb83042c045bc
-                            0x0eefa094a5054da196943cc80509dcb9f59e5bc2e
-        , k     = 0x0000000c3a4ff97286126dab1e5089395fcc47ebb
-        , r     = 0x0dbe6c3a1dc851e7f2338b5c26c62b4b37bf8035c
-        , s     = 0x1c76458135b1ff9fbd23009b8414a47996126b56a
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_t163k1
-        , msg   = i2osp 0x67048080daaeb77d3ac31babdf8be23dbe75ceb4dfb94aa8113db5c5dcb6fe14b70f717b7b0ed0881835a66a86e6d840ffcb7d976c75ef2d1d4322fbbc86357384e24707aef88cea2c41a01a9a3d1b9e72ce650c7fdecc4f9448d3a77df6cdf13647ab295bb3132de0b1b2c402d8d2de7d452f1e003e0695de1470d1064eee16
-        , d     = 0x00000006a3803301daee9af09bb5b6c991a4f49a4
-        , q     = ECC.Point 0x4b500f555e857da8c299780130c5c3f48f02ee322 0x5c1c0ae25b47f06cc46fb86b12d2d8c0ba6a4bf07
-        , k     = 0x0000002f39fbf77f3e0dc046116de692b6cf91b16
-        , r     = 0x3d3eeda42f65d727f4a564f1415654356c6c57a6c
-        , s     = 0x35e4d43c5f08baddf138449db1ad0b7872552b7cd
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_t163k1
-        , msg   = i2osp 0x77e007dc2acd7248256165a4b30e98986f51a81efd926b85f74c81bc2a6d2bcd030060a844091e22fbb0ff3db5a20caaefb5d58ccdcbc27f0ff8a4d940e78f303079ec1ca5b0ca3d4ecc7580f8b34a9f0496c9e719d2ec3e1614b7644bc11179e895d2c0b58a1da204fbf0f6e509f97f983eacb6487092caf6e8e4e6b3c458b2
-        , d     = 0x0000002e28676514bd93fea11b62db0f6e324b18d
-        , q     = ECC.Point 0x3f9c90b71f6a1de20a2716f38ef1b5f98c757bd42 0x2ff0a5d266d447ef62d43fbca6c34c08c1ce35a40
-        , k     = 0x00000001233ae699883e74e7f4dfb5279ff22280a
-        , r     = 0x39de3cd2cf04145e522b8fba3f23e9218226e0860
-        , s     = 0x2af62bfb3cfa202e2342606ee5bb0934c3b0375b6
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_t163k1
-        , msg   = i2osp 0xfbacfcce4688748406ddf5c3495021eef8fb399865b649eb2395a04a1ab28335da2c236d306fcc59f7b65ea931cf0139571e1538ede5688958c3ac69f47a285362f5ad201f89cc735b7b465408c2c41b310fc8908d0be45054df2a7351fae36b390e842f3b5cdd9ad832940df5b2d25c2ed43ce86eaf2508bcf401ae58bb1d47
-        , d     = 0x000000361dd088e3a6d3c910686c8dce57e5d4d8e
-        , q     = ECC.Point 0x064f905c1da9d7e9c32d81890ae6f30dcc7839d32 0x06f1faedb6d9032016d3b681e7cf69c29d29eb27b
-        , k     = 0x00000022f723e9f5da56d3d0837d5dca2f937395f
-        , r     = 0x374cdc8571083fecfbd4e25e1cd69ecc66b715f2d
-        , s     = 0x313b10949222929b2f20b15d446c27d6dcae3f086
-        }
-    ]
-
-rfc6979_vectorsSHA224 =
-    [ VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , msg   = "sample"
-        , d     = 0x6fab034934e4c0fc9ae67f5b5659a9d7d1fefd187ee09fd4
-        , q     = ECC.Point 0xac2c77f529f91689fea0ea5efec7f210d8eea0b9e047ed56
-                            0x3bc723e57670bd4887ebc732c523063d0a7c957bc97c1c43
-        , k     = 0x4381526b3fc1e7128f202e194505592f01d5ff4c5af015d8
-        , r     = 0xa1f00dad97aeec91c95585f36200c65f3c01812aa60378f5
-        , s     = 0xe07ec1304c7c6c9debbe980b9692668f81d4de7922a0f97a
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , msg   = "test"
-        , d     = 0x6fab034934e4c0fc9ae67f5b5659a9d7d1fefd187ee09fd4
-        , q     = ECC.Point 0xac2c77f529f91689fea0ea5efec7f210d8eea0b9e047ed56
-                            0x3bc723e57670bd4887ebc732c523063d0a7c957bc97c1c43
-        , k     = 0xf5dc805f76ef851800700cce82e7b98d8911b7d510059fbe
-        , r     = 0x6945a1c1d1b2206b8145548f633bb61cef04891baf26ed34
-        , s     = 0xb7fb7fdfc339c0b9bd61a9f5a8eaf9be58fc5cba2cb15293
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p224r1
-        , msg   = "sample"
-        , d     = 0xf220266e1105bfe3083e03ec7a3a654651f45e37167e88600bf257c1
-        , q     = ECC.Point 0x00cf08da5ad719e42707fa431292dea11244d64fc51610d94b130d6c
-                            0xeeab6f3debe455e3dbf85416f7030cbd94f34f2d6f232c69f3c1385a
-        , k     = 0xc1d1f2f10881088301880506805feb4825fe09acb6816c36991aa06d
-        , r     = 0x1cdfe6662dde1e4a1ec4cdedf6a1f5a2fb7fbd9145c12113e6abfd3e
-        , s     = 0xa6694fd7718a21053f225d3f46197ca699d45006c06f871808f43ebc
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p224r1
-        , msg   = "test"
-        , d     = 0xf220266e1105bfe3083e03ec7a3a654651f45e37167e88600bf257c1
-        , q     = ECC.Point 0x00cf08da5ad719e42707fa431292dea11244d64fc51610d94b130d6c
-                            0xeeab6f3debe455e3dbf85416f7030cbd94f34f2d6f232c69f3c1385a
-        , k     = 0xdf8b38d40dca3e077d0ac520bf56b6d565134d9b5f2eae0d34900524
-        , r     = 0xc441ce8e261ded634e4cf84910e4c5d1d22c5cf3b732bb204dbef019
-        , s     = 0x902f42847a63bdc5f6046ada114953120f99442d76510150f372a3f4
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p256r1
-        , msg   = "sample"
-        , d     = 0xc9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721
-        , q     = ECC.Point 0x60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6
-                            0x7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299
-        , k     = 0x103f90ee9dc52e5e7fb5132b7033c63066d194321491862059967c715985d473
-        , r     = 0x53b2fff5d1752b2c689df257c04c40a587fababb3f6fc2702f1343af7ca9aa3f
-        , s     = 0xb9afb64fdc03dc1a131c7d2386d11e349f070aa432a4acc918bea988bf75c74c
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p256r1
-        , msg   = "test"
-        , d     = 0xc9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721
-        , q     = ECC.Point 0x60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6
-                            0x7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299
-        , k     = 0x669f4426f2688b8be0db3a6bd1989bdaefff84b649eeb84f3dd26080f667faa7
-        , r     = 0xc37edb6f0ae79d47c3c27e962fa269bb4f441770357e114ee511f662ec34a692
-        , s     = 0xc820053a05791e521fcaad6042d40aea1d6b1a540138558f47d0719800e18f2d
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p384r1
-        , msg   = "sample"
-        , d     = 0x6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5
-        , q     = ECC.Point 0xec3a4e415b4e19a4568618029f427fa5da9a8bc4ae92e02e06aae5286b300c64def8f0ea9055866064a254515480bc13
-                            0x8015d9b72d7d57244ea8ef9ac0c621896708a59367f9dfb9f54ca84b3f1c9db1288b231c3ae0d4fe7344fd2533264720
-        , k     = 0xa4e4d2f0e729eb786b31fc20ad5d849e304450e0ae8e3e341134a5c1afa03cab8083ee4e3c45b06a5899ea56c51b5879
-        , r     = 0x42356e76b55a6d9b4631c865445dbe54e056d3b3431766d0509244793c3f9366450f76ee3de43f5a125333a6be060122
-        , s     = 0x9da0c81787064021e78df658f2fbb0b042bf304665db721f077a4298b095e4834c082c03d83028efbf93a3c23940ca8d
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p384r1
-        , msg   = "test"
-        , d     = 0x6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5
-        , q     = ECC.Point 0xec3a4e415b4e19a4568618029f427fa5da9a8bc4ae92e02e06aae5286b300c64def8f0ea9055866064a254515480bc13
-                            0x8015d9b72d7d57244ea8ef9ac0c621896708a59367f9dfb9f54ca84b3f1c9db1288b231c3ae0d4fe7344fd2533264720
-        , k     = 0x18fa39db95aa5f561f30fa3591dc59c0fa3653a80daffa0b48d1a4c6dfcbff6e3d33be4dc5eb8886a8ecd093f2935726
-        , r     = 0xe8c9d0b6ea72a0e7837fea1d14a1a9557f29faa45d3e7ee888fc5bf954b5e62464a9a817c47ff78b8c11066b24080e72
-        , s     = 0x07041d4a7a0379ac7232ff72e6f77b6ddb8f09b16cce0ec3286b2bd43fa8c6141c53ea5abef0d8231077a04540a96b66
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p521r1
-        , msg   = "sample"
-        , d     = 0x0fad06daa62ba3b25d2fb40133da757205de67f5bb0018fee8c86e1b68c7e75caa896eb32f1f47c70855836a6d16fcc1466f6d8fbec67db89ec0c08b0e996b83538
-        , q     = ECC.Point 0x1894550d0785932e00eaa23b694f213f8c3121f86dc97a04e5a7167db4e5bcd371123d46e45db6b5d5370a7f20fb633155d38ffa16d2bd761dcac474b9a2f5023a4
-                            0x0493101c962cd4d2fddf782285e64584139c2f91b47f87ff82354d6630f746a28a0db25741b5b34a828008b22acc23f924faafbd4d33f81ea66956dfeaa2bfdfcf5
-        , k     = 0x121415ec2cd7726330a61f7f3fa5de14be9436019c4db8cb4041f3b54cf31be0493ee3f427fb906393d895a19c9523f3a1d54bb8702bd4aa9c99dab2597b92113f3
-        , r     = 0x1776331cfcdf927d666e032e00cf776187bc9fdd8e69d0dabb4109ffe1b5e2a30715f4cc923a4a5e94d2503e9acfed92857b7f31d7152e0f8c00c15ff3d87e2ed2e
-        , s     = 0x050cb5265417fe2320bbb5a122b8e1a32bd699089851128e360e620a30c7e17ba41a666af126ce100e5799b153b60528d5300d08489ca9178fb610a2006c254b41f
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p521r1
-        , msg   = "test"
-        , d     = 0x0fad06daa62ba3b25d2fb40133da757205de67f5bb0018fee8c86e1b68c7e75caa896eb32f1f47c70855836a6d16fcc1466f6d8fbec67db89ec0c08b0e996b83538
-        , q     = ECC.Point 0x1894550d0785932e00eaa23b694f213f8c3121f86dc97a04e5a7167db4e5bcd371123d46e45db6b5d5370a7f20fb633155d38ffa16d2bd761dcac474b9a2f5023a4
-                            0x0493101c962cd4d2fddf782285e64584139c2f91b47f87ff82354d6630f746a28a0db25741b5b34a828008b22acc23f924faafbd4d33f81ea66956dfeaa2bfdfcf5
-        , k     = 0x040d09fcf3c8a5f62cf4fb223cbbb2b9937f6b0577c27020a99602c25a01136987e452988781484edbbcf1c47e554e7fc901bc3085e5206d9f619cff07e73d6f706
-        , r     = 0x1c7ed902e123e6815546065a2c4af977b22aa8eaddb68b2c1110e7ea44d42086bfe4a34b67ddc0e17e96536e358219b23a706c6a6e16ba77b65e1c595d43cae17fb
-        , s     = 0x177336676304fcb343ce028b38e7b4fba76c1c1b277da18cad2a8478b2a9a9f5bec0f3ba04f35db3e4263569ec6aade8c92746e4c82f8299ae1b8f1739f8fd519a4
-        }
-    ]
-
-rfc6979_vectorsSHA256 =
-    [ VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , msg   = "sample"
-        , d     = 0x6fab034934e4c0fc9ae67f5b5659a9d7d1fefd187ee09fd4
-        , q     = ECC.Point 0xac2c77f529f91689fea0ea5efec7f210d8eea0b9e047ed56
-                            0x3bc723e57670bd4887ebc732c523063d0a7c957bc97c1c43
-        , k     = 0x32b1b6d7d42a05cb449065727a84804fb1a3e34d8f261496
-        , r     = 0x4b0b8ce98a92866a2820e20aa6b75b56382e0f9bfd5ecb55
-        , s     = 0xccdb006926ea9565cbadc840829d8c384e06de1f1e381b85
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , msg   = "test"
-        , d     = 0x6fab034934e4c0fc9ae67f5b5659a9d7d1fefd187ee09fd4
-        , q     = ECC.Point 0xac2c77f529f91689fea0ea5efec7f210d8eea0b9e047ed56
-                            0x3bc723e57670bd4887ebc732c523063d0a7c957bc97c1c43
-        , k     = 0x5c4ce89cf56d9e7c77c8585339b006b97b5f0680b4306c6c
-        , r     = 0x3a718bd8b4926c3b52ee6bbe67ef79b18cb6eb62b1ad97ae
-        , s     = 0x5662e6848a4a19b1f1ae2f72acd4b8bbe50f1eac65d9124f
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p224r1
-        , msg   = "sample"
-        , d     = 0xf220266e1105bfe3083e03ec7a3a654651f45e37167e88600bf257c1
-        , q     = ECC.Point 0x00cf08da5ad719e42707fa431292dea11244d64fc51610d94b130d6c
-                            0xeeab6f3debe455e3dbf85416f7030cbd94f34f2d6f232c69f3c1385a
-        , k     = 0xad3029e0278f80643de33917ce6908c70a8ff50a411f06e41dedfcdc
-        , r     = 0x61aa3da010e8e8406c656bc477a7a7189895e7e840cdfe8ff42307ba
-        , s     = 0xbc814050dab5d23770879494f9e0a680dc1af7161991bde692b10101
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p224r1
-        , msg   = "test"
-        , d     = 0xf220266e1105bfe3083e03ec7a3a654651f45e37167e88600bf257c1
-        , q     = ECC.Point 0x00cf08da5ad719e42707fa431292dea11244d64fc51610d94b130d6c
-                            0xeeab6f3debe455e3dbf85416f7030cbd94f34f2d6f232c69f3c1385a
-        , k     = 0xff86f57924da248d6e44e8154eb69f0ae2aebaee9931d0b5a969f904
-        , r     = 0xad04dde87b84747a243a631ea47a1ba6d1faa059149ad2440de6fba6
-        , s     = 0x178d49b1ae90e3d8b629be3db5683915f4e8c99fdf6e666cf37adcfd
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p256r1
-        , msg   = "sample"
-        , d     = 0xc9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721
-        , q     = ECC.Point 0x60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6
-                            0x7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299
-        , k     = 0xa6e3c57dd01abe90086538398355dd4c3b17aa873382b0f24d6129493d8aad60
-        , r     = 0xefd48b2aacb6a8fd1140dd9cd45e81d69d2c877b56aaf991c34d0ea84eaf3716
-        , s     = 0xf7cb1c942d657c41d436c7a1b6e29f65f3e900dbb9aff4064dc4ab2f843acda8
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p256r1
-        , msg   = "test"
-        , d     = 0xc9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721
-        , q     = ECC.Point 0x60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6
-                            0x7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299
-        , k     = 0xd16b6ae827f17175e040871a1c7ec3500192c4c92677336ec2537acaee0008e0
-        , r     = 0xf1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d38367
-        , s     = 0x019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p384r1
-        , msg   = "sample"
-        , d     = 0x6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5
-        , q     = ECC.Point 0xec3a4e415b4e19a4568618029f427fa5da9a8bc4ae92e02e06aae5286b300c64def8f0ea9055866064a254515480bc13
-                            0x8015d9b72d7d57244ea8ef9ac0c621896708a59367f9dfb9f54ca84b3f1c9db1288b231c3ae0d4fe7344fd2533264720
-        , k     = 0x180ae9f9aec5438a44bc159a1fcb277c7be54fa20e7cf404b490650a8acc414e375572342863c899f9f2edf9747a9b60
-        , r     = 0x21b13d1e013c7fa1392d03c5f99af8b30c570c6f98d4ea8e354b63a21d3daa33bde1e888e63355d92fa2b3c36d8fb2cd
-        , s     = 0xf3aa443fb107745bf4bd77cb3891674632068a10ca67e3d45db2266fa7d1feebefdc63eccd1ac42ec0cb8668a4fa0ab0
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p384r1
-        , msg   = "test"
-        , d     = 0x6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5
-        , q     = ECC.Point 0xec3a4e415b4e19a4568618029f427fa5da9a8bc4ae92e02e06aae5286b300c64def8f0ea9055866064a254515480bc13
-                            0x8015d9b72d7d57244ea8ef9ac0c621896708a59367f9dfb9f54ca84b3f1c9db1288b231c3ae0d4fe7344fd2533264720
-        , k     = 0x0cfac37587532347dc3389fdc98286bba8c73807285b184c83e62e26c401c0faa48dd070ba79921a3457abff2d630ad7
-        , r     = 0x6d6defac9ab64dabafe36c6bf510352a4cc27001263638e5b16d9bb51d451559f918eedaf2293be5b475cc8f0188636b
-        , s     = 0x2d46f3becbcc523d5f1a1256bf0c9b024d879ba9e838144c8ba6baeb4b53b47d51ab373f9845c0514eefb14024787265
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p521r1
-        , msg   = "sample"
-        , d     = 0x0fad06daa62ba3b25d2fb40133da757205de67f5bb0018fee8c86e1b68c7e75caa896eb32f1f47c70855836a6d16fcc1466f6d8fbec67db89ec0c08b0e996b83538
-        , q     = ECC.Point 0x1894550d0785932e00eaa23b694f213f8c3121f86dc97a04e5a7167db4e5bcd371123d46e45db6b5d5370a7f20fb633155d38ffa16d2bd761dcac474b9a2f5023a4
-                            0x0493101c962cd4d2fddf782285e64584139c2f91b47f87ff82354d6630f746a28a0db25741b5b34a828008b22acc23f924faafbd4d33f81ea66956dfeaa2bfdfcf5
-        , k     = 0x0edf38afcaaecab4383358b34d67c9f2216c8382aaea44a3dad5fdc9c32575761793fef24eb0fc276dfc4f6e3ec476752f043cf01415387470bcbd8678ed2c7e1a0
-        , r     = 0x1511bb4d675114fe266fc4372b87682baecc01d3cc62cf2303c92b3526012659d16876e25c7c1e57648f23b73564d67f61c6f14d527d54972810421e7d87589e1a7
-        , s     = 0x04a171143a83163d6df460aaf61522695f207a58b95c0644d87e52aa1a347916e4f7a72930b1bc06dbe22ce3f58264afd23704cbb63b29b931f7de6c9d949a7ecfc
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p521r1
-        , msg   = "test"
-        , d     = 0x0fad06daa62ba3b25d2fb40133da757205de67f5bb0018fee8c86e1b68c7e75caa896eb32f1f47c70855836a6d16fcc1466f6d8fbec67db89ec0c08b0e996b83538
-        , q     = ECC.Point 0x1894550d0785932e00eaa23b694f213f8c3121f86dc97a04e5a7167db4e5bcd371123d46e45db6b5d5370a7f20fb633155d38ffa16d2bd761dcac474b9a2f5023a4
-                            0x0493101c962cd4d2fddf782285e64584139c2f91b47f87ff82354d6630f746a28a0db25741b5b34a828008b22acc23f924faafbd4d33f81ea66956dfeaa2bfdfcf5
-        , k     = 0x01de74955efaabc4c4f17f8e84d881d1310b5392d7700275f82f145c61e843841af09035bf7a6210f5a431a6a9e81c9323354a9e69135d44ebd2fcaa7731b909258
-        , r     = 0x00e871c4a14f993c6c7369501900c4bc1e9c7b0b4ba44e04868b30b41d8071042eb28c4c250411d0ce08cd197e4188ea4876f279f90b3d8d74a3c76e6f1e4656aa8
-        , s     = 0x0cd52dbaa33b063c3a6cd8058a1fb0a46a4754b034fcc644766ca14da8ca5ca9fde00e88c1ad60ccba759025299079d7a427ec3cc5b619bfbc828e7769bcd694e86
-        }
-    ]
-
-rfc6979_vectorsSHA384 =
-    [ VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , msg   = "sample"
-        , d     = 0x6fab034934e4c0fc9ae67f5b5659a9d7d1fefd187ee09fd4
-        , q     = ECC.Point 0xac2c77f529f91689fea0ea5efec7f210d8eea0b9e047ed56
-                            0x3bc723e57670bd4887ebc732c523063d0a7c957bc97c1c43
-        , k     = 0x4730005c4fcb01834c063a7b6760096dbe284b8252ef4311
-        , r     = 0xda63bf0b9abcf948fbb1e9167f136145f7a20426dcc287d5
-        , s     = 0xc3aa2c960972bd7a2003a57e1c4c77f0578f8ae95e31ec5e
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , msg   = "test"
-        , d     = 0x6fab034934e4c0fc9ae67f5b5659a9d7d1fefd187ee09fd4
-        , q     = ECC.Point 0xac2c77f529f91689fea0ea5efec7f210d8eea0b9e047ed56
-                            0x3bc723e57670bd4887ebc732c523063d0a7c957bc97c1c43
-        , k     = 0x5afefb5d3393261b828db6c91fbc68c230727b030c975693
-        , r     = 0xb234b60b4db75a733e19280a7a6034bd6b1ee88af5332367
-        , s     = 0x7994090b2d59bb782be57e74a44c9a1c700413f8abefe77a
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p224r1
-        , msg   = "sample"
-        , d     = 0xf220266e1105bfe3083e03ec7a3a654651f45e37167e88600bf257c1
-        , q     = ECC.Point 0x00cf08da5ad719e42707fa431292dea11244d64fc51610d94b130d6c
-                            0xeeab6f3debe455e3dbf85416f7030cbd94f34f2d6f232c69f3c1385a
-        , k     = 0x52b40f5a9d3d13040f494e83d3906c6079f29981035c7bd51e5cac40
-        , r     = 0x0b115e5e36f0f9ec81f1325a5952878d745e19d7bb3eabfaba77e953
-        , s     = 0x830f34ccdfe826ccfdc81eb4129772e20e122348a2bbd889a1b1af1d
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p224r1
-        , msg   = "test"
-        , d     = 0xf220266e1105bfe3083e03ec7a3a654651f45e37167e88600bf257c1
-        , q     = ECC.Point 0x00cf08da5ad719e42707fa431292dea11244d64fc51610d94b130d6c
-                            0xeeab6f3debe455e3dbf85416f7030cbd94f34f2d6f232c69f3c1385a
-        , k     = 0x7046742b839478c1b5bd31db2e862ad868e1a45c863585b5f22bdc2d
-        , r     = 0x389b92682e399b26518a95506b52c03bc9379a9dadf3391a21fb0ea4
-        , s     = 0x414a718ed3249ff6dbc5b50c27f71f01f070944da22ab1f78f559aab
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p256r1
-        , msg   = "sample"
-        , d     = 0xc9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721
-        , q     = ECC.Point 0x60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6
-                            0x7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299
-        , k     = 0x09f634b188cefd98e7ec88b1aa9852d734d0bc272f7d2a47decc6ebeb375aad4
-        , r     = 0x0eafea039b20e9b42309fb1d89e213057cbf973dc0cfc8f129edddc800ef7719
-        , s     = 0x4861f0491e6998b9455193e34e7b0d284ddd7149a74b95b9261f13abde940954
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p256r1
-        , msg   = "test"
-        , d     = 0xc9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721
-        , q     = ECC.Point 0x60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6
-                            0x7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299
-        , k     = 0x16aeffa357260b04b1dd199693960740066c1a8f3e8edd79070aa914d361b3b8
-        , r     = 0x83910e8b48bb0c74244ebdf7f07a1c5413d61472bd941ef3920e623fbccebeb6
-        , s     = 0x8ddbec54cf8cd5874883841d712142a56a8d0f218f5003cb0296b6b509619f2c
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p384r1
-        , msg   = "sample"
-        , d     = 0x6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5
-        , q     = ECC.Point 0xec3a4e415b4e19a4568618029f427fa5da9a8bc4ae92e02e06aae5286b300c64def8f0ea9055866064a254515480bc13
-                            0x8015d9b72d7d57244ea8ef9ac0c621896708a59367f9dfb9f54ca84b3f1c9db1288b231c3ae0d4fe7344fd2533264720
-        , k     = 0x94ed910d1a099dad3254e9242ae85abde4ba15168eaf0ca87a555fd56d10fbca2907e3e83ba95368623b8c4686915cf9
-        , r     = 0x94edbb92a5ecb8aad4736e56c691916b3f88140666ce9fa73d64c4ea95ad133c81a648152e44acf96e36dd1e80fabe46
-        , s     = 0x99ef4aeb15f178cea1fe40db2603138f130e740a19624526203b6351d0a3a94fa329c145786e679e7b82c71a38628ac8
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p384r1
-        , msg   = "test"
-        , d     = 0x6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5
-        , q     = ECC.Point 0xec3a4e415b4e19a4568618029f427fa5da9a8bc4ae92e02e06aae5286b300c64def8f0ea9055866064a254515480bc13
-                            0x8015d9b72d7d57244ea8ef9ac0c621896708a59367f9dfb9f54ca84b3f1c9db1288b231c3ae0d4fe7344fd2533264720
-        , k     = 0x015ee46a5bf88773ed9123a5ab0807962d193719503c527b031b4c2d225092ada71f4a459bc0da98adb95837db8312ea
-        , r     = 0x8203b63d3c853e8d77227fb377bcf7b7b772e97892a80f36ab775d509d7a5feb0542a7f0812998da8f1dd3ca3cf023db
-        , s     = 0xddd0760448d42d8a43af45af836fce4de8be06b485e9b61b827c2f13173923e06a739f040649a667bf3b828246baa5a5
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p521r1
-        , msg   = "sample"
-        , d     = 0x0fad06daa62ba3b25d2fb40133da757205de67f5bb0018fee8c86e1b68c7e75caa896eb32f1f47c70855836a6d16fcc1466f6d8fbec67db89ec0c08b0e996b83538
-        , q     = ECC.Point 0x1894550d0785932e00eaa23b694f213f8c3121f86dc97a04e5a7167db4e5bcd371123d46e45db6b5d5370a7f20fb633155d38ffa16d2bd761dcac474b9a2f5023a4
-                            0x0493101c962cd4d2fddf782285e64584139c2f91b47f87ff82354d6630f746a28a0db25741b5b34a828008b22acc23f924faafbd4d33f81ea66956dfeaa2bfdfcf5
-        , k     = 0x1546a108bc23a15d6f21872f7ded661fa8431ddbd922d0dcdb77cc878c8553ffad064c95a920a750ac9137e527390d2d92f153e66196966ea554d9adfcb109c4211
-        , r     = 0x1ea842a0e17d2de4f92c15315c63ddf72685c18195c2bb95e572b9c5136ca4b4b576ad712a52be9730627d16054ba40cc0b8d3ff035b12ae75168397f5d50c67451
-        , s     = 0x1f21a3cee066e1961025fb048bd5fe2b7924d0cd797babe0a83b66f1e35eeaf5fde143fa85dc394a7dee766523393784484bdf3e00114a1c857cde1aa203db65d61
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p521r1
-        , msg   = "test"
-        , d     = 0x0fad06daa62ba3b25d2fb40133da757205de67f5bb0018fee8c86e1b68c7e75caa896eb32f1f47c70855836a6d16fcc1466f6d8fbec67db89ec0c08b0e996b83538
-        , q     = ECC.Point 0x1894550d0785932e00eaa23b694f213f8c3121f86dc97a04e5a7167db4e5bcd371123d46e45db6b5d5370a7f20fb633155d38ffa16d2bd761dcac474b9a2f5023a4
-                            0x0493101c962cd4d2fddf782285e64584139c2f91b47f87ff82354d6630f746a28a0db25741b5b34a828008b22acc23f924faafbd4d33f81ea66956dfeaa2bfdfcf5
-        , k     = 0x1f1fc4a349a7da9a9e116bfdd055dc08e78252ff8e23ac276ac88b1770ae0b5dceb1ed14a4916b769a523ce1e90ba22846af11df8b300c38818f713dadd85de0c88
-        , r     = 0x14bee21a18b6d8b3c93fab08d43e739707953244fdbe924fa926d76669e7ac8c89df62ed8975c2d8397a65a49dcc09f6b0ac62272741924d479354d74ff6075578c
-        , s     = 0x133330865c067a0eaf72362a65e2d7bc4e461e8c8995c3b6226a21bd1aa78f0ed94fe536a0dca35534f0cd1510c41525d163fe9d74d134881e35141ed5e8e95b979
-        }
-    ]
-
-rfc6979_vectorsSHA512 =
-    [ VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , msg   = "sample"
-        , d     = 0x6fab034934e4c0fc9ae67f5b5659a9d7d1fefd187ee09fd4
-        , q     = ECC.Point 0xac2c77f529f91689fea0ea5efec7f210d8eea0b9e047ed56
-                            0x3bc723e57670bd4887ebc732c523063d0a7c957bc97c1c43
-        , k     = 0xa2ac7ab055e4f20692d49209544c203a7d1f2c0bfbc75db1
-        , r     = 0x4d60c5ab1996bd848343b31c00850205e2ea6922dac2e4b8
-        , s     = 0x3f6e837448f027a1bf4b34e796e32a811cbb4050908d8f67
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p192r1
-        , msg   = "test"
-        , d     = 0x6fab034934e4c0fc9ae67f5b5659a9d7d1fefd187ee09fd4
-        , q     = ECC.Point 0xac2c77f529f91689fea0ea5efec7f210d8eea0b9e047ed56
-                            0x3bc723e57670bd4887ebc732c523063d0a7c957bc97c1c43
-        , k     = 0x0758753a5254759c7cfbad2e2d9b0792eee44136c9480527
-        , r     = 0xfe4f4ae86a58b6507946715934fe2d8ff9d95b6b098fe739
-        , s     = 0x74cf5605c98fba0e1ef34d4b5a1577a7dcf59457cae52290
-           }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p224r1
-        , msg   = "sample"
-        , d     = 0xf220266e1105bfe3083e03ec7a3a654651f45e37167e88600bf257c1
-        , q     = ECC.Point 0x00cf08da5ad719e42707fa431292dea11244d64fc51610d94b130d6c
-                            0xeeab6f3debe455e3dbf85416f7030cbd94f34f2d6f232c69f3c1385a
-        , k     = 0x9db103ffededf9cfdba05184f925400c1653b8501bab89cea0fbec14
-        , r     = 0x074bd1d979d5f32bf958ddc61e4fb4872adcafeb2256497cdac30397
-        , s     = 0xa4ceca196c3d5a1ff31027b33185dc8ee43f288b21ab342e5d8eb084
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p224r1
-        , msg   = "test"
-        , d     = 0xf220266e1105bfe3083e03ec7a3a654651f45e37167e88600bf257c1
-        , q     = ECC.Point 0x00cf08da5ad719e42707fa431292dea11244d64fc51610d94b130d6c
-                            0xeeab6f3debe455e3dbf85416f7030cbd94f34f2d6f232c69f3c1385a
-        , k     = 0xe39c2aa4ea6be2306c72126d40ed77bf9739bb4d6ef2bbb1dcb6169d
-        , r     = 0x049f050477c5add858cac56208394b5a55baebbe887fdf765047c17c
-        , s     = 0x077eb13e7005929cefa3cd0403c7cdcc077adf4e44f3c41b2f60ecff
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p256r1
-        , msg   = "sample"
-        , d     = 0xc9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721
-        , q     = ECC.Point 0x60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6
-                            0x7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299
-        , k     = 0x5fa81c63109badb88c1f367b47da606da28cad69aa22c4fe6ad7df73a7173aa5
-        , r     = 0x8496a60b5e9b47c825488827e0495b0e3fa109ec4568fd3f8d1097678eb97f00
-        , s     = 0x2362ab1adbe2b8adf9cb9edab740ea6049c028114f2460f96554f61fae3302fe
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p256r1
-        , msg   = "test"
-        , d     = 0xc9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721
-        , q     = ECC.Point 0x60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6
-                            0x7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299
-        , k     = 0x6915d11632aca3c40d5d51c08daf9c555933819548784480e93499000d9f0b7f
-        , r     = 0x461d93f31b6540894788fd206c07cfa0cc35f46fa3c91816fff1040ad1581a04
-        , s     = 0x39af9f15de0db8d97e72719c74820d304ce5226e32dedae67519e840d1194e55
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p384r1
-        , msg   = "sample"
-        , d     = 0x6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5
-        , q     = ECC.Point 0xec3a4e415b4e19a4568618029f427fa5da9a8bc4ae92e02e06aae5286b300c64def8f0ea9055866064a254515480bc13
-                            0x8015d9b72d7d57244ea8ef9ac0c621896708a59367f9dfb9f54ca84b3f1c9db1288b231c3ae0d4fe7344fd2533264720
-        , k     = 0x92fc3c7183a883e24216d1141f1a8976c5b0dd797dfa597e3d7b32198bd35331a4e966532593a52980d0e3aaa5e10ec3
-        , r     = 0xed0959d5880ab2d869ae7f6c2915c6d60f96507f9cb3e047c0046861da4a799cfe30f35cc900056d7c99cd7882433709
-        , s     = 0x512c8cceee3890a84058ce1e22dbc2198f42323ce8aca9135329f03c068e5112dc7cc3ef3446defceb01a45c2667fdd5
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p384r1
-        , msg   = "test"
-        , d     = 0x6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5
-        , q     = ECC.Point 0xec3a4e415b4e19a4568618029f427fa5da9a8bc4ae92e02e06aae5286b300c64def8f0ea9055866064a254515480bc13
-                            0x8015d9b72d7d57244ea8ef9ac0c621896708a59367f9dfb9f54ca84b3f1c9db1288b231c3ae0d4fe7344fd2533264720
-        , k     = 0x3780c4f67cb15518b6acae34c9f83568d2e12e47deab6c50a4e4ee5319d1e8ce0e2cc8a136036dc4b9c00e6888f66b6c
-        , r     = 0xa0d5d090c9980faf3c2ce57b7ae951d31977dd11c775d314af55f76c676447d06fb6495cd21b4b6e340fc236584fb277
-        , s     = 0x976984e59b4c77b0e8e4460dca3d9f20e07b9bb1f63beefaf576f6b2e8b224634a2092cd3792e0159ad9cee37659c736
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p521r1
-        , msg   = "sample"
-        , d     = 0x0fad06daa62ba3b25d2fb40133da757205de67f5bb0018fee8c86e1b68c7e75caa896eb32f1f47c70855836a6d16fcc1466f6d8fbec67db89ec0c08b0e996b83538
-        , q     = ECC.Point 0x1894550d0785932e00eaa23b694f213f8c3121f86dc97a04e5a7167db4e5bcd371123d46e45db6b5d5370a7f20fb633155d38ffa16d2bd761dcac474b9a2f5023a4
-                            0x0493101c962cd4d2fddf782285e64584139c2f91b47f87ff82354d6630f746a28a0db25741b5b34a828008b22acc23f924faafbd4d33f81ea66956dfeaa2bfdfcf5
-        , k     = 0x1dae2ea071f8110dc26882d4d5eae0621a3256fc8847fb9022e2b7d28e6f10198b1574fdd03a9053c08a1854a168aa5a57470ec97dd5ce090124ef52a2f7ecbffd3
-        , r     = 0x0c328fafcbd79dd77850370c46325d987cb525569fb63c5d3bc53950e6d4c5f174e25a1ee9017b5d450606add152b534931d7d4e8455cc91f9b15bf05ec36e377fa
-        , s     = 0x0617cce7cf5064806c467f678d3b4080d6f1cc50af26ca209417308281b68af282623eaa63e5b5c0723d8b8c37ff0777b1a20f8ccb1dccc43997f1ee0e44da4a67a
-        }
-    , VectorECDSA
-        { curve = ECC.getCurveByName ECC.SEC_p521r1
-        , msg   = "test"
-        , d     = 0x0fad06daa62ba3b25d2fb40133da757205de67f5bb0018fee8c86e1b68c7e75caa896eb32f1f47c70855836a6d16fcc1466f6d8fbec67db89ec0c08b0e996b83538
-        , q     = ECC.Point 0x1894550d0785932e00eaa23b694f213f8c3121f86dc97a04e5a7167db4e5bcd371123d46e45db6b5d5370a7f20fb633155d38ffa16d2bd761dcac474b9a2f5023a4
-                            0x0493101c962cd4d2fddf782285e64584139c2f91b47f87ff82354d6630f746a28a0db25741b5b34a828008b22acc23f924faafbd4d33f81ea66956dfeaa2bfdfcf5
-        , k     = 0x16200813020ec986863bedfc1b121f605c1215645018aea1a7b215a564de9eb1b38a67aa1128b80ce391c4fb71187654aaa3431027bfc7f395766ca988c964dc56d
-        , r     = 0x13e99020abf5cee7525d16b69b229652ab6bdf2affcaef38773b4b7d08725f10cdb93482fdcc54edcee91eca4166b2a7c6265ef0ce2bd7051b7cef945babd47ee6d
-        , s     = 0x1fbd0013c674aa79cb39849527916ce301c66ea7ce8b80682786ad60f98f7e78a19ca69eff5c57400e3b3a0ad66ce0978214d13baf4e9ac60752f7b155e2de4dce3
-        }
-    ]
-
-vectorToPrivate :: VectorECDSA -> ECDSA.PrivateKey
-vectorToPrivate vector = ECDSA.PrivateKey (curve vector) (d vector)
-
-vectorToPublic :: VectorECDSA -> ECDSA.PublicKey
-vectorToPublic vector = ECDSA.PublicKey (curve vector) (q vector)
-
-doSignatureTest hashAlg i vector = testCase (show i) (expected @=? actual)
-  where expected = Just $ ECDSA.Signature (r vector) (s vector)
-        actual   = ECDSA.signWith (k vector) (vectorToPrivate vector) hashAlg (msg vector)
-
-doVerifyTest hashAlg i vector = testCase (show i) (True @=? actual)
-  where actual = ECDSA.verify hashAlg (vectorToPublic vector) (ECDSA.Signature (r vector) (s vector)) (msg vector)
-
-ecdsaTests = testGroup "ECDSA"
-    [ testGroup "SHA1"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA1) [katZero..] vectorsSHA1
-        , testGroup "verify" $ zipWith (doVerifyTest SHA1) [katZero..] vectorsSHA1
-        ]
-    , testGroup "SHA224"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA224) [katZero..] rfc6979_vectorsSHA224
-        , testGroup "verify" $ zipWith (doVerifyTest SHA224) [katZero..] rfc6979_vectorsSHA224
-        ]
-    , testGroup "SHA256"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA256) [katZero..] rfc6979_vectorsSHA256
-        , testGroup "verify" $ zipWith (doVerifyTest SHA256) [katZero..] rfc6979_vectorsSHA256
-        ]
-    , testGroup "SHA384"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA384) [katZero..] rfc6979_vectorsSHA384
-        , testGroup "verify" $ zipWith (doVerifyTest SHA384) [katZero..] rfc6979_vectorsSHA384
-        ]
-    , testGroup "SHA512"
-        [ testGroup "signature" $ zipWith (doSignatureTest SHA512) [katZero..] rfc6979_vectorsSHA512
-        , testGroup "verify" $ zipWith (doVerifyTest SHA512) [katZero..] rfc6979_vectorsSHA512
-        ]
-    ]
+{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE OverloadedStrings #-}
+
+module KAT_PubKey.ECDSA (ecdsaTests) where
+
+import Crypto.Hash
+import Crypto.Number.Serialize
+import Crypto.PubKey.ECC.ECDSA (
+    PrivateKey (..),
+    PublicKey (..),
+    Signature (..),
+    deterministicNonce,
+    signWith,
+    verify,
+ )
+import Crypto.PubKey.ECC.Generate
+import Crypto.PubKey.ECC.Types
+import Data.ByteString (ByteString)
+import qualified Data.ByteString as B
+import Test.Tasty
+import Test.Tasty.HUnit
+import Text.Printf
+
+-- existential type allows storing different hash algorithms in the same value
+data HashAlg = forall hash. (Show hash, HashAlgorithm hash) => HashAlg hash
+instance Show HashAlg where show (HashAlg alg) = show alg
+
+data Entry = Entry
+    { curveName :: CurveName
+    , privateNumber :: PrivateNumber
+    , publicPoint :: PublicPoint
+    , hashAlgorithm :: HashAlg
+    , message :: ByteString
+    , nonce :: Integer
+    , signature :: Signature
+    }
+instance Show Entry where
+    show entry =
+        printf
+            "%s.%s.%s"
+            (show $ curveName entry)
+            (show $ B.take 8 $ message entry)
+            (show $ hashAlgorithm entry)
+
+normalize :: Entry -> Entry
+normalize entry
+    | s <= n `div` 2 = entry
+    | otherwise = entry{signature = Signature r (n - s)}
+  where
+    Signature r s = signature entry
+    n = ecc_n $ common_curve $ getCurveByName $ curveName entry
+
+-- taken from GEC 2: Test Vectors for SEC 1
+gec2Entries :: [Entry]
+gec2Entries =
+    [ Entry
+        { curveName = SEC_p160r1
+        , privateNumber = 971761939728640320549601132085879836204587084162
+        , publicPoint =
+            Point
+                466448783855397898016055842232266600516272889280
+                1110706324081757720403272427311003102474457754220
+        , hashAlgorithm = HashAlg SHA1
+        , message = "abc"
+        , nonce = 702232148019446860144825009548118511996283736794
+        , signature =
+            Signature
+                { sign_r = 1176954224688105769566774212902092897866168635793
+                , sign_s = 299742580584132926933316745664091704165278518100
+                }
+        }
+    , Entry
+        { curveName = SEC_t163k1
+        , privateNumber = 0x00000011f2626d90d26cb4c0379043b26e64107fc
+        , publicPoint =
+            Point
+                0x0389fa5ad7f8304325a8c060ef7dcb83042c045bc
+                0x0eefa094a5054da196943cc80509dcb9f59e5bc2e
+        , hashAlgorithm = HashAlg SHA1
+        , message =
+            i2osp
+                0xa2c1a03fdd00521bb08fc88d20344321977aaf637ef9d5470dd7d2c8628fc8d0d1f1d3587c6b3fd02386f8c13db341b14748a9475cc63baf065df64054b27d5c2cdf0f98e3bbb81d0b5dc94f8cdb87acf75720f6163de394c8c6af360bc1acb85b923a493b7b27cc111a257e36337bd94eb0fab9d5e633befb1ae7f1b244bfaa
+        , nonce = 0x0000000c3a4ff97286126dab1e5089395fcc47ebb
+        , signature =
+            Signature
+                { sign_r = 0x0dbe6c3a1dc851e7f2338b5c26c62b4b37bf8035c
+                , sign_s = 0x1c76458135b1ff9fbd23009b8414a47996126b56a
+                }
+        }
+    , Entry
+        { curveName = SEC_t163k1
+        , privateNumber = 0x00000006a3803301daee9af09bb5b6c991a4f49a4
+        , publicPoint =
+            Point
+                0x4b500f555e857da8c299780130c5c3f48f02ee322
+                0x5c1c0ae25b47f06cc46fb86b12d2d8c0ba6a4bf07
+        , hashAlgorithm = HashAlg SHA1
+        , message =
+            i2osp
+                0x67048080daaeb77d3ac31babdf8be23dbe75ceb4dfb94aa8113db5c5dcb6fe14b70f717b7b0ed0881835a66a86e6d840ffcb7d976c75ef2d1d4322fbbc86357384e24707aef88cea2c41a01a9a3d1b9e72ce650c7fdecc4f9448d3a77df6cdf13647ab295bb3132de0b1b2c402d8d2de7d452f1e003e0695de1470d1064eee16
+        , nonce = 0x0000002f39fbf77f3e0dc046116de692b6cf91b16
+        , signature =
+            Signature
+                { sign_r = 0x3d3eeda42f65d727f4a564f1415654356c6c57a6c
+                , sign_s = 0x35e4d43c5f08baddf138449db1ad0b7872552b7cd
+                }
+        }
+    , Entry
+        { curveName = SEC_t163k1
+        , privateNumber = 0x0000002e28676514bd93fea11b62db0f6e324b18d
+        , publicPoint =
+            Point
+                0x3f9c90b71f6a1de20a2716f38ef1b5f98c757bd42
+                0x2ff0a5d266d447ef62d43fbca6c34c08c1ce35a40
+        , hashAlgorithm = HashAlg SHA1
+        , message =
+            i2osp
+                0x77e007dc2acd7248256165a4b30e98986f51a81efd926b85f74c81bc2a6d2bcd030060a844091e22fbb0ff3db5a20caaefb5d58ccdcbc27f0ff8a4d940e78f303079ec1ca5b0ca3d4ecc7580f8b34a9f0496c9e719d2ec3e1614b7644bc11179e895d2c0b58a1da204fbf0f6e509f97f983eacb6487092caf6e8e4e6b3c458b2
+        , nonce = 0x00000001233ae699883e74e7f4dfb5279ff22280a
+        , signature =
+            Signature
+                { sign_r = 0x39de3cd2cf04145e522b8fba3f23e9218226e0860
+                , sign_s = 0x2af62bfb3cfa202e2342606ee5bb0934c3b0375b6
+                }
+        }
+    , Entry
+        { curveName = SEC_t163k1
+        , privateNumber = 0x000000361dd088e3a6d3c910686c8dce57e5d4d8e
+        , publicPoint =
+            Point
+                0x064f905c1da9d7e9c32d81890ae6f30dcc7839d32
+                0x06f1faedb6d9032016d3b681e7cf69c29d29eb27b
+        , hashAlgorithm = HashAlg SHA1
+        , message =
+            i2osp
+                0xfbacfcce4688748406ddf5c3495021eef8fb399865b649eb2395a04a1ab28335da2c236d306fcc59f7b65ea931cf0139571e1538ede5688958c3ac69f47a285362f5ad201f89cc735b7b465408c2c41b310fc8908d0be45054df2a7351fae36b390e842f3b5cdd9ad832940df5b2d25c2ed43ce86eaf2508bcf401ae58bb1d47
+        , nonce = 0x00000022f723e9f5da56d3d0837d5dca2f937395f
+        , signature =
+            Signature
+                { sign_r = 0x374cdc8571083fecfbd4e25e1cd69ecc66b715f2d
+                , sign_s = 0x313b10949222929b2f20b15d446c27d6dcae3f086
+                }
+        }
+    ]
+
+data EntryCurve = EntryCurve
+    { ecName :: CurveName
+    , ecPrivate :: PrivateNumber
+    , ecPublic :: PublicPoint
+    , ecMessages :: [EntryMessage]
+    }
+data EntryMessage = EntryMessage
+    { emMessage :: ByteString
+    , emHashes :: [EntryHash]
+    }
+data EntryHash = EntryHash
+    { ehAlgorithm :: HashAlg
+    , ehK :: Integer
+    , ehR :: Integer
+    , ehS :: Integer
+    }
+
+flatten :: [EntryCurve] -> [Entry]
+flatten hierarchy = do
+    entryCurve <- hierarchy
+    entryMessage <- ecMessages entryCurve
+    entryHash <- emHashes entryMessage
+    pure $
+        Entry
+            { curveName = ecName entryCurve
+            , privateNumber = ecPrivate entryCurve
+            , publicPoint = ecPublic entryCurve
+            , hashAlgorithm = ehAlgorithm entryHash
+            , message = emMessage entryMessage
+            , nonce = ehK entryHash
+            , signature = Signature (ehR entryHash) (ehS entryHash)
+            }
+
+-- taken from RFC 6979
+rfc6979Entries :: [EntryCurve]
+rfc6979Entries =
+    [ EntryCurve
+        { ecName = SEC_p192r1
+        , ecPrivate = 0x6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4
+        , ecPublic =
+            Point
+                0xAC2C77F529F91689FEA0EA5EFEC7F210D8EEA0B9E047ED56
+                0x3BC723E57670BD4887EBC732C523063D0A7C957BC97C1C43
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x37D7CA00D2C7B0E5E412AC03BD44BA837FDD5B28CD3B0021
+                        , ehR = 0x98C6BD12B23EAF5E2A2045132086BE3EB8EBD62ABF6698FF
+                        , ehS = 0x57A22B07DEA9530F8DE9471B1DC6624472E8E2844BC25B64
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x4381526B3FC1E7128F202E194505592F01D5FF4C5AF015D8
+                        , ehR = 0xA1F00DAD97AEEC91C95585F36200C65F3C01812AA60378F5
+                        , ehS = 0xE07EC1304C7C6C9DEBBE980B9692668F81D4DE7922A0F97A
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x32B1B6D7D42A05CB449065727A84804FB1A3E34D8F261496
+                        , ehR = 0x4B0B8CE98A92866A2820E20AA6B75B56382E0F9BFD5ECB55
+                        , ehS = 0xCCDB006926EA9565CBADC840829D8C384E06DE1F1E381B85
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x4730005C4FCB01834C063A7B6760096DBE284B8252EF4311
+                        , ehR = 0xDA63BF0B9ABCF948FBB1E9167F136145F7A20426DCC287D5
+                        , ehS = 0xC3AA2C960972BD7A2003A57E1C4C77F0578F8AE95E31EC5E
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0xA2AC7AB055E4F20692D49209544C203A7D1F2C0BFBC75DB1
+                        , ehR = 0x4D60C5AB1996BD848343B31C00850205E2EA6922DAC2E4B8
+                        , ehS = 0x3F6E837448F027A1BF4B34E796E32A811CBB4050908D8F67
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0xD9CF9C3D3297D3260773A1DA7418DB5537AB8DD93DE7FA25
+                        , ehR = 0x0F2141A0EBBC44D2E1AF90A50EBCFCE5E197B3B7D4DE036D
+                        , ehS = 0xEB18BC9E1F3D7387500CB99CF5F7C157070A8961E38700B7
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0xF5DC805F76EF851800700CCE82E7B98D8911B7D510059FBE
+                        , ehR = 0x6945A1C1D1B2206B8145548F633BB61CEF04891BAF26ED34
+                        , ehS = 0xB7FB7FDFC339C0B9BD61A9F5A8EAF9BE58FC5CBA2CB15293
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x5C4CE89CF56D9E7C77C8585339B006B97B5F0680B4306C6C
+                        , ehR = 0x3A718BD8B4926C3B52EE6BBE67EF79B18CB6EB62B1AD97AE
+                        , ehS = 0x5662E6848A4A19B1F1AE2F72ACD4B8BBE50F1EAC65D9124F
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x5AFEFB5D3393261B828DB6C91FBC68C230727B030C975693
+                        , ehR = 0xB234B60B4DB75A733E19280A7A6034BD6B1EE88AF5332367
+                        , ehS = 0x7994090B2D59BB782BE57E74A44C9A1C700413F8ABEFE77A
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x0758753A5254759C7CFBAD2E2D9B0792EEE44136C9480527
+                        , ehR = 0xFE4F4AE86A58B6507946715934FE2D8FF9D95B6B098FE739
+                        , ehS = 0x74CF5605C98FBA0E1EF34D4B5A1577A7DCF59457CAE52290
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_p224r1
+        , ecPrivate = 0xF220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1
+        , ecPublic =
+            Point
+                0x00CF08DA5AD719E42707FA431292DEA11244D64FC51610D94B130D6C
+                0xEEAB6F3DEBE455E3DBF85416F7030CBD94F34F2D6F232C69F3C1385A
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x7EEFADD91110D8DE6C2C470831387C50D3357F7F4D477054B8B426BC
+                        , ehR = 0x22226F9D40A96E19C4A301CE5B74B115303C0F3A4FD30FC257FB57AC
+                        , ehS = 0x66D1CDD83E3AF75605DD6E2FEFF196D30AA7ED7A2EDF7AF475403D69
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0xC1D1F2F10881088301880506805FEB4825FE09ACB6816C36991AA06D
+                        , ehR = 0x1CDFE6662DDE1E4A1EC4CDEDF6A1F5A2FB7FBD9145C12113E6ABFD3E
+                        , ehS = 0xA6694FD7718A21053F225D3F46197CA699D45006C06F871808F43EBC
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0xAD3029E0278F80643DE33917CE6908C70A8FF50A411F06E41DEDFCDC
+                        , ehR = 0x61AA3DA010E8E8406C656BC477A7A7189895E7E840CDFE8FF42307BA
+                        , ehS = 0xBC814050DAB5D23770879494F9E0A680DC1AF7161991BDE692B10101
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x52B40F5A9D3D13040F494E83D3906C6079F29981035C7BD51E5CAC40
+                        , ehR = 0x0B115E5E36F0F9EC81F1325A5952878D745E19D7BB3EABFABA77E953
+                        , ehS = 0x830F34CCDFE826CCFDC81EB4129772E20E122348A2BBD889A1B1AF1D
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x9DB103FFEDEDF9CFDBA05184F925400C1653B8501BAB89CEA0FBEC14
+                        , ehR = 0x074BD1D979D5F32BF958DDC61E4FB4872ADCAFEB2256497CDAC30397
+                        , ehS = 0xA4CECA196C3D5A1FF31027B33185DC8EE43F288B21AB342E5D8EB084
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x2519178F82C3F0E4F87ED5883A4E114E5B7A6E374043D8EFD329C253
+                        , ehR = 0xDEAA646EC2AF2EA8AD53ED66B2E2DDAA49A12EFD8356561451F3E21C
+                        , ehS = 0x95987796F6CF2062AB8135271DE56AE55366C045F6D9593F53787BD2
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0xDF8B38D40DCA3E077D0AC520BF56B6D565134D9B5F2EAE0D34900524
+                        , ehR = 0xC441CE8E261DED634E4CF84910E4C5D1D22C5CF3B732BB204DBEF019
+                        , ehS = 0x902F42847A63BDC5F6046ADA114953120F99442D76510150F372A3F4
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0xFF86F57924DA248D6E44E8154EB69F0AE2AEBAEE9931D0B5A969F904
+                        , ehR = 0xAD04DDE87B84747A243A631EA47A1BA6D1FAA059149AD2440DE6FBA6
+                        , ehS = 0x178D49B1AE90E3D8B629BE3DB5683915F4E8C99FDF6E666CF37ADCFD
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x7046742B839478C1B5BD31DB2E862AD868E1A45C863585B5F22BDC2D
+                        , ehR = 0x389B92682E399B26518A95506B52C03BC9379A9DADF3391A21FB0EA4
+                        , ehS = 0x414A718ED3249FF6DBC5B50C27F71F01F070944DA22AB1F78F559AAB
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0xE39C2AA4EA6BE2306C72126D40ED77BF9739BB4D6EF2BBB1DCB6169D
+                        , ehR = 0x049F050477C5ADD858CAC56208394B5A55BAEBBE887FDF765047C17C
+                        , ehS = 0x077EB13E7005929CEFA3CD0403C7CDCC077ADF4E44F3C41B2F60ECFF
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_p256r1
+        , ecPrivate = 0xC9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721
+        , ecPublic =
+            Point
+                0x60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6
+                0x7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x882905F1227FD620FBF2ABF21244F0BA83D0DC3A9103DBBEE43A1FB858109DB4
+                        , ehR = 0x61340C88C3AAEBEB4F6D667F672CA9759A6CCAA9FA8811313039EE4A35471D32
+                        , ehS = 0x6D7F147DAC089441BB2E2FE8F7A3FA264B9C475098FDCF6E00D7C996E1B8B7EB
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x103F90EE9DC52E5E7FB5132B7033C63066D194321491862059967C715985D473
+                        , ehR = 0x53B2FFF5D1752B2C689DF257C04C40A587FABABB3F6FC2702F1343AF7CA9AA3F
+                        , ehS = 0xB9AFB64FDC03DC1A131C7D2386D11E349F070AA432A4ACC918BEA988BF75C74C
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0xA6E3C57DD01ABE90086538398355DD4C3B17AA873382B0F24D6129493D8AAD60
+                        , ehR = 0xEFD48B2AACB6A8FD1140DD9CD45E81D69D2C877B56AAF991C34D0EA84EAF3716
+                        , ehS = 0xF7CB1C942D657C41D436C7A1B6E29F65F3E900DBB9AFF4064DC4AB2F843ACDA8
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x09F634B188CEFD98E7EC88B1AA9852D734D0BC272F7D2A47DECC6EBEB375AAD4
+                        , ehR = 0x0EAFEA039B20E9B42309FB1D89E213057CBF973DC0CFC8F129EDDDC800EF7719
+                        , ehS = 0x4861F0491E6998B9455193E34E7B0D284DDD7149A74B95B9261F13ABDE940954
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x5FA81C63109BADB88C1F367B47DA606DA28CAD69AA22C4FE6AD7DF73A7173AA5
+                        , ehR = 0x8496A60B5E9B47C825488827E0495B0E3FA109EC4568FD3F8D1097678EB97F00
+                        , ehS = 0x2362AB1ADBE2B8ADF9CB9EDAB740EA6049C028114F2460F96554F61FAE3302FE
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x8C9520267C55D6B980DF741E56B4ADEE114D84FBFA2E62137954164028632A2E
+                        , ehR = 0x0CBCC86FD6ABD1D99E703E1EC50069EE5C0B4BA4B9AC60E409E8EC5910D81A89
+                        , ehS = 0x01B9D7B73DFAA60D5651EC4591A0136F87653E0FD780C3B1BC872FFDEAE479B1
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x669F4426F2688B8BE0DB3A6BD1989BDAEFFF84B649EEB84F3DD26080F667FAA7
+                        , ehR = 0xC37EDB6F0AE79D47C3C27E962FA269BB4F441770357E114EE511F662EC34A692
+                        , ehS = 0xC820053A05791E521FCAAD6042D40AEA1D6B1A540138558F47D0719800E18F2D
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0xD16B6AE827F17175E040871A1C7EC3500192C4C92677336EC2537ACAEE0008E0
+                        , ehR = 0xF1ABB023518351CD71D881567B1EA663ED3EFCF6C5132B354F28D3B0B7D38367
+                        , ehS = 0x019F4113742A2B14BD25926B49C649155F267E60D3814B4C0CC84250E46F0083
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x16AEFFA357260B04B1DD199693960740066C1A8F3E8EDD79070AA914D361B3B8
+                        , ehR = 0x83910E8B48BB0C74244EBDF7F07A1C5413D61472BD941EF3920E623FBCCEBEB6
+                        , ehS = 0x8DDBEC54CF8CD5874883841D712142A56A8D0F218F5003CB0296B6B509619F2C
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x6915D11632ACA3C40D5D51C08DAF9C555933819548784480E93499000D9F0B7F
+                        , ehR = 0x461D93F31B6540894788FD206C07CFA0CC35F46FA3C91816FFF1040AD1581A04
+                        , ehS = 0x39AF9F15DE0DB8D97E72719C74820D304CE5226E32DEDAE67519E840D1194E55
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_p384r1
+        , ecPrivate =
+            0x6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5
+        , ecPublic =
+            Point
+                0xEC3A4E415B4E19A4568618029F427FA5DA9A8BC4AE92E02E06AAE5286B300C64DEF8F0EA9055866064A254515480BC13
+                0x8015D9B72D7D57244EA8EF9AC0C621896708A59367F9DFB9F54CA84B3F1C9DB1288B231C3AE0D4FE7344FD2533264720
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x4471EF7518BB2C7C20F62EAE1C387AD0C5E8E470995DB4ACF694466E6AB096630F29E5938D25106C3C340045A2DB01A7
+                        , ehR =
+                            0xEC748D839243D6FBEF4FC5C4859A7DFFD7F3ABDDF72014540C16D73309834FA37B9BA002899F6FDA3A4A9386790D4EB2
+                        , ehS =
+                            0xA3BCFA947BEEF4732BF247AC17F71676CB31A847B9FF0CBC9C9ED4C1A5B3FACF26F49CA031D4857570CCB5CA4424A443
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0xA4E4D2F0E729EB786B31FC20AD5D849E304450E0AE8E3E341134A5C1AFA03CAB8083EE4E3C45B06A5899EA56C51B5879
+                        , ehR =
+                            0x42356E76B55A6D9B4631C865445DBE54E056D3B3431766D0509244793C3F9366450F76EE3DE43F5A125333A6BE060122
+                        , ehS =
+                            0x9DA0C81787064021E78DF658F2FBB0B042BF304665DB721F077A4298B095E4834C082C03D83028EFBF93A3C23940CA8D
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x180AE9F9AEC5438A44BC159A1FCB277C7BE54FA20E7CF404B490650A8ACC414E375572342863C899F9F2EDF9747A9B60
+                        , ehR =
+                            0x21B13D1E013C7FA1392D03C5F99AF8B30C570C6F98D4EA8E354B63A21D3DAA33BDE1E888E63355D92FA2B3C36D8FB2CD
+                        , ehS =
+                            0xF3AA443FB107745BF4BD77CB3891674632068A10CA67E3D45DB2266FA7D1FEEBEFDC63ECCD1AC42EC0CB8668A4FA0AB0
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x94ED910D1A099DAD3254E9242AE85ABDE4BA15168EAF0CA87A555FD56D10FBCA2907E3E83BA95368623B8C4686915CF9
+                        , ehR =
+                            0x94EDBB92A5ECB8AAD4736E56C691916B3F88140666CE9FA73D64C4EA95AD133C81A648152E44ACF96E36DD1E80FABE46
+                        , ehS =
+                            0x99EF4AEB15F178CEA1FE40DB2603138F130E740A19624526203B6351D0A3A94FA329C145786E679E7B82C71A38628AC8
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x92FC3C7183A883E24216D1141F1A8976C5B0DD797DFA597E3D7B32198BD35331A4E966532593A52980D0E3AAA5E10EC3
+                        , ehR =
+                            0xED0959D5880AB2D869AE7F6C2915C6D60F96507F9CB3E047C0046861DA4A799CFE30F35CC900056D7C99CD7882433709
+                        , ehS =
+                            0x512C8CCEEE3890A84058CE1E22DBC2198F42323CE8ACA9135329F03C068E5112DC7CC3EF3446DEFCEB01A45C2667FDD5
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x66CC2C8F4D303FC962E5FF6A27BD79F84EC812DDAE58CF5243B64A4AD8094D47EC3727F3A3C186C15054492E30698497
+                        , ehR =
+                            0x4BC35D3A50EF4E30576F58CD96CE6BF638025EE624004A1F7789A8B8E43D0678ACD9D29876DAF46638645F7F404B11C7
+                        , ehS =
+                            0xD5A6326C494ED3FF614703878961C0FDE7B2C278F9A65FD8C4B7186201A2991695BA1C84541327E966FA7B50F7382282
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x18FA39DB95AA5F561F30FA3591DC59C0FA3653A80DAFFA0B48D1A4C6DFCBFF6E3D33BE4DC5EB8886A8ECD093F2935726
+                        , ehR =
+                            0xE8C9D0B6EA72A0E7837FEA1D14A1A9557F29FAA45D3E7EE888FC5BF954B5E62464A9A817C47FF78B8C11066B24080E72
+                        , ehS =
+                            0x07041D4A7A0379AC7232FF72E6F77B6DDB8F09B16CCE0EC3286B2BD43FA8C6141C53EA5ABEF0D8231077A04540A96B66
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x0CFAC37587532347DC3389FDC98286BBA8C73807285B184C83E62E26C401C0FAA48DD070BA79921A3457ABFF2D630AD7
+                        , ehR =
+                            0x6D6DEFAC9AB64DABAFE36C6BF510352A4CC27001263638E5B16D9BB51D451559F918EEDAF2293BE5B475CC8F0188636B
+                        , ehS =
+                            0x2D46F3BECBCC523D5F1A1256BF0C9B024D879BA9E838144C8BA6BAEB4B53B47D51AB373F9845C0514EEFB14024787265
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x015EE46A5BF88773ED9123A5AB0807962D193719503C527B031B4C2D225092ADA71F4A459BC0DA98ADB95837DB8312EA
+                        , ehR =
+                            0x8203B63D3C853E8D77227FB377BCF7B7B772E97892A80F36AB775D509D7A5FEB0542A7F0812998DA8F1DD3CA3CF023DB
+                        , ehS =
+                            0xDDD0760448D42D8A43AF45AF836FCE4DE8BE06B485E9B61B827C2F13173923E06A739F040649A667BF3B828246BAA5A5
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x3780C4F67CB15518B6ACAE34C9F83568D2E12E47DEAB6C50A4E4EE5319D1E8CE0E2CC8A136036DC4B9C00E6888F66B6C
+                        , ehR =
+                            0xA0D5D090C9980FAF3C2CE57B7AE951D31977DD11C775D314AF55F76C676447D06FB6495CD21B4B6E340FC236584FB277
+                        , ehS =
+                            0x976984E59B4C77B0E8E4460DCA3D9F20E07B9BB1F63BEEFAF576F6B2E8B224634A2092CD3792E0159AD9CEE37659C736
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_p521r1
+        , ecPrivate =
+            0x0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538
+        , ecPublic =
+            Point
+                0x1894550D0785932E00EAA23B694F213F8C3121F86DC97A04E5A7167DB4E5BCD371123D46E45DB6B5D5370A7F20FB633155D38FFA16D2BD761DCAC474B9A2F5023A4
+                0x0493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A28A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDFCF5
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x089C071B419E1C2820962321787258469511958E80582E95D8378E0C2CCDB3CB42BEDE42F50E3FA3C71F5A76724281D31D9C89F0F91FC1BE4918DB1C03A5838D0F9
+                        , ehR =
+                            0x0343B6EC45728975EA5CBA6659BBB6062A5FF89EEA58BE3C80B619F322C87910FE092F7D45BB0F8EEE01ED3F20BABEC079D202AE677B243AB40B5431D497C55D75D
+                        , ehS =
+                            0x0E7B0E675A9B24413D448B8CC119D2BF7B2D2DF032741C096634D6D65D0DBE3D5694625FB9E8104D3B842C1B0E2D0B98BEA19341E8676AEF66AE4EBA3D5475D5D16
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x121415EC2CD7726330A61F7F3FA5DE14BE9436019C4DB8CB4041F3B54CF31BE0493EE3F427FB906393D895A19C9523F3A1D54BB8702BD4AA9C99DAB2597B92113F3
+                        , ehR =
+                            0x1776331CFCDF927D666E032E00CF776187BC9FDD8E69D0DABB4109FFE1B5E2A30715F4CC923A4A5E94D2503E9ACFED92857B7F31D7152E0F8C00C15FF3D87E2ED2E
+                        , ehS =
+                            0x050CB5265417FE2320BBB5A122B8E1A32BD699089851128E360E620A30C7E17BA41A666AF126CE100E5799B153B60528D5300D08489CA9178FB610A2006C254B41F
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x0EDF38AFCAAECAB4383358B34D67C9F2216C8382AAEA44A3DAD5FDC9C32575761793FEF24EB0FC276DFC4F6E3EC476752F043CF01415387470BCBD8678ED2C7E1A0
+                        , ehR =
+                            0x1511BB4D675114FE266FC4372B87682BAECC01D3CC62CF2303C92B3526012659D16876E25C7C1E57648F23B73564D67F61C6F14D527D54972810421E7D87589E1A7
+                        , ehS =
+                            0x04A171143A83163D6DF460AAF61522695F207A58B95C0644D87E52AA1A347916E4F7A72930B1BC06DBE22CE3F58264AFD23704CBB63B29B931F7DE6C9D949A7ECFC
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x1546A108BC23A15D6F21872F7DED661FA8431DDBD922D0DCDB77CC878C8553FFAD064C95A920A750AC9137E527390D2D92F153E66196966EA554D9ADFCB109C4211
+                        , ehR =
+                            0x1EA842A0E17D2DE4F92C15315C63DDF72685C18195C2BB95E572B9C5136CA4B4B576AD712A52BE9730627D16054BA40CC0B8D3FF035B12AE75168397F5D50C67451
+                        , ehS =
+                            0x1F21A3CEE066E1961025FB048BD5FE2B7924D0CD797BABE0A83B66F1E35EEAF5FDE143FA85DC394A7DEE766523393784484BDF3E00114A1C857CDE1AA203DB65D61
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x1DAE2EA071F8110DC26882D4D5EAE0621A3256FC8847FB9022E2B7D28E6F10198B1574FDD03A9053C08A1854A168AA5A57470EC97DD5CE090124EF52A2F7ECBFFD3
+                        , ehR =
+                            0x0C328FAFCBD79DD77850370C46325D987CB525569FB63C5D3BC53950E6D4C5F174E25A1EE9017B5D450606ADD152B534931D7D4E8455CC91F9B15BF05EC36E377FA
+                        , ehS =
+                            0x0617CCE7CF5064806C467F678D3B4080D6F1CC50AF26CA209417308281B68AF282623EAA63E5B5C0723D8B8C37FF0777B1A20F8CCB1DCCC43997F1EE0E44DA4A67A
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x0BB9F2BF4FE1038CCF4DABD7139A56F6FD8BB1386561BD3C6A4FC818B20DF5DDBA80795A947107A1AB9D12DAA615B1ADE4F7A9DC05E8E6311150F47F5C57CE8B222
+                        , ehR =
+                            0x13BAD9F29ABE20DE37EBEB823C252CA0F63361284015A3BF430A46AAA80B87B0693F0694BD88AFE4E661FC33B094CD3B7963BED5A727ED8BD6A3A202ABE009D0367
+                        , ehS =
+                            0x1E9BB81FF7944CA409AD138DBBEE228E1AFCC0C890FC78EC8604639CB0DBDC90F717A99EAD9D272855D00162EE9527567DD6A92CBD629805C0445282BBC916797FF
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x040D09FCF3C8A5F62CF4FB223CBBB2B9937F6B0577C27020A99602C25A01136987E452988781484EDBBCF1C47E554E7FC901BC3085E5206D9F619CFF07E73D6F706
+                        , ehR =
+                            0x1C7ED902E123E6815546065A2C4AF977B22AA8EADDB68B2C1110E7EA44D42086BFE4A34B67DDC0E17E96536E358219B23A706C6A6E16BA77B65E1C595D43CAE17FB
+                        , ehS =
+                            0x177336676304FCB343CE028B38E7B4FBA76C1C1B277DA18CAD2A8478B2A9A9F5BEC0F3BA04F35DB3E4263569EC6AADE8C92746E4C82F8299AE1B8F1739F8FD519A4
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x01DE74955EFAABC4C4F17F8E84D881D1310B5392D7700275F82F145C61E843841AF09035BF7A6210F5A431A6A9E81C9323354A9E69135D44EBD2FCAA7731B909258
+                        , ehR =
+                            0x00E871C4A14F993C6C7369501900C4BC1E9C7B0B4BA44E04868B30B41D8071042EB28C4C250411D0CE08CD197E4188EA4876F279F90B3D8D74A3C76E6F1E4656AA8
+                        , ehS =
+                            0x0CD52DBAA33B063C3A6CD8058A1FB0A46A4754B034FCC644766CA14DA8CA5CA9FDE00E88C1AD60CCBA759025299079D7A427EC3CC5B619BFBC828E7769BCD694E86
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x1F1FC4A349A7DA9A9E116BFDD055DC08E78252FF8E23AC276AC88B1770AE0B5DCEB1ED14A4916B769A523CE1E90BA22846AF11DF8B300C38818F713DADD85DE0C88
+                        , ehR =
+                            0x14BEE21A18B6D8B3C93FAB08D43E739707953244FDBE924FA926D76669E7AC8C89DF62ED8975C2D8397A65A49DCC09F6B0AC62272741924D479354D74FF6075578C
+                        , ehS =
+                            0x133330865C067A0EAF72362A65E2D7BC4E461E8C8995C3B6226A21BD1AA78F0ED94FE536A0DCA35534F0CD1510C41525D163FE9D74D134881E35141ED5E8E95B979
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x16200813020EC986863BEDFC1B121F605C1215645018AEA1A7B215A564DE9EB1B38A67AA1128B80CE391C4FB71187654AAA3431027BFC7F395766CA988C964DC56D
+                        , ehR =
+                            0x13E99020ABF5CEE7525D16B69B229652AB6BDF2AFFCAEF38773B4B7D08725F10CDB93482FDCC54EDCEE91ECA4166B2A7C6265EF0CE2BD7051B7CEF945BABD47EE6D
+                        , ehS =
+                            0x1FBD0013C674AA79CB39849527916CE301C66EA7CE8B80682786AD60F98F7E78A19CA69EFF5C57400E3B3A0AD66CE0978214D13BAF4E9AC60752F7B155E2DE4DCE3
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t163k1
+        , ecPrivate = 0x09A4D6792295A7F730FC3F2B49CBC0F62E862272F
+        , ecPublic =
+            Point
+                0x79AEE090DB05EC252D5CB4452F356BE198A4FF96F
+                0x782E29634DDC9A31EF40386E896BAA18B53AFA5A3
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x09744429FA741D12DE2BE8316E35E84DB9E5DF1CD
+                        , ehR = 0x30C45B80BA0E1406C4EFBBB7000D6DE4FA465D505
+                        , ehS = 0x38D87DF89493522FC4CD7DE1553BD9DBBA2123011
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x323E7B28BFD64E6082F5B12110AA87BC0D6A6E159
+                        , ehR = 0x38A2749F7EA13BD5DA0C76C842F512D5A65FFAF32
+                        , ehS = 0x064F841F70112B793FD773F5606BFA5AC2A04C1E8
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x23AF4074C90A02B3FE61D286D5C87F425E6BDD81B
+                        , ehR = 0x113A63990598A3828C407C0F4D2438D990DF99A7F
+                        , ehS = 0x1313A2E03F5412DDB296A22E2C455335545672D9F
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x2132ABE0ED518487D3E4FA7FD24F8BED1F29CCFCE
+                        , ehR = 0x34D4DE955871BB84FEA4E7D068BA5E9A11BD8B6C4
+                        , ehS = 0x2BAAF4D4FD57F175C405A2F39F9755D9045C820BD
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x00BBCC2F39939388FDFE841892537EC7B1FF33AA3
+                        , ehR = 0x38E487F218D696A7323B891F0CCF055D895B77ADC
+                        , ehS = 0x0972D7721093F9B3835A5EB7F0442FA8DCAA873C4
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x14CAB9192F39C8A0EA8E81B4B87574228C99CD681
+                        , ehR = 0x1375BEF93F21582F601497036A7DC8014A99C2B79
+                        , ehS = 0x254B7F1472FFFEE9002D081BB8CE819CCE6E687F9
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x091DD986F38EB936BE053DD6ACE3419D2642ADE8D
+                        , ehR = 0x110F17EF209957214E35E8C2E83CBE73B3BFDEE2C
+                        , ehS = 0x057D5022392D359851B95DEC2444012502A5349CB
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x193649CE51F0CFF0784CFC47628F4FA854A93F7A2
+                        , ehR = 0x0354D5CD24F9C41F85D02E856FA2B0001C83AF53E
+                        , ehS = 0x020B200677731CD4FE48612A92F72A19853A82B65
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x37C73C6F8B404EC83DA17A6EBCA724B3FF1F7EEBA
+                        , ehR = 0x11B6A84206515495AD8DBB2E5785D6D018D75817E
+                        , ehS = 0x1A7D4C1E17D4030A5D748ADEA785C77A54581F6D0
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x331AD98D3186F73967B1E0B120C80B1E22EFC2988
+                        , ehR = 0x148934745B351F6367FF5BB56B1848A2F508902A9
+                        , ehS = 0x36214B19444FAB504DBA61D4D6FF2D2F9640F4837
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t233k1
+        , ecPrivate = 0x103B2142BDC2A3C3B55080D09DF1808F79336DA2399F5CA7171D1BE9B0
+        , ecPublic =
+            Point
+                0x0682886F36C68473C1A221720C2B12B9BE13458BA907E1C4736595779F2
+                0x1B20639B41BE0927090999B7817A3B3928D20503A39546044EC13A10309
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x273179E3E12C69591AD3DD9C7CCE3985820E3913AB6696EB14486DDBCF
+                        , ehR = 0x5474541C988A9A1F73899F55EF28963DFFBBF0C2B1A1EE787C6A76C6A4
+                        , ehS = 0x46301F9EC6624257BFC70D72186F17898EDBD0A3522560A88DD1B7D45A
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x71626A309D9CD80AD0B975D757FE6BF4B84E49F8F34C780070D7746F19
+                        , ehR = 0x667F2FCE3E1C497EBD8E4B7C6372A8234003FE4ED6D4515814E7E11430
+                        , ehS = 0x6A1C41340DAA730320DB9475F10E29A127D7AE3432F155E1F7954E1B57
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x73552F9CAC5774F74F485FA253871F2109A0C86040552EAA67DBA92DC9
+                        , ehR = 0x38AD9C1D2CB29906E7D63C24601AC55736B438FB14F4093D6C32F63A10
+                        , ehS = 0x647AAD2599C21B6EE89BE7FF957D98F684B7921DE1FD3CC82C079624F4
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x17D726A67539C609BD99E29AA3737EF247724B71455C3B6310034038C8
+                        , ehR = 0x0C6510F57559C36FBCFF8C7BA4B81853DC618AD0BAAB03CFFDF3FD09FD
+                        , ehS = 0x0AD331EE1C9B91A88BA77997235769C60AD07EE69E11F7137E17C5CF67
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x0E535C328774CDE546BE3AF5D7FCD263872F107E807435105BA2FDC166
+                        , ehR = 0x47C4AC1B344028CC740BA7BB9F8AA59D6390E3158153D4F2ADE4B74950
+                        , ehS = 0x26CE0CDE18A1B884B3EE1A879C13B42F11BB7C85F7A3745C8BECEC8E6E
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x1D8BBF5CB6EFFA270A1CDC22C81E269F0CC16E27151E0A460BA9B51AFF
+                        , ehR = 0x4780B2DE4BAA5613872179AD90664249842E8B96FCD5653B55DD63EED4
+                        , ehS = 0x6AF46BA322E21D4A88DAEC1650EF38774231276266D6A45ED6A64ECB44
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x67634D0ABA2C9BF7AE54846F26DCD166E7100654BCE6FDC96667631AA2
+                        , ehR = 0x61D9CC8C842DF19B3D9F4BDA0D0E14A957357ADABC239444610FB39AEA
+                        , ehS = 0x66432278891CB594BA8D08A0C556053D15917E53449E03C2EF88474CF6
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x2CE5AEDC155ACC0DDC5E679EBACFD21308362E5EFC05C5E99B2557A8D7
+                        , ehR = 0x05E4E6B4DB0E13034E7F1F2E5DBAB766D37C15AE4056C7EE607C8AC7F4
+                        , ehS = 0x5FC46AA489BF828B34FBAD25EC432190F161BEA8F60D3FCADB0EE3B725
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x1B4BD3903E74FD0B31E23F956C70062014DFEFEE21832032EA5352A055
+                        , ehR = 0x50F1EFEDFFEC1088024620280EE0D7641542E4D4B5D61DB32358FC571B
+                        , ehS = 0x4614EAE449927A9EB2FCC42EA3E955B43D194087719511A007EC9217A5
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x1775ED919CA491B5B014C5D5E86AF53578B5A7976378F192AF665CB705
+                        , ehR = 0x6FE6D0D3A953BB66BB01BC6B9EDFAD9F35E88277E5768D1B214395320F
+                        , ehS = 0x7C01A236E4BFF0A771050AD01EC1D24025D3130BBD9E4E81978EB3EC09
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t283k1
+        , ecPrivate =
+            0x06A0777356E87B89BA1ED3A3D845357BE332173C8F7A65BDC7DB4FAB3C4CC79ACC8194E
+        , ecPublic =
+            Point
+                0x25330D0A651D5A20DC6389BC02345117725640AEC3C126612CE444EDD19649BDECC03D6
+                0x505BD60A4B67182474EC4D1C668A73140F70504A68F39EFCD972487E9530E0508A76193
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x0A96F788DECAF6C9DBE24DC75ABA6EAAE85E7AB003C8D4F83CB1540625B2993BF445692
+                        , ehR = 0x1B66D1E33FBDB6E107A69B610995C93C744CEBAEAF623CB42737C27D60188BD1D045A68
+                        , ehS = 0x02E45B62C9C258643532FD536594B46C63B063946494F95DAFF8759FD552502324295C5
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x1B4C4E3B2F6B08B5991BD2BDDE277A7016DA527AD0AAE5BC61B64C5A0EE63E8B502EF61
+                        , ehR = 0x018CF2F371BE86BB62E02B27CDE56DDAC83CCFBB3141FC59AEE022B66AC1A60DBBD8B76
+                        , ehS = 0x1854E02A381295EA7F184CEE71AB7222D6974522D3B99B309B1A8025EB84118A28BF20E
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x1CEB9E8E0DFF53CE687DEB81339ACA3C98E7A657D5A9499EF779F887A934408ECBE5A38
+                        , ehR = 0x19E90AA3DE5FB20AED22879F92C6FED278D9C9B9293CC5E94922CD952C9DBF20DF1753A
+                        , ehS = 0x135AA7443B6A25D11BB64AC482E04D47902D017752882BD72527114F46CF8BB56C5A8C3
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x1460A5C41745A5763A9D548AE62F2C3630BBED71B6AA549D7F829C22442A728C5D965DA
+                        , ehR = 0x0F8C1CA9C221AD9907A136F787D33BA56B0495A40E86E671C940FD767EDD75EB6001A49
+                        , ehS = 0x1071A56915DEE89E22E511975AA09D00CDC4AA7F5054CBE83F5977EE6F8E1CC31EC43FD
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x00F3B59FCB5C1A01A1A2A0019E98C244DFF61502D6E6B9C4E957EDDCEB258EF4DBEF04A
+                        , ehR = 0x1D0008CF4BA4A701BEF70771934C2A4A87386155A2354140E2ED52E18553C35B47D9E50
+                        , ehS = 0x0D15F4FA1B7A4D41D9843578E22EF98773179103DC4FF0DD1F74A6B5642841B91056F78
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x168B5F8C0881D4026C08AC5894A2239D219FA9F4DA0600ADAA56D5A1781AF81F08A726E
+                        , ehR = 0x140932FA7307666A8CCB1E1A09656CC40F5932965841ABD5E8E43559D93CF2311B02767
+                        , ehS = 0x16A2FD46DA497E5E739DED67F426308C45C2E16528BF2A17EB5D65964FD88B770FBB9C6
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x045E13EA645CE01D9B25EA38C8A8A170E04C83BB7F231EE3152209FE10EC8B2E565536C
+                        , ehR = 0x0E72AF7E39CD72EF21E61964D87C838F977485FA6A7E999000AFA97A381B2445FCEE541
+                        , ehS = 0x1644FF7D848DA1A040F77515082C27C763B1B4BF332BCF5D08251C6B57D806319778208
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x0B585A7A68F51089691D6EDE2B43FC4451F66C10E65F134B963D4CBD4EB844B0E1469A6
+                        , ehR = 0x158FAEB2470B306C57764AFC8528174589008449E11DB8B36994B607A65956A59715531
+                        , ehS = 0x0521BC667CA1CA42B5649E78A3D76823C678B7BB3CD58D2E93CD791D53043A6F83F1FD1
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x1E88738E14482A09EE16A73D490A7FE8739DF500039538D5C4B6C8D6D7F208D6CA56760
+                        , ehR = 0x1CC4DC5479E0F34C4339631A45AA690580060BF0EB518184C983E0E618C3B93AAB14BBE
+                        , ehS = 0x0284D72FF8AFA83DE364502CBA0494BB06D40AE08F9D9746E747EA87240E589BA0683B7
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x00E5F24A223BD459653F682763C3BB322D4EE75DD89C63D4DC61518D543E76585076BBA
+                        , ehR = 0x1E7912517C6899732E09756B1660F6B96635D638283DF9A8A11D30E008895D7F5C9C7F3
+                        , ehS = 0x0887E75CBD0B7DD9DE30ED79BDB3D78E4F1121C5EAFF5946918F594F88D363644789DA7
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t409k1
+        , ecPrivate =
+            0x29C16768F01D1B8A89FDA85E2EFD73A09558B92A178A2931F359E4D70AD853E569CDAF16DAA569758FB4E73089E4525D8BBFCF
+        , ecPublic =
+            Point
+                0x0CF923F523FE34A6E863D8BA45FB1FE6D784C8F219C414EEF4DB8362DBBD3CA71AEB28F568668D5D7A0093E2B84F6FAD759DB42
+                0x13B1C374D5132978A1B1123EBBE9A5C54D1A9D56B09AFDB4ADE93CCD7C4D332E2916F7D4B9D18578EE3C2E2DE4D2ECE0DE63549
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x7866E5247F9A3556F983C86E81EDA696AC8489DB40A2862F278603982D304F08B2B6E1E7848534BEAF1330D37A1CF84C7994C1
+                        , ehR =
+                            0x7192EE99EC7AFE23E02CB1F9850D1ECE620475EDA6B65D04984029408EC1E5A6476BC940D81F218FC31D979814CAC6E78340FA
+                        , ehS =
+                            0x1DE75DE97CBE740FC79A6B5B22BC2B7832C687E6960F0B8173D5D8BE2A75AC6CA43438BAF69C669CE6D64E0FB93BC5854E0F81
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x512340DB682C7B8EBE407BF1AA54194DFE85D49025FE0F632C9B8A06A996F2FCD0D73C752FB09D23DB8FBE50605DC25DF0745C
+                        , ehR =
+                            0x41C8EDF39D5E4E76A04D24E6BFD4B2EC35F99CD2483478FD8B0A03E99379576EDACC4167590B7D9C387857A5130B1220CB771F
+                        , ehS =
+                            0x659652EEAC9747BCAD58034B25362B6AA61836E1BA50E2F37630813050D43457E62EAB0F13AE197E6CFE0244F983107555E269
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x782385F18BAF5A36A588637A76DFAB05739A14163BF723A4417B74BD1469D37AC9E8CCE6AEC8FF63F37B815AAF14A876EED962
+                        , ehR =
+                            0x49EC220D6D24980693E6D33B191532EAB4C5D924E97E305E2C1CCFE6F1EAEF96C17F6EC27D1E06191023615368628A7E0BD6A9
+                        , ehS =
+                            0x1A4AB1DD9BAAA21F77C503E1B39E770FFD44718349D54BA4CF08F688CE89D7D7C5F7213F225944BE5F7C9BA42B8BEE382F8AF9
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x4DA637CB2E5C90E486744E45A73935DD698D4597E736DA332A06EDA8B26D5ABC6153EC2ECE14981CF3E5E023F36FFA55EEA6D7
+                        , ehR =
+                            0x562BB99EE027644EC04E493C5E81B41F261F6BD18FB2FAE3AFEAD91FAB8DD44AFA910B13B9C79C87555225219E44E72245BB7C
+                        , ehS =
+                            0x25BA5F28047DDDBDA7ED7E49DA31B62B20FD9C7E5B8988817BBF738B3F4DFDD2DCD06EE6DF2A1B744C850DAF952C12B9A56774
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x57055B293ECFDFE983CEF716166091E573275C53906A39EADC25C89C5EC8D7A7E5629FCFDFAD514E1348161C9A34EA1C42D58C
+                        , ehR =
+                            0x16C7E7FB33B5577F7CF6F77762F0F2D531C6E7A3528BD2CF582498C1A48F200789E9DF7B754029DA0D7E3CE96A2DC760932606
+                        , ehS =
+                            0x2729617EFBF80DA5D2F201AC7910D3404A992C39921C2F65F8CF4601392DFE933E6457EAFDBD13DFE160D243100378B55C290A
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x545453D8DC05D220F9A12EF322D0B855E664C72835FABE8A41211453EB8A7CFF950D80773839D0043A46852DDA5A536E02291F
+                        , ehR =
+                            0x565648A5BAD24E747A7D7531FA9DBDFCB184ECFEFDB00A319459242B68D0989E52BED4107AED35C27D8ECA10E876ACA48006C9
+                        , ehS =
+                            0x7420BA6FF72ECC5C92B7CA0309258B5879F26393DB22753B9EC5DF905500A04228AC08880C485E2AC8834E13E8FA44FA57BF18
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x3C5352929D4EBE3CCE87A2DCE380F0D2B33C901E61ABC530DAF3506544AB0930AB9BFD553E51FCDA44F06CD2F49E17E07DB519
+                        , ehR =
+                            0x251DFE54EAEC8A781ADF8A623F7F36B4ABFC7EE0AE78C8406E93B5C3932A8120AB8DFC49D8E243C7C30CB5B1E021BADBDF9CA4
+                        , ehS =
+                            0x77854C2E72EAA6924CC0B5F6751379D132569843B1C7885978DBBAA6678967F643A50DBB06E6EA6102FFAB7766A57C3887BD22
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x251E32DEE10ED5EA4AD7370DF3EFF091E467D5531CA59DE3AA791763715E1169AB5E18C2A11CD473B0044FB45308E8542F2EB0
+                        , ehR =
+                            0x58075FF7E8D36844EED0FC3F78B7CFFDEEF6ADE5982D5636552A081923E24841C9E37DF2C8C4BF2F2F7A174927F3B7E6A0BEB2
+                        , ehS =
+                            0x0A737469D013A31B91E781CE201100FDE1FA488ABF2252C025C678462D715AD3078C9D049E06555CABDF37878CFB909553FF51
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x11C540EA46C5038FE28BB66E2E9E9A04C9FE9567ADF33D56745953D44C1DC8B5B92922F53A174E431C0ED8267D919329F19014
+                        , ehR =
+                            0x1C5C88642EA216682244E46E24B7CE9AAEF9B3F97E585577D158C3CBC3C598250A53F6D46DFB1E2DD9DC302E7DA4F0CAAFF291
+                        , ehS =
+                            0x1D3FD721C35872C74514359F88AD983E170E5DE5B31AFC0BE12E9F4AB2B2538C7797686BA955C1D042FD1F8CDC482775579F11
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x59527CE953BC09DF5E85155CAE7BB1D7F342265F41635545B06044F844ECB4FA6476E7D47420ADC8041E75460EC0A4EC760E95
+                        , ehR =
+                            0x1A32CD7764149DF79349DBF79451F4585BB490BD63A200700D7111B45DDA414000AE1B0A69AEACBA1364DD7719968AAD123F93
+                        , ehS =
+                            0x582AB1076CAFAE23A76244B82341AEFC4C6D8D8060A62A352C33187720C8A37F3DAC227E62758B11DF1562FD249941C1679F82
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t571k1
+        , ecPrivate =
+            0x0C16F58550D824ED7B95569D4445375D3A490BC7E0194C41A39DEB732C29396CDF1D66DE02DD1460A816606F3BEC0F32202C7BD18A32D87506466AA92032F1314ED7B19762B0D22
+        , ecPublic =
+            Point
+                0x6CFB0DF7541CDD4C41EF319EA88E849EFC8605D97779148082EC991C463ED32319596F9FDF4779C17CAF20EFD9BEB57E9F4ED55BFC52A2FA15CA23BC62B7BF019DB59793DD77318
+                0x1CFC91102F7759A561BD8D5B51AAAEEC7F40E659D67870361990D6DE29F6B4F7E18AE13BDE5EA5C1F77B23D676F44050C9DBFCCDD7B3756328DDA059779AAE8446FC5158A75C227
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x17F7E360B21BEAE4A757A19ACA77FB404D273F05719A86EAD9D7B3F4D5ED7B4630584BB153CF7DCD5A87CCA101BD7EA9ECA0CE5EE27CA985833560000BB52B6BBE068740A45B267
+                        , ehR =
+                            0x0767913F96C82E38B7146A505938B79EC07E9AA3214377651BE968B52C039D3E4837B4A2DE26C481C4E1DE96F4D9DE63845D9B32E26D0D332725678E3CE57F668A5E3108FB6CEA5
+                        , ehS =
+                            0x109F89F55FA39FF465E40EBCF869A9B1DB425AEA53AB4ECBCE3C310572F79315F5D4891461372A0C36E63871BEDDBB3BA2042C6410B67311F1A185589FF4C987DBA02F9D992B9DF
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x0B599D068A1A00498EE0B9AD6F388521F594BD3F234E47F7A1DB6490D7B57D60B0101B36F39CC22885F78641C69411279706F0989E6991E5D5B53619E43EFB397E25E0814EF02BC
+                        , ehR =
+                            0x010774B9F14DE6C9525131AD61531FA30987170D43782E9FB84FF0D70F093946DF75ECB69D400FE39B12D58C67C19DCE96335CEC1D9AADE004FE5B498AB8A940D46C8444348686A
+                        , ehS =
+                            0x06DFE9AA5FEA6CF2CEDC06EE1F9FD9853D411F0B958F1C9C519C90A85F6D24C1C3435B3CDF4E207B4A67467C87B7543F6C0948DD382D24D1E48B3763EC27D4D32A0151C240CC5E0
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x0F79D53E63D89FB87F4D9E6DC5949F5D9388BCFE9EBCB4C2F7CE497814CF40E845705F8F18DBF0F860DE0B1CC4A433EF74A5741F3202E958C082E0B76E16ECD5866AA0F5F3DF300
+                        , ehR =
+                            0x1604BE98D1A27CEC2D3FA4BD07B42799E07743071E4905D7DCE7F6992B21A27F14F55D0FE5A7810DF65CF07F2F2554658817E5A88D952282EA1B8310514C0B40FFF46F159965168
+                        , ehS =
+                            0x18249377C654B8588475510F7B797081F68C2F8CCCE49F730353B2DA3364B1CD3E984813E11BB791824038EA367BA74583AB97A69AF2D77FA691AA694E348E15DA76F5A44EC1F40
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x0308253C022D25F8A9EBCD24459DD6596590BDEC7895618EEE8A2623A98D2A2B2E7594EE6B7AD3A39D70D68CB4ED01CB28E2129F8E2CC0CC8DC7780657E28BCD655F0BE9B7D35A2
+                        , ehR =
+                            0x1E6D7FB237040EA1904CCBF0984B81B866DE10D8AA93B06364C4A46F6C9573FA288C8BDDCC0C6B984E6AA75B42E7BF82FF34D51DFFBD7C87FDBFAD971656185BD12E4B8372F4BF1
+                        , ehS =
+                            0x04F94550072ADA7E8C82B7E83577DD39959577799CDABCEA60E267F36F1BEB981ABF24E722A7F031582D2CC5D80DAA7C0DEEBBE1AC5E729A6DBB34A5D645B698719FCA409FBA370
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x0C5EE7070AF55F84EBC43A0D481458CEDE1DCEBB57720A3C92F59B4941A044FECFF4F703940F3121773595E880333772ACF822F2449E17C64DA286BCD65711DD5DA44D7155BF004
+                        , ehR =
+                            0x086C9E048EADD7D3D2908501086F3AF449A01AF6BEB2026DC381B39530BCDDBE8E854251CBD5C31E6976553813C11213E4761CB8CA2E5352240AD9FB9C635D55FAB13AE42E4EE4F
+                        , ehS =
+                            0x09FEE0A68F322B380217FCF6ABFF15D78C432BD8DD82E18B6BA877C01C860E24410F5150A44F979920147826219766ECB4E2E11A151B6A15BB8E2E825AC95BCCA228D8A1C9D3568
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x1D056563469E933E4BE064585D84602D430983BFBFD6885A94BA484DF9A7AB031AD6AC090A433D8EEDC0A7643EA2A9BC3B6299E8ABA933B4C1F2652BB49DAEE833155C8F1319908
+                        , ehR =
+                            0x1D055F499A3F7E3FC73D6E7D517B470879BDCB14ABC938369F23643C7B96D0242C1FF326FDAF1CCC8593612ACE982209658E73C24C9EC493B785608669DA74A5B7C9A1D8EA843BC
+                        , ehS =
+                            0x1621376C53CFE3390A0520D2C657B1FF0EBB10E4B9C2510EDC39D04FEBAF12B8502B098A8B8F842EA6E8EB9D55CFEF94B7FF6D145AC3FFCE71BD978FEA3EF8194D4AB5293A8F3EA
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x1DA875065B9D94DBE75C61848D69578BCC267935792624F9887B53C9AF9E43CABFC42E4C3F9A456BA89E717D24F1412F33CFD297A7A4D403B18B5438654C74D592D5022125E0C6B
+                        , ehR =
+                            0x18709BDE4E9B73D046CE0D48842C97063DA54DCCA28DCB087168FA37DA2BF5FDBE4720EE48D49EDE4DD5BD31AC0149DB8297BD410F9BC02A11EB79B60C8EE63AF51B65267D71881
+                        , ehS =
+                            0x12D8B9E98FBF1D264D78669E236319D8FFD8426C56AFB10C76471EE88D7F0AB1B158E685B6D93C850D47FB1D02E4B24527473DB60B8D1AEF26CEEBD3467B65A70FFDDC0DBB64D5F
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x04DDD0707E81BB56EA2D1D45D7FAFDBDD56912CAE224086802FEA1018DB306C4FB8D93338DBF6841CE6C6AB1506E9A848D2C0463E0889268843DEE4ACB552CFFCB858784ED116B2
+                        , ehR =
+                            0x1F5BF6B044048E0E310309FFDAC825290A69634A0D3592DBEE7BE71F69E45412F766AC92E174CC99AABAA5C9C89FCB187DFDBCC7A26765DB6D9F1EEC8A6127BBDFA5801E44E3BEC
+                        , ehS =
+                            0x1B44CBFB233BFA2A98D5E8B2F0B2C27F9494BEAA77FEB59CDE3E7AE9CB2E385BE8DA7B80D7944AA71E0654E5067E9A70E88E68833054EED49F28283F02B229123995AF37A6089F0
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x0141B53DC6E569D8C0C0718A58A5714204502FDA146E7E2133E56D19E905B79413457437095DE13CF68B5CF5C54A1F2E198A55D974FC3E507AFC0ACF95ED391C93CC79E3B3FE37C
+                        , ehR =
+                            0x11F61A6EFAB6D83053D9C52665B3542FF3F63BD5913E527BDBA07FBAF34BC766C2EC83163C5273243AA834C75FDDD1BC8A2BEAD388CD06C4EBA1962D645EEB35E92D44E8F2E081D
+                        , ehS =
+                            0x16BF6341876F051DF224770CC8BA0E4D48B3332568A2B014BC80827BAA89DE18D1AEBC73E3BE8F85A8008C682AAC7D5F0E9FB5ECBEFBB637E30E4A0F226D2C2AA3E569BB54AB72B
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x14842F97F263587A164B215DD0F912C588A88DC4AB6AF4C530ADC1226F16E086D62C14435E6BFAB56F019886C88922D2321914EE41A8F746AAA2B964822E4AC6F40EE2492B66824
+                        , ehR =
+                            0x0F1E50353A39EA64CDF23081D6BB4B2A91DD73E99D3DD5A1AA1C49B4F6E34A665EAD24FD530B9103D522609A395AF3EF174C85206F67EF84835ED1632E0F6BAB718EA90DF9E2DA0
+                        , ehS =
+                            0x0B385004D7596625028E3FDE72282DE4EDC5B4CE33C1127F21CC37527C90B7307AE7D09281B840AEBCECAA711B00718103DDB32B3E9F6A9FBC6AF23E224A73B9435F619D9C62527
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t163r2
+        , ecPrivate = 0x35318FC447D48D7E6BC93B48617DDDEDF26AA658F
+        , ecPublic =
+            Point
+                0x126CF562D95A1D77D387BA75A3EA3A1407F23425A
+                0x7D7CB5273C94DA8CA93049AFDA18721C24672BD71
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x0707A94C3D352E0A9FE49FB12F264992152A20004
+                        , ehR = 0x153FEBD179A69B6122DEBF5BC61EB947B24C93526
+                        , ehS = 0x37AC9C670F8CF18045049BAE7DD35553545C19E49
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x3B24C5E2C2D935314EABF57A6484289B291ADFE3F
+                        , ehR = 0x0A379E69C44F9C16EA3215EA39EB1A9B5D58CC955
+                        , ehS = 0x04BAFF5308DA2A7FE2C1742769265AD3ED1D24E74
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x3D7086A59E6981064A9CDB684653F3A81B6EC0F0B
+                        , ehR = 0x134E00F78FC1CB9501675D91C401DE20DDF228CDC
+                        , ehS = 0x373273AEC6C36CB7BAFBB1903A5F5EA6A1D50B624
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x3B1E4443443486C7251A68EF184A936F05F8B17C7
+                        , ehR = 0x29430B935AF8E77519B0CA4F6903B0B82E6A21A66
+                        , ehS = 0x1EA1415306E9353FA5AA54BC7C2581DFBB888440D
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x2EDF5CFCAC7553C17421FDF54AD1D2EF928A879D2
+                        , ehR = 0x0B2F177A99F9DF2D51CCAF55F015F326E4B65E7A0
+                        , ehS = 0x0DF1FB4487E9B120C5E970EFE48F55E406306C3A1
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x10024F5B324CBC8954BA6ADB320CD3AB9296983B4
+                        , ehR = 0x256D4079C6C7169B8BC92529D701776A269D56308
+                        , ehS = 0x341D3FFEC9F1EB6A6ACBE88E3C86A1C8FDEB8B8E1
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x34F46DE59606D56C75406BFB459537A7CC280AA62
+                        , ehR = 0x28ECC6F1272CE80EA59DCF32F7AC2D861BA803393
+                        , ehS = 0x0AD4AE2C06E60183C1567D2B82F19421FE3053CE2
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x38145E3FFCA94E4DDACC20AD6E0997BD0E3B669D2
+                        , ehR = 0x227DF377B3FA50F90C1CB3CDCBBDBA552C1D35104
+                        , ehS = 0x1F7BEAD92583FE920D353F368C1960D0E88B46A56
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x375813210ECE9C4D7AB42DDC3C55F89189CF6DFFD
+                        , ehR = 0x11811DAFEEA441845B6118A0DFEE8A0061231337D
+                        , ehS = 0x36258301865EE48C5C6F91D63F62695002AB55B57
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x25AD8B393BC1E9363600FDA1A2AB6DF40079179A3
+                        , ehR = 0x3B6BB95CA823BE2ED8E3972FF516EB8972D765571
+                        , ehS = 0x13DC6F420628969DF900C3FCC48220B38BE24A541
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t233r1
+        , ecPrivate = 0x07ADC13DD5BF34D1DDEEB50B2CE23B5F5E6D18067306D60C5F6FF11E5D3
+        , ecPublic =
+            Point
+                0x0FB348B3246B473AA7FBB2A01B78D61B62C4221D0F9AB55FC72DB3DF478
+                0x1162FA1F6C6ACF7FD8D19FC7D74BDD9104076E833898BC4C042A6E6BEBF
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x0A4E0B67A3A081C1B35D7BECEB5FE72A918B422B907145DB5416ED751CE
+                        , ehR = 0x015CC6FD78BB06E0878E71465515EA5A21A2C18E6FC77B4B158DBEB3944
+                        , ehS = 0x0822A4A6C2EB2DF213A5E90BF40377956365EE8C4B4A5A4E2EB9270CB6A
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x0F2B1C1E80BEB58283AAA79857F7B83BDF724120D0913606FD07F7FFB2C
+                        , ehR = 0x05D9920B53471148E10502AB49AB7A3F11084820A074FD89883CF51BC1A
+                        , ehS = 0x04D3938900C0A9AAA7080D1DFEB56CFB0FADABE4214536C7ED5117ED13A
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x034A53897B0BBDB484302E19BF3F9B34A2ABFED639D109A388DC52006B5
+                        , ehR = 0x0A797F3B8AEFCE7456202DF1E46CCC291EA5A49DA3D4BDDA9A4B62D5E0D
+                        , ehS = 0x01F6F81DA55C22DA4152134C661588F4BD6F82FDBAF0C5877096B070DC2
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x04D4670B28990BC92EEB49840B482A1FA03FE028D09F3D21F89C67ECA85
+                        , ehR = 0x015E85A8D46225DD7E314A1C4289731FC14DECE949349FE535D11043B85
+                        , ehS = 0x03F189D37F50493EFD5111A129443A662AB3C6B289129AD8C0CAC85119C
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x0DE108AAADA760A14F42C057EF81C0A31AF6B82E8FBCA8DC86E443AB549
+                        , ehR = 0x03B62A4BF783919098B1E42F496E65F7621F01D1D466C46940F0F132A95
+                        , ehS = 0x0F4BE031C6E5239E7DAA014CBBF1ED19425E49DAEB426EC9DF4C28A2E30
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x0250C5C90A4E2A3F8849FEBA87F0D0AE630AB18CBABB84F4FFFB36CEAC0
+                        , ehR = 0x02F1FEDC57BE203E4C8C6B8C1CEB35E13C1FCD956AB41E3BD4C8A6EFB1F
+                        , ehS = 0x05738EC8A8EDEA8E435EE7266AD3EDE1EEFC2CEBE2BE1D614008D5D2951
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x07BDB6A7FD080D9EC2FC84BFF9E3E15750789DC04290C84FED00E109BBD
+                        , ehR = 0x0CCE175124D3586BA7486F7146894C65C2A4A5A1904658E5C7F9DF5FA5D
+                        , ehS = 0x08804B456D847ACE5CA86D97BF79FD6335E5B17F6C0D964B5D0036C867E
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x00376886E89013F7FF4B5214D56A30D49C99F53F211A3AFE01AA2BDE12D
+                        , ehR = 0x035C3D6DFEEA1CFB29B93BE3FDB91A7B130951770C2690C16833A159677
+                        , ehS = 0x0600F7301D12AB376B56D4459774159ADB51F97E282FF384406AFD53A02
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x03726870DE75613C5E529E453F4D92631C03D08A7F63813E497D4CB3877
+                        , ehR = 0x061602FC8068BFD5FB86027B97455D200EC603057446CCE4D76DB8EF42C
+                        , ehS = 0x03396DD0D59C067BB999B422D9883736CF9311DFD6951F91033BD03CA8D
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x09CE5810F1AC68810B0DFFBB6BEEF2E0053BB937969AE7886F9D064A8C4
+                        , ehR = 0x07E12CB60FDD614958E8E34B3C12DDFF35D85A9C5800E31EA2CC2EF63B1
+                        , ehS = 0x0E8970FD99D836F3CC1C807A2C58760DE6EDAA23705A82B9CB1CE93FECC
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t283r1
+        , ecPrivate =
+            0x14510D4BC44F2D26F4553942C98073C1BD35545CEABB5CC138853C5158D2729EA408836
+        , ecPublic =
+            Point
+                0x17E3409A13C399F0CA8A192F028D46E3446BCFFCDF51FF8A905ED2DED786E74F9C3E8A9
+                0x47EFCBCC31C01D86D1992F7BFAC0277DBD02A6D289274099A2C0F039C8F59F318371B0E
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x277F389559667E8AE4B65DC056F8CE2872E1917E7CC59D17D485B0B98343206FBCCD441
+                        , ehR = 0x201E18D48C6DB3D5D097C4DCE1E25587E1501FC3CF47BDB5B4289D79E273D6A9ACB8285
+                        , ehS = 0x151AE05712B024CE617358260774C8CA8B0E7A7E72EF8229BF2ACE7609560CB30322C4F
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x14CC8FCFEECD6B999B4DC6084EBB06FDED0B44D5C507802CC7A5E9ECF36E69DA6AE23C6
+                        , ehR = 0x143E878DDFD4DF40D97B8CD638B3C4706501C2201CF7108F2FB91478C11D69473246925
+                        , ehS = 0x0CBF1B9717FEEA3AABB09D9654110144267098E0E1E8D0289A6211BE0EEDFDD86A3DB79
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x38C9D662188982943E080B794A4CFB0732DBA37C6F40D5B8CFADED6FF31C5452BA3F877
+                        , ehR = 0x29FD82497FB3E5CEF65579272138DE59E2B666B8689466572B3B69A172CEE83BE145659
+                        , ehS = 0x05A89D9166B40795AF0FE5958201B9C0523E500013CA12B4840EA2BC53F25F9B3CE87C0
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x21B7265DEBF90E6F988CFFDB62B121A02105226C652807CC324ED6FB119A287A72680AB
+                        , ehR = 0x2F00689C1BFCD2A8C7A41E0DE55AE182E6463A152828EF89FE3525139B6603294E69353
+                        , ehS = 0x1744514FE0A37447250C8A329EAAADA81572226CABA16F39270EE5DD03F27B1F665EB5D
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x20583259DC179D9DA8E5387E89BFF2A3090788CF1496BCABFE7D45BB120B0C811EB8980
+                        , ehR = 0x0DA43A9ADFAA6AD767998A054C6A8F1CF77A562924628D73C62761847AD8286E0D91B47
+                        , ehS = 0x1D118733AE2C88357827CAFC6F68ABC25C80C640532925E95CFE66D40F8792F3AC44C42
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK = 0x0185C57A743D5BA06193CE2AA47B07EF3D6067E5AE1A6469BCD3FC510128BA564409D82
+                        , ehR = 0x05A408133919F2CDCDBE5E4C14FBC706C1F71BADAFEF41F5DE4EC27272FC1CA9366FBB2
+                        , ehS = 0x012966272872C097FEA7BCE64FAB1A81982A773E26F6E4EF7C99969846E67CA9CBE1692
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK = 0x2E5C1F00677A0E015EC3F799FA9E9A004309DBD784640EAAF5E1CE64D3045B9FE9C1FA1
+                        , ehR = 0x08F3824E40C16FF1DDA8DC992776D26F4A5981AB5092956C4FDBB4F1AE0A711EEAA10E5
+                        , ehS = 0x0A64B91EFADB213E11483FB61C73E3EF63D3B44EEFC56EA401B99DCC60CC28E99F0F1FA
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK = 0x018A7D44F2B4341FEFE68F6BD8894960F97E08124AAB92C1FFBBE90450FCC9356C9AAA5
+                        , ehR = 0x3597B406F5329D11A79E887847E5EC60861CCBB19EC61F252DB7BD549C699951C182796
+                        , ehS = 0x0A6A100B997BC622D91701D9F5C6F6D3815517E577622DA69D3A0E8917C1CBE63ACD345
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK = 0x3C75397BA4CF1B931877076AF29F2E2F4231B117AB4B8E039F7F9704DE1BD3522F150B6
+                        , ehR = 0x1BB490926E5A1FDC7C5AA86D0835F9B994EDA315CA408002AF54A298728D422EBF59E4C
+                        , ehS = 0x36C682CFC9E2C89A782BFD3A191609D1F0C1910D5FD6981442070393159D65FBCC0A8BA
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK = 0x14E66B18441FA54C21E3492D0611D2B48E19DE3108D915FD5CA08E786327A2675F11074
+                        , ehR = 0x19944AA68F9778C2E3D6E240947613E6DA60EFCE9B9B2C063FF5466D72745B5A0B25BA2
+                        , ehS = 0x03F1567B3C5B02DF15C874F0EE22850824693D5ADC4663BAA19E384E550B1DD41F31EE6
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t409r1
+        , ecPrivate =
+            0x0494994CC325B08E7B4CE038BD9436F90B5E59A2C13C3140CD3AE07C04A01FC489F572CE0569A6DB7B8060393DE76330C624177
+        , ecPublic =
+            Point
+                0x1A7055961CF1DA4B9A015B18B1524EF01FDD9B93FAEFC26FB1F2F828A7227B7031925DA0AC1A8A075C3B33554B222EA859C17E7
+                0x18105C042F290736088F30AEC7AE7732A45DE47BCE0940113AB8132516D1E059B0F581FD581A9A3CB3A0AC42A1962738ADB86E6
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x042D8A2B34402757EB2CCFDDC3E6E96A7ADD3FDA547FC10A0CB77CFC720B4F9E16EEAAA2A8CC4E4A4B5DBF7D8AC4EA491859E60
+                        , ehR =
+                            0x0D8783188E1A540E2022D389E1D35B32F56F8C2BB5636B8ABF7718806B27A713EBAE37F63ECD4B61445CEF5801B62594EF3E982
+                        , ehS =
+                            0x03A6B4A80E204DB0DE12E7415C13C9EC091C52935658316B4A0C591216A3879154BEB1712560E346E7EF26517707435B55C3141
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x0C933F1DC4C70838C2AD16564715ACAF545BCDD8DC203D25AF3EC63949C65CB2E68AC1F60CA7EACA2A823F4E240927AA82CEEC5
+                        , ehR =
+                            0x0EE4F39ACC2E03CE96C3D9FCBAFA5C22C89053662F8D4117752A9B10F09ADFDA59DB061E247FE5321D6B170EE758ACE1BE4D157
+                        , ehS =
+                            0x00A2B83265B456A430A8BF27DCC8A9488B3F126C10F0D6D64BF7B8A218FAAF20E51A295A3AE78F205E5A4A6AE224C3639F1BB34
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x08EC42D13A3909A20C41BEBD2DFED8CACCE56C7A7D1251DF43F3E9E289DAE00E239F6960924AC451E125B784CB687C7F23283FD
+                        , ehR =
+                            0x02D8B1B31E33E74D7EB46C30FDE5AD2CA04EC8FE08FBA0E73BA5E568953AC5EA307C072942238DFC07F4A4D7C7C6A9F86436D17
+                        , ehS =
+                            0x079F7D471E6CB73234AF7F7C381D2CE15DE35BAF8BB68393B73235B3A26EC2DF4842CE433FB492D6E074E604D4870024D42189A
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x0DA881BCE3BA851485879EF8AC585A63F1540B9198ECB8A1096D70CB25A104E2F8A96B108AE76CB49CF34491ABC70E9D2AAD450
+                        , ehR =
+                            0x07BC638B7E7CE6FEE5E9C64A0F966D722D01BB4BC3F3A35F30D4CDDA92DFC5F7F0B4BBFE8065D9AD452FD77A1914BE3A2440C18
+                        , ehS =
+                            0x06D904429850521B28A32CBF55C7C0FDF35DC4E0BDA2552C7BF68A171E970E6788ACC0B9521EACB4796E057C70DD9B95FED5BFB
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x0750926FFAD7FF5DE85DF7960B3A4F9E3D38CF5A049BFC89739C48D42B34FBEE03D2C047025134CC3145B60AFD22A68DF0A7FB2
+                        , ehR =
+                            0x05D178DECAFD2D02A3DA0D8BA1C4C1D95EE083C760DF782193A9F7B4A8BE6FC5C21FD60613BCA65C063A61226E050A680B3ABD4
+                        , ehS =
+                            0x013B7581E98F6A63FBBCB3E49BCDA60F816DB230B888506D105DC229600497C3B46588C784BE3AA9343BEF82F7C9C80AEB63C3B
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x017E167EAB1850A3B38EE66BFE2270F2F6BFDAC5E2D227D47B20E75F0719161E6C74E9F23088F0C58B1E63BC6F185AD2EF4EAE6
+                        , ehR =
+                            0x049F54E7C10D2732B4638473053782C6919218BBEFCEC8B51640FC193E832291F05FA12371E9B448417B3290193F08EE9319195
+                        , ehS =
+                            0x0499E267DEC84E02F6F108B10E82172C414F15B1B7364BE8BFD66ADC0C5DE23FEE3DF0D811134C25AFE0E05A6672F98889F28F1
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x01ADEB94C19951B460A146B8275D81638C07735B38A525D76023AAF26AA8A058590E1D5B1E78AB3C91608BDA67CFFBE6FC8A6CC
+                        , ehR =
+                            0x0B1527FFAA7DD7C7E46B628587A5BEC0539A2D04D3CF27C54841C2544E1BBDB42FDBDAAF8671A4CA86DFD619B1E3732D7BB56F2
+                        , ehS =
+                            0x0442C68C044868DF4832C807F1EDDEBF7F5052A64B826FD03451440794063F52B022DF304F47403D4069234CA9EB4C964B37C02
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x06EBA3D58D0E0DFC406D67FC72EF0C943624CF40019D1E48C3B54CCAB0594AFD5DEE30AEBAA22E693DBCFECAD1A85D774313DAD
+                        , ehR =
+                            0x0BB27755B991D6D31757BCBF68CB01225A38E1CFA20F775E861055DD108ED7EA455E4B96B2F6F7CD6C6EC2B3C70C3EDDEB9743B
+                        , ehS =
+                            0x0C5BE90980E7F444B5F7A12C9E9AC7A04CA81412822DD5AD1BE7C45D5032555EA070864245CF69266871FEB8CD1B7EDC30EF6D5
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x0A45B787DB44C06DEAB846511EEDBF7BFCFD3BD2C11D965C92FC195F67328F36A2DC83C0352885DAB96B55B02FCF49DCCB0E2DA
+                        , ehR =
+                            0x04EFEB7098772187907C87B33E0FBBA4584226C50C11E98CA7AAC6986F8D3BE044E5B52D201A410B852536527724CA5F8CE6549
+                        , ehS =
+                            0x09574102FEB3EF87E6D66B94119F5A6062950FF4F902EA1E6BD9E2037F33FF991E31F5956C23AFE48FCDC557FD6F088C7C9B2B3
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x0B90F8A0E757E81D4EA6891766729C96A6D01F9AEDC0D334932D1F81CC4E1973A4F01C33555FF08530A5098CADB6EDAE268ABB5
+                        , ehR =
+                            0x07E0249C68536AE2AEC2EC30090340DA49E6DC9E9EEC8F85E5AABFB234B6DA7D2E9524028CF821F21C6019770474CC40B01FAF6
+                        , ehS =
+                            0x08125B5A03FB44AE81EA46D446130C2A415ECCA265910CA69D55F2453E16CD7B2DFA4E28C50FA8137F9C0C6CEE4CD37ABCCF6D8
+                        }
+                    ]
+                }
+            ]
+        }
+    , EntryCurve
+        { ecName = SEC_t571r1
+        , ecPrivate =
+            0x028A04857F24C1C082DF0D909C0E72F453F2E2340CCB071F0E389BCA2575DA19124198C57174929AD26E348CF63F78D28021EF5A9BF2D5CBEAF6B7CCB6C4DA824DD5C82CFB24E11
+        , ecPublic =
+            Point
+                0x4B4B3CE9377550140B62C1061763AA524814DDCEF37B00CD5CDE94F7792BB0E96758E55DA2E9FEA8FF2A8B6830AE1D57A9CA7A77FCB0836BF43EA5454CDD9FEAD5CCFE7375C6A83
+                0x4453B18F261E7A0E7570CD72F235EA750438E43946FBEBD2518B696954767AA7849C1719E18E1C51652C28CA853426F15C09AA4B579487338ABC7F33768FADD61B5A3A6443A8189
+        , ecMessages =
+            [ EntryMessage
+                { emMessage = "sample"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x2669FAFEF848AF67D437D4A151C3C5D3F9AA8BB66EDC35F090C9118F95BA0041B0993BE2EF55DAAF36B5B3A737C40DB1F6E3D93D97B8419AD6E1BB8A5D4A0E9B2E76832D4E7B862
+                        , ehR =
+                            0x147D3EB0EDA9F2152DFD014363D6A9CE816D7A1467D326A625FC4AB0C786E1B74DDF7CD4D0E99541391B266C704BB6B6E8DCCD27B460802E0867143727AA415555454321EFE5CB6
+                        , ehS =
+                            0x17319571CAF533D90D2E78A64060B9C53169AB7FC908947B3EDADC54C79CCF0A7920B4C64A4EAB6282AFE9A459677CDA37FD6DD50BEF18709590FE18B923BDF74A66B189A850819
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x2EAFAD4AC8644DEB29095BBAA88D19F31316434F1766AD4423E0B54DD2FE0C05E307758581B0DAED2902683BBC7C47B00E63E3E429BA54EA6BA3AEC33A94C9A24A6EF8E27B7677A
+                        , ehR =
+                            0x10F4B63E79B2E54E4F4F6A2DBC786D8F4A143ECA7B2AD97810F6472AC6AE20853222854553BE1D44A7974599DB7061AE8560DF57F2675BE5F9DD94ABAF3D47F1582B318E459748B
+                        , ehS =
+                            0x3BBEA07C6B269C2B7FE9AE4DDB118338D0C2F0022920A7F9DCFCB7489594C03B536A9900C4EA6A10410007222D3DAE1A96F291C4C9275D75D98EB290DC0EEF176037B2C7A7A39A3
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x15C2C6B7D1A070274484774E558B69FDFA193BDB7A23F27C2CD24298CE1B22A6CC9B7FB8CABFD6CF7C6B1CF3251E5A1CDDD16FBFED28DE79935BB2C631B8B8EA9CC4BCC937E669E
+                        , ehR =
+                            0x213EF9F3B0CFC4BF996B8AF3A7E1F6CACD2B87C8C63820000800AC787F17EC99C04BCEDF29A8413CFF83142BB88A50EF8D9A086AF4EB03E97C567500C21D865714D832E03C6D054
+                        , ehS =
+                            0x3D32322559B094E20D8935E250B6EC139AC4AAB77920812C119AF419FB62B332C8D226C6C9362AE3C1E4AABE19359B8428EA74EC8FBE83C8618C2BCCB6B43FBAA0F2CCB7D303945
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x0FEF0B68CB49453A4C6ECBF1708DBEEFC885C57FDAFB88417AAEFA5B1C35017B4B498507937ADCE2F1D9EFFA5FE8F5AEB116B804FD182A6CF1518FDB62D53F60A0FF6EB707D856B
+                        , ehR =
+                            0x375D8F49C656A0BBD21D3F54CDA287D853C4BB1849983CD891EF6CD6BB56A62B687807C16685C2C9BCA2663C33696ACCE344C45F3910B1DF806204FF731ECB289C100EF4D1805EC
+                        , ehS =
+                            0x1CDEC6F46DFEEE44BCE71D41C60550DC67CF98D6C91363625AC2553E4368D2DFB734A8E8C72E118A76ACDB0E58697940A0F3DF49E72894BD799450FC9E550CC04B9FF9B0380021C
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x3FF373833A06C791D7AD586AFA3990F6EF76999C35246C4AD0D519BFF180CA1880E11F2FB38B764854A0AE3BECDDB50F05AC4FCEE542F207C0A6229E2E19652F0E647B9C4882193
+                        , ehR =
+                            0x1C26F40D940A7EAA0EB1E62991028057D91FEDA0366B606F6C434C361F04E545A6A51A435E26416F6838FFA260C617E798E946B57215284182BE55F29A355E6024FE32A47289CF0
+                        , ehS =
+                            0x3691DE4369D921FE94EDDA67CB71FBBEC9A436787478063EB1CC778B3DCDC1C4162662752D28DEEDF6F32A269C82D1DB80C87CE4D3B662E03AC347806E3F19D18D6D4DE7358DF7E
+                        }
+                    ]
+                }
+            , EntryMessage
+                { emMessage = "test"
+                , emHashes =
+                    [ EntryHash
+                        { ehAlgorithm = HashAlg SHA1
+                        , ehK =
+                            0x019B506FD472675A7140E429AA5510DCDDC21004206EEC1B39B28A688A8FD324138F12503A4EFB64F934840DFBA2B4797CFC18B8BD0B31BBFF3CA66A4339E4EF9D771B15279D1DC
+                        , ehR =
+                            0x133F5414F2A9BC41466D339B79376038A64D045E5B0F792A98E5A7AA87E0AD016419E5F8D176007D5C9C10B5FD9E2E0AB8331B195797C0358BA05ECBF24ACE59C5F368A6C0997CC
+                        , ehS =
+                            0x3D16743AE9F00F0B1A500F738719C5582550FEB64689DA241665C4CE4F328BA0E34A7EF527ED13BFA5889FD2D1D214C11EB17D6BC338E05A56F41CAFF1AF7B8D574DB62EF0D0F21
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA224
+                        , ehK =
+                            0x333C711F8C62F205F926593220233B06228285261D34026232F6F729620C6DE12220F282F4206D223226705608688B20B8BA86D8DFE54F07A37EC48F253283AC33C3F5102C8CC3E
+                        , ehR =
+                            0x3048E76506C5C43D92B2E33F62B33E3111CEEB87F6C7DF7C7C01E3CDA28FA5E8BE04B5B23AA03C0C70FEF8F723CBCEBFF0B7A52A3F5C8B84B741B4F6157E69A5FB0524B48F31828
+                        , ehS =
+                            0x2C99078CCFE5C82102B8D006E3703E020C46C87C75163A2CD839C885550BA5CB501AC282D29A1C26D26773B60FBE05AAB62BFA0BA32127563D42F7669C97784C8897C22CFB4B8FA
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA256
+                        , ehK =
+                            0x328E02CF07C7B5B6D3749D8302F1AE5BFAA8F239398459AF4A2C859C7727A8123A7FE9BE8B228413FC8DC0E9DE16AF3F8F43005107F9989A5D97A5C4455DA895E81336710A3FB2C
+                        , ehR =
+                            0x184BC808506E11A65D628B457FDA60952803C604CC7181B59BD25AEE1411A66D12A777F3A0DC99E1190C58D0037807A95E5080FA1B2E5CCAA37B50D401CFFC3417C005AEE963469
+                        , ehS =
+                            0x27280D45F81B19334DBDB07B7E63FE8F39AC7E9AE14DE1D2A6884D2101850289D70EE400F26ACA5E7D73F534A14568478E59D00594981ABE6A1BA18554C13EB5E03921E4DC98333
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA384
+                        , ehK =
+                            0x2A77E29EAD9E811A9FDA0284C14CDFA1D9F8FA712DA59D530A06CDE54187E250AD1D4FB5788161938B8DE049616399C5A56B0737C9564C9D4D845A4C6A7CDFCBFF0F01A82BE672E
+                        , ehR =
+                            0x319EE57912E7B0FAA1FBB145B0505849A89C6DB1EC06EA20A6A7EDE072A6268AF6FD9C809C7E422A5F33C6C3326EAD7402467DF3272A1B2726C1C20975950F0F50D8324578F13EC
+                        , ehS =
+                            0x2CF3EA27EADD0612DD2F96F46E89AB894B01A10DF985C5FC099CFFE0EA083EB44BE682B08BFE405DAD5F37D0A2C59015BA41027E24B99F8F75A70B6B7385BF39BBEA02513EB880C
+                        }
+                    , EntryHash
+                        { ehAlgorithm = HashAlg SHA512
+                        , ehK =
+                            0x21CE6EE4A2C72C9F93BDB3B552F4A633B8C20C200F894F008643240184BE57BB282A1645E47FBBE131E899B4C61244EFC2486D88CDBD1DD4A65EBDD837019D02628D0DCD6ED8FB5
+                        , ehR =
+                            0x2AA1888EAB05F7B00B6A784C4F7081D2C833D50794D9FEAF6E22B8BE728A2A90BFCABDC803162020AA629718295A1489EE7ED0ECB8AAA197B9BDFC49D18DDD78FC85A48F9715544
+                        , ehS =
+                            0x0AA5371FE5CA671D6ED9665849C37F394FED85D51FEF72DA2B5F28EDFB2C6479CA63320C19596F5E1101988E2C619E302DD05112F47E8823040CE540CD3E90DCF41DBC461744EE9
+                        }
+                    ]
+                }
+            ]
+        }
+    ]
+
+testPublic :: PrivateKey -> PublicPoint -> TestTree
+testPublic (PrivateKey curve key) pub =
+    testCase "public" $
+        pub @=? generateQ curve key
+
+testNonce :: PrivateKey -> HashAlg -> ByteString -> Integer -> TestTree
+testNonce key (HashAlg alg) msg nonc =
+    testCase "nonce" $
+        nonc @=? deterministicNonce alg key (hashWith alg msg) Just
+
+testSignature
+    :: PrivateKey -> HashAlg -> ByteString -> Integer -> Signature -> TestTree
+testSignature key (HashAlg alg) msg nonc sig = testCase "signature" $
+    case signWith nonc key alg msg of
+        Nothing -> assertFailure "could not sign message"
+        Just result -> sig @=? result
+
+testVerify :: PublicKey -> HashAlg -> ByteString -> Signature -> TestTree
+testVerify pub (HashAlg alg) msg sig =
+    testCase "verify" $
+        assertBool "signature verification failed" $
+            verify alg pub sig msg
+
+testEntry :: Entry -> TestTree
+testEntry entry = testGroup (show entry) tests
+  where
+    tests =
+        [ testPublic key $ publicPoint entry
+        , testSignature
+            key
+            (hashAlgorithm entry)
+            (message entry)
+            (nonce entry)
+            (signature entry)
+        , testVerify pub (hashAlgorithm entry) (message entry) (signature entry)
+        ]
+    pub = PublicKey curve $ publicPoint entry
+    key = PrivateKey curve $ privateNumber entry
+    curve = getCurveByName $ curveName entry
+
+testEntryNonce :: Entry -> TestTree
+testEntryNonce entry = testGroup (show entry) tests
+  where
+    tests =
+        [ testPublic key $ publicPoint entry
+        , testNonce key (hashAlgorithm entry) (message entry) (nonce entry)
+        , testSignature
+            key
+            (hashAlgorithm entry)
+            (message entry)
+            (nonce entry)
+            (signature entry)
+        , testVerify pub (hashAlgorithm entry) (message entry) (signature entry)
+        ]
+    pub = PublicKey curve $ publicPoint entry
+    key = PrivateKey curve $ privateNumber entry
+    curve = getCurveByName $ curveName entry
+
+ecdsaTests :: TestTree
+ecdsaTests =
+    testGroup
+        "ECDSA"
+        [ testGroup "GEC 2" $ testEntry . normalize <$> gec2Entries
+        , testGroup "RFC 6979" $ testEntryNonce . normalize <$> flatten rfc6979Entries
+        ]
diff --git a/tests/KAT_PubKey/OAEP.hs b/tests/KAT_PubKey/OAEP.hs
--- a/tests/KAT_PubKey/OAEP.hs
+++ b/tests/KAT_PubKey/OAEP.hs
@@ -1,97 +1,142 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_PubKey.OAEP (oaepTests) where
 
+import Crypto.Hash
 import Crypto.PubKey.RSA
 import qualified Crypto.PubKey.RSA.OAEP as OAEP
-import Crypto.Hash
 
 import Imports
 
-rsaKeyInt = PrivateKey
-    { private_pub = PublicKey
-        { public_n = 0xbbf82f090682ce9c2338ac2b9da871f7368d07eed41043a440d6b6f07454f51fb8dfbaaf035c02ab61ea48ceeb6fcd4876ed520d60e1ec4619719d8a5b8b807fafb8e0a3dfc737723ee6b4b7d93a2584ee6a649d060953748834b2454598394ee0aab12d7b61a51f527a9a41f6c1687fe2537298ca2a8f5946f8e5fd091dbdcb
-        , public_e = 0x11 
-        , public_size = 128
+rsaKeyInt =
+    PrivateKey
+        { private_pub =
+            PublicKey
+                { public_n =
+                    0xbbf82f090682ce9c2338ac2b9da871f7368d07eed41043a440d6b6f07454f51fb8dfbaaf035c02ab61ea48ceeb6fcd4876ed520d60e1ec4619719d8a5b8b807fafb8e0a3dfc737723ee6b4b7d93a2584ee6a649d060953748834b2454598394ee0aab12d7b61a51f527a9a41f6c1687fe2537298ca2a8f5946f8e5fd091dbdcb
+                , public_e = 0x11
+                , public_size = 128
+                }
+        , private_d =
+            0xa5dafc5341faf289c4b988db30c1cdf83f31251e0668b42784813801579641b29410b3c7998d6bc465745e5c392669d6870da2c082a939e37fdcb82ec93edac97ff3ad5950accfbc111c76f1a9529444e56aaf68c56c092cd38dc3bef5d20a939926ed4f74a13eddfbe1a1cecc4894af9428c2b7b8883fe4463a4bc85b1cb3c1
+        , private_p =
+            0xeecfae81b1b9b3c908810b10a1b5600199eb9f44aef4fda493b81a9e3d84f632124ef0236e5d1e3b7e28fae7aa040a2d5b252176459d1f397541ba2a58fb6599
+        , private_q =
+            0xc97fb1f027f453f6341233eaaad1d9353f6c42d08866b1d05a0f2035028b9d869840b41666b42e92ea0da3b43204b5cfce3352524d0416a5a441e700af461503
+        , private_dP =
+            0x54494ca63eba0337e4e24023fcd69a5aeb07dddc0183a4d0ac9b54b051f2b13ed9490975eab77414ff59c1f7692e9a2e202b38fc910a474174adc93c1f67c981
+        , private_dQ =
+            0x471e0290ff0af0750351b7f878864ca961adbd3a8a7e991c5c0556a94c3146a7f9803f8f6f8ae342e931fd8ae47a220d1b99a495849807fe39f9245a9836da3d
+        , private_qinv =
+            0xb06c4fdabb6301198d265bdbae9423b380f271f73453885093077fcd39e2119fc98632154f5883b167a967bf402b4e9e2e0f9656e698ea3666edfb25798039f7
         }
-    , private_d = 0xa5dafc5341faf289c4b988db30c1cdf83f31251e0668b42784813801579641b29410b3c7998d6bc465745e5c392669d6870da2c082a939e37fdcb82ec93edac97ff3ad5950accfbc111c76f1a9529444e56aaf68c56c092cd38dc3bef5d20a939926ed4f74a13eddfbe1a1cecc4894af9428c2b7b8883fe4463a4bc85b1cb3c1
-    , private_p = 0xeecfae81b1b9b3c908810b10a1b5600199eb9f44aef4fda493b81a9e3d84f632124ef0236e5d1e3b7e28fae7aa040a2d5b252176459d1f397541ba2a58fb6599
-    , private_q = 0xc97fb1f027f453f6341233eaaad1d9353f6c42d08866b1d05a0f2035028b9d869840b41666b42e92ea0da3b43204b5cfce3352524d0416a5a441e700af461503
-    , private_dP = 0x54494ca63eba0337e4e24023fcd69a5aeb07dddc0183a4d0ac9b54b051f2b13ed9490975eab77414ff59c1f7692e9a2e202b38fc910a474174adc93c1f67c981
-    , private_dQ = 0x471e0290ff0af0750351b7f878864ca961adbd3a8a7e991c5c0556a94c3146a7f9803f8f6f8ae342e931fd8ae47a220d1b99a495849807fe39f9245a9836da3d
-    , private_qinv = 0xb06c4fdabb6301198d265bdbae9423b380f271f73453885093077fcd39e2119fc98632154f5883b167a967bf402b4e9e2e0f9656e698ea3666edfb25798039f7
-    }
 
-rsaKey1 = PrivateKey
-    { private_pub = PublicKey
-        { public_n = 0xa8b3b284af8eb50b387034a860f146c4919f318763cd6c5598c8ae4811a1e0abc4c7e0b082d693a5e7fced675cf4668512772c0cbc64a742c6c630f533c8cc72f62ae833c40bf25842e984bb78bdbf97c0107d55bdb662f5c4e0fab9845cb5148ef7392dd3aaff93ae1e6b667bb3d4247616d4f5ba10d4cfd226de88d39f16fb
-        , public_e = 0x010001
-        , public_size = 128
+rsaKey1 =
+    PrivateKey
+        { private_pub =
+            PublicKey
+                { public_n =
+                    0xa8b3b284af8eb50b387034a860f146c4919f318763cd6c5598c8ae4811a1e0abc4c7e0b082d693a5e7fced675cf4668512772c0cbc64a742c6c630f533c8cc72f62ae833c40bf25842e984bb78bdbf97c0107d55bdb662f5c4e0fab9845cb5148ef7392dd3aaff93ae1e6b667bb3d4247616d4f5ba10d4cfd226de88d39f16fb
+                , public_e = 0x010001
+                , public_size = 128
+                }
+        , private_d =
+            0x53339cfdb79fc8466a655c7316aca85c55fd8f6dd898fdaf119517ef4f52e8fd8e258df93fee180fa0e4ab29693cd83b152a553d4ac4d1812b8b9fa5af0e7f55fe7304df41570926f3311f15c4d65a732c483116ee3d3d2d0af3549ad9bf7cbfb78ad884f84d5beb04724dc7369b31def37d0cf539e9cfcdd3de653729ead5d1
+        , private_p =
+            0xd32737e7267ffe1341b2d5c0d150a81b586fb3132bed2f8d5262864a9cb9f30af38be448598d413a172efb802c21acf1c11c520c2f26a471dcad212eac7ca39d
+        , private_q =
+            0xcc8853d1d54da630fac004f471f281c7b8982d8224a490edbeb33d3e3d5cc93c4765703d1dd791642f1f116a0dd852be2419b2af72bfe9a030e860b0288b5d77
+        , private_dP =
+            0x0e12bf1718e9cef5599ba1c3882fe8046a90874eefce8f2ccc20e4f2741fb0a33a3848aec9c9305fbecbd2d76819967d4671acc6431e4037968db37878e695c1
+        , private_dQ =
+            0x95297b0f95a2fa67d00707d609dfd4fc05c89dafc2ef6d6ea55bec771ea333734d9251e79082ecda866efef13c459e1a631386b7e354c899f5f112ca85d71583
+        , private_qinv =
+            0x4f456c502493bdc0ed2ab756a3a6ed4d67352a697d4216e93212b127a63d5411ce6fa98d5dbefd73263e3728142743818166ed7dd63687dd2a8ca1d2f4fbd8e1
         }
-    , private_d = 0x53339cfdb79fc8466a655c7316aca85c55fd8f6dd898fdaf119517ef4f52e8fd8e258df93fee180fa0e4ab29693cd83b152a553d4ac4d1812b8b9fa5af0e7f55fe7304df41570926f3311f15c4d65a732c483116ee3d3d2d0af3549ad9bf7cbfb78ad884f84d5beb04724dc7369b31def37d0cf539e9cfcdd3de653729ead5d1
-    , private_p = 0xd32737e7267ffe1341b2d5c0d150a81b586fb3132bed2f8d5262864a9cb9f30af38be448598d413a172efb802c21acf1c11c520c2f26a471dcad212eac7ca39d
-    , private_q = 0xcc8853d1d54da630fac004f471f281c7b8982d8224a490edbeb33d3e3d5cc93c4765703d1dd791642f1f116a0dd852be2419b2af72bfe9a030e860b0288b5d77
-    , private_dP = 0x0e12bf1718e9cef5599ba1c3882fe8046a90874eefce8f2ccc20e4f2741fb0a33a3848aec9c9305fbecbd2d76819967d4671acc6431e4037968db37878e695c1
-    , private_dQ = 0x95297b0f95a2fa67d00707d609dfd4fc05c89dafc2ef6d6ea55bec771ea333734d9251e79082ecda866efef13c459e1a631386b7e354c899f5f112ca85d71583
-    , private_qinv = 0x4f456c502493bdc0ed2ab756a3a6ed4d67352a697d4216e93212b127a63d5411ce6fa98d5dbefd73263e3728142743818166ed7dd63687dd2a8ca1d2f4fbd8e1
-    }
 
-
-data VectorOAEP = VectorOAEP { seed :: ByteString
-                             , message :: ByteString
-                             , cipherText :: ByteString
-                             }
-vectorInt = VectorOAEP
-    { message = "\xd4\x36\xe9\x95\x69\xfd\x32\xa7\xc8\xa0\x5b\xbc\x90\xd3\x2c\x49"
-    , seed    = "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2\xf0\x6c\xb5\x8f"
-    , cipherText = "\x12\x53\xe0\x4d\xc0\xa5\x39\x7b\xb4\x4a\x7a\xb8\x7e\x9b\xf2\xa0\x39\xa3\x3d\x1e\x99\x6f\xc8\x2a\x94\xcc\xd3\x00\x74\xc9\x5d\xf7\x63\x72\x20\x17\x06\x9e\x52\x68\xda\x5d\x1c\x0b\x4f\x87\x2c\xf6\x53\xc1\x1d\xf8\x23\x14\xa6\x79\x68\xdf\xea\xe2\x8d\xef\x04\xbb\x6d\x84\xb1\xc3\x1d\x65\x4a\x19\x70\xe5\x78\x3b\xd6\xeb\x96\xa0\x24\xc2\xca\x2f\x4a\x90\xfe\x9f\x2e\xf5\xc9\xc1\x40\xe5\xbb\x48\xda\x95\x36\xad\x87\x00\xc8\x4f\xc9\x13\x0a\xde\xa7\x4e\x55\x8d\x51\xa7\x4d\xdf\x85\xd8\xb5\x0d\xe9\x68\x38\xd6\x06\x3e\x09\x55"
+data VectorOAEP = VectorOAEP
+    { seed :: ByteString
+    , message :: ByteString
+    , cipherText :: ByteString
     }
+vectorInt =
+    VectorOAEP
+        { message = "\xd4\x36\xe9\x95\x69\xfd\x32\xa7\xc8\xa0\x5b\xbc\x90\xd3\x2c\x49"
+        , seed =
+            "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2\xf0\x6c\xb5\x8f"
+        , cipherText =
+            "\x12\x53\xe0\x4d\xc0\xa5\x39\x7b\xb4\x4a\x7a\xb8\x7e\x9b\xf2\xa0\x39\xa3\x3d\x1e\x99\x6f\xc8\x2a\x94\xcc\xd3\x00\x74\xc9\x5d\xf7\x63\x72\x20\x17\x06\x9e\x52\x68\xda\x5d\x1c\x0b\x4f\x87\x2c\xf6\x53\xc1\x1d\xf8\x23\x14\xa6\x79\x68\xdf\xea\xe2\x8d\xef\x04\xbb\x6d\x84\xb1\xc3\x1d\x65\x4a\x19\x70\xe5\x78\x3b\xd6\xeb\x96\xa0\x24\xc2\xca\x2f\x4a\x90\xfe\x9f\x2e\xf5\xc9\xc1\x40\xe5\xbb\x48\xda\x95\x36\xad\x87\x00\xc8\x4f\xc9\x13\x0a\xde\xa7\x4e\x55\x8d\x51\xa7\x4d\xdf\x85\xd8\xb5\x0d\xe9\x68\x38\xd6\x06\x3e\x09\x55"
+        }
 
 vectorsKey1 =
     [ VectorOAEP -- 1.1
-        { message = "\x66\x28\x19\x4e\x12\x07\x3d\xb0\x3b\xa9\x4c\xda\x9e\xf9\x53\x23\x97\xd5\x0d\xba\x79\xb9\x87\x00\x4a\xfe\xfe\x34"
-        , seed = "\x18\xb7\x76\xea\x21\x06\x9d\x69\x77\x6a\x33\xe9\x6b\xad\x48\xe1\xdd\xa0\xa5\xef"
-        , cipherText = "\x35\x4f\xe6\x7b\x4a\x12\x6d\x5d\x35\xfe\x36\xc7\x77\x79\x1a\x3f\x7b\xa1\x3d\xef\x48\x4e\x2d\x39\x08\xaf\xf7\x22\xfa\xd4\x68\xfb\x21\x69\x6d\xe9\x5d\x0b\xe9\x11\xc2\xd3\x17\x4f\x8a\xfc\xc2\x01\x03\x5f\x7b\x6d\x8e\x69\x40\x2d\xe5\x45\x16\x18\xc2\x1a\x53\x5f\xa9\xd7\xbf\xc5\xb8\xdd\x9f\xc2\x43\xf8\xcf\x92\x7d\xb3\x13\x22\xd6\xe8\x81\xea\xa9\x1a\x99\x61\x70\xe6\x57\xa0\x5a\x26\x64\x26\xd9\x8c\x88\x00\x3f\x84\x77\xc1\x22\x70\x94\xa0\xd9\xfa\x1e\x8c\x40\x24\x30\x9c\xe1\xec\xcc\xb5\x21\x00\x35\xd4\x7a\xc7\x2e\x8a"
+        { message =
+            "\x66\x28\x19\x4e\x12\x07\x3d\xb0\x3b\xa9\x4c\xda\x9e\xf9\x53\x23\x97\xd5\x0d\xba\x79\xb9\x87\x00\x4a\xfe\xfe\x34"
+        , seed =
+            "\x18\xb7\x76\xea\x21\x06\x9d\x69\x77\x6a\x33\xe9\x6b\xad\x48\xe1\xdd\xa0\xa5\xef"
+        , cipherText =
+            "\x35\x4f\xe6\x7b\x4a\x12\x6d\x5d\x35\xfe\x36\xc7\x77\x79\x1a\x3f\x7b\xa1\x3d\xef\x48\x4e\x2d\x39\x08\xaf\xf7\x22\xfa\xd4\x68\xfb\x21\x69\x6d\xe9\x5d\x0b\xe9\x11\xc2\xd3\x17\x4f\x8a\xfc\xc2\x01\x03\x5f\x7b\x6d\x8e\x69\x40\x2d\xe5\x45\x16\x18\xc2\x1a\x53\x5f\xa9\xd7\xbf\xc5\xb8\xdd\x9f\xc2\x43\xf8\xcf\x92\x7d\xb3\x13\x22\xd6\xe8\x81\xea\xa9\x1a\x99\x61\x70\xe6\x57\xa0\x5a\x26\x64\x26\xd9\x8c\x88\x00\x3f\x84\x77\xc1\x22\x70\x94\xa0\xd9\xfa\x1e\x8c\x40\x24\x30\x9c\xe1\xec\xcc\xb5\x21\x00\x35\xd4\x7a\xc7\x2e\x8a"
         }
-
     , VectorOAEP -- 1.2
-        { message = "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
-        , seed = "\x0c\xc7\x42\xce\x4a\x9b\x7f\x32\xf9\x51\xbc\xb2\x51\xef\xd9\x25\xfe\x4f\xe3\x5f"
-        , cipherText = "\x64\x0d\xb1\xac\xc5\x8e\x05\x68\xfe\x54\x07\xe5\xf9\xb7\x01\xdf\xf8\xc3\xc9\x1e\x71\x6c\x53\x6f\xc7\xfc\xec\x6c\xb5\xb7\x1c\x11\x65\x98\x8d\x4a\x27\x9e\x15\x77\xd7\x30\xfc\x7a\x29\x93\x2e\x3f\x00\xc8\x15\x15\x23\x6d\x8d\x8e\x31\x01\x7a\x7a\x09\xdf\x43\x52\xd9\x04\xcd\xeb\x79\xaa\x58\x3a\xdc\xc3\x1e\xa6\x98\xa4\xc0\x52\x83\xda\xba\x90\x89\xbe\x54\x91\xf6\x7c\x1a\x4e\xe4\x8d\xc7\x4b\xbb\xe6\x64\x3a\xef\x84\x66\x79\xb4\xcb\x39\x5a\x35\x2d\x5e\xd1\x15\x91\x2d\xf6\x96\xff\xe0\x70\x29\x32\x94\x6d\x71\x49\x2b\x44"
+        { message =
+            "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
+        , seed =
+            "\x0c\xc7\x42\xce\x4a\x9b\x7f\x32\xf9\x51\xbc\xb2\x51\xef\xd9\x25\xfe\x4f\xe3\x5f"
+        , cipherText =
+            "\x64\x0d\xb1\xac\xc5\x8e\x05\x68\xfe\x54\x07\xe5\xf9\xb7\x01\xdf\xf8\xc3\xc9\x1e\x71\x6c\x53\x6f\xc7\xfc\xec\x6c\xb5\xb7\x1c\x11\x65\x98\x8d\x4a\x27\x9e\x15\x77\xd7\x30\xfc\x7a\x29\x93\x2e\x3f\x00\xc8\x15\x15\x23\x6d\x8d\x8e\x31\x01\x7a\x7a\x09\xdf\x43\x52\xd9\x04\xcd\xeb\x79\xaa\x58\x3a\xdc\xc3\x1e\xa6\x98\xa4\xc0\x52\x83\xda\xba\x90\x89\xbe\x54\x91\xf6\x7c\x1a\x4e\xe4\x8d\xc7\x4b\xbb\xe6\x64\x3a\xef\x84\x66\x79\xb4\xcb\x39\x5a\x35\x2d\x5e\xd1\x15\x91\x2d\xf6\x96\xff\xe0\x70\x29\x32\x94\x6d\x71\x49\x2b\x44"
         }
     , VectorOAEP -- 1.3
-        { message = "\xd9\x4a\xe0\x83\x2e\x64\x45\xce\x42\x33\x1c\xb0\x6d\x53\x1a\x82\xb1\xdb\x4b\xaa\xd3\x0f\x74\x6d\xc9\x16\xdf\x24\xd4\xe3\xc2\x45\x1f\xff\x59\xa6\x42\x3e\xb0\xe1\xd0\x2d\x4f\xe6\x46\xcf\x69\x9d\xfd\x81\x8c\x6e\x97\xb0\x51"
-        , seed = "\x25\x14\xdf\x46\x95\x75\x5a\x67\xb2\x88\xea\xf4\x90\x5c\x36\xee\xc6\x6f\xd2\xfd"
-        , cipherText = "\x42\x37\x36\xed\x03\x5f\x60\x26\xaf\x27\x6c\x35\xc0\xb3\x74\x1b\x36\x5e\x5f\x76\xca\x09\x1b\x4e\x8c\x29\xe2\xf0\xbe\xfe\xe6\x03\x59\x5a\xa8\x32\x2d\x60\x2d\x2e\x62\x5e\x95\xeb\x81\xb2\xf1\xc9\x72\x4e\x82\x2e\xca\x76\xdb\x86\x18\xcf\x09\xc5\x34\x35\x03\xa4\x36\x08\x35\xb5\x90\x3b\xc6\x37\xe3\x87\x9f\xb0\x5e\x0e\xf3\x26\x85\xd5\xae\xc5\x06\x7c\xd7\xcc\x96\xfe\x4b\x26\x70\xb6\xea\xc3\x06\x6b\x1f\xcf\x56\x86\xb6\x85\x89\xaa\xfb\x7d\x62\x9b\x02\xd8\xf8\x62\x5c\xa3\x83\x36\x24\xd4\x80\x0f\xb0\x81\xb1\xcf\x94\xeb"
+        { message =
+            "\xd9\x4a\xe0\x83\x2e\x64\x45\xce\x42\x33\x1c\xb0\x6d\x53\x1a\x82\xb1\xdb\x4b\xaa\xd3\x0f\x74\x6d\xc9\x16\xdf\x24\xd4\xe3\xc2\x45\x1f\xff\x59\xa6\x42\x3e\xb0\xe1\xd0\x2d\x4f\xe6\x46\xcf\x69\x9d\xfd\x81\x8c\x6e\x97\xb0\x51"
+        , seed =
+            "\x25\x14\xdf\x46\x95\x75\x5a\x67\xb2\x88\xea\xf4\x90\x5c\x36\xee\xc6\x6f\xd2\xfd"
+        , cipherText =
+            "\x42\x37\x36\xed\x03\x5f\x60\x26\xaf\x27\x6c\x35\xc0\xb3\x74\x1b\x36\x5e\x5f\x76\xca\x09\x1b\x4e\x8c\x29\xe2\xf0\xbe\xfe\xe6\x03\x59\x5a\xa8\x32\x2d\x60\x2d\x2e\x62\x5e\x95\xeb\x81\xb2\xf1\xc9\x72\x4e\x82\x2e\xca\x76\xdb\x86\x18\xcf\x09\xc5\x34\x35\x03\xa4\x36\x08\x35\xb5\x90\x3b\xc6\x37\xe3\x87\x9f\xb0\x5e\x0e\xf3\x26\x85\xd5\xae\xc5\x06\x7c\xd7\xcc\x96\xfe\x4b\x26\x70\xb6\xea\xc3\x06\x6b\x1f\xcf\x56\x86\xb6\x85\x89\xaa\xfb\x7d\x62\x9b\x02\xd8\xf8\x62\x5c\xa3\x83\x36\x24\xd4\x80\x0f\xb0\x81\xb1\xcf\x94\xeb"
         }
     , VectorOAEP
-        { message = "\x52\xe6\x50\xd9\x8e\x7f\x2a\x04\x8b\x4f\x86\x85\x21\x53\xb9\x7e\x01\xdd\x31\x6f\x34\x6a\x19\xf6\x7a\x85"
-        , seed = "\xc4\x43\x5a\x3e\x1a\x18\xa6\x8b\x68\x20\x43\x62\x90\xa3\x7c\xef\xb8\x5d\xb3\xfb"
-        , cipherText = "\x45\xea\xd4\xca\x55\x1e\x66\x2c\x98\x00\xf1\xac\xa8\x28\x3b\x05\x25\xe6\xab\xae\x30\xbe\x4b\x4a\xba\x76\x2f\xa4\x0f\xd3\xd3\x8e\x22\xab\xef\xc6\x97\x94\xf6\xeb\xbb\xc0\x5d\xdb\xb1\x12\x16\x24\x7d\x2f\x41\x2f\xd0\xfb\xa8\x7c\x6e\x3a\xcd\x88\x88\x13\x64\x6f\xd0\xe4\x8e\x78\x52\x04\xf9\xc3\xf7\x3d\x6d\x82\x39\x56\x27\x22\xdd\xdd\x87\x71\xfe\xc4\x8b\x83\xa3\x1e\xe6\xf5\x92\xc4\xcf\xd4\xbc\x88\x17\x4f\x3b\x13\xa1\x12\xaa\xe3\xb9\xf7\xb8\x0e\x0f\xc6\xf7\x25\x5b\xa8\x80\xdc\x7d\x80\x21\xe2\x2a\xd6\xa8\x5f\x07\x55"
+        { message =
+            "\x52\xe6\x50\xd9\x8e\x7f\x2a\x04\x8b\x4f\x86\x85\x21\x53\xb9\x7e\x01\xdd\x31\x6f\x34\x6a\x19\xf6\x7a\x85"
+        , seed =
+            "\xc4\x43\x5a\x3e\x1a\x18\xa6\x8b\x68\x20\x43\x62\x90\xa3\x7c\xef\xb8\x5d\xb3\xfb"
+        , cipherText =
+            "\x45\xea\xd4\xca\x55\x1e\x66\x2c\x98\x00\xf1\xac\xa8\x28\x3b\x05\x25\xe6\xab\xae\x30\xbe\x4b\x4a\xba\x76\x2f\xa4\x0f\xd3\xd3\x8e\x22\xab\xef\xc6\x97\x94\xf6\xeb\xbb\xc0\x5d\xdb\xb1\x12\x16\x24\x7d\x2f\x41\x2f\xd0\xfb\xa8\x7c\x6e\x3a\xcd\x88\x88\x13\x64\x6f\xd0\xe4\x8e\x78\x52\x04\xf9\xc3\xf7\x3d\x6d\x82\x39\x56\x27\x22\xdd\xdd\x87\x71\xfe\xc4\x8b\x83\xa3\x1e\xe6\xf5\x92\xc4\xcf\xd4\xbc\x88\x17\x4f\x3b\x13\xa1\x12\xaa\xe3\xb9\xf7\xb8\x0e\x0f\xc6\xf7\x25\x5b\xa8\x80\xdc\x7d\x80\x21\xe2\x2a\xd6\xa8\x5f\x07\x55"
         }
-
     , VectorOAEP
-        { message = "\x8d\xa8\x9f\xd9\xe5\xf9\x74\xa2\x9f\xef\xfb\x46\x2b\x49\x18\x0f\x6c\xf9\xe8\x02"
-        , seed = "\xb3\x18\xc4\x2d\xf3\xbe\x0f\x83\xfe\xa8\x23\xf5\xa7\xb4\x7e\xd5\xe4\x25\xa3\xb5"
-        , cipherText = "\x36\xf6\xe3\x4d\x94\xa8\xd3\x4d\xaa\xcb\xa3\x3a\x21\x39\xd0\x0a\xd8\x5a\x93\x45\xa8\x60\x51\xe7\x30\x71\x62\x00\x56\xb9\x20\xe2\x19\x00\x58\x55\xa2\x13\xa0\xf2\x38\x97\xcd\xcd\x73\x1b\x45\x25\x7c\x77\x7f\xe9\x08\x20\x2b\xef\xdd\x0b\x58\x38\x6b\x12\x44\xea\x0c\xf5\x39\xa0\x5d\x5d\x10\x32\x9d\xa4\x4e\x13\x03\x0f\xd7\x60\xdc\xd6\x44\xcf\xef\x20\x94\xd1\x91\x0d\x3f\x43\x3e\x1c\x7c\x6d\xd1\x8b\xc1\xf2\xdf\x7f\x64\x3d\x66\x2f\xb9\xdd\x37\xea\xd9\x05\x91\x90\xf4\xfa\x66\xca\x39\xe8\x69\xc4\xeb\x44\x9c\xbd\xc4\x39"
+        { message =
+            "\x8d\xa8\x9f\xd9\xe5\xf9\x74\xa2\x9f\xef\xfb\x46\x2b\x49\x18\x0f\x6c\xf9\xe8\x02"
+        , seed =
+            "\xb3\x18\xc4\x2d\xf3\xbe\x0f\x83\xfe\xa8\x23\xf5\xa7\xb4\x7e\xd5\xe4\x25\xa3\xb5"
+        , cipherText =
+            "\x36\xf6\xe3\x4d\x94\xa8\xd3\x4d\xaa\xcb\xa3\x3a\x21\x39\xd0\x0a\xd8\x5a\x93\x45\xa8\x60\x51\xe7\x30\x71\x62\x00\x56\xb9\x20\xe2\x19\x00\x58\x55\xa2\x13\xa0\xf2\x38\x97\xcd\xcd\x73\x1b\x45\x25\x7c\x77\x7f\xe9\x08\x20\x2b\xef\xdd\x0b\x58\x38\x6b\x12\x44\xea\x0c\xf5\x39\xa0\x5d\x5d\x10\x32\x9d\xa4\x4e\x13\x03\x0f\xd7\x60\xdc\xd6\x44\xcf\xef\x20\x94\xd1\x91\x0d\x3f\x43\x3e\x1c\x7c\x6d\xd1\x8b\xc1\xf2\xdf\x7f\x64\x3d\x66\x2f\xb9\xdd\x37\xea\xd9\x05\x91\x90\xf4\xfa\x66\xca\x39\xe8\x69\xc4\xeb\x44\x9c\xbd\xc4\x39"
         }
     , VectorOAEP -- 1.6
         { message = "\x26\x52\x10\x50\x84\x42\x71"
-        , seed = "\xe4\xec\x09\x82\xc2\x33\x6f\x3a\x67\x7f\x6a\x35\x61\x74\xeb\x0c\xe8\x87\xab\xc2"
-        , cipherText = "\x42\xce\xe2\x61\x7b\x1e\xce\xa4\xdb\x3f\x48\x29\x38\x6f\xbd\x61\xda\xfb\xf0\x38\xe1\x80\xd8\x37\xc9\x63\x66\xdf\x24\xc0\x97\xb4\xab\x0f\xac\x6b\xdf\x59\x0d\x82\x1c\x9f\x10\x64\x2e\x68\x1a\xd0\x5b\x8d\x78\xb3\x78\xc0\xf4\x6c\xe2\xfa\xd6\x3f\x74\xe0\xad\x3d\xf0\x6b\x07\x5d\x7e\xb5\xf5\x63\x6f\x8d\x40\x3b\x90\x59\xca\x76\x1b\x5c\x62\xbb\x52\xaa\x45\x00\x2e\xa7\x0b\xaa\xce\x08\xde\xd2\x43\xb9\xd8\xcb\xd6\x2a\x68\xad\xe2\x65\x83\x2b\x56\x56\x4e\x43\xa6\xfa\x42\xed\x19\x9a\x09\x97\x69\x74\x2d\xf1\x53\x9e\x82\x55"
+        , seed =
+            "\xe4\xec\x09\x82\xc2\x33\x6f\x3a\x67\x7f\x6a\x35\x61\x74\xeb\x0c\xe8\x87\xab\xc2"
+        , cipherText =
+            "\x42\xce\xe2\x61\x7b\x1e\xce\xa4\xdb\x3f\x48\x29\x38\x6f\xbd\x61\xda\xfb\xf0\x38\xe1\x80\xd8\x37\xc9\x63\x66\xdf\x24\xc0\x97\xb4\xab\x0f\xac\x6b\xdf\x59\x0d\x82\x1c\x9f\x10\x64\x2e\x68\x1a\xd0\x5b\x8d\x78\xb3\x78\xc0\xf4\x6c\xe2\xfa\xd6\x3f\x74\xe0\xad\x3d\xf0\x6b\x07\x5d\x7e\xb5\xf5\x63\x6f\x8d\x40\x3b\x90\x59\xca\x76\x1b\x5c\x62\xbb\x52\xaa\x45\x00\x2e\xa7\x0b\xaa\xce\x08\xde\xd2\x43\xb9\xd8\xcb\xd6\x2a\x68\xad\xe2\x65\x83\x2b\x56\x56\x4e\x43\xa6\xfa\x42\xed\x19\x9a\x09\x97\x69\x74\x2d\xf1\x53\x9e\x82\x55"
         }
     ]
 
 doEncryptionTest key i vec = testCase (show i) (Right (cipherText vec) @=? actual)
-    where actual = OAEP.encryptWithSeed (seed vec) (OAEP.defaultOAEPParams SHA1) key (message vec)
+  where
+    actual =
+        OAEP.encryptWithSeed (seed vec) (OAEP.defaultOAEPParams SHA1) key (message vec)
 
 doDecryptionTest key i vec = testCase (show i) (Right (message vec) @=? actual)
-    where actual = OAEP.decrypt Nothing (OAEP.defaultOAEPParams SHA1) key (cipherText vec)
+  where
+    actual = OAEP.decrypt Nothing (OAEP.defaultOAEPParams SHA1) key (cipherText vec)
 
-oaepTests = testGroup "RSA-OAEP"
-    [ testGroup "internal"
-        [ doEncryptionTest (private_pub rsaKeyInt) (0 :: Int) vectorInt
-        , doDecryptionTest rsaKeyInt (0 :: Int) vectorInt
+oaepTests =
+    testGroup
+        "RSA-OAEP"
+        [ testGroup
+            "internal"
+            [ doEncryptionTest (private_pub rsaKeyInt) (0 :: Int) vectorInt
+            , doDecryptionTest rsaKeyInt (0 :: Int) vectorInt
+            ]
+        , testGroup "encryption key 1024 bits" $
+            zipWith (doEncryptionTest $ private_pub rsaKey1) [katZero ..] vectorsKey1
+        , testGroup "decryption key 1024 bits" $
+            zipWith (doDecryptionTest rsaKey1) [katZero ..] vectorsKey1
         ]
-    , testGroup "encryption key 1024 bits" $ zipWith (doEncryptionTest $ private_pub rsaKey1) [katZero..] vectorsKey1
-    , testGroup "decryption key 1024 bits" $ zipWith (doDecryptionTest rsaKey1) [katZero..] vectorsKey1
-    ]
diff --git a/tests/KAT_PubKey/P256.hs b/tests/KAT_PubKey/P256.hs
--- a/tests/KAT_PubKey/P256.hs
+++ b/tests/KAT_PubKey/P256.hs
@@ -1,55 +1,61 @@
-{-# LANGUAGE OverloadedStrings   #-}
+{-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE ScopedTypeVariables #-}
+
 module KAT_PubKey.P256 (tests) where
 
-import qualified Crypto.PubKey.ECC.Types as ECC
-import qualified Crypto.PubKey.ECC.Prim as ECC
 import qualified Crypto.PubKey.ECC.P256 as P256
+import qualified Crypto.PubKey.ECC.Prim as ECC
+import qualified Crypto.PubKey.ECC.Types as ECC
 
-import           Data.ByteArray (Bytes)
-import           Crypto.Number.Serialize (i2ospOf, os2ip)
-import           Crypto.Number.ModArithmetic (inverseCoprimes)
-import           Crypto.Error
+import Crypto.Error
+import Crypto.Number.ModArithmetic (inverseCoprimes)
+import Crypto.Number.Serialize (i2ospOf, os2ip)
+import Data.ByteArray (Bytes)
 
-import           Imports
+import Imports
 
 newtype P256Scalar = P256Scalar Integer
-    deriving (Show,Eq,Ord)
+    deriving (Show, Eq, Ord)
 
 instance Arbitrary P256Scalar where
     -- Cover the full range up to 2^256-1 except 0 and curveN.  To test edge
     -- cases with arithmetic functions, some values close to 0, curveN and
     -- 2^256 are given higher frequency.
-    arbitrary = P256Scalar <$> oneof
-        [ choose (1, w)
-        , choose (w + 1, curveN - w - 1)
-        , choose (curveN - w, curveN - 1)
-        , choose (curveN + 1, curveN + w)
-        , choose (curveN + w + 1, high - w - 1)
-        , choose (high - w, high - 1)
-        ]
-      where high = 2^(256 :: Int)
-            w    = 100
+    arbitrary =
+        P256Scalar
+            <$> oneof
+                [ choose (1, w)
+                , choose (w + 1, curveN - w - 1)
+                , choose (curveN - w, curveN - 1)
+                , choose (curveN + 1, curveN + w)
+                , choose (curveN + w + 1, high - w - 1)
+                , choose (high - w, high - 1)
+                ]
+      where
+        high = 2 ^ (256 :: Int)
+        w = 100
 
-curve  = ECC.getCurveByName ECC.SEC_p256r1
+curve = ECC.getCurveByName ECC.SEC_p256r1
 curveN = ECC.ecc_n . ECC.common_curve $ curve
 curveGen = ECC.ecc_g . ECC.common_curve $ curve
 
 pointP256ToECC :: P256.Point -> ECC.Point
-pointP256ToECC = uncurry ECC.Point . P256.pointToIntegers
+pointP256ToECC p
+    | P256.pointIsAtInfinity p = ECC.PointO
+    | otherwise = uncurry ECC.Point (P256.pointToIntegers p)
 
 i2ospScalar :: Integer -> Bytes
 i2ospScalar i =
     case i2ospOf 32 i of
         Nothing -> error "invalid size of P256 scalar"
-        Just b  -> b
+        Just b -> b
 
 unP256Scalar :: P256Scalar -> P256.Scalar
 unP256Scalar (P256Scalar r) =
     let rBytes = i2ospScalar r
      in case P256.scalarFromBinary rBytes of
-                    CryptoFailed err    -> error ("cannot convert scalar: " ++ show err)
-                    CryptoPassed scalar -> scalar
+            CryptoFailed err -> error ("cannot convert scalar: " ++ show err)
+            CryptoPassed scalar -> scalar
 
 unP256 :: P256Scalar -> Integer
 unP256 (P256Scalar r) = r
@@ -67,122 +73,179 @@
 xR = 0x72b13dd4354b6b81745195e98cc5ba6970349191ac476bd4553cf35a545a067e
 yR = 0x8d585cbb2e1327d75241a8a122d7620dc33b13315aa5c9d46d013011744ac264
 
-tests = testGroup "P256"
-    [ testGroup "scalar"
-        [ testProperty "marshalling" $ \(QAInteger r) ->
-            let rBytes = i2ospScalar r
-             in case P256.scalarFromBinary rBytes of
-                    CryptoFailed err    -> error (show err)
-                    CryptoPassed scalar -> rBytes `propertyEq` P256.scalarToBinary scalar
-        , testProperty "add" $ \r1 r2 ->
-            let r = (unP256 r1 + unP256 r2) `mod` curveN
-                r' = P256.scalarAdd (unP256Scalar r1) (unP256Scalar r2)
-             in r `propertyEq` p256ScalarToInteger r'
-        , testProperty "add0" $ \r ->
-            let v = unP256 r `mod` curveN
-                v' = P256.scalarAdd (unP256Scalar r) P256.scalarZero
-             in v `propertyEq` p256ScalarToInteger v'
-        , testProperty "sub" $ \r1 r2 ->
-            let r = (unP256 r1 - unP256 r2) `mod` curveN
-                r' = P256.scalarSub (unP256Scalar r1) (unP256Scalar r2)
-                v = (unP256 r2 - unP256 r1) `mod` curveN
-                v' = P256.scalarSub (unP256Scalar r2) (unP256Scalar r1)
-             in propertyHold
-                    [ eqTest "r1-r2" r (p256ScalarToInteger r')
-                    , eqTest "r2-r1" v (p256ScalarToInteger v')
-                    ]
-        , testProperty "sub0" $ \r ->
-            let v = unP256 r `mod` curveN
-                v' = P256.scalarSub (unP256Scalar r) P256.scalarZero
-             in v `propertyEq` p256ScalarToInteger v'
-        , testProperty "mul" $ \r1 r2 ->
-            let r = (unP256 r1 * unP256 r2) `mod` curveN
-                r' = P256.scalarMul (unP256Scalar r1) (unP256Scalar r2)
-             in r `propertyEq` p256ScalarToInteger r'
-        , testProperty "inv" $ \r' ->
-            let inv  = inverseCoprimes (unP256 r') curveN
-                inv' = P256.scalarInv (unP256Scalar r')
-             in unP256 r' /= 0 ==> inv `propertyEq` p256ScalarToInteger inv'
-        , testProperty "inv-safe" $ \r' ->
-            let inv  = P256.scalarInv (unP256Scalar r')
-                inv' = P256.scalarInvSafe (unP256Scalar r')
-             in unP256 r' /= 0 ==> inv `propertyEq` inv'
-        , testProperty "inv-safe-mul" $ \r' ->
-            let inv = P256.scalarInvSafe (unP256Scalar r')
-                res = P256.scalarMul (unP256Scalar r') inv
-             in unP256 r' /= 0 ==> 1 `propertyEq` p256ScalarToInteger res
-        , testProperty "inv-safe-zero" $
-            let inv0 = P256.scalarInvSafe P256.scalarZero
-                invN = P256.scalarInvSafe P256.scalarN
-             in propertyHold [ eqTest "scalarZero" P256.scalarZero inv0
-                             , eqTest "scalarN"    P256.scalarZero invN
-                             ]
-        ]
-    , testGroup "point"
-        [ testProperty "marshalling" $ \rx ry ->
-            let p = P256.pointFromIntegers (unP256 rx, unP256 ry)
-                b = P256.pointToBinary p :: Bytes
-                p' = P256.unsafePointFromBinary b
-             in propertyHold [ eqTest "point" (CryptoPassed p) p' ]
-        , testProperty "marshalling-integer" $ \rx ry ->
-            let p = P256.pointFromIntegers (unP256 rx, unP256 ry)
-                (x,y) = P256.pointToIntegers p
-             in propertyHold [ eqTest "x" (unP256 rx) x, eqTest "y" (unP256 ry) y ]
-        , testCase "valid-point-1" $ casePointIsValid (xS,yS)
-        , testCase "valid-point-2" $ casePointIsValid (xR,yR)
-        , testCase "valid-point-3" $ casePointIsValid (xT,yT)
-        , testCase "point-add-1" $
-            let s = P256.pointFromIntegers (xS, yS)
-                t = P256.pointFromIntegers (xT, yT)
-                r = P256.pointFromIntegers (xR, yR)
-             in r @=? P256.pointAdd s t
-        , testProperty "lift-to-curve" propertyLiftToCurve
-        , testProperty "point-add" propertyPointAdd
-        , testProperty "point-negate" propertyPointNegate
-        , testProperty "point-mul" propertyPointMul
-        , testProperty "infinity" $
-            let gN = P256.toPoint P256.scalarN
-                g1 = P256.pointBase
-             in propertyHold [ eqTest "zero" True  (P256.pointIsAtInfinity gN)
-                             , eqTest "base" False (P256.pointIsAtInfinity g1)
-                             ]
+tests =
+    testGroup
+        "P256"
+        [ testGroup
+            "scalar"
+            [ testProperty "marshalling" $ \(QAInteger r) ->
+                let rBytes = i2ospScalar r
+                 in case P256.scalarFromBinary rBytes of
+                        CryptoFailed err -> error (show err)
+                        CryptoPassed scalar -> rBytes `propertyEq` P256.scalarToBinary scalar
+            , testProperty "add" $ \r1 r2 ->
+                let r = (unP256 r1 + unP256 r2) `mod` curveN
+                    r' = P256.scalarAdd (unP256Scalar r1) (unP256Scalar r2)
+                 in r `propertyEq` p256ScalarToInteger r'
+            , testProperty "add0" $ \r ->
+                let v = unP256 r `mod` curveN
+                    v' = P256.scalarAdd (unP256Scalar r) P256.scalarZero
+                 in v `propertyEq` p256ScalarToInteger v'
+            , testProperty "sub" $ \r1 r2 ->
+                let r = (unP256 r1 - unP256 r2) `mod` curveN
+                    r' = P256.scalarSub (unP256Scalar r1) (unP256Scalar r2)
+                    v = (unP256 r2 - unP256 r1) `mod` curveN
+                    v' = P256.scalarSub (unP256Scalar r2) (unP256Scalar r1)
+                 in propertyHold
+                        [ eqTest "r1-r2" r (p256ScalarToInteger r')
+                        , eqTest "r2-r1" v (p256ScalarToInteger v')
+                        ]
+            , testProperty "sub0" $ \r ->
+                let v = unP256 r `mod` curveN
+                    v' = P256.scalarSub (unP256Scalar r) P256.scalarZero
+                 in v `propertyEq` p256ScalarToInteger v'
+            , testProperty "mul" $ \r1 r2 ->
+                let r = (unP256 r1 * unP256 r2) `mod` curveN
+                    r' = P256.scalarMul (unP256Scalar r1) (unP256Scalar r2)
+                 in r `propertyEq` p256ScalarToInteger r'
+            , testProperty "inv" $ \r' ->
+                let inv = inverseCoprimes (unP256 r') curveN
+                    inv' = P256.scalarInv (unP256Scalar r')
+                 in unP256 r' /= 0 ==> inv `propertyEq` p256ScalarToInteger inv'
+            , testProperty "inv-safe" $ \r' ->
+                let inv = P256.scalarInv (unP256Scalar r')
+                    inv' = P256.scalarInvSafe (unP256Scalar r')
+                 in unP256 r' /= 0 ==> inv `propertyEq` inv'
+            , testProperty "inv-safe-mul" $ \r' ->
+                let inv = P256.scalarInvSafe (unP256Scalar r')
+                    res = P256.scalarMul (unP256Scalar r') inv
+                 in unP256 r' /= 0 ==> 1 `propertyEq` p256ScalarToInteger res
+            , testProperty "inv-safe-zero" $
+                let inv0 = P256.scalarInvSafe P256.scalarZero
+                    invN = P256.scalarInvSafe P256.scalarN
+                 in propertyHold
+                        [ eqTest "scalarZero" P256.scalarZero inv0
+                        , eqTest "scalarN" P256.scalarZero invN
+                        ]
+            ]
+        , testGroup
+            "point"
+            [ testProperty "marshalling" $ \rx ry ->
+                let p = P256.pointFromIntegers (unP256 rx, unP256 ry)
+                    b = P256.pointToBinary p :: Bytes
+                    p' = P256.unsafePointFromBinary b
+                 in propertyHold [eqTest "point" (CryptoPassed p) p']
+            , testProperty "marshalling-integer" $ \rx ry ->
+                let p = P256.pointFromIntegers (unP256 rx, unP256 ry)
+                    (x, y) = P256.pointToIntegers p
+                 in propertyHold [eqTest "x" (unP256 rx) x, eqTest "y" (unP256 ry) y]
+            , testCase "valid-point-1" $ casePointIsValid (xS, yS)
+            , testCase "valid-point-2" $ casePointIsValid (xR, yR)
+            , testCase "valid-point-3" $ casePointIsValid (xT, yT)
+            , testCase "point-add-1" $
+                let s = P256.pointFromIntegers (xS, yS)
+                    t = P256.pointFromIntegers (xT, yT)
+                    r = P256.pointFromIntegers (xR, yR)
+                 in r @=? P256.pointAdd s t
+            , testProperty "point-add-infinity" casePointAddInfinity
+            , testProperty "lift-to-curve" propertyLiftToCurve
+            , testProperty "point-add" propertyPointAdd
+            , testProperty "point-add-infinity-identity" propertyPointAddInfinityIdentity
+            , testProperty "point-add-inverse" propertyPointAddInverse
+            , testProperty "point-negate" propertyPointNegate
+            , testProperty "point-mul" propertyPointMul
+            , testProperty "infinity" $
+                let gN = P256.toPoint P256.scalarN
+                    g1 = P256.pointBase
+                 in propertyHold
+                        [ eqTest "zero" True (P256.pointIsAtInfinity gN)
+                        , eqTest "base" False (P256.pointIsAtInfinity g1)
+                        ]
+            ]
         ]
-    ]
   where
     casePointIsValid pointTuple =
         let s = P256.pointFromIntegers pointTuple in True @=? P256.pointIsValid s
 
     propertyLiftToCurve r =
-        let p     = P256.toPoint (unP256Scalar r)
-            (x,y) = P256.pointToIntegers p
-            pEcc  = ECC.pointMul curve (unP256 r) curveGen
+        let p = P256.toPoint (unP256Scalar r)
+            (x, y) = P256.pointToIntegers p
+            pEcc = ECC.pointMul curve (unP256 r) curveGen
          in pEcc `propertyEq` ECC.Point x y
 
     propertyPointAdd r1 r2 =
-        let p1    = P256.toPoint (unP256Scalar r1)
-            p2    = P256.toPoint (unP256Scalar r2)
-            pe1   = ECC.pointMul curve (unP256 r1) curveGen
-            pe2   = ECC.pointMul curve (unP256 r2) curveGen
-            pR    = P256.toPoint (P256.scalarAdd (unP256Scalar r1) (unP256Scalar r2))
-            peR   = ECC.pointAdd curve pe1 pe2
-         in (unP256 r1 + unP256 r2) `mod` curveN /= 0 ==>
-            propertyHold [ eqTest "p256" pR (P256.pointAdd p1 p2)
-                         , eqTest "ecc" peR (pointP256ToECC pR)
-                         ]
+        let p1 = P256.toPoint (unP256Scalar r1)
+            p2 = P256.toPoint (unP256Scalar r2)
+            pe1 = ECC.pointMul curve (unP256 r1) curveGen
+            pe2 = ECC.pointMul curve (unP256 r2) curveGen
+            pR = P256.toPoint (P256.scalarAdd (unP256Scalar r1) (unP256Scalar r2))
+            peR = ECC.pointAdd curve pe1 pe2
+         in (unP256 r1 + unP256 r2) `mod` curveN
+                /= 0
+                    ==> propertyHold
+                        [ eqTest "p256" pR (P256.pointAdd p1 p2)
+                        , eqTest "ecc" peR (pointP256ToECC pR)
+                        ]
 
     propertyPointNegate r =
-        let p  = P256.toPoint (unP256Scalar r)
+        let p = P256.toPoint (unP256Scalar r)
             pe = ECC.pointMul curve (unP256 r) curveGen
             pR = P256.pointNegate p
          in ECC.pointNegate curve pe `propertyEq` pointP256ToECC pR
 
     propertyPointMul s' r' =
-        let s     = modP256Scalar s'
-            r     = modP256Scalar r'
-            p     = P256.toPoint (unP256Scalar r)
-            pe    = ECC.pointMul curve (unP256 r) curveGen
-            pR    = P256.toPoint (P256.scalarMul (unP256Scalar s) (unP256Scalar r))
-            peR   = ECC.pointMul curve (unP256 s) pe
-         in propertyHold [ eqTest "p256" pR (P256.pointMul (unP256Scalar s) p)
-                         , eqTest "ecc" peR (pointP256ToECC pR)
-                         ]
+        let s = modP256Scalar s'
+            r = modP256Scalar r'
+            p = P256.toPoint (unP256Scalar r)
+            pe = ECC.pointMul curve (unP256 r) curveGen
+            pR = P256.toPoint (P256.scalarMul (unP256Scalar s) (unP256Scalar r))
+            peR = ECC.pointMul curve (unP256 s) pe
+         in propertyHold
+                [ eqTest "p256" pR (P256.pointMul (unP256Scalar s) p)
+                , eqTest "ecc" peR (pointP256ToECC pR)
+                ]
+
+    pointInfinity :: P256.Point
+    pointInfinity = P256.pointFromIntegers (0, 0)
+
+    casePointAddInfinity =
+        propertyHold
+            [ eqTest
+                "infinity + base"
+                P256.pointBase
+                (P256.pointAdd pointInfinity P256.pointBase)
+            , eqTest
+                "base + infinity"
+                P256.pointBase
+                (P256.pointAdd P256.pointBase pointInfinity)
+            , eqTest
+                "infinity + infinity"
+                pointInfinity
+                (P256.pointAdd pointInfinity pointInfinity)
+            ]
+
+    propertyPointAddInfinityIdentity r =
+        let p = P256.toPoint (unP256Scalar r)
+         in propertyHold
+                [ eqTest
+                    "infinity + p"
+                    p
+                    (P256.pointAdd pointInfinity p)
+                , eqTest
+                    "p + infinity"
+                    p
+                    (P256.pointAdd p pointInfinity)
+                ]
+
+    propertyPointAddInverse r =
+        let p = P256.toPoint (unP256Scalar r)
+         in propertyHold
+                [ eqTest
+                    "p + negate p"
+                    True
+                    (P256.pointIsAtInfinity (P256.pointAdd p (P256.pointNegate p)))
+                , eqTest
+                    "negate p + p"
+                    True
+                    (P256.pointIsAtInfinity (P256.pointAdd (P256.pointNegate p) p))
+                ]
diff --git a/tests/KAT_PubKey/PSS.hs b/tests/KAT_PubKey/PSS.hs
--- a/tests/KAT_PubKey/PSS.hs
+++ b/tests/KAT_PubKey/PSS.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_PubKey.PSS (pssTests) where
 
 import Crypto.PubKey.RSA
@@ -9,146 +10,185 @@
 -- Module contains one vector generated by the implementation itself and other
 -- vectors from <ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip>
 
-data VectorPSS = VectorPSS { message :: ByteString
-                           , salt :: ByteString
-                           , signature :: ByteString
-                           }
+data VectorPSS = VectorPSS
+    { message :: ByteString
+    , salt :: ByteString
+    , signature :: ByteString
+    }
 
-rsaKeyInt = PrivateKey
-    { private_pub = PublicKey
-        { public_n = 0xa2ba40ee07e3b2bd2f02ce227f36a195024486e49c19cb41bbbdfbba98b22b0e577c2eeaffa20d883a76e65e394c69d4b3c05a1e8fadda27edb2a42bc000fe888b9b32c22d15add0cd76b3e7936e19955b220dd17d4ea904b1ec102b2e4de7751222aa99151024c7cb41cc5ea21d00eeb41f7c800834d2c6e06bce3bce7ea9a5
-        , public_e = 0x010001
-        , public_size = 128
+rsaKeyInt =
+    PrivateKey
+        { private_pub =
+            PublicKey
+                { public_n =
+                    0xa2ba40ee07e3b2bd2f02ce227f36a195024486e49c19cb41bbbdfbba98b22b0e577c2eeaffa20d883a76e65e394c69d4b3c05a1e8fadda27edb2a42bc000fe888b9b32c22d15add0cd76b3e7936e19955b220dd17d4ea904b1ec102b2e4de7751222aa99151024c7cb41cc5ea21d00eeb41f7c800834d2c6e06bce3bce7ea9a5
+                , public_e = 0x010001
+                , public_size = 128
+                }
+        , private_d =
+            0x50e2c3e38d886110288dfc68a9533e7e12e27d2aa56d2cdb3fb6efa990bcff29e1d2987fb711962860e7391b1ce01ebadb9e812d2fbdfaf25df4ae26110a6d7a26f0b810f54875e17dd5c9fb6d641761245b81e79f8c88f0e55a6dcd5f133abd35f8f4ec80adf1bf86277a582894cb6ebcd2162f1c7534f1f4947b129151b71
+        , private_p =
+            0xd17f655bf27c8b16d35462c905cc04a26f37e2a67fa9c0ce0dced472394a0df743fe7f929e378efdb368eddff453cf007af6d948e0ade757371f8a711e278f6b
+        , private_q =
+            0xc6d92b6fee7414d1358ce1546fb62987530b90bd15e0f14963a5e2635adb69347ec0c01b2ab1763fd8ac1a592fb22757463a982425bb97a3a437c5bf86d03f2f
+        , private_dP =
+            0x9d0dbf83e5ce9e4b1754dcd5cd05bcb7b55f1508330ea49f14d4e889550f8256cb5f806dff34b17ada44208853577d08e4262890acf752461cea05547601bc4f
+        , private_dQ =
+            0x1291a524c6b7c059e90e46dc83b2171eb3fa98818fd179b6c8bf6cecaa476303abf283fe05769cfc495788fe5b1ddfde9e884a3cd5e936b7e955ebf97eb563b1
+        , private_qinv =
+            0xa63f1da38b950c9ad1c67ce0d677ec2914cd7d40062df42a67eb198a176f9742aac7c5fea14f2297662b84812c4defc49a8025ab4382286be4c03788dd01d69f
         }
-    , private_d = 0x50e2c3e38d886110288dfc68a9533e7e12e27d2aa56d2cdb3fb6efa990bcff29e1d2987fb711962860e7391b1ce01ebadb9e812d2fbdfaf25df4ae26110a6d7a26f0b810f54875e17dd5c9fb6d641761245b81e79f8c88f0e55a6dcd5f133abd35f8f4ec80adf1bf86277a582894cb6ebcd2162f1c7534f1f4947b129151b71
-    , private_p = 0xd17f655bf27c8b16d35462c905cc04a26f37e2a67fa9c0ce0dced472394a0df743fe7f929e378efdb368eddff453cf007af6d948e0ade757371f8a711e278f6b
-    , private_q = 0xc6d92b6fee7414d1358ce1546fb62987530b90bd15e0f14963a5e2635adb69347ec0c01b2ab1763fd8ac1a592fb22757463a982425bb97a3a437c5bf86d03f2f
-    , private_dP = 0x9d0dbf83e5ce9e4b1754dcd5cd05bcb7b55f1508330ea49f14d4e889550f8256cb5f806dff34b17ada44208853577d08e4262890acf752461cea05547601bc4f
-    , private_dQ = 0x1291a524c6b7c059e90e46dc83b2171eb3fa98818fd179b6c8bf6cecaa476303abf283fe05769cfc495788fe5b1ddfde9e884a3cd5e936b7e955ebf97eb563b1
-    , private_qinv = 0xa63f1da38b950c9ad1c67ce0d677ec2914cd7d40062df42a67eb198a176f9742aac7c5fea14f2297662b84812c4defc49a8025ab4382286be4c03788dd01d69f
-    }
 
-rsaKey1 = PrivateKey
-    { private_pub = PublicKey
-        { public_n = 0xa56e4a0e701017589a5187dc7ea841d156f2ec0e36ad52a44dfeb1e61f7ad991d8c51056ffedb162b4c0f283a12a88a394dff526ab7291cbb307ceabfce0b1dfd5cd9508096d5b2b8b6df5d671ef6377c0921cb23c270a70e2598e6ff89d19f105acc2d3f0cb35f29280e1386b6f64c4ef22e1e1f20d0ce8cffb2249bd9a2137
-        , public_e = 0x010001
-        , public_size = 128
+rsaKey1 =
+    PrivateKey
+        { private_pub =
+            PublicKey
+                { public_n =
+                    0xa56e4a0e701017589a5187dc7ea841d156f2ec0e36ad52a44dfeb1e61f7ad991d8c51056ffedb162b4c0f283a12a88a394dff526ab7291cbb307ceabfce0b1dfd5cd9508096d5b2b8b6df5d671ef6377c0921cb23c270a70e2598e6ff89d19f105acc2d3f0cb35f29280e1386b6f64c4ef22e1e1f20d0ce8cffb2249bd9a2137
+                , public_e = 0x010001
+                , public_size = 128
+                }
+        , private_d =
+            0x33a5042a90b27d4f5451ca9bbbd0b44771a101af884340aef9885f2a4bbe92e894a724ac3c568c8f97853ad07c0266c8c6a3ca0929f1e8f11231884429fc4d9ae55fee896a10ce707c3ed7e734e44727a39574501a532683109c2abacaba283c31b4bd2f53c3ee37e352cee34f9e503bd80c0622ad79c6dcee883547c6a3b325
+        , private_p =
+            0xe7e8942720a877517273a356053ea2a1bc0c94aa72d55c6e86296b2dfc967948c0a72cbccca7eacb35706e09a1df55a1535bd9b3cc34160b3b6dcd3eda8e6443
+        , private_q =
+            0xb69dca1cf7d4d7ec81e75b90fcca874abcde123fd2700180aa90479b6e48de8d67ed24f9f19d85ba275874f542cd20dc723e6963364a1f9425452b269a6799fd
+        , private_dP =
+            0x28fa13938655be1f8a159cbaca5a72ea190c30089e19cd274a556f36c4f6e19f554b34c077790427bbdd8dd3ede2448328f385d81b30e8e43b2fffa027861979
+        , private_dQ =
+            0x1a8b38f398fa712049898d7fb79ee0a77668791299cdfa09efc0e507acb21ed74301ef5bfd48be455eaeb6e1678255827580a8e4e8e14151d1510a82a3f2e729
+        , private_qinv =
+            0x27156aba4126d24a81f3a528cbfb27f56886f840a9f6e86e17a44b94fe9319584b8e22fdde1e5a2e3bd8aa5ba8d8584194eb2190acf832b847f13a3d24a79f4d
         }
-    , private_d = 0x33a5042a90b27d4f5451ca9bbbd0b44771a101af884340aef9885f2a4bbe92e894a724ac3c568c8f97853ad07c0266c8c6a3ca0929f1e8f11231884429fc4d9ae55fee896a10ce707c3ed7e734e44727a39574501a532683109c2abacaba283c31b4bd2f53c3ee37e352cee34f9e503bd80c0622ad79c6dcee883547c6a3b325
-    , private_p = 0xe7e8942720a877517273a356053ea2a1bc0c94aa72d55c6e86296b2dfc967948c0a72cbccca7eacb35706e09a1df55a1535bd9b3cc34160b3b6dcd3eda8e6443
-    , private_q = 0xb69dca1cf7d4d7ec81e75b90fcca874abcde123fd2700180aa90479b6e48de8d67ed24f9f19d85ba275874f542cd20dc723e6963364a1f9425452b269a6799fd
-    , private_dP = 0x28fa13938655be1f8a159cbaca5a72ea190c30089e19cd274a556f36c4f6e19f554b34c077790427bbdd8dd3ede2448328f385d81b30e8e43b2fffa027861979
-    , private_dQ = 0x1a8b38f398fa712049898d7fb79ee0a77668791299cdfa09efc0e507acb21ed74301ef5bfd48be455eaeb6e1678255827580a8e4e8e14151d1510a82a3f2e729
-    , private_qinv = 0x27156aba4126d24a81f3a528cbfb27f56886f840a9f6e86e17a44b94fe9319584b8e22fdde1e5a2e3bd8aa5ba8d8584194eb2190acf832b847f13a3d24a79f4d
-    }
 
-vectorInt = VectorPSS
-    { message = "\x85\x9e\xef\x2f\xd7\x8a\xca\x00\x30\x8b\xdc\x47\x11\x93\xbf\x55\xbf\x9d\x78\xdb\x8f\x8a\x67\x2b\x48\x46\x34\xf3\xc9\xc2\x6e\x64\x78\xae\x10\x26\x0f\xe0\xdd\x8c\x08\x2e\x53\xa5\x29\x3a\xf2\x17\x3c\xd5\x0c\x6d\x5d\x35\x4f\xeb\xf7\x8b\x26\x02\x1c\x25\xc0\x27\x12\xe7\x8c\xd4\x69\x4c\x9f\x46\x97\x77\xe4\x51\xe7\xf8\xe9\xe0\x4c\xd3\x73\x9c\x6b\xbf\xed\xae\x48\x7f\xb5\x56\x44\xe9\xca\x74\xff\x77\xa5\x3c\xb7\x29\x80\x2f\x6e\xd4\xa5\xff\xa8\xba\x15\x98\x90\xfc"
-    , salt = "\xe3\xb5\xd5\xd0\x02\xc1\xbc\xe5\x0c\x2b\x65\xef\x88\xa1\x88\xd8\x3b\xce\x7e\x61"
-    , signature = "\x8d\xaa\x62\x7d\x3d\xe7\x59\x5d\x63\x05\x6c\x7e\xc6\x59\xe5\x44\x06\xf1\x06\x10\x12\x8b\xaa\xe8\x21\xc8\xb2\xa0\xf3\x93\x6d\x54\xdc\x3b\xdc\xe4\x66\x89\xf6\xb7\x95\x1b\xb1\x8e\x84\x05\x42\x76\x97\x18\xd5\x71\x5d\x21\x0d\x85\xef\xbb\x59\x61\x92\x03\x2c\x42\xbe\x4c\x29\x97\x2c\x85\x62\x75\xeb\x6d\x5a\x45\xf0\x5f\x51\x87\x6f\xc6\x74\x3d\xed\xdd\x28\xca\xec\x9b\xb3\x0e\xa9\x9e\x02\xc3\x48\x82\x69\x60\x4f\xe4\x97\xf7\x4c\xcd\x7c\x7f\xca\x16\x71\x89\x71\x23\xcb\xd3\x0d\xef\x5d\x54\xa2\xb5\x53\x6a\xd9\x0a\x74\x7e"
-    }
+vectorInt =
+    VectorPSS
+        { message =
+            "\x85\x9e\xef\x2f\xd7\x8a\xca\x00\x30\x8b\xdc\x47\x11\x93\xbf\x55\xbf\x9d\x78\xdb\x8f\x8a\x67\x2b\x48\x46\x34\xf3\xc9\xc2\x6e\x64\x78\xae\x10\x26\x0f\xe0\xdd\x8c\x08\x2e\x53\xa5\x29\x3a\xf2\x17\x3c\xd5\x0c\x6d\x5d\x35\x4f\xeb\xf7\x8b\x26\x02\x1c\x25\xc0\x27\x12\xe7\x8c\xd4\x69\x4c\x9f\x46\x97\x77\xe4\x51\xe7\xf8\xe9\xe0\x4c\xd3\x73\x9c\x6b\xbf\xed\xae\x48\x7f\xb5\x56\x44\xe9\xca\x74\xff\x77\xa5\x3c\xb7\x29\x80\x2f\x6e\xd4\xa5\xff\xa8\xba\x15\x98\x90\xfc"
+        , salt =
+            "\xe3\xb5\xd5\xd0\x02\xc1\xbc\xe5\x0c\x2b\x65\xef\x88\xa1\x88\xd8\x3b\xce\x7e\x61"
+        , signature =
+            "\x8d\xaa\x62\x7d\x3d\xe7\x59\x5d\x63\x05\x6c\x7e\xc6\x59\xe5\x44\x06\xf1\x06\x10\x12\x8b\xaa\xe8\x21\xc8\xb2\xa0\xf3\x93\x6d\x54\xdc\x3b\xdc\xe4\x66\x89\xf6\xb7\x95\x1b\xb1\x8e\x84\x05\x42\x76\x97\x18\xd5\x71\x5d\x21\x0d\x85\xef\xbb\x59\x61\x92\x03\x2c\x42\xbe\x4c\x29\x97\x2c\x85\x62\x75\xeb\x6d\x5a\x45\xf0\x5f\x51\x87\x6f\xc6\x74\x3d\xed\xdd\x28\xca\xec\x9b\xb3\x0e\xa9\x9e\x02\xc3\x48\x82\x69\x60\x4f\xe4\x97\xf7\x4c\xcd\x7c\x7f\xca\x16\x71\x89\x71\x23\xcb\xd3\x0d\xef\x5d\x54\xa2\xb5\x53\x6a\xd9\x0a\x74\x7e"
+        }
 
 {-
 # mHash    = Hash(M)
 # salt     = random string of octets
 # M'       = Padding || mHash || salt
 # H        = Hash(M')
-# DB       = Padding || salt 
+# DB       = Padding || salt
 # dbMask   = MGF(H, length(DB))
 # maskedDB = DB xor dbMask (leftmost bit set to
 #            zero)
 # EM       = maskedDB || H || 0xbc
 
 # mHash:
-37 b6 6a e0 44 58 43 35 3d 47 ec b0 b4 fd 14 c1 
-10 e6 2d 6a 
+37 b6 6a e0 44 58 43 35 3d 47 ec b0 b4 fd 14 c1
+10 e6 2d 6a
 
 # salt:
 
 # M':
-00 00 00 00 00 00 00 00 37 b6 6a e0 44 58 43 35 
-3d 47 ec b0 b4 fd 14 c1 10 e6 2d 6a e3 b5 d5 d0 
-02 c1 bc e5 0c 2b 65 ef 88 a1 88 d8 3b ce 7e 61 
+00 00 00 00 00 00 00 00 37 b6 6a e0 44 58 43 35
+3d 47 ec b0 b4 fd 14 c1 10 e6 2d 6a e3 b5 d5 d0
+02 c1 bc e5 0c 2b 65 ef 88 a1 88 d8 3b ce 7e 61
 
 # H:
-df 1a 89 6f 9d 8b c8 16 d9 7c d7 a2 c4 3b ad 54 
-6f be 8c fe 
+df 1a 89 6f 9d 8b c8 16 d9 7c d7 a2 c4 3b ad 54
+6f be 8c fe
 
 # DB:
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
-00 00 00 00 00 00 01 e3 b5 d5 d0 02 c1 bc e5 0c 
-2b 65 ef 88 a1 88 d8 3b ce 7e 61 
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 01 e3 b5 d5 d0 02 c1 bc e5 0c
+2b 65 ef 88 a1 88 d8 3b ce 7e 61
 
 # dbMask:
-66 e4 67 2e 83 6a d1 21 ba 24 4b ed 65 76 b8 67 
-d9 a4 47 c2 8a 6e 66 a5 b8 7d ee 7f bc 7e 65 af 
-50 57 f8 6f ae 89 84 d9 ba 7f 96 9a d6 fe 02 a4 
-d7 5f 74 45 fe fd d8 5b 6d 3a 47 7c 28 d2 4b a1 
-e3 75 6f 79 2d d1 dc e8 ca 94 44 0e cb 52 79 ec 
-d3 18 3a 31 1f c8 97 39 a9 66 43 13 6e 8b 0f 46 
-5e 87 a4 53 5c d4 c5 9b 10 02 8d 
+66 e4 67 2e 83 6a d1 21 ba 24 4b ed 65 76 b8 67
+d9 a4 47 c2 8a 6e 66 a5 b8 7d ee 7f bc 7e 65 af
+50 57 f8 6f ae 89 84 d9 ba 7f 96 9a d6 fe 02 a4
+d7 5f 74 45 fe fd d8 5b 6d 3a 47 7c 28 d2 4b a1
+e3 75 6f 79 2d d1 dc e8 ca 94 44 0e cb 52 79 ec
+d3 18 3a 31 1f c8 97 39 a9 66 43 13 6e 8b 0f 46
+5e 87 a4 53 5c d4 c5 9b 10 02 8d
 
 # maskedDB:
-66 e4 67 2e 83 6a d1 21 ba 24 4b ed 65 76 b8 67 
-d9 a4 47 c2 8a 6e 66 a5 b8 7d ee 7f bc 7e 65 af 
-50 57 f8 6f ae 89 84 d9 ba 7f 96 9a d6 fe 02 a4 
-d7 5f 74 45 fe fd d8 5b 6d 3a 47 7c 28 d2 4b a1 
-e3 75 6f 79 2d d1 dc e8 ca 94 44 0e cb 52 79 ec 
-d3 18 3a 31 1f c8 96 da 1c b3 93 11 af 37 ea 4a 
-75 e2 4b db fd 5c 1d a0 de 7c ec 
+66 e4 67 2e 83 6a d1 21 ba 24 4b ed 65 76 b8 67
+d9 a4 47 c2 8a 6e 66 a5 b8 7d ee 7f bc 7e 65 af
+50 57 f8 6f ae 89 84 d9 ba 7f 96 9a d6 fe 02 a4
+d7 5f 74 45 fe fd d8 5b 6d 3a 47 7c 28 d2 4b a1
+e3 75 6f 79 2d d1 dc e8 ca 94 44 0e cb 52 79 ec
+d3 18 3a 31 1f c8 96 da 1c b3 93 11 af 37 ea 4a
+75 e2 4b db fd 5c 1d a0 de 7c ec
 
 # Encoded message EM:
-66 e4 67 2e 83 6a d1 21 ba 24 4b ed 65 76 b8 67 
-d9 a4 47 c2 8a 6e 66 a5 b8 7d ee 7f bc 7e 65 af 
-50 57 f8 6f ae 89 84 d9 ba 7f 96 9a d6 fe 02 a4 
-d7 5f 74 45 fe fd d8 5b 6d 3a 47 7c 28 d2 4b a1 
-e3 75 6f 79 2d d1 dc e8 ca 94 44 0e cb 52 79 ec 
-d3 18 3a 31 1f c8 96 da 1c b3 93 11 af 37 ea 4a 
-75 e2 4b db fd 5c 1d a0 de 7c ec df 1a 89 6f 9d 
-8b c8 16 d9 7c d7 a2 c4 3b ad 54 6f be 8c fe bc 
+66 e4 67 2e 83 6a d1 21 ba 24 4b ed 65 76 b8 67
+d9 a4 47 c2 8a 6e 66 a5 b8 7d ee 7f bc 7e 65 af
+50 57 f8 6f ae 89 84 d9 ba 7f 96 9a d6 fe 02 a4
+d7 5f 74 45 fe fd d8 5b 6d 3a 47 7c 28 d2 4b a1
+e3 75 6f 79 2d d1 dc e8 ca 94 44 0e cb 52 79 ec
+d3 18 3a 31 1f c8 96 da 1c b3 93 11 af 37 ea 4a
+75 e2 4b db fd 5c 1d a0 de 7c ec df 1a 89 6f 9d
+8b c8 16 d9 7c d7 a2 c4 3b ad 54 6f be 8c fe bc
 -}
 
 vectorsKey1 =
-    [
-    -- Example 1.1
+    [ -- Example 1.1
       VectorPSS
-        { message = "\xcd\xc8\x7d\xa2\x23\xd7\x86\xdf\x3b\x45\xe0\xbb\xbc\x72\x13\x26\xd1\xee\x2a\xf8\x06\xcc\x31\x54\x75\xcc\x6f\x0d\x9c\x66\xe1\xb6\x23\x71\xd4\x5c\xe2\x39\x2e\x1a\xc9\x28\x44\xc3\x10\x10\x2f\x15\x6a\x0d\x8d\x52\xc1\xf4\xc4\x0b\xa3\xaa\x65\x09\x57\x86\xcb\x76\x97\x57\xa6\x56\x3b\xa9\x58\xfe\xd0\xbc\xc9\x84\xe8\xb5\x17\xa3\xd5\xf5\x15\xb2\x3b\x8a\x41\xe7\x4a\xa8\x67\x69\x3f\x90\xdf\xb0\x61\xa6\xe8\x6d\xfa\xae\xe6\x44\x72\xc0\x0e\x5f\x20\x94\x57\x29\xcb\xeb\xe7\x7f\x06\xce\x78\xe0\x8f\x40\x98\xfb\xa4\x1f\x9d\x61\x93\xc0\x31\x7e\x8b\x60\xd4\xb6\x08\x4a\xcb\x42\xd2\x9e\x38\x08\xa3\xbc\x37\x2d\x85\xe3\x31\x17\x0f\xcb\xf7\xcc\x72\xd0\xb7\x1c\x29\x66\x48\xb3\xa4\xd1\x0f\x41\x62\x95\xd0\x80\x7a\xa6\x25\xca\xb2\x74\x4f\xd9\xea\x8f\xd2\x23\xc4\x25\x37\x02\x98\x28\xbd\x16\xbe\x02\x54\x6f\x13\x0f\xd2\xe3\x3b\x93\x6d\x26\x76\xe0\x8a\xed\x1b\x73\x31\x8b\x75\x0a\x01\x67\xd0"
-        , salt = "\xde\xe9\x59\xc7\xe0\x64\x11\x36\x14\x20\xff\x80\x18\x5e\xd5\x7f\x3e\x67\x76\xaf"
-        , signature = "\x90\x74\x30\x8f\xb5\x98\xe9\x70\x1b\x22\x94\x38\x8e\x52\xf9\x71\xfa\xac\x2b\x60\xa5\x14\x5a\xf1\x85\xdf\x52\x87\xb5\xed\x28\x87\xe5\x7c\xe7\xfd\x44\xdc\x86\x34\xe4\x07\xc8\xe0\xe4\x36\x0b\xc2\x26\xf3\xec\x22\x7f\x9d\x9e\x54\x63\x8e\x8d\x31\xf5\x05\x12\x15\xdf\x6e\xbb\x9c\x2f\x95\x79\xaa\x77\x59\x8a\x38\xf9\x14\xb5\xb9\xc1\xbd\x83\xc4\xe2\xf9\xf3\x82\xa0\xd0\xaa\x35\x42\xff\xee\x65\x98\x4a\x60\x1b\xc6\x9e\xb2\x8d\xeb\x27\xdc\xa1\x2c\x82\xc2\xd4\xc3\xf6\x6c\xd5\x00\xf1\xff\x2b\x99\x4d\x8a\x4e\x30\xcb\xb3\x3c"
+        { message =
+            "\xcd\xc8\x7d\xa2\x23\xd7\x86\xdf\x3b\x45\xe0\xbb\xbc\x72\x13\x26\xd1\xee\x2a\xf8\x06\xcc\x31\x54\x75\xcc\x6f\x0d\x9c\x66\xe1\xb6\x23\x71\xd4\x5c\xe2\x39\x2e\x1a\xc9\x28\x44\xc3\x10\x10\x2f\x15\x6a\x0d\x8d\x52\xc1\xf4\xc4\x0b\xa3\xaa\x65\x09\x57\x86\xcb\x76\x97\x57\xa6\x56\x3b\xa9\x58\xfe\xd0\xbc\xc9\x84\xe8\xb5\x17\xa3\xd5\xf5\x15\xb2\x3b\x8a\x41\xe7\x4a\xa8\x67\x69\x3f\x90\xdf\xb0\x61\xa6\xe8\x6d\xfa\xae\xe6\x44\x72\xc0\x0e\x5f\x20\x94\x57\x29\xcb\xeb\xe7\x7f\x06\xce\x78\xe0\x8f\x40\x98\xfb\xa4\x1f\x9d\x61\x93\xc0\x31\x7e\x8b\x60\xd4\xb6\x08\x4a\xcb\x42\xd2\x9e\x38\x08\xa3\xbc\x37\x2d\x85\xe3\x31\x17\x0f\xcb\xf7\xcc\x72\xd0\xb7\x1c\x29\x66\x48\xb3\xa4\xd1\x0f\x41\x62\x95\xd0\x80\x7a\xa6\x25\xca\xb2\x74\x4f\xd9\xea\x8f\xd2\x23\xc4\x25\x37\x02\x98\x28\xbd\x16\xbe\x02\x54\x6f\x13\x0f\xd2\xe3\x3b\x93\x6d\x26\x76\xe0\x8a\xed\x1b\x73\x31\x8b\x75\x0a\x01\x67\xd0"
+        , salt =
+            "\xde\xe9\x59\xc7\xe0\x64\x11\x36\x14\x20\xff\x80\x18\x5e\xd5\x7f\x3e\x67\x76\xaf"
+        , signature =
+            "\x90\x74\x30\x8f\xb5\x98\xe9\x70\x1b\x22\x94\x38\x8e\x52\xf9\x71\xfa\xac\x2b\x60\xa5\x14\x5a\xf1\x85\xdf\x52\x87\xb5\xed\x28\x87\xe5\x7c\xe7\xfd\x44\xdc\x86\x34\xe4\x07\xc8\xe0\xe4\x36\x0b\xc2\x26\xf3\xec\x22\x7f\x9d\x9e\x54\x63\x8e\x8d\x31\xf5\x05\x12\x15\xdf\x6e\xbb\x9c\x2f\x95\x79\xaa\x77\x59\x8a\x38\xf9\x14\xb5\xb9\xc1\xbd\x83\xc4\xe2\xf9\xf3\x82\xa0\xd0\xaa\x35\x42\xff\xee\x65\x98\x4a\x60\x1b\xc6\x9e\xb2\x8d\xeb\x27\xdc\xa1\x2c\x82\xc2\xd4\xc3\xf6\x6c\xd5\x00\xf1\xff\x2b\x99\x4d\x8a\x4e\x30\xcb\xb3\x3c"
         }
-    -- Example 1.2
-    , VectorPSS
-        { message = "\x85\x13\x84\xcd\xfe\x81\x9c\x22\xed\x6c\x4c\xcb\x30\xda\xeb\x5c\xf0\x59\xbc\x8e\x11\x66\xb7\xe3\x53\x0c\x4c\x23\x3e\x2b\x5f\x8f\x71\xa1\xcc\xa5\x82\xd4\x3e\xcc\x72\xb1\xbc\xa1\x6d\xfc\x70\x13\x22\x6b\x9e"
-        , salt = "\xef\x28\x69\xfa\x40\xc3\x46\xcb\x18\x3d\xab\x3d\x7b\xff\xc9\x8f\xd5\x6d\xf4\x2d"
-        , signature = "\x3e\xf7\xf4\x6e\x83\x1b\xf9\x2b\x32\x27\x41\x42\xa5\x85\xff\xce\xfb\xdc\xa7\xb3\x2a\xe9\x0d\x10\xfb\x0f\x0c\x72\x99\x84\xf0\x4e\xf2\x9a\x9d\xf0\x78\x07\x75\xce\x43\x73\x9b\x97\x83\x83\x90\xdb\x0a\x55\x05\xe6\x3d\xe9\x27\x02\x8d\x9d\x29\xb2\x19\xca\x2c\x45\x17\x83\x25\x58\xa5\x5d\x69\x4a\x6d\x25\xb9\xda\xb6\x60\x03\xc4\xcc\xcd\x90\x78\x02\x19\x3b\xe5\x17\x0d\x26\x14\x7d\x37\xb9\x35\x90\x24\x1b\xe5\x1c\x25\x05\x5f\x47\xef\x62\x75\x2c\xfb\xe2\x14\x18\xfa\xfe\x98\xc2\x2c\x4d\x4d\x47\x72\x4f\xdb\x56\x69\xe8\x43"
+    , -- Example 1.2
+      VectorPSS
+        { message =
+            "\x85\x13\x84\xcd\xfe\x81\x9c\x22\xed\x6c\x4c\xcb\x30\xda\xeb\x5c\xf0\x59\xbc\x8e\x11\x66\xb7\xe3\x53\x0c\x4c\x23\x3e\x2b\x5f\x8f\x71\xa1\xcc\xa5\x82\xd4\x3e\xcc\x72\xb1\xbc\xa1\x6d\xfc\x70\x13\x22\x6b\x9e"
+        , salt =
+            "\xef\x28\x69\xfa\x40\xc3\x46\xcb\x18\x3d\xab\x3d\x7b\xff\xc9\x8f\xd5\x6d\xf4\x2d"
+        , signature =
+            "\x3e\xf7\xf4\x6e\x83\x1b\xf9\x2b\x32\x27\x41\x42\xa5\x85\xff\xce\xfb\xdc\xa7\xb3\x2a\xe9\x0d\x10\xfb\x0f\x0c\x72\x99\x84\xf0\x4e\xf2\x9a\x9d\xf0\x78\x07\x75\xce\x43\x73\x9b\x97\x83\x83\x90\xdb\x0a\x55\x05\xe6\x3d\xe9\x27\x02\x8d\x9d\x29\xb2\x19\xca\x2c\x45\x17\x83\x25\x58\xa5\x5d\x69\x4a\x6d\x25\xb9\xda\xb6\x60\x03\xc4\xcc\xcd\x90\x78\x02\x19\x3b\xe5\x17\x0d\x26\x14\x7d\x37\xb9\x35\x90\x24\x1b\xe5\x1c\x25\x05\x5f\x47\xef\x62\x75\x2c\xfb\xe2\x14\x18\xfa\xfe\x98\xc2\x2c\x4d\x4d\x47\x72\x4f\xdb\x56\x69\xe8\x43"
         }
-    -- Example 1.3
-    , VectorPSS
-        { message = "\xa4\xb1\x59\x94\x17\x61\xc4\x0c\x6a\x82\xf2\xb8\x0d\x1b\x94\xf5\xaa\x26\x54\xfd\x17\xe1\x2d\x58\x88\x64\x67\x9b\x54\xcd\x04\xef\x8b\xd0\x30\x12\xbe\x8d\xc3\x7f\x4b\x83\xaf\x79\x63\xfa\xff\x0d\xfa\x22\x54\x77\x43\x7c\x48\x01\x7f\xf2\xbe\x81\x91\xcf\x39\x55\xfc\x07\x35\x6e\xab\x3f\x32\x2f\x7f\x62\x0e\x21\xd2\x54\xe5\xdb\x43\x24\x27\x9f\xe0\x67\xe0\x91\x0e\x2e\x81\xca\x2c\xab\x31\xc7\x45\xe6\x7a\x54\x05\x8e\xb5\x0d\x99\x3c\xdb\x9e\xd0\xb4\xd0\x29\xc0\x6d\x21\xa9\x4c\xa6\x61\xc3\xce\x27\xfa\xe1\xd6\xcb\x20\xf4\x56\x4d\x66\xce\x47\x67\x58\x3d\x0e\x5f\x06\x02\x15\xb5\x90\x17\xbe\x85\xea\x84\x89\x39\x12\x7b\xd8\xc9\xc4\xd4\x7b\x51\x05\x6c\x03\x1c\xf3\x36\xf1\x7c\x99\x80\xf3\xb8\xf5\xb9\xb6\x87\x8e\x8b\x79\x7a\xa4\x3b\x88\x26\x84\x33\x3e\x17\x89\x3f\xe9\xca\xa6\xaa\x29\x9f\x7e\xd1\xa1\x8e\xe2\xc5\x48\x64\xb7\xb2\xb9\x9b\x72\x61\x8f\xb0\x25\x74\xd1\x39\xef\x50\xf0\x19\xc9\xee\xf4\x16\x97\x13\x38\xe7\xd4\x70"
-        , salt = "\x71\x0b\x9c\x47\x47\xd8\x00\xd4\xde\x87\xf1\x2a\xfd\xce\x6d\xf1\x81\x07\xcc\x77"
-        , signature = "\x66\x60\x26\xfb\xa7\x1b\xd3\xe7\xcf\x13\x15\x7c\xc2\xc5\x1a\x8e\x4a\xa6\x84\xaf\x97\x78\xf9\x18\x49\xf3\x43\x35\xd1\x41\xc0\x01\x54\xc4\x19\x76\x21\xf9\x62\x4a\x67\x5b\x5a\xbc\x22\xee\x7d\x5b\xaa\xff\xaa\xe1\xc9\xba\xca\x2c\xc3\x73\xb3\xf3\x3e\x78\xe6\x14\x3c\x39\x5a\x91\xaa\x7f\xac\xa6\x64\xeb\x73\x3a\xfd\x14\xd8\x82\x72\x59\xd9\x9a\x75\x50\xfa\xca\x50\x1e\xf2\xb0\x4e\x33\xc2\x3a\xa5\x1f\x4b\x9e\x82\x82\xef\xdb\x72\x8c\xc0\xab\x09\x40\x5a\x91\x60\x7c\x63\x69\x96\x1b\xc8\x27\x0d\x2d\x4f\x39\xfc\xe6\x12\xb1"
+    , -- Example 1.3
+      VectorPSS
+        { message =
+            "\xa4\xb1\x59\x94\x17\x61\xc4\x0c\x6a\x82\xf2\xb8\x0d\x1b\x94\xf5\xaa\x26\x54\xfd\x17\xe1\x2d\x58\x88\x64\x67\x9b\x54\xcd\x04\xef\x8b\xd0\x30\x12\xbe\x8d\xc3\x7f\x4b\x83\xaf\x79\x63\xfa\xff\x0d\xfa\x22\x54\x77\x43\x7c\x48\x01\x7f\xf2\xbe\x81\x91\xcf\x39\x55\xfc\x07\x35\x6e\xab\x3f\x32\x2f\x7f\x62\x0e\x21\xd2\x54\xe5\xdb\x43\x24\x27\x9f\xe0\x67\xe0\x91\x0e\x2e\x81\xca\x2c\xab\x31\xc7\x45\xe6\x7a\x54\x05\x8e\xb5\x0d\x99\x3c\xdb\x9e\xd0\xb4\xd0\x29\xc0\x6d\x21\xa9\x4c\xa6\x61\xc3\xce\x27\xfa\xe1\xd6\xcb\x20\xf4\x56\x4d\x66\xce\x47\x67\x58\x3d\x0e\x5f\x06\x02\x15\xb5\x90\x17\xbe\x85\xea\x84\x89\x39\x12\x7b\xd8\xc9\xc4\xd4\x7b\x51\x05\x6c\x03\x1c\xf3\x36\xf1\x7c\x99\x80\xf3\xb8\xf5\xb9\xb6\x87\x8e\x8b\x79\x7a\xa4\x3b\x88\x26\x84\x33\x3e\x17\x89\x3f\xe9\xca\xa6\xaa\x29\x9f\x7e\xd1\xa1\x8e\xe2\xc5\x48\x64\xb7\xb2\xb9\x9b\x72\x61\x8f\xb0\x25\x74\xd1\x39\xef\x50\xf0\x19\xc9\xee\xf4\x16\x97\x13\x38\xe7\xd4\x70"
+        , salt =
+            "\x71\x0b\x9c\x47\x47\xd8\x00\xd4\xde\x87\xf1\x2a\xfd\xce\x6d\xf1\x81\x07\xcc\x77"
+        , signature =
+            "\x66\x60\x26\xfb\xa7\x1b\xd3\xe7\xcf\x13\x15\x7c\xc2\xc5\x1a\x8e\x4a\xa6\x84\xaf\x97\x78\xf9\x18\x49\xf3\x43\x35\xd1\x41\xc0\x01\x54\xc4\x19\x76\x21\xf9\x62\x4a\x67\x5b\x5a\xbc\x22\xee\x7d\x5b\xaa\xff\xaa\xe1\xc9\xba\xca\x2c\xc3\x73\xb3\xf3\x3e\x78\xe6\x14\x3c\x39\x5a\x91\xaa\x7f\xac\xa6\x64\xeb\x73\x3a\xfd\x14\xd8\x82\x72\x59\xd9\x9a\x75\x50\xfa\xca\x50\x1e\xf2\xb0\x4e\x33\xc2\x3a\xa5\x1f\x4b\x9e\x82\x82\xef\xdb\x72\x8c\xc0\xab\x09\x40\x5a\x91\x60\x7c\x63\x69\x96\x1b\xc8\x27\x0d\x2d\x4f\x39\xfc\xe6\x12\xb1"
         }
-    -- Example 1.4
-    , VectorPSS
+    , -- Example 1.4
+      VectorPSS
         { message = "\xbc\x65\x67\x47\xfa\x9e\xaf\xb3\xf0"
-        , salt = "\x05\x6f\x00\x98\x5d\xe1\x4d\x8e\xf5\xce\xa9\xe8\x2f\x8c\x27\xbe\xf7\x20\x33\x5e"
-        , signature = "\x46\x09\x79\x3b\x23\xe9\xd0\x93\x62\xdc\x21\xbb\x47\xda\x0b\x4f\x3a\x76\x22\x64\x9a\x47\xd4\x64\x01\x9b\x9a\xea\xfe\x53\x35\x9c\x17\x8c\x91\xcd\x58\xba\x6b\xcb\x78\xbe\x03\x46\xa7\xbc\x63\x7f\x4b\x87\x3d\x4b\xab\x38\xee\x66\x1f\x19\x96\x34\xc5\x47\xa1\xad\x84\x42\xe0\x3d\xa0\x15\xb1\x36\xe5\x43\xf7\xab\x07\xc0\xc1\x3e\x42\x25\xb8\xde\x8c\xce\x25\xd4\xf6\xeb\x84\x00\xf8\x1f\x7e\x18\x33\xb7\xee\x6e\x33\x4d\x37\x09\x64\xca\x79\xfd\xb8\x72\xb4\xd7\x52\x23\xb5\xee\xb0\x81\x01\x59\x1f\xb5\x32\xd1\x55\xa6\xde\x87"
+        , salt =
+            "\x05\x6f\x00\x98\x5d\xe1\x4d\x8e\xf5\xce\xa9\xe8\x2f\x8c\x27\xbe\xf7\x20\x33\x5e"
+        , signature =
+            "\x46\x09\x79\x3b\x23\xe9\xd0\x93\x62\xdc\x21\xbb\x47\xda\x0b\x4f\x3a\x76\x22\x64\x9a\x47\xd4\x64\x01\x9b\x9a\xea\xfe\x53\x35\x9c\x17\x8c\x91\xcd\x58\xba\x6b\xcb\x78\xbe\x03\x46\xa7\xbc\x63\x7f\x4b\x87\x3d\x4b\xab\x38\xee\x66\x1f\x19\x96\x34\xc5\x47\xa1\xad\x84\x42\xe0\x3d\xa0\x15\xb1\x36\xe5\x43\xf7\xab\x07\xc0\xc1\x3e\x42\x25\xb8\xde\x8c\xce\x25\xd4\xf6\xeb\x84\x00\xf8\x1f\x7e\x18\x33\xb7\xee\x6e\x33\x4d\x37\x09\x64\xca\x79\xfd\xb8\x72\xb4\xd7\x52\x23\xb5\xee\xb0\x81\x01\x59\x1f\xb5\x32\xd1\x55\xa6\xde\x87"
         }
-    -- Example 1.5
-    , VectorPSS
-        { message = "\xb4\x55\x81\x54\x7e\x54\x27\x77\x0c\x76\x8e\x8b\x82\xb7\x55\x64\xe0\xea\x4e\x9c\x32\x59\x4d\x6b\xff\x70\x65\x44\xde\x0a\x87\x76\xc7\xa8\x0b\x45\x76\x55\x0e\xee\x1b\x2a\xca\xbc\x7e\x8b\x7d\x3e\xf7\xbb\x5b\x03\xe4\x62\xc1\x10\x47\xea\xdd\x00\x62\x9a\xe5\x75\x48\x0a\xc1\x47\x0f\xe0\x46\xf1\x3a\x2b\xf5\xaf\x17\x92\x1d\xc4\xb0\xaa\x8b\x02\xbe\xe6\x33\x49\x11\x65\x1d\x7f\x85\x25\xd1\x0f\x32\xb5\x1d\x33\xbe\x52\x0d\x3d\xdf\x5a\x70\x99\x55\xa3\xdf\xe7\x82\x83\xb9\xe0\xab\x54\x04\x6d\x15\x0c\x17\x7f\x03\x7f\xdc\xcc\x5b\xe4\xea\x5f\x68\xb5\xe5\xa3\x8c\x9d\x7e\xdc\xcc\xc4\x97\x5f\x45\x5a\x69\x09\xb4"
-        , salt = "\x80\xe7\x0f\xf8\x6a\x08\xde\x3e\xc6\x09\x72\xb3\x9b\x4f\xbf\xdc\xea\x67\xae\x8e"
-        , signature = "\x1d\x2a\xad\x22\x1c\xa4\xd3\x1d\xdf\x13\x50\x92\x39\x01\x93\x98\xe3\xd1\x4b\x32\xdc\x34\xdc\x5a\xf4\xae\xae\xa3\xc0\x95\xaf\x73\x47\x9c\xf0\xa4\x5e\x56\x29\x63\x5a\x53\xa0\x18\x37\x76\x15\xb1\x6c\xb9\xb1\x3b\x3e\x09\xd6\x71\xeb\x71\xe3\x87\xb8\x54\x5c\x59\x60\xda\x5a\x64\x77\x6e\x76\x8e\x82\xb2\xc9\x35\x83\xbf\x10\x4c\x3f\xdb\x23\x51\x2b\x7b\x4e\x89\xf6\x33\xdd\x00\x63\xa5\x30\xdb\x45\x24\xb0\x1c\x3f\x38\x4c\x09\x31\x0e\x31\x5a\x79\xdc\xd3\xd6\x84\x02\x2a\x7f\x31\xc8\x65\xa6\x64\xe3\x16\x97\x8b\x75\x9f\xad"
+    , -- Example 1.5
+      VectorPSS
+        { message =
+            "\xb4\x55\x81\x54\x7e\x54\x27\x77\x0c\x76\x8e\x8b\x82\xb7\x55\x64\xe0\xea\x4e\x9c\x32\x59\x4d\x6b\xff\x70\x65\x44\xde\x0a\x87\x76\xc7\xa8\x0b\x45\x76\x55\x0e\xee\x1b\x2a\xca\xbc\x7e\x8b\x7d\x3e\xf7\xbb\x5b\x03\xe4\x62\xc1\x10\x47\xea\xdd\x00\x62\x9a\xe5\x75\x48\x0a\xc1\x47\x0f\xe0\x46\xf1\x3a\x2b\xf5\xaf\x17\x92\x1d\xc4\xb0\xaa\x8b\x02\xbe\xe6\x33\x49\x11\x65\x1d\x7f\x85\x25\xd1\x0f\x32\xb5\x1d\x33\xbe\x52\x0d\x3d\xdf\x5a\x70\x99\x55\xa3\xdf\xe7\x82\x83\xb9\xe0\xab\x54\x04\x6d\x15\x0c\x17\x7f\x03\x7f\xdc\xcc\x5b\xe4\xea\x5f\x68\xb5\xe5\xa3\x8c\x9d\x7e\xdc\xcc\xc4\x97\x5f\x45\x5a\x69\x09\xb4"
+        , salt =
+            "\x80\xe7\x0f\xf8\x6a\x08\xde\x3e\xc6\x09\x72\xb3\x9b\x4f\xbf\xdc\xea\x67\xae\x8e"
+        , signature =
+            "\x1d\x2a\xad\x22\x1c\xa4\xd3\x1d\xdf\x13\x50\x92\x39\x01\x93\x98\xe3\xd1\x4b\x32\xdc\x34\xdc\x5a\xf4\xae\xae\xa3\xc0\x95\xaf\x73\x47\x9c\xf0\xa4\x5e\x56\x29\x63\x5a\x53\xa0\x18\x37\x76\x15\xb1\x6c\xb9\xb1\x3b\x3e\x09\xd6\x71\xeb\x71\xe3\x87\xb8\x54\x5c\x59\x60\xda\x5a\x64\x77\x6e\x76\x8e\x82\xb2\xc9\x35\x83\xbf\x10\x4c\x3f\xdb\x23\x51\x2b\x7b\x4e\x89\xf6\x33\xdd\x00\x63\xa5\x30\xdb\x45\x24\xb0\x1c\x3f\x38\x4c\x09\x31\x0e\x31\x5a\x79\xdc\xd3\xd6\x84\x02\x2a\x7f\x31\xc8\x65\xa6\x64\xe3\x16\x97\x8b\x75\x9f\xad"
         }
-    -- Example 1.6
-    , VectorPSS
-        { message = "\x10\xaa\xe9\xa0\xab\x0b\x59\x5d\x08\x41\x20\x7b\x70\x0d\x48\xd7\x5f\xae\xdd\xe3\xb7\x75\xcd\x6b\x4c\xc8\x8a\xe0\x6e\x46\x94\xec\x74\xba\x18\xf8\x52\x0d\x4f\x5e\xa6\x9c\xbb\xe7\xcc\x2b\xeb\xa4\x3e\xfd\xc1\x02\x15\xac\x4e\xb3\x2d\xc3\x02\xa1\xf5\x3d\xc6\xc4\x35\x22\x67\xe7\x93\x6c\xfe\xbf\x7c\x8d\x67\x03\x57\x84\xa3\x90\x9f\xa8\x59\xc7\xb7\xb5\x9b\x8e\x39\xc5\xc2\x34\x9f\x18\x86\xb7\x05\xa3\x02\x67\xd4\x02\xf7\x48\x6a\xb4\xf5\x8c\xad\x5d\x69\xad\xb1\x7a\xb8\xcd\x0c\xe1\xca\xf5\x02\x5a\xf4\xae\x24\xb1\xfb\x87\x94\xc6\x07\x0c\xc0\x9a\x51\xe2\xf9\x91\x13\x11\xe3\x87\x7d\x00\x44\xc7\x1c\x57\xa9\x93\x39\x50\x08\x80\x6b\x72\x3a\xc3\x83\x73\xd3\x95\x48\x18\x18\x52\x8c\x1e\x70\x53\x73\x92\x82\x05\x35\x29\x51\x0e\x93\x5c\xd0\xfa\x77\xb8\xfa\x53\xcc\x2d\x47\x4b\xd4\xfb\x3c\xc5\xc6\x72\xd6\xff\xdc\x90\xa0\x0f\x98\x48\x71\x2c\x4b\xcf\xe4\x6c\x60\x57\x36\x59\xb1\x1e\x64\x57\xe8\x61\xf0\xf6\x04\xb6\x13\x8d\x14\x4f\x8c\xe4\xe2\xda\x73"
-        , salt = "\xa8\xab\x69\xdd\x80\x1f\x00\x74\xc2\xa1\xfc\x60\x64\x98\x36\xc6\x16\xd9\x96\x81"
-        , signature = "\x2a\x34\xf6\x12\x5e\x1f\x6b\x0b\xf9\x71\xe8\x4f\xbd\x41\xc6\x32\xbe\x8f\x2c\x2a\xce\x7d\xe8\xb6\x92\x6e\x31\xff\x93\xe9\xaf\x98\x7f\xbc\x06\xe5\x1e\x9b\xe1\x4f\x51\x98\xf9\x1f\x3f\x95\x3b\xd6\x7d\xa6\x0a\x9d\xf5\x97\x64\xc3\xdc\x0f\xe0\x8e\x1c\xbe\xf0\xb7\x5f\x86\x8d\x10\xad\x3f\xba\x74\x9f\xef\x59\xfb\x6d\xac\x46\xa0\xd6\xe5\x04\x36\x93\x31\x58\x6f\x58\xe4\x62\x8f\x39\xaa\x27\x89\x82\x54\x3b\xc0\xee\xb5\x37\xdc\x61\x95\x80\x19\xb3\x94\xfb\x27\x3f\x21\x58\x58\xa0\xa0\x1a\xc4\xd6\x50\xb9\x55\xc6\x7f\x4c\x58"
+    , -- Example 1.6
+      VectorPSS
+        { message =
+            "\x10\xaa\xe9\xa0\xab\x0b\x59\x5d\x08\x41\x20\x7b\x70\x0d\x48\xd7\x5f\xae\xdd\xe3\xb7\x75\xcd\x6b\x4c\xc8\x8a\xe0\x6e\x46\x94\xec\x74\xba\x18\xf8\x52\x0d\x4f\x5e\xa6\x9c\xbb\xe7\xcc\x2b\xeb\xa4\x3e\xfd\xc1\x02\x15\xac\x4e\xb3\x2d\xc3\x02\xa1\xf5\x3d\xc6\xc4\x35\x22\x67\xe7\x93\x6c\xfe\xbf\x7c\x8d\x67\x03\x57\x84\xa3\x90\x9f\xa8\x59\xc7\xb7\xb5\x9b\x8e\x39\xc5\xc2\x34\x9f\x18\x86\xb7\x05\xa3\x02\x67\xd4\x02\xf7\x48\x6a\xb4\xf5\x8c\xad\x5d\x69\xad\xb1\x7a\xb8\xcd\x0c\xe1\xca\xf5\x02\x5a\xf4\xae\x24\xb1\xfb\x87\x94\xc6\x07\x0c\xc0\x9a\x51\xe2\xf9\x91\x13\x11\xe3\x87\x7d\x00\x44\xc7\x1c\x57\xa9\x93\x39\x50\x08\x80\x6b\x72\x3a\xc3\x83\x73\xd3\x95\x48\x18\x18\x52\x8c\x1e\x70\x53\x73\x92\x82\x05\x35\x29\x51\x0e\x93\x5c\xd0\xfa\x77\xb8\xfa\x53\xcc\x2d\x47\x4b\xd4\xfb\x3c\xc5\xc6\x72\xd6\xff\xdc\x90\xa0\x0f\x98\x48\x71\x2c\x4b\xcf\xe4\x6c\x60\x57\x36\x59\xb1\x1e\x64\x57\xe8\x61\xf0\xf6\x04\xb6\x13\x8d\x14\x4f\x8c\xe4\xe2\xda\x73"
+        , salt =
+            "\xa8\xab\x69\xdd\x80\x1f\x00\x74\xc2\xa1\xfc\x60\x64\x98\x36\xc6\x16\xd9\x96\x81"
+        , signature =
+            "\x2a\x34\xf6\x12\x5e\x1f\x6b\x0b\xf9\x71\xe8\x4f\xbd\x41\xc6\x32\xbe\x8f\x2c\x2a\xce\x7d\xe8\xb6\x92\x6e\x31\xff\x93\xe9\xaf\x98\x7f\xbc\x06\xe5\x1e\x9b\xe1\x4f\x51\x98\xf9\x1f\x3f\x95\x3b\xd6\x7d\xa6\x0a\x9d\xf5\x97\x64\xc3\xdc\x0f\xe0\x8e\x1c\xbe\xf0\xb7\x5f\x86\x8d\x10\xad\x3f\xba\x74\x9f\xef\x59\xfb\x6d\xac\x46\xa0\xd6\xe5\x04\x36\x93\x31\x58\x6f\x58\xe4\x62\x8f\x39\xaa\x27\x89\x82\x54\x3b\xc0\xee\xb5\x37\xdc\x61\x95\x80\x19\xb3\x94\xfb\x27\x3f\x21\x58\x58\xa0\xa0\x1a\xc4\xd6\x50\xb9\x55\xc6\x7f\x4c\x58"
         }
     ]
 
@@ -156,57 +196,83 @@
 -- Example 2: A 1025-bit RSA Key Pair
 -- ==================================
 
-rsaKey2 = PrivateKey
-    { private_pub = PublicKey
-        { public_n = 0x01d40c1bcf97a68ae7cdbd8a7bf3e34fa19dcca4ef75a47454375f94514d88fed006fb829f8419ff87d6315da68a1ff3a0938e9abb3464011c303ad99199cf0c7c7a8b477dce829e8844f625b115e5e9c4a59cf8f8113b6834336a2fd2689b472cbb5e5cabe674350c59b6c17e176874fb42f8fc3d176a017edc61fd326c4b33c9
-        , public_e = 0x010001
-        , public_size = 129
+rsaKey2 =
+    PrivateKey
+        { private_pub =
+            PublicKey
+                { public_n =
+                    0x01d40c1bcf97a68ae7cdbd8a7bf3e34fa19dcca4ef75a47454375f94514d88fed006fb829f8419ff87d6315da68a1ff3a0938e9abb3464011c303ad99199cf0c7c7a8b477dce829e8844f625b115e5e9c4a59cf8f8113b6834336a2fd2689b472cbb5e5cabe674350c59b6c17e176874fb42f8fc3d176a017edc61fd326c4b33c9
+                , public_e = 0x010001
+                , public_size = 129
+                }
+        , private_d =
+            0x027d147e4673057377fd1ea201565772176a7dc38358d376045685a2e787c23c15576bc16b9f444402d6bfc5d98a3e88ea13ef67c353eca0c0ddba9255bd7b8bb50a644afdfd1dd51695b252d22e7318d1b6687a1c10ff75545f3db0fe602d5f2b7f294e3601eab7b9d1cecd767f64692e3e536ca2846cb0c2dd486a39fa75b1
+        , private_p =
+            0x016601e926a0f8c9e26ecab769ea65a5e7c52cc9e080ef519457c644da6891c5a104d3ea7955929a22e7c68a7af9fcad777c3ccc2b9e3d3650bce404399b7e59d1
+        , private_q =
+            0x014eafa1d4d0184da7e31f877d1281ddda625664869e8379e67ad3b75eae74a580e9827abd6eb7a002cb5411f5266797768fb8e95ae40e3e8a01f35ff89e56c079
+        , private_dP =
+            0xe247cce504939b8f0a36090de200938755e2444b29539a7da7a902f6056835c0db7b52559497cfe2c61a8086d0213c472c78851800b171f6401de2e9c2756f31
+        , private_dQ =
+            0xb12fba757855e586e46f64c38a70c68b3f548d93d787b399999d4c8f0bbd2581c21e19ed0018a6d5d3df86424b3abcad40199d31495b61309f27c1bf55d487c1
+        , private_qinv =
+            0x564b1e1fa003bda91e89090425aac05b91da9ee25061e7628d5f51304a84992fdc33762bd378a59f030a334d532bd0dae8f298ea9ed844636ad5fb8cbdc03cad
         }
-    , private_d = 0x027d147e4673057377fd1ea201565772176a7dc38358d376045685a2e787c23c15576bc16b9f444402d6bfc5d98a3e88ea13ef67c353eca0c0ddba9255bd7b8bb50a644afdfd1dd51695b252d22e7318d1b6687a1c10ff75545f3db0fe602d5f2b7f294e3601eab7b9d1cecd767f64692e3e536ca2846cb0c2dd486a39fa75b1
-    , private_p = 0x016601e926a0f8c9e26ecab769ea65a5e7c52cc9e080ef519457c644da6891c5a104d3ea7955929a22e7c68a7af9fcad777c3ccc2b9e3d3650bce404399b7e59d1
-    , private_q = 0x014eafa1d4d0184da7e31f877d1281ddda625664869e8379e67ad3b75eae74a580e9827abd6eb7a002cb5411f5266797768fb8e95ae40e3e8a01f35ff89e56c079
-    , private_dP = 0xe247cce504939b8f0a36090de200938755e2444b29539a7da7a902f6056835c0db7b52559497cfe2c61a8086d0213c472c78851800b171f6401de2e9c2756f31
-    , private_dQ = 0xb12fba757855e586e46f64c38a70c68b3f548d93d787b399999d4c8f0bbd2581c21e19ed0018a6d5d3df86424b3abcad40199d31495b61309f27c1bf55d487c1
-    , private_qinv = 0x564b1e1fa003bda91e89090425aac05b91da9ee25061e7628d5f51304a84992fdc33762bd378a59f030a334d532bd0dae8f298ea9ed844636ad5fb8cbdc03cad
-    }
 
 vectorsKey2 =
-    [
-    -- Example 2.1
+    [ -- Example 2.1
       VectorPSS
-        { message = "\xda\xba\x03\x20\x66\x26\x3f\xae\xdb\x65\x98\x48\x11\x52\x78\xa5\x2c\x44\xfa\xa3\xa7\x6f\x37\x51\x5e\xd3\x36\x32\x10\x72\xc4\x0a\x9d\x9b\x53\xbc\x05\x01\x40\x78\xad\xf5\x20\x87\x51\x46\xaa\xe7\x0f\xf0\x60\x22\x6d\xcb\x7b\x1f\x1f\xc2\x7e\x93\x60"
-        , salt = "\x57\xbf\x16\x0b\xcb\x02\xbb\x1d\xc7\x28\x0c\xf0\x45\x85\x30\xb7\xd2\x83\x2f\xf7"
-        , signature = "\x01\x4c\x5b\xa5\x33\x83\x28\xcc\xc6\xe7\xa9\x0b\xf1\xc0\xab\x3f\xd6\x06\xff\x47\x96\xd3\xc1\x2e\x4b\x63\x9e\xd9\x13\x6a\x5f\xec\x6c\x16\xd8\x88\x4b\xdd\x99\xcf\xdc\x52\x14\x56\xb0\x74\x2b\x73\x68\x68\xcf\x90\xde\x09\x9a\xdb\x8d\x5f\xfd\x1d\xef\xf3\x9b\xa4\x00\x7a\xb7\x46\xce\xfd\xb2\x2d\x7d\xf0\xe2\x25\xf5\x46\x27\xdc\x65\x46\x61\x31\x72\x1b\x90\xaf\x44\x53\x63\xa8\x35\x8b\x9f\x60\x76\x42\xf7\x8f\xab\x0a\xb0\xf4\x3b\x71\x68\xd6\x4b\xae\x70\xd8\x82\x78\x48\xd8\xef\x1e\x42\x1c\x57\x54\xdd\xf4\x2c\x25\x89\xb5\xb3"
+        { message =
+            "\xda\xba\x03\x20\x66\x26\x3f\xae\xdb\x65\x98\x48\x11\x52\x78\xa5\x2c\x44\xfa\xa3\xa7\x6f\x37\x51\x5e\xd3\x36\x32\x10\x72\xc4\x0a\x9d\x9b\x53\xbc\x05\x01\x40\x78\xad\xf5\x20\x87\x51\x46\xaa\xe7\x0f\xf0\x60\x22\x6d\xcb\x7b\x1f\x1f\xc2\x7e\x93\x60"
+        , salt =
+            "\x57\xbf\x16\x0b\xcb\x02\xbb\x1d\xc7\x28\x0c\xf0\x45\x85\x30\xb7\xd2\x83\x2f\xf7"
+        , signature =
+            "\x01\x4c\x5b\xa5\x33\x83\x28\xcc\xc6\xe7\xa9\x0b\xf1\xc0\xab\x3f\xd6\x06\xff\x47\x96\xd3\xc1\x2e\x4b\x63\x9e\xd9\x13\x6a\x5f\xec\x6c\x16\xd8\x88\x4b\xdd\x99\xcf\xdc\x52\x14\x56\xb0\x74\x2b\x73\x68\x68\xcf\x90\xde\x09\x9a\xdb\x8d\x5f\xfd\x1d\xef\xf3\x9b\xa4\x00\x7a\xb7\x46\xce\xfd\xb2\x2d\x7d\xf0\xe2\x25\xf5\x46\x27\xdc\x65\x46\x61\x31\x72\x1b\x90\xaf\x44\x53\x63\xa8\x35\x8b\x9f\x60\x76\x42\xf7\x8f\xab\x0a\xb0\xf4\x3b\x71\x68\xd6\x4b\xae\x70\xd8\x82\x78\x48\xd8\xef\x1e\x42\x1c\x57\x54\xdd\xf4\x2c\x25\x89\xb5\xb3"
         }
-    -- Example 2.2
-    , VectorPSS
-        { message = "\xe4\xf8\x60\x1a\x8a\x6d\xa1\xbe\x34\x44\x7c\x09\x59\xc0\x58\x57\x0c\x36\x68\xcf\xd5\x1d\xd5\xf9\xcc\xd6\xad\x44\x11\xfe\x82\x13\x48\x6d\x78\xa6\xc4\x9f\x93\xef\xc2\xca\x22\x88\xce\xbc\x2b\x9b\x60\xbd\x04\xb1\xe2\x20\xd8\x6e\x3d\x48\x48\xd7\x09\xd0\x32\xd1\xe8\xc6\xa0\x70\xc6\xaf\x9a\x49\x9f\xcf\x95\x35\x4b\x14\xba\x61\x27\xc7\x39\xde\x1b\xb0\xfd\x16\x43\x1e\x46\x93\x8a\xec\x0c\xf8\xad\x9e\xb7\x2e\x83\x2a\x70\x35\xde\x9b\x78\x07\xbd\xc0\xed\x8b\x68\xeb\x0f\x5a\xc2\x21\x6b\xe4\x0c\xe9\x20\xc0\xdb\x0e\xdd\xd3\x86\x0e\xd7\x88\xef\xac\xca\xca\x50\x2d\x8f\x2b\xd6\xd1\xa7\xc1\xf4\x1f\xf4\x6f\x16\x81\xc8\xf1\xf8\x18\xe9\xc4\xf6\xd9\x1a\x0c\x78\x03\xcc\xc6\x3d\x76\xa6\x54\x4d\x84\x3e\x08\x4e\x36\x3b\x8a\xcc\x55\xaa\x53\x17\x33\xed\xb5\xde\xe5\xb5\x19\x6e\x9f\x03\xe8\xb7\x31\xb3\x77\x64\x28\xd9\xe4\x57\xfe\x3f\xbc\xb3\xdb\x72\x74\x44\x2d\x78\x58\x90\xe9\xcb\x08\x54\xb6\x44\x4d\xac\xe7\x91\xd7\x27\x3d\xe1\x88\x97\x19\x33\x8a\x77\xfe"
-        , salt = "\x7f\x6d\xd3\x59\xe6\x04\xe6\x08\x70\xe8\x98\xe4\x7b\x19\xbf\x2e\x5a\x7b\x2a\x90"
-        , signature = "\x01\x09\x91\x65\x6c\xca\x18\x2b\x7f\x29\xd2\xdb\xc0\x07\xe7\xae\x0f\xec\x15\x8e\xb6\x75\x9c\xb9\xc4\x5c\x5f\xf8\x7c\x76\x35\xdd\x46\xd1\x50\x88\x2f\x4d\xe1\xe9\xae\x65\xe7\xf7\xd9\x01\x8f\x68\x36\x95\x4a\x47\xc0\xa8\x1a\x8a\x6b\x6f\x83\xf2\x94\x4d\x60\x81\xb1\xaa\x7c\x75\x9b\x25\x4b\x2c\x34\xb6\x91\xda\x67\xcc\x02\x26\xe2\x0b\x2f\x18\xb4\x22\x12\x76\x1d\xcd\x4b\x90\x8a\x62\xb3\x71\xb5\x91\x8c\x57\x42\xaf\x4b\x53\x7e\x29\x69\x17\x67\x4f\xb9\x14\x19\x47\x61\x62\x1c\xc1\x9a\x41\xf6\xfb\x95\x3f\xbc\xbb\x64\x9d\xea"
+    , -- Example 2.2
+      VectorPSS
+        { message =
+            "\xe4\xf8\x60\x1a\x8a\x6d\xa1\xbe\x34\x44\x7c\x09\x59\xc0\x58\x57\x0c\x36\x68\xcf\xd5\x1d\xd5\xf9\xcc\xd6\xad\x44\x11\xfe\x82\x13\x48\x6d\x78\xa6\xc4\x9f\x93\xef\xc2\xca\x22\x88\xce\xbc\x2b\x9b\x60\xbd\x04\xb1\xe2\x20\xd8\x6e\x3d\x48\x48\xd7\x09\xd0\x32\xd1\xe8\xc6\xa0\x70\xc6\xaf\x9a\x49\x9f\xcf\x95\x35\x4b\x14\xba\x61\x27\xc7\x39\xde\x1b\xb0\xfd\x16\x43\x1e\x46\x93\x8a\xec\x0c\xf8\xad\x9e\xb7\x2e\x83\x2a\x70\x35\xde\x9b\x78\x07\xbd\xc0\xed\x8b\x68\xeb\x0f\x5a\xc2\x21\x6b\xe4\x0c\xe9\x20\xc0\xdb\x0e\xdd\xd3\x86\x0e\xd7\x88\xef\xac\xca\xca\x50\x2d\x8f\x2b\xd6\xd1\xa7\xc1\xf4\x1f\xf4\x6f\x16\x81\xc8\xf1\xf8\x18\xe9\xc4\xf6\xd9\x1a\x0c\x78\x03\xcc\xc6\x3d\x76\xa6\x54\x4d\x84\x3e\x08\x4e\x36\x3b\x8a\xcc\x55\xaa\x53\x17\x33\xed\xb5\xde\xe5\xb5\x19\x6e\x9f\x03\xe8\xb7\x31\xb3\x77\x64\x28\xd9\xe4\x57\xfe\x3f\xbc\xb3\xdb\x72\x74\x44\x2d\x78\x58\x90\xe9\xcb\x08\x54\xb6\x44\x4d\xac\xe7\x91\xd7\x27\x3d\xe1\x88\x97\x19\x33\x8a\x77\xfe"
+        , salt =
+            "\x7f\x6d\xd3\x59\xe6\x04\xe6\x08\x70\xe8\x98\xe4\x7b\x19\xbf\x2e\x5a\x7b\x2a\x90"
+        , signature =
+            "\x01\x09\x91\x65\x6c\xca\x18\x2b\x7f\x29\xd2\xdb\xc0\x07\xe7\xae\x0f\xec\x15\x8e\xb6\x75\x9c\xb9\xc4\x5c\x5f\xf8\x7c\x76\x35\xdd\x46\xd1\x50\x88\x2f\x4d\xe1\xe9\xae\x65\xe7\xf7\xd9\x01\x8f\x68\x36\x95\x4a\x47\xc0\xa8\x1a\x8a\x6b\x6f\x83\xf2\x94\x4d\x60\x81\xb1\xaa\x7c\x75\x9b\x25\x4b\x2c\x34\xb6\x91\xda\x67\xcc\x02\x26\xe2\x0b\x2f\x18\xb4\x22\x12\x76\x1d\xcd\x4b\x90\x8a\x62\xb3\x71\xb5\x91\x8c\x57\x42\xaf\x4b\x53\x7e\x29\x69\x17\x67\x4f\xb9\x14\x19\x47\x61\x62\x1c\xc1\x9a\x41\xf6\xfb\x95\x3f\xbc\xbb\x64\x9d\xea"
         }
-    -- Example 2.3
-    , VectorPSS
-        { message = "\x52\xa1\xd9\x6c\x8a\xc3\x9e\x41\xe4\x55\x80\x98\x01\xb9\x27\xa5\xb4\x45\xc1\x0d\x90\x2a\x0d\xcd\x38\x50\xd2\x2a\x66\xd2\xbb\x07\x03\xe6\x7d\x58\x67\x11\x45\x95\xaa\xbf\x5a\x7a\xeb\x5a\x8f\x87\x03\x4b\xbb\x30\xe1\x3c\xfd\x48\x17\xa9\xbe\x76\x23\x00\x23\x60\x6d\x02\x86\xa3\xfa\xf8\xa4\xd2\x2b\x72\x8e\xc5\x18\x07\x9f\x9e\x64\x52\x6e\x3a\x0c\xc7\x94\x1a\xa3\x38\xc4\x37\x99\x7c\x68\x0c\xca\xc6\x7c\x66\xbf\xa1"
-        , salt = "\xfc\xa8\x62\x06\x8b\xce\x22\x46\x72\x4b\x70\x8a\x05\x19\xda\x17\xe6\x48\x68\x8c"
-        , signature = "\x00\x7f\x00\x30\x01\x8f\x53\xcd\xc7\x1f\x23\xd0\x36\x59\xfd\xe5\x4d\x42\x41\xf7\x58\xa7\x50\xb4\x2f\x18\x5f\x87\x57\x85\x20\xc3\x07\x42\xaf\xd8\x43\x59\xb6\xe6\xe8\xd3\xed\x95\x9d\xc6\xfe\x48\x6b\xed\xc8\xe2\xcf\x00\x1f\x63\xa7\xab\xe1\x62\x56\xa1\xb8\x4d\xf0\xd2\x49\xfc\x05\xd3\x19\x4c\xe5\xf0\x91\x27\x42\xdb\xbf\x80\xdd\x17\x4f\x6c\x51\xf6\xba\xd7\xf1\x6c\xf3\x36\x4e\xba\x09\x5a\x06\x26\x7d\xc3\x79\x38\x03\xac\x75\x26\xae\xbe\x0a\x47\x5d\x38\xb8\xc2\x24\x7a\xb5\x1c\x48\x98\xdf\x70\x47\xdc\x6a\xdf\x52\xc6\xc4"
+    , -- Example 2.3
+      VectorPSS
+        { message =
+            "\x52\xa1\xd9\x6c\x8a\xc3\x9e\x41\xe4\x55\x80\x98\x01\xb9\x27\xa5\xb4\x45\xc1\x0d\x90\x2a\x0d\xcd\x38\x50\xd2\x2a\x66\xd2\xbb\x07\x03\xe6\x7d\x58\x67\x11\x45\x95\xaa\xbf\x5a\x7a\xeb\x5a\x8f\x87\x03\x4b\xbb\x30\xe1\x3c\xfd\x48\x17\xa9\xbe\x76\x23\x00\x23\x60\x6d\x02\x86\xa3\xfa\xf8\xa4\xd2\x2b\x72\x8e\xc5\x18\x07\x9f\x9e\x64\x52\x6e\x3a\x0c\xc7\x94\x1a\xa3\x38\xc4\x37\x99\x7c\x68\x0c\xca\xc6\x7c\x66\xbf\xa1"
+        , salt =
+            "\xfc\xa8\x62\x06\x8b\xce\x22\x46\x72\x4b\x70\x8a\x05\x19\xda\x17\xe6\x48\x68\x8c"
+        , signature =
+            "\x00\x7f\x00\x30\x01\x8f\x53\xcd\xc7\x1f\x23\xd0\x36\x59\xfd\xe5\x4d\x42\x41\xf7\x58\xa7\x50\xb4\x2f\x18\x5f\x87\x57\x85\x20\xc3\x07\x42\xaf\xd8\x43\x59\xb6\xe6\xe8\xd3\xed\x95\x9d\xc6\xfe\x48\x6b\xed\xc8\xe2\xcf\x00\x1f\x63\xa7\xab\xe1\x62\x56\xa1\xb8\x4d\xf0\xd2\x49\xfc\x05\xd3\x19\x4c\xe5\xf0\x91\x27\x42\xdb\xbf\x80\xdd\x17\x4f\x6c\x51\xf6\xba\xd7\xf1\x6c\xf3\x36\x4e\xba\x09\x5a\x06\x26\x7d\xc3\x79\x38\x03\xac\x75\x26\xae\xbe\x0a\x47\x5d\x38\xb8\xc2\x24\x7a\xb5\x1c\x48\x98\xdf\x70\x47\xdc\x6a\xdf\x52\xc6\xc4"
         }
-    -- Example 2.4
-    , VectorPSS
-        { message = "\xa7\x18\x2c\x83\xac\x18\xbe\x65\x70\xa1\x06\xaa\x9d\x5c\x4e\x3d\xbb\xd4\xaf\xae\xb0\xc6\x0c\x4a\x23\xe1\x96\x9d\x79\xff"
-        , salt = "\x80\x70\xef\x2d\xe9\x45\xc0\x23\x87\x68\x4b\xa0\xd3\x30\x96\x73\x22\x35\xd4\x40"
-        , signature = "\x00\x9c\xd2\xf4\xed\xbe\x23\xe1\x23\x46\xae\x8c\x76\xdd\x9a\xd3\x23\x0a\x62\x07\x61\x41\xf1\x6c\x15\x2b\xa1\x85\x13\xa4\x8e\xf6\xf0\x10\xe0\xe3\x7f\xd3\xdf\x10\xa1\xec\x62\x9a\x0c\xb5\xa3\xb5\xd2\x89\x30\x07\x29\x8c\x30\x93\x6a\x95\x90\x3b\x6b\xa8\x55\x55\xd9\xec\x36\x73\xa0\x61\x08\xfd\x62\xa2\xfd\xa5\x6d\x1c\xe2\xe8\x5c\x4d\xb6\xb2\x4a\x81\xca\x3b\x49\x6c\x36\xd4\xfd\x06\xeb\x7c\x91\x66\xd8\xe9\x48\x77\xc4\x2b\xea\x62\x2b\x3b\xfe\x92\x51\xfd\xc2\x1d\x8d\x53\x71\xba\xda\xd7\x8a\x48\x82\x14\x79\x63\x35\xb4\x0b"
+    , -- Example 2.4
+      VectorPSS
+        { message =
+            "\xa7\x18\x2c\x83\xac\x18\xbe\x65\x70\xa1\x06\xaa\x9d\x5c\x4e\x3d\xbb\xd4\xaf\xae\xb0\xc6\x0c\x4a\x23\xe1\x96\x9d\x79\xff"
+        , salt =
+            "\x80\x70\xef\x2d\xe9\x45\xc0\x23\x87\x68\x4b\xa0\xd3\x30\x96\x73\x22\x35\xd4\x40"
+        , signature =
+            "\x00\x9c\xd2\xf4\xed\xbe\x23\xe1\x23\x46\xae\x8c\x76\xdd\x9a\xd3\x23\x0a\x62\x07\x61\x41\xf1\x6c\x15\x2b\xa1\x85\x13\xa4\x8e\xf6\xf0\x10\xe0\xe3\x7f\xd3\xdf\x10\xa1\xec\x62\x9a\x0c\xb5\xa3\xb5\xd2\x89\x30\x07\x29\x8c\x30\x93\x6a\x95\x90\x3b\x6b\xa8\x55\x55\xd9\xec\x36\x73\xa0\x61\x08\xfd\x62\xa2\xfd\xa5\x6d\x1c\xe2\xe8\x5c\x4d\xb6\xb2\x4a\x81\xca\x3b\x49\x6c\x36\xd4\xfd\x06\xeb\x7c\x91\x66\xd8\xe9\x48\x77\xc4\x2b\xea\x62\x2b\x3b\xfe\x92\x51\xfd\xc2\x1d\x8d\x53\x71\xba\xda\xd7\x8a\x48\x82\x14\x79\x63\x35\xb4\x0b"
         }
-    -- Example 2.5
-    , VectorPSS
-        { message = "\x86\xa8\x3d\x4a\x72\xee\x93\x2a\x4f\x56\x30\xaf\x65\x79\xa3\x86\xb7\x8f\xe8\x89\x99\xe0\xab\xd2\xd4\x90\x34\xa4\xbf\xc8\x54\xdd\x94\xf1\x09\x4e\x2e\x8c\xd7\xa1\x79\xd1\x95\x88\xe4\xae\xfc\x1b\x1b\xd2\x5e\x95\xe3\xdd\x46\x1f"
-        , salt = "\x17\x63\x9a\x4e\x88\xd7\x22\xc4\xfc\xa2\x4d\x07\x9a\x8b\x29\xc3\x24\x33\xb0\xc9"
-        , signature = "\x00\xec\x43\x08\x24\x93\x1e\xbd\x3b\xaa\x43\x03\x4d\xae\x98\xba\x64\x6b\x8c\x36\x01\x3d\x16\x71\xc3\xcf\x1c\xf8\x26\x0c\x37\x4b\x19\xf8\xe1\xcc\x8d\x96\x50\x12\x40\x5e\x7e\x9b\xf7\x37\x86\x12\xdf\xcc\x85\xfc\xe1\x2c\xda\x11\xf9\x50\xbd\x0b\xa8\x87\x67\x40\x43\x6c\x1d\x25\x95\xa6\x4a\x1b\x32\xef\xcf\xb7\x4a\x21\xc8\x73\xb3\xcc\x33\xaa\xf4\xe3\xdc\x39\x53\xde\x67\xf0\x67\x4c\x04\x53\xb4\xfd\x9f\x60\x44\x06\xd4\x41\xb8\x16\x09\x8c\xb1\x06\xfe\x34\x72\xbc\x25\x1f\x81\x5f\x59\xdb\x2e\x43\x78\xa3\xad\xdc\x18\x1e\xcf"
+    , -- Example 2.5
+      VectorPSS
+        { message =
+            "\x86\xa8\x3d\x4a\x72\xee\x93\x2a\x4f\x56\x30\xaf\x65\x79\xa3\x86\xb7\x8f\xe8\x89\x99\xe0\xab\xd2\xd4\x90\x34\xa4\xbf\xc8\x54\xdd\x94\xf1\x09\x4e\x2e\x8c\xd7\xa1\x79\xd1\x95\x88\xe4\xae\xfc\x1b\x1b\xd2\x5e\x95\xe3\xdd\x46\x1f"
+        , salt =
+            "\x17\x63\x9a\x4e\x88\xd7\x22\xc4\xfc\xa2\x4d\x07\x9a\x8b\x29\xc3\x24\x33\xb0\xc9"
+        , signature =
+            "\x00\xec\x43\x08\x24\x93\x1e\xbd\x3b\xaa\x43\x03\x4d\xae\x98\xba\x64\x6b\x8c\x36\x01\x3d\x16\x71\xc3\xcf\x1c\xf8\x26\x0c\x37\x4b\x19\xf8\xe1\xcc\x8d\x96\x50\x12\x40\x5e\x7e\x9b\xf7\x37\x86\x12\xdf\xcc\x85\xfc\xe1\x2c\xda\x11\xf9\x50\xbd\x0b\xa8\x87\x67\x40\x43\x6c\x1d\x25\x95\xa6\x4a\x1b\x32\xef\xcf\xb7\x4a\x21\xc8\x73\xb3\xcc\x33\xaa\xf4\xe3\xdc\x39\x53\xde\x67\xf0\x67\x4c\x04\x53\xb4\xfd\x9f\x60\x44\x06\xd4\x41\xb8\x16\x09\x8c\xb1\x06\xfe\x34\x72\xbc\x25\x1f\x81\x5f\x59\xdb\x2e\x43\x78\xa3\xad\xdc\x18\x1e\xcf"
         }
-    -- Example 2.6
-    , VectorPSS
-        { message = "\x04\x9f\x91\x54\xd8\x71\xac\x4a\x7c\x7a\xb4\x53\x25\xba\x75\x45\xa1\xed\x08\xf7\x05\x25\xb2\x66\x7c\xf1"
-        , salt = "\x37\x81\x0d\xef\x10\x55\xed\x92\x2b\x06\x3d\xf7\x98\xde\x5d\x0a\xab\xf8\x86\xee"
-        , signature = "\x00\x47\x5b\x16\x48\xf8\x14\xa8\xdc\x0a\xbd\xc3\x7b\x55\x27\xf5\x43\xb6\x66\xbb\x6e\x39\xd3\x0e\x5b\x49\xd3\xb8\x76\xdc\xcc\x58\xea\xc1\x4e\x32\xa2\xd5\x5c\x26\x16\x01\x44\x56\xad\x2f\x24\x6f\xc8\xe3\xd5\x60\xda\x3d\xdf\x37\x9a\x1c\x0b\xd2\x00\xf1\x02\x21\xdf\x07\x8c\x21\x9a\x15\x1b\xc8\xd4\xec\x9d\x2f\xc2\x56\x44\x67\x81\x10\x14\xef\x15\xd8\xea\x01\xc2\xeb\xbf\xf8\xc2\xc8\xef\xab\x38\x09\x6e\x55\xfc\xbe\x32\x85\xc7\xaa\x55\x88\x51\x25\x4f\xaf\xfa\x92\xc1\xc7\x2b\x78\x75\x86\x63\xef\x45\x82\x84\x31\x39\xd7\xa6"
+    , -- Example 2.6
+      VectorPSS
+        { message =
+            "\x04\x9f\x91\x54\xd8\x71\xac\x4a\x7c\x7a\xb4\x53\x25\xba\x75\x45\xa1\xed\x08\xf7\x05\x25\xb2\x66\x7c\xf1"
+        , salt =
+            "\x37\x81\x0d\xef\x10\x55\xed\x92\x2b\x06\x3d\xf7\x98\xde\x5d\x0a\xab\xf8\x86\xee"
+        , signature =
+            "\x00\x47\x5b\x16\x48\xf8\x14\xa8\xdc\x0a\xbd\xc3\x7b\x55\x27\xf5\x43\xb6\x66\xbb\x6e\x39\xd3\x0e\x5b\x49\xd3\xb8\x76\xdc\xcc\x58\xea\xc1\x4e\x32\xa2\xd5\x5c\x26\x16\x01\x44\x56\xad\x2f\x24\x6f\xc8\xe3\xd5\x60\xda\x3d\xdf\x37\x9a\x1c\x0b\xd2\x00\xf1\x02\x21\xdf\x07\x8c\x21\x9a\x15\x1b\xc8\xd4\xec\x9d\x2f\xc2\x56\x44\x67\x81\x10\x14\xef\x15\xd8\xea\x01\xc2\xeb\xbf\xf8\xc2\xc8\xef\xab\x38\x09\x6e\x55\xfc\xbe\x32\x85\xc7\xaa\x55\x88\x51\x25\x4f\xaf\xfa\x92\xc1\xc7\x2b\x78\x75\x86\x63\xef\x45\x82\x84\x31\x39\xd7\xa6"
         }
     ]
 
@@ -214,57 +280,83 @@
 -- Example 3: A 1026-bit RSA Key Pair
 -- ==================================
 
-rsaKey3 = PrivateKey
-    { private_pub = PublicKey
-        { public_n = 0x02f246ef451ed3eebb9a310200cc25859c048e4be798302991112eb68ce6db674e280da21feded1ae74880ca522b18db249385012827c515f0e466a1ffa691d98170574e9d0eadb087586ca48933da3cc953d95bd0ed50de10ddcb6736107d6c831c7f663e833ca4c097e700ce0fb945f88fb85fe8e5a773172565b914a471a443
-        , public_e = 0x010001
-        , public_size = 129
+rsaKey3 =
+    PrivateKey
+        { private_pub =
+            PublicKey
+                { public_n =
+                    0x02f246ef451ed3eebb9a310200cc25859c048e4be798302991112eb68ce6db674e280da21feded1ae74880ca522b18db249385012827c515f0e466a1ffa691d98170574e9d0eadb087586ca48933da3cc953d95bd0ed50de10ddcb6736107d6c831c7f663e833ca4c097e700ce0fb945f88fb85fe8e5a773172565b914a471a443
+                , public_e = 0x010001
+                , public_size = 129
+                }
+        , private_d =
+            0x651451733b56de5ac0a689a4aeb6e6894a69014e076c88dd7a667eab3232bbccd2fc44ba2fa9c31db46f21edd1fdb23c5c128a5da5bab91e7f952b67759c7cff705415ac9fa0907c7ca6178f668fb948d869da4cc3b7356f4008dfd5449d32ee02d9a477eb69fc29266e5d9070512375a50fbbcc27e238ad98425f6ebbf88991
+        , private_p =
+            0x01bd36e18ece4b0fdb2e9c9d548bd1a7d6e2c21c6fdc35074a1d05b1c6c8b3d558ea2639c9a9a421680169317252558bd148ad215aac550e2dcf12a82d0ebfe853
+        , private_q =
+            0x01b1b656ad86d8e19d5dc86292b3a192fdf6e0dd37877bad14822fa00190cab265f90d3f02057b6f54d6ecb14491e5adeacebc48bf0ebd2a2ad26d402e54f61651
+        , private_dP =
+            0x1f2779fd2e3e5e6bae05539518fba0cd0ead1aa4513a7cba18f1cf10e3f68195693d278a0f0ee72f89f9bc760d80e2f9d0261d516501c6ae39f14a476ce2ccf5
+        , private_dQ =
+            0x011a0d36794b04a854aab4b2462d439a5046c91d940b2bc6f75b62956fef35a2a6e63c5309817f307bbff9d59e7e331bd363f6d66849b18346adea169f0ae9aec1
+        , private_qinv =
+            0x0b30f0ecf558752fb3a6ce4ba2b8c675f659eba6c376585a1b39712d038ae3d2b46fcb418ae15d0905da6440e1513a30b9b7d6668fbc5e88e5ab7a175e73ba35
         }
-    , private_d = 0x651451733b56de5ac0a689a4aeb6e6894a69014e076c88dd7a667eab3232bbccd2fc44ba2fa9c31db46f21edd1fdb23c5c128a5da5bab91e7f952b67759c7cff705415ac9fa0907c7ca6178f668fb948d869da4cc3b7356f4008dfd5449d32ee02d9a477eb69fc29266e5d9070512375a50fbbcc27e238ad98425f6ebbf88991
-    , private_p = 0x01bd36e18ece4b0fdb2e9c9d548bd1a7d6e2c21c6fdc35074a1d05b1c6c8b3d558ea2639c9a9a421680169317252558bd148ad215aac550e2dcf12a82d0ebfe853
-    , private_q = 0x01b1b656ad86d8e19d5dc86292b3a192fdf6e0dd37877bad14822fa00190cab265f90d3f02057b6f54d6ecb14491e5adeacebc48bf0ebd2a2ad26d402e54f61651
-    , private_dP = 0x1f2779fd2e3e5e6bae05539518fba0cd0ead1aa4513a7cba18f1cf10e3f68195693d278a0f0ee72f89f9bc760d80e2f9d0261d516501c6ae39f14a476ce2ccf5
-    , private_dQ = 0x011a0d36794b04a854aab4b2462d439a5046c91d940b2bc6f75b62956fef35a2a6e63c5309817f307bbff9d59e7e331bd363f6d66849b18346adea169f0ae9aec1
-    , private_qinv = 0x0b30f0ecf558752fb3a6ce4ba2b8c675f659eba6c376585a1b39712d038ae3d2b46fcb418ae15d0905da6440e1513a30b9b7d6668fbc5e88e5ab7a175e73ba35
-    }
 
 vectorsKey3 =
-    [
-    -- Example 3.1
+    [ -- Example 3.1
       VectorPSS
-        { message = "\x59\x4b\x37\x33\x3b\xbb\x2c\x84\x52\x4a\x87\xc1\xa0\x1f\x75\xfc\xec\x0e\x32\x56\xf1\x08\xe3\x8d\xca\x36\xd7\x0d\x00\x57"
-        , salt = "\xf3\x1a\xd6\xc8\xcf\x89\xdf\x78\xed\x77\xfe\xac\xbc\xc2\xf8\xb0\xa8\xe4\xcf\xaa"
-        , signature = "\x00\x88\xb1\x35\xfb\x17\x94\xb6\xb9\x6c\x4a\x3e\x67\x81\x97\xf8\xca\xc5\x2b\x64\xb2\xfe\x90\x7d\x6f\x27\xde\x76\x11\x24\x96\x4a\x99\xa0\x1a\x88\x27\x40\xec\xfa\xed\x6c\x01\xa4\x74\x64\xbb\x05\x18\x23\x13\xc0\x13\x38\xa8\xcd\x09\x72\x14\xcd\x68\xca\x10\x3b\xd5\x7d\x3b\xc9\xe8\x16\x21\x3e\x61\xd7\x84\xf1\x82\x46\x7a\xbf\x8a\x01\xcf\x25\x3e\x99\xa1\x56\xea\xa8\xe3\xe1\xf9\x0e\x3c\x6e\x4e\x3a\xa2\xd8\x3e\xd0\x34\x5b\x89\xfa\xfc\x9c\x26\x07\x7c\x14\xb6\xac\x51\x45\x4f\xa2\x6e\x44\x6e\x3a\x2f\x15\x3b\x2b\x16\x79\x7f"
+        { message =
+            "\x59\x4b\x37\x33\x3b\xbb\x2c\x84\x52\x4a\x87\xc1\xa0\x1f\x75\xfc\xec\x0e\x32\x56\xf1\x08\xe3\x8d\xca\x36\xd7\x0d\x00\x57"
+        , salt =
+            "\xf3\x1a\xd6\xc8\xcf\x89\xdf\x78\xed\x77\xfe\xac\xbc\xc2\xf8\xb0\xa8\xe4\xcf\xaa"
+        , signature =
+            "\x00\x88\xb1\x35\xfb\x17\x94\xb6\xb9\x6c\x4a\x3e\x67\x81\x97\xf8\xca\xc5\x2b\x64\xb2\xfe\x90\x7d\x6f\x27\xde\x76\x11\x24\x96\x4a\x99\xa0\x1a\x88\x27\x40\xec\xfa\xed\x6c\x01\xa4\x74\x64\xbb\x05\x18\x23\x13\xc0\x13\x38\xa8\xcd\x09\x72\x14\xcd\x68\xca\x10\x3b\xd5\x7d\x3b\xc9\xe8\x16\x21\x3e\x61\xd7\x84\xf1\x82\x46\x7a\xbf\x8a\x01\xcf\x25\x3e\x99\xa1\x56\xea\xa8\xe3\xe1\xf9\x0e\x3c\x6e\x4e\x3a\xa2\xd8\x3e\xd0\x34\x5b\x89\xfa\xfc\x9c\x26\x07\x7c\x14\xb6\xac\x51\x45\x4f\xa2\x6e\x44\x6e\x3a\x2f\x15\x3b\x2b\x16\x79\x7f"
         }
-    -- Example 3.2
-    , VectorPSS
-        { message = "\x8b\x76\x95\x28\x88\x4a\x0d\x1f\xfd\x09\x0c\xf1\x02\x99\x3e\x79\x6d\xad\xcf\xbd\xdd\x38\xe4\x4f\xf6\x32\x4c\xa4\x51"
-        , salt = "\xfc\xf9\xf0\xe1\xf1\x99\xa3\xd1\xd0\xda\x68\x1c\x5b\x86\x06\xfc\x64\x29\x39\xf7"
-        , signature = "\x02\xa5\xf0\xa8\x58\xa0\x86\x4a\x4f\x65\x01\x7a\x7d\x69\x45\x4f\x3f\x97\x3a\x29\x99\x83\x9b\x7b\xbc\x48\xbf\x78\x64\x11\x69\x17\x95\x56\xf5\x95\xfa\x41\xf6\xff\x18\xe2\x86\xc2\x78\x30\x79\xbc\x09\x10\xee\x9c\xc3\x4f\x49\xba\x68\x11\x24\xf9\x23\xdf\xa8\x8f\x42\x61\x41\xa3\x68\xa5\xf5\xa9\x30\xc6\x28\xc2\xc3\xc2\x00\xe1\x8a\x76\x44\x72\x1a\x0c\xbe\xc6\xdd\x3f\x62\x79\xbd\xe3\xe8\xf2\xbe\x5e\x2d\x4e\xe5\x6f\x97\xe7\xce\xaf\x33\x05\x4b\xe7\x04\x2b\xd9\x1a\x63\xbb\x09\xf8\x97\xbd\x41\xe8\x11\x97\xde\xe9\x9b\x11\xaf"
+    , -- Example 3.2
+      VectorPSS
+        { message =
+            "\x8b\x76\x95\x28\x88\x4a\x0d\x1f\xfd\x09\x0c\xf1\x02\x99\x3e\x79\x6d\xad\xcf\xbd\xdd\x38\xe4\x4f\xf6\x32\x4c\xa4\x51"
+        , salt =
+            "\xfc\xf9\xf0\xe1\xf1\x99\xa3\xd1\xd0\xda\x68\x1c\x5b\x86\x06\xfc\x64\x29\x39\xf7"
+        , signature =
+            "\x02\xa5\xf0\xa8\x58\xa0\x86\x4a\x4f\x65\x01\x7a\x7d\x69\x45\x4f\x3f\x97\x3a\x29\x99\x83\x9b\x7b\xbc\x48\xbf\x78\x64\x11\x69\x17\x95\x56\xf5\x95\xfa\x41\xf6\xff\x18\xe2\x86\xc2\x78\x30\x79\xbc\x09\x10\xee\x9c\xc3\x4f\x49\xba\x68\x11\x24\xf9\x23\xdf\xa8\x8f\x42\x61\x41\xa3\x68\xa5\xf5\xa9\x30\xc6\x28\xc2\xc3\xc2\x00\xe1\x8a\x76\x44\x72\x1a\x0c\xbe\xc6\xdd\x3f\x62\x79\xbd\xe3\xe8\xf2\xbe\x5e\x2d\x4e\xe5\x6f\x97\xe7\xce\xaf\x33\x05\x4b\xe7\x04\x2b\xd9\x1a\x63\xbb\x09\xf8\x97\xbd\x41\xe8\x11\x97\xde\xe9\x9b\x11\xaf"
         }
-    -- Example 3.3
-    , VectorPSS
-        { message = "\x1a\xbd\xba\x48\x9c\x5a\xda\x2f\x99\x5e\xd1\x6f\x19\xd5\xa9\x4d\x9e\x6e\xc3\x4a\x8d\x84\xf8\x45\x57\xd2\x6e\x5e\xf9\xb0\x2b\x22\x88\x7e\x3f\x9a\x4b\x69\x0a\xd1\x14\x92\x09\xc2\x0c\x61\x43\x1f\x0c\x01\x7c\x36\xc2\x65\x7b\x35\xd7\xb0\x7d\x3f\x5a\xd8\x70\x85\x07\xa9\xc1\xb8\x31\xdf\x83\x5a\x56\xf8\x31\x07\x18\x14\xea\x5d\x3d\x8d\x8f\x6a\xde\x40\xcb\xa3\x8b\x42\xdb\x7a\x2d\x3d\x7a\x29\xc8\xf0\xa7\x9a\x78\x38\xcf\x58\xa9\x75\x7f\xa2\xfe\x4c\x40\xdf\x9b\xaa\x19\x3b\xfc\x6f\x92\xb1\x23\xad\x57\xb0\x7a\xce\x3e\x6a\xc0\x68\xc9\xf1\x06\xaf\xd9\xee\xb0\x3b\x4f\x37\xc2\x5d\xbf\xbc\xfb\x30\x71\xf6\xf9\x77\x17\x66\xd0\x72\xf3\xbb\x07\x0a\xf6\x60\x55\x32\x97\x3a\xe2\x50\x51"
-        , salt = "\x98\x6e\x7c\x43\xdb\xb6\x71\xbd\x41\xb9\xa7\xf4\xb6\xaf\xc8\x0e\x80\x5f\x24\x23"
-        , signature = "\x02\x44\xbc\xd1\xc8\xc1\x69\x55\x73\x6c\x80\x3b\xe4\x01\x27\x2e\x18\xcb\x99\x08\x11\xb1\x4f\x72\xdb\x96\x41\x24\xd5\xfa\x76\x06\x49\xcb\xb5\x7a\xfb\x87\x55\xdb\xb6\x2b\xf5\x1f\x46\x6c\xf2\x3a\x0a\x16\x07\x57\x6e\x98\x3d\x77\x8f\xce\xff\xa9\x2d\xf7\x54\x8a\xea\x8e\xa4\xec\xad\x2c\x29\xdd\x9f\x95\xbc\x07\xfe\x91\xec\xf8\xbe\xe2\x55\xbf\xe8\x76\x2f\xd7\x69\x0a\xa9\xbf\xa4\xfa\x08\x49\xef\x72\x8c\x2c\x42\xc4\x53\x23\x64\x52\x2d\xf2\xab\x7f\x9f\x8a\x03\xb6\x3f\x7a\x49\x91\x75\x82\x86\x68\xf5\xef\x5a\x29\xe3\x80\x2c"
+    , -- Example 3.3
+      VectorPSS
+        { message =
+            "\x1a\xbd\xba\x48\x9c\x5a\xda\x2f\x99\x5e\xd1\x6f\x19\xd5\xa9\x4d\x9e\x6e\xc3\x4a\x8d\x84\xf8\x45\x57\xd2\x6e\x5e\xf9\xb0\x2b\x22\x88\x7e\x3f\x9a\x4b\x69\x0a\xd1\x14\x92\x09\xc2\x0c\x61\x43\x1f\x0c\x01\x7c\x36\xc2\x65\x7b\x35\xd7\xb0\x7d\x3f\x5a\xd8\x70\x85\x07\xa9\xc1\xb8\x31\xdf\x83\x5a\x56\xf8\x31\x07\x18\x14\xea\x5d\x3d\x8d\x8f\x6a\xde\x40\xcb\xa3\x8b\x42\xdb\x7a\x2d\x3d\x7a\x29\xc8\xf0\xa7\x9a\x78\x38\xcf\x58\xa9\x75\x7f\xa2\xfe\x4c\x40\xdf\x9b\xaa\x19\x3b\xfc\x6f\x92\xb1\x23\xad\x57\xb0\x7a\xce\x3e\x6a\xc0\x68\xc9\xf1\x06\xaf\xd9\xee\xb0\x3b\x4f\x37\xc2\x5d\xbf\xbc\xfb\x30\x71\xf6\xf9\x77\x17\x66\xd0\x72\xf3\xbb\x07\x0a\xf6\x60\x55\x32\x97\x3a\xe2\x50\x51"
+        , salt =
+            "\x98\x6e\x7c\x43\xdb\xb6\x71\xbd\x41\xb9\xa7\xf4\xb6\xaf\xc8\x0e\x80\x5f\x24\x23"
+        , signature =
+            "\x02\x44\xbc\xd1\xc8\xc1\x69\x55\x73\x6c\x80\x3b\xe4\x01\x27\x2e\x18\xcb\x99\x08\x11\xb1\x4f\x72\xdb\x96\x41\x24\xd5\xfa\x76\x06\x49\xcb\xb5\x7a\xfb\x87\x55\xdb\xb6\x2b\xf5\x1f\x46\x6c\xf2\x3a\x0a\x16\x07\x57\x6e\x98\x3d\x77\x8f\xce\xff\xa9\x2d\xf7\x54\x8a\xea\x8e\xa4\xec\xad\x2c\x29\xdd\x9f\x95\xbc\x07\xfe\x91\xec\xf8\xbe\xe2\x55\xbf\xe8\x76\x2f\xd7\x69\x0a\xa9\xbf\xa4\xfa\x08\x49\xef\x72\x8c\x2c\x42\xc4\x53\x23\x64\x52\x2d\xf2\xab\x7f\x9f\x8a\x03\xb6\x3f\x7a\x49\x91\x75\x82\x86\x68\xf5\xef\x5a\x29\xe3\x80\x2c"
         }
-    -- Example 3.4
-    , VectorPSS
-        { message = "\x8f\xb4\x31\xf5\xee\x79\x2b\x6c\x2a\xc7\xdb\x53\xcc\x42\x86\x55\xae\xb3\x2d\x03\xf4\xe8\x89\xc5\xc2\x5d\xe6\x83\xc4\x61\xb5\x3a\xcf\x89\xf9\xf8\xd3\xaa\xbd\xf6\xb9\xf0\xc2\xa1\xde\x12\xe1\x5b\x49\xed\xb3\x91\x9a\x65\x2f\xe9\x49\x1c\x25\xa7\xfc\xe1\xf7\x22\xc2\x54\x36\x08\xb6\x9d\xc3\x75\xec"
-        , salt = "\xf8\x31\x2d\x9c\x8e\xea\x13\xec\x0a\x4c\x7b\x98\x12\x0c\x87\x50\x90\x87\xc4\x78"
-        , signature = "\x01\x96\xf1\x2a\x00\x5b\x98\x12\x9c\x8d\xf1\x3c\x4c\xb1\x6f\x8a\xa8\x87\xd3\xc4\x0d\x96\xdf\x3a\x88\xe7\x53\x2e\xf3\x9c\xd9\x92\xf2\x73\xab\xc3\x70\xbc\x1b\xe6\xf0\x97\xcf\xeb\xbf\x01\x18\xfd\x9e\xf4\xb9\x27\x15\x5f\x3d\xf2\x2b\x90\x4d\x90\x70\x2d\x1f\x7b\xa7\xa5\x2b\xed\x8b\x89\x42\xf4\x12\xcd\x7b\xd6\x76\xc9\xd1\x8e\x17\x03\x91\xdc\xd3\x45\xc0\x6a\x73\x09\x64\xb3\xf3\x0b\xcc\xe0\xbb\x20\xba\x10\x6f\x9a\xb0\xee\xb3\x9c\xf8\xa6\x60\x7f\x75\xc0\x34\x7f\x0a\xf7\x9f\x16\xaf\xa0\x81\xd2\xc9\x2d\x1e\xe6\xf8\x36\xb8"
+    , -- Example 3.4
+      VectorPSS
+        { message =
+            "\x8f\xb4\x31\xf5\xee\x79\x2b\x6c\x2a\xc7\xdb\x53\xcc\x42\x86\x55\xae\xb3\x2d\x03\xf4\xe8\x89\xc5\xc2\x5d\xe6\x83\xc4\x61\xb5\x3a\xcf\x89\xf9\xf8\xd3\xaa\xbd\xf6\xb9\xf0\xc2\xa1\xde\x12\xe1\x5b\x49\xed\xb3\x91\x9a\x65\x2f\xe9\x49\x1c\x25\xa7\xfc\xe1\xf7\x22\xc2\x54\x36\x08\xb6\x9d\xc3\x75\xec"
+        , salt =
+            "\xf8\x31\x2d\x9c\x8e\xea\x13\xec\x0a\x4c\x7b\x98\x12\x0c\x87\x50\x90\x87\xc4\x78"
+        , signature =
+            "\x01\x96\xf1\x2a\x00\x5b\x98\x12\x9c\x8d\xf1\x3c\x4c\xb1\x6f\x8a\xa8\x87\xd3\xc4\x0d\x96\xdf\x3a\x88\xe7\x53\x2e\xf3\x9c\xd9\x92\xf2\x73\xab\xc3\x70\xbc\x1b\xe6\xf0\x97\xcf\xeb\xbf\x01\x18\xfd\x9e\xf4\xb9\x27\x15\x5f\x3d\xf2\x2b\x90\x4d\x90\x70\x2d\x1f\x7b\xa7\xa5\x2b\xed\x8b\x89\x42\xf4\x12\xcd\x7b\xd6\x76\xc9\xd1\x8e\x17\x03\x91\xdc\xd3\x45\xc0\x6a\x73\x09\x64\xb3\xf3\x0b\xcc\xe0\xbb\x20\xba\x10\x6f\x9a\xb0\xee\xb3\x9c\xf8\xa6\x60\x7f\x75\xc0\x34\x7f\x0a\xf7\x9f\x16\xaf\xa0\x81\xd2\xc9\x2d\x1e\xe6\xf8\x36\xb8"
         }
-    -- Example 3.5
-    , VectorPSS
-        { message = "\xfe\xf4\x16\x1d\xfa\xaf\x9c\x52\x95\x05\x1d\xfc\x1f\xf3\x81\x0c\x8c\x9e\xc2\xe8\x66\xf7\x07\x54\x22\xc8\xec\x42\x16\xa9\xc4\xff\x49\x42\x7d\x48\x3c\xae\x10\xc8\x53\x4a\x41\xb2\xfd\x15\xfe\xe0\x69\x60\xec\x6f\xb3\xf7\xa7\xe9\x4a\x2f\x8a\x2e\x3e\x43\xdc\x4a\x40\x57\x6c\x30\x97\xac\x95\x3b\x1d\xe8\x6f\x0b\x4e\xd3\x6d\x64\x4f\x23\xae\x14\x42\x55\x29\x62\x24\x64\xca\x0c\xbf\x0b\x17\x41\x34\x72\x38\x15\x7f\xab\x59\xe4\xde\x55\x24\x09\x6d\x62\xba\xec\x63\xac\x64"
-        , salt = "\x50\x32\x7e\xfe\xc6\x29\x2f\x98\x01\x9f\xc6\x7a\x2a\x66\x38\x56\x3e\x9b\x6e\x2d"
-        , signature = "\x02\x1e\xca\x3a\xb4\x89\x22\x64\xec\x22\x41\x1a\x75\x2d\x92\x22\x10\x76\xd4\xe0\x1c\x0e\x6f\x0d\xde\x9a\xfd\x26\xba\x5a\xcf\x6d\x73\x9e\xf9\x87\x54\x5d\x16\x68\x3e\x56\x74\xc9\xe7\x0f\x1d\xe6\x49\xd7\xe6\x1d\x48\xd0\xca\xeb\x4f\xb4\xd8\xb2\x4f\xba\x84\xa6\xe3\x10\x8f\xee\x7d\x07\x05\x97\x32\x66\xac\x52\x4b\x4a\xd2\x80\xf7\xae\x17\xdc\x59\xd9\x6d\x33\x51\x58\x6b\x5a\x3b\xdb\x89\x5d\x1e\x1f\x78\x20\xac\x61\x35\xd8\x75\x34\x80\x99\x83\x82\xba\x32\xb7\x34\x95\x59\x60\x8c\x38\x74\x52\x90\xa8\x5e\xf4\xe9\xf9\xbd\x83"
+    , -- Example 3.5
+      VectorPSS
+        { message =
+            "\xfe\xf4\x16\x1d\xfa\xaf\x9c\x52\x95\x05\x1d\xfc\x1f\xf3\x81\x0c\x8c\x9e\xc2\xe8\x66\xf7\x07\x54\x22\xc8\xec\x42\x16\xa9\xc4\xff\x49\x42\x7d\x48\x3c\xae\x10\xc8\x53\x4a\x41\xb2\xfd\x15\xfe\xe0\x69\x60\xec\x6f\xb3\xf7\xa7\xe9\x4a\x2f\x8a\x2e\x3e\x43\xdc\x4a\x40\x57\x6c\x30\x97\xac\x95\x3b\x1d\xe8\x6f\x0b\x4e\xd3\x6d\x64\x4f\x23\xae\x14\x42\x55\x29\x62\x24\x64\xca\x0c\xbf\x0b\x17\x41\x34\x72\x38\x15\x7f\xab\x59\xe4\xde\x55\x24\x09\x6d\x62\xba\xec\x63\xac\x64"
+        , salt =
+            "\x50\x32\x7e\xfe\xc6\x29\x2f\x98\x01\x9f\xc6\x7a\x2a\x66\x38\x56\x3e\x9b\x6e\x2d"
+        , signature =
+            "\x02\x1e\xca\x3a\xb4\x89\x22\x64\xec\x22\x41\x1a\x75\x2d\x92\x22\x10\x76\xd4\xe0\x1c\x0e\x6f\x0d\xde\x9a\xfd\x26\xba\x5a\xcf\x6d\x73\x9e\xf9\x87\x54\x5d\x16\x68\x3e\x56\x74\xc9\xe7\x0f\x1d\xe6\x49\xd7\xe6\x1d\x48\xd0\xca\xeb\x4f\xb4\xd8\xb2\x4f\xba\x84\xa6\xe3\x10\x8f\xee\x7d\x07\x05\x97\x32\x66\xac\x52\x4b\x4a\xd2\x80\xf7\xae\x17\xdc\x59\xd9\x6d\x33\x51\x58\x6b\x5a\x3b\xdb\x89\x5d\x1e\x1f\x78\x20\xac\x61\x35\xd8\x75\x34\x80\x99\x83\x82\xba\x32\xb7\x34\x95\x59\x60\x8c\x38\x74\x52\x90\xa8\x5e\xf4\xe9\xf9\xbd\x83"
         }
-    -- Example 3.6
-    , VectorPSS
-        { message = "\xef\xd2\x37\xbb\x09\x8a\x44\x3a\xee\xb2\xbf\x6c\x3f\x8c\x81\xb8\xc0\x1b\x7f\xcb\x3f\xeb"
-        , salt = "\xb0\xde\x3f\xc2\x5b\x65\xf5\xaf\x96\xb1\xd5\xcc\x3b\x27\xd0\xc6\x05\x30\x87\xb3"
-        , signature = "\x01\x2f\xaf\xec\x86\x2f\x56\xe9\xe9\x2f\x60\xab\x0c\x77\x82\x4f\x42\x99\xa0\xca\x73\x4e\xd2\x6e\x06\x44\xd5\xd2\x22\xc7\xf0\xbd\xe0\x39\x64\xf8\xe7\x0a\x5c\xb6\x5e\xd4\x4e\x44\xd5\x6a\xe0\xed\xf1\xff\x86\xca\x03\x2c\xc5\xdd\x44\x04\xdb\xb7\x6a\xb8\x54\x58\x6c\x44\xee\xd8\x33\x6d\x08\xd4\x57\xce\x6c\x03\x69\x3b\x45\xc0\xf1\xef\xef\x93\x62\x4b\x95\xb8\xec\x16\x9c\x61\x6d\x20\xe5\x53\x8e\xbc\x0b\x67\x37\xa6\xf8\x2b\x4b\xc0\x57\x09\x24\xfc\x6b\x35\x75\x9a\x33\x48\x42\x62\x79\xf8\xb3\xd7\x74\x4e\x2d\x22\x24\x26\xce"
+    , -- Example 3.6
+      VectorPSS
+        { message =
+            "\xef\xd2\x37\xbb\x09\x8a\x44\x3a\xee\xb2\xbf\x6c\x3f\x8c\x81\xb8\xc0\x1b\x7f\xcb\x3f\xeb"
+        , salt =
+            "\xb0\xde\x3f\xc2\x5b\x65\xf5\xaf\x96\xb1\xd5\xcc\x3b\x27\xd0\xc6\x05\x30\x87\xb3"
+        , signature =
+            "\x01\x2f\xaf\xec\x86\x2f\x56\xe9\xe9\x2f\x60\xab\x0c\x77\x82\x4f\x42\x99\xa0\xca\x73\x4e\xd2\x6e\x06\x44\xd5\xd2\x22\xc7\xf0\xbd\xe0\x39\x64\xf8\xe7\x0a\x5c\xb6\x5e\xd4\x4e\x44\xd5\x6a\xe0\xed\xf1\xff\x86\xca\x03\x2c\xc5\xdd\x44\x04\xdb\xb7\x6a\xb8\x54\x58\x6c\x44\xee\xd8\x33\x6d\x08\xd4\x57\xce\x6c\x03\x69\x3b\x45\xc0\xf1\xef\xef\x93\x62\x4b\x95\xb8\xec\x16\x9c\x61\x6d\x20\xe5\x53\x8e\xbc\x0b\x67\x37\xa6\xf8\x2b\x4b\xc0\x57\x09\x24\xfc\x6b\x35\x75\x9a\x33\x48\x42\x62\x79\xf8\xb3\xd7\x74\x4e\x2d\x22\x24\x26\xce"
         }
     ]
 
@@ -272,77 +364,128 @@
 -- Example 8: A 1031-bit RSA Key Pair
 -- ==================================
 
-rsaKey8 = PrivateKey
-    { private_pub = PublicKey
-        { public_n = 0x495370a1fb18543c16d3631e3163255df62be6eee890d5f25509e4f778a8ea6fbbbcdf85dff64e0d972003ab3681fbba6dd41fd541829b2e582de9f2a4a4e0a2d0900bef4753db3cee0ee06c7dfae8b1d53b5953218f9cceea695b08668edeaadced9463b1d790d5ebf27e9115b46cad4d9a2b8efab0561b0810344739ada0733f
-        , public_e = 0x010001
-        , public_size = 129
+rsaKey8 =
+    PrivateKey
+        { private_pub =
+            PublicKey
+                { public_n =
+                    0x495370a1fb18543c16d3631e3163255df62be6eee890d5f25509e4f778a8ea6fbbbcdf85dff64e0d972003ab3681fbba6dd41fd541829b2e582de9f2a4a4e0a2d0900bef4753db3cee0ee06c7dfae8b1d53b5953218f9cceea695b08668edeaadced9463b1d790d5ebf27e9115b46cad4d9a2b8efab0561b0810344739ada0733f
+                , public_e = 0x010001
+                , public_size = 129
+                }
+        , private_d =
+            0x6c66ffe98980c38fcdeab5159898836165f4b4b817c4f6a8d486ee4ea9130fe9b9092bd136d184f95f504a607eac565846d2fdd6597a8967c7396ef95a6eeebb4578a643966dca4d8ee3de842de63279c618159c1ab54a89437b6a6120e4930afb52a4ba6ced8a4947ac64b30a3497cbe701c2d6266d517219ad0ec6d347dbe9
+        , private_p =
+            0x08dad7f11363faa623d5d6d5e8a319328d82190d7127d2846c439b0ab72619b0a43a95320e4ec34fc3a9cea876422305bd76c5ba7be9e2f410c8060645a1d29edb
+        , private_q =
+            0x0847e732376fc7900f898ea82eb2b0fc418565fdae62f7d9ec4ce2217b97990dd272db157f99f63c0dcbb9fbacdbd4c4dadb6df67756358ca4174825b48f49706d
+        , private_dP =
+            0x05c2a83c124b3621a2aa57ea2c3efe035eff4560f33ddebb7adab81fce69a0c8c2edc16520dda83d59a23be867963ac65f2cc710bbcfb96ee103deb771d105fd85
+        , private_dQ =
+            0x04cae8aa0d9faa165c87b682ec140b8ed3b50b24594b7a3b2c220b3669bb819f984f55310a1ae7823651d4a02e99447972595139363434e5e30a7e7d241551e1b9
+        , private_qinv =
+            0x07d3e47bf686600b11ac283ce88dbb3f6051e8efd04680e44c171ef531b80b2b7c39fc766320e2cf15d8d99820e96ff30dc69691839c4b40d7b06e45307dc91f3f
         }
-    , private_d = 0x6c66ffe98980c38fcdeab5159898836165f4b4b817c4f6a8d486ee4ea9130fe9b9092bd136d184f95f504a607eac565846d2fdd6597a8967c7396ef95a6eeebb4578a643966dca4d8ee3de842de63279c618159c1ab54a89437b6a6120e4930afb52a4ba6ced8a4947ac64b30a3497cbe701c2d6266d517219ad0ec6d347dbe9
-    , private_p = 0x08dad7f11363faa623d5d6d5e8a319328d82190d7127d2846c439b0ab72619b0a43a95320e4ec34fc3a9cea876422305bd76c5ba7be9e2f410c8060645a1d29edb
-    , private_q = 0x0847e732376fc7900f898ea82eb2b0fc418565fdae62f7d9ec4ce2217b97990dd272db157f99f63c0dcbb9fbacdbd4c4dadb6df67756358ca4174825b48f49706d
-    , private_dP = 0x05c2a83c124b3621a2aa57ea2c3efe035eff4560f33ddebb7adab81fce69a0c8c2edc16520dda83d59a23be867963ac65f2cc710bbcfb96ee103deb771d105fd85
-    , private_dQ = 0x04cae8aa0d9faa165c87b682ec140b8ed3b50b24594b7a3b2c220b3669bb819f984f55310a1ae7823651d4a02e99447972595139363434e5e30a7e7d241551e1b9
-    , private_qinv = 0x07d3e47bf686600b11ac283ce88dbb3f6051e8efd04680e44c171ef531b80b2b7c39fc766320e2cf15d8d99820e96ff30dc69691839c4b40d7b06e45307dc91f3f
-    }
 
 vectorsKey8 =
-    [
-    -- Example 8.1
+    [ -- Example 8.1
       VectorPSS
-        { message = "\x81\x33\x2f\x4b\xe6\x29\x48\x41\x5e\xa1\xd8\x99\x79\x2e\xea\xcf\x6c\x6e\x1d\xb1\xda\x8b\xe1\x3b\x5c\xea\x41\xdb\x2f\xed\x46\x70\x92\xe1\xff\x39\x89\x14\xc7\x14\x25\x97\x75\xf5\x95\xf8\x54\x7f\x73\x56\x92\xa5\x75\xe6\x92\x3a\xf7\x8f\x22\xc6\x99\x7d\xdb\x90\xfb\x6f\x72\xd7\xbb\x0d\xd5\x74\x4a\x31\xde\xcd\x3d\xc3\x68\x58\x49\x83\x6e\xd3\x4a\xec\x59\x63\x04\xad\x11\x84\x3c\x4f\x88\x48\x9f\x20\x97\x35\xf5\xfb\x7f\xda\xf7\xce\xc8\xad\xdc\x58\x18\x16\x8f\x88\x0a\xcb\xf4\x90\xd5\x10\x05\xb7\xa8\xe8\x4e\x43\xe5\x42\x87\x97\x75\x71\xdd\x99\xee\xa4\xb1\x61\xeb\x2d\xf1\xf5\x10\x8f\x12\xa4\x14\x2a\x83\x32\x2e\xdb\x05\xa7\x54\x87\xa3\x43\x5c\x9a\x78\xce\x53\xed\x93\xbc\x55\x08\x57\xd7\xa9\xfb"
-        , salt = "\x1d\x65\x49\x1d\x79\xc8\x64\xb3\x73\x00\x9b\xe6\xf6\xf2\x46\x7b\xac\x4c\x78\xfa"
-        , signature = "\x02\x62\xac\x25\x4b\xfa\x77\xf3\xc1\xac\xa2\x2c\x51\x79\xf8\xf0\x40\x42\x2b\x3c\x5b\xaf\xd4\x0a\x8f\x21\xcf\x0f\xa5\xa6\x67\xcc\xd5\x99\x3d\x42\xdb\xaf\xb4\x09\xc5\x20\xe2\x5f\xce\x2b\x1e\xe1\xe7\x16\x57\x7f\x1e\xfa\x17\xf3\xda\x28\x05\x2f\x40\xf0\x41\x9b\x23\x10\x6d\x78\x45\xaa\xf0\x11\x25\xb6\x98\xe7\xa4\xdf\xe9\x2d\x39\x67\xbb\x00\xc4\xd0\xd3\x5b\xa3\x55\x2a\xb9\xa8\xb3\xee\xf0\x7c\x7f\xec\xdb\xc5\x42\x4a\xc4\xdb\x1e\x20\xcb\x37\xd0\xb2\x74\x47\x69\x94\x0e\xa9\x07\xe1\x7f\xbb\xca\x67\x3b\x20\x52\x23\x80\xc5"
+        { message =
+            "\x81\x33\x2f\x4b\xe6\x29\x48\x41\x5e\xa1\xd8\x99\x79\x2e\xea\xcf\x6c\x6e\x1d\xb1\xda\x8b\xe1\x3b\x5c\xea\x41\xdb\x2f\xed\x46\x70\x92\xe1\xff\x39\x89\x14\xc7\x14\x25\x97\x75\xf5\x95\xf8\x54\x7f\x73\x56\x92\xa5\x75\xe6\x92\x3a\xf7\x8f\x22\xc6\x99\x7d\xdb\x90\xfb\x6f\x72\xd7\xbb\x0d\xd5\x74\x4a\x31\xde\xcd\x3d\xc3\x68\x58\x49\x83\x6e\xd3\x4a\xec\x59\x63\x04\xad\x11\x84\x3c\x4f\x88\x48\x9f\x20\x97\x35\xf5\xfb\x7f\xda\xf7\xce\xc8\xad\xdc\x58\x18\x16\x8f\x88\x0a\xcb\xf4\x90\xd5\x10\x05\xb7\xa8\xe8\x4e\x43\xe5\x42\x87\x97\x75\x71\xdd\x99\xee\xa4\xb1\x61\xeb\x2d\xf1\xf5\x10\x8f\x12\xa4\x14\x2a\x83\x32\x2e\xdb\x05\xa7\x54\x87\xa3\x43\x5c\x9a\x78\xce\x53\xed\x93\xbc\x55\x08\x57\xd7\xa9\xfb"
+        , salt =
+            "\x1d\x65\x49\x1d\x79\xc8\x64\xb3\x73\x00\x9b\xe6\xf6\xf2\x46\x7b\xac\x4c\x78\xfa"
+        , signature =
+            "\x02\x62\xac\x25\x4b\xfa\x77\xf3\xc1\xac\xa2\x2c\x51\x79\xf8\xf0\x40\x42\x2b\x3c\x5b\xaf\xd4\x0a\x8f\x21\xcf\x0f\xa5\xa6\x67\xcc\xd5\x99\x3d\x42\xdb\xaf\xb4\x09\xc5\x20\xe2\x5f\xce\x2b\x1e\xe1\xe7\x16\x57\x7f\x1e\xfa\x17\xf3\xda\x28\x05\x2f\x40\xf0\x41\x9b\x23\x10\x6d\x78\x45\xaa\xf0\x11\x25\xb6\x98\xe7\xa4\xdf\xe9\x2d\x39\x67\xbb\x00\xc4\xd0\xd3\x5b\xa3\x55\x2a\xb9\xa8\xb3\xee\xf0\x7c\x7f\xec\xdb\xc5\x42\x4a\xc4\xdb\x1e\x20\xcb\x37\xd0\xb2\x74\x47\x69\x94\x0e\xa9\x07\xe1\x7f\xbb\xca\x67\x3b\x20\x52\x23\x80\xc5"
         }
-    -- Example 8.2
-    , VectorPSS
-        { message = "\xe2\xf9\x6e\xaf\x0e\x05\xe7\xba\x32\x6e\xcc\xa0\xba\x7f\xd2\xf7\xc0\x23\x56\xf3\xce\xde\x9d\x0f\xaa\xbf\x4f\xcc\x8e\x60\xa9\x73\xe5\x59\x5f\xd9\xea\x08"
-        , salt = "\x43\x5c\x09\x8a\xa9\x90\x9e\xb2\x37\x7f\x12\x48\xb0\x91\xb6\x89\x87\xff\x18\x38"
-        , signature = "\x27\x07\xb9\xad\x51\x15\xc5\x8c\x94\xe9\x32\xe8\xec\x0a\x28\x0f\x56\x33\x9e\x44\xa1\xb5\x8d\x4d\xdc\xff\x2f\x31\x2e\x5f\x34\xdc\xfe\x39\xe8\x9c\x6a\x94\xdc\xee\x86\xdb\xbd\xae\x5b\x79\xba\x4e\x08\x19\xa9\xe7\xbf\xd9\xd9\x82\xe7\xee\x6c\x86\xee\x68\x39\x6e\x8b\x3a\x14\xc9\xc8\xf3\x4b\x17\x8e\xb7\x41\xf9\xd3\xf1\x21\x10\x9b\xf5\xc8\x17\x2f\xad\xa2\xe7\x68\xf9\xea\x14\x33\x03\x2c\x00\x4a\x8a\xa0\x7e\xb9\x90\x00\x0a\x48\xdc\x94\xc8\xba\xc8\xaa\xbe\x2b\x09\xb1\xaa\x46\xc0\xa2\xaa\x0e\x12\xf6\x3f\xbb\xa7\x75\xba\x7e"
+    , -- Example 8.2
+      VectorPSS
+        { message =
+            "\xe2\xf9\x6e\xaf\x0e\x05\xe7\xba\x32\x6e\xcc\xa0\xba\x7f\xd2\xf7\xc0\x23\x56\xf3\xce\xde\x9d\x0f\xaa\xbf\x4f\xcc\x8e\x60\xa9\x73\xe5\x59\x5f\xd9\xea\x08"
+        , salt =
+            "\x43\x5c\x09\x8a\xa9\x90\x9e\xb2\x37\x7f\x12\x48\xb0\x91\xb6\x89\x87\xff\x18\x38"
+        , signature =
+            "\x27\x07\xb9\xad\x51\x15\xc5\x8c\x94\xe9\x32\xe8\xec\x0a\x28\x0f\x56\x33\x9e\x44\xa1\xb5\x8d\x4d\xdc\xff\x2f\x31\x2e\x5f\x34\xdc\xfe\x39\xe8\x9c\x6a\x94\xdc\xee\x86\xdb\xbd\xae\x5b\x79\xba\x4e\x08\x19\xa9\xe7\xbf\xd9\xd9\x82\xe7\xee\x6c\x86\xee\x68\x39\x6e\x8b\x3a\x14\xc9\xc8\xf3\x4b\x17\x8e\xb7\x41\xf9\xd3\xf1\x21\x10\x9b\xf5\xc8\x17\x2f\xad\xa2\xe7\x68\xf9\xea\x14\x33\x03\x2c\x00\x4a\x8a\xa0\x7e\xb9\x90\x00\x0a\x48\xdc\x94\xc8\xba\xc8\xaa\xbe\x2b\x09\xb1\xaa\x46\xc0\xa2\xaa\x0e\x12\xf6\x3f\xbb\xa7\x75\xba\x7e"
         }
-    -- Example 8.3
-    , VectorPSS
-        { message = "\xe3\x5c\x6e\xd9\x8f\x64\xa6\xd5\xa6\x48\xfc\xab\x8a\xdb\x16\x33\x1d\xb3\x2e\x5d\x15\xc7\x4a\x40\xed\xf9\x4c\x3d\xc4\xa4\xde\x79\x2d\x19\x08\x89\xf2\x0f\x1e\x24\xed\x12\x05\x4a\x6b\x28\x79\x8f\xcb\x42\xd1\xc5\x48\x76\x9b\x73\x4c\x96\x37\x31\x42\x09\x2a\xed\x27\x76\x03\xf4\x73\x8d\xf4\xdc\x14\x46\x58\x6d\x0e\xc6\x4d\xa4\xfb\x60\x53\x6d\xb2\xae\x17\xfc\x7e\x3c\x04\xbb\xfb\xbb\xd9\x07\xbf\x11\x7c\x08\x63\x6f\xa1\x6f\x95\xf5\x1a\x62\x16\x93\x4d\x3e\x34\xf8\x50\x30\xf1\x7b\xbb\xc5\xba\x69\x14\x40\x58\xaf\xf0\x81\xe0\xb1\x9c\xf0\x3c\x17\x19\x5c\x5e\x88\x8b\xa5\x8f\x6f\xe0\xa0\x2e\x5c\x3b\xda\x97\x19\xa7"
-        , salt = "\xc6\xeb\xbe\x76\xdf\x0c\x4a\xea\x32\xc4\x74\x17\x5b\x2f\x13\x68\x62\xd0\x45\x29"
-        , signature = "\x2a\xd2\x05\x09\xd7\x8c\xf2\x6d\x1b\x6c\x40\x61\x46\x08\x6e\x4b\x0c\x91\xa9\x1c\x2b\xd1\x64\xc8\x7b\x96\x6b\x8f\xaa\x42\xaa\x0c\xa4\x46\x02\x23\x23\xba\x4b\x1a\x1b\x89\x70\x6d\x7f\x4c\x3b\xe5\x7d\x7b\x69\x70\x2d\x16\x8a\xb5\x95\x5e\xe2\x90\x35\x6b\x8c\x4a\x29\xed\x46\x7d\x54\x7e\xc2\x3c\xba\xdf\x28\x6c\xcb\x58\x63\xc6\x67\x9d\xa4\x67\xfc\x93\x24\xa1\x51\xc7\xec\x55\xaa\xc6\xdb\x40\x84\xf8\x27\x26\x82\x5c\xfe\x1a\xa4\x21\xbc\x64\x04\x9f\xb4\x2f\x23\x14\x8f\x9c\x25\xb2\xdc\x30\x04\x37\xc3\x8d\x42\x8a\xa7\x5f\x96"
+    , -- Example 8.3
+      VectorPSS
+        { message =
+            "\xe3\x5c\x6e\xd9\x8f\x64\xa6\xd5\xa6\x48\xfc\xab\x8a\xdb\x16\x33\x1d\xb3\x2e\x5d\x15\xc7\x4a\x40\xed\xf9\x4c\x3d\xc4\xa4\xde\x79\x2d\x19\x08\x89\xf2\x0f\x1e\x24\xed\x12\x05\x4a\x6b\x28\x79\x8f\xcb\x42\xd1\xc5\x48\x76\x9b\x73\x4c\x96\x37\x31\x42\x09\x2a\xed\x27\x76\x03\xf4\x73\x8d\xf4\xdc\x14\x46\x58\x6d\x0e\xc6\x4d\xa4\xfb\x60\x53\x6d\xb2\xae\x17\xfc\x7e\x3c\x04\xbb\xfb\xbb\xd9\x07\xbf\x11\x7c\x08\x63\x6f\xa1\x6f\x95\xf5\x1a\x62\x16\x93\x4d\x3e\x34\xf8\x50\x30\xf1\x7b\xbb\xc5\xba\x69\x14\x40\x58\xaf\xf0\x81\xe0\xb1\x9c\xf0\x3c\x17\x19\x5c\x5e\x88\x8b\xa5\x8f\x6f\xe0\xa0\x2e\x5c\x3b\xda\x97\x19\xa7"
+        , salt =
+            "\xc6\xeb\xbe\x76\xdf\x0c\x4a\xea\x32\xc4\x74\x17\x5b\x2f\x13\x68\x62\xd0\x45\x29"
+        , signature =
+            "\x2a\xd2\x05\x09\xd7\x8c\xf2\x6d\x1b\x6c\x40\x61\x46\x08\x6e\x4b\x0c\x91\xa9\x1c\x2b\xd1\x64\xc8\x7b\x96\x6b\x8f\xaa\x42\xaa\x0c\xa4\x46\x02\x23\x23\xba\x4b\x1a\x1b\x89\x70\x6d\x7f\x4c\x3b\xe5\x7d\x7b\x69\x70\x2d\x16\x8a\xb5\x95\x5e\xe2\x90\x35\x6b\x8c\x4a\x29\xed\x46\x7d\x54\x7e\xc2\x3c\xba\xdf\x28\x6c\xcb\x58\x63\xc6\x67\x9d\xa4\x67\xfc\x93\x24\xa1\x51\xc7\xec\x55\xaa\xc6\xdb\x40\x84\xf8\x27\x26\x82\x5c\xfe\x1a\xa4\x21\xbc\x64\x04\x9f\xb4\x2f\x23\x14\x8f\x9c\x25\xb2\xdc\x30\x04\x37\xc3\x8d\x42\x8a\xa7\x5f\x96"
         }
-    -- Example 8.4
-    , VectorPSS
-        { message = "\xdb\xc5\xf7\x50\xa7\xa1\x4b\xe2\xb9\x3e\x83\x8d\x18\xd1\x4a\x86\x95\xe5\x2e\x8a\xdd\x9c\x0a\xc7\x33\xb8\xf5\x6d\x27\x47\xe5\x29\xa0\xcc\xa5\x32\xdd\x49\xb9\x02\xae\xfe\xd5\x14\x44\x7f\x9e\x81\xd1\x61\x95\xc2\x85\x38\x68\xcb\x9b\x30\xf7\xd0\xd4\x95\xc6\x9d\x01\xb5\xc5\xd5\x0b\x27\x04\x5d\xb3\x86\x6c\x23\x24\xa4\x4a\x11\x0b\x17\x17\x74\x6d\xe4\x57\xd1\xc8\xc4\x5c\x3c\xd2\xa9\x29\x70\xc3\xd5\x96\x32\x05\x5d\x4c\x98\xa4\x1d\x6e\x99\xe2\xa3\xdd\xd5\xf7\xf9\x97\x9a\xb3\xcd\x18\xf3\x75\x05\xd2\x51\x41\xde\x2a\x1b\xff\x17\xb3\xa7\xdc\xe9\x41\x9e\xcc\x38\x5c\xf1\x1d\x72\x84\x0f\x19\x95\x3f\xd0\x50\x92\x51\xf6\xca\xfd\xe2\x89\x3d\x0e\x75\xc7\x81\xba\x7a\x50\x12\xca\x40\x1a\x4f\xa9\x9e\x04\xb3\xc3\x24\x9f\x92\x6d\x5a\xfe\x82\xcc\x87\xda\xb2\x2c\x3c\x1b\x10\x5d\xe4\x8e\x34\xac\xe9\xc9\x12\x4e\x59\x59\x7a\xc7\xeb\xf8"
-        , salt = "\x02\x1f\xdc\xc6\xeb\xb5\xe1\x9b\x1c\xb1\x6e\x9c\x67\xf2\x76\x81\x65\x7f\xe2\x0a"
-        , signature = "\x1e\x24\xe6\xe5\x86\x28\xe5\x17\x50\x44\xa9\xeb\x6d\x83\x7d\x48\xaf\x12\x60\xb0\x52\x0e\x87\x32\x7d\xe7\x89\x7e\xe4\xd5\xb9\xf0\xdf\x0b\xe3\xe0\x9e\xd4\xde\xa8\xc1\x45\x4f\xf3\x42\x3b\xb0\x8e\x17\x93\x24\x5a\x9d\xf8\xbf\x6a\xb3\x96\x8c\x8e\xdd\xc3\xb5\x32\x85\x71\xc7\x7f\x09\x1c\xc5\x78\x57\x69\x12\xdf\xeb\xd1\x64\xb9\xde\x54\x54\xfe\x0b\xe1\xc1\xf6\x38\x5b\x32\x83\x60\xce\x67\xec\x7a\x05\xf6\xe3\x0e\xb4\x5c\x17\xc4\x8a\xc7\x00\x41\xd2\xca\xb6\x7f\x0a\x2a\xe7\xaa\xfd\xcc\x8d\x24\x5e\xa3\x44\x2a\x63\x00\xcc\xc7"
+    , -- Example 8.4
+      VectorPSS
+        { message =
+            "\xdb\xc5\xf7\x50\xa7\xa1\x4b\xe2\xb9\x3e\x83\x8d\x18\xd1\x4a\x86\x95\xe5\x2e\x8a\xdd\x9c\x0a\xc7\x33\xb8\xf5\x6d\x27\x47\xe5\x29\xa0\xcc\xa5\x32\xdd\x49\xb9\x02\xae\xfe\xd5\x14\x44\x7f\x9e\x81\xd1\x61\x95\xc2\x85\x38\x68\xcb\x9b\x30\xf7\xd0\xd4\x95\xc6\x9d\x01\xb5\xc5\xd5\x0b\x27\x04\x5d\xb3\x86\x6c\x23\x24\xa4\x4a\x11\x0b\x17\x17\x74\x6d\xe4\x57\xd1\xc8\xc4\x5c\x3c\xd2\xa9\x29\x70\xc3\xd5\x96\x32\x05\x5d\x4c\x98\xa4\x1d\x6e\x99\xe2\xa3\xdd\xd5\xf7\xf9\x97\x9a\xb3\xcd\x18\xf3\x75\x05\xd2\x51\x41\xde\x2a\x1b\xff\x17\xb3\xa7\xdc\xe9\x41\x9e\xcc\x38\x5c\xf1\x1d\x72\x84\x0f\x19\x95\x3f\xd0\x50\x92\x51\xf6\xca\xfd\xe2\x89\x3d\x0e\x75\xc7\x81\xba\x7a\x50\x12\xca\x40\x1a\x4f\xa9\x9e\x04\xb3\xc3\x24\x9f\x92\x6d\x5a\xfe\x82\xcc\x87\xda\xb2\x2c\x3c\x1b\x10\x5d\xe4\x8e\x34\xac\xe9\xc9\x12\x4e\x59\x59\x7a\xc7\xeb\xf8"
+        , salt =
+            "\x02\x1f\xdc\xc6\xeb\xb5\xe1\x9b\x1c\xb1\x6e\x9c\x67\xf2\x76\x81\x65\x7f\xe2\x0a"
+        , signature =
+            "\x1e\x24\xe6\xe5\x86\x28\xe5\x17\x50\x44\xa9\xeb\x6d\x83\x7d\x48\xaf\x12\x60\xb0\x52\x0e\x87\x32\x7d\xe7\x89\x7e\xe4\xd5\xb9\xf0\xdf\x0b\xe3\xe0\x9e\xd4\xde\xa8\xc1\x45\x4f\xf3\x42\x3b\xb0\x8e\x17\x93\x24\x5a\x9d\xf8\xbf\x6a\xb3\x96\x8c\x8e\xdd\xc3\xb5\x32\x85\x71\xc7\x7f\x09\x1c\xc5\x78\x57\x69\x12\xdf\xeb\xd1\x64\xb9\xde\x54\x54\xfe\x0b\xe1\xc1\xf6\x38\x5b\x32\x83\x60\xce\x67\xec\x7a\x05\xf6\xe3\x0e\xb4\x5c\x17\xc4\x8a\xc7\x00\x41\xd2\xca\xb6\x7f\x0a\x2a\xe7\xaa\xfd\xcc\x8d\x24\x5e\xa3\x44\x2a\x63\x00\xcc\xc7"
         }
-    -- Example 8.5
-    , VectorPSS
-        { message = "\x04\xdc\x25\x1b\xe7\x2e\x88\xe5\x72\x34\x85\xb6\x38\x3a\x63\x7e\x2f\xef\xe0\x76\x60\xc5\x19\xa5\x60\xb8\xbc\x18\xbd\xed\xb8\x6e\xae\x23\x64\xea\x53\xba\x9d\xca\x6e\xb3\xd2\xe7\xd6\xb8\x06\xaf\x42\xb3\xe8\x7f\x29\x1b\x4a\x88\x81\xd5\xbf\x57\x2c\xc9\xa8\x5e\x19\xc8\x6a\xcb\x28\xf0\x98\xf9\xda\x03\x83\xc5\x66\xd3\xc0\xf5\x8c\xfd\x8f\x39\x5d\xcf\x60\x2e\x5c\xd4\x0e\x8c\x71\x83\xf7\x14\x99\x6e\x22\x97\xef"
-        , salt = "\xc5\x58\xd7\x16\x7c\xbb\x45\x08\xad\xa0\x42\x97\x1e\x71\xb1\x37\x7e\xea\x42\x69"
-        , signature = "\x33\x34\x1b\xa3\x57\x6a\x13\x0a\x50\xe2\xa5\xcf\x86\x79\x22\x43\x88\xd5\x69\x3f\x5a\xcc\xc2\x35\xac\x95\xad\xd6\x8e\x5e\xb1\xee\xc3\x16\x66\xd0\xca\x7a\x1c\xda\x6f\x70\xa1\xaa\x76\x2c\x05\x75\x2a\x51\x95\x0c\xdb\x8a\xf3\xc5\x37\x9f\x18\xcf\xe6\xb5\xbc\x55\xa4\x64\x82\x26\xa1\x5e\x91\x2e\xf1\x9a\xd7\x7a\xde\xea\x91\x1d\x67\xcf\xef\xd6\x9b\xa4\x3f\xa4\x11\x91\x35\xff\x64\x21\x17\xba\x98\x5a\x7e\x01\x00\x32\x5e\x95\x19\xf1\xca\x6a\x92\x16\xbd\xa0\x55\xb5\x78\x50\x15\x29\x11\x25\xe9\x0d\xcd\x07\xa2\xca\x96\x73\xee"
+    , -- Example 8.5
+      VectorPSS
+        { message =
+            "\x04\xdc\x25\x1b\xe7\x2e\x88\xe5\x72\x34\x85\xb6\x38\x3a\x63\x7e\x2f\xef\xe0\x76\x60\xc5\x19\xa5\x60\xb8\xbc\x18\xbd\xed\xb8\x6e\xae\x23\x64\xea\x53\xba\x9d\xca\x6e\xb3\xd2\xe7\xd6\xb8\x06\xaf\x42\xb3\xe8\x7f\x29\x1b\x4a\x88\x81\xd5\xbf\x57\x2c\xc9\xa8\x5e\x19\xc8\x6a\xcb\x28\xf0\x98\xf9\xda\x03\x83\xc5\x66\xd3\xc0\xf5\x8c\xfd\x8f\x39\x5d\xcf\x60\x2e\x5c\xd4\x0e\x8c\x71\x83\xf7\x14\x99\x6e\x22\x97\xef"
+        , salt =
+            "\xc5\x58\xd7\x16\x7c\xbb\x45\x08\xad\xa0\x42\x97\x1e\x71\xb1\x37\x7e\xea\x42\x69"
+        , signature =
+            "\x33\x34\x1b\xa3\x57\x6a\x13\x0a\x50\xe2\xa5\xcf\x86\x79\x22\x43\x88\xd5\x69\x3f\x5a\xcc\xc2\x35\xac\x95\xad\xd6\x8e\x5e\xb1\xee\xc3\x16\x66\xd0\xca\x7a\x1c\xda\x6f\x70\xa1\xaa\x76\x2c\x05\x75\x2a\x51\x95\x0c\xdb\x8a\xf3\xc5\x37\x9f\x18\xcf\xe6\xb5\xbc\x55\xa4\x64\x82\x26\xa1\x5e\x91\x2e\xf1\x9a\xd7\x7a\xde\xea\x91\x1d\x67\xcf\xef\xd6\x9b\xa4\x3f\xa4\x11\x91\x35\xff\x64\x21\x17\xba\x98\x5a\x7e\x01\x00\x32\x5e\x95\x19\xf1\xca\x6a\x92\x16\xbd\xa0\x55\xb5\x78\x50\x15\x29\x11\x25\xe9\x0d\xcd\x07\xa2\xca\x96\x73\xee"
         }
-    -- Example 8.6
-    , VectorPSS
-        { message = "\x0e\xa3\x7d\xf9\xa6\xfe\xa4\xa8\xb6\x10\x37\x3c\x24\xcf\x39\x0c\x20\xfa\x6e\x21\x35\xc4\x00\xc8\xa3\x4f\x5c\x18\x3a\x7e\x8e\xa4\xc9\xae\x09\x0e\xd3\x17\x59\xf4\x2d\xc7\x77\x19\xcc\xa4\x00\xec\xdc\xc5\x17\xac\xfc\x7a\xc6\x90\x26\x75\xb2\xef\x30\xc5\x09\x66\x5f\x33\x21\x48\x2f\xc6\x9a\x9f\xb5\x70\xd1\x5e\x01\xc8\x45\xd0\xd8\xe5\x0d\x2a\x24\xcb\xf1\xcf\x0e\x71\x49\x75\xa5\xdb\x7b\x18\xd9\xe9\xe9\xcb\x91\xb5\xcb\x16\x86\x90\x60\xed\x18\xb7\xb5\x62\x45\x50\x3f\x0c\xaf\x90\x35\x2b\x8d\xe8\x1c\xb5\xa1\xd9\xc6\x33\x60\x92\xf0\xcd"
-        , salt = "\x76\xfd\x4e\x64\xfd\xc9\x8e\xb9\x27\xa0\x40\x3e\x35\xa0\x84\xe7\x6b\xa9\xf9\x2a"
-        , signature = "\x1e\xd1\xd8\x48\xfb\x1e\xdb\x44\x12\x9b\xd9\xb3\x54\x79\x5a\xf9\x7a\x06\x9a\x7a\x00\xd0\x15\x10\x48\x59\x3e\x0c\x72\xc3\x51\x7f\xf9\xff\x2a\x41\xd0\xcb\x5a\x0a\xc8\x60\xd7\x36\xa1\x99\x70\x4f\x7c\xb6\xa5\x39\x86\xa8\x8b\xbd\x8a\xbc\xc0\x07\x6a\x2c\xe8\x47\x88\x00\x31\x52\x5d\x44\x9d\xa2\xac\x78\x35\x63\x74\xc5\x36\xe3\x43\xfa\xa7\xcb\xa4\x2a\x5a\xaa\x65\x06\x08\x77\x91\xc0\x6a\x8e\x98\x93\x35\xae\xd1\x9b\xfa\xb2\xd5\xe6\x7e\x27\xfb\x0c\x28\x75\xaf\x89\x6c\x21\xb6\xe8\xe7\x30\x9d\x04\xe4\xf6\x72\x7e\x69\x46\x3e"
+    , -- Example 8.6
+      VectorPSS
+        { message =
+            "\x0e\xa3\x7d\xf9\xa6\xfe\xa4\xa8\xb6\x10\x37\x3c\x24\xcf\x39\x0c\x20\xfa\x6e\x21\x35\xc4\x00\xc8\xa3\x4f\x5c\x18\x3a\x7e\x8e\xa4\xc9\xae\x09\x0e\xd3\x17\x59\xf4\x2d\xc7\x77\x19\xcc\xa4\x00\xec\xdc\xc5\x17\xac\xfc\x7a\xc6\x90\x26\x75\xb2\xef\x30\xc5\x09\x66\x5f\x33\x21\x48\x2f\xc6\x9a\x9f\xb5\x70\xd1\x5e\x01\xc8\x45\xd0\xd8\xe5\x0d\x2a\x24\xcb\xf1\xcf\x0e\x71\x49\x75\xa5\xdb\x7b\x18\xd9\xe9\xe9\xcb\x91\xb5\xcb\x16\x86\x90\x60\xed\x18\xb7\xb5\x62\x45\x50\x3f\x0c\xaf\x90\x35\x2b\x8d\xe8\x1c\xb5\xa1\xd9\xc6\x33\x60\x92\xf0\xcd"
+        , salt =
+            "\x76\xfd\x4e\x64\xfd\xc9\x8e\xb9\x27\xa0\x40\x3e\x35\xa0\x84\xe7\x6b\xa9\xf9\x2a"
+        , signature =
+            "\x1e\xd1\xd8\x48\xfb\x1e\xdb\x44\x12\x9b\xd9\xb3\x54\x79\x5a\xf9\x7a\x06\x9a\x7a\x00\xd0\x15\x10\x48\x59\x3e\x0c\x72\xc3\x51\x7f\xf9\xff\x2a\x41\xd0\xcb\x5a\x0a\xc8\x60\xd7\x36\xa1\x99\x70\x4f\x7c\xb6\xa5\x39\x86\xa8\x8b\xbd\x8a\xbc\xc0\x07\x6a\x2c\xe8\x47\x88\x00\x31\x52\x5d\x44\x9d\xa2\xac\x78\x35\x63\x74\xc5\x36\xe3\x43\xfa\xa7\xcb\xa4\x2a\x5a\xaa\x65\x06\x08\x77\x91\xc0\x6a\x8e\x98\x93\x35\xae\xd1\x9b\xfa\xb2\xd5\xe6\x7e\x27\xfb\x0c\x28\x75\xaf\x89\x6c\x21\xb6\xe8\xe7\x30\x9d\x04\xe4\xf6\x72\x7e\x69\x46\x3e"
         }
     ]
 
 doSignTest key i vector = testCase (show i) (Right (signature vector) @=? actual)
-    where actual = PSS.signWithSalt (salt vector) Nothing PSS.defaultPSSParamsSHA1 key (message vector)
+  where
+    actual =
+        PSS.signWithSalt
+            (salt vector)
+            Nothing
+            PSS.defaultPSSParamsSHA1
+            key
+            (message vector)
 
 doVerifyTest key i vector = testCase (show i) (True @=? actual)
-    where actual = PSS.verify PSS.defaultPSSParamsSHA1 (private_pub key) (message vector) (signature vector)
+  where
+    actual =
+        PSS.verify
+            PSS.defaultPSSParamsSHA1
+            (private_pub key)
+            (message vector)
+            (signature vector)
 
-pssTests = testGroup "RSA-PSS"
-    [ testGroup "signature internal"
-        [ doSignTest rsaKeyInt katZero vectorInt ]
-    , testGroup "verify internal"
-        [ doVerifyTest rsaKeyInt katZero vectorInt ]
-    , testGroup "signature key 1024" $ zipWith (doSignTest rsaKey1) [katZero..] vectorsKey1
-    , testGroup "verify key 1024" $ zipWith (doVerifyTest rsaKey1) [katZero..] vectorsKey1
-    , testGroup "signature key 1025" $ zipWith (doSignTest rsaKey2) [katZero..] vectorsKey2
-    , testGroup "verify key 1025" $ zipWith (doVerifyTest rsaKey2) [katZero..] vectorsKey2
-    , testGroup "signature key 1026" $ zipWith (doSignTest rsaKey3) [katZero..] vectorsKey3
-    , testGroup "verify key 1026" $ zipWith (doVerifyTest rsaKey3) [katZero..] vectorsKey3
-    , testGroup "signature key 1031" $ zipWith (doSignTest rsaKey8) [katZero..] vectorsKey8
-    , testGroup "verify key 1031" $ zipWith (doVerifyTest rsaKey8) [katZero..] vectorsKey8
-    ]
+pssTests =
+    testGroup
+        "RSA-PSS"
+        [ testGroup
+            "signature internal"
+            [doSignTest rsaKeyInt katZero vectorInt]
+        , testGroup
+            "verify internal"
+            [doVerifyTest rsaKeyInt katZero vectorInt]
+        , testGroup "signature key 1024" $
+            zipWith (doSignTest rsaKey1) [katZero ..] vectorsKey1
+        , testGroup "verify key 1024" $
+            zipWith (doVerifyTest rsaKey1) [katZero ..] vectorsKey1
+        , testGroup "signature key 1025" $
+            zipWith (doSignTest rsaKey2) [katZero ..] vectorsKey2
+        , testGroup "verify key 1025" $
+            zipWith (doVerifyTest rsaKey2) [katZero ..] vectorsKey2
+        , testGroup "signature key 1026" $
+            zipWith (doSignTest rsaKey3) [katZero ..] vectorsKey3
+        , testGroup "verify key 1026" $
+            zipWith (doVerifyTest rsaKey3) [katZero ..] vectorsKey3
+        , testGroup "signature key 1031" $
+            zipWith (doSignTest rsaKey8) [katZero ..] vectorsKey8
+        , testGroup "verify key 1031" $
+            zipWith (doVerifyTest rsaKey8) [katZero ..] vectorsKey8
+        ]
diff --git a/tests/KAT_PubKey/RSA.hs b/tests/KAT_PubKey/RSA.hs
--- a/tests/KAT_PubKey/RSA.hs
+++ b/tests/KAT_PubKey/RSA.hs
@@ -1,102 +1,130 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_PubKey.RSA (rsaTests) where
 
-import qualified Crypto.PubKey.RSA        as RSA
+import Crypto.Hash
+import qualified Crypto.PubKey.RSA as RSA
 import qualified Crypto.PubKey.RSA.PKCS15 as RSA
-import           Crypto.Hash
-
-import           Imports
+import Data.Either
 
-import           Data.Either (isRight)
+import Imports
 
 data VectorRSA = VectorRSA
     { size :: Int
-    , msg  :: ByteString
-    , n    :: Integer
-    , e    :: Integer
-    , d    :: Integer
-    , p    :: Integer
-    , q    :: Integer
-    , dP   :: Integer
-    , dQ   :: Integer
+    , msg :: ByteString
+    , n :: Integer
+    , e :: Integer
+    , d :: Integer
+    , p :: Integer
+    , q :: Integer
+    , dP :: Integer
+    , dQ :: Integer
     , qinv :: Integer
-    , sig  :: Either RSA.Error ByteString
+    , sig :: Either RSA.Error ByteString
     }
 
+vectorsSHA1 :: [VectorRSA]
 vectorsSHA1 =
     [ VectorRSA
         { size = 2048 `div` 8
-        , msg  = "The quick brown fox jumps over the lazy dog"
-        , n    = 0x00c896c245fcca81775346c5f4f958229cab1aee08196dab4ee5959018b856aab93e4486f37a32da1a6804403c88473ecf9f1b9266fc682400d45329b6ec195710c98d9ba728bc09d767e7e9d9b8b102c3b7e7529b87f649a2a5ebe165da21863ec7842de600a834a8be2227bc989145b52f84ba685d45484a3d530745598a5d8a9e7551b3278bf139a770929f776aed5d43559205fe937df93eeb8ff3fb3f2ce22d4b8a5c17aeafd19758ac5e6251df09ef6a2858e8558a7f476dde4efe859ff2fcb97767614563033fd1d2d300196b1abf256f7badb16c17def3804946d1bf9cd51760176b41bbd506b44ff2bfe5bcd5052180da3cfbbc6cd6f662c06a8baed9
-        , e    = 0x10001
-        , d    = 0x58aa533bae8f310536d95cdd796e5cf655a7f4b9bdcbbd62859743f7b95c0de10e462a44ebaa18c07d640ba4f6344fee648d427ca56bbf2662b45407187be70173a655bc6104257182eb7f720ef2a79f2de6619c804ffca299a7179df6fac4a57179daf4052c550295f0f111ab7ae38e406ff219f9c88b38cdbcaac51bdc4e961361b87e100d168fc08b298626a806b3bfeaa9579f400bbe6e3e6e4ae9b27446e1c5ce8c10c848b9ad7b6ed3a6b3871ad6a1a88af24e581da054845c197e8bae1582858410087c1180c4f0cc61689abfd0f61b8031910f3b3779e11a7fbe823d9a704c63c313f78c994975de834ee9ead5faf6c18b3e4248c51ba307776bf845
-        , p    = 0x00f85bfcfe55af59445f21f67ab1d8617d1f84360556eeb660d5c466f29e4d2228f9cc3fde4c594ea97069a19c666b68b6d905b65738ae63de6c11f9181ee9262313e5165591651bb3abec192abbc8c3694550bcffa451a2e2d1976bf3ecbc4480354f8d8646133298156aaa626b8807c5295850f93686400835466b6a5ccec61b
-        , q    = 0x00cec28b22b1d37c6c60d25e9747cb1bebd1270f0306db56ed8533f392d6a0cfe6b3dde13789758cf89febac214ba96667e46599f89ca210dced550ca6092a854ff95dff80ea48ff1a83455f4bb93f2ececa782da03b85a789239e8be5264130628724ceab57c8f76e4c7e822bf4fbf334c7d32610bec65047433e0e3b636afe1b
-        , dP   = 0x52fe0a50c339514f33ab19be6e67ac4c2f97f2a55e236ef674f8a89e329ffbe64d731f749d76ca7e7c7e0fef3f9a6ce78d260784a600408736fdda8b60e8f0419088612a3ee7d695f7c171b78200d8abf8e9bdfe7f5e785beb45fa610c9eed151abb76c383ef2e5cfbeb24fcb68a426e741e7b108c53d859e5d39e5970a1f839
-        , dQ   = 0x39ef91853b47038a6ae707d2642fa9b73e782f60adbf307085eeb4c5e496532b56234a4481a40ac870275da846c74506bf9d28b3dd501c618baf5548013185018fe2a301c0a48bb726297e367dc6129ba7685d8094ad32f0dea64295074f24fbb6dabd7e8daea686a5b09d512be89d91a09cae01eb332eb389480e3cddf2d119
-        , qinv = 0x09ce1fa29008ef4b9798e5b8ec213dbdfec4fab4403ebf4b8786ad401ef33bc880c40a990b0826f72415192a206a504b27d2ba45ca555706200ea8e7a9b42d4077e9e6e0d80d4144966c53a36d23d30d987322dcc0013efe8df3b6b5914a2ceefc22cc5de6d569731794e9894f18f11d36a79558dc4c3ae5db1ce9bd05e7bf2e
-        , sig  = Right "\x56\x66\x99\x0f\xd4\xea\x2b\xe0\x6d\x46\x3b\x10\x99\x5b\x06\x32\x5e\xec\x29\xfe\xa4\x63\x4d\x54\xf6\x31\x74\x5d\x01\x5a\x67\x09\x2e\xa7\x02\x8a\x48\x00\x3c\x0d\xef\x04\xe7\x52\x46\xe0\xfa\xb1\x42\x26\x89\xe7\xec\x25\x44\x76\xa0\x86\x33\xb0\xbe\x22\x17\x88\x9b\x18\x4d\x3e\xc2\x9b\xd4\x61\x2b\x9e\xde\x08\x56\xf8\xd5\xee\xb8\x38\xf4\x3d\xda\x9a\xbb\x34\x58\x87\x71\x1d\x1a\x7e\xc7\x3d\x46\x39\x01\x79\x29\x8b\xa4\xcd\xce\xd7\xab\xcb\x2e\x94\x5c\xfd\x54\xcc\xef\x80\x31\xfc\x5e\x8f\xc2\x4d\x76\x1e\x4c\xbc\x50\x7a\x9b\x08\xae\x85\xeb\x6a\xe0\x80\xdc\xff\x60\x13\xb0\x31\x94\x14\x9d\x8f\x9f\x48\x38\xcf\x4c\x82\x9d\x3b\x68\xc6\xe4\xe9\x5d\x94\x74\xa2\xac\x1f\xb9\x84\x41\x86\x11\xeb\x2c\x50\x64\xd7\x00\xe0\x85\x21\x5a\xd7\xae\x9b\x4c\x8e\x6a\x92\x97\xac\xcc\xb8\x38\x4f\x41\xb9\x3d\xa9\xfe\x69\x8b\x04\x81\xad\xfb\x0f\x49\x74\xfe\x26\x9c\x86\x0c\xf3\xd1\x8e\xa1\xb5\xaf\xef\x85\x3d\xfe\xd0\x7c\xcf\x18\xe4\x0f\x14\x99\xea\x93\x61\x79\x16\xbf\x38\xac\xa2\xa2\xac\xac\x2d\xae\x21\x85\x71\x94\xda\x5d\xa1\x82\xa8\x76\x82\xe5\x2f"
+        , msg = "The quick brown fox jumps over the lazy dog"
+        , n =
+            0x00c896c245fcca81775346c5f4f958229cab1aee08196dab4ee5959018b856aab93e4486f37a32da1a6804403c88473ecf9f1b9266fc682400d45329b6ec195710c98d9ba728bc09d767e7e9d9b8b102c3b7e7529b87f649a2a5ebe165da21863ec7842de600a834a8be2227bc989145b52f84ba685d45484a3d530745598a5d8a9e7551b3278bf139a770929f776aed5d43559205fe937df93eeb8ff3fb3f2ce22d4b8a5c17aeafd19758ac5e6251df09ef6a2858e8558a7f476dde4efe859ff2fcb97767614563033fd1d2d300196b1abf256f7badb16c17def3804946d1bf9cd51760176b41bbd506b44ff2bfe5bcd5052180da3cfbbc6cd6f662c06a8baed9
+        , e = 0x10001
+        , d =
+            0x58aa533bae8f310536d95cdd796e5cf655a7f4b9bdcbbd62859743f7b95c0de10e462a44ebaa18c07d640ba4f6344fee648d427ca56bbf2662b45407187be70173a655bc6104257182eb7f720ef2a79f2de6619c804ffca299a7179df6fac4a57179daf4052c550295f0f111ab7ae38e406ff219f9c88b38cdbcaac51bdc4e961361b87e100d168fc08b298626a806b3bfeaa9579f400bbe6e3e6e4ae9b27446e1c5ce8c10c848b9ad7b6ed3a6b3871ad6a1a88af24e581da054845c197e8bae1582858410087c1180c4f0cc61689abfd0f61b8031910f3b3779e11a7fbe823d9a704c63c313f78c994975de834ee9ead5faf6c18b3e4248c51ba307776bf845
+        , p =
+            0x00f85bfcfe55af59445f21f67ab1d8617d1f84360556eeb660d5c466f29e4d2228f9cc3fde4c594ea97069a19c666b68b6d905b65738ae63de6c11f9181ee9262313e5165591651bb3abec192abbc8c3694550bcffa451a2e2d1976bf3ecbc4480354f8d8646133298156aaa626b8807c5295850f93686400835466b6a5ccec61b
+        , q =
+            0x00cec28b22b1d37c6c60d25e9747cb1bebd1270f0306db56ed8533f392d6a0cfe6b3dde13789758cf89febac214ba96667e46599f89ca210dced550ca6092a854ff95dff80ea48ff1a83455f4bb93f2ececa782da03b85a789239e8be5264130628724ceab57c8f76e4c7e822bf4fbf334c7d32610bec65047433e0e3b636afe1b
+        , dP =
+            0x52fe0a50c339514f33ab19be6e67ac4c2f97f2a55e236ef674f8a89e329ffbe64d731f749d76ca7e7c7e0fef3f9a6ce78d260784a600408736fdda8b60e8f0419088612a3ee7d695f7c171b78200d8abf8e9bdfe7f5e785beb45fa610c9eed151abb76c383ef2e5cfbeb24fcb68a426e741e7b108c53d859e5d39e5970a1f839
+        , dQ =
+            0x39ef91853b47038a6ae707d2642fa9b73e782f60adbf307085eeb4c5e496532b56234a4481a40ac870275da846c74506bf9d28b3dd501c618baf5548013185018fe2a301c0a48bb726297e367dc6129ba7685d8094ad32f0dea64295074f24fbb6dabd7e8daea686a5b09d512be89d91a09cae01eb332eb389480e3cddf2d119
+        , qinv =
+            0x09ce1fa29008ef4b9798e5b8ec213dbdfec4fab4403ebf4b8786ad401ef33bc880c40a990b0826f72415192a206a504b27d2ba45ca555706200ea8e7a9b42d4077e9e6e0d80d4144966c53a36d23d30d987322dcc0013efe8df3b6b5914a2ceefc22cc5de6d569731794e9894f18f11d36a79558dc4c3ae5db1ce9bd05e7bf2e
+        , sig =
+            Right
+                "\x56\x66\x99\x0f\xd4\xea\x2b\xe0\x6d\x46\x3b\x10\x99\x5b\x06\x32\x5e\xec\x29\xfe\xa4\x63\x4d\x54\xf6\x31\x74\x5d\x01\x5a\x67\x09\x2e\xa7\x02\x8a\x48\x00\x3c\x0d\xef\x04\xe7\x52\x46\xe0\xfa\xb1\x42\x26\x89\xe7\xec\x25\x44\x76\xa0\x86\x33\xb0\xbe\x22\x17\x88\x9b\x18\x4d\x3e\xc2\x9b\xd4\x61\x2b\x9e\xde\x08\x56\xf8\xd5\xee\xb8\x38\xf4\x3d\xda\x9a\xbb\x34\x58\x87\x71\x1d\x1a\x7e\xc7\x3d\x46\x39\x01\x79\x29\x8b\xa4\xcd\xce\xd7\xab\xcb\x2e\x94\x5c\xfd\x54\xcc\xef\x80\x31\xfc\x5e\x8f\xc2\x4d\x76\x1e\x4c\xbc\x50\x7a\x9b\x08\xae\x85\xeb\x6a\xe0\x80\xdc\xff\x60\x13\xb0\x31\x94\x14\x9d\x8f\x9f\x48\x38\xcf\x4c\x82\x9d\x3b\x68\xc6\xe4\xe9\x5d\x94\x74\xa2\xac\x1f\xb9\x84\x41\x86\x11\xeb\x2c\x50\x64\xd7\x00\xe0\x85\x21\x5a\xd7\xae\x9b\x4c\x8e\x6a\x92\x97\xac\xcc\xb8\x38\x4f\x41\xb9\x3d\xa9\xfe\x69\x8b\x04\x81\xad\xfb\x0f\x49\x74\xfe\x26\x9c\x86\x0c\xf3\xd1\x8e\xa1\xb5\xaf\xef\x85\x3d\xfe\xd0\x7c\xcf\x18\xe4\x0f\x14\x99\xea\x93\x61\x79\x16\xbf\x38\xac\xa2\xa2\xac\xac\x2d\xae\x21\x85\x71\x94\xda\x5d\xa1\x82\xa8\x76\x82\xe5\x2f"
         }
     , VectorRSA
         { size = 360 `div` 8
-        , msg  = "The quick brown fox jumps over the lazy dog"
-        , n    = 0x00bc2d7481c83c8be55da4caeaf1a30dbf9a1226ba7443c0a66213180d3eb8e29c3162401b7be067dff8f571a8eb
-        , e    = 0x10001
-        , d    = 0x726fb62d82c707507a2d5055a6934136270d28ce350c3a36d89066e26fb54f5b33da0bc9a05c2084f2b39be4e1
-        , p    = 0x0e3ff89e1f95a461c9f5ee480fd7b13529a225f3ee07fb
-        , q    = 0x0d349ebc89329b493c03451ad20155de9775df55c55fd1
-        , dP   = 0x00943adef9fb93a561967bab33f198c2c7414e777df997
-        , dQ   = 0x078de99ceb5392f7f327dfb97717a27ae2e4606dddaa71
+        , msg = "The quick brown fox jumps over the lazy dog"
+        , n =
+            0x00bc2d7481c83c8be55da4caeaf1a30dbf9a1226ba7443c0a66213180d3eb8e29c3162401b7be067dff8f571a8eb
+        , e = 0x10001
+        , d =
+            0x726fb62d82c707507a2d5055a6934136270d28ce350c3a36d89066e26fb54f5b33da0bc9a05c2084f2b39be4e1
+        , p = 0x0e3ff89e1f95a461c9f5ee480fd7b13529a225f3ee07fb
+        , q = 0x0d349ebc89329b493c03451ad20155de9775df55c55fd1
+        , dP = 0x00943adef9fb93a561967bab33f198c2c7414e777df997
+        , dQ = 0x078de99ceb5392f7f327dfb97717a27ae2e4606dddaa71
         , qinv = 0x0c54d59eaa029844fb3fe33a180161590b1cb103cc668e
-        , sig  = Left RSA.SignatureTooLong
+        , sig = Left RSA.SignatureTooLong
         }
     , VectorRSA
         { size = 368 `div` 8
-        , msg  = "The quick brown fox jumps over the lazy dog"
-        , n    = 0x009cff2fd20246e390d6860b48a3926e83086d1386f7147e9f195623cf8f18546ceb20d428b77e0748864c8f611cb7
-        , e    = 0x10001
-        , d    = 0x0097706cbf6624dd448c3a36ce35c27d49762a4948ca33804178d2ff826f8d336aaed622801c8d76d442be371da841
-        , p    = 0x00d12519f81441069ab1a86c38e0065e9578a46e655d5a17
-        , q    = 0x00c02b485ac3ee241d57b6b282f830d7d5bf6f4de75c1661
-        , dP   = 0x00a1af4611444f34f4d88d7504cf23fd711e70382c42ec07
-        , dQ   = 0x04226a4219a90bf9dda33e9ff6bb0649c0fea20c723cc1
+        , msg = "The quick brown fox jumps over the lazy dog"
+        , n =
+            0x009cff2fd20246e390d6860b48a3926e83086d1386f7147e9f195623cf8f18546ceb20d428b77e0748864c8f611cb7
+        , e = 0x10001
+        , d =
+            0x0097706cbf6624dd448c3a36ce35c27d49762a4948ca33804178d2ff826f8d336aaed622801c8d76d442be371da841
+        , p = 0x00d12519f81441069ab1a86c38e0065e9578a46e655d5a17
+        , q = 0x00c02b485ac3ee241d57b6b282f830d7d5bf6f4de75c1661
+        , dP = 0x00a1af4611444f34f4d88d7504cf23fd711e70382c42ec07
+        , dQ = 0x04226a4219a90bf9dda33e9ff6bb0649c0fea20c723cc1
         , qinv = 0x5dd87bf3c1e295dcc8602859a7cd74f05a2fe91a9d5877
-        , sig  = Right "\x51\xe4\xdd\x98\xee\xd5\x06\xef\x7a\xa5\x3c\xaf\x29\x33\xa4\x91\xfa\x8b\xb8\x09\xcf\x3e\xa1\x64\x92\x71\xad\x7b\x3a\x83\xb2\xa0\x77\x94\x4e\x59\xdf\x69\x58\x2e\xc8\x8d\xa0\x70\xfe\x7d"
+        , sig =
+            Right
+                "\x51\xe4\xdd\x98\xee\xd5\x06\xef\x7a\xa5\x3c\xaf\x29\x33\xa4\x91\xfa\x8b\xb8\x09\xcf\x3e\xa1\x64\x92\x71\xad\x7b\x3a\x83\xb2\xa0\x77\x94\x4e\x59\xdf\x69\x58\x2e\xc8\x8d\xa0\x70\xfe\x7d"
         }
     ]
 
 vectorToPrivate :: VectorRSA -> RSA.PrivateKey
-vectorToPrivate vector = RSA.PrivateKey
-    { RSA.private_pub  = vectorToPublic vector
-    , RSA.private_d    = d vector
-    , RSA.private_p    = p vector
-    , RSA.private_q    = q vector
-    , RSA.private_dP   = dP vector
-    , RSA.private_dQ   = dQ vector
-    , RSA.private_qinv = qinv vector
-    }
+vectorToPrivate vector =
+    RSA.PrivateKey
+        { RSA.private_pub = vectorToPublic vector
+        , RSA.private_d = d vector
+        , RSA.private_p = p vector
+        , RSA.private_q = q vector
+        , RSA.private_dP = dP vector
+        , RSA.private_dQ = dQ vector
+        , RSA.private_qinv = qinv vector
+        }
 
 vectorToPublic :: VectorRSA -> RSA.PublicKey
-vectorToPublic vector = RSA.PublicKey
-    { RSA.public_size = size vector
-    , RSA.public_n    = n vector
-    , RSA.public_e    = e vector
-    }
+vectorToPublic vector =
+    RSA.PublicKey
+        { RSA.public_size = size vector
+        , RSA.public_n = n vector
+        , RSA.public_e = e vector
+        }
 
 vectorHasSignature :: VectorRSA -> Bool
 vectorHasSignature = isRight . sig
 
+doSignatureTest :: Show a => a -> VectorRSA -> TestTree
 doSignatureTest i vector = testCase (show i) (expected @=? actual)
-    where expected = sig vector
-          actual   = RSA.sign Nothing (Just SHA1) (vectorToPrivate vector) (msg vector)
+  where
+    expected = sig vector
+    actual = RSA.sign Nothing (Just SHA1) (vectorToPrivate vector) (msg vector)
 
+doVerifyTest :: Show a => a -> VectorRSA -> TestTree
 doVerifyTest i vector = testCase (show i) (True @=? actual)
-    where actual = RSA.verify (Just SHA1) (vectorToPublic vector) (msg vector) bs
-          Right bs = sig vector
+  where
+    actual = RSA.verify (Just SHA1) (vectorToPublic vector) (msg vector) bs
+    bs = fromRight (error "doVerifyTest") $ sig vector
 
-rsaTests = testGroup "RSA"
-    [ testGroup "SHA1"
-        [ testGroup "signature" $ zipWith doSignatureTest [katZero..] vectorsSHA1
-        , testGroup "verify" $ zipWith doVerifyTest [katZero..] $ filter vectorHasSignature vectorsSHA1
+rsaTests :: TestTree
+rsaTests =
+    testGroup
+        "RSA"
+        [ testGroup
+            "SHA1"
+            [ testGroup "signature" $ zipWith doSignatureTest [katZero ..] vectorsSHA1
+            , testGroup "verify" $
+                zipWith doVerifyTest [katZero ..] $
+                    filter vectorHasSignature vectorsSHA1
+            ]
         ]
-    ]
diff --git a/tests/KAT_PubKey/Rabin.hs b/tests/KAT_PubKey/Rabin.hs
--- a/tests/KAT_PubKey/Rabin.hs
+++ b/tests/KAT_PubKey/Rabin.hs
@@ -1,47 +1,67 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_PubKey.Rabin (rabinTests) where
 
 import qualified Data.ByteString as B
 
-import           Crypto.Hash
-import           Crypto.Number.Serialize (os2ip)
+import Crypto.Hash
+import Crypto.Number.Serialize (os2ip)
 import qualified Crypto.PubKey.Rabin.Basic as BRabin
 import qualified Crypto.PubKey.Rabin.Modified as MRabin
 import qualified Crypto.PubKey.Rabin.OAEP as OAEP
 import qualified Crypto.PubKey.Rabin.RW as RW
 
-import           Imports
+import Imports
 
-basicRabinKey = BRabin.PrivateKey
-    { BRabin.private_pub = BRabin.PublicKey
-        { BRabin.public_n = 0xc9c4b0df9db989d93df4137fc2de2a9cee2610523f7a450ecbbf252babe98fba2f8e389c3e420c081e18f584c5746ca43f77f6af1fc79161f8bf8fbcb9564779986ecbe656dd16740cb8e399c33ff1dcc679e73c9c98a58c65a8673b7de57290a2d3191cb27e29d627f7ec6e874b1406051ffe9181e4d90d1b487b100ad30685 
-        , BRabin.public_size = 128
+basicRabinKey =
+    BRabin.PrivateKey
+        { BRabin.private_pub =
+            BRabin.PublicKey
+                { BRabin.public_n =
+                    0xc9c4b0df9db989d93df4137fc2de2a9cee2610523f7a450ecbbf252babe98fba2f8e389c3e420c081e18f584c5746ca43f77f6af1fc79161f8bf8fbcb9564779986ecbe656dd16740cb8e399c33ff1dcc679e73c9c98a58c65a8673b7de57290a2d3191cb27e29d627f7ec6e874b1406051ffe9181e4d90d1b487b100ad30685
+                , BRabin.public_size = 128
+                }
+        , BRabin.private_p =
+            0xe071f231ab5912285a1f8db199795f5efdea4c32f646a3436eaec091ba853a3092216f26b539bbac1fe2ab2e4fbb20aad272a434a1e909bf6d3028aecae2a7b7
+        , BRabin.private_q =
+            0xe6229470dc7da58bfcd962f1b3ddcf52304efbfb91d31c8ed84dbae2380c1ad2e338a523b4250863a689b3f262f949bd7a9f1a603c36634bb932dd71bf5daba3
+        , BRabin.private_a =
+            0x65956653f711a63b776ce45862d4cd78f1ad7b1f8ed118bb8b5ea5fffd59762da5dc7c5298e236a8e45d5c93477cbc51f214b1cd1a4980eda859c1cb05e55666
+        , BRabin.private_b =
+            -0x63126dd9c5d6b5215f62012885570e1306b6a47ec1c46553f3b13ceae869149d14544438dbb976800cd62fbb52266f9a6405bc91f192a462c974bc8a6f832e03
         }
-    , BRabin.private_p = 0xe071f231ab5912285a1f8db199795f5efdea4c32f646a3436eaec091ba853a3092216f26b539bbac1fe2ab2e4fbb20aad272a434a1e909bf6d3028aecae2a7b7
-    , BRabin.private_q = 0xe6229470dc7da58bfcd962f1b3ddcf52304efbfb91d31c8ed84dbae2380c1ad2e338a523b4250863a689b3f262f949bd7a9f1a603c36634bb932dd71bf5daba3
-    , BRabin.private_a = 0x65956653f711a63b776ce45862d4cd78f1ad7b1f8ed118bb8b5ea5fffd59762da5dc7c5298e236a8e45d5c93477cbc51f214b1cd1a4980eda859c1cb05e55666
-    , BRabin.private_b = -0x63126dd9c5d6b5215f62012885570e1306b6a47ec1c46553f3b13ceae869149d14544438dbb976800cd62fbb52266f9a6405bc91f192a462c974bc8a6f832e03
-    }
 
-modifiedRabinKey = MRabin.PrivateKey
-    { MRabin.private_pub = MRabin.PublicKey
-        { MRabin.public_n = 0x9461a6e7c55cb610f20fd9af5d642404a63332a8d7c4fe7aa559cbcaec691e7216eed5d9322cb6a8619c220a0241b44e0d0a7cefda01fb84e59722b4e842ab5e190d214424bbdfed6d523426fc57a28045dfbb6e8159123077c542c0278ee2daf2d8993e286bf709a10a948da6b13008441581a22233f0ad3d5ebc5858ff7be5 
-        , MRabin.public_size = 128
+modifiedRabinKey =
+    MRabin.PrivateKey
+        { MRabin.private_pub =
+            MRabin.PublicKey
+                { MRabin.public_n =
+                    0x9461a6e7c55cb610f20fd9af5d642404a63332a8d7c4fe7aa559cbcaec691e7216eed5d9322cb6a8619c220a0241b44e0d0a7cefda01fb84e59722b4e842ab5e190d214424bbdfed6d523426fc57a28045dfbb6e8159123077c542c0278ee2daf2d8993e286bf709a10a948da6b13008441581a22233f0ad3d5ebc5858ff7be5
+                , MRabin.public_size = 128
+                }
+        , MRabin.private_p =
+            0xc401e0ddbe565a8797292389bebb561c35eb019116ba25cc6c865a8d3d7bc599626ddf0bc4f575c22f89144fe99fc3300dd497ec2b7acc0221e729a61756b3f3
+        , MRabin.private_q =
+            0xc1cc0e35f23f5086691a18c755881e3fe6937581948b109f47605b45d055e7b352e19ff729dfb33fbecb1d28b115e590449e5e4e228ab1876d889d3d41d87ec7
+        , MRabin.private_d =
+            0x128c34dcf8ab96c21e41fb35ebac848094c666551af89fcf54ab39795d8d23ce42dddabb264596d50c33844140483689c1a14f9dfb403f709cb2e4569d08556b9267e6460e84c69beda1defabd0285c4852c288b7ac27b78987bd19da337a6b1c7b123476732d9c0f656cc62a17f70e8fe34516cfa85ce6475bddeae9ffa0926
         }
-    , MRabin.private_p = 0xc401e0ddbe565a8797292389bebb561c35eb019116ba25cc6c865a8d3d7bc599626ddf0bc4f575c22f89144fe99fc3300dd497ec2b7acc0221e729a61756b3f3
-    , MRabin.private_q = 0xc1cc0e35f23f5086691a18c755881e3fe6937581948b109f47605b45d055e7b352e19ff729dfb33fbecb1d28b115e590449e5e4e228ab1876d889d3d41d87ec7 
-    , MRabin.private_d = 0x128c34dcf8ab96c21e41fb35ebac848094c666551af89fcf54ab39795d8d23ce42dddabb264596d50c33844140483689c1a14f9dfb403f709cb2e4569d08556b9267e6460e84c69beda1defabd0285c4852c288b7ac27b78987bd19da337a6b1c7b123476732d9c0f656cc62a17f70e8fe34516cfa85ce6475bddeae9ffa0926
-    }
 
-rwKey = RW.PrivateKey
-    { RW.private_pub = RW.PublicKey
-        { RW.public_n = 0x992db4c84564c68d4ee2fe0903d938b41e83bcac48dfe8f2219ccee2ccbdefda4cbeea9f1c98a515c5f39a458f5ea11bca97102aaa3d9ac69e000093024e7b968359287cdf57bdacff5df1893df3539c7e358f037d49b5c6ae7110ab8117220c73b6265987039c2c97078fccacdd3f5a560aff5076fdc3958c532db28ab9a855 
-        , RW.public_size = 128
+rwKey =
+    RW.PrivateKey
+        { RW.private_pub =
+            RW.PublicKey
+                { RW.public_n =
+                    0x992db4c84564c68d4ee2fe0903d938b41e83bcac48dfe8f2219ccee2ccbdefda4cbeea9f1c98a515c5f39a458f5ea11bca97102aaa3d9ac69e000093024e7b968359287cdf57bdacff5df1893df3539c7e358f037d49b5c6ae7110ab8117220c73b6265987039c2c97078fccacdd3f5a560aff5076fdc3958c532db28ab9a855
+                , RW.public_size = 128
+                }
+        , RW.private_p =
+            0xc144dd739c45397d61868ca944a9729a7ad34cf90466c8f5c98a88f5ab5e3288bcfd31d4af1d441d23a756a60abd4cf05c3e0b0053eb150166a327ae31e9347b
+        , RW.private_q =
+            0xcae5a381f25a27ae2c359068753118fc384471cd6027e88b8b910306fb940781261089259a3c569546677aebd268704c767a071dbd4f50cb9f15fe448788856f
+        , RW.private_d =
+            0x1325b69908ac98d1a9dc5fc1207b271683d07795891bfd1e443399dc5997bdfb4997dd53e39314a2b8be7348b1ebd4237952e2055547b358d3c000126049cf729ee5d4f0ea170b902e343a8ef0831900b963ba07a3176088ab2ab095db449d0052150d6be7b5402f459f17c759f6f043b06a5da64cb86bb910d340f7fa28fdce
         }
-    , RW.private_p = 0xc144dd739c45397d61868ca944a9729a7ad34cf90466c8f5c98a88f5ab5e3288bcfd31d4af1d441d23a756a60abd4cf05c3e0b0053eb150166a327ae31e9347b
-    , RW.private_q = 0xcae5a381f25a27ae2c359068753118fc384471cd6027e88b8b910306fb940781261089259a3c569546677aebd268704c767a071dbd4f50cb9f15fe448788856f
-    , RW.private_d = 0x1325b69908ac98d1a9dc5fc1207b271683d07795891bfd1e443399dc5997bdfb4997dd53e39314a2b8be7348b1ebd4237952e2055547b358d3c000126049cf729ee5d4f0ea170b902e343a8ef0831900b963ba07a3176088ab2ab095db449d0052150d6be7b5402f459f17c759f6f043b06a5da64cb86bb910d340f7fa28fdce
-    }
 
 data EncryptionVector = EncryptionVector
     { seed :: ByteString
@@ -49,7 +69,7 @@
     , cipherText :: ByteString
     }
 
-data SignatureVector = SignatureVector 
+data SignatureVector = SignatureVector
     { message :: ByteString
     , padding :: ByteString
     , signature :: Integer
@@ -57,89 +77,166 @@
 
 basicRabinEncryptionVectors =
     [ EncryptionVector
-        { plainText = "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
-        , seed = "\x0c\xc7\x42\xce\x4a\x9b\x7f\x32\xf9\x51\xbc\xb2\x51\xef\xd9\x25\xfe\x4f\xe3\x5f"
-        , cipherText = "\xaf\xc7\x03\xe3\x9d\x2f\x81\xc6\x3a\x80\x2a\xd1\x44\x26\x3f\x17\x0c\x0a\xe6\x48\x68\x98\x23\x14\x8f\x95\xd2\xce\xbb\xe7\x3f\x49\x34\x76\x1d\x99\x30\x7b\xeb\x84\xe5\x2a\x10\xd2\x1e\x11\x7e\x65\xe8\x88\x24\xc1\x12\xeb\x19\x0d\x97\xcd\x12\x25\x6b\x1f\x9b\x0c\x40\x40\xa3\x47\x00\xb7\x11\xf8\x50\x08\x51\x79\xe8\x1b\xd1\x77\xe0\x99\xa7\xe1\x5c\x63\xda\x29\xc7\xde\x28\x5d\x60\xed\x8e\xb2\x12\xd4\xfe\xb8\x1a\x5d\x17\x65\x80\x62\x6e\x65\x5c\x37\x07\x1c\xfa\xff\xe6\x21\xa5\x9f\xcd\x6a\x6a\xce\xa6\x96\xb2\xc5\x08\xe6"
-        }   
+        { plainText =
+            "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
+        , seed =
+            "\x0c\xc7\x42\xce\x4a\x9b\x7f\x32\xf9\x51\xbc\xb2\x51\xef\xd9\x25\xfe\x4f\xe3\x5f"
+        , cipherText =
+            "\xaf\xc7\x03\xe3\x9d\x2f\x81\xc6\x3a\x80\x2a\xd1\x44\x26\x3f\x17\x0c\x0a\xe6\x48\x68\x98\x23\x14\x8f\x95\xd2\xce\xbb\xe7\x3f\x49\x34\x76\x1d\x99\x30\x7b\xeb\x84\xe5\x2a\x10\xd2\x1e\x11\x7e\x65\xe8\x88\x24\xc1\x12\xeb\x19\x0d\x97\xcd\x12\x25\x6b\x1f\x9b\x0c\x40\x40\xa3\x47\x00\xb7\x11\xf8\x50\x08\x51\x79\xe8\x1b\xd1\x77\xe0\x99\xa7\xe1\x5c\x63\xda\x29\xc7\xde\x28\x5d\x60\xed\x8e\xb2\x12\xd4\xfe\xb8\x1a\x5d\x17\x65\x80\x62\x6e\x65\x5c\x37\x07\x1c\xfa\xff\xe6\x21\xa5\x9f\xcd\x6a\x6a\xce\xa6\x96\xb2\xc5\x08\xe6"
+        }
     ]
 
 basicRabinSignatureVectors =
     [ SignatureVector
-        { message = "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
+        { message =
+            "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
         , padding = "\xe9\x87\x17\x15\xa2\xe4\x30\x15"
-        , signature = 0xac95807bdd03ca975690151d39d23d75e5db2731c4ba30b83c3f3ea74709e4d4e340d7dab952356a76c9b8705b214e28d59f5bdc7c7fdff4e104569e30359b5c65c2dcd5b94db58505cd8b188267121700beebd7edbee492e374514646471b5c3fa252a2580dc7343f455683815d6d7c590dd3bcaa7df41d8b08197ccb183408
-        }   
+        , signature =
+            0xac95807bdd03ca975690151d39d23d75e5db2731c4ba30b83c3f3ea74709e4d4e340d7dab952356a76c9b8705b214e28d59f5bdc7c7fdff4e104569e30359b5c65c2dcd5b94db58505cd8b188267121700beebd7edbee492e374514646471b5c3fa252a2580dc7343f455683815d6d7c590dd3bcaa7df41d8b08197ccb183408
+        }
     ]
 
 modifiedRabinSignatureVectors =
     [ SignatureVector
-        { message = "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
+        { message =
+            "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
         , padding = B.empty -- not used
-        , signature = 0x278c7c269119218ab7f501ea53a97ab15a3a5a263c6daed8980abec78291e9729e0e3457731cdea8ec31a7566e93d10fc9b2615fe3e54f4533a5506ac24a3bd286e270324e538066f0ddf503f9b5e0c18e18379659834906ebd99c0d31588c66e70fc653bc8865b9239999cbd35704917d8647d1199286c533233e3e03582dd
-        }   
+        , signature =
+            0x278c7c269119218ab7f501ea53a97ab15a3a5a263c6daed8980abec78291e9729e0e3457731cdea8ec31a7566e93d10fc9b2615fe3e54f4533a5506ac24a3bd286e270324e538066f0ddf503f9b5e0c18e18379659834906ebd99c0d31588c66e70fc653bc8865b9239999cbd35704917d8647d1199286c533233e3e03582dd
+        }
     ]
-    
+
 rwEncryptionVectors =
     [ EncryptionVector
-        { plainText = "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
-        , seed = "\x0c\xc7\x42\xce\x4a\x9b\x7f\x32\xf9\x51\xbc\xb2\x51\xef\xd9\x25\xfe\x4f\xe3\x5f"
-        , cipherText = "\x40\xc2\xe3\x36\xac\x46\x72\x8a\xaf\x33\x75\xe1\x27\xd0\x38\x40\xe2\x24\x4e\x20\xa7\x5d\x85\xd3\x74\x81\x21\xfd\xc9\x40\x90\x80\x8c\xed\x2d\xd3\x5b\xc4\xb7\xc9\x7c\x80\xa5\x2f\x63\x86\x34\x4e\x8c\x92\x07\x86\x9e\xda\xfd\xf8\x11\x83\x8a\x5a\x23\xc1\xe6\x77\x37\x5d\xf9\x5c\x60\xd1\x6d\xfd\x0c\x54\xd1\x00\xe9\xab\x97\x6d\x8e\x83\x8b\x6e\x1a\x38\x73\x43\xe2\x24\xc2\xe2\x4e\x74\x3f\xe4\x4d\xdd\x27\xed\xc7\x72\x88\xd3\x0f\x93\xb3\xdb\xa2\xb7\xaf\x6d\xe9\xab\x76\x53\x63\xf9\x62\xd7\x52\x44\x61\x60\x5d\x2e\x9b\xf7"
-        }   
+        { plainText =
+            "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
+        , seed =
+            "\x0c\xc7\x42\xce\x4a\x9b\x7f\x32\xf9\x51\xbc\xb2\x51\xef\xd9\x25\xfe\x4f\xe3\x5f"
+        , cipherText =
+            "\x40\xc2\xe3\x36\xac\x46\x72\x8a\xaf\x33\x75\xe1\x27\xd0\x38\x40\xe2\x24\x4e\x20\xa7\x5d\x85\xd3\x74\x81\x21\xfd\xc9\x40\x90\x80\x8c\xed\x2d\xd3\x5b\xc4\xb7\xc9\x7c\x80\xa5\x2f\x63\x86\x34\x4e\x8c\x92\x07\x86\x9e\xda\xfd\xf8\x11\x83\x8a\x5a\x23\xc1\xe6\x77\x37\x5d\xf9\x5c\x60\xd1\x6d\xfd\x0c\x54\xd1\x00\xe9\xab\x97\x6d\x8e\x83\x8b\x6e\x1a\x38\x73\x43\xe2\x24\xc2\xe2\x4e\x74\x3f\xe4\x4d\xdd\x27\xed\xc7\x72\x88\xd3\x0f\x93\xb3\xdb\xa2\xb7\xaf\x6d\xe9\xab\x76\x53\x63\xf9\x62\xd7\x52\x44\x61\x60\x5d\x2e\x9b\xf7"
+        }
     ]
 
 rwSignatureVectors =
     [ SignatureVector
-        { message = "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
+        { message =
+            "\x75\x0c\x40\x47\xf5\x47\xe8\xe4\x14\x11\x85\x65\x23\x29\x8a\xc9\xba\xe2\x45\xef\xaf\x13\x97\xfb\xe5\x6f\x9d\xd5"
         , padding = B.empty -- not used
-        , signature = 0x1e57b554a8e83aacd9d4067f9535991e7db47803250cded5cc8af5458a6bb11fea852139e0afe143f9339dd94a518e354e702134d1ae222460127829d92e8bf6441336f5ae7044ec7b6c3ad8b9aeeb1ea02a49798e020cb5b558120bbb51f060eb1608ba68f90cac7edb1051c177d3bdbb99d1ad92e8d75d6f72f1d06f1d25be
-        }   
+        , signature =
+            0x1e57b554a8e83aacd9d4067f9535991e7db47803250cded5cc8af5458a6bb11fea852139e0afe143f9339dd94a518e354e702134d1ae222460127829d92e8bf6441336f5ae7044ec7b6c3ad8b9aeeb1ea02a49798e020cb5b558120bbb51f060eb1608ba68f90cac7edb1051c177d3bdbb99d1ad92e8d75d6f72f1d06f1d25be
+        }
     ]
 
 doBasicRabinEncryptTest key i vector = testCase (show i) (Right (cipherText vector) @=? actual)
-    where actual = BRabin.encryptWithSeed (seed vector) (OAEP.defaultOAEPParams SHA1) key (plainText vector)
+  where
+    actual =
+        BRabin.encryptWithSeed
+            (seed vector)
+            (OAEP.defaultOAEPParams SHA1)
+            key
+            (plainText vector)
 
 doBasicRabinDecryptTest key i vector = testCase (show i) (Just (plainText vector) @=? actual)
-    where actual = BRabin.decrypt (OAEP.defaultOAEPParams SHA1) key (cipherText vector)
+  where
+    actual = BRabin.decrypt (OAEP.defaultOAEPParams SHA1) key (cipherText vector)
 
-doBasicRabinSignTest key i vector = testCase (show i) (Right (BRabin.Signature ((os2ip $ padding vector), (signature vector))) @=? actual)
-    where actual = BRabin.signWith (padding vector) key SHA1 (message vector)
+doBasicRabinSignTest key i vector =
+    testCase
+        (show i)
+        ( Right (BRabin.Signature ((os2ip $ padding vector), (signature vector)))
+            @=? actual
+        )
+  where
+    actual = BRabin.signWith (padding vector) key SHA1 (message vector)
 
 doBasicRabinVerifyTest key i vector = testCase (show i) (True @=? actual)
-    where actual = BRabin.verify key SHA1 (message vector) (BRabin.Signature ((os2ip $ padding vector), (signature vector)))
+  where
+    actual =
+        BRabin.verify
+            key
+            SHA1
+            (message vector)
+            (BRabin.Signature ((os2ip $ padding vector), (signature vector)))
 
 doModifiedRabinSignTest key i vector = testCase (show i) (Right (signature vector) @=? actual)
-    where actual = MRabin.sign key SHA1 (message vector)
+  where
+    actual = MRabin.sign key SHA1 (message vector)
 
 doModifiedRabinVerifyTest key i vector = testCase (show i) (True @=? actual)
-    where actual = MRabin.verify key SHA1 (message vector) (signature vector)
+  where
+    actual = MRabin.verify key SHA1 (message vector) (signature vector)
 
 doRwEncryptTest key i vector = testCase (show i) (Right (cipherText vector) @=? actual)
-    where actual = RW.encryptWithSeed (seed vector) (OAEP.defaultOAEPParams SHA1) key (plainText vector)
+  where
+    actual =
+        RW.encryptWithSeed
+            (seed vector)
+            (OAEP.defaultOAEPParams SHA1)
+            key
+            (plainText vector)
 
 doRwDecryptTest key i vector = testCase (show i) (Just (plainText vector) @=? actual)
-    where actual = RW.decrypt (OAEP.defaultOAEPParams SHA1) key (cipherText vector)
+  where
+    actual = RW.decrypt (OAEP.defaultOAEPParams SHA1) key (cipherText vector)
 
 doRwSignTest key i vector = testCase (show i) (Right (signature vector) @=? actual)
-    where actual = RW.sign key SHA1 (message vector)
+  where
+    actual = RW.sign key SHA1 (message vector)
 
 doRwVerifyTest key i vector = testCase (show i) (True @=? actual)
-    where actual = RW.verify key SHA1 (message vector) (signature vector)
+  where
+    actual = RW.verify key SHA1 (message vector) (signature vector)
 
-rabinTests = testGroup "Rabin"
-    [ testGroup "Basic"
-        [ testGroup "encrypt" $ zipWith (doBasicRabinEncryptTest $ BRabin.private_pub basicRabinKey) [katZero..] basicRabinEncryptionVectors
-        , testGroup "decrypt" $ zipWith (doBasicRabinDecryptTest basicRabinKey) [katZero..] basicRabinEncryptionVectors
-        , testGroup "sign" $ zipWith (doBasicRabinSignTest basicRabinKey) [katZero..] basicRabinSignatureVectors
-        , testGroup "verify" $ zipWith (doBasicRabinVerifyTest $ BRabin.private_pub basicRabinKey) [katZero..] basicRabinSignatureVectors
-        ]
-    , testGroup "Modified"
-        [ testGroup "sign" $ zipWith (doModifiedRabinSignTest modifiedRabinKey) [katZero..] modifiedRabinSignatureVectors
-        , testGroup "verify" $ zipWith (doModifiedRabinVerifyTest $ MRabin.private_pub modifiedRabinKey) [katZero..] modifiedRabinSignatureVectors
-        ]
-    , testGroup "RW"
-        [ testGroup "encrypt" $ zipWith (doRwEncryptTest $ RW.private_pub rwKey) [katZero..] rwEncryptionVectors
-        , testGroup "decrypt" $ zipWith (doRwDecryptTest rwKey) [katZero..] rwEncryptionVectors
-        , testGroup "sign" $ zipWith (doRwSignTest rwKey) [katZero..] rwSignatureVectors
-        , testGroup "verify" $ zipWith (doRwVerifyTest $ RW.private_pub rwKey) [katZero..] rwSignatureVectors
+rabinTests =
+    testGroup
+        "Rabin"
+        [ testGroup
+            "Basic"
+            [ testGroup "encrypt" $
+                zipWith
+                    (doBasicRabinEncryptTest $ BRabin.private_pub basicRabinKey)
+                    [katZero ..]
+                    basicRabinEncryptionVectors
+            , testGroup "decrypt" $
+                zipWith
+                    (doBasicRabinDecryptTest basicRabinKey)
+                    [katZero ..]
+                    basicRabinEncryptionVectors
+            , testGroup "sign" $
+                zipWith
+                    (doBasicRabinSignTest basicRabinKey)
+                    [katZero ..]
+                    basicRabinSignatureVectors
+            , testGroup "verify" $
+                zipWith
+                    (doBasicRabinVerifyTest $ BRabin.private_pub basicRabinKey)
+                    [katZero ..]
+                    basicRabinSignatureVectors
+            ]
+        , testGroup
+            "Modified"
+            [ testGroup "sign" $
+                zipWith
+                    (doModifiedRabinSignTest modifiedRabinKey)
+                    [katZero ..]
+                    modifiedRabinSignatureVectors
+            , testGroup "verify" $
+                zipWith
+                    (doModifiedRabinVerifyTest $ MRabin.private_pub modifiedRabinKey)
+                    [katZero ..]
+                    modifiedRabinSignatureVectors
+            ]
+        , testGroup
+            "RW"
+            [ testGroup "encrypt" $
+                zipWith
+                    (doRwEncryptTest $ RW.private_pub rwKey)
+                    [katZero ..]
+                    rwEncryptionVectors
+            , testGroup "decrypt" $
+                zipWith (doRwDecryptTest rwKey) [katZero ..] rwEncryptionVectors
+            , testGroup "sign" $ zipWith (doRwSignTest rwKey) [katZero ..] rwSignatureVectors
+            , testGroup "verify" $
+                zipWith (doRwVerifyTest $ RW.private_pub rwKey) [katZero ..] rwSignatureVectors
+            ]
         ]
-    ]
diff --git a/tests/KAT_RC4.hs b/tests/KAT_RC4.hs
--- a/tests/KAT_RC4.hs
+++ b/tests/KAT_RC4.hs
@@ -1,34 +1,42 @@
-{-# LANGUAGE ViewPatterns #-}
 {-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE ViewPatterns #-}
+
 module KAT_RC4 where
 
 import Test.Tasty
 import Test.Tasty.HUnit
 
+import qualified Crypto.Cipher.RC4 as RC4
 import Data.ByteString (ByteString)
 import Data.ByteString.Char8 ()
-import qualified Crypto.Cipher.RC4 as RC4
 
 -- taken from wikipedia pages
 vectors :: [(ByteString, ByteString, ByteString)]
 vectors =
-    [   ("Key"
-        ,"Plaintext"
-        ,"\xBB\xF3\x16\xE8\xD9\x40\xAF\x0A\xD3"
+    [
+        ( "Key"
+        , "Plaintext"
+        , "\xBB\xF3\x16\xE8\xD9\x40\xAF\x0A\xD3"
         )
-    ,   ("Wiki"
-        ,"pedia"
-        ,"\x10\x21\xBF\x04\x20"
+    ,
+        ( "Wiki"
+        , "pedia"
+        , "\x10\x21\xBF\x04\x20"
         )
-    ,   ("Secret"
-        ,"Attack at dawn"
-        ,"\x45\xA0\x1F\x64\x5F\xC3\x5B\x38\x35\x52\x54\x4B\x9B\xF5"
+    ,
+        ( "Secret"
+        , "Attack at dawn"
+        , "\x45\xA0\x1F\x64\x5F\xC3\x5B\x38\x35\x52\x54\x4B\x9B\xF5"
         )
     ]
 
-tests = testGroup "RC4"
-    $ zipWith toKatTest is vectors
-  where toKatTest i (key, plainText, cipherText) =
-            testCase (show i) (cipherText @=? snd (RC4.combine (RC4.initialize key) plainText))
-        is :: [Int]
-        is = [1..]
+tests =
+    testGroup "RC4" $
+        zipWith toKatTest is vectors
+  where
+    toKatTest i (key, plainText, cipherText) =
+        testCase
+            (show i)
+            (cipherText @=? snd (RC4.combine (RC4.initialize key) plainText))
+    is :: [Int]
+    is = [1 ..]
diff --git a/tests/KAT_Scrypt.hs b/tests/KAT_Scrypt.hs
--- a/tests/KAT_Scrypt.hs
+++ b/tests/KAT_Scrypt.hs
@@ -1,33 +1,41 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module KAT_Scrypt (tests) where
 
 import Data.ByteString (ByteString)
 import Data.ByteString.Char8 ()
 
+import Data.Word
 import Test.Tasty
 import Test.Tasty.HUnit
-import Data.Word
 
 import qualified Crypto.KDF.Scrypt as Scrypt
 
-vectors :: [ ((ByteString, ByteString, Word64, Int, Int, Int), ByteString) ]
+vectors :: [((ByteString, ByteString, Word64, Int, Int, Int), ByteString)]
 vectors =
     [
         ( ("", "", 16, 1, 1, 64)
         , "\x77\xd6\x57\x62\x38\x65\x7b\x20\x3b\x19\xca\x42\xc1\x8a\x04\x97\xf1\x6b\x48\x44\xe3\x07\x4a\xe8\xdf\xdf\xfa\x3f\xed\xe2\x14\x42\xfc\xd0\x06\x9d\xed\x09\x48\xf8\x32\x6a\x75\x3a\x0f\xc8\x1f\x17\xe8\xd3\xe0\xfb\x2e\x0d\x36\x28\xcf\x35\xe2\x0c\x38\xd1\x89\x06"
         )
-    ,   ( ("password", "NaCl", 1024, 8, 16, 64)
+    ,
+        ( ("password", "NaCl", 1024, 8, 16, 64)
         , "\xfd\xba\xbe\x1c\x9d\x34\x72\x00\x78\x56\xe7\x19\x0d\x01\xe9\xfe\x7c\x6a\xd7\xcb\xc8\x23\x78\x30\xe7\x73\x76\x63\x4b\x37\x31\x62\x2e\xaf\x30\xd9\x2e\x22\xa3\x88\x6f\xf1\x09\x27\x9d\x98\x30\xda\xc7\x27\xaf\xb9\x4a\x83\xee\x6d\x83\x60\xcb\xdf\xa2\xcc\x06\x40"
         )
-    ,   ( ("pleaseletmein", "SodiumChloride", 16384, 8, 1, 64)
+    ,
+        ( ("pleaseletmein", "SodiumChloride", 16384, 8, 1, 64)
         , "\x70\x23\xbd\xcb\x3a\xfd\x73\x48\x46\x1c\x06\xcd\x81\xfd\x38\xeb\xfd\xa8\xfb\xba\x90\x4f\x8e\x3e\xa9\xb5\x43\xf6\x54\x5d\xa1\xf2\xd5\x43\x29\x55\x61\x3f\x0f\xcf\x62\xd4\x97\x05\x24\x2a\x9a\xf9\xe6\x1e\x85\xdc\x0d\x65\x1e\x40\xdf\xcf\x01\x7b\x45\x57\x58\x87"
         )
-    ,   ( ("pleaseletmein", "SodiumChloride", 1048576, 8, 1, 64)
+    ,
+        ( ("pleaseletmein", "SodiumChloride", 1048576, 8, 1, 64)
         , "\x21\x01\xcb\x9b\x6a\x51\x1a\xae\xad\xdb\xbe\x09\xcf\x70\xf8\x81\xec\x56\x8d\x57\x4a\x2f\xfd\x4d\xab\xe5\xee\x98\x20\xad\xaa\x47\x8e\x56\xfd\x8f\x4b\xa5\xd0\x9f\xfa\x1c\x6d\x92\x7c\x40\xf4\xc3\x37\x30\x40\x49\xe8\xa9\x52\xfb\xcb\xf4\x5c\x6f\xa7\x7a\x41\xa4"
         )
     ]
 
-tests = testGroup "Scrypt"
-    $ zipWith toCase [(1::Int)..] vectors
-  where toCase i ((pass,salt,n,r,p,dklen), output) =
-            testCase (show i) (output @=? Scrypt.generate (Scrypt.Parameters n r p dklen) pass salt)
+tests =
+    testGroup "Scrypt" $
+        zipWith toCase [(1 :: Int) ..] vectors
+  where
+    toCase i ((pass, salt, n, r, p, dklen), output) =
+        testCase
+            (show i)
+            (output @=? Scrypt.generate (Scrypt.Parameters n r p dklen) pass salt)
diff --git a/tests/KAT_TripleDES.hs b/tests/KAT_TripleDES.hs
--- a/tests/KAT_TripleDES.hs
+++ b/tests/KAT_TripleDES.hs
@@ -1,12 +1,14 @@
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE ViewPatterns #-}
+
 module KAT_TripleDES (tests) where
 
-import Imports
 import BlockCipher
 import qualified Crypto.Cipher.TripleDES as TripleDES
+import Imports
 
 kats = defaultKATs
 
-tests = localOption (QuickCheckTests 5)
-      $ testBlockCipher kats (undefined :: TripleDES.DES_EEE3)
+tests =
+    localOption (QuickCheckTests 5) $
+        testBlockCipher kats (undefined :: TripleDES.DES_EEE3)
diff --git a/tests/KAT_Twofish.hs b/tests/KAT_Twofish.hs
--- a/tests/KAT_Twofish.hs
+++ b/tests/KAT_Twofish.hs
@@ -1,45 +1,388 @@
 module KAT_Twofish (tests) where
 
-import Imports
 import BlockCipher
+import Imports
 
-import qualified Data.ByteString as B
 import Crypto.Cipher.Twofish
-
+import qualified Data.ByteString as B
 
 vectors_twofish128 =
-    [ KAT_ECB (B.replicate 16 0x00) (B.replicate 16 0x00) (B.pack [0x9F,0x58,0x9F,0x5C,0xF6,0x12,0x2C,0x32,0xB6,0xBF,0xEC,0x2F,0x2A,0xE8,0xC3,0x5A])
-    , KAT_ECB (B.pack [0x9F,0x58,0x9F,0x5C,0xF6,0x12,0x2C,0x32,0xB6,0xBF,0xEC,0x2F,0x2A,0xE8,0xC3,0x5A])
-              (B.pack [0xD4, 0x91, 0xDB, 0x16, 0xE7, 0xB1, 0xC3, 0x9E, 0x86, 0xCB, 0x08, 0x6B, 0x78, 0x9F, 0x54, 0x19])
-              (B.pack [0x01, 0x9F, 0x98, 0x09, 0xDE, 0x17, 0x11, 0x85, 0x8F, 0xAA, 0xC3, 0xA3, 0xBA, 0x20, 0xFB, 0xC3])
+    [ KAT_ECB
+        (B.replicate 16 0x00)
+        (B.replicate 16 0x00)
+        ( B.pack
+            [ 0x9F
+            , 0x58
+            , 0x9F
+            , 0x5C
+            , 0xF6
+            , 0x12
+            , 0x2C
+            , 0x32
+            , 0xB6
+            , 0xBF
+            , 0xEC
+            , 0x2F
+            , 0x2A
+            , 0xE8
+            , 0xC3
+            , 0x5A
+            ]
+        )
+    , KAT_ECB
+        ( B.pack
+            [ 0x9F
+            , 0x58
+            , 0x9F
+            , 0x5C
+            , 0xF6
+            , 0x12
+            , 0x2C
+            , 0x32
+            , 0xB6
+            , 0xBF
+            , 0xEC
+            , 0x2F
+            , 0x2A
+            , 0xE8
+            , 0xC3
+            , 0x5A
+            ]
+        )
+        ( B.pack
+            [ 0xD4
+            , 0x91
+            , 0xDB
+            , 0x16
+            , 0xE7
+            , 0xB1
+            , 0xC3
+            , 0x9E
+            , 0x86
+            , 0xCB
+            , 0x08
+            , 0x6B
+            , 0x78
+            , 0x9F
+            , 0x54
+            , 0x19
+            ]
+        )
+        ( B.pack
+            [ 0x01
+            , 0x9F
+            , 0x98
+            , 0x09
+            , 0xDE
+            , 0x17
+            , 0x11
+            , 0x85
+            , 0x8F
+            , 0xAA
+            , 0xC3
+            , 0xA3
+            , 0xBA
+            , 0x20
+            , 0xFB
+            , 0xC3
+            ]
+        )
     ]
 
 vectors_twofish192 =
-    [ KAT_ECB (B.pack [0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
-                       0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77])
-              (B.pack [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
-              (B.pack [0xCF, 0xD1, 0xD2, 0xE5, 0xA9, 0xBE, 0x9C, 0xDF, 0x50, 0x1F, 0x13, 0xB8, 0x92, 0xBD, 0x22, 0x48])
-    , KAT_ECB (B.pack [0x88, 0xB2, 0xB2, 0x70, 0x6B, 0x10, 0x5E, 0x36, 0xB4, 0x46, 0xBB, 0x6D, 0x73, 0x1A, 0x1E, 0x88,
-                       0xEF, 0xA7, 0x1F, 0x78, 0x89, 0x65, 0xBD, 0x44])
-              (B.pack [0x39, 0xDA, 0x69, 0xD6, 0xBA, 0x49, 0x97, 0xD5, 0x85, 0xB6, 0xDC, 0x07, 0x3C, 0xA3, 0x41, 0xB2])
-              (B.pack [0x18, 0x2B, 0x02, 0xD8, 0x14, 0x97, 0xEA, 0x45, 0xF9, 0xDA, 0xAC, 0xDC, 0x29, 0x19, 0x3A, 0x65])]
+    [ KAT_ECB
+        ( B.pack
+            [ 0x01
+            , 0x23
+            , 0x45
+            , 0x67
+            , 0x89
+            , 0xAB
+            , 0xCD
+            , 0xEF
+            , 0xFE
+            , 0xDC
+            , 0xBA
+            , 0x98
+            , 0x76
+            , 0x54
+            , 0x32
+            , 0x10
+            , 0x00
+            , 0x11
+            , 0x22
+            , 0x33
+            , 0x44
+            , 0x55
+            , 0x66
+            , 0x77
+            ]
+        )
+        ( B.pack
+            [ 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            ]
+        )
+        ( B.pack
+            [ 0xCF
+            , 0xD1
+            , 0xD2
+            , 0xE5
+            , 0xA9
+            , 0xBE
+            , 0x9C
+            , 0xDF
+            , 0x50
+            , 0x1F
+            , 0x13
+            , 0xB8
+            , 0x92
+            , 0xBD
+            , 0x22
+            , 0x48
+            ]
+        )
+    , KAT_ECB
+        ( B.pack
+            [ 0x88
+            , 0xB2
+            , 0xB2
+            , 0x70
+            , 0x6B
+            , 0x10
+            , 0x5E
+            , 0x36
+            , 0xB4
+            , 0x46
+            , 0xBB
+            , 0x6D
+            , 0x73
+            , 0x1A
+            , 0x1E
+            , 0x88
+            , 0xEF
+            , 0xA7
+            , 0x1F
+            , 0x78
+            , 0x89
+            , 0x65
+            , 0xBD
+            , 0x44
+            ]
+        )
+        ( B.pack
+            [ 0x39
+            , 0xDA
+            , 0x69
+            , 0xD6
+            , 0xBA
+            , 0x49
+            , 0x97
+            , 0xD5
+            , 0x85
+            , 0xB6
+            , 0xDC
+            , 0x07
+            , 0x3C
+            , 0xA3
+            , 0x41
+            , 0xB2
+            ]
+        )
+        ( B.pack
+            [ 0x18
+            , 0x2B
+            , 0x02
+            , 0xD8
+            , 0x14
+            , 0x97
+            , 0xEA
+            , 0x45
+            , 0xF9
+            , 0xDA
+            , 0xAC
+            , 0xDC
+            , 0x29
+            , 0x19
+            , 0x3A
+            , 0x65
+            ]
+        )
+    ]
 
 vectors_twofish256 =
-    [ KAT_ECB (B.pack [0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
-                       0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF])
-              (B.pack [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
-              (B.pack [0x37, 0x52, 0x7B, 0xE0, 0x05, 0x23, 0x34, 0xB8, 0x9F, 0x0C, 0xFC, 0xCA, 0xE8, 0x7C, 0xFA, 0x20])
-    , KAT_ECB (B.pack [0xD4, 0x3B, 0xB7, 0x55, 0x6E, 0xA3, 0x2E, 0x46, 0xF2, 0xA2, 0x82, 0xB7, 0xD4, 0x5B, 0x4E, 0x0D,
-                       0x57, 0xFF, 0x73, 0x9D, 0x4D, 0xC9, 0x2C, 0x1B, 0xD7, 0xFC, 0x01, 0x70, 0x0C, 0xC8, 0x21, 0x6F])
-              (B.pack [0x90, 0xAF, 0xE9, 0x1B, 0xB2, 0x88, 0x54, 0x4F, 0x2C, 0x32, 0xDC, 0x23, 0x9B, 0x26, 0x35, 0xE6])
-              (B.pack [0x6C, 0xB4, 0x56, 0x1C, 0x40, 0xBF, 0x0A, 0x97, 0x05, 0x93, 0x1C, 0xB6, 0xD4, 0x08, 0xE7, 0xFA])]
-
-kats128 = defaultKATs { kat_ECB = vectors_twofish128 }
-kats192 = defaultKATs { kat_ECB = vectors_twofish192 }
-kats256 = defaultKATs { kat_ECB = vectors_twofish256 }
+    [ KAT_ECB
+        ( B.pack
+            [ 0x01
+            , 0x23
+            , 0x45
+            , 0x67
+            , 0x89
+            , 0xAB
+            , 0xCD
+            , 0xEF
+            , 0xFE
+            , 0xDC
+            , 0xBA
+            , 0x98
+            , 0x76
+            , 0x54
+            , 0x32
+            , 0x10
+            , 0x00
+            , 0x11
+            , 0x22
+            , 0x33
+            , 0x44
+            , 0x55
+            , 0x66
+            , 0x77
+            , 0x88
+            , 0x99
+            , 0xAA
+            , 0xBB
+            , 0xCC
+            , 0xDD
+            , 0xEE
+            , 0xFF
+            ]
+        )
+        ( B.pack
+            [ 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            , 0x00
+            ]
+        )
+        ( B.pack
+            [ 0x37
+            , 0x52
+            , 0x7B
+            , 0xE0
+            , 0x05
+            , 0x23
+            , 0x34
+            , 0xB8
+            , 0x9F
+            , 0x0C
+            , 0xFC
+            , 0xCA
+            , 0xE8
+            , 0x7C
+            , 0xFA
+            , 0x20
+            ]
+        )
+    , KAT_ECB
+        ( B.pack
+            [ 0xD4
+            , 0x3B
+            , 0xB7
+            , 0x55
+            , 0x6E
+            , 0xA3
+            , 0x2E
+            , 0x46
+            , 0xF2
+            , 0xA2
+            , 0x82
+            , 0xB7
+            , 0xD4
+            , 0x5B
+            , 0x4E
+            , 0x0D
+            , 0x57
+            , 0xFF
+            , 0x73
+            , 0x9D
+            , 0x4D
+            , 0xC9
+            , 0x2C
+            , 0x1B
+            , 0xD7
+            , 0xFC
+            , 0x01
+            , 0x70
+            , 0x0C
+            , 0xC8
+            , 0x21
+            , 0x6F
+            ]
+        )
+        ( B.pack
+            [ 0x90
+            , 0xAF
+            , 0xE9
+            , 0x1B
+            , 0xB2
+            , 0x88
+            , 0x54
+            , 0x4F
+            , 0x2C
+            , 0x32
+            , 0xDC
+            , 0x23
+            , 0x9B
+            , 0x26
+            , 0x35
+            , 0xE6
+            ]
+        )
+        ( B.pack
+            [ 0x6C
+            , 0xB4
+            , 0x56
+            , 0x1C
+            , 0x40
+            , 0xBF
+            , 0x0A
+            , 0x97
+            , 0x05
+            , 0x93
+            , 0x1C
+            , 0xB6
+            , 0xD4
+            , 0x08
+            , 0xE7
+            , 0xFA
+            ]
+        )
+    ]
 
-tests = testGroup "Twofish"
-            [ testBlockCipher kats128 (undefined :: Twofish128)
-            , testBlockCipher kats192 (undefined :: Twofish192)
-            , testBlockCipher kats256 (undefined :: Twofish256) ]
+kats128 = defaultKATs{kat_ECB = vectors_twofish128}
+kats192 = defaultKATs{kat_ECB = vectors_twofish192}
+kats256 = defaultKATs{kat_ECB = vectors_twofish256}
 
+tests =
+    testGroup
+        "Twofish"
+        [ testBlockCipher kats128 (undefined :: Twofish128)
+        , testBlockCipher kats192 (undefined :: Twofish192)
+        , testBlockCipher kats256 (undefined :: Twofish256)
+        ]
diff --git a/tests/Number.hs b/tests/Number.hs
--- a/tests/Number.hs
+++ b/tests/Number.hs
@@ -1,87 +1,117 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module Number (tests) where
 
 import Imports
 
-import Data.ByteArray (Bytes)
-import qualified Data.ByteArray as B
 import Crypto.Number.Basic
 import Crypto.Number.Generate
-import qualified Crypto.Number.Serialize    as BE
-import qualified Crypto.Number.Serialize.LE as LE
-import Crypto.Number.Prime
 import Crypto.Number.ModArithmetic
+import Crypto.Number.Prime
+import qualified Crypto.Number.Serialize as BE
+import qualified Crypto.Number.Serialize.LE as LE
 import Data.Bits
+import Data.ByteArray (Bytes)
+import qualified Data.ByteArray as B
 
 serializationVectors :: [(Int, Integer, ByteString)]
 serializationVectors =
-    [ (128, 468189858948067662094510918729062682059955669513914188715630930503497261316361784677177564296207557978182700664806717692596876084916561811001371208806217360635705059859428069669992937334724312890015700331031248133952795914192719979937664050389500162437642525331653766885896869239678885404647468665996400635, "\x00\xaa\xae\x74\xc8\xec\x3c\x36\x06\x5e\x46\xca\x8e\x57\xab\x09\x87\xfd\xcd\x1f\xa4\xe7\xf9\xd2\x60\xd5\x4a\x1b\x74\xdc\xa8\x75\xd8\xdd\xff\x2b\x74\x28\x14\x59\x67\x6c\x82\xae\xa3\xa5\x1d\x3f\xb4\xb7\xfe\x5c\xd2\xf0\x7f\xd8\xd9\xa9\xb0\xce\x26\xc1\x26\x74\x96\xf5\xf6\x4c\x8f\x66\x7f\x5d\xf1\x68\x38\xd4\x03\x62\xe9\x30\xc8\xa1\xc1\x84\x97\x62\x20\xfd\xd7\x03\x35\xc1\x25\x45\x1b\x86\x81\x3d\xa4\x92\xc0\xd3\xdd\xfa\x86\x1d\xdf\x0a\xbb\xf4\xc0\x56\xf7\xa2\xb0\x3b\x52\xf7\xa5\x89\x4c\x69\x34\x91\x46\xd9\x57\xfb")
-    , (128, 40031303476923779996794876613623495515025748694978019540894726181695410095832601107261950025830235596060960914255795497479135806963313279476038687192202016132891881954743054164975707083302554941058329647014950354509055121290280892911153779672733723699997592027662953953692834215577119173225643193201177329, "\x00\x0e\x97\xf9\xd5\x79\xb9\x90\x7c\x85\x48\x49\x01\x19\x64\xfb\x76\x31\xcd\x51\xfb\x8a\x9d\x55\xe5\xd3\x7b\x87\x2d\xad\x63\x2d\x6b\x1c\x84\x3f\x65\x95\xb6\xf3\x1a\xa9\x43\x3f\x06\x46\x7b\xf8\xf3\x35\x45\x84\x11\x56\x91\x53\x43\xd7\xe1\x6d\x80\x64\x14\x45\x35\x4e\x93\x7d\x5e\x48\xec\xe0\x79\x7b\x44\x8e\xab\x0f\xc4\x5f\xc6\xa1\x71\xee\x37\xb1\x55\x51\x98\x44\x57\xe3\xc3\x56\x3a\x50\x27\xaf\xa5\x1d\x1a\x0a\x90\x19\x0d\x14\xed\x3d\x93\x40\x62\x76\xa3\xaa\x00\x23\x86\xca\x98\xb2\x6e\x02\x43\xa7\xbc\xb1\xb2\xf1")
-    , (128, 75152325976543603337003024341071663845101857195436434620947904288957274825323005869230041326941600298094896018190395352332646796347130114769768242670539699217743549573961461985255265474392937773768121046339453584830072421569334022498680626938734088755136253492360177084153487115846920446085149631919580041, "\x00\x1b\x65\xb1\x73\x74\xed\xd2\xcb\xb8\xf3\x6b\x3f\xc2\x05\xaa\x91\xab\x48\x5b\x03\x30\xae\x24\xa3\xec\x7a\x6a\xf0\x34\x73\x18\x04\xea\xe4\xd6\x19\x97\xc4\xc1\x13\x7d\x12\x0d\xd5\xcb\xbd\x18\x05\xc2\xce\x87\x66\x84\x12\xe8\x24\xa3\x31\x69\xfa\xf4\x2c\x21\x53\xa6\x04\x74\x78\xc4\x93\x0d\x38\x7f\x28\xfe\x80\x8e\xd2\x7b\x20\xc8\xf5\x1f\x0f\x73\x68\xb2\xe5\x08\xf1\x94\xa1\xe6\xcf\x3a\x2c\x12\x63\xda\x08\x3a\x78\x12\xb8\x11\x23\x3c\x38\x38\x10\x94\x2b\xac\x64\x5d\x67\x0c\xb6\x0d\xc3\x9a\x45\x39\x50\x8a\x63\x89")
-    , (128, 132094272981815297755209818914225029878347650582749561568514551350741192910991391836297682842650690115955454061006435646226436379226218676796260483719213285072886626400953065229934239690821114513313427305727000011361769875430428291375851099221794646192854831002408178061474948738788927399080262963320752452, "\x00\x30\x27\xe0\xbf\x46\xec\x77\x2d\xc6\x06\x77\xbc\x68\x87\x3c\x1b\x2e\xc7\xb7\x6c\x88\x25\xec\x8c\x95\xbf\x74\xe5\x37\x01\x25\x96\xe1\x70\x33\x5c\x7d\xab\x1f\xc2\x9c\xad\xf7\xca\x26\x85\x2d\xfc\x8f\xc7\xab\x49\x28\xa4\x47\xe6\xd5\x6e\xfa\x0a\xbb\x57\xe4\xa2\x51\xc7\xc6\x12\x0f\xa9\x98\x69\xb8\x05\x84\xc5\xe3\x28\x86\x0f\x54\x1d\xf9\x92\x42\x9f\xb1\x77\x2b\x58\x89\xe2\xfc\x22\xb0\x1e\x71\x78\xea\x39\xc1\x87\x4f\xd4\x83\x2c\x96\x1d\xea\xd5\xf9\xf9\xb9\x7b\x86\xfa\xf6\xad\x5b\xb1\x3c\xe7\x11\xd7\x96\x89\x44")
-    , (128, 577245873336454863811643140721674509319073059708446946821011267146688442860798353087462545395033001525475835015592425207995480357299993009193426638306801669333644226765032464458284920004140299209138389393494751627076239104390434285377314678827349631962212281858308570255468721491493027423799738158196939966, "\x00\xd2\x70\x41\xdb\x3d\xb5\xfe\x8c\xef\x79\xcf\x5b\x7b\x37\xb0\x05\xb8\x5a\x9b\x7d\x01\x28\xc7\xf5\x5a\x02\xba\xce\xbc\xf5\x8e\x91\x59\xd0\x42\x6f\x04\x82\x4b\x78\xb0\xdd\x91\x2e\x15\x9d\xea\x4f\x0c\x21\xc0\x67\x54\xa2\x39\xa8\xe1\x13\x8f\xa9\xff\x46\x2d\x11\x56\x04\xa0\xde\x64\xc8\x0f\xf4\x2c\xd2\x31\xdf\x2a\xfd\xac\xc7\x25\x58\xc8\xea\xfd\x47\x6e\xdd\x2a\x53\x02\x77\x49\xa7\x0d\x18\xfb\x05\x18\x4b\x28\xd3\xa2\x39\x8c\x83\x80\x90\xd1\xa8\x81\x56\x6f\xd1\x94\x9d\x65\x34\x95\x79\xc1\x27\xbc\x76\xc3\x5c\xbe")
+    [
+        ( 128
+        , 468189858948067662094510918729062682059955669513914188715630930503497261316361784677177564296207557978182700664806717692596876084916561811001371208806217360635705059859428069669992937334724312890015700331031248133952795914192719979937664050389500162437642525331653766885896869239678885404647468665996400635
+        , "\x00\xaa\xae\x74\xc8\xec\x3c\x36\x06\x5e\x46\xca\x8e\x57\xab\x09\x87\xfd\xcd\x1f\xa4\xe7\xf9\xd2\x60\xd5\x4a\x1b\x74\xdc\xa8\x75\xd8\xdd\xff\x2b\x74\x28\x14\x59\x67\x6c\x82\xae\xa3\xa5\x1d\x3f\xb4\xb7\xfe\x5c\xd2\xf0\x7f\xd8\xd9\xa9\xb0\xce\x26\xc1\x26\x74\x96\xf5\xf6\x4c\x8f\x66\x7f\x5d\xf1\x68\x38\xd4\x03\x62\xe9\x30\xc8\xa1\xc1\x84\x97\x62\x20\xfd\xd7\x03\x35\xc1\x25\x45\x1b\x86\x81\x3d\xa4\x92\xc0\xd3\xdd\xfa\x86\x1d\xdf\x0a\xbb\xf4\xc0\x56\xf7\xa2\xb0\x3b\x52\xf7\xa5\x89\x4c\x69\x34\x91\x46\xd9\x57\xfb"
+        )
+    ,
+        ( 128
+        , 40031303476923779996794876613623495515025748694978019540894726181695410095832601107261950025830235596060960914255795497479135806963313279476038687192202016132891881954743054164975707083302554941058329647014950354509055121290280892911153779672733723699997592027662953953692834215577119173225643193201177329
+        , "\x00\x0e\x97\xf9\xd5\x79\xb9\x90\x7c\x85\x48\x49\x01\x19\x64\xfb\x76\x31\xcd\x51\xfb\x8a\x9d\x55\xe5\xd3\x7b\x87\x2d\xad\x63\x2d\x6b\x1c\x84\x3f\x65\x95\xb6\xf3\x1a\xa9\x43\x3f\x06\x46\x7b\xf8\xf3\x35\x45\x84\x11\x56\x91\x53\x43\xd7\xe1\x6d\x80\x64\x14\x45\x35\x4e\x93\x7d\x5e\x48\xec\xe0\x79\x7b\x44\x8e\xab\x0f\xc4\x5f\xc6\xa1\x71\xee\x37\xb1\x55\x51\x98\x44\x57\xe3\xc3\x56\x3a\x50\x27\xaf\xa5\x1d\x1a\x0a\x90\x19\x0d\x14\xed\x3d\x93\x40\x62\x76\xa3\xaa\x00\x23\x86\xca\x98\xb2\x6e\x02\x43\xa7\xbc\xb1\xb2\xf1"
+        )
+    ,
+        ( 128
+        , 75152325976543603337003024341071663845101857195436434620947904288957274825323005869230041326941600298094896018190395352332646796347130114769768242670539699217743549573961461985255265474392937773768121046339453584830072421569334022498680626938734088755136253492360177084153487115846920446085149631919580041
+        , "\x00\x1b\x65\xb1\x73\x74\xed\xd2\xcb\xb8\xf3\x6b\x3f\xc2\x05\xaa\x91\xab\x48\x5b\x03\x30\xae\x24\xa3\xec\x7a\x6a\xf0\x34\x73\x18\x04\xea\xe4\xd6\x19\x97\xc4\xc1\x13\x7d\x12\x0d\xd5\xcb\xbd\x18\x05\xc2\xce\x87\x66\x84\x12\xe8\x24\xa3\x31\x69\xfa\xf4\x2c\x21\x53\xa6\x04\x74\x78\xc4\x93\x0d\x38\x7f\x28\xfe\x80\x8e\xd2\x7b\x20\xc8\xf5\x1f\x0f\x73\x68\xb2\xe5\x08\xf1\x94\xa1\xe6\xcf\x3a\x2c\x12\x63\xda\x08\x3a\x78\x12\xb8\x11\x23\x3c\x38\x38\x10\x94\x2b\xac\x64\x5d\x67\x0c\xb6\x0d\xc3\x9a\x45\x39\x50\x8a\x63\x89"
+        )
+    ,
+        ( 128
+        , 132094272981815297755209818914225029878347650582749561568514551350741192910991391836297682842650690115955454061006435646226436379226218676796260483719213285072886626400953065229934239690821114513313427305727000011361769875430428291375851099221794646192854831002408178061474948738788927399080262963320752452
+        , "\x00\x30\x27\xe0\xbf\x46\xec\x77\x2d\xc6\x06\x77\xbc\x68\x87\x3c\x1b\x2e\xc7\xb7\x6c\x88\x25\xec\x8c\x95\xbf\x74\xe5\x37\x01\x25\x96\xe1\x70\x33\x5c\x7d\xab\x1f\xc2\x9c\xad\xf7\xca\x26\x85\x2d\xfc\x8f\xc7\xab\x49\x28\xa4\x47\xe6\xd5\x6e\xfa\x0a\xbb\x57\xe4\xa2\x51\xc7\xc6\x12\x0f\xa9\x98\x69\xb8\x05\x84\xc5\xe3\x28\x86\x0f\x54\x1d\xf9\x92\x42\x9f\xb1\x77\x2b\x58\x89\xe2\xfc\x22\xb0\x1e\x71\x78\xea\x39\xc1\x87\x4f\xd4\x83\x2c\x96\x1d\xea\xd5\xf9\xf9\xb9\x7b\x86\xfa\xf6\xad\x5b\xb1\x3c\xe7\x11\xd7\x96\x89\x44"
+        )
+    ,
+        ( 128
+        , 577245873336454863811643140721674509319073059708446946821011267146688442860798353087462545395033001525475835015592425207995480357299993009193426638306801669333644226765032464458284920004140299209138389393494751627076239104390434285377314678827349631962212281858308570255468721491493027423799738158196939966
+        , "\x00\xd2\x70\x41\xdb\x3d\xb5\xfe\x8c\xef\x79\xcf\x5b\x7b\x37\xb0\x05\xb8\x5a\x9b\x7d\x01\x28\xc7\xf5\x5a\x02\xba\xce\xbc\xf5\x8e\x91\x59\xd0\x42\x6f\x04\x82\x4b\x78\xb0\xdd\x91\x2e\x15\x9d\xea\x4f\x0c\x21\xc0\x67\x54\xa2\x39\xa8\xe1\x13\x8f\xa9\xff\x46\x2d\x11\x56\x04\xa0\xde\x64\xc8\x0f\xf4\x2c\xd2\x31\xdf\x2a\xfd\xac\xc7\x25\x58\xc8\xea\xfd\x47\x6e\xdd\x2a\x53\x02\x77\x49\xa7\x0d\x18\xfb\x05\x18\x4b\x28\xd3\xa2\x39\x8c\x83\x80\x90\xd1\xa8\x81\x56\x6f\xd1\x94\x9d\x65\x34\x95\x79\xc1\x27\xbc\x76\xc3\x5c\xbe"
+        )
     ]
 
-tests = testGroup "number"
-    [ testProperty "num-bits" $ \(Int1_2901 i) ->
-        and [ (numBits (2^i-1) == i)
-            , (numBits (2^i) == i+1)
-            , (numBits (2^i + (2^i-1)) == i+1)
-            ]
-    , testProperty "num-bits2" $ \(Positive i) ->
-        not (i `testBit` numBits i) && (i `testBit` (numBits i - 1))
-    , testProperty "generate-param" $ \testDRG (Int1_2901 bits)  ->
-        let r = withTestDRG testDRG $ generateParams bits (Just SetHighest) False
-         in r >= 0 && numBits r == bits && testBit r (bits-1)
-    , testProperty "generate-param2" $ \testDRG (Int1_2901 m1bits) ->
-        let bits = m1bits + 1 -- make sure minimum is 2
-            r = withTestDRG testDRG $ generateParams bits (Just SetTwoHighest) False
-         in r >= 0 && numBits r == bits && testBit r (bits-1) && testBit r (bits-2)
-    , testProperty "generate-param-odd" $ \testDRG (Int1_2901 bits) ->
-        let r = withTestDRG testDRG $ generateParams bits Nothing True
-         in r >= 0 && odd r
-    , testProperty "generate-range" $ \testDRG (Positive range) ->
-        let r = withTestDRG testDRG $ generateMax range
-         in 0 <= r && r < range
-    , testProperty "generate-prime" $ \testDRG (Int0_2901 baseBits') ->
-        let baseBits = baseBits' `mod` 800
-            bits  = 5 + baseBits -- generating lower than 5 bits causes an error ..
-            prime = withTestDRG testDRG $ generatePrime bits
-         in bits == numBits prime
-    , testProperty "generate-safe-prime" $ \testDRG (Int0_2901 baseBits') ->
-        let baseBits = baseBits' `mod` 200
-            bits = 6 + baseBits
-            prime = withTestDRG testDRG $ generateSafePrime bits
-         in bits == numBits prime
-    , testProperty "as-power-of-2-and-odd" $ \n ->
-        let (e, a1) = asPowerOf2AndOdd n
-         in n == (2^e)*a1
-    , testProperty "squareRoot" $ \testDRG (Int0_2901 baseBits') -> do
-        let baseBits = baseBits' `mod` 500
-            bits = 5 + baseBits -- generating lower than 5 bits causes an error ..
-            p = withTestDRG testDRG $ generatePrime bits
-        g <- choose (1, p - 1)
-        let square x = (x * x) `mod` p
-            r = square <$> squareRoot p g
-        case jacobi g p of
-            Just   1  -> return $ Just g `assertEq` r
-            Just (-1) -> return $ Nothing `assertEq` r
-            _         -> error "invalid jacobi result"
-    , testProperty "marshalling-be" $ \qaInt ->
-        getQAInteger qaInt == BE.os2ip (BE.i2osp (getQAInteger qaInt) :: Bytes)
-    , testProperty "marshalling-le" $ \qaInt ->
-        getQAInteger qaInt == LE.os2ip (LE.i2osp (getQAInteger qaInt) :: Bytes)
-    , testProperty "be-rev-le" $ \qaInt ->
-        getQAInteger qaInt == LE.os2ip (B.reverse (BE.i2osp (getQAInteger qaInt) :: Bytes))
-    , testProperty "be-rev-le-40" $ \qaInt ->
-        getQAInteger qaInt == LE.os2ip (B.reverse (BE.i2ospOf_ 40 (getQAInteger qaInt) :: Bytes))
-    , testProperty "le-rev-be" $ \qaInt ->
-        getQAInteger qaInt == BE.os2ip (B.reverse (LE.i2osp (getQAInteger qaInt) :: Bytes))
-    , testProperty "le-rev-be-40" $ \qaInt ->
-        getQAInteger qaInt == BE.os2ip (B.reverse (LE.i2ospOf_ 40 (getQAInteger qaInt) :: Bytes))
-    , testGroup "marshalling-kat-to-bytearray" $ zipWith toSerializationKat [katZero..] serializationVectors
-    , testGroup "marshalling-kat-to-integer" $ zipWith toSerializationKatInteger [katZero..] serializationVectors
-    ]
+tests =
+    testGroup
+        "number"
+        [ testProperty "num-bits" $ \(Int1_2901 i) ->
+            and
+                [ (numBits (2 ^ i - 1) == i)
+                , (numBits (2 ^ i) == i + 1)
+                , (numBits (2 ^ i + (2 ^ i - 1)) == i + 1)
+                ]
+        , testProperty "num-bits2" $ \(Positive i) ->
+            not (i `testBit` numBits i) && (i `testBit` (numBits i - 1))
+        , testProperty "generate-param" $ \testDRG (Int1_2901 bits) ->
+            let r = withTestDRG testDRG $ generateParams bits (Just SetHighest) False
+             in r >= 0 && numBits r == bits && testBit r (bits - 1)
+        , testProperty "generate-param2" $ \testDRG (Int1_2901 m1bits) ->
+            let bits = m1bits + 1 -- make sure minimum is 2
+                r = withTestDRG testDRG $ generateParams bits (Just SetTwoHighest) False
+             in r >= 0 && numBits r == bits && testBit r (bits - 1) && testBit r (bits - 2)
+        , testProperty "generate-param-odd" $ \testDRG (Int1_2901 bits) ->
+            let r = withTestDRG testDRG $ generateParams bits Nothing True
+             in r >= 0 && odd r
+        , testProperty "generate-range" $ \testDRG (Positive range) ->
+            let r = withTestDRG testDRG $ generateMax range
+             in 0 <= r && r < range
+        , testProperty "generate-prime" $ \testDRG (Int0_2901 baseBits') ->
+            let baseBits = baseBits' `mod` 800
+                bits = 5 + baseBits -- generating lower than 5 bits causes an error ..
+                prime = withTestDRG testDRG $ generatePrime bits
+             in bits == numBits prime
+        , testProperty "generate-safe-prime" $ \testDRG (Int0_2901 baseBits') ->
+            let baseBits = baseBits' `mod` 200
+                bits = 6 + baseBits
+                prime = withTestDRG testDRG $ generateSafePrime bits
+             in bits == numBits prime
+        , testProperty "as-power-of-2-and-odd" $ \n ->
+            let (e, a1) = asPowerOf2AndOdd n
+             in n == (2 ^ e) * a1
+        , testProperty "squareRoot" $ \testDRG (Int0_2901 baseBits') -> do
+            let baseBits = baseBits' `mod` 500
+                bits = 5 + baseBits -- generating lower than 5 bits causes an error ..
+                p = withTestDRG testDRG $ generatePrime bits
+            g <- choose (1, p - 1)
+            let square x = (x * x) `mod` p
+                r = square <$> squareRoot p g
+            case jacobi g p of
+                Just 1 -> return $ Just g `assertEq` r
+                Just (-1) -> return $ Nothing `assertEq` r
+                _ -> error "invalid jacobi result"
+        , testProperty "marshalling-be" $ \qaInt ->
+            getQAInteger qaInt == BE.os2ip (BE.i2osp (getQAInteger qaInt) :: Bytes)
+        , testProperty "marshalling-le" $ \qaInt ->
+            getQAInteger qaInt == LE.os2ip (LE.i2osp (getQAInteger qaInt) :: Bytes)
+        , testProperty "be-rev-le" $ \qaInt ->
+            getQAInteger qaInt
+                == LE.os2ip (B.reverse (BE.i2osp (getQAInteger qaInt) :: Bytes))
+        , testProperty "be-rev-le-40" $ \qaInt ->
+            getQAInteger qaInt
+                == LE.os2ip (B.reverse (BE.i2ospOf_ 40 (getQAInteger qaInt) :: Bytes))
+        , testProperty "le-rev-be" $ \qaInt ->
+            getQAInteger qaInt
+                == BE.os2ip (B.reverse (LE.i2osp (getQAInteger qaInt) :: Bytes))
+        , testProperty "le-rev-be-40" $ \qaInt ->
+            getQAInteger qaInt
+                == BE.os2ip (B.reverse (LE.i2ospOf_ 40 (getQAInteger qaInt) :: Bytes))
+        , testGroup "marshalling-kat-to-bytearray" $
+            zipWith toSerializationKat [katZero ..] serializationVectors
+        , testGroup "marshalling-kat-to-integer" $
+            zipWith toSerializationKatInteger [katZero ..] serializationVectors
+        ]
   where
     toSerializationKat i (sz, n, ba) = testCase (show i) (ba @=? BE.i2ospOf_ sz n)
     toSerializationKatInteger i (_, n, ba) = testCase (show i) (n @=? BE.os2ip ba)
diff --git a/tests/Number/F2m.hs b/tests/Number/F2m.hs
--- a/tests/Number/F2m.hs
+++ b/tests/Number/F2m.hs
@@ -1,111 +1,127 @@
 module Number.F2m (tests) where
 
-import Imports hiding ((.&.))
-import Data.Bits
-import Data.Maybe
 import Crypto.Number.Basic (log2)
 import Crypto.Number.F2m
+import Data.Bits
+import Data.Maybe
+import Imports hiding ((.&.))
 
-addTests = testGroup "addF2m"
-    [ testProperty "commutative"
-        $ \a b -> a `addF2m` b == b `addF2m` a
-    , testProperty "associative"
-        $ \a b c -> (a `addF2m` b) `addF2m` c == a `addF2m` (b `addF2m` c)
-    , testProperty "0 is neutral"
-        $ \a -> a `addF2m` 0 == a
-    , testProperty "nullable"
-        $ \a -> a `addF2m` a == 0
-    , testProperty "works per bit"
-        $ \a b -> (a `addF2m` b) .&. b == (a .&. b) `addF2m` b
-    ]
+addTests =
+    testGroup
+        "addF2m"
+        [ testProperty "commutative" $
+            \a b -> a `addF2m` b == b `addF2m` a
+        , testProperty "associative" $
+            \a b c -> (a `addF2m` b) `addF2m` c == a `addF2m` (b `addF2m` c)
+        , testProperty "0 is neutral" $
+            \a -> a `addF2m` 0 == a
+        , testProperty "nullable" $
+            \a -> a `addF2m` a == 0
+        , testProperty "works per bit" $
+            \a b -> (a `addF2m` b) .&. b == (a .&. b) `addF2m` b
+        ]
 
-modTests = testGroup "modF2m"
-    [ testProperty "idempotent"
-        $ \(Positive m) (NonNegative a) -> modF2m m a == modF2m m (modF2m m a)
-    , testProperty "upper bound"
-        $ \(Positive m) (NonNegative a) -> modF2m m a < 2 ^ log2 m
-    , testProperty "reach upper"
-        $ \(Positive m) -> let a = 2 ^ log2 m - 1 in modF2m m (m `addF2m` a) == a
-    , testProperty "lower bound"
-        $ \(Positive m) (NonNegative a) -> modF2m m a >= 0
-    , testProperty "reach lower"
-        $ \(Positive m) -> modF2m m m == 0
-    , testProperty "additive"
-        $ \(Positive m) (NonNegative a) (NonNegative b)
-            -> modF2m m a `addF2m` modF2m m b == modF2m m (a `addF2m` b)
-    ]
+modTests =
+    testGroup
+        "modF2m"
+        [ testProperty "idempotent" $
+            \(Positive m) (NonNegative a) -> modF2m m a == modF2m m (modF2m m a)
+        , testProperty "upper bound" $
+            \(Positive m) (NonNegative a) -> modF2m m a < 2 ^ log2 m
+        , testProperty "reach upper" $
+            \(Positive m) -> let a = 2 ^ log2 m - 1 in modF2m m (m `addF2m` a) == a
+        , testProperty "lower bound" $
+            \(Positive m) (NonNegative a) -> modF2m m a >= 0
+        , testProperty "reach lower" $
+            \(Positive m) -> modF2m m m == 0
+        , testProperty "additive" $
+            \(Positive m) (NonNegative a) (NonNegative b) ->
+                modF2m m a `addF2m` modF2m m b == modF2m m (a `addF2m` b)
+        ]
 
-mulTests = testGroup "mulF2m"
-    [ testProperty "commutative"
-        $ \(Positive m) (NonNegative a) (NonNegative b) -> mulF2m m a b == mulF2m m b a
-    , testProperty "associative"
-        $ \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c)
-            -> mulF2m m (mulF2m m a b) c == mulF2m m a (mulF2m m b c)
-    , testProperty "1 is neutral"
-        $ \(Positive m) (NonNegative a) -> mulF2m m a 1 == modF2m m a
-    , testProperty "0 is annihilator"
-        $ \(Positive m) (NonNegative a) -> mulF2m m a 0 == 0
-    , testProperty "distributive"
-        $ \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c)
-            -> mulF2m m a (b `addF2m` c) == mulF2m m a b `addF2m` mulF2m m a c
-    ]
+mulTests =
+    testGroup
+        "mulF2m"
+        [ testProperty "commutative" $
+            \(Positive m) (NonNegative a) (NonNegative b) -> mulF2m m a b == mulF2m m b a
+        , testProperty "associative" $
+            \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c) ->
+                mulF2m m (mulF2m m a b) c == mulF2m m a (mulF2m m b c)
+        , testProperty "1 is neutral" $
+            \(Positive m) (NonNegative a) -> mulF2m m a 1 == modF2m m a
+        , testProperty "0 is annihilator" $
+            \(Positive m) (NonNegative a) -> mulF2m m a 0 == 0
+        , testProperty "distributive" $
+            \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c) ->
+                mulF2m m a (b `addF2m` c) == mulF2m m a b `addF2m` mulF2m m a c
+        ]
 
-squareTests = testGroup "squareF2m"
-    [ testProperty "sqr(a) == a * a"
-        $ \(Positive m) (NonNegative a) -> mulF2m m a a == squareF2m m a
-    -- disabled because we require @m@ to be a suitable modulus and there is no
-    -- way to guarantee this
-    -- , testProperty "sqrt(a) * sqrt(a) = a"
-    --     $ \(Positive m) (NonNegative aa) -> let a = sqrtF2m m aa in mulF2m m a a == modF2m m aa
-    , testProperty "sqrt(a) * sqrt(a) = a in GF(2^16)"
-        $ let m = 65581 :: Integer -- x^16 + x^5 + x^3 + x^2 + 1
-              nums = [0 .. 65535 :: Integer]
-          in  nums == [let y = sqrtF2m m x in squareF2m m y | x <- nums]
-    ]
+squareTests =
+    testGroup
+        "squareF2m"
+        [ testProperty "sqr(a) == a * a" $
+            \(Positive m) (NonNegative a) -> mulF2m m a a == squareF2m m a
+        , -- disabled because we require @m@ to be a suitable modulus and there is no
+          -- way to guarantee this
+          -- , testProperty "sqrt(a) * sqrt(a) = a"
+          --     $ \(Positive m) (NonNegative aa) -> let a = sqrtF2m m aa in mulF2m m a a == modF2m m aa
+          testProperty "sqrt(a) * sqrt(a) = a in GF(2^16)" $
+            let m = 65581 :: Integer -- x^16 + x^5 + x^3 + x^2 + 1
+                nums = [0 .. 65535 :: Integer]
+             in nums == [let y = sqrtF2m m x in squareF2m m y | x <- nums]
+        ]
 
-powTests = testGroup "powF2m"
-    [ testProperty "2 is square"
-        $ \(Positive m) (NonNegative a) -> powF2m m a 2 == squareF2m m a
-    , testProperty "1 is identity"
-        $ \(Positive m) (NonNegative a) -> powF2m m a 1 == modF2m m a
-    , testProperty "0 is annihilator"
-        $ \(Positive m) (NonNegative a) -> powF2m m a 0 == modF2m m 1
-    , testProperty "(a * b) ^ c == (a ^ c) * (b ^ c)"
-        $ \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c)
-            -> powF2m m (mulF2m m a b) c == mulF2m m (powF2m m a c) (powF2m m b c)
-    , testProperty "a ^ (b + c) == (a ^ b) * (a ^ c)"
-        $ \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c)
-            -> powF2m m a (b + c) == mulF2m m (powF2m m a b) (powF2m m a c)
-    , testProperty "a ^ (b * c) == (a ^ b) ^ c"
-        $ \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c)
-            -> powF2m m a (b * c) == powF2m m (powF2m m a b) c
-    ]
+powTests =
+    testGroup
+        "powF2m"
+        [ testProperty "2 is square" $
+            \(Positive m) (NonNegative a) -> powF2m m a 2 == squareF2m m a
+        , testProperty "1 is identity" $
+            \(Positive m) (NonNegative a) -> powF2m m a 1 == modF2m m a
+        , testProperty "0 is annihilator" $
+            \(Positive m) (NonNegative a) -> powF2m m a 0 == modF2m m 1
+        , testProperty "(a * b) ^ c == (a ^ c) * (b ^ c)" $
+            \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c) ->
+                powF2m m (mulF2m m a b) c == mulF2m m (powF2m m a c) (powF2m m b c)
+        , testProperty "a ^ (b + c) == (a ^ b) * (a ^ c)" $
+            \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c) ->
+                powF2m m a (b + c) == mulF2m m (powF2m m a b) (powF2m m a c)
+        , testProperty "a ^ (b * c) == (a ^ b) ^ c" $
+            \(Positive m) (NonNegative a) (NonNegative b) (NonNegative c) ->
+                powF2m m a (b * c) == powF2m m (powF2m m a b) c
+        ]
 
-invTests = testGroup "invF2m"
-    [ testProperty "1 / a * a == 1"
-        $ \(Positive m) (NonNegative a)
-            -> maybe True (\c -> mulF2m m c a == modF2m m 1) (invF2m m a)
-    , testProperty "1 / a == a (mod a^2-1)"
-        $ \(NonNegative a) -> a < 2 || invF2m (squareF2m' a `addF2m` 1) a == Just a
-    ]
+invTests =
+    testGroup
+        "invF2m"
+        [ testProperty "1 / a * a == 1" $
+            \(Positive m) (NonNegative a) ->
+                maybe True (\c -> mulF2m m c a == modF2m m 1) (invF2m m a)
+        , testProperty "1 / a == a (mod a^2-1)" $
+            \(NonNegative a) -> a < 2 || invF2m (squareF2m' a `addF2m` 1) a == Just a
+        ]
 
-divTests = testGroup "divF2m"
-    [ testProperty "1 / a == inv a"
-        $ \(Positive m) (NonNegative a) -> divF2m m 1 a == invF2m m a
-    , testProperty "a / b == a * inv b"
-        $ \(Positive m) (NonNegative a) (NonNegative b)
-            -> divF2m m a b == (mulF2m m a <$> invF2m m b)
-    , testProperty "a * b / b == a"
-        $ \(Positive m) (NonNegative a) (NonNegative b)
-            -> isNothing (invF2m m b) || divF2m m (mulF2m m a b) b == Just (modF2m m a)
-    ]
+divTests =
+    testGroup
+        "divF2m"
+        [ testProperty "1 / a == inv a" $
+            \(Positive m) (NonNegative a) -> divF2m m 1 a == invF2m m a
+        , testProperty "a / b == a * inv b" $
+            \(Positive m) (NonNegative a) (NonNegative b) ->
+                divF2m m a b == (mulF2m m a <$> invF2m m b)
+        , testProperty "a * b / b == a" $
+            \(Positive m) (NonNegative a) (NonNegative b) ->
+                isNothing (invF2m m b) || divF2m m (mulF2m m a b) b == Just (modF2m m a)
+        ]
 
-tests = testGroup "number.F2m"
-    [ addTests
-    , modTests
-    , mulTests
-    , squareTests
-    , powTests
-    , invTests
-    , divTests
-    ]
+tests =
+    testGroup
+        "number.F2m"
+        [ addTests
+        , modTests
+        , mulTests
+        , squareTests
+        , powTests
+        , invTests
+        , divTests
+        ]
diff --git a/tests/Padding.hs b/tests/Padding.hs
--- a/tests/Padding.hs
+++ b/tests/Padding.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module Padding (tests) where
 
 import qualified Data.ByteString as B
@@ -18,21 +19,28 @@
     , ("0123456789abcdef", 16, "0123456789abcdef", Just "0123456789abcdef")
     ]
 
---instance Arbitrary where
+-- instance Arbitrary where
 
 testPad :: Int -> (B.ByteString, Int, B.ByteString) -> TestTree
 testPad n (inp, sz, padded) =
-    testCase (show n) $ propertyHoldCase [ eqTest "padded" padded (pad (PKCS7 sz) inp)
-                                         , eqTest "unpadded" (Just inp) (unpad (PKCS7 sz) padded)
-                                         ]
+    testCase (show n) $
+        propertyHoldCase
+            [ eqTest "padded" padded (pad (PKCS7 sz) inp)
+            , eqTest "unpadded" (Just inp) (unpad (PKCS7 sz) padded)
+            ]
 
-testZeroPad :: Int -> (B.ByteString, Int, B.ByteString, Maybe B.ByteString) -> TestTree
+testZeroPad
+    :: Int -> (B.ByteString, Int, B.ByteString, Maybe B.ByteString) -> TestTree
 testZeroPad n (inp, sz, padded, unpadded) =
-    testCase (show n) $ propertyHoldCase [ eqTest "padded" padded (pad (ZERO sz) inp)
-                                         , eqTest "unpadded" unpadded (unpad (ZERO sz) padded)
-                                         ]
+    testCase (show n) $
+        propertyHoldCase
+            [ eqTest "padded" padded (pad (ZERO sz) inp)
+            , eqTest "unpadded" unpadded (unpad (ZERO sz) padded)
+            ]
 
-tests = testGroup "Padding"
-    [ testGroup "Cases" $ zipWith testPad [1..] cases
-    , testGroup "ZeroCases" $ zipWith testZeroPad [1..] zeroCases
-    ]
+tests =
+    testGroup
+        "Padding"
+        [ testGroup "Cases" $ zipWith testPad [1 ..] cases
+        , testGroup "ZeroCases" $ zipWith testZeroPad [1 ..] zeroCases
+        ]
diff --git a/tests/Poly1305.hs b/tests/Poly1305.hs
--- a/tests/Poly1305.hs
+++ b/tests/Poly1305.hs
@@ -1,11 +1,12 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module Poly1305 (tests) where
 
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Char8 as B ()
 
-import Imports
 import Crypto.Error
+import Imports
 
 import qualified Crypto.MAC.Poly1305 as Poly1305
 import qualified Data.ByteArray as B (convert)
@@ -14,23 +15,34 @@
     show _ = "Auth"
 
 data Chunking = Chunking Int Int
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance Arbitrary Chunking where
-    arbitrary = Chunking <$> choose (1,34) <*> choose (1,2048)
+    arbitrary = Chunking <$> choose (1, 34) <*> choose (1, 2048)
 
-tests = testGroup "Poly1305"
-    [ testCase "V0" $
-        let key = "\x85\xd6\xbe\x78\x57\x55\x6d\x33\x7f\x44\x52\xfe\x42\xd5\x06\xa8\x01\x03\x80\x8a\xfb\x0d\xb2\xfd\x4a\xbf\xf6\xaf\x41\x49\xf5\x1b" :: ByteString
-            msg = "Cryptographic Forum Research Group" :: ByteString
-            tag = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9" :: ByteString
-         in tag @=? B.convert (Poly1305.auth key msg)
-    , testProperty "Chunking" $ \(Chunking chunkLen totalLen) ->
-        let key = B.replicate 32 0
-            msg = B.pack $ take totalLen $ concat (replicate 10 [1..255])
-         in Poly1305.auth key msg == Poly1305.finalize (foldr (flip Poly1305.update) (throwCryptoError $ Poly1305.initialize key) (chunks chunkLen msg))
-    ]
+tests =
+    testGroup
+        "Poly1305"
+        [ testCase "V0" $
+            let key =
+                    "\x85\xd6\xbe\x78\x57\x55\x6d\x33\x7f\x44\x52\xfe\x42\xd5\x06\xa8\x01\x03\x80\x8a\xfb\x0d\xb2\xfd\x4a\xbf\xf6\xaf\x41\x49\xf5\x1b"
+                        :: ByteString
+                msg = "Cryptographic Forum Research Group" :: ByteString
+                tag =
+                    "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9" :: ByteString
+             in tag @=? B.convert (Poly1305.auth key msg)
+        , testProperty "Chunking" $ \(Chunking chunkLen totalLen) ->
+            let key = B.replicate 32 0
+                msg = B.pack $ take totalLen $ concat (replicate 10 [1 .. 255])
+             in Poly1305.auth key msg
+                    == Poly1305.finalize
+                        ( foldr
+                            (flip Poly1305.update)
+                            (throwCryptoError $ Poly1305.initialize key)
+                            (chunks chunkLen msg)
+                        )
+        ]
   where
-        chunks i bs
-            | B.length bs < i = [bs]
-            | otherwise       = let (b1,b2) = B.splitAt i bs in b1 : chunks i b2
+    chunks i bs
+        | B.length bs < i = [bs]
+        | otherwise = let (b1, b2) = B.splitAt i bs in b1 : chunks i b2
diff --git a/tests/Salsa.hs b/tests/Salsa.hs
--- a/tests/Salsa.hs
+++ b/tests/Salsa.hs
@@ -1,100 +1,134 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module Salsa (tests) where
 
-import qualified Data.ByteString as B
 import qualified Crypto.Cipher.Salsa as Salsa
+import qualified Data.ByteString as B
 
-import           Imports
+import Imports
 
 type Vector = (Int, B.ByteString, B.ByteString, [(Int, B.ByteString)])
 
 vectors :: [Vector]
 vectors =
-    [ (20, key, iv
-      , [ (0, "\x99\xA8\xCC\xEC\x6C\x5B\x2A\x0B\x6E\x33\x6C\xB2\x06\x52\x24\x1C\x32\xB2\x4D\x34\xAC\xC0\x45\x7E\xF6\x79\x17\x8E\xDE\x7C\xF8\x05\x80\x5A\x93\x05\xC7\xC4\x99\x09\x68\x3B\xD1\xA8\x03\x32\x78\x17\x62\x7C\xA4\x6F\xE8\xB9\x29\xB6\xDF\x00\x12\xBD\x86\x41\x83\xBE")
-        , (192, "\x2D\x22\x6C\x11\xF4\x7B\x3C\x0C\xCD\x09\x59\xB6\x1F\x59\xD5\xCC\x30\xFC\xEF\x6D\xBB\x8C\xBB\x3D\xCC\x1C\xC2\x52\x04\xFC\xD4\x49\x8C\x37\x42\x6A\x63\xBE\xA3\x28\x2B\x1A\x8A\x0D\x60\xE1\x3E\xB2\xFE\x59\x24\x1A\x9F\x6A\xF4\x26\x68\x98\x66\xED\xC7\x69\xE1\xE6\x48\x2F\xE1\xC1\x28\xA1\x5C\x11\x23\xB5\x65\x5E\xD5\x46\xDF\x01\x4C\xE0\xC4\x55\xDB\xF5\xD3\xA1\x3D\x9C\xD4\xF0\xE2\xD1\xDA\xB9\xF1\x2F\xB6\x8C\x54\x42\x61\xD7\xF8\x8E\xAC\x1C\x6C\xBF\x99\x3F\xBB\xB8\xE0\xAA\x85\x10\xBF\xF8\xE7\x38\x35\xA1\xE8\x6E\xAD\xBB")
-        , (448, "\x05\x97\x18\x8A\x1C\x19\x25\x57\x69\xBE\x1C\x21\x03\x99\xAD\x17\x2E\xB4\x6C\x52\xF9\x2F\xD5\x41\xDF\x2E\xAD\x71\xB1\xFF\x8E\xA7\xAD\xD3\x80\xEC\x71\xA5\xFD\x7A\xDB\x51\x81\xEA\xDD\x18\x25\xEC\x02\x77\x9A\x45\x09\xBE\x58\x32\x70\x8C\xA2\x83\x6C\x16\x93\xA5")
-        ])
-    , (20
-      , "\x00\x53\xA6\xF9\x4C\x9F\xF2\x45\x98\xEB\x3E\x91\xE4\x37\x8A\xDD\x30\x83\xD6\x29\x7C\xCF\x22\x75\xC8\x1B\x6E\xC1\x14\x67\xBA\x0D"
-      , "\x0D\x74\xDB\x42\xA9\x10\x77\xDE"
-      , [ (0, "\xF5\xFA\xD5\x3F\x79\xF9\xDF\x58\xC4\xAE\xA0\xD0\xED\x9A\x96\x01\xF2\x78\x11\x2C\xA7\x18\x0D\x56\x5B\x42\x0A\x48\x01\x96\x70\xEA\xF2\x4C\xE4\x93\xA8\x62\x63\xF6\x77\xB4\x6A\xCE\x19\x24\x77\x3D\x2B\xB2\x55\x71\xE1\xAA\x85\x93\x75\x8F\xC3\x82\xB1\x28\x0B\x71")
-        , (65472, "\xB7\x0C\x50\x13\x9C\x63\x33\x2E\xF6\xE7\x7A\xC5\x43\x38\xA4\x07\x9B\x82\xBE\xC9\xF9\xA4\x03\xDF\xEA\x82\x1B\x83\xF7\x86\x07\x91\x65\x0E\xF1\xB2\x48\x9D\x05\x90\xB1\xDE\x77\x2E\xED\xA4\xE3\xBC\xD6\x0F\xA7\xCE\x9C\xD6\x23\xD9\xD2\xFD\x57\x58\xB8\x65\x3E\x70\x81\x58\x2C\x65\xD7\x56\x2B\x80\xAE\xC2\xF1\xA6\x73\xA9\xD0\x1C\x9F\x89\x2A\x23\xD4\x91\x9F\x6A\xB4\x7B\x91\x54\xE0\x8E\x69\x9B\x41\x17\xD7\xC6\x66\x47\x7B\x60\xF8\x39\x14\x81\x68\x2F\x5D\x95\xD9\x66\x23\xDB\xC4\x89\xD8\x8D\xAA\x69\x56\xB9\xF0\x64\x6B\x6E")
-        , (131008, "\xA1\x3F\xFA\x12\x08\xF8\xBF\x50\x90\x08\x86\xFA\xAB\x40\xFD\x10\xE8\xCA\xA3\x06\xE6\x3D\xF3\x95\x36\xA1\x56\x4F\xB7\x60\xB2\x42\xA9\xD6\xA4\x62\x8C\xDC\x87\x87\x62\x83\x4E\x27\xA5\x41\xDA\x2A\x5E\x3B\x34\x45\x98\x9C\x76\xF6\x11\xE0\xFE\xC6\xD9\x1A\xCA\xCC")
-        ])
+    [
+        ( 20
+        , key
+        , iv
+        ,
+            [
+                ( 0
+                , "\x99\xA8\xCC\xEC\x6C\x5B\x2A\x0B\x6E\x33\x6C\xB2\x06\x52\x24\x1C\x32\xB2\x4D\x34\xAC\xC0\x45\x7E\xF6\x79\x17\x8E\xDE\x7C\xF8\x05\x80\x5A\x93\x05\xC7\xC4\x99\x09\x68\x3B\xD1\xA8\x03\x32\x78\x17\x62\x7C\xA4\x6F\xE8\xB9\x29\xB6\xDF\x00\x12\xBD\x86\x41\x83\xBE"
+                )
+            ,
+                ( 192
+                , "\x2D\x22\x6C\x11\xF4\x7B\x3C\x0C\xCD\x09\x59\xB6\x1F\x59\xD5\xCC\x30\xFC\xEF\x6D\xBB\x8C\xBB\x3D\xCC\x1C\xC2\x52\x04\xFC\xD4\x49\x8C\x37\x42\x6A\x63\xBE\xA3\x28\x2B\x1A\x8A\x0D\x60\xE1\x3E\xB2\xFE\x59\x24\x1A\x9F\x6A\xF4\x26\x68\x98\x66\xED\xC7\x69\xE1\xE6\x48\x2F\xE1\xC1\x28\xA1\x5C\x11\x23\xB5\x65\x5E\xD5\x46\xDF\x01\x4C\xE0\xC4\x55\xDB\xF5\xD3\xA1\x3D\x9C\xD4\xF0\xE2\xD1\xDA\xB9\xF1\x2F\xB6\x8C\x54\x42\x61\xD7\xF8\x8E\xAC\x1C\x6C\xBF\x99\x3F\xBB\xB8\xE0\xAA\x85\x10\xBF\xF8\xE7\x38\x35\xA1\xE8\x6E\xAD\xBB"
+                )
+            ,
+                ( 448
+                , "\x05\x97\x18\x8A\x1C\x19\x25\x57\x69\xBE\x1C\x21\x03\x99\xAD\x17\x2E\xB4\x6C\x52\xF9\x2F\xD5\x41\xDF\x2E\xAD\x71\xB1\xFF\x8E\xA7\xAD\xD3\x80\xEC\x71\xA5\xFD\x7A\xDB\x51\x81\xEA\xDD\x18\x25\xEC\x02\x77\x9A\x45\x09\xBE\x58\x32\x70\x8C\xA2\x83\x6C\x16\x93\xA5"
+                )
+            ]
+        )
+    ,
+        ( 20
+        , "\x00\x53\xA6\xF9\x4C\x9F\xF2\x45\x98\xEB\x3E\x91\xE4\x37\x8A\xDD\x30\x83\xD6\x29\x7C\xCF\x22\x75\xC8\x1B\x6E\xC1\x14\x67\xBA\x0D"
+        , "\x0D\x74\xDB\x42\xA9\x10\x77\xDE"
+        ,
+            [
+                ( 0
+                , "\xF5\xFA\xD5\x3F\x79\xF9\xDF\x58\xC4\xAE\xA0\xD0\xED\x9A\x96\x01\xF2\x78\x11\x2C\xA7\x18\x0D\x56\x5B\x42\x0A\x48\x01\x96\x70\xEA\xF2\x4C\xE4\x93\xA8\x62\x63\xF6\x77\xB4\x6A\xCE\x19\x24\x77\x3D\x2B\xB2\x55\x71\xE1\xAA\x85\x93\x75\x8F\xC3\x82\xB1\x28\x0B\x71"
+                )
+            ,
+                ( 65472
+                , "\xB7\x0C\x50\x13\x9C\x63\x33\x2E\xF6\xE7\x7A\xC5\x43\x38\xA4\x07\x9B\x82\xBE\xC9\xF9\xA4\x03\xDF\xEA\x82\x1B\x83\xF7\x86\x07\x91\x65\x0E\xF1\xB2\x48\x9D\x05\x90\xB1\xDE\x77\x2E\xED\xA4\xE3\xBC\xD6\x0F\xA7\xCE\x9C\xD6\x23\xD9\xD2\xFD\x57\x58\xB8\x65\x3E\x70\x81\x58\x2C\x65\xD7\x56\x2B\x80\xAE\xC2\xF1\xA6\x73\xA9\xD0\x1C\x9F\x89\x2A\x23\xD4\x91\x9F\x6A\xB4\x7B\x91\x54\xE0\x8E\x69\x9B\x41\x17\xD7\xC6\x66\x47\x7B\x60\xF8\x39\x14\x81\x68\x2F\x5D\x95\xD9\x66\x23\xDB\xC4\x89\xD8\x8D\xAA\x69\x56\xB9\xF0\x64\x6B\x6E"
+                )
+            ,
+                ( 131008
+                , "\xA1\x3F\xFA\x12\x08\xF8\xBF\x50\x90\x08\x86\xFA\xAB\x40\xFD\x10\xE8\xCA\xA3\x06\xE6\x3D\xF3\x95\x36\xA1\x56\x4F\xB7\x60\xB2\x42\xA9\xD6\xA4\x62\x8C\xDC\x87\x87\x62\x83\x4E\x27\xA5\x41\xDA\x2A\x5E\x3B\x34\x45\x98\x9C\x76\xF6\x11\xE0\xFE\xC6\xD9\x1A\xCA\xCC"
+                )
+            ]
+        )
     ]
   where
-        key :: B.ByteString
-        key = "\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09"
+    key :: B.ByteString
+    key =
+        "\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09"
 
-        iv  = B.replicate 8 0
+    iv = B.replicate 8 0
 
 newtype RandomVector = RandomVector Vector
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance Arbitrary RandomVector where
     arbitrary = RandomVector <$> elements vectors
 
-tests = testGroup "Salsa"
-    [ testGroup "KAT" $
-        zipWith (\i (r,k,n,e) -> testCase (show (i :: Int)) $ salsaRunSimple e r k n) [1..] vectors
-    , testProperty "generate-combine" salsaGenerateCombine
-    , testProperty "chunking-generate" salsaGenerateChunks
-    , testProperty "chunking-combine" salsaCombineChunks
-    ]
+tests =
+    testGroup
+        "Salsa"
+        [ testGroup "KAT" $
+            zipWith
+                (\i (r, k, n, e) -> testCase (show (i :: Int)) $ salsaRunSimple e r k n)
+                [1 ..]
+                vectors
+        , testProperty "generate-combine" salsaGenerateCombine
+        , testProperty "chunking-generate" salsaGenerateChunks
+        , testProperty "chunking-combine" salsaCombineChunks
+        ]
   where
-        salsaRunSimple expected rounds key nonce =
-            let salsa = Salsa.initialize rounds key nonce
-             in map snd expected @=? salsaLoop 0 salsa expected
-
-        salsaLoop _       _     [] = []
-        salsaLoop current salsa (r@(ofs,expectBs):rs)
-            | current < ofs  =
-                let (_, salsaNext) = Salsa.generate salsa (ofs - current) :: (ByteString, Salsa.State)
-                 in salsaLoop ofs salsaNext (r:rs)
-            | current == ofs =
-                let (e, salsaNext) = Salsa.generate salsa (B.length expectBs)
-                 in e : salsaLoop (current + B.length expectBs) salsaNext rs
-            | otherwise = error "internal error in salsaLoop"
-
-        salsaGenerateCombine :: ChunkingLen0_127 -> RandomVector -> Int0_2901 -> Bool
-        salsaGenerateCombine (ChunkingLen0_127 ckLen) (RandomVector (rounds, key, iv, _)) (Int0_2901 nbBytes) =
-            let initSalsa    = Salsa.initialize rounds key iv
-             in loop nbBytes ckLen initSalsa
-          where loop n []     salsa = loop n ckLen salsa
-                loop 0 _      _     = True
-                loop n (x:xs) salsa =
-                    let len        = min x n
-                        (c1, next) = Salsa.generate salsa len
-                        (c2, _)    = Salsa.combine salsa (B.replicate len 0)
-                     in if c1 == c2 then loop (n - len) xs next else False
+    salsaRunSimple expected rounds key nonce =
+        let salsa = Salsa.initialize rounds key nonce
+         in map snd expected @=? salsaLoop 0 salsa expected
 
-        salsaGenerateChunks :: ChunkingLen -> RandomVector -> Bool
-        salsaGenerateChunks (ChunkingLen ckLen) (RandomVector (rounds, key, iv, _)) =
-            let initSalsa    = Salsa.initialize rounds key iv
-                nbBytes      = 1048
-                (expected,_) = Salsa.generate initSalsa nbBytes
-                chunks       = loop nbBytes ckLen (Salsa.initialize rounds key iv)
-             in expected == B.concat chunks
+    salsaLoop _ _ [] = []
+    salsaLoop current salsa (r@(ofs, expectBs) : rs)
+        | current < ofs =
+            let (_, salsaNext) = Salsa.generate salsa (ofs - current) :: (ByteString, Salsa.State)
+             in salsaLoop ofs salsaNext (r : rs)
+        | current == ofs =
+            let (e, salsaNext) = Salsa.generate salsa (B.length expectBs)
+             in e : salsaLoop (current + B.length expectBs) salsaNext rs
+        | otherwise = error "internal error in salsaLoop"
 
-          where loop n []     salsa = loop n ckLen salsa
-                loop 0 _      _     = []
-                loop n (x:xs) salsa =
-                    let len       = min x n
-                        (c, next) = Salsa.generate salsa len
-                     in c : loop (n - len) xs next
+    salsaGenerateCombine :: ChunkingLen0_127 -> RandomVector -> Int0_2901 -> Bool
+    salsaGenerateCombine (ChunkingLen0_127 ckLen) (RandomVector (rounds, key, iv, _)) (Int0_2901 nbBytes) =
+        let initSalsa = Salsa.initialize rounds key iv
+         in loop nbBytes ckLen initSalsa
+      where
+        loop n [] salsa = loop n ckLen salsa
+        loop 0 _ _ = True
+        loop n (x : xs) salsa =
+            let len = min x n
+                (c1, next) = Salsa.generate salsa len
+                (c2, _) = Salsa.combine salsa (B.replicate len 0)
+             in if c1 == c2 then loop (n - len) xs next else False
 
-        salsaCombineChunks :: ChunkingLen -> RandomVector -> ArbitraryBS0_2901 -> Bool
-        salsaCombineChunks (ChunkingLen ckLen) (RandomVector (rounds, key, iv, _)) (ArbitraryBS0_2901 wholebs) =
-            let initSalsa    = Salsa.initialize rounds key iv
-                (expected,_) = Salsa.combine initSalsa wholebs
-                chunks       = loop wholebs ckLen initSalsa
-             in expected `propertyEq` B.concat chunks
+    salsaGenerateChunks :: ChunkingLen -> RandomVector -> Bool
+    salsaGenerateChunks (ChunkingLen ckLen) (RandomVector (rounds, key, iv, _)) =
+        let initSalsa = Salsa.initialize rounds key iv
+            nbBytes = 1048
+            (expected, _) = Salsa.generate initSalsa nbBytes
+            chunks = loop nbBytes ckLen (Salsa.initialize rounds key iv)
+         in expected == B.concat chunks
+      where
+        loop n [] salsa = loop n ckLen salsa
+        loop 0 _ _ = []
+        loop n (x : xs) salsa =
+            let len = min x n
+                (c, next) = Salsa.generate salsa len
+             in c : loop (n - len) xs next
 
-          where loop bs []     salsa = loop bs ckLen salsa
-                loop bs (x:xs) salsa
-                    | B.null bs = []
-                    | otherwise =
-                        let (bs1, bs2) = B.splitAt (min x (B.length bs)) bs
-                            (c, next)  = Salsa.combine salsa bs1
-                         in c : loop bs2 xs next
+    salsaCombineChunks :: ChunkingLen -> RandomVector -> ArbitraryBS0_2901 -> Bool
+    salsaCombineChunks (ChunkingLen ckLen) (RandomVector (rounds, key, iv, _)) (ArbitraryBS0_2901 wholebs) =
+        let initSalsa = Salsa.initialize rounds key iv
+            (expected, _) = Salsa.combine initSalsa wholebs
+            chunks = loop wholebs ckLen initSalsa
+         in expected `propertyEq` B.concat chunks
+      where
+        loop bs [] salsa = loop bs ckLen salsa
+        loop bs (x : xs) salsa
+            | B.null bs = []
+            | otherwise =
+                let (bs1, bs2) = B.splitAt (min x (B.length bs)) bs
+                    (c, next) = Salsa.combine salsa bs1
+                 in c : loop bs2 xs next
diff --git a/tests/Tests.hs b/tests/Tests.hs
--- a/tests/Tests.hs
+++ b/tests/Tests.hs
@@ -1,39 +1,41 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module Main where
 
 import Imports
 
 import Crypto.System.CPU
 
-import qualified Number
-import qualified Number.F2m
 import qualified BCrypt
 import qualified BCryptPBKDF
+import qualified ChaCha
+import qualified ChaChaPoly1305
 import qualified ECC
 import qualified ECC.Edwards25519
 import qualified ECDSA
 import qualified Hash
-import qualified Poly1305
-import qualified Salsa
-import qualified XSalsa
-import qualified ChaCha
-import qualified ChaChaPoly1305
-import qualified KAT_MiyaguchiPreneel
+import qualified KAT_Argon2
 import qualified KAT_Blake2
 import qualified KAT_CMAC
-import qualified KAT_HMAC
-import qualified KAT_KMAC
-import qualified KAT_HKDF
-import qualified KAT_Argon2
-import qualified KAT_PBKDF2
 import qualified KAT_Curve25519
 import qualified KAT_Curve448
 import qualified KAT_Ed25519
 import qualified KAT_Ed448
 import qualified KAT_EdDSA
+import qualified KAT_HKDF
+import qualified KAT_HMAC
+import qualified KAT_KMAC
+import qualified KAT_MiyaguchiPreneel
 import qualified KAT_OTP
+import qualified KAT_PBKDF2
 import qualified KAT_PubKey
 import qualified KAT_Scrypt
+import qualified Number
+import qualified Number.F2m
+import qualified Poly1305
+import qualified Salsa
+import qualified XSalsa
+
 -- symmetric cipher --------------------
 import qualified KAT_AES
 import qualified KAT_AESGCMSIV
@@ -44,64 +46,73 @@
 import qualified KAT_RC4
 import qualified KAT_TripleDES
 import qualified KAT_Twofish
+
 -- misc --------------------------------
 import qualified KAT_AFIS
 import qualified Padding
 
-tests = testGroup "cryptonite"
-    [ testGroup "runtime"
-        [ testCaseInfo "CPU" (return $ show processorOptions)
-        ]
-    , Number.tests
-    , Number.F2m.tests
-    , Hash.tests
-    , Padding.tests
-    , testGroup "ConstructHash"
-        [ KAT_MiyaguchiPreneel.tests
-        ]
-    , testGroup "MAC"
-        [ Poly1305.tests
-        , KAT_Blake2.tests
-        , KAT_CMAC.tests
-        , KAT_HMAC.tests
-        , KAT_KMAC.tests
-        ]
-    , KAT_Curve25519.tests
-    , KAT_Curve448.tests
-    , KAT_Ed25519.tests
-    , KAT_Ed448.tests
-    , KAT_EdDSA.tests
-    , KAT_PubKey.tests
-    , KAT_OTP.tests
-    , testGroup "KDF"
-        [ KAT_PBKDF2.tests
-        , KAT_Scrypt.tests
-        , BCrypt.tests
-        , BCryptPBKDF.tests
-        , KAT_HKDF.tests
-        , KAT_Argon2.tests
-        ]
-    , testGroup "block-cipher"
-        [ KAT_AES.tests
-        , KAT_AESGCMSIV.tests
-        , KAT_Blowfish.tests
-        , KAT_CAST5.tests
-        , KAT_Camellia.tests
-        , KAT_DES.tests
-        , KAT_TripleDES.tests
-        , KAT_Twofish.tests
-        ]
-    , testGroup "stream-cipher"
-        [ KAT_RC4.tests
-        , ChaCha.tests
-        , ChaChaPoly1305.tests
-        , Salsa.tests
-        , XSalsa.tests
+tests =
+    testGroup
+        "crypton"
+        [ testGroup
+            "runtime"
+            [ testCaseInfo "CPU" (return $ show processorOptions)
+            ]
+        , Number.tests
+        , Number.F2m.tests
+        , Hash.tests
+        , Padding.tests
+        , testGroup
+            "ConstructHash"
+            [ KAT_MiyaguchiPreneel.tests
+            ]
+        , testGroup
+            "MAC"
+            [ Poly1305.tests
+            , KAT_Blake2.tests
+            , KAT_CMAC.tests
+            , KAT_HMAC.tests
+            , KAT_KMAC.tests
+            ]
+        , KAT_Curve25519.tests
+        , KAT_Curve448.tests
+        , KAT_Ed25519.tests
+        , KAT_Ed448.tests
+        , KAT_EdDSA.tests
+        , KAT_PubKey.tests
+        , KAT_OTP.tests
+        , testGroup
+            "KDF"
+            [ KAT_PBKDF2.tests
+            , KAT_Scrypt.tests
+            , BCrypt.tests
+            , BCryptPBKDF.tests
+            , KAT_HKDF.tests
+            , KAT_Argon2.tests
+            ]
+        , testGroup
+            "block-cipher"
+            [ KAT_AES.tests
+            , KAT_AESGCMSIV.tests
+            , KAT_Blowfish.tests
+            , KAT_CAST5.tests
+            , KAT_Camellia.tests
+            , KAT_DES.tests
+            , KAT_TripleDES.tests
+            , KAT_Twofish.tests
+            ]
+        , testGroup
+            "stream-cipher"
+            [ KAT_RC4.tests
+            , ChaCha.tests
+            , ChaChaPoly1305.tests
+            , Salsa.tests
+            , XSalsa.tests
+            ]
+        , KAT_AFIS.tests
+        , ECC.tests
+        , ECC.Edwards25519.tests
+        , ECDSA.tests
         ]
-    , KAT_AFIS.tests
-    , ECC.tests
-    , ECC.Edwards25519.tests
-    , ECDSA.tests
-    ]
 
 main = defaultMain tests
diff --git a/tests/Utils.hs b/tests/Utils.hs
--- a/tests/Utils.hs
+++ b/tests/Utils.hs
@@ -1,69 +1,70 @@
 {-# LANGUAGE ExistentialQuantification #-}
+
 module Utils where
 
 import Control.Applicative
-import Data.Char
-import Data.Word
-import Data.List
+import Crypto.Number.Serialize (os2ip)
+import Crypto.Random
 import Data.ByteString (ByteString)
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Lazy as L
-import Crypto.Random
-import Crypto.Number.Serialize (os2ip)
+import Data.Char
+import Data.List
+import Data.Word
 import Prelude
 
-import Test.Tasty.QuickCheck
 import Test.Tasty.HUnit ((@=?))
+import Test.Tasty.QuickCheck
 
 newtype TestDRG = TestDRG (Word64, Word64, Word64, Word64, Word64)
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance Arbitrary TestDRG where
-    arbitrary = TestDRG `fmap` arbitrary  -- distribution not uniform
+    arbitrary = TestDRG `fmap` arbitrary -- distribution not uniform
 
 withTestDRG (TestDRG l) f = fst $ withDRG (drgNewTest l) f
 
 newtype ChunkingLen = ChunkingLen [Int]
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance Arbitrary ChunkingLen where
-    arbitrary = ChunkingLen `fmap` vectorOf 16 (choose (0,14))
+    arbitrary = ChunkingLen `fmap` vectorOf 16 (choose (0, 14))
 
 newtype ChunkingLen0_127 = ChunkingLen0_127 [Int]
-    deriving (Show,Eq)
+    deriving (Show, Eq)
 
 instance Arbitrary ChunkingLen0_127 where
-    arbitrary = ChunkingLen0_127 `fmap` vectorOf 16 (choose (0,127))
-
+    arbitrary = ChunkingLen0_127 `fmap` vectorOf 16 (choose (0, 127))
 
 newtype ArbitraryBS0_2901 = ArbitraryBS0_2901 ByteString
-    deriving (Show,Eq,Ord)
+    deriving (Show, Eq, Ord)
 
 instance Arbitrary ArbitraryBS0_2901 where
     arbitrary = ArbitraryBS0_2901 `fmap` arbitraryBSof 0 2901
 
 newtype Int0_2901 = Int0_2901 Int
-    deriving (Show,Eq,Ord)
+    deriving (Show, Eq, Ord)
 
 newtype Int1_2901 = Int1_2901 Int
-    deriving (Show,Eq,Ord)
+    deriving (Show, Eq, Ord)
 
 instance Arbitrary Int0_2901 where
-    arbitrary = Int0_2901 `fmap` choose (0,2901)
+    arbitrary = Int0_2901 `fmap` choose (0, 2901)
 
 instance Arbitrary Int1_2901 where
-    arbitrary = Int1_2901 `fmap` choose (1,2901)
+    arbitrary = Int1_2901 `fmap` choose (1, 2901)
 
 -- | a integer wrapper with a better range property
-newtype QAInteger = QAInteger { getQAInteger :: Integer }
-    deriving (Show,Eq)
+newtype QAInteger = QAInteger {getQAInteger :: Integer}
+    deriving (Show, Eq)
 
 instance Arbitrary QAInteger where
-    arbitrary = oneof
-        [ QAInteger . fromIntegral <$> (choose (0, 65536) :: Gen Int)  -- small integer
-        , larger <$> choose (0,4096) <*> choose (0, 65536) -- medium integer
-        , QAInteger . os2ip <$> arbitraryBSof 0 32 -- [ 0 .. 2^32 ] sized integer
-        ]
+    arbitrary =
+        oneof
+            [ QAInteger . fromIntegral <$> (choose (0, 65536) :: Gen Int) -- small integer
+            , larger <$> choose (0, 4096) <*> choose (0, 65536) -- medium integer
+            , QAInteger . os2ip <$> arbitraryBSof 0 32 -- [ 0 .. 2^32 ] sized integer
+            ]
       where
         larger :: Int -> Int -> QAInteger
         larger p b = QAInteger (fromIntegral p * somePrime + fromIntegral b)
@@ -79,73 +80,81 @@
 
 chunkS :: ChunkingLen -> ByteString -> [ByteString]
 chunkS (ChunkingLen originalChunks) = loop originalChunks
-  where loop l bs
-            | B.null bs = []
-            | otherwise =
-                case l of
-                    (x:xs) -> let (b1, b2) = B.splitAt x bs in b1 : loop xs b2
-                    []     -> loop originalChunks bs
+  where
+    loop l bs
+        | B.null bs = []
+        | otherwise =
+            case l of
+                (x : xs) -> let (b1, b2) = B.splitAt x bs in b1 : loop xs b2
+                [] -> loop originalChunks bs
 
 chunksL :: ChunkingLen -> L.ByteString -> L.ByteString
 chunksL (ChunkingLen originalChunks) = L.fromChunks . loop originalChunks . L.toChunks
-  where loop _ []       = []
-        loop l (b:bs)
-            | B.null b  = loop l bs
-            | otherwise =
-                case l of
-                    (x:xs) -> let (b1, b2) = B.splitAt x b in b1 : loop xs (b2:bs)
-                    []     -> loop originalChunks (b:bs)
+  where
+    loop _ [] = []
+    loop l (b : bs)
+        | B.null b = loop l bs
+        | otherwise =
+            case l of
+                (x : xs) -> let (b1, b2) = B.splitAt x b in b1 : loop xs (b2 : bs)
+                [] -> loop originalChunks (b : bs)
 
 katZero :: Int
 katZero = 0
 
---hexalise :: String -> [Word8]
-hexalise s = concatMap (\c -> [ hex $ c `div` 16, hex $ c `mod` 16 ]) s
-  where hex i
-            | i >= 0 && i <= 9   = fromIntegral (ord '0') + i
-            | i >= 10 && i <= 15 = fromIntegral (ord 'a') + i - 10
-            | otherwise          = 0
+-- hexalise :: String -> [Word8]
+hexalise s = concatMap (\c -> [hex $ c `div` 16, hex $ c `mod` 16]) s
+  where
+    hex i
+        | i >= 0 && i <= 9 = fromIntegral (ord '0') + i
+        | i >= 10 && i <= 15 = fromIntegral (ord 'a') + i - 10
+        | otherwise = 0
 
 splitB :: Int -> ByteString -> [ByteString]
 splitB l b =
     if B.length b > l
         then
-            let (b1, b2) = B.splitAt l b in
-            b1 : splitB l b2
+            let (b1, b2) = B.splitAt l b
+             in b1 : splitB l b2
         else
-            [ b ]
+            [b]
 
 assertBytesEq :: ByteString -> ByteString -> Bool
-assertBytesEq b1 b2 | b1 /= b2  = error ("expected: " ++ show b1 ++ " got: " ++ show b2)
-                    | otherwise = True
+assertBytesEq b1 b2
+    | b1 /= b2 = error ("expected: " ++ show b1 ++ " got: " ++ show b2)
+    | otherwise = True
 
 assertEq :: (Show a, Eq a) => a -> a -> Bool
-assertEq b1 b2 | b1 /= b2  = error ("expected: " ++ show b1 ++ " got: " ++ show b2)
-               | otherwise = True
+assertEq b1 b2
+    | b1 /= b2 = error ("expected: " ++ show b1 ++ " got: " ++ show b2)
+    | otherwise = True
 
 propertyEq :: (Show a, Eq a) => a -> a -> Bool
 propertyEq = assertEq
 
-data PropertyTest =
-      forall a . (Show a, Eq a) => EqTest String a a
+data PropertyTest
+    = forall a. (Show a, Eq a) => EqTest String a a
 
 type PropertyName = String
 
-eqTest :: (Show a, Eq a)
-       => PropertyName
-       -> a -- ^ expected value
-       -> a -- ^ got
-       -> PropertyTest
+eqTest
+    :: (Show a, Eq a)
+    => PropertyName
+    -> a
+    -- ^ expected value
+    -> a
+    -- ^ got
+    -> PropertyTest
 eqTest name a b = EqTest name a b
 
 propertyHold :: [PropertyTest] -> Bool
 propertyHold l =
     case foldl runProperty [] l of
-        []     -> True
+        [] -> True
         failed -> error (intercalate "\n" failed)
   where
     runProperty acc (EqTest name a b)
-        | a == b    = acc
+        | a == b = acc
         | otherwise =
             (name ++ ": expected " ++ show a ++ " but got: " ++ show b) : acc
 
diff --git a/tests/XSalsa.hs b/tests/XSalsa.hs
--- a/tests/XSalsa.hs
+++ b/tests/XSalsa.hs
@@ -1,128 +1,173 @@
 {-# LANGUAGE OverloadedStrings #-}
+
 module XSalsa (tests) where
 
-import qualified Data.ByteString as B
 import qualified Crypto.Cipher.XSalsa as XSalsa
+import qualified Data.ByteString as B
 
-import           Imports
+import Imports
 
 type Vector = (Int, B.ByteString, B.ByteString, B.ByteString, B.ByteString)
 
 -- Test vectors generated by naclcrypto library (https://nacl.cr.yp.to)
 vectors :: [Vector]
 vectors =
-    [ ( 20
-       , "\xA6\xA7\x25\x1C\x1E\x72\x91\x6D\x11\xC2\xCB\x21\x4D\x3C\x25\x25\x39\x12\x1D\x8E\x23\x4E\x65\x2D\x65\x1F\xA4\xC8\xCF\xF8\x80\x30"
-       , "\x9E\x64\x5A\x74\xE9\xE0\xA6\x0D\x82\x43\xAC\xD9\x17\x7A\xB5\x1A\x1B\xEB\x8D\x5A\x2F\x5D\x70\x0C"
-       , "\x09\x3C\x5E\x55\x85\x57\x96\x25\x33\x7B\xD3\xAB\x61\x9D\x61\x57\x60\xD8\xC5\xB2\x24\xA8\x5B\x1D\x0E\xFE\x0E\xB8\xA7\xEE\x16\x3A\xBB\x03\x76\x52\x9F\xCC\x09\xBA\xB5\x06\xC6\x18\xE1\x3C\xE7\x77\xD8\x2C\x3A\xE9\xD1\xA6\xF9\x72\xD4\x16\x02\x87\xCB\xFE\x60\xBF\x21\x30\xFC\x0A\x6F\xF6\x04\x9D\x0A\x5C\x8A\x82\xF4\x29\x23\x1F\x00\x80\x82\xE8\x45\xD7\xE1\x89\xD3\x7F\x9E\xD2\xB4\x64\xE6\xB9\x19\xE6\x52\x3A\x8C\x12\x10\xBD\x52\xA0\x2A\x4C\x3F\xE4\x06\xD3\x08\x5F\x50\x68\xD1\x90\x9E\xEE\xCA\x63\x69\xAB\xC9\x81\xA4\x2E\x87\xFE\x66\x55\x83\xF0\xAB\x85\xAE\x71\xF6\xF8\x4F\x52\x8E\x6B\x39\x7A\xF8\x6F\x69\x17\xD9\x75\x4B\x73\x20\xDB\xDC\x2F\xEA\x81\x49\x6F\x27\x32\xF5\x32\xAC\x78\xC4\xE9\xC6\xCF\xB1\x8F\x8E\x9B\xDF\x74\x62\x2E\xB1\x26\x14\x14\x16\x77\x69\x71\xA8\x4F\x94\xD1\x56\xBE\xAF\x67\xAE\xCB\xF2\xAD\x41\x2E\x76\xE6\x6E\x8F\xAD\x76\x33\xF5\xB6\xD7\xF3\xD6\x4B\x5C\x6C\x69\xCE\x29\x00\x3C\x60\x24\x46\x5A\xE3\xB8\x9B\xE7\x8E\x91\x5D\x88\xB4\xB5\x62\x1D"
-       , "\xB2\xAF\x68\x8E\x7D\x8F\xC4\xB5\x08\xC0\x5C\xC3\x9D\xD5\x83\xD6\x71\x43\x22\xC6\x4D\x7F\x3E\x63\x14\x7A\xED\xE2\xD9\x53\x49\x34\xB0\x4F\xF6\xF3\x37\xB0\x31\x81\x5C\xD0\x94\xBD\xBC\x6D\x7A\x92\x07\x7D\xCE\x70\x94\x12\x28\x68\x22\xEF\x07\x37\xEE\x47\xF6\xB7\xFF\xA2\x2F\x9D\x53\xF1\x1D\xD2\xB0\xA3\xBB\x9F\xC0\x1D\x9A\x88\xF9\xD5\x3C\x26\xE9\x36\x5C\x2C\x3C\x06\x3B\xC4\x84\x0B\xFC\x81\x2E\x4B\x80\x46\x3E\x69\xD1\x79\x53\x0B\x25\xC1\x58\xF5\x43\x19\x1C\xFF\x99\x31\x06\x51\x1A\xA0\x36\x04\x3B\xBC\x75\x86\x6A\xB7\xE3\x4A\xFC\x57\xE2\xCC\xE4\x93\x4A\x5F\xAA\xE6\xEA\xBE\x4F\x22\x17\x70\x18\x3D\xD0\x60\x46\x78\x27\xC2\x7A\x35\x41\x59\xA0\x81\x27\x5A\x29\x1F\x69\xD9\x46\xD6\xFE\x28\xED\x0B\x9C\xE0\x82\x06\xCF\x48\x49\x25\xA5\x1B\x94\x98\xDB\xDE\x17\x8D\xDD\x3A\xE9\x1A\x85\x81\xB9\x16\x82\xD8\x60\xF8\x40\x78\x2F\x6E\xEA\x49\xDB\xB9\xBD\x72\x15\x01\xD2\xC6\x71\x22\xDE\xA3\xB7\x28\x38\x48\xC5\xF1\x3E\x0C\x0D\xE8\x76\xBD\x22\x7A\x85\x6E\x4D\xE5\x93\xA3")
-    , ( 20
-       , "\x9E\x1D\xA2\x39\xD1\x55\xF5\x2A\xD3\x7F\x75\xC7\x36\x8A\x53\x66\x68\xB0\x51\x95\x29\x23\xAD\x44\xF5\x7E\x75\xAB\x58\x8E\x47\x5A"
-       , "\xAF\x06\xF1\x78\x59\xDF\xFA\x79\x98\x91\xC4\x28\x8F\x66\x35\xB5\xC5\xA4\x5E\xEE\x90\x17\xFD\x72"
-       , "\xFE\xAC\x9D\x54\xFC\x8C\x11\x5A\xE2\x47\xD9\xA7\xE9\x19\xDD\x76\xCF\xCB\xC7\x2D\x32\xCA\xE4\x94\x48\x60\x81\x7C\xBD\xFB\x8C\x04\xE6\xB1\xDF\x76\xA1\x65\x17\xCD\x33\xCC\xF1\xAC\xDA\x92\x06\x38\x9E\x9E\x31\x8F\x59\x66\xC0\x93\xCF\xB3\xEC\x2D\x9E\xE2\xDE\x85\x64\x37\xED\x58\x1F\x55\x2F\x26\xAC\x29\x07\x60\x9D\xF8\xC6\x13\xB9\xE3\x3D\x44\xBF\xC2\x1F\xF7\x91\x53\xE9\xEF\x81\xA9\xD6\x6C\xC3\x17\x85\x7F\x75\x2C\xC1\x75\xFD\x88\x91\xFE\xFE\xBB\x7D\x04\x1E\x65\x17\xC3\x16\x2D\x19\x7E\x21\x12\x83\x7D\x3B\xC4\x10\x43\x12\xAD\x35\xB7\x5E\xA6\x86\xE7\xC7\x0D\x4E\xC0\x47\x46\xB5\x2F\xF0\x9C\x42\x14\x51\x45\x9F\xB5\x9F"
-       , "\x2C\x26\x1A\x2F\x4E\x61\xA6\x2E\x1B\x27\x68\x99\x16\xBF\x03\x45\x3F\xCB\xC9\x7B\xB2\xAF\x6F\x32\x93\x91\xEF\x06\x3B\x5A\x21\x9B\xF9\x84\xD0\x7D\x70\xF6\x02\xD8\x5F\x6D\xB6\x14\x74\xE9\xD9\xF5\xA2\xDE\xEC\xB4\xFC\xD9\x01\x84\xD1\x6F\x3B\x5B\x5E\x16\x8E\xE0\x3E\xA8\xC9\x3F\x39\x33\xA2\x2B\xC3\xD1\xA5\xAE\x8C\x2D\x8B\x02\x75\x7C\x87\xC0\x73\x40\x90\x52\xA2\xA8\xA4\x1E\x7F\x48\x7E\x04\x1F\x9A\x49\xA0\x99\x7B\x54\x0E\x18\x62\x1C\xAD\x3A\x24\xF0\xA5\x6D\x9B\x19\x22\x79\x29\x05\x7A\xB3\xBA\x95\x0F\x62\x74\xB1\x21\xF1\x93\xE3\x2E\x06\xE5\x38\x87\x81\xA1\xCB\x57\x31\x7C\x0B\xA6\x30\x5E\x91\x09\x61\xD0\x10\x02\xF0")
-    , ( 20
-       , "\xD5\xC7\xF6\x79\x7B\x7E\x7E\x9C\x1D\x7F\xD2\x61\x0B\x2A\xBF\x2B\xC5\xA7\x88\x5F\xB3\xFF\x78\x09\x2F\xB3\xAB\xE8\x98\x6D\x35\xE2"
-       , "\x74\x4E\x17\x31\x2B\x27\x96\x9D\x82\x64\x44\x64\x0E\x9C\x4A\x37\x8A\xE3\x34\xF1\x85\x36\x9C\x95"
-       , "\x77\x58\x29\x8C\x62\x8E\xB3\xA4\xB6\x96\x3C\x54\x45\xEF\x66\x97\x12\x22\xBE\x5D\x1A\x4A\xD8\x39\x71\x5D\x11\x88\x07\x17\x39\xB7\x7C\xC6\xE0\x5D\x54\x10\xF9\x63\xA6\x41\x67\x62\x97\x57"
-       , "\x27\xB8\xCF\xE8\x14\x16\xA7\x63\x01\xFD\x1E\xEC\x6A\x4D\x99\x67\x50\x69\xB2\xDA\x27\x76\xC3\x60\xDB\x1B\xDF\xEA\x7C\x0A\xA6\x13\x91\x3E\x10\xF7\xA6\x0F\xEC\x04\xD1\x1E\x65\xF2\xD6\x4E")
-    , ( 20
-       , "\x73\x7D\x78\x11\xCE\x96\x47\x2E\xFE\xD1\x22\x58\xB7\x81\x22\xF1\x1D\xEA\xEC\x87\x59\xCC\xBD\x71\xEA\xC6\xBB\xEF\xA6\x27\x78\x5C"
-       , "\x6F\xB2\xEE\x3D\xDA\x6D\xBD\x12\xF1\x27\x4F\x12\x67\x01\xEC\x75\xC3\x5C\x86\x60\x7A\xDB\x3E\xDD"
-       , "\x50\x13\x25\xFB\x26\x45\x26\x48\x64\xDF\x11\xFA\xA1\x7B\xBD\x58\x31\x2B\x77\xCA\xD3\xD9\x4A\xC8\xFB\x85\x42\xF0\xEB\x65\x3A\xD7\x3D\x7F\xCE\x93\x2B\xB8\x74\xCB\x89\xAC\x39\xFC\x47\xF8\x26\x7C\xF0\xF0\xC2\x09\xF2\x04\xB2\xD8\x57\x8A\x3B\xDF\x46\x1C\xB6\xA2\x71\xA4\x68\xBE\xBA\xCC\xD9\x68\x50\x14\xCC\xBC\x9A\x73\x61\x8C\x6A\x5E\x77\x8A\x21\xCC\x84\x16\xC6\x0A\xD2\x4D\xDC\x41\x7A\x13\x0D\x53\xED\xA6\xDF\xBF\xE4\x7D\x09\x17\x0A\x7B\xE1\xA7\x08\xB7\xB5\xF3\xAD\x46\x43\x10\xBE\x36\xD9\xA2\xA9\x5D\xC3\x9E\x83\xD3\x86\x67\xE8\x42\xEB\x64\x11\xE8\xA2\x37\x12\x29\x7B\x16\x5F\x69\x0C\x2D\x7C\xA1\xB1\x34\x6E\x3C\x1F\xCC\xF5\xCA\xFD\x4F\x8B\xE0"
-       , "\x67\x24\xC3\x72\xD2\xE9\x07\x4D\xA5\xE2\x7A\x6C\x54\xB2\xD7\x03\xDC\x1D\x4C\x9B\x1F\x8D\x90\xF0\x0C\x12\x2E\x69\x2A\xCE\x77\x00\xEA\xDC\xA9\x42\x54\x45\x07\xF1\x37\x5B\x65\x81\xD5\xA8\xFB\x39\x98\x1C\x1C\x0E\x6E\x1F\xF2\x14\x0B\x08\x2E\x9E\xC0\x16\xFC\xE1\x41\xD5\x19\x96\x47\xD4\x3B\x0B\x68\xBF\xD0\xFE\xA5\xE0\x0F\x46\x89\x62\xC7\x38\x4D\xD6\x12\x9A\xEA\x6A\x3F\xDF\xE7\x5A\xBB\x21\x0E\xD5\x60\x7C\xEF\x8F\xA0\xE1\x52\x83\x3D\x5A\xC3\x7D\x52\xE5\x57\xB9\x10\x98\xA3\x22\xE7\x6A\x45\xBB\xBC\xF4\x89\x9E\x79\x06\x18\xAA\x3F\x4C\x2E\x5E\x0F\xC3\xDE\x93\x26\x9A\x57\x7D\x77\xA5\x50\x2E\x8E\xA0\x2F\x71\x7B\x1D\xD2\xDF\x1E\xC6\x9D\x8B\x61\xCA")
-    , ( 20
-       , "\x76\x01\x58\xDA\x09\xF8\x9B\xBA\xB2\xC9\x9E\x69\x97\xF9\x52\x3A\x95\xFC\xEF\x10\x23\x9B\xCC\xA2\x57\x3B\x71\x05\xF6\x89\x8D\x34"
-       , "\x43\x63\x6B\x2C\xC3\x46\xFC\x8B\x7C\x85\xA1\x9B\xF5\x07\xBD\xC3\xDA\xFE\x95\x3B\x88\xC6\x9D\xBA"
-       , "\xD3\x0A\x6D\x42\xDF\xF4\x9F\x0E\xD0\x39\xA3\x06\xBA\xE9\xDE\xC8\xD9\xE8\x83\x66\xCC\x19\xE8\xC3\x64\x2F\xD5\x8F\xA0\x79\x4E\xBF\x80\x29\xD9\x49\x73\x03\x39\xB0\x82\x3A\x51\xF0\xF4\x9F\x0D\x2C\x71\xF1\x05\x1C\x1E\x0E\x2C\x86\x94\x1F\x17\x27\x89\xCD\xB1\xB0\x10\x74\x13\xE7\x0F\x98\x2F\xF9\x76\x18\x77\xBB\x52\x6E\xF1\xC3\xEB\x11\x06\xA9\x48\xD6\x0E\xF2\x1B\xD3\x5D\x32\xCF\xD6\x4F\x89\xB7\x9E\xD6\x3E\xCC\x5C\xCA\x56\x24\x6A\xF7\x36\x76\x6F\x28\x5D\x8E\x6B\x0D\xA9\xCB\x1C\xD2\x10\x20\x22\x3F\xFA\xCC\x5A\x32"
-       , "\xC8\x15\xB6\xB7\x9B\x64\xF9\x36\x9A\xEC\x8D\xCE\x8C\x75\x3D\xF8\xA5\x0F\x2B\xC9\x7C\x70\xCE\x2F\x01\x4D\xB3\x3A\x65\xAC\x58\x16\xBA\xC9\xE3\x0A\xC0\x8B\xDD\xED\x30\x8C\x65\xCB\x87\xE2\x8E\x2E\x71\xB6\x77\xDC\x25\xC5\xA6\x49\x9C\x15\x53\x55\x5D\xAF\x1F\x55\x27\x0A\x56\x95\x9D\xFF\xA0\xC6\x6F\x24\xE0\xAF\x00\x95\x1E\xC4\xBB\x59\xCC\xC3\xA6\xC5\xF5\x2E\x09\x81\x64\x7E\x53\xE4\x39\x31\x3A\x52\xC4\x0F\xA7\x00\x4C\x85\x5B\x6E\x6E\xB2\x5B\x21\x2A\x13\x8E\x84\x3A\x9B\xA4\x6E\xDB\x2A\x03\x9E\xE8\x2A\x26\x3A\xBE")
-    , ( 20
-       , "\x27\xBA\x7E\x81\xE7\xED\xD4\xE7\x1B\xE5\x3C\x07\xCE\x8E\x63\x31\x38\xF2\x87\xE1\x55\xC7\xFA\x9E\x84\xC4\xAD\x80\x4B\x7F\xA1\xB9"
-       , "\xEA\x05\xF4\xEB\xCD\x2F\xB6\xB0\x00\xDA\x06\x12\x86\x1B\xA5\x4F\xF5\xC1\x76\xFB\x60\x13\x91\xAA"
-       , "\xE0\x9F\xF5\xD2\xCB\x05\x0D\x69\xB2\xD4\x24\x94\xBD\xE5\x82\x52\x38\xC7\x56\xD6\x99\x1D\x99\xD7\xA2\x0D\x1E\xF0\xB8\x3C\x37\x1C\x89\x87\x26\x90\xB2\xFC\x11\xD5\x36\x9F\x4F\xC4\x97\x1B\x6D\x3D\x6C\x07\x8A\xEF\x9B\x0F\x05\xC0\xE6\x1A\xB8\x9C\x02\x51\x68\x05\x4D\xEF\xEB\x03\xFE\xF6\x33\x85\x87\x00\xC5\x8B\x12\x62\xCE\x01\x13\x00\x01\x26\x73\xE8\x93\xE4\x49\x01\xDC\x18\xEE\xE3\x10\x56\x99\xC4\x4C\x80\x58\x97\xBD\xAF\x77\x6A\xF1\x83\x31\x62\xA2\x1A"
-       , "\xA2\x3E\x7E\xF9\x3C\x5D\x06\x67\xC9\x6D\x9E\x40\x4D\xCB\xE6\xBE\x62\x02\x6F\xA9\x8F\x7A\x3F\xF9\xBA\x5D\x45\x86\x43\xA1\x6A\x1C\xEF\x72\x72\xDC\x60\x97\xA9\xB5\x2F\x35\x98\x35\x57\xC7\x7A\x11\xB3\x14\xB4\xF7\xD5\xDC\x2C\xCA\x15\xEE\x47\x61\x6F\x86\x18\x73\xCB\xFE\xD1\xD3\x23\x72\x17\x1A\x61\xE3\x8E\x44\x7F\x3C\xF3\x62\xB3\xAB\xBB\x2E\xD4\x17\x0D\x89\xDC\xB2\x81\x87\xB7\xBF\xD2\x06\xA3\xE0\x26\xF0\x84\xA7\xE0\xED\x63\xD3\x19\xDE\x6B\xC9\xAF\xC0")
-    , ( 20
-       , "\x67\x99\xD7\x6E\x5F\xFB\x5B\x49\x20\xBC\x27\x68\xBA\xFD\x3F\x8C\x16\x55\x4E\x65\xEF\xCF\x9A\x16\xF4\x68\x3A\x7A\x06\x92\x7C\x11"
-       , "\x61\xAB\x95\x19\x21\xE5\x4F\xF0\x6D\x9B\x77\xF3\x13\xA4\xE4\x9D\xF7\xA0\x57\xD5\xFD\x62\x79\x89"
-       , "\x47\x27\x66"
-       , "\x8F\xD7\xDF")
-    , ( 20
+    [
+        ( 20
+        , "\xA6\xA7\x25\x1C\x1E\x72\x91\x6D\x11\xC2\xCB\x21\x4D\x3C\x25\x25\x39\x12\x1D\x8E\x23\x4E\x65\x2D\x65\x1F\xA4\xC8\xCF\xF8\x80\x30"
+        , "\x9E\x64\x5A\x74\xE9\xE0\xA6\x0D\x82\x43\xAC\xD9\x17\x7A\xB5\x1A\x1B\xEB\x8D\x5A\x2F\x5D\x70\x0C"
+        , "\x09\x3C\x5E\x55\x85\x57\x96\x25\x33\x7B\xD3\xAB\x61\x9D\x61\x57\x60\xD8\xC5\xB2\x24\xA8\x5B\x1D\x0E\xFE\x0E\xB8\xA7\xEE\x16\x3A\xBB\x03\x76\x52\x9F\xCC\x09\xBA\xB5\x06\xC6\x18\xE1\x3C\xE7\x77\xD8\x2C\x3A\xE9\xD1\xA6\xF9\x72\xD4\x16\x02\x87\xCB\xFE\x60\xBF\x21\x30\xFC\x0A\x6F\xF6\x04\x9D\x0A\x5C\x8A\x82\xF4\x29\x23\x1F\x00\x80\x82\xE8\x45\xD7\xE1\x89\xD3\x7F\x9E\xD2\xB4\x64\xE6\xB9\x19\xE6\x52\x3A\x8C\x12\x10\xBD\x52\xA0\x2A\x4C\x3F\xE4\x06\xD3\x08\x5F\x50\x68\xD1\x90\x9E\xEE\xCA\x63\x69\xAB\xC9\x81\xA4\x2E\x87\xFE\x66\x55\x83\xF0\xAB\x85\xAE\x71\xF6\xF8\x4F\x52\x8E\x6B\x39\x7A\xF8\x6F\x69\x17\xD9\x75\x4B\x73\x20\xDB\xDC\x2F\xEA\x81\x49\x6F\x27\x32\xF5\x32\xAC\x78\xC4\xE9\xC6\xCF\xB1\x8F\x8E\x9B\xDF\x74\x62\x2E\xB1\x26\x14\x14\x16\x77\x69\x71\xA8\x4F\x94\xD1\x56\xBE\xAF\x67\xAE\xCB\xF2\xAD\x41\x2E\x76\xE6\x6E\x8F\xAD\x76\x33\xF5\xB6\xD7\xF3\xD6\x4B\x5C\x6C\x69\xCE\x29\x00\x3C\x60\x24\x46\x5A\xE3\xB8\x9B\xE7\x8E\x91\x5D\x88\xB4\xB5\x62\x1D"
+        , "\xB2\xAF\x68\x8E\x7D\x8F\xC4\xB5\x08\xC0\x5C\xC3\x9D\xD5\x83\xD6\x71\x43\x22\xC6\x4D\x7F\x3E\x63\x14\x7A\xED\xE2\xD9\x53\x49\x34\xB0\x4F\xF6\xF3\x37\xB0\x31\x81\x5C\xD0\x94\xBD\xBC\x6D\x7A\x92\x07\x7D\xCE\x70\x94\x12\x28\x68\x22\xEF\x07\x37\xEE\x47\xF6\xB7\xFF\xA2\x2F\x9D\x53\xF1\x1D\xD2\xB0\xA3\xBB\x9F\xC0\x1D\x9A\x88\xF9\xD5\x3C\x26\xE9\x36\x5C\x2C\x3C\x06\x3B\xC4\x84\x0B\xFC\x81\x2E\x4B\x80\x46\x3E\x69\xD1\x79\x53\x0B\x25\xC1\x58\xF5\x43\x19\x1C\xFF\x99\x31\x06\x51\x1A\xA0\x36\x04\x3B\xBC\x75\x86\x6A\xB7\xE3\x4A\xFC\x57\xE2\xCC\xE4\x93\x4A\x5F\xAA\xE6\xEA\xBE\x4F\x22\x17\x70\x18\x3D\xD0\x60\x46\x78\x27\xC2\x7A\x35\x41\x59\xA0\x81\x27\x5A\x29\x1F\x69\xD9\x46\xD6\xFE\x28\xED\x0B\x9C\xE0\x82\x06\xCF\x48\x49\x25\xA5\x1B\x94\x98\xDB\xDE\x17\x8D\xDD\x3A\xE9\x1A\x85\x81\xB9\x16\x82\xD8\x60\xF8\x40\x78\x2F\x6E\xEA\x49\xDB\xB9\xBD\x72\x15\x01\xD2\xC6\x71\x22\xDE\xA3\xB7\x28\x38\x48\xC5\xF1\x3E\x0C\x0D\xE8\x76\xBD\x22\x7A\x85\x6E\x4D\xE5\x93\xA3"
+        )
+    ,
+        ( 20
+        , "\x9E\x1D\xA2\x39\xD1\x55\xF5\x2A\xD3\x7F\x75\xC7\x36\x8A\x53\x66\x68\xB0\x51\x95\x29\x23\xAD\x44\xF5\x7E\x75\xAB\x58\x8E\x47\x5A"
+        , "\xAF\x06\xF1\x78\x59\xDF\xFA\x79\x98\x91\xC4\x28\x8F\x66\x35\xB5\xC5\xA4\x5E\xEE\x90\x17\xFD\x72"
+        , "\xFE\xAC\x9D\x54\xFC\x8C\x11\x5A\xE2\x47\xD9\xA7\xE9\x19\xDD\x76\xCF\xCB\xC7\x2D\x32\xCA\xE4\x94\x48\x60\x81\x7C\xBD\xFB\x8C\x04\xE6\xB1\xDF\x76\xA1\x65\x17\xCD\x33\xCC\xF1\xAC\xDA\x92\x06\x38\x9E\x9E\x31\x8F\x59\x66\xC0\x93\xCF\xB3\xEC\x2D\x9E\xE2\xDE\x85\x64\x37\xED\x58\x1F\x55\x2F\x26\xAC\x29\x07\x60\x9D\xF8\xC6\x13\xB9\xE3\x3D\x44\xBF\xC2\x1F\xF7\x91\x53\xE9\xEF\x81\xA9\xD6\x6C\xC3\x17\x85\x7F\x75\x2C\xC1\x75\xFD\x88\x91\xFE\xFE\xBB\x7D\x04\x1E\x65\x17\xC3\x16\x2D\x19\x7E\x21\x12\x83\x7D\x3B\xC4\x10\x43\x12\xAD\x35\xB7\x5E\xA6\x86\xE7\xC7\x0D\x4E\xC0\x47\x46\xB5\x2F\xF0\x9C\x42\x14\x51\x45\x9F\xB5\x9F"
+        , "\x2C\x26\x1A\x2F\x4E\x61\xA6\x2E\x1B\x27\x68\x99\x16\xBF\x03\x45\x3F\xCB\xC9\x7B\xB2\xAF\x6F\x32\x93\x91\xEF\x06\x3B\x5A\x21\x9B\xF9\x84\xD0\x7D\x70\xF6\x02\xD8\x5F\x6D\xB6\x14\x74\xE9\xD9\xF5\xA2\xDE\xEC\xB4\xFC\xD9\x01\x84\xD1\x6F\x3B\x5B\x5E\x16\x8E\xE0\x3E\xA8\xC9\x3F\x39\x33\xA2\x2B\xC3\xD1\xA5\xAE\x8C\x2D\x8B\x02\x75\x7C\x87\xC0\x73\x40\x90\x52\xA2\xA8\xA4\x1E\x7F\x48\x7E\x04\x1F\x9A\x49\xA0\x99\x7B\x54\x0E\x18\x62\x1C\xAD\x3A\x24\xF0\xA5\x6D\x9B\x19\x22\x79\x29\x05\x7A\xB3\xBA\x95\x0F\x62\x74\xB1\x21\xF1\x93\xE3\x2E\x06\xE5\x38\x87\x81\xA1\xCB\x57\x31\x7C\x0B\xA6\x30\x5E\x91\x09\x61\xD0\x10\x02\xF0"
+        )
+    ,
+        ( 20
+        , "\xD5\xC7\xF6\x79\x7B\x7E\x7E\x9C\x1D\x7F\xD2\x61\x0B\x2A\xBF\x2B\xC5\xA7\x88\x5F\xB3\xFF\x78\x09\x2F\xB3\xAB\xE8\x98\x6D\x35\xE2"
+        , "\x74\x4E\x17\x31\x2B\x27\x96\x9D\x82\x64\x44\x64\x0E\x9C\x4A\x37\x8A\xE3\x34\xF1\x85\x36\x9C\x95"
+        , "\x77\x58\x29\x8C\x62\x8E\xB3\xA4\xB6\x96\x3C\x54\x45\xEF\x66\x97\x12\x22\xBE\x5D\x1A\x4A\xD8\x39\x71\x5D\x11\x88\x07\x17\x39\xB7\x7C\xC6\xE0\x5D\x54\x10\xF9\x63\xA6\x41\x67\x62\x97\x57"
+        , "\x27\xB8\xCF\xE8\x14\x16\xA7\x63\x01\xFD\x1E\xEC\x6A\x4D\x99\x67\x50\x69\xB2\xDA\x27\x76\xC3\x60\xDB\x1B\xDF\xEA\x7C\x0A\xA6\x13\x91\x3E\x10\xF7\xA6\x0F\xEC\x04\xD1\x1E\x65\xF2\xD6\x4E"
+        )
+    ,
+        ( 20
+        , "\x73\x7D\x78\x11\xCE\x96\x47\x2E\xFE\xD1\x22\x58\xB7\x81\x22\xF1\x1D\xEA\xEC\x87\x59\xCC\xBD\x71\xEA\xC6\xBB\xEF\xA6\x27\x78\x5C"
+        , "\x6F\xB2\xEE\x3D\xDA\x6D\xBD\x12\xF1\x27\x4F\x12\x67\x01\xEC\x75\xC3\x5C\x86\x60\x7A\xDB\x3E\xDD"
+        , "\x50\x13\x25\xFB\x26\x45\x26\x48\x64\xDF\x11\xFA\xA1\x7B\xBD\x58\x31\x2B\x77\xCA\xD3\xD9\x4A\xC8\xFB\x85\x42\xF0\xEB\x65\x3A\xD7\x3D\x7F\xCE\x93\x2B\xB8\x74\xCB\x89\xAC\x39\xFC\x47\xF8\x26\x7C\xF0\xF0\xC2\x09\xF2\x04\xB2\xD8\x57\x8A\x3B\xDF\x46\x1C\xB6\xA2\x71\xA4\x68\xBE\xBA\xCC\xD9\x68\x50\x14\xCC\xBC\x9A\x73\x61\x8C\x6A\x5E\x77\x8A\x21\xCC\x84\x16\xC6\x0A\xD2\x4D\xDC\x41\x7A\x13\x0D\x53\xED\xA6\xDF\xBF\xE4\x7D\x09\x17\x0A\x7B\xE1\xA7\x08\xB7\xB5\xF3\xAD\x46\x43\x10\xBE\x36\xD9\xA2\xA9\x5D\xC3\x9E\x83\xD3\x86\x67\xE8\x42\xEB\x64\x11\xE8\xA2\x37\x12\x29\x7B\x16\x5F\x69\x0C\x2D\x7C\xA1\xB1\x34\x6E\x3C\x1F\xCC\xF5\xCA\xFD\x4F\x8B\xE0"
+        , "\x67\x24\xC3\x72\xD2\xE9\x07\x4D\xA5\xE2\x7A\x6C\x54\xB2\xD7\x03\xDC\x1D\x4C\x9B\x1F\x8D\x90\xF0\x0C\x12\x2E\x69\x2A\xCE\x77\x00\xEA\xDC\xA9\x42\x54\x45\x07\xF1\x37\x5B\x65\x81\xD5\xA8\xFB\x39\x98\x1C\x1C\x0E\x6E\x1F\xF2\x14\x0B\x08\x2E\x9E\xC0\x16\xFC\xE1\x41\xD5\x19\x96\x47\xD4\x3B\x0B\x68\xBF\xD0\xFE\xA5\xE0\x0F\x46\x89\x62\xC7\x38\x4D\xD6\x12\x9A\xEA\x6A\x3F\xDF\xE7\x5A\xBB\x21\x0E\xD5\x60\x7C\xEF\x8F\xA0\xE1\x52\x83\x3D\x5A\xC3\x7D\x52\xE5\x57\xB9\x10\x98\xA3\x22\xE7\x6A\x45\xBB\xBC\xF4\x89\x9E\x79\x06\x18\xAA\x3F\x4C\x2E\x5E\x0F\xC3\xDE\x93\x26\x9A\x57\x7D\x77\xA5\x50\x2E\x8E\xA0\x2F\x71\x7B\x1D\xD2\xDF\x1E\xC6\x9D\x8B\x61\xCA"
+        )
+    ,
+        ( 20
+        , "\x76\x01\x58\xDA\x09\xF8\x9B\xBA\xB2\xC9\x9E\x69\x97\xF9\x52\x3A\x95\xFC\xEF\x10\x23\x9B\xCC\xA2\x57\x3B\x71\x05\xF6\x89\x8D\x34"
+        , "\x43\x63\x6B\x2C\xC3\x46\xFC\x8B\x7C\x85\xA1\x9B\xF5\x07\xBD\xC3\xDA\xFE\x95\x3B\x88\xC6\x9D\xBA"
+        , "\xD3\x0A\x6D\x42\xDF\xF4\x9F\x0E\xD0\x39\xA3\x06\xBA\xE9\xDE\xC8\xD9\xE8\x83\x66\xCC\x19\xE8\xC3\x64\x2F\xD5\x8F\xA0\x79\x4E\xBF\x80\x29\xD9\x49\x73\x03\x39\xB0\x82\x3A\x51\xF0\xF4\x9F\x0D\x2C\x71\xF1\x05\x1C\x1E\x0E\x2C\x86\x94\x1F\x17\x27\x89\xCD\xB1\xB0\x10\x74\x13\xE7\x0F\x98\x2F\xF9\x76\x18\x77\xBB\x52\x6E\xF1\xC3\xEB\x11\x06\xA9\x48\xD6\x0E\xF2\x1B\xD3\x5D\x32\xCF\xD6\x4F\x89\xB7\x9E\xD6\x3E\xCC\x5C\xCA\x56\x24\x6A\xF7\x36\x76\x6F\x28\x5D\x8E\x6B\x0D\xA9\xCB\x1C\xD2\x10\x20\x22\x3F\xFA\xCC\x5A\x32"
+        , "\xC8\x15\xB6\xB7\x9B\x64\xF9\x36\x9A\xEC\x8D\xCE\x8C\x75\x3D\xF8\xA5\x0F\x2B\xC9\x7C\x70\xCE\x2F\x01\x4D\xB3\x3A\x65\xAC\x58\x16\xBA\xC9\xE3\x0A\xC0\x8B\xDD\xED\x30\x8C\x65\xCB\x87\xE2\x8E\x2E\x71\xB6\x77\xDC\x25\xC5\xA6\x49\x9C\x15\x53\x55\x5D\xAF\x1F\x55\x27\x0A\x56\x95\x9D\xFF\xA0\xC6\x6F\x24\xE0\xAF\x00\x95\x1E\xC4\xBB\x59\xCC\xC3\xA6\xC5\xF5\x2E\x09\x81\x64\x7E\x53\xE4\x39\x31\x3A\x52\xC4\x0F\xA7\x00\x4C\x85\x5B\x6E\x6E\xB2\x5B\x21\x2A\x13\x8E\x84\x3A\x9B\xA4\x6E\xDB\x2A\x03\x9E\xE8\x2A\x26\x3A\xBE"
+        )
+    ,
+        ( 20
+        , "\x27\xBA\x7E\x81\xE7\xED\xD4\xE7\x1B\xE5\x3C\x07\xCE\x8E\x63\x31\x38\xF2\x87\xE1\x55\xC7\xFA\x9E\x84\xC4\xAD\x80\x4B\x7F\xA1\xB9"
+        , "\xEA\x05\xF4\xEB\xCD\x2F\xB6\xB0\x00\xDA\x06\x12\x86\x1B\xA5\x4F\xF5\xC1\x76\xFB\x60\x13\x91\xAA"
+        , "\xE0\x9F\xF5\xD2\xCB\x05\x0D\x69\xB2\xD4\x24\x94\xBD\xE5\x82\x52\x38\xC7\x56\xD6\x99\x1D\x99\xD7\xA2\x0D\x1E\xF0\xB8\x3C\x37\x1C\x89\x87\x26\x90\xB2\xFC\x11\xD5\x36\x9F\x4F\xC4\x97\x1B\x6D\x3D\x6C\x07\x8A\xEF\x9B\x0F\x05\xC0\xE6\x1A\xB8\x9C\x02\x51\x68\x05\x4D\xEF\xEB\x03\xFE\xF6\x33\x85\x87\x00\xC5\x8B\x12\x62\xCE\x01\x13\x00\x01\x26\x73\xE8\x93\xE4\x49\x01\xDC\x18\xEE\xE3\x10\x56\x99\xC4\x4C\x80\x58\x97\xBD\xAF\x77\x6A\xF1\x83\x31\x62\xA2\x1A"
+        , "\xA2\x3E\x7E\xF9\x3C\x5D\x06\x67\xC9\x6D\x9E\x40\x4D\xCB\xE6\xBE\x62\x02\x6F\xA9\x8F\x7A\x3F\xF9\xBA\x5D\x45\x86\x43\xA1\x6A\x1C\xEF\x72\x72\xDC\x60\x97\xA9\xB5\x2F\x35\x98\x35\x57\xC7\x7A\x11\xB3\x14\xB4\xF7\xD5\xDC\x2C\xCA\x15\xEE\x47\x61\x6F\x86\x18\x73\xCB\xFE\xD1\xD3\x23\x72\x17\x1A\x61\xE3\x8E\x44\x7F\x3C\xF3\x62\xB3\xAB\xBB\x2E\xD4\x17\x0D\x89\xDC\xB2\x81\x87\xB7\xBF\xD2\x06\xA3\xE0\x26\xF0\x84\xA7\xE0\xED\x63\xD3\x19\xDE\x6B\xC9\xAF\xC0"
+        )
+    ,
+        ( 20
+        , "\x67\x99\xD7\x6E\x5F\xFB\x5B\x49\x20\xBC\x27\x68\xBA\xFD\x3F\x8C\x16\x55\x4E\x65\xEF\xCF\x9A\x16\xF4\x68\x3A\x7A\x06\x92\x7C\x11"
+        , "\x61\xAB\x95\x19\x21\xE5\x4F\xF0\x6D\x9B\x77\xF3\x13\xA4\xE4\x9D\xF7\xA0\x57\xD5\xFD\x62\x79\x89"
+        , "\x47\x27\x66"
+        , "\x8F\xD7\xDF"
+        )
+    ,
+        ( 20
         , "\xF6\x82\x38\xC0\x83\x65\xBB\x29\x3D\x26\x98\x0A\x60\x64\x88\xD0\x9C\x2F\x10\x9E\xDA\xFA\x0B\xBA\xE9\x93\x7B\x5C\xC2\x19\xA4\x9C"
         , "\x51\x90\xB5\x1E\x9B\x70\x86\x24\x82\x0B\x5A\xBD\xF4\xE4\x0F\xAD\x1F\xB9\x50\xAD\x1A\xDC\x2D\x26"
         , "\x47\xEC\x6B\x1F\x73\xC4\xB7\xFF\x52\x74\xA0\xBF\xD7\xF4\x5F\x86\x48\x12\xC8\x5A\x12\xFB\xCB\x3C\x2C\xF8\xA3\xE9\x0C\xF6\x6C\xCF\x2E\xAC\xB5\x21\xE7\x48\x36\x3C\x77\xF5\x2E\xB4\x26\xAE\x57\xA0\xC6\xC7\x8F\x75\xAF\x71\x28\x45\x69\xE7\x9D\x1A\x92\xF9\x49\xA9\xD6\x9C\x4E\xFC\x0B\x69\x90\x2F\x1E\x36\xD7\x56\x27\x65\x54\x3E\x2D\x39\x42\xD9\xF6\xFF\x59\x48\xD8\xA3\x12\xCF\xF7\x2C\x1A\xFD\x9E\xA3\x08\x8A\xFF\x76\x40\xBF\xD2\x65\xF7\xA9\x94\x6E\x60\x6A\xBC\x77\xBC\xED\xAE\x6B\xDD\xC7\x5A\x0D\xBA\x0B\xD9\x17\xD7\x3E\x3B\xD1\x26\x8F\x72\x7E\x00\x96\x34\x5D\xA1\xED\x25\xCF\x55\x3E\xA7\xA9\x8F\xEA\x6B\x6F\x28\x57\x32\xDE\x37\x43\x15\x61\xEE\x1B\x30\x64\x88\x7F\xBC\xBD\x71\x93\x5E\x02"
-        , "\x36\x16\x0E\x88\xD3\x50\x05\x29\xBA\x4E\xDB\xA1\x7B\xC2\x4D\x8C\xFA\xCA\x9A\x06\x80\xB3\xB1\xFC\x97\xCF\x03\xF3\x67\x5B\x7A\xC3\x01\xC8\x83\xA6\x8C\x07\x1B\xC5\x4A\xCD\xD3\xB6\x3A\xF4\xA2\xD7\x2F\x98\x5E\x51\xF9\xD6\x0A\x4C\x7F\xD4\x81\xAF\x10\xB2\xFC\x75\xE2\x52\xFD\xEE\x7E\xA6\xB6\x45\x31\x90\x61\x7D\xCC\x6E\x2F\xE1\xCD\x56\x58\x5F\xC2\xF0\xB0\xE9\x7C\x5C\x3F\x8A\xD7\xEB\x4F\x31\xBC\x48\x90\xC0\x38\x82\xAA\xC2\x4C\xC5\x3A\xCC\x19\x82\x29\x65\x26\x69\x0A\x22\x02\x71\xC2\xF6\xE3\x26\x75\x0D\x3F\xBD\xA5\xD5\xB6\x35\x12\xC8\x31\xF6\x78\x30\xF5\x9A\xC4\x9A\xAE\x33\x0B\x3E\x0E\x02\xC9\xEA\x00\x91\xD1\x98\x41\xF1\xB0\xE1\x3D\x69\xC9\xFB\xFE\x8A\x12\xD6\xF3\x0B\xB7\x34\xD9\xD2")
-    , ( 20
-       , "\x45\xB2\xBD\x0D\xE4\xED\x92\x93\xEC\x3E\x26\xC4\x84\x0F\xAA\xF6\x4B\x7D\x61\x9D\x51\xE9\xD7\xA2\xC7\xE3\x6C\x83\xD5\x84\xC3\xDF"
-       , "\x54\x6C\x8C\x5D\x6B\xE8\xF9\x09\x52\xCA\xB3\xF3\x6D\x7C\x19\x57\xBA\xAA\x7A\x59\xAB\xE3\xD7\xE5"
-       , "\x50\x07\xC8\xCD\x5B\x3C\x40\xE1\x7D\x7F\xE4\x23\xA8\x7A\xE0\xCE\xD8\x6B\xEC\x1C\x39\xDC\x07\xA2\x57\x72\xF3\xE9\x6D\xAB\xD5\x6C\xD3\xFD\x73\x19\xF6\xC9\x65\x49\x25\xF2\xD8\x70\x87\xA7\x00\xE1\xB1\x30\xDA\x79\x68\x95\xD1\xC9\xB9\xAC\xD6\x2B\x26\x61\x44\x06\x7D\x37\x3E\xD5\x1E\x78\x74\x98\xB0\x3C\x52\xFA\xAD\x16\xBB\x38\x26\xFA\x51\x1B\x0E\xD2\xA1\x9A\x86\x63\xF5\xBA\x2D\x6E\xA7\xC3\x8E\x72\x12\xE9\x69\x7D\x91\x48\x6C\x49\xD8\xA0\x00\xB9\xA1\x93\x5D\x6A\x7F\xF7\xEF\x23\xE7\x20\xA4\x58\x55\x48\x14\x40\x46\x3B\x4A\xC8\xC4\xF6\xE7\x06\x2A\xDC\x1F\x1E\x1E\x25\xD3\xD6\x5A\x31\x81\x2F\x58\xA7\x11\x60"
-       , "\x8E\xAC\xFB\xA5\x68\x89\x8B\x10\xC0\x95\x7A\x7D\x44\x10\x06\x85\xE8\x76\x3A\x71\xA6\x9A\x8D\x16\xBC\x7B\x3F\x88\x08\x5B\xB9\xA2\xF0\x96\x42\xE4\xD0\x9A\x9F\x0A\xD0\x9D\x0A\xAD\x66\xB2\x26\x10\xC8\xBD\x02\xFF\x66\x79\xBB\x92\xC2\xC0\x26\xA2\x16\xBF\x42\x5C\x6B\xE3\x5F\xB8\xDA\xE7\xFF\x0C\x72\xB0\xEF\xD6\xA1\x80\x37\xC7\x0E\xED\x0C\xA9\x00\x62\xA4\x9A\x3C\x97\xFD\xC9\x0A\x8F\x9C\x2E\xA5\x36\xBF\xDC\x41\x91\x8A\x75\x82\xC9\x92\x7F\xAE\x47\xEF\xAA\x3D\xC8\x79\x67\xB7\x88\x7D\xEE\x1B\xF0\x71\x73\x4C\x76\x65\x90\x1D\x91\x05\xDA\xE2\xFD\xF6\x6B\x49\x18\xE5\x1D\x8F\x4A\x48\xC6\x0D\x19\xFB\xFB\xBC\xBA")
-    , ( 20
-       , "\xFE\x55\x9C\x9A\x28\x2B\xEB\x40\x81\x4D\x01\x6D\x6B\xFC\xB2\xC0\xC0\xD8\xBF\x07\x7B\x11\x10\xB8\x70\x3A\x3C\xE3\x9D\x70\xE0\xE1"
-       , "\xB0\x76\x20\x0C\xC7\x01\x12\x59\x80\x5E\x18\xB3\x04\x09\x27\x54\x00\x27\x23\xEB\xEC\x5D\x62\x00"
-       , "\x6D\xB6\x5B\x9E\xC8\xB1\x14\xA9\x44\x13\x7C\x82\x1F\xD6\x06\xBE\x75\x47\x8D\x92\x83\x66\xD5\x28\x40\x96\xCD\xEF\x78\x2F\xCF\xF7\xE8\xF5\x9C\xB8\xFF\xCD\xA9\x79\x75\x79\x02\xC5\xFF\xA6\xBC\x47\x7C\xEA\xA4\xCB\x5D\x5E\xA7\x6F\x94\xD9\x1E\x83\x3F\x82\x3A\x6B\xC7\x8F\x10\x55\xDF\xA6\xA9\x7B\xEA\x89\x65\xC1\xCD\xE6\x7A\x66\x8E\x00\x12\x57\x33\x4A\x58\x57\x27\xD9\xE0\xF7\xC1\xA0\x6E\x88\xD3\xD2\x5A\x4E\x6D\x90\x96\xC9\x68\xBF\x13\x8E\x11\x6A\x3E\xBE\xFF\xD4\xBB\x48\x08\xAD\xB1\xFD\x69\x81\x64\xBA\x0A\x35\xC7\x09\xA4\x7F\x16\xF1\xF4\x43\x5A\x23\x45\xA9\x19\x4A\x00\xB9\x5A\xBD\x51\x85\x1D\x50\x58\x09\xA6\x07\x7D\xA9\xBA\xCA\x58\x31\xAF\xFF\x31\x57\x8C\x48\x7E\xE6\x8F\x27\x67\x97\x4A\x98\xA7\xE8\x03\xAA\xC7\x88\xDA\x98\x31\x9C\x4E\xA8\xEA\xA3\xD3\x94\x85\x56\x51\xF4\x84\xCE\xF5\x43\xF5\x37\xE3\x51\x58\xEE\x29"
-       , "\x4D\xCE\x9C\x8F\x97\xA0\x28\x05\x1B\x07\x27\xF3\x4E\x1B\x9E\xF2\x1F\x06\xF0\x76\x0F\x36\xE7\x17\x13\x20\x40\x27\x90\x20\x90\xBA\x2B\xB6\xB1\x34\x36\xEE\x77\x8D\x9F\x50\x53\x0E\xFB\xD7\xA3\x2B\x0D\x41\x44\x3F\x58\xCC\xAE\xE7\x81\xC7\xB7\x16\xD3\xA9\x6F\xDE\xC0\xE3\x76\x4E\xD7\x95\x9F\x34\xC3\x94\x12\x78\x59\x1E\xA0\x33\xB5\xCB\xAD\xC0\xF1\x91\x60\x32\xE9\xBE\xBB\xD1\xA8\x39\x5B\x83\xFB\x63\xB1\x45\x4B\xD7\x75\xBD\x20\xB3\xA2\xA9\x6F\x95\x12\x46\xAC\x14\xDA\xF6\x81\x66\xBA\x62\xF6\xCB\xFF\x8B\xD1\x21\xAC\x94\x98\xFF\x88\x52\xFD\x2B\xE9\x75\xDF\x52\xB5\xDA\xEF\x38\x29\xD1\x8E\xDA\x42\xE7\x15\x02\x2D\xCB\xF9\x30\xD0\xA7\x89\xEE\x6A\x14\x6C\x2C\x70\x88\xC3\x57\x73\xC6\x3C\x06\xB4\xAF\x45\x59\x85\x6A\xC1\x99\xCE\xD8\x68\x63\xE4\x29\x47\x07\x82\x53\x37\xC5\x85\x79\x70\xEB\x7F\xDD\xEB\x26\x37\x81\x30\x90\x11")
-    , ( 20
-       , "\x0A\xE1\x00\x12\xD7\xE5\x66\x14\xB0\x3D\xCC\x89\xB1\x4B\xAE\x92\x42\xFF\xE6\x30\xF3\xD7\xE3\x5C\xE8\xBB\xB9\x7B\xBC\x2C\x92\xC3"
-       , "\xF9\x6B\x02\x5D\x6C\xF4\x6A\x8A\x12\xAC\x2A\xF1\xE2\xAE\xF1\xFB\x83\x59\x0A\xDA\xDA\xA5\xC5\xEA"
-       , "\xEA\x0F\x35\x4E\x96\xF1\x2B\xC7\x2B\xBA\xA3\xD1\x2B\x4A\x8E\xD8\x79\xB0\x42\xF0\x68\x98\x78\xF4\x6B\x65\x1C\xC4\x11\x6D\x6F\x78\x40\x9B\x11\x43\x0B\x3A\xAA\x30\xB2\x07\x68\x91\xE8\xE1\xFA\x52\x8F\x2F\xD1\x69\xED\x93\xDC\x9F\x84\xE2\x44\x09\xEE\xC2\x10\x1D\xAF\x4D\x05\x7B\xE2\x49\x2D\x11\xDE\x64\x0C\xBD\x7B\x35\x5A\xD2\x9F\xB7\x04\x00\xFF\xFD\x7C\xD6\xD4\x25\xAB\xEE\xB7\x32\xA0\xEA\xA4\x33\x0A\xF4\xC6\x56\x25\x2C\x41\x73\xDE\xAB\x65\x3E\xB8\x5C\x58\x46\x2D\x7A\xB0\xF3\x5F\xD1\x2B\x61\x3D\x29\xD4\x73\xD3\x30\x31\x0D\xC3\x23\xD3\xC6\x63\x48\xBB\xDB\xB6\x8A\x32\x63\x24\x65\x7C\xAE\x7B\x77\xA9\xE3\x43\x58\xF2\xCE\xC5\x0C\x85\x60\x9E\x73\x05\x68\x56\x79\x6E\x3B\xE8\xD6\x2B\x6E\x2F\xE9\xF9\x53"
-       , "\xE8\xAB\xD4\x89\x24\xB5\x4E\x5B\x80\x86\x6B\xE7\xD4\xEB\xE5\xCF\x42\x74\xCA\xFF\xF0\x8B\x39\xCB\x2D\x40\xA8\xF0\xB4\x72\x39\x8A\xED\xC7\x76\xE0\x79\x38\x12\xFB\xF1\xF6\x00\x78\x63\x5D\x2E\xD8\x6B\x15\xEF\xCD\xBA\x60\x41\x1E\xE2\x3B\x07\x23\x35\x92\xA4\x4E\xC3\x1B\x10\x13\xCE\x89\x64\x23\x66\x75\xF8\xF1\x83\xAE\xF8\x85\xE8\x64\xF2\xA7\x2E\xDF\x42\x15\xB5\x33\x8F\xA2\xB5\x46\x53\xDF\xA1\xA8\xC5\x5C\xE5\xD9\x5C\xC6\x05\xB9\xB3\x11\x52\x7F\x2E\x34\x63\xFF\xBE\xC7\x8A\x9D\x1D\x65\xDA\xBA\xD2\xF3\x38\x76\x9C\x9F\x43\xF1\x33\xA7\x91\xA1\x1C\x7E\xCA\x9A\xF0\xB7\x71\xA4\xAC\x32\x96\x3D\xC8\xF6\x31\xA2\xC1\x12\x17\xAC\x6E\x1B\x94\x30\xC1\xAA\xE1\xCE\xEB\xE2\x27\x03\xF4\x29\x99\x8A\x8F\xB8\xC6\x41")
-    , ( 20
-       , "\x08\x2C\x53\x9B\xC5\xB2\x0F\x97\xD7\x67\xCD\x3F\x22\x9E\xDA\x80\xB2\xAD\xC4\xFE\x49\xC8\x63\x29\xB5\xCD\x62\x50\xA9\x87\x74\x50"
-       , "\x84\x55\x43\x50\x2E\x8B\x64\x91\x2D\x8F\x2C\x8D\x9F\xFF\xB3\xC6\x93\x65\x68\x65\x87\xC0\x8D\x0C"
-       , "\xA9\x6B\xB7\xE9\x10\x28\x1A\x6D\xFA\xD7\xC8\xA9\xC3\x70\x67\x4F\x0C\xEE\xC1\xAD\x8D\x4F\x0D\xE3\x2F\x9A\xE4\xA2\x3E\xD3\x29\xE3\xD6\xBC\x70\x8F\x87\x66\x40\xA2\x29\x15\x3A\xC0\xE7\x28\x1A\x81\x88\xDD\x77\x69\x51\x38\xF0\x1C\xDA\x5F\x41\xD5\x21\x5F\xD5\xC6\xBD\xD4\x6D\x98\x2C\xB7\x3B\x1E\xFE\x29\x97\x97\x0A\x9F\xDB\xDB\x1E\x76\x8D\x7E\x5D\xB7\x12\x06\x8D\x8B\xA1\xAF\x60\x67\xB5\x75\x34\x95\xE2\x3E\x6E\x19\x63\xAF\x01\x2F\x9C\x7C\xE4\x50\xBF\x2D\xE6\x19\xD3\xD5\x95\x42\xFB\x55\xF3"
-       , "\x83\x5D\xA7\x4F\xC6\xDE\x08\xCB\xDA\x27\x7A\x79\x66\xA0\x7C\x8D\xCD\x62\x7E\x7B\x17\xAD\xDE\x6D\x93\x0B\x65\x81\xE3\x12\x4B\x8B\xAA\xD0\x96\xF6\x93\x99\x1F\xED\xB1\x57\x29\x30\x60\x1F\xC7\x70\x95\x41\x83\x9B\x8E\x3F\xFD\x5F\x03\x3D\x20\x60\xD9\x99\xC6\xC6\xE3\x04\x82\x76\x61\x3E\x64\x80\x00\xAC\xB5\x21\x2C\xC6\x32\xA9\x16\xAF\xCE\x29\x0E\x20\xEB\xDF\x61\x2D\x08\xA6\xAA\x4C\x79\xA7\x4B\x07\x0D\x3F\x87\x2A\x86\x1F\x8D\xC6\xBB\x07\x61\x4D\xB5\x15\xD3\x63\x34\x9D\x3A\x8E\x33\x36\xA3")
-    , ( 20
-       , "\x3D\x02\xBF\xF3\x37\x5D\x40\x30\x27\x35\x6B\x94\xF5\x14\x20\x37\x37\xEE\x9A\x85\xD2\x05\x2D\xB3\xE4\xE5\xA2\x17\xC2\x59\xD1\x8A"
-       , "\x74\x21\x6C\x95\x03\x18\x95\xF4\x8C\x1D\xBA\x65\x15\x55\xEB\xFA\x3C\xA3\x26\xA7\x55\x23\x70\x25"
-       , "\x0D\x4B\x0F\x54\xFD\x09\xAE\x39\xBA\xA5\xFA\x4B\xAC\xCF\x2E\x66\x82\xE6\x1B\x25\x7E\x01\xF4\x2B\x8F"
-       , "\x16\xC4\x00\x6C\x28\x36\x51\x90\x41\x1E\xB1\x59\x38\x14\xCF\x15\xE7\x4C\x22\x23\x8F\x21\x0A\xFC\x3D")
-    , ( 20
-       , "\xAD\x1A\x5C\x47\x68\x88\x74\xE6\x66\x3A\x0F\x3F\xA1\x6F\xA7\xEF\xB7\xEC\xAD\xC1\x75\xC4\x68\xE5\x43\x29\x14\xBD\xB4\x80\xFF\xC6"
-       , "\xE4\x89\xEE\xD4\x40\xF1\xAA\xE1\xFA\xC8\xFB\x7A\x98\x25\x63\x54\x54\xF8\xF8\xF1\xF5\x2E\x2F\xCC"
-       , "\xAA\x6C\x1E\x53\x58\x0F\x03\xA9\xAB\xB7\x3B\xFD\xAD\xED\xFE\xCA\xDA\x4C\x6B\x0E\xBE\x02\x0E\xF1\x0D\xB7\x45\xE5\x4B\xA8\x61\xCA\xF6\x5F\x0E\x40\xDF\xC5\x20\x20\x3B\xB5\x4D\x29\xE0\xA8\xF7\x8F\x16\xB3\xF1\xAA\x52\x5D\x6B\xFA\x33\xC5\x47\x26\xE5\x99\x88\xCF\xBE\xC7\x80\x56"
-       , "\x02\xFE\x84\xCE\x81\xE1\x78\xE7\xAA\xBD\xD3\xBA\x92\x5A\x76\x6C\x3C\x24\x75\x6E\xEF\xAE\x33\x94\x2A\xF7\x5E\x8B\x46\x45\x56\xB5\x99\x7E\x61\x6F\x3F\x2D\xFC\x7F\xCE\x91\x84\x8A\xFD\x79\x91\x2D\x9F\xB5\x52\x01\xB5\x81\x3A\x5A\x07\x4D\x2C\x0D\x42\x92\xC1\xFD\x44\x18\x07\xC5")
-    , ( 20
-       , "\x05\x3A\x02\xBE\xDD\x63\x68\xC1\xFB\x8A\xFC\x7A\x1B\x19\x9F\x7F\x7E\xA2\x22\x0C\x9A\x4B\x64\x2A\x68\x50\x09\x1C\x9D\x20\xAB\x9C"
-       , "\xC7\x13\xEE\xA5\xC2\x6D\xAD\x75\xAD\x3F\x52\x45\x1E\x00\x3A\x9C\xB0\xD6\x49\xF9\x17\xC8\x9D\xDE"
-       , "\x8F\x0A\x8A\x16\x47\x60\x42\x65\x67\xE3\x88\x84\x02\x76\xDE\x3F\x95\xCB\x5E\x3F\xAD\xC6\xED\x3F\x3E\x4F\xE8\xBC\x16\x9D\x93\x88\x80\x4D\xCB\x94\xB6\x58\x7D\xBB\x66\xCB\x0B\xD5\xF8\x7B\x8E\x98\xB5\x2A\xF3\x7B\xA2\x90\x62\x9B\x85\x8E\x0E\x2A\xA7\x37\x80\x47\xA2\x66\x02"
-       , "\x51\x67\x10\xE5\x98\x43\xE6\xFB\xD4\xF2\x5D\x0D\x8C\xA0\xEC\x0D\x47\xD3\x9D\x12\x5E\x9D\xAD\x98\x7E\x05\x18\xD4\x91\x07\x01\x4C\xB0\xAE\x40\x5E\x30\xC2\xEB\x37\x94\x75\x0B\xCA\x14\x2C\xE9\x5E\x29\x0C\xF9\x5A\xBE\x15\xE8\x22\x82\x3E\x2E\x7D\x3A\xB2\x1B\xC8\xFB\xD4\x45")
-    , ( 20
-       ,"\x5B\x14\xAB\x0F\xBE\xD4\xC5\x89\x52\x54\x8A\x6C\xB1\xE0\x00\x0C\xF4\x48\x14\x21\xF4\x12\x88\xEA\x0A\xA8\x4A\xDD\x9F\x7D\xEB\x96"
-       , "\x54\xBF\x52\xB9\x11\x23\x1B\x95\x2B\xA1\xA6\xAF\x8E\x45\xB1\xC5\xA2\x9D\x97\xE2\xAB\xAD\x7C\x83"
-       , "\x37\xFB\x44\xA6\x75\x97\x8B\x56\x0F\xF9\xA4\xA8\x70\x11\xD6\xF3\xAD\x2D\x37\xA2\xC3\x81\x5B\x45\xA3\xC0\xE6\xD1\xB1\xD8\xB1\x78\x4C\xD4\x68\x92\x7C\x2E\xE3\x9E\x1D\xCC\xD4\x76\x5E\x1C\x3D\x67\x6A\x33\x5B\xE1\xCC\xD6\x90\x0A\x45\xF5\xD4\x1A\x31\x76\x48\x31\x5D\x8A\x8C\x24\xAD\xC6\x4E\xB2\x85\xF6\xAE\xBA\x05\xB9\x02\x95\x86\x35\x3D\x30\x3F\x17\xA8\x07\x65\x8B\x9F\xF7\x90\x47\x4E\x17\x37\xBD\x5F\xDC\x60\x4A\xEF\xF8\xDF\xCA\xF1\x42\x7D\xCC\x3A\xAC\xBB\x02\x56\xBA\xDC\xD1\x83\xED\x75\xA2\xDC\x52\x45\x2F\x87\xD3\xC1\xED\x2A\xA5\x83\x47\x2B\x0A\xB9\x1C\xDA\x20\x61\x4E\x9B\x6F\xDB\xDA\x3B\x49\xB0\x98\xC9\x58\x23\xCC\x72\xD8\xE5\xB7\x17\xF2\x31\x4B\x03\x24\xE9\xCE"
-       , "\xAE\x6D\xEB\x5D\x6C\xE4\x3D\x4B\x09\xD0\xE6\xB1\xC0\xE9\xF4\x61\x57\xBC\xD8\xAB\x50\xEA\xA3\x19\x7F\xF9\xFA\x2B\xF7\xAF\x64\x9E\xB5\x2C\x68\x54\x4F\xD3\xAD\xFE\x6B\x1E\xB3\x16\xF1\xF2\x35\x38\xD4\x70\xC3\x0D\xBF\xEC\x7E\x57\xB6\x0C\xBC\xD0\x96\xC7\x82\xE7\x73\x6B\x66\x91\x99\xC8\x25\x3E\x70\x21\x4C\xF2\xA0\x98\xFD\xA8\xEA\xC5\xDA\x79\xA9\x49\x6A\x3A\xAE\x75\x4D\x03\xB1\x7C\x6D\x70\xD1\x02\x7F\x42\xBF\x7F\x95\xCE\x3D\x1D\x9C\x33\x88\x54\xE1\x58\xFC\xC8\x03\xE4\xD6\x26\x2F\xB6\x39\x52\x1E\x47\x11\x6E\xF7\x8A\x7A\x43\x7C\xA9\x42\x7B\xA6\x45\xCD\x64\x68\x32\xFE\xAB\x82\x2A\x20\x82\x78\xE4\x5E\x93\xE1\x18\xD7\x80\xB9\x88\xD6\x53\x97\xED\xDF\xD7\xA8\x19\x52\x6E")
-    , ( 20
-       , "\xD7\x46\x36\xE3\x41\x3A\x88\xD8\x5F\x32\x2C\xA8\x0F\xB0\xBD\x65\x0B\xD0\xBF\x01\x34\xE2\x32\x91\x60\xB6\x96\x09\xCD\x58\xA4\xB0"
-       , "\xEF\xB6\x06\xAA\x1D\x9D\x9F\x0F\x46\x5E\xAA\x7F\x81\x65\xF1\xAC\x09\xF5\xCB\x46\xFE\xCF\x2A\x57"
-       , "\xF8\x54\x71\xB7\x5F\x6E\xC8\x1A\xBA\xC2\x79\x9E\xC0\x9E\x98\xE2\x80\xB2\xFF\xD6\x4C\xA2\x85\xE5\xA0\x10\x9C\xFB\x31\xFF\xAB\x2D\x61\x7B\x2C\x29\x52\xA2\xA8\xA7\x88\xFC\x0D\xA2\xAF\x7F\x53\x07\x58\xF7\x4F\x1A\xB5\x63\x91\xAB\x5F\xF2\xAD\xBC\xC5\xBE\x2D\x6C\x7F\x49\xFB\xE8\x11\x81\x04\xC6\xFF\x9A\x23\xC6\xDF\xE5\x2F\x57\x95\x4E\x6A\x69\xDC\xEE\x5D\xB0\x6F\x51\x4F\x4A\x0A\x57\x2A\x9A\x85\x25\xD9\x61\xDA\xE7\x22\x69\xB9\x87\x18\x9D\x46\x5D\xF6\x10\x71\x19\xC7\xFA\x79\x08\x53\xE0\x63\xCB\xA0\xFA\xB7\x80\x0C\xA9\x32\xE2\x58\x88\x0F\xD7\x4C\x33\xC7\x84\x67\x5B\xED\xAD\x0E\x7C\x09\xE9\xCC\x4D\x63\xDD\x5E\x97\x13\xD5\xD4\xA0\x19\x6E\x6B\x56\x22\x26\xAC\x31\xB4\xF5\x7C\x04\xF9\x0A\x18\x19\x73\x73\x7D\xDC\x7E\x80\xF3\x64\x11\x2A\x9F\xBB\x43\x5E\xBD\xBC\xAB\xF7\xD4\x90\xCE\x52"
-       , "\xB2\xB7\x95\xFE\x6C\x1D\x4C\x83\xC1\x32\x7E\x01\x5A\x67\xD4\x46\x5F\xD8\xE3\x28\x13\x57\x5C\xBA\xB2\x63\xE2\x0E\xF0\x58\x64\xD2\xDC\x17\xE0\xE4\xEB\x81\x43\x6A\xDF\xE9\xF6\x38\xDC\xC1\xC8\xD7\x8F\x6B\x03\x06\xBA\xF9\x38\xE5\xD2\xAB\x0B\x3E\x05\xE7\x35\xCC\x6F\xFF\x2D\x6E\x02\xE3\xD6\x04\x84\xBE\xA7\xC7\xA8\xE1\x3E\x23\x19\x7F\xEA\x7B\x04\xD4\x7D\x48\xF4\xA4\xE5\x94\x41\x74\x53\x94\x92\x80\x0D\x3E\xF5\x1E\x2E\xE5\xE4\xC8\xA0\xBD\xF0\x50\xC2\xDD\x3D\xD7\x4F\xCE\x5E\x7E\x5C\x37\x36\x4F\x75\x47\xA1\x14\x80\xA3\x06\x3B\x9A\x0A\x15\x7B\x15\xB1\x0A\x5A\x95\x4D\xE2\x73\x1C\xED\x05\x5A\xA2\xE2\x76\x7F\x08\x91\xD4\x32\x9C\x42\x6F\x38\x08\xEE\x86\x7B\xED\x0D\xC7\x5B\x59\x22\xB7\xCF\xB8\x95\x70\x0F\xDA\x01\x61\x05\xA4\xC7\xB7\xF0\xBB\x90\xF0\x29\xF6\xBB\xCB\x04\xAC\x36\xAC\x16") 
+        , "\x36\x16\x0E\x88\xD3\x50\x05\x29\xBA\x4E\xDB\xA1\x7B\xC2\x4D\x8C\xFA\xCA\x9A\x06\x80\xB3\xB1\xFC\x97\xCF\x03\xF3\x67\x5B\x7A\xC3\x01\xC8\x83\xA6\x8C\x07\x1B\xC5\x4A\xCD\xD3\xB6\x3A\xF4\xA2\xD7\x2F\x98\x5E\x51\xF9\xD6\x0A\x4C\x7F\xD4\x81\xAF\x10\xB2\xFC\x75\xE2\x52\xFD\xEE\x7E\xA6\xB6\x45\x31\x90\x61\x7D\xCC\x6E\x2F\xE1\xCD\x56\x58\x5F\xC2\xF0\xB0\xE9\x7C\x5C\x3F\x8A\xD7\xEB\x4F\x31\xBC\x48\x90\xC0\x38\x82\xAA\xC2\x4C\xC5\x3A\xCC\x19\x82\x29\x65\x26\x69\x0A\x22\x02\x71\xC2\xF6\xE3\x26\x75\x0D\x3F\xBD\xA5\xD5\xB6\x35\x12\xC8\x31\xF6\x78\x30\xF5\x9A\xC4\x9A\xAE\x33\x0B\x3E\x0E\x02\xC9\xEA\x00\x91\xD1\x98\x41\xF1\xB0\xE1\x3D\x69\xC9\xFB\xFE\x8A\x12\xD6\xF3\x0B\xB7\x34\xD9\xD2"
+        )
+    ,
+        ( 20
+        , "\x45\xB2\xBD\x0D\xE4\xED\x92\x93\xEC\x3E\x26\xC4\x84\x0F\xAA\xF6\x4B\x7D\x61\x9D\x51\xE9\xD7\xA2\xC7\xE3\x6C\x83\xD5\x84\xC3\xDF"
+        , "\x54\x6C\x8C\x5D\x6B\xE8\xF9\x09\x52\xCA\xB3\xF3\x6D\x7C\x19\x57\xBA\xAA\x7A\x59\xAB\xE3\xD7\xE5"
+        , "\x50\x07\xC8\xCD\x5B\x3C\x40\xE1\x7D\x7F\xE4\x23\xA8\x7A\xE0\xCE\xD8\x6B\xEC\x1C\x39\xDC\x07\xA2\x57\x72\xF3\xE9\x6D\xAB\xD5\x6C\xD3\xFD\x73\x19\xF6\xC9\x65\x49\x25\xF2\xD8\x70\x87\xA7\x00\xE1\xB1\x30\xDA\x79\x68\x95\xD1\xC9\xB9\xAC\xD6\x2B\x26\x61\x44\x06\x7D\x37\x3E\xD5\x1E\x78\x74\x98\xB0\x3C\x52\xFA\xAD\x16\xBB\x38\x26\xFA\x51\x1B\x0E\xD2\xA1\x9A\x86\x63\xF5\xBA\x2D\x6E\xA7\xC3\x8E\x72\x12\xE9\x69\x7D\x91\x48\x6C\x49\xD8\xA0\x00\xB9\xA1\x93\x5D\x6A\x7F\xF7\xEF\x23\xE7\x20\xA4\x58\x55\x48\x14\x40\x46\x3B\x4A\xC8\xC4\xF6\xE7\x06\x2A\xDC\x1F\x1E\x1E\x25\xD3\xD6\x5A\x31\x81\x2F\x58\xA7\x11\x60"
+        , "\x8E\xAC\xFB\xA5\x68\x89\x8B\x10\xC0\x95\x7A\x7D\x44\x10\x06\x85\xE8\x76\x3A\x71\xA6\x9A\x8D\x16\xBC\x7B\x3F\x88\x08\x5B\xB9\xA2\xF0\x96\x42\xE4\xD0\x9A\x9F\x0A\xD0\x9D\x0A\xAD\x66\xB2\x26\x10\xC8\xBD\x02\xFF\x66\x79\xBB\x92\xC2\xC0\x26\xA2\x16\xBF\x42\x5C\x6B\xE3\x5F\xB8\xDA\xE7\xFF\x0C\x72\xB0\xEF\xD6\xA1\x80\x37\xC7\x0E\xED\x0C\xA9\x00\x62\xA4\x9A\x3C\x97\xFD\xC9\x0A\x8F\x9C\x2E\xA5\x36\xBF\xDC\x41\x91\x8A\x75\x82\xC9\x92\x7F\xAE\x47\xEF\xAA\x3D\xC8\x79\x67\xB7\x88\x7D\xEE\x1B\xF0\x71\x73\x4C\x76\x65\x90\x1D\x91\x05\xDA\xE2\xFD\xF6\x6B\x49\x18\xE5\x1D\x8F\x4A\x48\xC6\x0D\x19\xFB\xFB\xBC\xBA"
+        )
+    ,
+        ( 20
+        , "\xFE\x55\x9C\x9A\x28\x2B\xEB\x40\x81\x4D\x01\x6D\x6B\xFC\xB2\xC0\xC0\xD8\xBF\x07\x7B\x11\x10\xB8\x70\x3A\x3C\xE3\x9D\x70\xE0\xE1"
+        , "\xB0\x76\x20\x0C\xC7\x01\x12\x59\x80\x5E\x18\xB3\x04\x09\x27\x54\x00\x27\x23\xEB\xEC\x5D\x62\x00"
+        , "\x6D\xB6\x5B\x9E\xC8\xB1\x14\xA9\x44\x13\x7C\x82\x1F\xD6\x06\xBE\x75\x47\x8D\x92\x83\x66\xD5\x28\x40\x96\xCD\xEF\x78\x2F\xCF\xF7\xE8\xF5\x9C\xB8\xFF\xCD\xA9\x79\x75\x79\x02\xC5\xFF\xA6\xBC\x47\x7C\xEA\xA4\xCB\x5D\x5E\xA7\x6F\x94\xD9\x1E\x83\x3F\x82\x3A\x6B\xC7\x8F\x10\x55\xDF\xA6\xA9\x7B\xEA\x89\x65\xC1\xCD\xE6\x7A\x66\x8E\x00\x12\x57\x33\x4A\x58\x57\x27\xD9\xE0\xF7\xC1\xA0\x6E\x88\xD3\xD2\x5A\x4E\x6D\x90\x96\xC9\x68\xBF\x13\x8E\x11\x6A\x3E\xBE\xFF\xD4\xBB\x48\x08\xAD\xB1\xFD\x69\x81\x64\xBA\x0A\x35\xC7\x09\xA4\x7F\x16\xF1\xF4\x43\x5A\x23\x45\xA9\x19\x4A\x00\xB9\x5A\xBD\x51\x85\x1D\x50\x58\x09\xA6\x07\x7D\xA9\xBA\xCA\x58\x31\xAF\xFF\x31\x57\x8C\x48\x7E\xE6\x8F\x27\x67\x97\x4A\x98\xA7\xE8\x03\xAA\xC7\x88\xDA\x98\x31\x9C\x4E\xA8\xEA\xA3\xD3\x94\x85\x56\x51\xF4\x84\xCE\xF5\x43\xF5\x37\xE3\x51\x58\xEE\x29"
+        , "\x4D\xCE\x9C\x8F\x97\xA0\x28\x05\x1B\x07\x27\xF3\x4E\x1B\x9E\xF2\x1F\x06\xF0\x76\x0F\x36\xE7\x17\x13\x20\x40\x27\x90\x20\x90\xBA\x2B\xB6\xB1\x34\x36\xEE\x77\x8D\x9F\x50\x53\x0E\xFB\xD7\xA3\x2B\x0D\x41\x44\x3F\x58\xCC\xAE\xE7\x81\xC7\xB7\x16\xD3\xA9\x6F\xDE\xC0\xE3\x76\x4E\xD7\x95\x9F\x34\xC3\x94\x12\x78\x59\x1E\xA0\x33\xB5\xCB\xAD\xC0\xF1\x91\x60\x32\xE9\xBE\xBB\xD1\xA8\x39\x5B\x83\xFB\x63\xB1\x45\x4B\xD7\x75\xBD\x20\xB3\xA2\xA9\x6F\x95\x12\x46\xAC\x14\xDA\xF6\x81\x66\xBA\x62\xF6\xCB\xFF\x8B\xD1\x21\xAC\x94\x98\xFF\x88\x52\xFD\x2B\xE9\x75\xDF\x52\xB5\xDA\xEF\x38\x29\xD1\x8E\xDA\x42\xE7\x15\x02\x2D\xCB\xF9\x30\xD0\xA7\x89\xEE\x6A\x14\x6C\x2C\x70\x88\xC3\x57\x73\xC6\x3C\x06\xB4\xAF\x45\x59\x85\x6A\xC1\x99\xCE\xD8\x68\x63\xE4\x29\x47\x07\x82\x53\x37\xC5\x85\x79\x70\xEB\x7F\xDD\xEB\x26\x37\x81\x30\x90\x11"
+        )
+    ,
+        ( 20
+        , "\x0A\xE1\x00\x12\xD7\xE5\x66\x14\xB0\x3D\xCC\x89\xB1\x4B\xAE\x92\x42\xFF\xE6\x30\xF3\xD7\xE3\x5C\xE8\xBB\xB9\x7B\xBC\x2C\x92\xC3"
+        , "\xF9\x6B\x02\x5D\x6C\xF4\x6A\x8A\x12\xAC\x2A\xF1\xE2\xAE\xF1\xFB\x83\x59\x0A\xDA\xDA\xA5\xC5\xEA"
+        , "\xEA\x0F\x35\x4E\x96\xF1\x2B\xC7\x2B\xBA\xA3\xD1\x2B\x4A\x8E\xD8\x79\xB0\x42\xF0\x68\x98\x78\xF4\x6B\x65\x1C\xC4\x11\x6D\x6F\x78\x40\x9B\x11\x43\x0B\x3A\xAA\x30\xB2\x07\x68\x91\xE8\xE1\xFA\x52\x8F\x2F\xD1\x69\xED\x93\xDC\x9F\x84\xE2\x44\x09\xEE\xC2\x10\x1D\xAF\x4D\x05\x7B\xE2\x49\x2D\x11\xDE\x64\x0C\xBD\x7B\x35\x5A\xD2\x9F\xB7\x04\x00\xFF\xFD\x7C\xD6\xD4\x25\xAB\xEE\xB7\x32\xA0\xEA\xA4\x33\x0A\xF4\xC6\x56\x25\x2C\x41\x73\xDE\xAB\x65\x3E\xB8\x5C\x58\x46\x2D\x7A\xB0\xF3\x5F\xD1\x2B\x61\x3D\x29\xD4\x73\xD3\x30\x31\x0D\xC3\x23\xD3\xC6\x63\x48\xBB\xDB\xB6\x8A\x32\x63\x24\x65\x7C\xAE\x7B\x77\xA9\xE3\x43\x58\xF2\xCE\xC5\x0C\x85\x60\x9E\x73\x05\x68\x56\x79\x6E\x3B\xE8\xD6\x2B\x6E\x2F\xE9\xF9\x53"
+        , "\xE8\xAB\xD4\x89\x24\xB5\x4E\x5B\x80\x86\x6B\xE7\xD4\xEB\xE5\xCF\x42\x74\xCA\xFF\xF0\x8B\x39\xCB\x2D\x40\xA8\xF0\xB4\x72\x39\x8A\xED\xC7\x76\xE0\x79\x38\x12\xFB\xF1\xF6\x00\x78\x63\x5D\x2E\xD8\x6B\x15\xEF\xCD\xBA\x60\x41\x1E\xE2\x3B\x07\x23\x35\x92\xA4\x4E\xC3\x1B\x10\x13\xCE\x89\x64\x23\x66\x75\xF8\xF1\x83\xAE\xF8\x85\xE8\x64\xF2\xA7\x2E\xDF\x42\x15\xB5\x33\x8F\xA2\xB5\x46\x53\xDF\xA1\xA8\xC5\x5C\xE5\xD9\x5C\xC6\x05\xB9\xB3\x11\x52\x7F\x2E\x34\x63\xFF\xBE\xC7\x8A\x9D\x1D\x65\xDA\xBA\xD2\xF3\x38\x76\x9C\x9F\x43\xF1\x33\xA7\x91\xA1\x1C\x7E\xCA\x9A\xF0\xB7\x71\xA4\xAC\x32\x96\x3D\xC8\xF6\x31\xA2\xC1\x12\x17\xAC\x6E\x1B\x94\x30\xC1\xAA\xE1\xCE\xEB\xE2\x27\x03\xF4\x29\x99\x8A\x8F\xB8\xC6\x41"
+        )
+    ,
+        ( 20
+        , "\x08\x2C\x53\x9B\xC5\xB2\x0F\x97\xD7\x67\xCD\x3F\x22\x9E\xDA\x80\xB2\xAD\xC4\xFE\x49\xC8\x63\x29\xB5\xCD\x62\x50\xA9\x87\x74\x50"
+        , "\x84\x55\x43\x50\x2E\x8B\x64\x91\x2D\x8F\x2C\x8D\x9F\xFF\xB3\xC6\x93\x65\x68\x65\x87\xC0\x8D\x0C"
+        , "\xA9\x6B\xB7\xE9\x10\x28\x1A\x6D\xFA\xD7\xC8\xA9\xC3\x70\x67\x4F\x0C\xEE\xC1\xAD\x8D\x4F\x0D\xE3\x2F\x9A\xE4\xA2\x3E\xD3\x29\xE3\xD6\xBC\x70\x8F\x87\x66\x40\xA2\x29\x15\x3A\xC0\xE7\x28\x1A\x81\x88\xDD\x77\x69\x51\x38\xF0\x1C\xDA\x5F\x41\xD5\x21\x5F\xD5\xC6\xBD\xD4\x6D\x98\x2C\xB7\x3B\x1E\xFE\x29\x97\x97\x0A\x9F\xDB\xDB\x1E\x76\x8D\x7E\x5D\xB7\x12\x06\x8D\x8B\xA1\xAF\x60\x67\xB5\x75\x34\x95\xE2\x3E\x6E\x19\x63\xAF\x01\x2F\x9C\x7C\xE4\x50\xBF\x2D\xE6\x19\xD3\xD5\x95\x42\xFB\x55\xF3"
+        , "\x83\x5D\xA7\x4F\xC6\xDE\x08\xCB\xDA\x27\x7A\x79\x66\xA0\x7C\x8D\xCD\x62\x7E\x7B\x17\xAD\xDE\x6D\x93\x0B\x65\x81\xE3\x12\x4B\x8B\xAA\xD0\x96\xF6\x93\x99\x1F\xED\xB1\x57\x29\x30\x60\x1F\xC7\x70\x95\x41\x83\x9B\x8E\x3F\xFD\x5F\x03\x3D\x20\x60\xD9\x99\xC6\xC6\xE3\x04\x82\x76\x61\x3E\x64\x80\x00\xAC\xB5\x21\x2C\xC6\x32\xA9\x16\xAF\xCE\x29\x0E\x20\xEB\xDF\x61\x2D\x08\xA6\xAA\x4C\x79\xA7\x4B\x07\x0D\x3F\x87\x2A\x86\x1F\x8D\xC6\xBB\x07\x61\x4D\xB5\x15\xD3\x63\x34\x9D\x3A\x8E\x33\x36\xA3"
+        )
+    ,
+        ( 20
+        , "\x3D\x02\xBF\xF3\x37\x5D\x40\x30\x27\x35\x6B\x94\xF5\x14\x20\x37\x37\xEE\x9A\x85\xD2\x05\x2D\xB3\xE4\xE5\xA2\x17\xC2\x59\xD1\x8A"
+        , "\x74\x21\x6C\x95\x03\x18\x95\xF4\x8C\x1D\xBA\x65\x15\x55\xEB\xFA\x3C\xA3\x26\xA7\x55\x23\x70\x25"
+        , "\x0D\x4B\x0F\x54\xFD\x09\xAE\x39\xBA\xA5\xFA\x4B\xAC\xCF\x2E\x66\x82\xE6\x1B\x25\x7E\x01\xF4\x2B\x8F"
+        , "\x16\xC4\x00\x6C\x28\x36\x51\x90\x41\x1E\xB1\x59\x38\x14\xCF\x15\xE7\x4C\x22\x23\x8F\x21\x0A\xFC\x3D"
+        )
+    ,
+        ( 20
+        , "\xAD\x1A\x5C\x47\x68\x88\x74\xE6\x66\x3A\x0F\x3F\xA1\x6F\xA7\xEF\xB7\xEC\xAD\xC1\x75\xC4\x68\xE5\x43\x29\x14\xBD\xB4\x80\xFF\xC6"
+        , "\xE4\x89\xEE\xD4\x40\xF1\xAA\xE1\xFA\xC8\xFB\x7A\x98\x25\x63\x54\x54\xF8\xF8\xF1\xF5\x2E\x2F\xCC"
+        , "\xAA\x6C\x1E\x53\x58\x0F\x03\xA9\xAB\xB7\x3B\xFD\xAD\xED\xFE\xCA\xDA\x4C\x6B\x0E\xBE\x02\x0E\xF1\x0D\xB7\x45\xE5\x4B\xA8\x61\xCA\xF6\x5F\x0E\x40\xDF\xC5\x20\x20\x3B\xB5\x4D\x29\xE0\xA8\xF7\x8F\x16\xB3\xF1\xAA\x52\x5D\x6B\xFA\x33\xC5\x47\x26\xE5\x99\x88\xCF\xBE\xC7\x80\x56"
+        , "\x02\xFE\x84\xCE\x81\xE1\x78\xE7\xAA\xBD\xD3\xBA\x92\x5A\x76\x6C\x3C\x24\x75\x6E\xEF\xAE\x33\x94\x2A\xF7\x5E\x8B\x46\x45\x56\xB5\x99\x7E\x61\x6F\x3F\x2D\xFC\x7F\xCE\x91\x84\x8A\xFD\x79\x91\x2D\x9F\xB5\x52\x01\xB5\x81\x3A\x5A\x07\x4D\x2C\x0D\x42\x92\xC1\xFD\x44\x18\x07\xC5"
+        )
+    ,
+        ( 20
+        , "\x05\x3A\x02\xBE\xDD\x63\x68\xC1\xFB\x8A\xFC\x7A\x1B\x19\x9F\x7F\x7E\xA2\x22\x0C\x9A\x4B\x64\x2A\x68\x50\x09\x1C\x9D\x20\xAB\x9C"
+        , "\xC7\x13\xEE\xA5\xC2\x6D\xAD\x75\xAD\x3F\x52\x45\x1E\x00\x3A\x9C\xB0\xD6\x49\xF9\x17\xC8\x9D\xDE"
+        , "\x8F\x0A\x8A\x16\x47\x60\x42\x65\x67\xE3\x88\x84\x02\x76\xDE\x3F\x95\xCB\x5E\x3F\xAD\xC6\xED\x3F\x3E\x4F\xE8\xBC\x16\x9D\x93\x88\x80\x4D\xCB\x94\xB6\x58\x7D\xBB\x66\xCB\x0B\xD5\xF8\x7B\x8E\x98\xB5\x2A\xF3\x7B\xA2\x90\x62\x9B\x85\x8E\x0E\x2A\xA7\x37\x80\x47\xA2\x66\x02"
+        , "\x51\x67\x10\xE5\x98\x43\xE6\xFB\xD4\xF2\x5D\x0D\x8C\xA0\xEC\x0D\x47\xD3\x9D\x12\x5E\x9D\xAD\x98\x7E\x05\x18\xD4\x91\x07\x01\x4C\xB0\xAE\x40\x5E\x30\xC2\xEB\x37\x94\x75\x0B\xCA\x14\x2C\xE9\x5E\x29\x0C\xF9\x5A\xBE\x15\xE8\x22\x82\x3E\x2E\x7D\x3A\xB2\x1B\xC8\xFB\xD4\x45"
+        )
+    ,
+        ( 20
+        , "\x5B\x14\xAB\x0F\xBE\xD4\xC5\x89\x52\x54\x8A\x6C\xB1\xE0\x00\x0C\xF4\x48\x14\x21\xF4\x12\x88\xEA\x0A\xA8\x4A\xDD\x9F\x7D\xEB\x96"
+        , "\x54\xBF\x52\xB9\x11\x23\x1B\x95\x2B\xA1\xA6\xAF\x8E\x45\xB1\xC5\xA2\x9D\x97\xE2\xAB\xAD\x7C\x83"
+        , "\x37\xFB\x44\xA6\x75\x97\x8B\x56\x0F\xF9\xA4\xA8\x70\x11\xD6\xF3\xAD\x2D\x37\xA2\xC3\x81\x5B\x45\xA3\xC0\xE6\xD1\xB1\xD8\xB1\x78\x4C\xD4\x68\x92\x7C\x2E\xE3\x9E\x1D\xCC\xD4\x76\x5E\x1C\x3D\x67\x6A\x33\x5B\xE1\xCC\xD6\x90\x0A\x45\xF5\xD4\x1A\x31\x76\x48\x31\x5D\x8A\x8C\x24\xAD\xC6\x4E\xB2\x85\xF6\xAE\xBA\x05\xB9\x02\x95\x86\x35\x3D\x30\x3F\x17\xA8\x07\x65\x8B\x9F\xF7\x90\x47\x4E\x17\x37\xBD\x5F\xDC\x60\x4A\xEF\xF8\xDF\xCA\xF1\x42\x7D\xCC\x3A\xAC\xBB\x02\x56\xBA\xDC\xD1\x83\xED\x75\xA2\xDC\x52\x45\x2F\x87\xD3\xC1\xED\x2A\xA5\x83\x47\x2B\x0A\xB9\x1C\xDA\x20\x61\x4E\x9B\x6F\xDB\xDA\x3B\x49\xB0\x98\xC9\x58\x23\xCC\x72\xD8\xE5\xB7\x17\xF2\x31\x4B\x03\x24\xE9\xCE"
+        , "\xAE\x6D\xEB\x5D\x6C\xE4\x3D\x4B\x09\xD0\xE6\xB1\xC0\xE9\xF4\x61\x57\xBC\xD8\xAB\x50\xEA\xA3\x19\x7F\xF9\xFA\x2B\xF7\xAF\x64\x9E\xB5\x2C\x68\x54\x4F\xD3\xAD\xFE\x6B\x1E\xB3\x16\xF1\xF2\x35\x38\xD4\x70\xC3\x0D\xBF\xEC\x7E\x57\xB6\x0C\xBC\xD0\x96\xC7\x82\xE7\x73\x6B\x66\x91\x99\xC8\x25\x3E\x70\x21\x4C\xF2\xA0\x98\xFD\xA8\xEA\xC5\xDA\x79\xA9\x49\x6A\x3A\xAE\x75\x4D\x03\xB1\x7C\x6D\x70\xD1\x02\x7F\x42\xBF\x7F\x95\xCE\x3D\x1D\x9C\x33\x88\x54\xE1\x58\xFC\xC8\x03\xE4\xD6\x26\x2F\xB6\x39\x52\x1E\x47\x11\x6E\xF7\x8A\x7A\x43\x7C\xA9\x42\x7B\xA6\x45\xCD\x64\x68\x32\xFE\xAB\x82\x2A\x20\x82\x78\xE4\x5E\x93\xE1\x18\xD7\x80\xB9\x88\xD6\x53\x97\xED\xDF\xD7\xA8\x19\x52\x6E"
+        )
+    ,
+        ( 20
+        , "\xD7\x46\x36\xE3\x41\x3A\x88\xD8\x5F\x32\x2C\xA8\x0F\xB0\xBD\x65\x0B\xD0\xBF\x01\x34\xE2\x32\x91\x60\xB6\x96\x09\xCD\x58\xA4\xB0"
+        , "\xEF\xB6\x06\xAA\x1D\x9D\x9F\x0F\x46\x5E\xAA\x7F\x81\x65\xF1\xAC\x09\xF5\xCB\x46\xFE\xCF\x2A\x57"
+        , "\xF8\x54\x71\xB7\x5F\x6E\xC8\x1A\xBA\xC2\x79\x9E\xC0\x9E\x98\xE2\x80\xB2\xFF\xD6\x4C\xA2\x85\xE5\xA0\x10\x9C\xFB\x31\xFF\xAB\x2D\x61\x7B\x2C\x29\x52\xA2\xA8\xA7\x88\xFC\x0D\xA2\xAF\x7F\x53\x07\x58\xF7\x4F\x1A\xB5\x63\x91\xAB\x5F\xF2\xAD\xBC\xC5\xBE\x2D\x6C\x7F\x49\xFB\xE8\x11\x81\x04\xC6\xFF\x9A\x23\xC6\xDF\xE5\x2F\x57\x95\x4E\x6A\x69\xDC\xEE\x5D\xB0\x6F\x51\x4F\x4A\x0A\x57\x2A\x9A\x85\x25\xD9\x61\xDA\xE7\x22\x69\xB9\x87\x18\x9D\x46\x5D\xF6\x10\x71\x19\xC7\xFA\x79\x08\x53\xE0\x63\xCB\xA0\xFA\xB7\x80\x0C\xA9\x32\xE2\x58\x88\x0F\xD7\x4C\x33\xC7\x84\x67\x5B\xED\xAD\x0E\x7C\x09\xE9\xCC\x4D\x63\xDD\x5E\x97\x13\xD5\xD4\xA0\x19\x6E\x6B\x56\x22\x26\xAC\x31\xB4\xF5\x7C\x04\xF9\x0A\x18\x19\x73\x73\x7D\xDC\x7E\x80\xF3\x64\x11\x2A\x9F\xBB\x43\x5E\xBD\xBC\xAB\xF7\xD4\x90\xCE\x52"
+        , "\xB2\xB7\x95\xFE\x6C\x1D\x4C\x83\xC1\x32\x7E\x01\x5A\x67\xD4\x46\x5F\xD8\xE3\x28\x13\x57\x5C\xBA\xB2\x63\xE2\x0E\xF0\x58\x64\xD2\xDC\x17\xE0\xE4\xEB\x81\x43\x6A\xDF\xE9\xF6\x38\xDC\xC1\xC8\xD7\x8F\x6B\x03\x06\xBA\xF9\x38\xE5\xD2\xAB\x0B\x3E\x05\xE7\x35\xCC\x6F\xFF\x2D\x6E\x02\xE3\xD6\x04\x84\xBE\xA7\xC7\xA8\xE1\x3E\x23\x19\x7F\xEA\x7B\x04\xD4\x7D\x48\xF4\xA4\xE5\x94\x41\x74\x53\x94\x92\x80\x0D\x3E\xF5\x1E\x2E\xE5\xE4\xC8\xA0\xBD\xF0\x50\xC2\xDD\x3D\xD7\x4F\xCE\x5E\x7E\x5C\x37\x36\x4F\x75\x47\xA1\x14\x80\xA3\x06\x3B\x9A\x0A\x15\x7B\x15\xB1\x0A\x5A\x95\x4D\xE2\x73\x1C\xED\x05\x5A\xA2\xE2\x76\x7F\x08\x91\xD4\x32\x9C\x42\x6F\x38\x08\xEE\x86\x7B\xED\x0D\xC7\x5B\x59\x22\xB7\xCF\xB8\x95\x70\x0F\xDA\x01\x61\x05\xA4\xC7\xB7\xF0\xBB\x90\xF0\x29\xF6\xBB\xCB\x04\xAC\x36\xAC\x16"
+        )
     ]
 
 -- Test vector from paper "Cryptography in NaCl"
 vectorsCB :: [Vector]
 vectorsCB =
-    [ ( 20
-       , "\x4A\x5D\x9D\x5B\xA4\xCE\x2D\xE1\x72\x8E\x3B\xF4\x80\x35\x0F\x25\xE0\x7E\x21\xC9\x47\xD1\x9E\x33\x76\xF0\x9B\x3C\x1E\x16\x17\x42"
-       , "\x69\x69\x6E\xE9\x55\xB6\x2B\x73\xCD\x62\xBD\xA8\x75\xFC\x73\xD6\x82\x19\xE0\x03\x6B\x7A\x0B\x37"
-       , "\xBE\x07\x5F\xC5\x3C\x81\xF2\xD5\xCF\x14\x13\x16\xEB\xEB\x0C\x7B\x52\x28\xC5\x2A\x4C\x62\xCB\xD4\x4B\x66\x84\x9B\x64\x24\x4F\xFC\xE5\xEC\xBA\xAF\x33\xBD\x75\x1A\x1A\xC7\x28\xD4\x5E\x6C\x61\x29\x6C\xDC\x3C\x01\x23\x35\x61\xF4\x1D\xB6\x6C\xCE\x31\x4A\xDB\x31\x0E\x3B\xE8\x25\x0C\x46\xF0\x6D\xCE\xEA\x3A\x7F\xA1\x34\x80\x57\xE2\xF6\x55\x6A\xD6\xB1\x31\x8A\x02\x4A\x83\x8F\x21\xAF\x1F\xDE\x04\x89\x77\xEB\x48\xF5\x9F\xFD\x49\x24\xCA\x1C\x60\x90\x2E\x52\xF0\xA0\x89\xBC\x76\x89\x70\x40\xE0\x82\xF9\x37\x76\x38\x48\x64\x5E\x07\x05"
-       , "\x8E\x99\x3B\x9F\x48\x68\x12\x73\xC2\x96\x50\xBA\x32\xFC\x76\xCE\x48\x33\x2E\xA7\x16\x4D\x96\xA4\x47\x6F\xB8\xC5\x31\xA1\x18\x6A\xC0\xDF\xC1\x7C\x98\xDC\xE8\x7B\x4D\xA7\xF0\x11\xEC\x48\xC9\x72\x71\xD2\xC2\x0F\x9B\x92\x8F\xE2\x27\x0D\x6F\xB8\x63\xD5\x17\x38\xB4\x8E\xEE\xE3\x14\xA7\xCC\x8A\xB9\x32\x16\x45\x48\xE5\x26\xAE\x90\x22\x43\x68\x51\x7A\xCF\xEA\xBD\x6B\xB3\x73\x2B\xC0\xE9\xDA\x99\x83\x2B\x61\xCA\x01\xB6\xDE\x56\x24\x4A\x9E\x88\xD5\xF9\xB3\x79\x73\xF6\x22\xA4\x3D\x14\xA6\x59\x9B\x1F\x65\x4C\xB4\x5A\x74\xE3\x55\xA5")
+    [
+        ( 20
+        , "\x4A\x5D\x9D\x5B\xA4\xCE\x2D\xE1\x72\x8E\x3B\xF4\x80\x35\x0F\x25\xE0\x7E\x21\xC9\x47\xD1\x9E\x33\x76\xF0\x9B\x3C\x1E\x16\x17\x42"
+        , "\x69\x69\x6E\xE9\x55\xB6\x2B\x73\xCD\x62\xBD\xA8\x75\xFC\x73\xD6\x82\x19\xE0\x03\x6B\x7A\x0B\x37"
+        , "\xBE\x07\x5F\xC5\x3C\x81\xF2\xD5\xCF\x14\x13\x16\xEB\xEB\x0C\x7B\x52\x28\xC5\x2A\x4C\x62\xCB\xD4\x4B\x66\x84\x9B\x64\x24\x4F\xFC\xE5\xEC\xBA\xAF\x33\xBD\x75\x1A\x1A\xC7\x28\xD4\x5E\x6C\x61\x29\x6C\xDC\x3C\x01\x23\x35\x61\xF4\x1D\xB6\x6C\xCE\x31\x4A\xDB\x31\x0E\x3B\xE8\x25\x0C\x46\xF0\x6D\xCE\xEA\x3A\x7F\xA1\x34\x80\x57\xE2\xF6\x55\x6A\xD6\xB1\x31\x8A\x02\x4A\x83\x8F\x21\xAF\x1F\xDE\x04\x89\x77\xEB\x48\xF5\x9F\xFD\x49\x24\xCA\x1C\x60\x90\x2E\x52\xF0\xA0\x89\xBC\x76\x89\x70\x40\xE0\x82\xF9\x37\x76\x38\x48\x64\x5E\x07\x05"
+        , "\x8E\x99\x3B\x9F\x48\x68\x12\x73\xC2\x96\x50\xBA\x32\xFC\x76\xCE\x48\x33\x2E\xA7\x16\x4D\x96\xA4\x47\x6F\xB8\xC5\x31\xA1\x18\x6A\xC0\xDF\xC1\x7C\x98\xDC\xE8\x7B\x4D\xA7\xF0\x11\xEC\x48\xC9\x72\x71\xD2\xC2\x0F\x9B\x92\x8F\xE2\x27\x0D\x6F\xB8\x63\xD5\x17\x38\xB4\x8E\xEE\xE3\x14\xA7\xCC\x8A\xB9\x32\x16\x45\x48\xE5\x26\xAE\x90\x22\x43\x68\x51\x7A\xCF\xEA\xBD\x6B\xB3\x73\x2B\xC0\xE9\xDA\x99\x83\x2B\x61\xCA\x01\xB6\xDE\x56\x24\x4A\x9E\x88\xD5\xF9\xB3\x79\x73\xF6\x22\xA4\x3D\x14\xA6\x59\x9B\x1F\x65\x4C\xB4\x5A\x74\xE3\x55\xA5"
+        )
     ]
 
-tests = testGroup "XSalsa"
-    [ testGroup "KAT" $
-        zipWith (\i (r, k, n, p, e) -> testCase (show (i :: Int)) $ salsaRunSimple r k n p e) [1..] vectors
-    , testGroup "crypto_box encryption" $
-        zipWith (\i (r, k, n, p, e) -> testCase (show (i :: Int)) $ cryptoBoxEnc r k n p e) [1..] vectorsCB
-    ]
+tests =
+    testGroup
+        "XSalsa"
+        [ testGroup "KAT" $
+            zipWith
+                (\i (r, k, n, p, e) -> testCase (show (i :: Int)) $ salsaRunSimple r k n p e)
+                [1 ..]
+                vectors
+        , testGroup "crypto_box encryption" $
+            zipWith
+                (\i (r, k, n, p, e) -> testCase (show (i :: Int)) $ cryptoBoxEnc r k n p e)
+                [1 ..]
+                vectorsCB
+        ]
   where
-      salsaRunSimple rounds key nonce plain expected =
-          let salsa = XSalsa.initialize rounds key nonce
-          in fst (XSalsa.combine salsa plain) @?= expected
+    salsaRunSimple rounds key nonce plain expected =
+        let salsa = XSalsa.initialize rounds key nonce
+         in fst (XSalsa.combine salsa plain) @?= expected
 
-      cryptoBoxEnc rounds shared nonce plain expected =
-          let zero        = B.replicate 16 0
-              (iv0, iv1)  = B.splitAt 8 nonce
-              salsa0      = XSalsa.initialize rounds shared (zero `B.append` iv0)
-              salsa1      = XSalsa.derive salsa0 iv1
-              (_, salsa2) = XSalsa.generate salsa1 32 :: (B.ByteString, XSalsa.State)
-          in fst (XSalsa.combine salsa2 plain) @?= expected
+    cryptoBoxEnc rounds shared nonce plain expected =
+        let zero = B.replicate 16 0
+            (iv0, iv1) = B.splitAt 8 nonce
+            salsa0 = XSalsa.initialize rounds shared (zero `B.append` iv0)
+            salsa1 = XSalsa.derive salsa0 iv1
+            (_, salsa2) = XSalsa.generate salsa1 32 :: (B.ByteString, XSalsa.State)
+         in fst (XSalsa.combine salsa2 plain) @?= expected
