Skip to main content

FfiHardwareKeyAgreement

Trait FfiHardwareKeyAgreement 

Source
pub trait FfiHardwareKeyAgreement: Send + Sync {
    // Required methods
    fn enroll(
        &self,
        key_alias: String,
    ) -> Result<Vec<u8>, FfiHardwareSignerError>;
    fn public_key(
        &self,
        key_alias: String,
    ) -> Result<Vec<u8>, FfiHardwareSignerError>;
    fn key_agreement(
        &self,
        key_alias: String,
        peer_public: Vec<u8>,
    ) -> Result<Vec<u8>, FfiHardwareSignerError>;
    fn assert_non_exportable(
        &self,
        key_alias: String,
    ) -> Result<(), FfiHardwareSignerError>;
}
Expand description

The per-platform key-agreement element (Secure Enclave P256.KeyAgreement, StrongBox ECDH, TPM 2.0 ECDH), implemented by native Swift/Kotlin over the uniffi foreign-trait boundary — the ECDH analogue of FfiHardwareSigner, and this namespace’s declaration of capsule-core’s HardwareKeyAgreement contract.

It backs the hardware-bound classical half of the device encryption key: the element holds a static P-256 private key and performs the ECDH, so the scalar never leaves hardware, while Rust drives the software-sealed ML-KEM-768 half and the hybrid combiner. Failures reuse FfiHardwareSignerError, exactly as core’s trait reuses its signer error.

Required Methods§

Source

fn enroll(&self, key_alias: String) -> Result<Vec<u8>, FfiHardwareSignerError>

Generate (or bind to) the hardware P-256 key-agreement keypair for key_alias, returning its public key as uncompressed SEC1 (0x04‖x‖y, 65 bytes). Idempotent per alias.

Source

fn public_key( &self, key_alias: String, ) -> Result<Vec<u8>, FfiHardwareSignerError>

The uncompressed-SEC1 P-256 public key for an already-enrolled key_alias.

Source

fn key_agreement( &self, key_alias: String, peer_public: Vec<u8>, ) -> Result<Vec<u8>, FfiHardwareSignerError>

ECDH against peer_public (the sender’s ephemeral P-256 public key, uncompressed SEC1) with the hardware key for key_alias, returning the raw 32-byte shared secret (the big-endian x-coordinate, before any KDF).

Source

fn assert_non_exportable( &self, key_alias: String, ) -> Result<(), FfiHardwareSignerError>

Non-exportability assertion: a conforming element MUST refuse to reveal the private bytes, returning FfiHardwareSignerError::Exportable if they can be read.

Trait Implementations§

Source§

impl<T> FfiConverterArc<T> for dyn FfiHardwareKeyAgreement

Source§

const TYPE_ID_META: MetadataBuffer

Source§

type FfiType = Handle

Source§

fn lower(obj: Arc<Self>) -> Self::FfiType

Source§

fn try_lift(handle: Self::FfiType) -> Result<Arc<Self>>

Source§

fn write(obj: Arc<Self>, buf: &mut Vec<u8>)

Source§

fn try_read(buf: &mut &[u8]) -> Result<Arc<Self>>

Source§

impl<T> LiftRef<T> for dyn FfiHardwareKeyAgreement

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§