Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/mls-rs-crypto-hpke/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  test_utils.rs

  Sprache: Rust
 

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

#![cfg(not(mls_build_async))]

use alloc::vec::Vec;

use crate::{
    context::{Context, ContextR, ContextS, EncryptionContext},
    dhkem::DhKem,
    hpke::Hpke,
};

use mls_rs_core::crypto::test_suite::{EncapOutput, TestHpke};
use mls_rs_crypto_traits::{AeadType, DhType, KdfType, KemType};

impl<DH: DhType, KDF: KdfType + Clone, AEAD: AeadType + Clone> TestHpke
    for Hpke<DhKem<DH, KDF>, KDF, AEAD>
{
    type ContextR = ContextR<KDF, AEAD>;
    type ContextS = ContextS<KDF, AEAD>;

    fn hpke_context(
        &self,
        key: Vec<u8>,
        base_nonce: Vec<u8>,
        exporter_secret: Vec<u8>,
    ) -> (Self::ContextS, Self::ContextR) {
        let encryption_context =
            EncryptionContext::new(base_nonce, self.aead.clone().unwrap(), key).unwrap();

        let context = Context::new(
            Some(encryption_context),
            exporter_secret.clone(),
            self.kdf.clone(),
        );

        (ContextS(context.clone()), ContextR(context))
    }

    fn encap(&mut self, ikm_e: Vec<u8>, pk_rm: Vec<u8>) -> EncapOutput {
        self.kem.set_test_data(ikm_e);
        let res = self.kem.encap(&pk_rm.into()).unwrap();

        EncapOutput {
            enc: res.enc.clone(),
            shared_secret: res.shared_secret.clone(),
        }
    }

    fn decap(&mut self, enc: Vec<u8>, sk_rm: Vec<u8>, pk_rm: Vec<u8>) -> Vec<u8> {
        self.kem.decap(&enc, &sk_rm.into(), &pk_rm.into()).unwrap()
    }
}

Messung V0.5 in Prozent
C=98 H=100 G=98

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.