Skip to content

Commit

Permalink
Generate k256 test vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Aug 27, 2024
1 parent ec80684 commit 06bac43
Show file tree
Hide file tree
Showing 9 changed files with 20,717 additions and 40 deletions.
12 changes: 8 additions & 4 deletions src/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ pub(crate) struct AeadCtx<A: Aead, Kdf: KdfTrait, Kem: KemTrait> {
/// Records whether the nonce sequence counter has overflowed
overflowed: bool,
/// The underlying AEAD instance. This also does decryption.
encryptor: A::AeadImpl,
pub(crate) encryptor: A::AeadImpl,
/// The base nonce which we XOR with sequence numbers
base_nonce: AeadNonce<A>,
pub(crate) base_nonce: AeadNonce<A>,
/// The exporter secret, used in the `export()` method
exporter_secret: ExporterSecret<Kdf>,
pub(crate) exporter_secret: ExporterSecret<Kdf>,
/// The running sequence number
seq: Seq,
/// This binds the `AeadCtx` to the KEM that made it. Used to generate `suite_id`.
Expand Down Expand Up @@ -236,6 +236,10 @@ impl<A: Aead, Kdf: KdfTrait, Kem: KemTrait> AeadCtx<A, Kdf, Kem> {
.labeled_expand(&self.suite_id, b"sec", exporter_ctx, out_buf)
.map_err(|_| HpkeError::KdfOutputTooLong)
}

pub(crate) fn current_nonce(&self) -> AeadNonce<A> {
mix_nonce::<A>(&self.base_nonce, &self.seq)
}
}

/// The HPKE receiver's context. This is what you use to `open` ciphertexts and `export` secrets.
Expand Down Expand Up @@ -355,7 +359,7 @@ impl<A: Aead, Kdf: KdfTrait, Kem: KemTrait> AeadCtxR<A, Kdf, Kem> {
}

/// The HPKE senders's context. This is what you use to `seal` plaintexts and `export` secrets.
pub struct AeadCtxS<A: Aead, Kdf: KdfTrait, Kem: KemTrait>(AeadCtx<A, Kdf, Kem>);
pub struct AeadCtxS<A: Aead, Kdf: KdfTrait, Kem: KemTrait>(pub(crate) AeadCtx<A, Kdf, Kem>);

// AeadCtx -> AeadCtxS via wrapping
impl<A: Aead, Kdf: KdfTrait, Kem: KemTrait> From<AeadCtx<A, Kdf, Kem>> for AeadCtxS<A, Kdf, Kem> {
Expand Down
6 changes: 6 additions & 0 deletions src/fursona.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b"my fursona is personal ok": 3695819e3cc5f3df753b7eedfc3c0adadabb0511acab818ebac13dd5ec27b986
b"my fursona is for my eyes only": df89e798e5048101b966e46a09c17b991db75e3151982d33cb79890b869f69c0
b"don't tread on my fursona": 7736453cadf9543f5ba50856a313f218bd70513226d342c6b6f04b18b8026b1c

"psk": "0247fd33b913760fa1fa51e1892d9f307fbe65eb171e8132c2af18555a738b82",
"psk_id": "456e6e796e20447572696e206172616e204d6f726961",
Loading

0 comments on commit 06bac43

Please sign in to comment.