diff --git a/Crypto/PubKey/ECC/P256.hs b/Crypto/PubKey/ECC/P256.hs index 1b05d3c..5c0a0a9 100644 --- a/Crypto/PubKey/ECC/P256.hs +++ b/Crypto/PubKey/ECC/P256.hs @@ -8,7 +8,6 @@ -- P256 support -- {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE EmptyDataDecls #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} diff --git a/Crypto/PubKey/Ed25519.hs b/Crypto/PubKey/Ed25519.hs index 870f971..2d9e844 100644 --- a/Crypto/PubKey/Ed25519.hs +++ b/Crypto/PubKey/Ed25519.hs @@ -8,7 +8,6 @@ -- Ed25519 support -- {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE BangPatterns #-} module Crypto.PubKey.Ed25519 ( SecretKey diff --git a/Crypto/PubKey/HashDescr.hs b/Crypto/PubKey/HashDescr.hs index c5f79a6..6ddf0e1 100644 --- a/Crypto/PubKey/HashDescr.hs +++ b/Crypto/PubKey/HashDescr.hs @@ -27,6 +27,7 @@ module Crypto.PubKey.HashDescr import Data.ByteString.Char8 () import Data.ByteString (ByteString) import qualified Data.ByteString as B +import Data.Word import Crypto.Hash import qualified Crypto.Internal.ByteArray as B (convert) @@ -43,50 +44,50 @@ data HashDescr = HashDescr { hashFunction :: HashFunction -- ^ hash hashDescrMD2 :: HashDescr hashDescrMD2 = HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest MD2) - , digestToASN1 = toHashWithInfo "\x30\x20\x30\x0c\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x02\x05\x00\x04\x10" + , digestToASN1 = toHashWithInfo [0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x02,0x05,0x00,0x04,0x10] } -- | Describe the MD5 hashing algorithm hashDescrMD5 :: HashDescr hashDescrMD5 = HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest MD5) - , digestToASN1 = toHashWithInfo "\x30\x20\x30\x0c\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x05\x05\x00\x04\x10" + , digestToASN1 = toHashWithInfo [0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x04,0x10] } -- | Describe the SHA1 hashing algorithm hashDescrSHA1 :: HashDescr hashDescrSHA1 = HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA1) - , digestToASN1 = toHashWithInfo "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14" + , digestToASN1 = toHashWithInfo [0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,0x05,0x00,0x04,0x14] } -- | Describe the SHA224 hashing algorithm hashDescrSHA224 :: HashDescr hashDescrSHA224 = HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA224) - , digestToASN1 = toHashWithInfo "\x30\x2d\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04\x05\x00\x04\x1c" + , digestToASN1 = toHashWithInfo [0x30,0x2d,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,0x05,0x00,0x04,0x1c] } -- | Describe the SHA256 hashing algorithm hashDescrSHA256 :: HashDescr hashDescrSHA256 = HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA256) - , digestToASN1 = toHashWithInfo "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20" + , digestToASN1 = toHashWithInfo [0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20] } -- | Describe the SHA384 hashing algorithm hashDescrSHA384 :: HashDescr hashDescrSHA384 = HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA384) - , digestToASN1 = toHashWithInfo "\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02\x05\x00\x04\x30" + , digestToASN1 = toHashWithInfo [0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30] } -- | Describe the SHA512 hashing algorithm hashDescrSHA512 :: HashDescr hashDescrSHA512 = HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA512) - , digestToASN1 = toHashWithInfo "\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40" + , digestToASN1 = toHashWithInfo [0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40] } -- | Describe the RIPEMD160 hashing algorithm hashDescrRIPEMD160 :: HashDescr hashDescrRIPEMD160 = HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest RIPEMD160) - , digestToASN1 = toHashWithInfo "\x30\x21\x30\x09\x06\x05\x2b\x24\x03\x02\x01\x05\x00\x04\x14" + , digestToASN1 = toHashWithInfo [0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x24,0x03,0x02,0x01,0x05,0x00,0x04,0x14] } -- | Generate the marshalled structure with the following ASN1 structure: @@ -99,5 +100,5 @@ hashDescrRIPEMD160 = -- ,OctetString digest -- ,End Sequence -- -toHashWithInfo :: ByteString -> ByteString -> ByteString -toHashWithInfo pre digest = pre `B.append` digest +toHashWithInfo :: [Word8] -> ByteString -> ByteString +toHashWithInfo pre digest = B.pack pre `B.append` digest diff --git a/Crypto/PubKey/RSA/OAEP.hs b/Crypto/PubKey/RSA/OAEP.hs index 6df7fce..770c7fb 100644 --- a/Crypto/PubKey/RSA/OAEP.hs +++ b/Crypto/PubKey/RSA/OAEP.hs @@ -8,7 +8,6 @@ -- RSA OAEP mode -- -- -{-# LANGUAGE OverloadedStrings #-} module Crypto.PubKey.RSA.OAEP ( OAEPParams(..) @@ -117,8 +116,8 @@ unpad oaep k em (ps1,msg) = B.splitAt 1 db2 paddingSuccess = and' [ labelHash' == labelHash -- no need for constant eq - , ps1 == "\x01" - , pb == "\x00" + , ps1 == B.replicate 1 0x1 + , pb == B.replicate 1 0x0 ] -- | Decrypt a ciphertext using OAEP diff --git a/Crypto/PubKey/RSA/PKCS15.hs b/Crypto/PubKey/RSA/PKCS15.hs index 933e273..deebc4a 100644 --- a/Crypto/PubKey/RSA/PKCS15.hs +++ b/Crypto/PubKey/RSA/PKCS15.hs @@ -5,7 +5,6 @@ -- Stability : experimental -- Portability : Good -- -{-# LANGUAGE OverloadedStrings #-} module Crypto.PubKey.RSA.PKCS15 ( -- * padding and unpadding diff --git a/QA.hs b/QA.hs index d532ab9..d7af81e 100644 --- a/QA.hs +++ b/QA.hs @@ -18,7 +18,7 @@ import Control.Exception import System.Console.ANSI allowedExtensions = - [ ScopedTypeVariables, BangPatterns, ForeignFunctionInterface, OverloadedStrings, DeriveDataTypeable, ViewPatterns, GeneralizedNewtypeDeriving, ExistentialQuantification, EmptyDataDecls ] + [ ScopedTypeVariables, BangPatterns, ForeignFunctionInterface, DeriveDataTypeable, ViewPatterns, GeneralizedNewtypeDeriving, ExistentialQuantification, EmptyDataDecls ] perModuleAllowedExtensions = [ ("Crypto/Hash/Utils.hs", [MagicHash]) , ("Crypto/Internal/ByteArray.hs", [MagicHash, UnboxedTuples])