Skip to content

Create a Parsec Ockam Vault: investigation #507

Open
@hug-dev

Description

@hug-dev

Parsec, and more specifically the Parsec Rust client, would be a good candidate for an Ockam Vault implementation. See this discussion for context.

This issue is about investigating what needs to be done to make it happen.

A Vault structure that uses the parsec-client dependency would have to be created and that structure would have to implement the ockam_vault_core traits.

Let's review them one per one (for the 0.20.0 version).

AsymmetricVault

ec_diffie_hellman: this seems to be the psa_raw_key_agreement function with the Ecdh algorithm.
However, if the output Secret is meant to be used as key material stored securely, this is not enough (see this warning).
Instead, we will have to chain a key agreement and a key derivation using the Parsec version of the PSA Crypto operation psa_key_derivation_key_agreement. This operation is a multi-part operation that has not yet been designed in Parsec.

Hasher

sha256 is available as psa_hash_compute with the Sha256 algorithm. Although since this operation should not be sensitive it could be implemented using a software library?

hkdf_sha256: The HKDF algorithm is part of the Parsec interface but as key derivation is a multi-step operation, it has not yet been designed in Parsec.

Note to myself: if hkdf_sha256 exists, does it mean that ec_diffie_hellman should only do the key agreement part but not the derivation? Does Ockam perform these two operations one after the other anyway?

KeyIdVault

Parsec already uses String to refer to keys stored in the various crypto backends so those methods should be trivial to implement.

SecretVault

All of those key management methods are already available in Parsec. Respectively:

  • psa_generate_key
  • psa_import_key
  • psa_export_key
  • key_attributes
  • psa_export_public_key
  • psa_destroy_key

The SecretAttributes look close enough to the Attributes with the following details:

  • Parsec only support persistent keys
  • the length of Parsec keys is in bits

For key types:

  • SecretType::Buffer should map to Type:RawData
  • SecretType::Aes should map to Type::Aes
  • SecretType::Curve25519 should map to Type::EccKeyPair or Type::EccPublicKey (I guess depending on the context) with the family EccFamily::Montgomery. For the Curve25519, the bits field should be 255. See this.
  • SecretType::P256 should be the same as above but with the ECC family set to EccFamily::SecpR1 and bits to 256. To double-check between SecpR1 and SecpK1.
  • SecretType::Bls: if this refer to that, I am not sure this is defined in the PSA Crypto API and hence we could not use it :(

Signer

sign should map to psa_sign_message. If we use a software implementation to hash the data before signing it, psa_sign_hash should be enough.
I guess the algorithm to use could be deduced from the key type. Looks like it is going to be ECDSA in all cases?
The input data and signature format should be checked: what hash needs to be used for data (or is it already hashed with something?). The format returned in Signature might not be the one we use in Parsec.

SymmetricVault

aead_aes_gcm_encrypt and _decrypt should be covered with psa_aead_encrypt and _decrypt. The algorithm to use should be Aes::Gcm.

Verifier

Similar to Signer with psa_verify_message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ecosystemIssues related to building or improving compatibility layers to enhance Parsec's ecosystem positiongood first issueGood for newcomershelp wantedExtra attention is neededlargeEffort label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions