RSA 2.0 support

This commit is contained in:
Michael Snoyman 2014-02-21 07:16:04 +02:00
parent 82a0d0d390
commit 94cab1c9d4
2 changed files with 9 additions and 1 deletions

View File

@ -35,7 +35,11 @@ import Data.Digest.Pure.SHA
import Data.ByteString.Base64 import Data.ByteString.Base64
import Data.Time import Data.Time
import Numeric import Numeric
#if MIN_VERSION_RSA(2, 0, 0)
import Codec.Crypto.RSA (rsassa_pkcs1_v1_5_sign, hashSHA1)
#else
import Codec.Crypto.RSA (rsassa_pkcs1_v1_5_sign, ha_SHA1) import Codec.Crypto.RSA (rsassa_pkcs1_v1_5_sign, ha_SHA1)
#endif
import Crypto.Types.PubKey.RSA (PrivateKey(..), PublicKey(..)) import Crypto.Types.PubKey.RSA (PrivateKey(..), PublicKey(..))
import Network.HTTP.Types (Header) import Network.HTTP.Types (Header)
import Blaze.ByteString.Builder (toByteString) import Blaze.ByteString.Builder (toByteString)
@ -344,7 +348,11 @@ genSign oa tok req =
PLAINTEXT -> PLAINTEXT ->
return $ BS.intercalate "&" $ map paramEncode [oauthConsumerSecret oa, tokenSecret tok] return $ BS.intercalate "&" $ map paramEncode [oauthConsumerSecret oa, tokenSecret tok]
RSASHA1 pr -> RSASHA1 pr ->
#if MIN_VERSION_RSA(2, 0, 0)
liftM (encode . toStrict . rsassa_pkcs1_v1_5_sign hashSHA1 pr) (getBaseString tok req)
#else
liftM (encode . toStrict . rsassa_pkcs1_v1_5_sign ha_SHA1 pr) (getBaseString tok req) liftM (encode . toStrict . rsassa_pkcs1_v1_5_sign ha_SHA1 pr) (getBaseString tok req)
#endif
#if MIN_VERSION_http_conduit(2, 0, 0) #if MIN_VERSION_http_conduit(2, 0, 0)
addAuthHeader :: BS.ByteString -> Credential -> Request -> Request addAuthHeader :: BS.ByteString -> Credential -> Request -> Request

View File

@ -19,7 +19,7 @@ library
, transformers >= 0.1 && < 0.4 , transformers >= 0.1 && < 0.4
, bytestring >= 0.9 , bytestring >= 0.9
, crypto-pubkey-types >= 0.1 && < 0.5 , crypto-pubkey-types >= 0.1 && < 0.5
, RSA >= 1.2 && < 1.3 , RSA >= 1.2 && < 2.1
, time , time
, data-default , data-default
, base64-bytestring >= 0.1 && < 1.1 , base64-bytestring >= 0.1 && < 1.1