Ixian SDK
DLT.ICryptoLib Interface Reference

Interface for implementing different cryptographic libraries. More...

Inheritance diagram for DLT.ICryptoLib:
CryptoLibs.BouncyCastle

Public Member Functions

IxianKeyPair generateKeys (int keySize, bool skip_header=false)
 Generates a new pair of RSA private and public keys. More...
 
byte [] getSignature (byte[] input, byte[] privateKey)
 Generates a cryptographic signature for the input data, using the provided private key in the Ixian serialized format. See the class IxianKeyPair and the function generateKeys() for information about how to obtain a serialized RSA key. More...
 
bool verifySignature (byte[] input, byte[] publicKey, byte[] signature)
 Verifies that the given signature correctly signs the data with the given public key. See the class IxianKeyPair and the function generateKeys() for information about how to obtain a serialized RSA key. The signature should be one which has been calculated with the getSignature() function. More...
 
byte [] encryptWithRSA (byte[] input, byte[] publicKey)
 Encrypts the data using RSA cryptography and using the provided public key in the Ixian serialized format. See the class IxianKeyPair and the function generateKeys() for information about how to obtain a serialized RSA key. More...
 
byte [] decryptWithRSA (byte[] input, byte[] privateKey)
 Decrypts the data using RSA cryptography and using the provided private key in the Ixian serialized format. See the class IxianKeyPair and the function generateKeys() for information about how to obtain a serialized RSA key. The encrypted data should be the value returned from encryptWithRSA() function. More...
 
byte [] encryptDataAES (byte[] input, byte[] key)
 Encrpyts the provided data with a variant of the AES algorithm and using the provided symmetrical encryption key. More...
 
byte [] decryptDataAES (byte[] input, byte[] key, int offset=0)
 Decrypts the provided block of data with a variant of the AES algorithm and using the provided symmetrical encryption key. More...
 
byte [] encryptWithPassword (byte[] data, string password)
 Encrypts the provided data with the given password. This function uses encryptDataAES() as the internal encryption primitive, but abstracts away some of the detail around key and salt generation. More...
 
byte [] decryptWithPassword (byte[] data, string password)
 Encrypts the provided data with the given password. This function uses decryptDataAES() as the internal encryption primitive, but abstracts away some of the detail around key and salt processing. More...
 
byte [] encryptWithChacha (byte[] input, byte[] key)
 Encrypts the provided data with the given password. This function uses Bouncy Castle's 'ChaCha' method as the internal encryption primitive, but abstracts away some of the detail around key processing. More...
 
byte [] decryptWithChacha (byte[] input, byte[] key)
 Decrypts the provided data with the given password. This function uses Bouncy Castle's 'ChaCha' method as the internal encryption primitive, but abstracts away some of the detail around key processing. More...
 
byte [] generateChildKey (byte[] parentKey, int seed=0)
 Generates a child RSA key from the given parent RSA key, so that the process may be repeated in the future. This function allows for RSA key derivation and hirearchical keys. Using a different seed value will yield different child keys, but the process can be repeated if the seed values are known. More...
 
bool testKeys (byte[] sample, IxianKeyPair kp)
 Verifies that the provided Ixian key pair are valid, working RSA keys. Both encryption and signing are tested and the resulting values are then decrypted and verified to ensure that the process is reversible. More...
 

Detailed Description

Interface for implementing different cryptographic libraries.

Definition at line 36 of file CryptoLib.cs.

Member Function Documentation

◆ decryptDataAES()

byte [] DLT.ICryptoLib.decryptDataAES ( byte []  input,
byte []  key,
int  offset = 0 
)

Decrypts the provided block of data with a variant of the AES algorithm and using the provided symmetrical encryption key.

This function mirrors encryptDataAES(), so the input data should also contain the random salt value used in encryption. The function allows processing encrypted data from a larger byte buffer by specifying the offset at which the data starts. For most use cases, offset should be set to 0.

Parameters
inputCiphertext data to decrypt
keyDecryption key.
offsetOffset of the encrypted data in the byte-field. This is usually 0.
Returns

Implemented in CryptoLibs.BouncyCastle.

◆ decryptWithChacha()

byte [] DLT.ICryptoLib.decryptWithChacha ( byte []  input,
byte []  key 
)

Decrypts the provided data with the given password. This function uses Bouncy Castle's 'ChaCha' method as the internal encryption primitive, but abstracts away some of the detail around key processing.

Parameters
dataCiphertext data.
passwordDecryption password.
Returns
Cleartext data.

Implemented in CryptoLibs.BouncyCastle.

◆ decryptWithPassword()

byte [] DLT.ICryptoLib.decryptWithPassword ( byte []  data,
string  password 
)

Encrypts the provided data with the given password. This function uses decryptDataAES() as the internal encryption primitive, but abstracts away some of the detail around key and salt processing.

In order to obtain a good encryption key from the password, PBKDF2 from RFC 2898 is used. This function is the inverse of encryptWithPassword(), so it can only process Ciphertext generated by that function.

Parameters
dataCiphertext data.
passwordEncryption password.
Returns
Cleartext data.

Implemented in CryptoLibs.BouncyCastle.

◆ decryptWithRSA()

byte [] DLT.ICryptoLib.decryptWithRSA ( byte []  input,
byte []  privateKey 
)

Decrypts the data using RSA cryptography and using the provided private key in the Ixian serialized format. See the class IxianKeyPair and the function generateKeys() for information about how to obtain a serialized RSA key. The encrypted data should be the value returned from encryptWithRSA() function.

