Table of Contents

Class StrongNamePublicKey

Namespace
AsmResolver.PE.DotNet.StrongName
Assembly
AsmResolver.PE.dll

Represents the public key in a RSA crypto system.

public class StrongNamePublicKey : StrongNameKeyStructure, ISegment, IOffsetProvider, IWritable
Inheritance
StrongNamePublicKey
Implements
Derived
Inherited Members

Constructors

StrongNamePublicKey(byte[], uint)

Creates a new strong name public key.

public StrongNamePublicKey(byte[] modulus, uint publicExponent)

Parameters

modulus byte[]

The modulus to use in the RSA crypto system.

publicExponent uint

The public exponent to use in the RSA crypto system.

StrongNamePublicKey(in RSAParameters)

Imports a public key from an instance of RSAParameters.

public StrongNamePublicKey(in RSAParameters parameters)

Parameters

parameters RSAParameters

The RSA parameters to import.

Properties

BitLength

Gets the number of bits used by the modulus parameter.

public int BitLength { get; }

Property Value

int

Magic

Gets the magic header number defining the type of RSA public key structure.

public virtual RsaPublicKeyMagic Magic { get; }

Property Value

RsaPublicKeyMagic

Modulus

Gets or sets the modulus used in the RSA crypto system.

public byte[] Modulus { get; set; }

Property Value

byte[]

PublicExponent

Gets or sets the public exponent used in the RSA crypto system.

public uint PublicExponent { get; set; }

Property Value

uint

SignatureAlgorithm

Gets the algorithm used.

public override SignatureAlgorithm SignatureAlgorithm { get; }

Property Value

SignatureAlgorithm

Type

Gets the type of structure that is encoded.

public override StrongNameKeyStructureType Type { get; }

Property Value

StrongNameKeyStructureType

Version

Gets the version number of the structure.

public override byte Version { get; }

Property Value

byte

Methods

CreatePublicKeyBlob(AssemblyHashAlgorithm)

Prepares a blob signature containing the full public key of an assembly.

public byte[] CreatePublicKeyBlob(AssemblyHashAlgorithm hashAlgorithm)

Parameters

hashAlgorithm AssemblyHashAlgorithm

The hash algorithm that is used to hash the PE file.

Returns

byte[]

The blob signature.

FromFile(string)

Reads a private key from an input file.

public static StrongNamePublicKey FromFile(string path)

Parameters

path string

The path to the strong-name key file.

Returns

StrongNamePublicKey

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 StrongNamePublicKey FromReader(ref BinaryStreamReader reader)

Parameters

reader BinaryStreamReader

The input stream.

Returns

StrongNamePublicKey

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 virtual 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 BinaryStreamWriter

The output stream to write the data to.