Class KeyManager
Definition
- Namespace:
- Tizen.Security.SecureRepository
- Assembly:
- Tizen.Security.SecureRepository.dll
- API Level:
- 3
This class provides the methods for storing, retrieving, and creating keys.
C#Copypublic class KeyManager : Manager
- Inheritance
Methods
CreateAesKey(Int32, String, Policy)
Creates the AES key and stores it inside the secure repository based on each policy.
Declaration
C#Copypublic static void CreateAesKey(int size, string keyAlias, Policy policy)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | The size of the key strength to be created. 128, 192 and 256 are supported. |
System.String | keyAlias | The name of key to be stored. |
Policy | policy | The policy about how to store the key securely. |
Remarks
If the password in policy is provided, the key is additionally encrypted with the password in policy.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The keyAlias or policy is null. |
System.ArgumentException | The key size is invalid. keyAlias is in the invalid format. |
System.InvalidOperationException | The key with privateKeyAlias or publicKeyAlias does already exist. |
API Level: 3
CreateDsaKeyPair(Int32, String, String, Policy, Policy)
Creates the DSA private/public key pair and stores them inside the secure repository based on each policy.
Declaration
C#Copypublic static void CreateDsaKeyPair(int size, string privateKeyAlias, string publicKeyAlias, Policy privateKeyPolicy, Policy publicKeyPolicy)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | The size of key strength to be created. 1024, 2048, 3072, and 4096 are supported. |
System.String | privateKeyAlias | The name of private key to be stored. |
System.String | publicKeyAlias | The name of public key to be stored. |
Policy | privateKeyPolicy | The policy about how to store a private key securely. |
Policy | publicKeyPolicy | The policy about how to store a public key securely. |
Remarks
If the password in policy is provided, the key is additionally encrypted with the password in policy.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Any of argument is null. |
System.ArgumentException | The size is invalid. privateKeyAlias or publicKeyAlias is invalid format. |
System.InvalidOperationException | The key with privateKeyAlias or publicKeyAlias does already exist. |
API Level: 3
CreateEcdsaKeyPair(EllipticCurveType, String, String, Policy, Policy)
Creates the ECDSA private/public key pair and stores them inside secure repository based on each policy.
Declaration
C#Copypublic static void CreateEcdsaKeyPair(EllipticCurveType type, string privateKeyAlias, string publicKeyAlias, Policy privateKeyPolicy, Policy publicKeyPolicy)
Parameters
Type | Name | Description |
---|---|---|
EllipticCurveType | type | The type of elliptic curve of ECDSA. |
System.String | privateKeyAlias | The name of private key to be stored. |
System.String | publicKeyAlias | The name of public key to be stored. |
Policy | privateKeyPolicy | The policy about how to store a private key securely. |
Policy | publicKeyPolicy | The policy about how to store a public key securely. |
Remarks
If the password in policy is provided, the key is additionally encrypted with the password in policy.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Any of argument is null. |
System.ArgumentException | The elliptic curve type is invalid. privateKeyAlias or publicKeyAlias is in the invalid format. |
System.InvalidOperationException | The key with privateKeyAlias or publicKeyAlias does already exist. |
API Level: 3
CreateRsaKeyPair(Int32, String, String, Policy, Policy)
Creates the RSA private/public key pair and stores them inside the secure repository based on each policy.
Declaration
C#Copypublic static void CreateRsaKeyPair(int size, string privateKeyAlias, string publicKeyAlias, Policy privateKeyPolicy, Policy publicKeyPolicy)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | The size of key strength to be created. 1024, 2048, and 4096 are supported. |
System.String | privateKeyAlias | The name of private key to be stored. |
System.String | publicKeyAlias | The name of public key to be stored. |
Policy | privateKeyPolicy | The policy about how to store a private key securely. |
Policy | publicKeyPolicy | The policy about how to store a public key securely. |
Remarks
If the password in policy is provided, the key is additionally encrypted with the password in policy.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Any of argument is null. |
System.ArgumentException | The size is invalid. privateKeyAlias or publicKeyAlias is invalid format. |
System.InvalidOperationException | The key with privateKeyAlias or publicKeyAlias does already exist. |
API Level: 3
Declaration
C#Copypublic static Key Get(string alias, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | The name of a key to retrieve. |
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. |
Returns
Type | Description |
---|---|
Key | A key specified by alias. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The alias argument is null. |
System.ArgumentException | The alias argument is in the invalid format. |
System.InvalidOperationException | The key does not exist with the alias or the key-protecting password isn't matched. |
API Level: 3
Declaration
C#Copypublic static IEnumerable<string> GetAliases()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | All aliases of keys, which the client can access. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | No alias to get. |
API Level: 3
Save(String, Key, Policy)
Stores a key inside the secure repository based on the provided policy.
Declaration
C#Copypublic static void Save(string alias, Key key, Policy policy)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | The name of a key to be stored. |
Key | key | The key's binary value to be stored. |
Policy | policy | The policy about how to store a key securely. |
Remarks
The type in key may be set to KeyType.None as an input. The type is determined inside the secure reposioty during storing keys.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Any of argument is null. |
System.ArgumentException | The alias argument is in the invalid format. key argument is in the invalid format. |
System.InvalidOperationException | The key with alias does already exist. |