@@ -124,8 +124,8 @@ fn seal(update: UpdateFn, ctx: &[u64; aead::KEY_CTX_BUF_ELEMS],
124
124
debug_assert ! ( core:: mem:: align_of_val( chacha20_key) >= 4 ) ;
125
125
debug_assert ! ( core:: mem:: align_of_val( & counter) >= 4 ) ;
126
126
unsafe {
127
- ChaCha20_ctr32 ( in_out. as_mut_ptr ( ) , in_out. as_ptr ( ) , in_out. len ( ) ,
128
- chacha20_key, & counter) ;
127
+ GFp_ChaCha20_ctr32 ( in_out. as_mut_ptr ( ) , in_out. as_ptr ( ) , in_out. len ( ) ,
128
+ chacha20_key, & counter) ;
129
129
}
130
130
counter[ 0 ] = 0 ;
131
131
aead_poly1305 ( update, tag_out, chacha20_key, & counter, ad, in_out) ;
@@ -154,15 +154,17 @@ fn open(update: UpdateFn, ctx: &[u64; aead::KEY_CTX_BUF_ELEMS],
154
154
// https://rt.openssl.org/Ticket/Display.html?id=4362
155
155
if cfg ! ( any( target_arch = "arm" , target_arch = "x86" ) ) &&
156
156
in_prefix_len != 0 {
157
- ChaCha20_ctr32 ( in_out[ in_prefix_len..] . as_mut_ptr ( ) ,
158
- in_out[ in_prefix_len..] . as_ptr ( ) ,
159
- in_out. len ( ) - in_prefix_len, chacha20_key,
160
- & counter) ;
157
+ GFp_ChaCha20_ctr32 ( in_out[ in_prefix_len..] . as_mut_ptr ( ) ,
158
+ in_out[ in_prefix_len..] . as_ptr ( ) ,
159
+ in_out. len ( ) - in_prefix_len, chacha20_key,
160
+ & counter) ;
161
161
core:: ptr:: copy ( in_out[ in_prefix_len..] . as_ptr ( ) ,
162
162
in_out. as_mut_ptr ( ) , in_out. len ( ) - in_prefix_len) ;
163
163
} else {
164
- ChaCha20_ctr32 ( in_out. as_mut_ptr ( ) , in_out[ in_prefix_len..] . as_ptr ( ) ,
165
- in_out. len ( ) - in_prefix_len, chacha20_key, & counter) ;
164
+ GFp_ChaCha20_ctr32 ( in_out. as_mut_ptr ( ) ,
165
+ in_out[ in_prefix_len..] . as_ptr ( ) ,
166
+ in_out. len ( ) - in_prefix_len, chacha20_key,
167
+ & counter) ;
166
168
}
167
169
}
168
170
Ok ( ( ) )
@@ -195,8 +197,8 @@ fn aead_poly1305(update: UpdateFn, tag_out: &mut [u8; aead::TAG_LEN],
195
197
debug_assert ! ( core:: mem:: align_of_val( chacha20_key) >= 4 ) ;
196
198
debug_assert ! ( core:: mem:: align_of_val( & counter) >= 4 ) ;
197
199
unsafe {
198
- ChaCha20_ctr32 ( poly1305_key. as_mut_ptr ( ) , poly1305_key. as_ptr ( ) ,
199
- POLY1305_KEY_LEN , chacha20_key, counter) ;
200
+ GFp_ChaCha20_ctr32 ( poly1305_key. as_mut_ptr ( ) , poly1305_key. as_ptr ( ) ,
201
+ POLY1305_KEY_LEN , chacha20_key, & counter) ;
200
202
}
201
203
let mut ctx = [ 0u8 ; POLY1305_STATE_LEN ] ;
202
204
poly1305_init ( & mut ctx, & poly1305_key) ;
@@ -241,8 +243,9 @@ fn poly1305_update(state: &mut [u8; POLY1305_STATE_LEN], in_: &[u8]) {
241
243
}
242
244
243
245
extern {
244
- fn ChaCha20_ctr32 ( out : * mut u8 , in_ : * const u8 , in_len : c:: size_t ,
245
- key : & [ u32 ; CHACHA20_KEY_LEN / 4 ] , counter : & [ u32 ; 4 ] ) ;
246
+ fn GFp_ChaCha20_ctr32 ( out : * mut u8 , in_ : * const u8 , in_len : c:: size_t ,
247
+ key : & [ u32 ; CHACHA20_KEY_LEN / 4 ] ,
248
+ counter : & [ u32 ; 4 ] ) ;
246
249
fn GFp_poly1305_init ( state : & mut [ u8 ; POLY1305_STATE_LEN ] ,
247
250
key : & [ u8 ; POLY1305_KEY_LEN ] ) ;
248
251
fn GFp_poly1305_finish ( state : & mut [ u8 ; POLY1305_STATE_LEN ] ,
@@ -254,7 +257,7 @@ extern {
254
257
#[ cfg( test) ]
255
258
mod tests {
256
259
use { aead, c, polyfill, test} ;
257
- use super :: { ChaCha20_ctr32 , CHACHA20_KEY_LEN , make_counter} ;
260
+ use super :: { GFp_ChaCha20_ctr32 , CHACHA20_KEY_LEN , make_counter} ;
258
261
259
262
bssl_test ! ( test_poly1305, bssl_poly1305_test_main) ;
260
263
@@ -328,8 +331,8 @@ mod tests {
328
331
// Straightforward encryption into disjoint buffers is computed
329
332
// correctly.
330
333
unsafe {
331
- ChaCha20_ctr32 ( in_out_buf. as_mut_ptr ( ) , input[ ..len] . as_ptr ( ) ,
332
- len, key, & ctr) ;
334
+ GFp_ChaCha20_ctr32 ( in_out_buf. as_mut_ptr ( ) , input[ ..len] . as_ptr ( ) ,
335
+ len, key, & ctr) ;
333
336
}
334
337
assert_eq ! ( & in_out_buf[ ..len] , expected) ;
335
338
@@ -348,9 +351,9 @@ mod tests {
348
351
for offset in 0 ..( max_offset + 1 ) {
349
352
in_out_buf[ alignment+offset..] [ ..len] . copy_from_slice ( input) ;
350
353
unsafe {
351
- ChaCha20_ctr32 ( in_out_buf[ alignment..] . as_mut_ptr ( ) ,
352
- in_out_buf[ alignment + offset..] . as_ptr ( ) ,
353
- len, key, ctr) ;
354
+ GFp_ChaCha20_ctr32 ( in_out_buf[ alignment..] . as_mut_ptr ( ) ,
355
+ in_out_buf[ alignment + offset..] . as_ptr ( ) ,
356
+ len, key, ctr) ;
354
357
assert_eq ! ( & in_out_buf[ alignment..] [ ..len] , expected) ;
355
358
}
356
359
}
0 commit comments