Class StrongNamePrivateKey
- Namespace
- AsmResolver.PE.DotNet.StrongName
- Assembly
- AsmResolver.PE.dll
Represents a public/private key pair in the RSA crypto system.
public class StrongNamePrivateKey : StrongNamePublicKey, ISegment, IOffsetProvider, IWritable
- Inheritance
-
StrongNamePrivateKey
- Implements
- Inherited Members
Constructors
StrongNamePrivateKey(in RSAParameters)
Imports a public/private key pair from an instance of RSAParameters.
public StrongNamePrivateKey(in RSAParameters parameters)
Parameters
parameters
RSAParametersThe RSA parameters to import.
StrongNamePrivateKey(uint)
Creates a new empty private key.
public StrongNamePrivateKey(uint bitLength)
Parameters
bitLength
uint
Properties
DP
Gets or sets the first exponent (equal to d mod (p-1)) used in the RSA crypto system.
public byte[] DP { get; set; }
Property Value
- byte[]
DQ
Gets or sets the second exponent (equal to d mod (q-1)) used in the RSA crypto system.
public byte[] DQ { get; set; }
Property Value
- byte[]
InverseQ
Gets or sets the coefficient which is equal to the modular inverse of q mod p, used in the RSA crypto system.
public byte[] InverseQ { get; set; }
Property Value
- byte[]
Magic
Gets the magic header number defining the type of RSA public key structure.
public override RsaPublicKeyMagic Magic { get; }
Property Value
P
Gets or sets the first prime number used in the RSA crypto system.
public byte[] P { get; set; }
Property Value
- byte[]
PrivateExponent
Gets or sets the private exponent used in the RSA crypto system.
public byte[] PrivateExponent { get; set; }
Property Value
- byte[]
Q
Gets or sets the second prime number used in the RSA crypto system.
public byte[] Q { get; set; }
Property Value
- byte[]
Type
Gets the type of structure that is encoded.
public override StrongNameKeyStructureType Type { get; }
Property Value
Version
Gets the version number of the structure.
public override byte Version { get; }
Property Value
Methods
FromFile(string)
Reads a private key from an input file.
public static StrongNamePrivateKey FromFile(string path)
Parameters
path
stringThe path to the strong-name key file.
Returns
- StrongNamePrivateKey
The private key.
Exceptions
- FormatException
Occurs when the input stream is not in the correct format.
- NotSupportedException
Occurs when an invalid or unsupported algorithm is specified.
FromReader(ref BinaryStreamReader)
Reads a private key from an input stream.
public static StrongNamePrivateKey FromReader(ref BinaryStreamReader reader)
Parameters
reader
BinaryStreamReaderThe input stream.
Returns
- StrongNamePrivateKey
The private key.
Exceptions
- FormatException
Occurs when the input stream is not in the correct format.
- NotSupportedException
Occurs when an invalid or unsupported algorithm is specified.
GetPhysicalSize()
Computes the number of bytes that the structure contains.
public override uint GetPhysicalSize()
Returns
- uint
The number of bytes.
ToRsaParameters()
Translates the strong name parameters to an instance of RSAParameters.
public override RSAParameters ToRsaParameters()
Returns
- RSAParameters
The converted RSA parameters.
Write(BinaryStreamWriter)
Serializes the structure to an output stream.
public override void Write(BinaryStreamWriter writer)
Parameters
writer
BinaryStreamWriterThe output stream to write the data to.