Show / Hide Table of Contents

Class KeyChain

A secure key chain.

Inheritance
Object
KeyChain
Implements
IKeyApi
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Ipfs.Engine.Cryptography
Assembly: Ipfs.Engine.dll
Syntax
public class KeyChain : IKeyApi

Constructors

| Improve this Doc View Source

KeyChain(IpfsEngine)

Create a new instance of the KeyChain class.

Declaration
public KeyChain(IpfsEngine ipfs)
Parameters
Type Name Description
IpfsEngine ipfs

The IPFS Engine associated with the key chain.

Properties

| Improve this Doc View Source

Options

The configuration options.

Declaration
public KeyChainOptions Options { get; set; }
Property Value
Type Description
KeyChainOptions

Methods

| Improve this Doc View Source

CreateAsync(String, String, Int32, CancellationToken)

Declaration
public Task<IKey> CreateAsync(string name, string keyType, int size, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name
String keyType
Int32 size
CancellationToken cancel
Returns
Type Description
Task<IKey>
| Improve this Doc View Source

CreateBCCertificateAsync(String, CancellationToken)

Create a X509 certificate for the specified key.

Declaration
public Task<X509Certificate> CreateBCCertificateAsync(string keyName, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String keyName

The key name.

CancellationToken cancel
Returns
Type Description
Task<Org.BouncyCastle.X509.X509Certificate>
| Improve this Doc View Source

CreateCertificateAsync(String, CancellationToken)

Create a X509 certificate for the specified key.

Declaration
public Task<byte[]> CreateCertificateAsync(string keyName, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String keyName

The key name.

CancellationToken cancel
Returns
Type Description
Task<Byte[]>
| Improve this Doc View Source

CreateProtectedDataAsync(String, Byte[], CancellationToken)

Encrypt data as CMS protected data.

Declaration
public Task<byte[]> CreateProtectedDataAsync(string keyName, byte[] plainText, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String keyName

The key name to protect the plainText with.

Byte[] plainText

The data to protect.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<Byte[]>

A task that represents the asynchronous operation. The task's result is the cipher text of the plainText.

Remarks

Cryptographic Message Syntax (CMS), aka PKCS #7 and RFC 5652, describes an encapsulation syntax for data protection. It is used to digitally sign, digest, authenticate, and/or encrypt arbitrary message content.

| Improve this Doc View Source

ExportAsync(String, Char[], CancellationToken)

Declaration
public Task<string> ExportAsync(string name, char[] password, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name
Char[] password
CancellationToken cancel
Returns
Type Description
Task<String>
| Improve this Doc View Source

FindKeyByNameAsync(String, CancellationToken)

Find a key by its name.

Declaration
public Task<IKey> FindKeyByNameAsync(string name, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name

The local name of the key.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<IKey>

A task that represents the asynchronous operation. The task's result is an IKey or null if the the key is not defined.

| Improve this Doc View Source

GetPrivateKeyAsync(String, CancellationToken)

Gets the Bouncy Castle representation of the private key.

Declaration
public Task<AsymmetricKeyParameter> GetPrivateKeyAsync(string name, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name

The local name of key.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<Org.BouncyCastle.Crypto.AsymmetricKeyParameter>

A task that represents the asynchronous operation. The task's result is the private key as an AsymmetricKeyParameter.

| Improve this Doc View Source

GetPublicKeyAsync(String, CancellationToken)

Gets the IPFS encoded public key for the specified key.

Declaration
public Task<string> GetPublicKeyAsync(string name, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name

The local name of the key.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<String>

A task that represents the asynchronous operation. The task's result is the IPFS encoded public key.

Remarks

The IPFS public key is the base-64 encoding of a protobuf encoding containing a type and the DER encoding of the PKCS Subject Public Key Info.

See Also
https://tools.ietf.org/html/rfc5280#section-4.1.2.7
| Improve this Doc View Source

ImportAsync(String, String, Char[], CancellationToken)

Declaration
public Task<IKey> ImportAsync(string name, string pem, char[] password = null, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name
String pem
Char[] password
CancellationToken cancel
Returns
Type Description
Task<IKey>
| Improve this Doc View Source

ListAsync(CancellationToken)

Declaration
public Task<IEnumerable<IKey>> ListAsync(CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
CancellationToken cancel
Returns
Type Description
Task<IEnumerable<IKey>>
| Improve this Doc View Source

ReadProtectedDataAsync(Byte[], CancellationToken)

Decrypt CMS protected data.

Declaration
public Task<byte[]> ReadProtectedDataAsync(byte[] cipherText, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
Byte[] cipherText

The protected CMS data.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<Byte[]>

A task that represents the asynchronous operation. The task's result is the plain text byte array of the protected data.

Remarks

Cryptographic Message Syntax (CMS), aka PKCS #7 and RFC 5652, describes an encapsulation syntax for data protection. It is used to digitally sign, digest, authenticate, and/or encrypt arbitrary message content.

Exceptions
Type Condition
KeyNotFoundException

When the required private key, to decrypt the data, is not foumd.

| Improve this Doc View Source

RemoveAsync(String, CancellationToken)

Declaration
public Task<IKey> RemoveAsync(string name, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name
CancellationToken cancel
Returns
Type Description
Task<IKey>
| Improve this Doc View Source

RenameAsync(String, String, CancellationToken)

Declaration
public Task<IKey> RenameAsync(string oldName, string newName, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String oldName
String newName
CancellationToken cancel
Returns
Type Description
Task<IKey>
| Improve this Doc View Source

SetPassphraseAsync(SecureString, CancellationToken)

Sets the passphrase for the key chain.

Declaration
public Task SetPassphraseAsync(SecureString passphrase, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
SecureString passphrase
CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task

A task that represents the asynchronous operation.

Remarks

The passphrase is used to generate a DEK (derived encryption key). The DEK is then used to encrypt the stored keys.

Neither the passphrase nor the DEK are stored.

Exceptions
Type Condition
UnauthorizedAccessException

When the passphrase is wrong.

Implements

IKeyApi
  • Improve this Doc
  • View Source
Back to top Generated by DocFX