Class Cipher
Definition
- Namespace:
- Tizen.Security.SecureRepository.Crypto
- Assembly:
- Tizen.Security.SecureRepository.dll
- API Level:
- 3
This class provides the methods for encrypting and decrypting data.
C#Copypublic class Cipher
- Inheritance
-
Cipher
Constructors
Cipher(CipherParameters)
A constructor of Cipher that takes the algorithm specific parameters.
Declaration
C#Copypublic Cipher(CipherParameters parameters)
Parameters
Type | Name | Description |
---|---|---|
CipherParameters | parameters | The algorithm specific parameters. |
API Level: 3
Properties
Declaration
C#Copypublic CipherParameters Parameters { get; }
Property Value
Type | Description |
---|---|
CipherParameters |
API Level: 3
Methods
Declaration
C#Copypublic byte[] Decrypt(string keyAlias, string password, byte[] cipherText)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyAlias | Alias of the key to be used for decryption. |
System.String | password | The password used in decrypting a key value. If password of policy is provided in SaveKey(), the same password should be provided. |
System.Byte[] | cipherText | Data to be decrypted (some algorithms may require additional information embedded in encrypted data.AES GCM is an example). |
Returns
Type | Description |
---|---|
System.Byte[] | Decrypted data. |
Remarks
The key type specified by keyAlias should be compatible with the algorithm specified in Parameters.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The keyAlias or cipherText is null. |
System.ArgumentException | The mandatory algorithm parameter is missing or invalid. The optional algorithm parameter is invalid. |
InvalidOperationException | The key-protecting password isn't matched. The key does not exist with the keyAlias. |
API Level: 3
Declaration
C#Copypublic byte[] Encrypt(string keyAlias, string password, byte[] plainText)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyAlias | Alias of the key to be used for encryption. |
System.String | password | The password used in decrypting a key value. If password of policy is provided in SaveKey(), the same password should be provided. |
System.Byte[] | plainText | Data to be encrypted. In case of the AES algorithm, there are no restrictions on the size of data. For RSA, the size must be smaller or equal to (key_size_in bytes - 42). Example: For 1024 RSA key, the maximum data size is 1024/8 - 42 = 86. |
Returns
Type | Description |
---|---|
System.Byte[] | Encrypted data. |
Remarks
The key type specified by the keyAlias should be compatible with the algorithm specified in Parameters.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The keyAlias or plainText is null. |
System.ArgumentException | The mandatory algorithm parameter is missing or invalid. The optional algorithm parameter is invalid. |
InvalidOperationException | The key-protecting password isn't matched. The key does not exist with the keyAlias. |