Codeunit RSA
Performs asymmetric encryption and digital signature using the implementation of the RSA class.
Properties
Name | Value |
---|---|
Access | Public |
InherentEntitlements | X |
InherentPermissions | X |
Methods
InitializeRSA
Initializes a new instance of RSA with the specified key size.
procedure InitializeRSA(KeySize: Integer)
Parameters
Name | Type | Description |
---|---|---|
KeySize | Integer |
The size of the key in bits. |
ToSecretXmlString
Creates and returns an XML string containing the key of the current RSA object.
procedure ToSecretXmlString(IncludePrivateParameters: Boolean): SecretText
Parameters
Name | Type | Description |
---|---|---|
IncludePrivateParameters | Boolean |
true to include a public and private RSA key; false to include only the public key. |
Returns
Type | Description |
---|---|
SecretText |
An XML string containing the key of the current RSA object. |
SignData
Computes the hash value of the specified data and signs it.
procedure SignData(XmlString: SecretText, DataInStream: InStream, HashAlgorithm: Enum "Hash Algorithm", RSASignaturePadding: Enum "RSA Signature Padding", SignatureOutStream: OutStream)
Parameters
Name | Type | Description |
---|---|---|
XmlString | SecretText |
The XML string containing RSA key information. |
DataInStream | InStream |
The input stream to hash and sign. |
HashAlgorithm | System.Security.Encryption."Hash Algorithm" |
The hash algorithm to use to create the hash value. |
RSASignaturePadding | System.Security.Encryption."RSA Signature Padding" |
The padding mode to use for the RSA signature. |
SignatureOutStream | OutStream |
The RSA signature stream for the specified data. |
VerifyData
Verifies that a digital signature is valid by determining the hash value in the signature using the provided public key and comparing it to the hash value of the provided data.
procedure VerifyData(XmlString: SecretText, DataInStream: InStream, HashAlgorithm: Enum "Hash Algorithm", RSASignaturePadding: Enum "RSA Signature Padding", SignatureInStream: InStream): Boolean
Parameters
Name | Type | Description |
---|---|---|
XmlString | SecretText |
The XML string containing RSA key information. |
DataInStream | InStream |
The input stream of data that was signed. |
HashAlgorithm | System.Security.Encryption."Hash Algorithm" |
The name of the hash algorithm used to create the hash value of the data. |
RSASignaturePadding | System.Security.Encryption."RSA Signature Padding" |
The padding mode to use for the RSA signature. |
SignatureInStream | InStream |
The stream of signature data to be verified. |
Returns
Type | Description |
---|---|
Boolean |
True if the signature is valid; otherwise, false. |
Encrypt
Encrypts the specified text with the RSA algorithm.
procedure Encrypt(XmlString: SecretText, PlainTextInStream: InStream, OaepPadding: Boolean, EncryptedTextOutStream: OutStream)
Parameters
Name | Type | Description |
---|---|---|
XmlString | SecretText |
The XML string containing RSA key information. |
PlainTextInStream | InStream |
The input stream to encrypt. |
OaepPadding | Boolean |
True to perform RSA encryption using OAEP padding; otherwise, false to use PKCS#1 padding. |
EncryptedTextOutStream | OutStream |
The RSA encryption stream for the specified text. |
Decrypt
Decrypts the specified text that was previously encrypted with the RSA algorithm.
procedure Decrypt(XmlString: SecretText, EncryptedTextInStream: InStream, OaepPadding: Boolean, DecryptedTextOutStream: OutStream)
Parameters
Name | Type | Description |
---|---|---|
XmlString | SecretText |
The XML string containing RSA key information. |
EncryptedTextInStream | InStream |
The input stream to decrypt. |
OaepPadding | Boolean |
true to perform RSA encryption using OAEP padding; otherwise, false to use PKCS#1 padding. |
DecryptedTextOutStream | OutStream |
The RSA decryption stream for the specified text. |