@blockchaincommons/components - v1.0.0-beta.4
    Preparing search index...

    Class EncryptedKey

    Encrypted key providing secure storage of symmetric keys.

    Use lock() to encrypt a content key with a password or secret, and unlock() to decrypt it. SSH-agent parameters need an SshAgent: lockWithAgent() and unlockWithAgent().

    Implements

    • ToCbor
    • ToUR
    Index
    • Lock (encrypt) a content key with an SSH agent, the asynchronous route for SSH-agent parameters: SSHAgentParams.lock with options, so the secret is the comment of the agent identity to use (empty for the only one) and options.agent signs the salt.

      The other methods need no agent and take no nonce, so they have no asynchronous route: use lockOpt() for them.

      Parameters

      • params: KeyDerivationParams

        SSH-agent parameters; id is set from the secret

      • secret: Uint8Array

        The identity's comment as UTF-8

      • contentKey: SymmetricKey

        The symmetric key to encrypt

      • options: SshAgentLockOptions

        The agent, and the nonce to use instead of a random one

      Returns Promise<EncryptedKey>

      The encrypted key

      InvalidData when params are not SSH-agent parameters; the SshAgent failures of SSHAgentParams.lock

    • Check if this uses SSH Agent for key derivation.

      Such a key is unlocked with unlockWithAgent(), which needs an SshAgent.

      Returns boolean

    • Unlock (decrypt) the content key.

      Parameters

      • secret: Uint8Array

        The secret (password or key material) used to lock

      Returns SymmetricKey

      The decrypted symmetric key

      ComponentsError if decryption fails (wrong password, tampered data, etc.)

    • Unlock (decrypt) the content key with an SSH agent: for SSH-agent parameters SSHAgentParams.unlock with options, where the secret is the comment of the agent identity to use, or empty for the stored id or else the first identity; for every other method the same as unlock(secret), the agent unused.

      Parameters

      • secret: Uint8Array

        The identity's comment as UTF-8, or the secret used to lock

      • options: SshAgentUnlockOptions

        The agent that signs the salt

      Returns Promise<SymmetricKey>

      The decrypted symmetric key

      as unlock; the SshAgent and Crypto failures of SSHAgentParams.unlock

    • Returns the untagged CBOR encoding. The EncryptedMessage is encoded with its own tag (40002).

      Returns Cbor