Pkcs1RsaPrivateKey class
PKCS #1 version 2.0 representation of an RSA private key.
This class can be used to:
- Decode a sequence of bytes into the parameters for an RSA private key using the decode constructor; or
- Encode the parameters for an RSA private key into a sequence of bytes using the encode method.
This class only exposes the modulus, privateExponent, prime1 and prime2 RSA parameters, even though the binary format includes other parameters.
Format
This binary format is defined in RFC 2437 PKCS #1: RSA Cryptography Specifications, Version 2.0 by this ASN.1 type:
RSAPrivateKey ::= SEQUENCE {
version Version,
modulus INTEGER, -- n
publicExponent INTEGER, -- e
privateExponent INTEGER, -- d
prime1 INTEGER, -- p
prime2 INTEGER, -- q
exponent1 INTEGER, -- d mod (p-1)
exponent2 INTEGER, -- d mod (q-1)
coefficient INTEGER -- (inverse of q) mod p }
Version ::= INTEGER
Where:
- version is the version number, for compatibility with future
- modulus is the modulus n.
- publicExponent is the public exponent e.
- privateExponent is the private exponent d.
- prime1 is the prime factor p of n.
- prime2 is the prime factor q of n.
- exponent1 is d mod (p-1).
- exponent2 is d mod (q-1).
- coefficient is the Chinese Remainder Theorem coefficient q-1 mod p.
This implementation only supports a value of 0 for the version object.
The ASN.1 type is identical in PKCS #1 version 1.5 (RFC 2313).
Version of PKCS #1 newer than version 2.0 are not supported. The ASN.1 type in PKCS #1 version 2.1 (RFC 3447) and PKCS #1 version 2.2 (RFC 8017) are identified by a value of 1 for the version object. The decode constructor will throw an exception if the value of the version object is not 0.
- Implemented types
Constructors
- Pkcs1RsaPrivateKey(BigInt modulus, BigInt privateExponent, BigInt prime1, BigInt prime2)
- Constructor.
- Pkcs1RsaPrivateKey.decode(Uint8List data, PvtTextSource? source)
- Decode from a sequence of bytes.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- modulus ↔ BigInt
-
RSA modulus (n)
latefinal
- prime1 ↔ BigInt
-
Prime 1 (p)
latefinal
- prime2 ↔ BigInt
-
Prime 2 (q)
latefinal
- privateExponent ↔ BigInt
-
RSA private exponent (d)
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → PvtTextSource?
-
Source this was decoded from.
final
Methods
-
encode(
) → Uint8List -
Encode as a sequence of bytes.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited