| License | BSD-style | 
|---|---|
| Maintainer | Carlos Rodriguez-Vega <crodveg@yahoo.es> | 
| Stability | experimental | 
| Portability | unknown | 
| Safe Haskell | Safe-Inferred | 
| Language | Haskell2010 | 
Crypto.PubKey.Rabin.Basic
Description
Rabin cryptosystem for public-key cryptography and digital signature.
Synopsis
- data PublicKey = PublicKey {- public_size :: Int
- public_n :: Integer
 
- data PrivateKey = PrivateKey {}
- data Signature = Signature (Integer, Integer)
- generate :: MonadRandom m => Int -> m (PublicKey, PrivateKey)
- encrypt :: (HashAlgorithm hash, MonadRandom m) => OAEPParams hash ByteString ByteString -> PublicKey -> ByteString -> m (Either Error ByteString)
- encryptWithSeed :: HashAlgorithm hash => ByteString -> OAEPParams hash ByteString ByteString -> PublicKey -> ByteString -> Either Error ByteString
- decrypt :: HashAlgorithm hash => OAEPParams hash ByteString ByteString -> PrivateKey -> ByteString -> Maybe ByteString
- sign :: (MonadRandom m, HashAlgorithm hash) => PrivateKey -> hash -> ByteString -> m (Either Error Signature)
- signWith :: HashAlgorithm hash => ByteString -> PrivateKey -> hash -> ByteString -> Either Error Signature
- verify :: HashAlgorithm hash => PublicKey -> hash -> ByteString -> Signature -> Bool
Documentation
Represent a Rabin public key.
Constructors
| PublicKey | |
| Fields 
 | |
Instances
| Data PublicKey Source # | |
| Defined in Crypto.PubKey.Rabin.Basic Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PublicKey -> c PublicKey # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PublicKey # toConstr :: PublicKey -> Constr # dataTypeOf :: PublicKey -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PublicKey) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PublicKey) # gmapT :: (forall b. Data b => b -> b) -> PublicKey -> PublicKey # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PublicKey -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PublicKey -> r # gmapQ :: (forall d. Data d => d -> u) -> PublicKey -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PublicKey -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PublicKey -> m PublicKey # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PublicKey -> m PublicKey # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PublicKey -> m PublicKey # | |
| Read PublicKey Source # | |
| Show PublicKey Source # | |
| Eq PublicKey Source # | |
data PrivateKey Source #
Represent a Rabin private key.
Constructors
| PrivateKey | |
Instances
| Data PrivateKey Source # | |
| Defined in Crypto.PubKey.Rabin.Basic Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PrivateKey -> c PrivateKey # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PrivateKey # toConstr :: PrivateKey -> Constr # dataTypeOf :: PrivateKey -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PrivateKey) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PrivateKey) # gmapT :: (forall b. Data b => b -> b) -> PrivateKey -> PrivateKey # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PrivateKey -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PrivateKey -> r # gmapQ :: (forall d. Data d => d -> u) -> PrivateKey -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PrivateKey -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PrivateKey -> m PrivateKey # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PrivateKey -> m PrivateKey # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PrivateKey -> m PrivateKey # | |
| Read PrivateKey Source # | |
| Defined in Crypto.PubKey.Rabin.Basic Methods readsPrec :: Int -> ReadS PrivateKey # readList :: ReadS [PrivateKey] # readPrec :: ReadPrec PrivateKey # readListPrec :: ReadPrec [PrivateKey] # | |
| Show PrivateKey Source # | |
| Defined in Crypto.PubKey.Rabin.Basic Methods showsPrec :: Int -> PrivateKey -> ShowS # show :: PrivateKey -> String # showList :: [PrivateKey] -> ShowS # | |
| Eq PrivateKey Source # | |
| Defined in Crypto.PubKey.Rabin.Basic | |
Rabin Signature.
Instances
| Data Signature Source # | |
| Defined in Crypto.PubKey.Rabin.Basic Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Signature -> c Signature # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Signature # toConstr :: Signature -> Constr # dataTypeOf :: Signature -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Signature) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Signature) # gmapT :: (forall b. Data b => b -> b) -> Signature -> Signature # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Signature -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Signature -> r # gmapQ :: (forall d. Data d => d -> u) -> Signature -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Signature -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Signature -> m Signature # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Signature -> m Signature # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Signature -> m Signature # | |
| Read Signature Source # | |
| Show Signature Source # | |
| Eq Signature Source # | |
generate :: MonadRandom m => Int -> m (PublicKey, PrivateKey) Source #
Generate a pair of (private, public) key of size in bytes. 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.
Arguments
| :: (HashAlgorithm hash, MonadRandom m) | |
| => OAEPParams hash ByteString ByteString | OAEP padding parameters | 
| -> PublicKey | public key | 
| -> ByteString | plaintext | 
| -> m (Either Error ByteString) | 
Encrypt plaintext using public key.
Arguments
| :: HashAlgorithm hash | |
| => ByteString | Seed | 
| -> OAEPParams hash ByteString ByteString | OAEP padding | 
| -> PublicKey | public key | 
| -> ByteString | plaintext | 
| -> Either Error ByteString | 
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.
Arguments
| :: HashAlgorithm hash | |
| => OAEPParams hash ByteString ByteString | OAEP padding parameters | 
| -> PrivateKey | private key | 
| -> ByteString | ciphertext | 
| -> Maybe ByteString | 
Decrypt ciphertext using private key.
See algorithm 8.12 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
Arguments
| :: (MonadRandom m, HashAlgorithm hash) | |
| => PrivateKey | private key | 
| -> hash | hash function | 
| -> ByteString | message to sign | 
| -> m (Either Error Signature) | 
Sign message using hash algorithm and private key.
See https://en.wikipedia.org/wiki/Rabin_signature_algorithm.
Arguments
| :: HashAlgorithm hash | |
| => ByteString | padding | 
| -> PrivateKey | private key | 
| -> hash | hash function | 
| -> ByteString | message to sign | 
| -> Either Error Signature | 
Sign message using padding, hash algorithm and private key.
See https://en.wikipedia.org/wiki/Rabin_signature_algorithm.
Arguments
| :: HashAlgorithm hash | |
| => PublicKey | private key | 
| -> hash | hash function | 
| -> ByteString | message | 
| -> Signature | signature | 
| -> Bool | 
Verify signature using hash algorithm and public key.
See https://en.wikipedia.org/wiki/Rabin_signature_algorithm.