remove dangerous OverloadedStrings

This commit is contained in:
Vincent Hanquez 2015-05-21 06:45:46 +01:00
parent dc34ce8289
commit 8065c26c2d
6 changed files with 14 additions and 17 deletions

View File

@ -8,7 +8,6 @@
-- P256 support -- P256 support
-- --
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE BangPatterns #-}
{-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE EmptyDataDecls #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-}

View File

@ -8,7 +8,6 @@
-- Ed25519 support -- Ed25519 support
-- --
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE BangPatterns #-}
module Crypto.PubKey.Ed25519 module Crypto.PubKey.Ed25519
( SecretKey ( SecretKey

View File

@ -27,6 +27,7 @@ module Crypto.PubKey.HashDescr
import Data.ByteString.Char8 () import Data.ByteString.Char8 ()
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import qualified Data.ByteString as B import qualified Data.ByteString as B
import Data.Word
import Crypto.Hash import Crypto.Hash
import qualified Crypto.Internal.ByteArray as B (convert) import qualified Crypto.Internal.ByteArray as B (convert)
@ -43,50 +44,50 @@ data HashDescr = HashDescr { hashFunction :: HashFunction -- ^ hash
hashDescrMD2 :: HashDescr hashDescrMD2 :: HashDescr
hashDescrMD2 = hashDescrMD2 =
HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest MD2) 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 -- | Describe the MD5 hashing algorithm
hashDescrMD5 :: HashDescr hashDescrMD5 :: HashDescr
hashDescrMD5 = hashDescrMD5 =
HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest MD5) 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 -- | Describe the SHA1 hashing algorithm
hashDescrSHA1 :: HashDescr hashDescrSHA1 :: HashDescr
hashDescrSHA1 = hashDescrSHA1 =
HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA1) 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 -- | Describe the SHA224 hashing algorithm
hashDescrSHA224 :: HashDescr hashDescrSHA224 :: HashDescr
hashDescrSHA224 = hashDescrSHA224 =
HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA224) 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 -- | Describe the SHA256 hashing algorithm
hashDescrSHA256 :: HashDescr hashDescrSHA256 :: HashDescr
hashDescrSHA256 = hashDescrSHA256 =
HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA256) 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 -- | Describe the SHA384 hashing algorithm
hashDescrSHA384 :: HashDescr hashDescrSHA384 :: HashDescr
hashDescrSHA384 = hashDescrSHA384 =
HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA384) 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 -- | Describe the SHA512 hashing algorithm
hashDescrSHA512 :: HashDescr hashDescrSHA512 :: HashDescr
hashDescrSHA512 = hashDescrSHA512 =
HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest SHA512) 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 -- | Describe the RIPEMD160 hashing algorithm
hashDescrRIPEMD160 :: HashDescr hashDescrRIPEMD160 :: HashDescr
hashDescrRIPEMD160 = hashDescrRIPEMD160 =
HashDescr { hashFunction = B.convert . (hash :: ByteString -> Digest RIPEMD160) 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: -- | Generate the marshalled structure with the following ASN1 structure:
@ -99,5 +100,5 @@ hashDescrRIPEMD160 =
-- ,OctetString digest -- ,OctetString digest
-- ,End Sequence -- ,End Sequence
-- --
toHashWithInfo :: ByteString -> ByteString -> ByteString toHashWithInfo :: [Word8] -> ByteString -> ByteString
toHashWithInfo pre digest = pre `B.append` digest toHashWithInfo pre digest = B.pack pre `B.append` digest

View File

@ -8,7 +8,6 @@
-- RSA OAEP mode -- RSA OAEP mode
-- <http://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding> -- <http://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding>
-- --
{-# LANGUAGE OverloadedStrings #-}
module Crypto.PubKey.RSA.OAEP module Crypto.PubKey.RSA.OAEP
( (
OAEPParams(..) OAEPParams(..)
@ -117,8 +116,8 @@ unpad oaep k em
(ps1,msg) = B.splitAt 1 db2 (ps1,msg) = B.splitAt 1 db2
paddingSuccess = and' [ labelHash' == labelHash -- no need for constant eq paddingSuccess = and' [ labelHash' == labelHash -- no need for constant eq
, ps1 == "\x01" , ps1 == B.replicate 1 0x1
, pb == "\x00" , pb == B.replicate 1 0x0
] ]
-- | Decrypt a ciphertext using OAEP -- | Decrypt a ciphertext using OAEP

View File

@ -5,7 +5,6 @@
-- Stability : experimental -- Stability : experimental
-- Portability : Good -- Portability : Good
-- --
{-# LANGUAGE OverloadedStrings #-}
module Crypto.PubKey.RSA.PKCS15 module Crypto.PubKey.RSA.PKCS15
( (
-- * padding and unpadding -- * padding and unpadding

2
QA.hs
View File

@ -18,7 +18,7 @@ import Control.Exception
import System.Console.ANSI import System.Console.ANSI
allowedExtensions = allowedExtensions =
[ ScopedTypeVariables, BangPatterns, ForeignFunctionInterface, OverloadedStrings, DeriveDataTypeable, ViewPatterns, GeneralizedNewtypeDeriving, ExistentialQuantification, EmptyDataDecls ] [ ScopedTypeVariables, BangPatterns, ForeignFunctionInterface, DeriveDataTypeable, ViewPatterns, GeneralizedNewtypeDeriving, ExistentialQuantification, EmptyDataDecls ]
perModuleAllowedExtensions = perModuleAllowedExtensions =
[ ("Crypto/Hash/Utils.hs", [MagicHash]) [ ("Crypto/Hash/Utils.hs", [MagicHash])
, ("Crypto/Internal/ByteArray.hs", [MagicHash, UnboxedTuples]) , ("Crypto/Internal/ByteArray.hs", [MagicHash, UnboxedTuples])