Class EbicsPrivKey
A private RSA user key.
Inheritance
Inherited Members
Namespace: Subsembly.EBICS
Assembly: Subsembly.EBICS.Core.dll
Syntax
public class EbicsPrivKey
Constructors
EbicsPrivKey(EbicsSecurityCode, DateTime, CryRSA)
Declaration
public EbicsPrivKey(EbicsSecurityCode nSecCode, DateTime tTimeStamp, CryRSA aRSA)
Parameters
Type | Name | Description |
---|---|---|
EbicsSecurityCode | nSecCode | The security process for which the key shall be used. |
System.DateTime | tTimeStamp | The exact time when the key was originally generated. Use DateTime.MinValue if not known or relevant. |
Subsembly.Crypto.CryRSA | aRSA | The RSA private key. Must not be |
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.
Declaration
public const int MAXKEYLENGTH = 512
Field Value
Type | Description |
---|---|
System.Int32 |
MINKEYLENGTH
The minimum RSA key length allowed for any EBICS key is 1024 bits or 128 bytes.
Declaration
public const int MINKEYLENGTH = 128
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
KeyLength
The actual length of the RSA modulus in bytes.
Declaration
public int KeyLength { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
RSA
Declaration
public CryRSA RSA { get; }
Property Value
Type | Description |
---|---|
Subsembly.Crypto.CryRSA |
SecurityCode
The security operation and implicit version that this key was generated for.
Declaration
public EbicsSecurityCode SecurityCode { get; }
Property Value
Type | Description |
---|---|
EbicsSecurityCode |
TimeStamp
The time at which this key was initially generated.
Declaration
public DateTime TimeStamp { get; }
Property Value
Type | Description |
---|---|
System.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.
Declaration
public static void CopyPrivKeys(EbicsContact aContact, IEbicsSecurityMedium aSourceMedium, IEbicsSecurityMedium aDestMedium)
Parameters
Type | Name | Description |
---|---|---|
EbicsContact | aContact | 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. |
IEbicsSecurityMedium | aSourceMedium | 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. |
IEbicsSecurityMedium | aDestMedium | 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
Type | Condition |
---|---|
System.ArgumentNullException | |
System.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. |
System.InvalidOperationException | Either the source or the destination security medium was not in the Authenticated state. |
Decrypt(Byte[])
Declaration
public byte[] Decrypt(byte[] vbCrypt)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vbCrypt |
Returns
Type | Description |
---|---|
System.Byte[] |
Remarks
This is a low level method that is not usually called by application code!
DeletePrivKeys(EbicsContact, IEbicsSecurityMedium)
Declaration
public static void DeletePrivKeys(EbicsContact aContact, IEbicsSecurityMedium aSecMedium)
Parameters
Type | Name | Description |
---|---|---|
EbicsContact | aContact | |
IEbicsSecurityMedium | aSecMedium |
ExportKeyBlob()
Exports all key data in an opaque byte blob for storage.
Declaration
public EbicsDataBuffer ExportKeyBlob()
Returns
Type | Description |
---|---|
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, Int32)
Generates a new RSA key pair of the given length.
Declaration
public static EbicsPrivKey Generate(EbicsSecurityCode nSecCode, int nKeyLength)
Parameters
Type | Name | Description |
---|---|---|
EbicsSecurityCode | nSecCode | The security operation for which the key shall be used. |
System.Int32 | nKeyLength | Byte length of the RSA keys to be generated. This must be in the range from MINKEYLENGTH to MAXKEYLENGTH. |
Returns
Type | Description |
---|---|
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.
Declaration
public byte[] GetPublicExponent()
Returns
Type | Description |
---|---|
System.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.
Declaration
public EbicsPubKeyInfo GetPublicKeyInfo()
Returns
Type | Description |
---|---|
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.
Declaration
public byte[] GetPublicModulus()
Returns
Type | Description |
---|---|
System.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.
Declaration
public static EbicsPrivKey ImportKeyBlob(EbicsDataBuffer dKeyBlob)
Parameters
Type | Name | Description |
---|---|---|
EbicsDataBuffer | dKeyBlob |
Returns
Type | Description |
---|---|
EbicsPrivKey |
See Also
SignHash(Byte[])
Declaration
public byte[] SignHash(byte[] vbHash)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vbHash |
Returns
Type | Description |
---|---|
System.Byte[] |
Remarks
This is a low level method that is not usually called by application code!