@@ -50,20 +50,11 @@ pub struct DndkGcm24 {
5050 aes : Aes256 ,
5151}
5252
53- /// DNDK-GCM with a 12-byte nonce (KC_Choice = 0).
54- #[ derive( Clone ) ]
55- pub struct DndkGcm12 {
56- aes : Aes256 ,
57- }
58-
5953type KeySize = <Aes256Gcm as KeySizeUser >:: KeySize ;
6054
6155/// DNDK-GCM nonce (24 bytes).
6256pub type Nonce24 = aes_gcm:: Nonce < cipher:: consts:: U24 > ;
6357
64- /// DNDK-GCM nonce (12 bytes).
65- pub type Nonce12 = aes_gcm:: Nonce < U12 > ;
66-
6758/// DNDK-GCM key.
6859pub type Key < B = Aes256 > = aes_gcm:: Key < B > ;
6960
@@ -85,32 +76,16 @@ impl AeadCore for DndkGcm24 {
8576 const TAG_POSITION : TagPosition = TagPosition :: Postfix ;
8677}
8778
88- impl AeadCore for DndkGcm12 {
89- type NonceSize = U12 ;
90- type TagSize = <Aes256Gcm as AeadCore >:: TagSize ;
91- const TAG_POSITION : TagPosition = TagPosition :: Postfix ;
92- }
93-
9479impl KeySizeUser for DndkGcm24 {
9580 type KeySize = KeySize ;
9681}
9782
98- impl KeySizeUser for DndkGcm12 {
99- type KeySize = KeySize ;
100- }
101-
10283impl KeyInit for DndkGcm24 {
10384 fn new ( key : & Key ) -> Self {
10485 Self { aes : Aes256 :: new ( key) }
10586 }
10687}
10788
108- impl KeyInit for DndkGcm12 {
109- fn new ( key : & Key ) -> Self {
110- Self { aes : Aes256 :: new ( key) }
111- }
112- }
113-
11489impl AeadInOut for DndkGcm24 {
11590 fn encrypt_inout_detached (
11691 & self ,
@@ -142,37 +117,6 @@ impl AeadInOut for DndkGcm24 {
142117 }
143118}
144119
145- impl AeadInOut for DndkGcm12 {
146- fn encrypt_inout_detached (
147- & self ,
148- nonce : & Nonce12 ,
149- associated_data : & [ u8 ] ,
150- buffer : InOutBuf < ' _ , ' _ , u8 > ,
151- ) -> Result < Tag , Error > {
152- if buffer. len ( ) as u64 > P_MAX || associated_data. len ( ) as u64 > A_MAX {
153- return Err ( Error ) ;
154- }
155-
156- let ( gcm_iv, key) = derive_key_and_iv :: < 12 > ( & self . aes , nonce. as_slice ( ) ) ;
157- Aes256Gcm :: new ( & key) . encrypt_inout_detached ( & gcm_iv, associated_data, buffer)
158- }
159-
160- fn decrypt_inout_detached (
161- & self ,
162- nonce : & Nonce12 ,
163- associated_data : & [ u8 ] ,
164- buffer : InOutBuf < ' _ , ' _ , u8 > ,
165- tag : & Tag ,
166- ) -> Result < ( ) , Error > {
167- if buffer. len ( ) as u64 > C_MAX || associated_data. len ( ) as u64 > A_MAX {
168- return Err ( Error ) ;
169- }
170-
171- let ( gcm_iv, key) = derive_key_and_iv :: < 12 > ( & self . aes , nonce. as_slice ( ) ) ;
172- Aes256Gcm :: new ( & key) . decrypt_inout_detached ( & gcm_iv, associated_data, buffer, tag)
173- }
174- }
175-
176120type Block = Array < u8 , <Aes256 as BlockSizeUser >:: BlockSize > ;
177121
178122type GcmIv = aes_gcm:: Nonce < U12 > ;
0 commit comments