Class KeyManager

Definition

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

Provides methods for storing, retrieving, and creating keys.

C#
Copy
public class KeyManager : Manager
Inheritance
object
KeyManager

Methods

View Source

CreateAesKey(int, string, Policy)

Creates AES key and stores it inside the secure repository based on policy.

Declaration
C#
Copy
public static void CreateAesKey(int size, string keyAlias, Policy policy)
Parameters
Type Name Description
int size

Size of the key strength to be created.

string keyAlias

The name of key to be stored.

Policy policy

Key storing policy.

Remarks

128, 192 and 256 sizes are supported.

Exceptions
Type Condition
System.ArgumentNullException

Thrown when keyAlias or policy is null.

System.ArgumentException

Thrown when size is invalid. Thrown when keyAlias has an invalid format.

System.InvalidOperationException

Thrown when key with keyAlias already exists.

View Source

CreateDsaKeyPair(int, string, string, Policy, Policy)

Creates DSA private/public key pair and stores them inside the secure repository based on each policy.

Declaration
C#
Copy
public static void CreateDsaKeyPair(int size, string privateKeyAlias, string publicKeyAlias, Policy privateKeyPolicy, Policy publicKeyPolicy)
Parameters
Type Name Description
int size

Size of key strength to be created.

string privateKeyAlias

Name of a private key to be stored.

string publicKeyAlias

Name of a public key to be stored.

Policy privateKeyPolicy

Private key storing policy.

Policy publicKeyPolicy

Public key storing policy.

Remarks

1024, 2048, 3072, and 4096 sizes are supported.

Exceptions
Type Condition
System.ArgumentNullException

Thrown when any provided argument is null.

System.ArgumentException

Thrown when size is invalid. Thrown when privateKeyAlias or publicKeyAlias has an invalid format.

System.InvalidOperationException

Thrown when key with privateKeyAlias or publicKeyAlias already exists.

View Source

CreateEcdsaKeyPair(EllipticCurveType, string, string, Policy, Policy)

Creates ECDSA private/public key pair and stores them inside secure repository based on each policy.

Declaration
C#
Copy
public static void CreateEcdsaKeyPair(EllipticCurveType type, string privateKeyAlias, string publicKeyAlias, Policy privateKeyPolicy, Policy publicKeyPolicy)
Parameters
Type Name Description
EllipticCurveType type

Type of elliptic curve of ECDSA.

string privateKeyAlias

Name of private key to be stored.

string publicKeyAlias

Name of public key to be stored.

Policy privateKeyPolicy

Private key storing policy.

Policy publicKeyPolicy

Public key storing policy.

Remarks

If the password in policy is provided, the key is additionally encrypted with the password in policy.

Exceptions
Type Condition
System.ArgumentNullException

Thrown when any provided argument is null.

System.ArgumentException

Thrown when type is invalid. Thrown when privateKeyAlias or publicKeyAlias has an invalid format.

System.InvalidOperationException

Thrown when key with privateKeyAlias or publicKeyAlias already exists.

View Source

CreateRsaKeyPair(int, string, string, Policy, Policy)

Creates RSA private/public key pair and stores them inside the secure repository based on each policy.

Declaration
C#
Copy
public static void CreateRsaKeyPair(int size, string privateKeyAlias, string publicKeyAlias, Policy privateKeyPolicy, Policy publicKeyPolicy)
Parameters
Type Name Description
int size

Size of key strength to be created.

string privateKeyAlias

Name of a private key to be stored.

string publicKeyAlias

Name of a public key to be stored.

Policy privateKeyPolicy

Private key storing policy.

Policy publicKeyPolicy

Public key storing policy.

Remarks

1024, 2048, and 4096 sizes are supported.

Exceptions
Type Condition
System.ArgumentNullException

Thrown when any provided argument is null.

System.ArgumentException

Thrown when size is invalid. Thrown when privateKeyAlias or publicKeyAlias has an invalid format.

System.InvalidOperationException

Thrown when key with privateKeyAlias or publicKeyAlias already exists.

View Source

Get(string, string)

Gets a key from the secure repository.

Declaration
C#
Copy
public static Key Get(string alias, string password)
Parameters
Type Name Description
string alias

Name of a key to retrieve.

string password

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

Returns
Type Description
Key

Key specified by alias.

Exceptions
Type Condition
System.ArgumentNullException

Thrown when alias argument is null.

System.ArgumentException

Thrown when alias argument has an invalid format.

System.InvalidOperationException

Thrown when key does not exist with given alias or the key-protecting password does not match.

View Source

GetAliases()

Gets all aliases of keys accessible by the client.

Declaration
C#
Copy
public static IEnumerable<string> GetAliases()
Returns
Type Description
System.Collections.Generic.IEnumerable<T><string>

All aliases of keys accessible by the client.

Exceptions
Type Condition
System.ArgumentException

Thrown when there's no alias to get.

View Source

Save(string, Key, Policy)

Stores a key inside the secure repository based on the provided policy.

Declaration
C#
Copy
public static void Save(string alias, Key key, Policy policy)
Parameters
Type Name Description
string alias

Name of a key to be stored.

Key key

Key's binary value to be stored.

Policy policy

Key storing policy.

Remarks

Type in key may be set to KeyType. None as an input. Type is determined inside the secure repository during storing keys.

Exceptions
Type Condition
System.ArgumentNullException

Thrown when any provided argument is null.

System.ArgumentException

Thrown when alias or key argument has an invalid format.

System.InvalidOperationException

Thrown when key with given alias already exists.