Class EbicsPrivKey

Namespace
Subsembly.EBICS
Assembly
Subsembly.EBICS.Core.dll

A private RSA user key.

public class EbicsPrivKey
Inheritance
EbicsPrivKey
Inherited Members

Constructors

EbicsPrivKey(EbicsSecurityCode, DateTime, CryRSA)

public EbicsPrivKey(EbicsSecurityCode nSecCode, DateTime tTimeStamp, CryRSA aRSA)

Parameters

nSecCode EbicsSecurityCode

The security process for which the key shall be used.

tTimeStamp DateTime

The exact time when the key was originally generated. Use DateTime.MinValue if not known or relevant.

aRSA CryRSA

The RSA private key. Must not be null and must contain both, the public and private key parts.

Fields

MAXKEYLENGTH

Actually the maximum RSA key length allowed for any EBICS key is 16384 bits or 2048 bytes. This constant, however, places a more practical limit at 4096 bits, or 512 bytes.

public const int MAXKEYLENGTH = 512

Field Value

int

MINKEYLENGTH

The minimum RSA key length allowed for any EBICS key is 1024 bits or 128 bytes.

public const int MINKEYLENGTH = 128

Field Value

int

Properties

KeyLength

The actual length of the RSA modulus in bytes.

public int KeyLength { get; }

Property Value

int

RSA

public CryRSA RSA { get; }

Property Value

CryRSA

SecurityCode

The security operation and implicit version that this key was generated for.

public EbicsSecurityCode SecurityCode { get; }

Property Value

EbicsSecurityCode

TimeStamp

The time at which this key was initially generated.

public DateTime TimeStamp { get; }

Property Value

DateTime

This is DateTime.MinValue if not known.

Methods

CopyPrivKeys(EbicsContact, IEbicsSecurityMedium, IEbicsSecurityMedium)

Copies all private keys from one security medium to another security medium.

public static void CopyPrivKeys(EbicsContact aContact, IEbicsSecurityMedium aSourceMedium, IEbicsSecurityMedium aDestMedium)

Parameters

aContact EbicsContact

The EBICS contact for which the keys shall be copied. A security medium may hold the keys for multiple contacts, hence this may be needed to identify the appropriate keys. Only the keys specified in AuthenticationVersion, EncryptionVersion, and SignatureVersion will be copied from the source to the destination medium.

aSourceMedium IEbicsSecurityMedium

The source security medium from which to copy the keys. This security medium must support getting the private keys, which is definitely not the case with smart cards. The security medium must already have been authenticated.

aDestMedium IEbicsSecurityMedium

The source security medium to which to copy the keys. This security medium must support setting the private keys, which is definitely not the case with smart cards. The security medium must already have been authenticated.

Exceptions

ArgumentNullException
NotSupportedException

Either the source or the destination security medium does not support access to the private keys. Or the destination medium does not support the key types from the source medium.

InvalidOperationException

Either the source or the destination security medium was not in the Authenticated state.

Decrypt(byte[])

public byte[] Decrypt(byte[] vbCrypt)

Parameters

vbCrypt byte[]

Returns

byte[]

Remarks

This is a low level method that is not usually called by application code!

DeletePrivKeys(EbicsContact, IEbicsSecurityMedium)

public static void DeletePrivKeys(EbicsContact aContact, IEbicsSecurityMedium aSecMedium)

Parameters

aContact EbicsContact
aSecMedium IEbicsSecurityMedium

ExportKeyBlob()

Exports all key data in an opaque byte blob for storage.

public EbicsDataBuffer ExportKeyBlob()

Returns

EbicsDataBuffer

Returns a data buffer with the key data. This key data can be used to re-create the private key via ImportKeyBlob(EbicsDataBuffer).

See Also

Generate(EbicsSecurityCode, int)

Generates a new RSA key pair of the given length.

public static EbicsPrivKey Generate(EbicsSecurityCode nSecCode, int nKeyLength)

Parameters

nSecCode EbicsSecurityCode

The security operation for which the key shall be used.

nKeyLength int

Byte length of the RSA keys to be generated. This must be in the range from MINKEYLENGTH to MAXKEYLENGTH.

Returns

EbicsPrivKey

Remarks

The public exponent is implicitly chosen as Fermat 4.

GetPublicExponent()

Provides the public RSA exponent (which is always Fermat 4) as a byte array.

public byte[] GetPublicExponent()

Returns

byte[]

Returns a compact byte array that contains only the significant bytes of the public exponent.

Remarks

This is a low level method that is not usually called by application code!

GetPublicKeyInfo()

Provides the complete public key information.

public EbicsPubKeyInfo GetPublicKeyInfo()

Returns

EbicsPubKeyInfo

A new EbicsPubKeyInfo instance that can be conveniently used to create a PubKeyInfo XML element and also to perform the public security operations.

GetPublicModulus()

Provides the common public RSA modulus as a byte array.

public byte[] GetPublicModulus()

Returns

byte[]

Returns a compact byte array that contains only the significant bytes of the public modulus.

Remarks

This is a low level method that is not usually called by application code!

ImportKeyBlob(EbicsDataBuffer)

Creates a new EbicsPrivKey instance from a previously exported key blob.

public static EbicsPrivKey ImportKeyBlob(EbicsDataBuffer dKeyBlob)

Parameters

dKeyBlob EbicsDataBuffer

Returns

EbicsPrivKey
See Also

SignHash(byte[])

public byte[] SignHash(byte[] vbHash)

Parameters

vbHash byte[]

Returns

byte[]

Remarks

This is a low level method that is not usually called by application code!