diff --git a/README.md b/README.md index ad604bc0..e485eb4f 100644 --- a/README.md +++ b/README.md @@ -16,18 +16,18 @@ crate. ## Crates -| Name | Algorithm | Crates.io | Documentation | MSRV | -|----------------------|------------------------------|-----------|---------------|-------| -| [`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.51 | -| [`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.51 | -| [`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.51 | -| [`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.56 | -| [`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.56 | -| [`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.41 | -| [`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.56 | -| [`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.51 | -| [`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.41 | -| [`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.41 | +| Name | Algorithm | Crates.io | Documentation | MSRV | +|----------------------|-----------------------|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|------| +| [`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.51 | +| [`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.51 | +| [`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.51 | +| [`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.56 | +| [`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.56 | +| [`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.41 | +| [`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.56 | +| [`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.51 | +| [`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.41 | +| [`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.41 | ## MSRV Policy @@ -38,8 +38,8 @@ done with a minor version bump. All crates licensed under either of - * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) - * [MIT license](http://opensource.org/licenses/MIT) +* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) +* [MIT license](http://opensource.org/licenses/MIT) at your option. @@ -52,39 +52,63 @@ dual licensed as above, without any additional terms or conditions. [//]: # (badges) [deps-image]: https://deps.rs/repo/github/RustCrypto/AEADs/status.svg + [deps-link]: https://deps.rs/repo/github/RustCrypto/AEADs + [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg + [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260038-AEADs [//]: # (general links) [AEAD]: https://en.wikipedia.org/wiki/Authenticated_encryption + [IND-CCA3]: https://eprint.iacr.org/2004/272.pdf [//]: # (crates) [`aead`]: https://docs.rs/aead + [`aes-ccm`]: https://crates.io/crates/aes-ccm + [`aes-gcm`]: https://github.com/RustCrypto/AEADs/tree/master/aes-gcm + [`aes-gcm-siv`]: https://github.com/RustCrypto/AEADs/tree/master/aes-gcm-siv + [`aes-siv`]: https://github.com/RustCrypto/AEADs/tree/master/aes-siv + [`ascon-aead`]: https://github.com/RustCrypto/AEADs/tree/master/ascon-aead + [`belt-dwp`]: https://github.com/RustCrypto/AEADs/tree/master/belt-dwp + [`ccm`]: https://github.com/RustCrypto/AEADs/tree/master/ccm + [`chacha20poly1305`]: https://github.com/RustCrypto/AEADs/tree/master/chacha20poly1305 + [`deoxys`]: https://github.com/RustCrypto/AEADs/tree/master/deoxys + [`eax`]: https://github.com/RustCrypto/AEADs/tree/master/eax + [`mgm`]: https://github.com/RustCrypto/AEADs/tree/master/mgm [//]: # (algorithms) [AES-GCM]: https://en.wikipedia.org/wiki/Galois/Counter_Mode + [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/ + [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 + [MGM]: https://eprint.iacr.org/2019/123.pdf + [BeltDwp]: https://apmi.bsu.by/assets/files/std/belt-spec372.pdf + [(X)ChaCha20Poly1305]: https://tools.ietf.org/html/rfc8439 diff --git a/belt-dwp/src/ghash.rs b/belt-dwp/src/ghash.rs index 306af3ad..1ecd103e 100644 --- a/belt-dwp/src/ghash.rs +++ b/belt-dwp/src/ghash.rs @@ -1,9 +1,4 @@ -use aead::{ - consts::U16, - KeyInit, - KeySizeUser, - consts::U1 -}; +use aead::{consts::U1, consts::U16, KeyInit, KeySizeUser}; use belt_block::cipher::{BlockSizeUser, ParBlocksSizeUser}; use universal_hash::{Reset, UhfBackend, UhfClosure, UniversalHash}; diff --git a/belt-dwp/src/lib.rs b/belt-dwp/src/lib.rs index 62511f83..3ef76971 100644 --- a/belt-dwp/src/lib.rs +++ b/belt-dwp/src/lib.rs @@ -82,14 +82,12 @@ //! [`aead::Buffer`] for `arrayvec::ArrayVec` (re-exported from the [`aead`] crate as //! [`aead::arrayvec::ArrayVec`]). +use aead::consts::{U0, U16, U32, U8}; pub use aead::{self, AeadCore, AeadInPlace, Error, Key, KeyInit, KeySizeUser}; -use aead:: { - consts::{U0, U16, U32, U8}, -}; +use belt_block::cipher::{Block, BlockEncrypt, KeyIvInit, StreamCipher}; use belt_block::{belt_block_raw, BeltBlock}; use belt_ctr::BeltCtr; -use belt_block::cipher::{Block, BlockEncrypt, KeyIvInit, StreamCipher}; use universal_hash::UniversalHash; use crate::{ @@ -172,7 +170,7 @@ impl Cipher { ) -> aead::Result { let sizes_block = get_sizes_block(associated_data.len() as u64 * 8, buffer.len() as u64 * 8); - + // 3. For 𝑖 = 1, 2, . . . , π‘š do: // 3.1 𝑑 ← 𝑑 βŠ• (𝐼𝑖 β€– 0^{128βˆ’|𝐼𝑖|}) // 3.2 𝑑 ← 𝑑 * π‘Ÿ. diff --git a/belt-dwp/tests/belt.rs b/belt-dwp/tests/belt.rs index ad4dc06f..821c3802 100644 --- a/belt-dwp/tests/belt.rs +++ b/belt-dwp/tests/belt.rs @@ -1,6 +1,6 @@ use aead::AeadInPlace; -use hex_literal::hex; use belt_dwp::{BeltDwp, KeyInit}; +use hex_literal::hex; /// Test from Appendix A, tables 19-20 of [STB 34.101.31-2020](https://apmi.bsu.by/assets/files/std/belt-spec372.pdf) #[test] @@ -30,9 +30,9 @@ fn test_belt_dwp() { x: hex!("DF181ED0 08A20F43 DCBBB936 50DAD34B"), y: hex!("E12BDC1A E28257EC 703FCCF0 95EE8DF1"), t: hex!("6A2C2C94 C4150DC0"), - } + }, ]; - + for vec in test_vectors { let mut x = vec.x; let beltdwp = BeltDwp::new_from_slice(&vec.k).unwrap(); @@ -44,4 +44,4 @@ fn test_belt_dwp() { .unwrap(); assert_eq!(x, vec.x); } -} \ No newline at end of file +}