RSA public-key encryption
Raised if the key is too small to transform the given message, i.e. if the numerical interpretation of the (potentially padded) message is not smaller than the modulus.
It is additionally raised if the message is 0
and the mode does not involve padding.
type priv = {
e : Z.t; | Public exponent |
d : Z.t; | Private exponent |
n : Z.t; | Modulus |
p : Z.t; | Prime factor |
q : Z.t; | Prime factor |
dp : Z.t; |
|
dq : Z.t; |
|
q' : Z.t; |
|
}
Private key (two-factor version).
Sexplib
convertible.
Masking (cryptographic blinding) option.
val pub_bits : pub -> int
Bit-size of a public key.
val priv_bits : priv -> int
Bit-size of a private key.
priv_of_primes e p q
creates priv from a minimal description: the public exponent and the two primes.
encrypt key message
is the encrypted message
.
- raises Insufficient_key
(see Insufficient_key)
decrypt mask key ciphertext
is the decrypted ciphertext
, left-padded with 0x00
up to key
size.
- raises Insufficient_key
(see Insufficient_key)
generate g e bits
is a new priv. e
defaults to 2^16+1
.
- raises Invalid_argument
if
e
is bad orbits
is too small.
PKCS#1 padded modes
module PKCS1 : sig ... end
PKCS v1.5-padded operations, as defined by PKCS #1 v1.5.
OAEP-padded encryption, as defined by PKCS #1 v2.1.