11use core:: ops:: { Add , Div , Mul , Sub } ;
22
33use cipher:: {
4+ AlgorithmName , Block , BlockSizeUser , KeyInit , KeySizeUser , ParBlocksSizeUser ,
45 array:: ArraySize ,
6+ block:: {
7+ BlockCipherDecBackend , BlockCipherDecClosure , BlockCipherDecrypt , BlockCipherEncBackend ,
8+ BlockCipherEncClosure , BlockCipherEncrypt ,
9+ } ,
510 crypto_common:: BlockSizes ,
611 inout:: InOut ,
7- typenum:: { Diff , IsLess , Le , NonZero , Sum , Unsigned , U1 , U12 , U16 , U2 , U20 , U24 , U256 , U4 , U8 } ,
8- AlgorithmName , Block , BlockBackend , BlockCipher , BlockCipherDecrypt , BlockCipherEncrypt ,
9- BlockSizeUser , KeyInit , KeySizeUser , ParBlocksSizeUser ,
12+ typenum:: { Diff , IsLess , Le , NonZero , Sum , U1 , U2 , U4 , U8 , U12 , U16 , U20 , U24 , U256 , Unsigned } ,
1013} ;
1114
12- use crate :: core:: { BlockSize , ExpandedKeyTableSize , KeyAsWordsSize , Word , RC6 } ;
15+ use crate :: core:: { BlockSize , ExpandedKeyTableSize , KeyAsWordsSize , RC6 , Word } ;
1316
1417impl < W , R , B > KeyInit for RC6 < W , R , B >
1518where
5962 type KeySize = B ;
6063}
6164
62- impl < W , R , B > BlockCipher for RC6 < W , R , B >
63- where
64- W : Word ,
65- // Block size
66- W :: Bytes : Mul < U4 > ,
67- BlockSize < W > : BlockSizes ,
68- // Rounds range
69- R : Unsigned ,
70- R : IsLess < U256 > ,
71- Le < R , U256 > : NonZero ,
72- // ExpandedKeyTableSize
73- R : Add < U2 > ,
74- Sum < R , U2 > : Mul < U2 > ,
75- ExpandedKeyTableSize < R > : ArraySize ,
76- {
77- }
78-
7965impl < W , R , B > BlockSizeUser for RC6 < W , R , B >
8066where
8167 W : Word ,
@@ -118,8 +104,8 @@ where
118104 Diff < Sum < B , W :: Bytes > , U1 > : Div < W :: Bytes > ,
119105 KeyAsWordsSize < W , B > : ArraySize ,
120106{
121- fn encrypt_with_backend ( & self , f : impl cipher :: BlockClosure < BlockSize = Self :: BlockSize > ) {
122- f. call ( & mut RC6EncryptBackend { enc_dec : self } )
107+ fn encrypt_with_backend ( & self , f : impl BlockCipherEncClosure < BlockSize = Self :: BlockSize > ) {
108+ f. call ( & RC6EncryptBackend { enc_dec : self } )
123109 }
124110}
125111
@@ -140,7 +126,7 @@ where
140126{
141127 enc_dec : & ' a RC6 < W , R , B > ,
142128}
143- impl < ' a , W , R , B > BlockSizeUser for RC6EncryptBackend < ' a , W , R , B >
129+ impl < W , R , B > BlockSizeUser for RC6EncryptBackend < ' _ , W , R , B >
144130where
145131 W : Word ,
146132 // Block size
@@ -158,7 +144,7 @@ where
158144 type BlockSize = BlockSize < W > ;
159145}
160146
161- impl < ' a , W , R , B > ParBlocksSizeUser for RC6EncryptBackend < ' a , W , R , B >
147+ impl < W , R , B > ParBlocksSizeUser for RC6EncryptBackend < ' _ , W , R , B >
162148where
163149 W : Word ,
164150 // Block size
@@ -176,7 +162,7 @@ where
176162 type ParBlocksSize = U1 ;
177163}
178164
179- impl < ' a , W , R , B > BlockBackend for RC6EncryptBackend < ' a , W , R , B >
165+ impl < W , R , B > BlockCipherEncBackend for RC6EncryptBackend < ' _ , W , R , B >
180166where
181167 W : Word ,
182168 // Block size
@@ -191,7 +177,7 @@ where
191177 Sum < R , U2 > : Mul < U2 > ,
192178 ExpandedKeyTableSize < R > : ArraySize ,
193179 // Key range
194- B : BlockSizes ,
180+ B : ArraySize ,
195181 B : IsLess < U256 > ,
196182 Le < B , U256 > : NonZero ,
197183 // KeyAsWordsSize
@@ -201,7 +187,7 @@ where
201187 KeyAsWordsSize < W , B > : ArraySize ,
202188{
203189 #[ inline( always) ]
204- fn proc_block ( & mut self , block : InOut < ' _ , ' _ , Block < Self > > ) {
190+ fn encrypt_block ( & self , block : InOut < ' _ , ' _ , Block < Self > > ) {
205191 let backend = self . enc_dec ;
206192 backend. encrypt ( block)
207193 }
@@ -231,8 +217,8 @@ where
231217 Diff < Sum < B , W :: Bytes > , U1 > : Div < W :: Bytes > ,
232218 KeyAsWordsSize < W , B > : ArraySize ,
233219{
234- fn decrypt_with_backend ( & self , f : impl cipher :: BlockClosure < BlockSize = Self :: BlockSize > ) {
235- f. call ( & mut RC6DecryptBackend { enc_dec : self } )
220+ fn decrypt_with_backend ( & self , f : impl BlockCipherDecClosure < BlockSize = Self :: BlockSize > ) {
221+ f. call ( & RC6DecryptBackend { enc_dec : self } )
236222 }
237223}
238224
@@ -253,7 +239,7 @@ where
253239{
254240 enc_dec : & ' a RC6 < W , R , B > ,
255241}
256- impl < ' a , W , R , B > BlockSizeUser for RC6DecryptBackend < ' a , W , R , B >
242+ impl < W , R , B > BlockSizeUser for RC6DecryptBackend < ' _ , W , R , B >
257243where
258244 W : Word ,
259245 // Block size
@@ -271,7 +257,7 @@ where
271257 type BlockSize = BlockSize < W > ;
272258}
273259
274- impl < ' a , W , R , B > ParBlocksSizeUser for RC6DecryptBackend < ' a , W , R , B >
260+ impl < W , R , B > ParBlocksSizeUser for RC6DecryptBackend < ' _ , W , R , B >
275261where
276262 W : Word ,
277263 // Block size
@@ -289,7 +275,7 @@ where
289275 type ParBlocksSize = U1 ;
290276}
291277
292- impl < ' a , W , R , B > BlockBackend for RC6DecryptBackend < ' a , W , R , B >
278+ impl < W , R , B > BlockCipherDecBackend for RC6DecryptBackend < ' _ , W , R , B >
293279where
294280 W : Word ,
295281 // Block size
@@ -314,7 +300,7 @@ where
314300 KeyAsWordsSize < W , B > : ArraySize ,
315301{
316302 #[ inline( always) ]
317- fn proc_block ( & mut self , block : InOut < ' _ , ' _ , Block < Self > > ) {
303+ fn decrypt_block ( & self , block : InOut < ' _ , ' _ , Block < Self > > ) {
318304 let backend = self . enc_dec ;
319305 backend. decrypt ( block)
320306 }
0 commit comments