Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/libthreema/lib/src/d2d_rendezvous/   (Social Medium ©)  Datei vom 26.9.2026 mit Größe 1 kB image not shown  

Quelle  rxdak.rs   Sprache: Rust

 

//! Rendezvous Initiator/Responder Device Authentication Key (RIDAK/RRDAK) utilities.
use libthreema_dependencies::crypto::{blake2b, chacha20, digest::FixedOutput as _};

use super::{RendezvousAuthenticationKey, rxdxk};

#[inline]
fn derive_keys(ak: &RendezvousAuthenticationKey) -> (chacha20::Key, chacha20::Key) {
    let ridak = blake2b::Blake2bMac256::new_with_salt_and_personal(Some(&ak.0), b"rida", b"3ma-rendezvous")
        .expect("Blake2bMac256 failed")
        .finalize_fixed();
    let rrdak = blake2b::Blake2bMac256::new_with_salt_and_personal(Some(&ak.0), b"rrda", b"3ma-rendezvous")
        .expect("Blake2bMac256 failed")
        .finalize_fixed();
    (ridak, rrdak)
}

/// RID's encrypt/decrypt context used for initial authentication.
pub(super) struct ForRid {
    pub(super) ridak: rxdxk::Encrypt,
    pub(super) rrdak: rxdxk::Decrypt,
}

/// RRD's encrypt/decrypt context used for initial authentication.
pub(super) struct ForRrd {
    pub(super) ridak: rxdxk::Decrypt,
    pub(super) rrdak: rxdxk::Encrypt,
}

impl ForRid {
    pub(super) fn new(ak: &RendezvousAuthenticationKey, pid: u32) -> Self {
        let (ridak, rrdak) = derive_keys(ak);
        Self {
            ridak: rxdxk::Encrypt::new(pid, 1, ridak),
            rrdak: rxdxk::Decrypt::new(pid, 1, rrdak),
        }
    }
}

impl ForRrd {
    pub(super) fn new(ak: &RendezvousAuthenticationKey, pid: u32) -> Self {
        let (ridak, rrdak) = derive_keys(ak);
        Self {
            ridak: rxdxk::Decrypt::new(pid, 1, ridak),
            rrdak: rxdxk::Encrypt::new(pid, 1, rrdak),
        }
    }
}

Messung
CHZG
869710094

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


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.