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

    Class SSHAgentParams

    SSH Agent parameters for key derivation.

    This method uses an SSH agent to derive encryption keys: the agent signs the salt with the Ed25519 identity id names (by comment), and the key is HKDF-SHA256 of that signature with the salt. The agent is passed to lock and unlock as an SshAgent: MemorySshAgent holds keys in memory, and the ssh-agent-node subpath connects to the agent $SSH_AUTH_SOCK names. Without an agent the synchronous lock and unlock of KeyDerivation throw SshAgent, where the reference would connect to $SSH_AUTH_SOCK itself.

    The CBOR encoding of SSHAgentParams is byte-identical to the reference's, so a payload produced by either implementation is read by the other.

    Implements

    Index
    INDEX: KeyDerivationMethod = KeyDerivationMethod.SSHAgent

    The method discriminant that opens the SSH-agent parameter array on the wire.

    • Derive a key with an SSH agent and encrypt the content key, the reference's lock.

      Without options there is no agent to ask, and the call throws SshAgent. With options.agent:

      1. secret is the id: the comment of the identity to use, as UTF-8 (SSH Agent secret must be a valid UTF-8 string otherwise).
      2. The agent's identities are listed and reduced to the Ed25519 ones (No Ed25519 identities available in SSH agent when there is none).
      3. An empty id takes the only identity (Multiple identities available in SSH agent, but no ID provided when there are several); a non-empty id takes the identity with that comment (No matching identity found).
      4. The agent signs the salt (SSH agent refused to sign on any failure).
      5. The encryption key is HKDF-SHA256 of the signature with the salt.
      6. id is stored in these parameters, which are then the additional authenticated data; the content key is encrypted with options.nonce or a random nonce.

      Parameters

      Returns EncryptedMessage

      SshAgent as listed above.

    • Derive a key with an SSH agent and encrypt the content key, the reference's lock.

      Without options there is no agent to ask, and the call throws SshAgent. With options.agent:

      1. secret is the id: the comment of the identity to use, as UTF-8 (SSH Agent secret must be a valid UTF-8 string otherwise).
      2. The agent's identities are listed and reduced to the Ed25519 ones (No Ed25519 identities available in SSH agent when there is none).
      3. An empty id takes the only identity (Multiple identities available in SSH agent, but no ID provided when there are several); a non-empty id takes the identity with that comment (No matching identity found).
      4. The agent signs the salt (SSH agent refused to sign on any failure).
      5. The encryption key is HKDF-SHA256 of the signature with the salt.
      6. id is stored in these parameters, which are then the additional authenticated data; the content key is encrypted with options.nonce or a random nonce.

      Parameters

      Returns Promise<EncryptedMessage>

      SshAgent as listed above.

    • Derive a key with an SSH agent and decrypt the content key, the reference's unlock.

      Without options there is no agent to ask, and the call throws SshAgent. With options.agent the identity is chosen, among the agent's Ed25519 identities, by the first of these that applies: the secret's id when non-empty, the stored id when non-empty (each by comment, No matching identity found otherwise), else the first identity. The agent signs the stored salt, the key is derived as in lock, and the message is decrypted.

      Parameters

      Returns SymmetricKey

      SshAgent for the secret, identity and signing failures of lock; Crypto Failed to decrypt the encrypted key: <reason> when the message does not decrypt (a wrong identity, tampered data), and Crypto Failed to convert decrypted key to SymmetricKey: <reason> when the plaintext is not a symmetric key.

    • Derive a key with an SSH agent and decrypt the content key, the reference's unlock.

      Without options there is no agent to ask, and the call throws SshAgent. With options.agent the identity is chosen, among the agent's Ed25519 identities, by the first of these that applies: the secret's id when non-empty, the stored id when non-empty (each by comment, No matching identity found otherwise), else the first identity. The agent signs the stored salt, the key is derived as in lock, and the message is decrypted.

      Parameters

      Returns Promise<SymmetricKey>

      SshAgent for the secret, identity and signing failures of lock; Crypto Failed to decrypt the encrypted key: <reason> when the message does not decrypt (a wrong identity, tampered data), and Crypto Failed to convert decrypted key to SymmetricKey: <reason> when the plaintext is not a symmetric key.

    • From the CBOR array, as the reference's TryFrom<CBOR> (a dcbor error): every failure is Cbor with the bare message. The index element is read as a usize (with dcbor's negative wrap) and its value ignored; the fixed-width fields wrap the same way.

      Parameters

      • cborValue: Cbor

      Returns SSHAgentParams