Skip to content

Commit da88ac7

Browse files
committed
Rename DNDK-GCM type to default
1 parent 29c904f commit da88ac7

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

dndk-gcm/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ This crate provides a fixed 24-byte nonce variant: `DndkGcm24`.
1111
```rust
1212
use dndk_gcm::{
1313
aead::{Aead, Key, KeyInit},
14-
DndkGcm24, Nonce24,
14+
DndkGcm, Nonce,
1515
};
1616

17-
let key = Key::<DndkGcm24>::from_slice(&[0u8; 32]);
18-
let cipher = DndkGcm24::new(key);
17+
let key = Key::<DndkGcm>::from_slice(&[0u8; 32]);
18+
let cipher = DndkGcm::new(key);
1919

20-
let nonce = Nonce24::from_slice(&[0u8; 24]);
20+
let nonce = Nonce::from_slice(&[0u8; 24]);
2121
let ciphertext = cipher.encrypt(nonce, b"hello".as_ref()).unwrap();
2222
let plaintext = cipher.decrypt(nonce, ciphertext.as_ref()).unwrap();
2323
assert_eq!(&plaintext, b"hello");

dndk-gcm/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
//!
2020
//! use dndk_gcm::{
2121
//! aead::{Aead, AeadCore, Key, KeyInit},
22-
//! DndkGcm24, Nonce24
22+
//! DndkGcm, Nonce
2323
//! };
2424
//!
25-
//! let key = Key::<DndkGcm24>::from_slice(&[0u8; 32]);
26-
//! let cipher = DndkGcm24::new(key);
27-
//! let nonce = Nonce24::from_slice(&[0u8; 24]); // 192-bits; MUST be unique per message
25+
//! let key = Key::<DndkGcm>::from_slice(&[0u8; 32]);
26+
//! let cipher = DndkGcm::new(key);
27+
//! let nonce = Nonce::from_slice(&[0u8; 24]); // 192-bits; MUST be unique per message
2828
//! let ciphertext = cipher.encrypt(nonce, b"plaintext message".as_ref())?;
2929
//! let plaintext = cipher.decrypt(nonce, ciphertext.as_ref())?;
3030
//! assert_eq!(&plaintext, b"plaintext message");
@@ -46,14 +46,14 @@ use cipher::{BlockCipherEncrypt, BlockSizeUser, consts::U12};
4646

4747
/// DNDK-GCM with a 24-byte nonce (KC_Choice = 0).
4848
#[derive(Clone)]
49-
pub struct DndkGcm24 {
49+
pub struct DndkGcm {
5050
aes: Aes256,
5151
}
5252

5353
type KeySize = <Aes256Gcm as KeySizeUser>::KeySize;
5454

5555
/// DNDK-GCM nonce (24 bytes).
56-
pub type Nonce24 = aes_gcm::Nonce<cipher::consts::U24>;
56+
pub type Nonce = aes_gcm::Nonce<cipher::consts::U24>;
5757

5858
/// DNDK-GCM key.
5959
pub type Key<B = Aes256> = aes_gcm::Key<B>;
@@ -70,26 +70,26 @@ pub const A_MAX: u64 = (1 << 61) - 1;
7070
/// Maximum length of ciphertext.
7171
pub const C_MAX: u64 = (1 << 36) - 32;
7272

73-
impl AeadCore for DndkGcm24 {
73+
impl AeadCore for DndkGcm {
7474
type NonceSize = cipher::consts::U24;
7575
type TagSize = <Aes256Gcm as AeadCore>::TagSize;
7676
const TAG_POSITION: TagPosition = TagPosition::Postfix;
7777
}
7878

79-
impl KeySizeUser for DndkGcm24 {
79+
impl KeySizeUser for DndkGcm {
8080
type KeySize = KeySize;
8181
}
8282

83-
impl KeyInit for DndkGcm24 {
83+
impl KeyInit for DndkGcm {
8484
fn new(key: &Key) -> Self {
8585
Self { aes: Aes256::new(key) }
8686
}
8787
}
8888

89-
impl AeadInOut for DndkGcm24 {
89+
impl AeadInOut for DndkGcm {
9090
fn encrypt_inout_detached(
9191
&self,
92-
nonce: &Nonce24,
92+
nonce: &Nonce,
9393
associated_data: &[u8],
9494
buffer: InOutBuf<'_, '_, u8>,
9595
) -> Result<Tag, Error> {
@@ -103,7 +103,7 @@ impl AeadInOut for DndkGcm24 {
103103

104104
fn decrypt_inout_detached(
105105
&self,
106-
nonce: &Nonce24,
106+
nonce: &Nonce,
107107
associated_data: &[u8],
108108
buffer: InOutBuf<'_, '_, u8>,
109109
tag: &Tag,

dndk-gcm/tests/dndkgcm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod common;
66

77
use aes_gcm::aead::{Aead, AeadInOut, KeyInit, Payload, array::Array};
88
use common::TestVector;
9-
use dndk_gcm::DndkGcm24;
9+
use dndk_gcm::DndkGcm;
1010
use hex_literal::hex;
1111

1212
/// DNDK-GCM test vectors (draft-gueron-cfrg-dndkgcm-03, Appendix A)
@@ -21,4 +21,4 @@ const TEST_VECTORS_24: &[TestVector<[u8; 32], [u8; 24]>] = &[
2121
},
2222
];
2323

24-
tests!(DndkGcm24, TEST_VECTORS_24);
24+
tests!(DndkGcm, TEST_VECTORS_24);

0 commit comments

Comments
 (0)