Parameters
inputCiphertext data to decrypt.
privateKeyRSA private key in the Ixian serialized format.
Returns
Decrypted data (Cleartext), using RSA cryptography.

Implemented in CryptoLibs.BouncyCastle.

◆ encryptDataAES()

byte [] DLT.ICryptoLib.encryptDataAES ( byte []  input,
byte []  key 
)

Encrpyts the provided data with a variant of the AES algorithm and using the provided symmetrical encryption key.

For best results, the key should be as random as possible. The function also generates a random salt value to increase the security of encryption. Because the salt value is needed for decryption, it is returned together with the ciphertext. The exact algorithm used for encryption is "AES/CBC/PKCS7Padding"

Parameters
inputCleartext data.
keyEncryption key.
Returns
AES-Encrypted data (Ciphertext) and the random salt value used in encryption.

Implemented in CryptoLibs.BouncyCastle.

◆ encryptWithChacha()

byte [] DLT.ICryptoLib.encryptWithChacha ( byte []  input,
byte []  key 
)

Encrypts the provided data with the given password. This function uses Bouncy Castle's 'ChaCha' method as the internal encryption primitive, but abstracts away some of the detail around key processing.

Parameters
dataCleartext data.
passwordEncryption password.
Returns
Ciphertext data.

Implemented in CryptoLibs.BouncyCastle.

◆ encryptWithPassword()

byte [] DLT.ICryptoLib.encryptWithPassword ( byte []  data,
string  password 
)

Encrypts the provided data with the given password. This function uses encryptDataAES() as the internal encryption primitive, but abstracts away some of the detail around key and salt generation.

In order to obtain a good encryption key from the password, PBKDF2 from RFC 2898 is used. Since the function also generates a random encryption salt, the returned byte-field also includes this salt value.

Parameters
dataCleartext data.
passwordEncryption password.
Returns
Ciphertext data with a random salt value.

Implemented in CryptoLibs.BouncyCastle.

◆ encryptWithRSA()

byte [] DLT.ICryptoLib.encryptWithRSA ( byte []  input,
byte []  publicKey 
)

Encrypts the data using RSA cryptography and using the provided public key in the Ixian serialized format. See the class IxianKeyPair and the function generateKeys() for information about how to obtain a serialized RSA key.

Parameters
inputCleartext data to encrypt.
publicKeyRSA public key in the Ixian serialized format.
Returns
Encrypted data (Ciphertext), using RSA cryptography.

Implemented in CryptoLibs.BouncyCastle.

◆ generateChildKey()

byte [] DLT.ICryptoLib.generateChildKey ( byte []  parentKey,
int  seed = 0 
)

Generates a child RSA key from the given parent RSA key, so that the process may be repeated in the future. This function allows for RSA key derivation and hirearchical keys. Using a different seed value will yield different child keys, but the process can be repeated if the seed values are known.

Parameters
parentKeyRSA private key in Ixian serialized format.
seedA unique seed value.
Returns
A new RSA key in Ixian serialized format.

Implemented in CryptoLibs.BouncyCastle.

◆ generateKeys()

IxianKeyPair DLT.ICryptoLib.generateKeys ( int  keySize,
bool  skip_header = false 
)

Generates a new pair of RSA private and public keys.

The serialized key format has changed slightly and the parameter skip_header is used to denote older Ixian keys which did not include version information. It is recommended that the parameter is left on its default value false when using this function, unless you have a very specific need togenerate older Ixian keys.

Parameters
keySizeSize of the new RSA key, in bits.
skip_headerLegacy parameter to allow generating older Ixian keys.
Returns
A new RSA key pair and associated Ixian data.

Implemented in CryptoLibs.BouncyCastle.

◆ getSignature()

byte [] DLT.ICryptoLib.getSignature ( byte []  input,
byte []  privateKey 
)

Generates a cryptographic signature for the input data, using the provided private key in the Ixian serialized format. See the class IxianKeyPair and the function generateKeys() for information about how to obtain a serialized RSA key.

Parameters
inputData which should be signed.
privateKeyPrivate key for signing the data in Ixian serialized format.
Returns
Signature of the given data with the given key in a byte-field format.

Implemented in CryptoLibs.BouncyCastle.

◆ testKeys()

bool DLT.ICryptoLib.testKeys ( byte []  sample,
IxianKeyPair  kp 
)

Verifies that the provided Ixian key pair are valid, working RSA keys. Both encryption and signing are tested and the resulting values are then decrypted and verified to ensure that the process is reversible.

Parameters
sampleSample data, used for testing the keys (Cleartext).
kpIxian RSA key pair to be tested.
Returns
True, if the keys are able to successfully encrypt and sign data.

Implemented in CryptoLibs.BouncyCastle.

◆ verifySignature()

bool DLT.ICryptoLib.verifySignature ( byte []  input,
byte []  publicKey,
byte []  signature 
)

Verifies that the given signature correctly signs the data with the given public key. See the class IxianKeyPair and the function generateKeys() for information about how to obtain a serialized RSA key. The signature should be one which has been calculated with the getSignature() function.

Parameters
inputData which has been signed using the public key's corresponding private key.
publicKeyPublic key against which the signature should be tested.
signatureSignature, as given by getSignature().
Returns
True, if the signature matches the data and has been generated from the correct private RSA key.

Implemented in CryptoLibs.BouncyCastle.


The documentation for this interface was generated from the following file: