RSA 1.2.1.0 → 1.2.2.0
raw patch · 2 files changed
+12/−13 lines, 2 filesdep ~crypto-pubkey-typesPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: crypto-pubkey-types
API changes (from Hackage documentation)
+ Codec.Crypto.RSA: data PrivateKey :: *
+ Codec.Crypto.RSA: data PublicKey :: *
Files
- Codec/Crypto/RSA.hs +10/−11
- RSA.cabal +2/−2
Codec/Crypto/RSA.hs view
@@ -5,6 +5,8 @@ module Codec.Crypto.RSA( -- * Keys and key generations generateKeyPair+ , PrivateKey+ , PublicKey -- * High-level encryption and signing functions , encrypt , decrypt@@ -75,14 +77,11 @@ return $ PublicKey (fromIntegral len) n 65537 instance Binary PrivateKey where- put pk = do putLazyByteString $ i2osp (private_size pk) 8- putLazyByteString $ i2osp (private_n pk) (private_size pk)- putLazyByteString $ i2osp (private_d pk) (private_size pk)- get = do len <- (fromIntegral . os2ip) `fmap` getLazyByteString 8- n <- os2ip `fmap` getLazyByteString len- d <- os2ip `fmap` getLazyByteString len- return $ PrivateKey { private_size = fromIntegral len- , private_n = n+ put pk = do put (private_pub pk)+ putLazyByteString $ i2osp (private_d pk) (public_size $ private_pub pk)+ get = do pub <- get+ d <- os2ip `fmap` getLazyByteString (fromIntegral $ public_size pub)+ return $ PrivateKey { private_pub = pub , private_d = d , private_p = 0 , private_q = 0@@ -115,7 +114,7 @@ -- generator is of considerable importance when using this function; the -- input CryptoRandomGen should never be used again for any other purpose. generateKeyPair :: CryptoRandomGen g => g -> Int -> (PublicKey, PrivateKey, g)-generateKeyPair g sizeBits = (PublicKey kLen n e, privateKey, g')+generateKeyPair g sizeBits = (publicKey, privateKey, g') where kLen = fromIntegral $ sizeBits `div` 8 (p, q, g') = generate_pq g kLen@@ -123,8 +122,8 @@ phi = (p - 1) * (q - 1) e = 65537 d = modular_inverse e phi - privateKey = PrivateKey { private_size = kLen- , private_n = n+ publicKey = PublicKey kLen n e+ privateKey = PrivateKey { private_pub = publicKey , private_d = d , private_p = 0 , private_q = 0
RSA.cabal view
@@ -1,6 +1,6 @@ name: RSA category: Cryptography, Codec-version: 1.2.1.0+version: 1.2.2.0 license: BSD3 license-file: LICENSE author: Adam Wick <awick@galois.com>@@ -32,7 +32,7 @@ Default: False Library- build-depends: bytestring, crypto-api >= 0.10, monadcryptorandom, crypto-pubkey-types+ build-depends: bytestring, crypto-api >= 0.10, monadcryptorandom, crypto-pubkey-types >= 0.2 GHC-Options: -O2 -Wall -fno-ignore-asserts -fno-warn-orphans if flag(OldBase) build-depends: base >= 3 && < 4, SHA < 1.4.1