Class EbicsPubKeyInfo
A public RSA key.
public class EbicsPubKeyInfo : EbicsElement, IEbicsJsonConverter
- Inheritance
-
EbicsPubKeyInfo
- Implements
- Inherited Members
- Extension Methods
Properties
Exponent
The common exponent
public EbicsDataBuffer Exponent { get; set; }
Property Value
Modulus
The public modulus.
public EbicsDataBuffer Modulus { get; set; }
Property Value
ModulusBitLength
The number of significant bits in the Modulus.
public int ModulusBitLength { get; }
Property Value
PubKeyDigestAlgorithm
public string PubKeyDigestAlgorithm { get; }
Property Value
TimeStamp
Optional time of key generation.
public DateTime TimeStamp { get; set; }
Property Value
- DateTime
The value DateTime.MinValue indicates that no date is set.
Remarks
This corresponds to the XML element ebics:TimeStamp.
Version
The security operation and version.
public EbicsSecurityCode Version { get; set; }
Property Value
Remarks
This corresponds to (and actually selects) one of the XML elements ebics:AuthenticationVersion, ebics:SignatureVersion, or ebics:EncryptionVersion.
X509Certificate
The X.509 certificate for this key. This is optional before EBICS 3.0, and mandatory starting with EBICS 3.0. It is always needed for French EBICS implementations.
public EbicsDataBuffer X509Certificate { get; set; }
Property Value
Remarks
If no certificate was issued for the user keys, then a self-signed certificate can be used by calling CreateSelfSignedCertificate(EbicsPrivKey, string) before submitting user keys.
Just parsing the EbicsPubKeyInfo does not validate the authority signature of this certificate.
- See Also
Methods
BuildPubKeyDigest(string, bool)
Builds a public key digest element.
public EbicsPubKeyDigest BuildPubKeyDigest(string sRootTag, bool fFromCertificate)
Parameters
sRootTag
stringThe root tag to be used for the returned element. This is usually one of "EncryptionPubKeyDigest", "Authentication", or "Encryption".
fFromCertificate
bool
Returns
Remarks
The returned element has a "Version" and an "Algorithm" attribute. The value of these attributes are derived from the Version of this public key.
BuildXml(XmlDocument, EbicsVersion)
public override XmlElement BuildXml(XmlDocument xmlDocument, EbicsVersion nVersion)
Parameters
xmlDocument
XmlDocumentnVersion
EbicsVersionThe EBICS version for which to build the XML element.
Returns
Remarks
This creates an XML element with the root node SignaturePubKeyInfo, AuthenticationPubKeyInfo, or EncryptionPubKeyInfo, depending on the current value of the Version property.
CheckCertificateSignature(EbicsPubKeyInfo)
Check the authority signature of the X509Certificate.
public bool CheckCertificateSignature(EbicsPubKeyInfo aAuthPubKey)
Parameters
aAuthPubKey
EbicsPubKeyInfoThe public key of the authority to check the certificate signature with. For a self signed certificate this can be provided as
this
. This must not benull
.
Returns
- bool
If the authority signature of the X509Certificate was successfully verfified with the given public key, then
true
is returned. If the signature is invalid, thenfalse
is returned.
Exceptions
- ArgumentNullException
The parameter
aAuthPubKey
wasnull
.- InvalidOperationException
The X509Certificate property was
null
.
CreatePubKeyInfo(JsonObject)
public static EbicsPubKeyInfo CreatePubKeyInfo(JsonObject jsonObject)
Parameters
jsonObject
JsonObject
Returns
CreateSelfSignedCertificate(EbicsPrivKey, string)
public void CreateSelfSignedCertificate(EbicsPrivKey aPrivKey, string sCommonName)
Parameters
aPrivKey
EbicsPrivKeyA private key for signing the certificate. This key must match the public Modulus and Exponent of this instance.
sCommonName
stringPreferably the caller should use the UserID as the common name of the certificate subject. If this is
null
, then the constant "EBICS" will be used.
Encrypt(byte[])
Encrypt a symmetric transaction key with this RSA key.
public byte[] Encrypt(byte[] vbInput)
Parameters
vbInput
byte[]The symmetric transaction key to be encrypted.
Returns
- byte[]
Remarks
This is a low level method that is not usually called by application code!
FromJson(JsonObject)
Initializes an EbicsPubKeyInfo-object from its json representation. FromJson(JsonObject).
public void FromJson(JsonObject jsonObject)
Parameters
jsonObject
JsonObject
GetFingerprint(bool)
Computes the fingerprint hash value for the printed Ini Letter. This is the same than calling GetPubKeyDigest(bool).
public byte[] GetFingerprint(bool fFromCertificate)
Parameters
fFromCertificate
boolFor EBICS 3.0 or French EBICS systems, this must be
true
in order to create a fingerprint based on the certificate instead of the public key data.
Returns
- byte[]
- See Also
GetPubKeyDigest(bool)
Computes the official digest value for this public key.
public EbicsDataBuffer GetPubKeyDigest(bool fFromCertificate)
Parameters
fFromCertificate
boolFor EBICS 3.0 or French EBICS systems, this must be
true
in order to create a digest based on the certificate instead of the public key data.
Returns
Remarks
There was some confusion on how the public bank key digest shall be computed in EBICS 3.0. In the original EBICS 3.0 specification it was not defined, hence many systems did use the old EBICS 2.5 method of computing it. Since EBICS 3.0.1 it is now explicitly specified, that the digest shall be computed over the certificate data and not the key data. For this reasons most, but not all, EBICS servers accept both digest values. The EbicsTransaction builds the public bank key digest based on the value of UsesCertificates.
Exceptions
- See Also
ParseXml(XmlElement, EbicsVersion)
public override void ParseXml(XmlElement xmlElement, EbicsVersion nVersion)
Parameters
xmlElement
XmlElementnVersion
EbicsVersion
ToJson(JsonObject)
Converts an EbicsPubKeyInfo-object to its json representation. ToJson(JsonObject).
public JsonObject ToJson(JsonObject jsonObject)
Parameters
jsonObject
JsonObject
Returns
ValidateKeys()
Checks whether the RSA keys lengths match the required key lengths according to the Version.
public bool ValidateKeys()
Returns
- bool
If an existing security version was chosen and both key parts are present and have the correct length, then
true
is returned. In any other casefalse
is returned.
Verify(byte[], byte[])
Verify a signature with this key.
public bool Verify(byte[] vbSignature, byte[] vbHash)
Parameters
vbSignature
byte[]The raw RSA signature value as a byte array in big endian order.
vbHash
byte[]The raw computed hash value as a byte array.
Returns
Remarks
This is a low level method that is not usually called by application code!