Class Cipher

    Definition

    Namespace:
    Tizen.Security.SecureRepository.Crypto
    Assembly:
    Tizen.Security.SecureRepository.dll

    This class provides the methods for encrypting and decrypting data.

    public class Cipher
    Inheritance
    object
    Cipher

    Constructors

    View Source

    Cipher(CipherParameters)

    A constructor of Cipher that takes the algorithm specific parameters.

    Declaration
    public Cipher(CipherParameters parameters)
    Parameters
    Type Name Description
    CipherParameters parameters

    The algorithm specific parameters.

    Properties

    View Source

    Parameters

    The algorithm specific parameters.

    Declaration
    public CipherParameters Parameters { get; }
    Property Value
    Type Description
    CipherParameters

    Methods

    View Source

    Decrypt(string, string, byte[])

    Decrypts data using the selected key and the algorithm.

    Declaration
    public byte[] Decrypt(string keyAlias, string password, byte[] cipherText)
    Parameters
    Type Name Description
    string keyAlias

    Alias of the key to be used for decryption.

    string password

    The password used in decrypting a key value. If password of policy is provided in SaveKey(), the same password should be provided.

    byte[] cipherText

    Data to be decrypted (some algorithms may require additional information embedded in encrypted data.AES GCM is an example).

    Returns
    Type Description
    byte[]

    Decrypted data.

    Remarks

    The key type specified by keyAlias should be compatible with the algorithm specified in Parameters.

    Exceptions
    Type Condition
    System.ArgumentNullException

    The keyAlias or cipherText is null.

    System.ArgumentException

    The mandatory algorithm parameter is missing or invalid. The optional algorithm parameter is invalid.

    System.InvalidOperationException

    The key-protecting password isn't matched. The key does not exist with the keyAlias.

    View Source

    Encrypt(string, string, byte[])

    Encrypts data using selected key and algorithm.

    Declaration
    public byte[] Encrypt(string keyAlias, string password, byte[] plainText)
    Parameters
    Type Name Description
    string keyAlias

    Alias of the key to be used for encryption.

    string password

    The password used in decrypting a key value. If password of policy is provided in SaveKey(), the same password should be provided.

    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
    byte[]

    Encrypted data.

    Remarks

    The key type specified by the keyAlias should be compatible with the algorithm specified in Parameters.

    Exceptions
    Type Condition
    System.ArgumentNullException

    The keyAlias or plainText is null.

    System.ArgumentException

    The mandatory algorithm parameter is missing or invalid. The optional algorithm parameter is invalid.

    System.InvalidOperationException

    The key-protecting password isn't matched. The key does not exist with the keyAlias.

    • View Source
    Back to top Copyright © 2016-2024 Samsung
    Generated by DocFX