@@ -33,13 +33,10 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
3333use aead:: { AeadCore , AeadInPlace , KeyInit , KeySizeUser } ;
3434
3535#[ cfg( feature = "aead" ) ]
36- use aead:: generic_array:: typenum:: { U0 , U12 , U16 , U32 } ;
36+ use aead:: generic_array:: typenum:: { U0 , U12 , U16 , U24 , U32 } ;
3737
3838#[ cfg( all( feature = "cipher" , not( feature = "aead" ) ) ) ]
39- use cipher:: typenum:: consts:: { U16 , U32 } ;
40-
41- #[ cfg( feature = "cipher" ) ]
42- use cipher:: typenum:: consts:: U24 ;
39+ use cipher:: typenum:: consts:: { U16 , U24 , U32 } ;
4340
4441#[ cfg( feature = "cipher" ) ]
4542use cipher:: {
@@ -557,6 +554,58 @@ impl AeadInPlace for Aes128Ccm {
557554 }
558555}
559556
557+ /// AES-192-CCM authenticated encryption (12-byte nonce, 16-byte tag).
558+ #[ cfg( all( aes_ccm, feature = "aead" ) ) ]
559+ #[ derive( Zeroize , ZeroizeOnDrop ) ]
560+ pub struct Aes192Ccm {
561+ key : [ u8 ; 24 ] ,
562+ }
563+
564+ #[ cfg( all( aes_ccm, feature = "aead" ) ) ]
565+ impl KeySizeUser for Aes192Ccm {
566+ type KeySize = U24 ;
567+ }
568+
569+ #[ cfg( all( aes_ccm, feature = "aead" ) ) ]
570+ impl AeadCore for Aes192Ccm {
571+ type NonceSize = U12 ;
572+ type TagSize = U16 ;
573+ type CiphertextOverhead = U0 ;
574+ }
575+
576+ #[ cfg( all( aes_ccm, feature = "aead" ) ) ]
577+ impl KeyInit for Aes192Ccm {
578+ fn new ( key : & aead:: Key < Self > ) -> Self {
579+ let mut k = [ 0u8 ; 24 ] ;
580+ k. copy_from_slice ( key. as_ref ( ) ) ;
581+ Aes192Ccm { key : k }
582+ }
583+ }
584+
585+ #[ cfg( all( aes_ccm, feature = "aead" ) ) ]
586+ impl AeadInPlace for Aes192Ccm {
587+ fn encrypt_in_place_detached (
588+ & self ,
589+ nonce : & aead:: Nonce < Self > ,
590+ associated_data : & [ u8 ] ,
591+ buffer : & mut [ u8 ] ,
592+ ) -> Result < aead:: Tag < Self > , aead:: Error > {
593+ let mut tag = aead:: Tag :: < Self > :: default ( ) ;
594+ ccm_encrypt_in_place ( & self . key , nonce. as_ref ( ) , associated_data, buffer, tag. as_mut ( ) ) ?;
595+ Ok ( tag)
596+ }
597+
598+ fn decrypt_in_place_detached (
599+ & self ,
600+ nonce : & aead:: Nonce < Self > ,
601+ associated_data : & [ u8 ] ,
602+ buffer : & mut [ u8 ] ,
603+ tag : & aead:: Tag < Self > ,
604+ ) -> Result < ( ) , aead:: Error > {
605+ ccm_decrypt_in_place ( & self . key , nonce. as_ref ( ) , associated_data, buffer, tag. as_ref ( ) )
606+ }
607+ }
608+
560609/// AES-256-CCM authenticated encryption (12-byte nonce, 16-byte tag).
561610#[ cfg( all( aes_ccm, feature = "aead" ) ) ]
562611#[ derive( Zeroize , ZeroizeOnDrop ) ]
@@ -1713,6 +1762,58 @@ impl AeadInPlace for Aes128Gcm {
17131762 }
17141763}
17151764
1765+ /// AES-192-GCM authenticated encryption (12-byte nonce, 16-byte tag).
1766+ #[ cfg( all( aes_gcm, feature = "aead" ) ) ]
1767+ #[ derive( Zeroize , ZeroizeOnDrop ) ]
1768+ pub struct Aes192Gcm {
1769+ key : [ u8 ; 24 ] ,
1770+ }
1771+
1772+ #[ cfg( all( aes_gcm, feature = "aead" ) ) ]
1773+ impl KeySizeUser for Aes192Gcm {
1774+ type KeySize = U24 ;
1775+ }
1776+
1777+ #[ cfg( all( aes_gcm, feature = "aead" ) ) ]
1778+ impl AeadCore for Aes192Gcm {
1779+ type NonceSize = U12 ;
1780+ type TagSize = U16 ;
1781+ type CiphertextOverhead = U0 ;
1782+ }
1783+
1784+ #[ cfg( all( aes_gcm, feature = "aead" ) ) ]
1785+ impl KeyInit for Aes192Gcm {
1786+ fn new ( key : & aead:: Key < Self > ) -> Self {
1787+ let mut k = [ 0u8 ; 24 ] ;
1788+ k. copy_from_slice ( key. as_ref ( ) ) ;
1789+ Aes192Gcm { key : k }
1790+ }
1791+ }
1792+
1793+ #[ cfg( all( aes_gcm, feature = "aead" ) ) ]
1794+ impl AeadInPlace for Aes192Gcm {
1795+ fn encrypt_in_place_detached (
1796+ & self ,
1797+ nonce : & aead:: Nonce < Self > ,
1798+ associated_data : & [ u8 ] ,
1799+ buffer : & mut [ u8 ] ,
1800+ ) -> Result < aead:: Tag < Self > , aead:: Error > {
1801+ let mut tag = aead:: Tag :: < Self > :: default ( ) ;
1802+ gcm_encrypt_in_place ( & self . key , nonce. as_ref ( ) , associated_data, buffer, tag. as_mut ( ) ) ?;
1803+ Ok ( tag)
1804+ }
1805+
1806+ fn decrypt_in_place_detached (
1807+ & self ,
1808+ nonce : & aead:: Nonce < Self > ,
1809+ associated_data : & [ u8 ] ,
1810+ buffer : & mut [ u8 ] ,
1811+ tag : & aead:: Tag < Self > ,
1812+ ) -> Result < ( ) , aead:: Error > {
1813+ gcm_decrypt_in_place ( & self . key , nonce. as_ref ( ) , associated_data, buffer, tag. as_ref ( ) )
1814+ }
1815+ }
1816+
17161817/// AES-256-GCM authenticated encryption (12-byte nonce, 16-byte tag).
17171818#[ cfg( all( aes_gcm, feature = "aead" ) ) ]
17181819#[ derive( Zeroize , ZeroizeOnDrop ) ]
0 commit comments