Skip to content

Commit

Permalink
update belt-dwp to prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Kitaev committed Mar 5, 2025
1 parent 571e7ff commit 0c39f0c
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 31 deletions.
31 changes: 31 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"aes-gcm-siv",
"aes-siv",
"ascon-aead",
"belt-dwp",
"ccm",
"chacha20poly1305",
"deoxys",
Expand All @@ -13,3 +14,6 @@ members = [
"xaes-256-gcm",
]
resolver = "2"

[patch.crates-io]
belt-ctr = { git = "https://github.com/RustCrypto/block-modes" }
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ crate.

## Crates

| Name | Algorithm | Crates.io | Documentation | MSRV |
|----------------------|------------------------------|:---------:|:-------------:|:----:|
| [`aead-stream`] | [STREAM] | [![crates.io](https://img.shields.io/crates/v/aead-stream.svg)](https://crates.io/crates/aead-stream) | [![Documentation](https://docs.rs/aead-stream/badge.svg)](https://docs.rs/aead-stream) | 1.81 |
| [`aes-gcm-siv`] | [AES-GCM-SIV] | [![crates.io](https://img.shields.io/crates/v/aes-gcm-siv.svg)](https://crates.io/crates/aes-gcm-siv) | [![Documentation](https://docs.rs/aes-gcm-siv/badge.svg)](https://docs.rs/aes-gcm-siv) | 1.81 |
| [`aes-gcm`] | [AES-GCM] | [![crates.io](https://img.shields.io/crates/v/aes-gcm.svg)](https://crates.io/crates/aes-gcm) | [![Documentation](https://docs.rs/aes-gcm/badge.svg)](https://docs.rs/aes-gcm) | 1.81 |
| [`aes-siv`] | [AES-SIV] | [![crates.io](https://img.shields.io/crates/v/aes-siv.svg)](https://crates.io/crates/aes-siv) | [![Documentation](https://docs.rs/aes-siv/badge.svg)](https://docs.rs/aes-siv) | 1.81 |
| [`ascon-aead`] | [Ascon] | [![crates.io](https://img.shields.io/crates/v/ascon-aead.svg)](https://crates.io/crates/ascon-aead) | [![Documentation](https://docs.rs/ascon-aead/badge.svg)](https://docs.rs/ascon-aead) | 1.81 |
| [`ccm`] | [CCM] | [![crates.io](https://img.shields.io/crates/v/ccm.svg)](https://crates.io/crates/ccm) | [![Documentation](https://docs.rs/ccm/badge.svg)](https://docs.rs/ccm) | 1.81 |
| Name | Algorithm | Crates.io | Documentation | MSRV |
|-------------------|------------------------------|:---------:|:-------------:|:----:|
| [`aead-stream`] | [STREAM] | [![crates.io](https://img.shields.io/crates/v/aead-stream.svg)](https://crates.io/crates/aead-stream) | [![Documentation](https://docs.rs/aead-stream/badge.svg)](https://docs.rs/aead-stream) | 1.81 |
| [`aes-gcm-siv`] | [AES-GCM-SIV] | [![crates.io](https://img.shields.io/crates/v/aes-gcm-siv.svg)](https://crates.io/crates/aes-gcm-siv) | [![Documentation](https://docs.rs/aes-gcm-siv/badge.svg)](https://docs.rs/aes-gcm-siv) | 1.81 |
| [`aes-gcm`] | [AES-GCM] | [![crates.io](https://img.shields.io/crates/v/aes-gcm.svg)](https://crates.io/crates/aes-gcm) | [![Documentation](https://docs.rs/aes-gcm/badge.svg)](https://docs.rs/aes-gcm) | 1.81 |
| [`aes-siv`] | [AES-SIV] | [![crates.io](https://img.shields.io/crates/v/aes-siv.svg)](https://crates.io/crates/aes-siv) | [![Documentation](https://docs.rs/aes-siv/badge.svg)](https://docs.rs/aes-siv) | 1.81 |
| [`ascon-aead`] | [Ascon] | [![crates.io](https://img.shields.io/crates/v/ascon-aead.svg)](https://crates.io/crates/ascon-aead) | [![Documentation](https://docs.rs/ascon-aead/badge.svg)](https://docs.rs/ascon-aead) | 1.81 |
| `belt-dwp` | [BeltDwp] | [![crates.io](https://img.shields.io/crates/v/belt-dwp.svg)](https://crates.io/crates/belt-dwp) | [![Documentation](https://docs.rs/belt-dwp/badge.svg)](https://docs.rs/belt-dwp) | 1.81 |
| [`ccm`] | [CCM] | [![crates.io](https://img.shields.io/crates/v/ccm.svg)](https://crates.io/crates/ccm) | [![Documentation](https://docs.rs/ccm/badge.svg)](https://docs.rs/ccm) | 1.81 |
| [`chacha20poly1305`] | [(X)ChaCha20Poly1305] | [![crates.io](https://img.shields.io/crates/v/chacha20poly1305.svg)](https://crates.io/crates/chacha20poly1305) | [![Documentation](https://docs.rs/chacha20poly1305/badge.svg)](https://docs.rs/chacha20poly1305) | 1.81 |
| [`deoxys`] | [Deoxys-I/II] | [![crates.io](https://img.shields.io/crates/v/deoxys.svg)](https://crates.io/crates/deoxys) | [![Documentation](https://docs.rs/deoxys/badge.svg)](https://docs.rs/deoxys) | 1.81 |
| [`eax`] | [EAX] | [![crates.io](https://img.shields.io/crates/v/eax.svg)](https://crates.io/crates/eax) | [![Documentation](https://docs.rs/eax/badge.svg)](https://docs.rs/eax) | 1.81 |
| [`mgm`] | [MGM] | [![crates.io](https://img.shields.io/crates/v/mgm.svg)](https://crates.io/crates/mgm) | [![Documentation](https://docs.rs/mgm/badge.svg)](https://docs.rs/mgm) | 1.81 |
| [`deoxys`] | [Deoxys-I/II] | [![crates.io](https://img.shields.io/crates/v/deoxys.svg)](https://crates.io/crates/deoxys) | [![Documentation](https://docs.rs/deoxys/badge.svg)](https://docs.rs/deoxys) | 1.81 |
| [`eax`] | [EAX] | [![crates.io](https://img.shields.io/crates/v/eax.svg)](https://crates.io/crates/eax) | [![Documentation](https://docs.rs/eax/badge.svg)](https://docs.rs/eax) | 1.81 |
| [`mgm`] | [MGM] | [![crates.io](https://img.shields.io/crates/v/mgm.svg)](https://crates.io/crates/mgm) | [![Documentation](https://docs.rs/mgm/badge.svg)](https://docs.rs/mgm) | 1.81 |

## MSRV Policy

Expand Down Expand Up @@ -83,6 +84,7 @@ dual licensed as above, without any additional terms or conditions.
[AES-GCM-SIV]: https://en.wikipedia.org/wiki/AES-GCM-SIV
[AES-SIV]: https://github.com/miscreant/meta/wiki/AES-SIV
[Ascon]: https://ascon.iaik.tugraz.at/
[BeltDwp]: https://apmi.bsu.by/assets/files/std/belt-spec372.pdf
[CCM]: https://en.wikipedia.org/wiki/CCM_mode
[Deoxys-I/II]: https://sites.google.com/view/deoxyscipher
[EAX]: https://en.wikipedia.org/wiki/EAX_mode
Expand Down
10 changes: 5 additions & 5 deletions belt-dwp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ documentation = "https://docs.rs/belt-dwp"
repository = "https://github.com/RustCrypto/AEADs/tree/master/belt-dwp"
keywords = ["aead", "belt-dwp"]
categories = ["cryptography", "no-std"]
rust-version = "1.56"
rust-version = "1.81"

[dependencies]
aead = { version = "0.5", default-features = false }
aead = { version = "0.6.0-rc.0", default-features = false }
zeroize = { version = "1.7", default-features = false }
universal-hash = { version = "0.5" }
universal-hash = { version = "0.6.0-rc.0" }
opaque-debug = { version = "0.3" }

belt-block = { version = "0.1" }
belt-ctr = { version = "0.1"}
belt-block = { version = "0.2.0-pre.2" }
belt-ctr = { version = "0.2.0-pre" }

[dev-dependencies]
hex-literal = "0.4"
Expand Down
16 changes: 8 additions & 8 deletions belt-dwp/src/gf.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use aead::generic_array::{ArrayLength, GenericArray};
use aead::array::{Array, ArraySize};

mod utils;

pub(crate) mod gf128_soft64;

pub trait GfElement {
type N: ArrayLength<u8>;
type N: ArraySize;

fn new() -> Self;
fn into_bytes(self) -> GenericArray<u8, Self::N>;
fn mul_sum(&mut self, a: &GenericArray<u8, Self::N>, b: &GenericArray<u8, Self::N>);
fn into_bytes(self) -> Array<u8, Self::N>;
fn mul_sum(&mut self, a: &Array<u8, Self::N>, b: &Array<u8, Self::N>);
}

/// Tests from Appendix A, table 18 of [STB 34.101.31-2020](https://apmi.bsu.by/assets/files/std/belt-spec372.pdf)
Expand All @@ -19,7 +19,7 @@ fn test_a18() {
use aead::consts::U16;
use hex_literal::hex;

type Block = GenericArray<u8, U16>;
type Block = Array<u8, U16>;

let test_vectors = [
(
Expand All @@ -34,9 +34,9 @@ fn test_a18() {
),
];
for (u, v, w) in test_vectors {
let a = Block::clone_from_slice(&u);
let b = Block::clone_from_slice(&v);
let c = Block::clone_from_slice(&w);
let a = Block::try_from(&u[..]).unwrap();
let b = Block::try_from(&v[..]).unwrap();
let c = Block::try_from(&w[..]).unwrap();

let mut elem = Element::new();
elem.mul_sum(&a, &b);
Expand Down
5 changes: 2 additions & 3 deletions belt-dwp/src/gf/gf128_soft64.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use aead::{array::Array, consts::U16};
use core::ops::{Add, Mul};

use aead::{consts::U16, generic_array::GenericArray};

use super::{utils::bmul64, GfElement};

#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
pub struct Element(u64, u64);

type Block = GenericArray<u8, U16>;
type Block = Array<u8, U16>;

impl GfElement for Element {
type N = U16;
Expand Down
10 changes: 6 additions & 4 deletions belt-dwp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//! assert_eq!(&plaintext, b"plaintext message");
//! # Ok(())
//! # }
//! ```
//! ```ignore
//!
//! ## In-place Usage (eliminates `alloc` requirement)
//!
Expand Down Expand Up @@ -85,7 +85,7 @@
use aead::consts::{U0, U16, U32, U8};
pub use aead::{self, AeadCore, AeadInPlace, Error, Key, KeyInit, KeySizeUser};

use belt_block::cipher::{Block, BlockEncrypt, KeyIvInit, StreamCipher};
use belt_block::cipher::{Block, BlockCipherEncrypt, KeyIvInit, StreamCipher};
use belt_block::{belt_block_raw, BeltBlock};
use belt_ctr::BeltCtr;
use universal_hash::UniversalHash;
Expand Down Expand Up @@ -159,7 +159,8 @@ impl Cipher {
Self {
enc_cipher: cipher,
mac_cipher: BeltBlock::new(&key),
ghash: GHash::new_with_init_block(Key::<GHash>::from_slice(&r), T),
// Unwrap is safe because the key is always 16 bytes
ghash: GHash::new_with_init_block(&Key::<GHash>::try_from(&r[..]).unwrap(), T),
}
}

Expand Down Expand Up @@ -194,7 +195,8 @@ impl Cipher {

self.mac_cipher.encrypt_block(&mut tag);

Ok(*Tag::from_slice(&tag[..8]))
// Unwrap is safe because the tag is always 8 bytes
Ok(Tag::try_from(&tag[..8]).unwrap())
}

fn decrypt_in_place_detached(
Expand Down
File renamed without changes.

0 comments on commit 0c39f0c

Please sign in to comment.