Skip to content

Commit 5ec28f5

Browse files
committed
Use the "GFp_" prefix for ChaCha20 externs.
1 parent 05f2c83 commit 5ec28f5

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

crypto/chacha/asm/chacha-armv4.pl

+4-4
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ sub ROUND {
188188
.word -1
189189
#endif
190190
191-
.globl ChaCha20_ctr32
192-
.type ChaCha20_ctr32,%function
191+
.globl GFp_ChaCha20_ctr32
192+
.type GFp_ChaCha20_ctr32,%function
193193
.align 5
194-
ChaCha20_ctr32:
194+
GFp_ChaCha20_ctr32:
195195
.LChaCha20_ctr32:
196196
ldr r12,[sp,#0] @ pull pointer to counter and nonce
197197
stmdb sp!,{r0-r2,r4-r11,lr}
@@ -613,7 +613,7 @@ sub ROUND {
613613
add sp,sp,#4*(32+3)
614614
.Lno_data:
615615
ldmia sp!,{r4-r11,pc}
616-
.size ChaCha20_ctr32,.-ChaCha20_ctr32
616+
.size GFp_ChaCha20_ctr32,.-GFp_ChaCha20_ctr32
617617
___
618618

619619
{{{

crypto/chacha/asm/chacha-armv8.pl

+4-4
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ sub ROUND {
130130
#endif
131131
.asciz "ChaCha20 for ARMv8, CRYPTOGAMS by <appro\@openssl.org>"
132132
133-
.globl ChaCha20_ctr32
134-
.type ChaCha20_ctr32,%function
133+
.globl GFp_ChaCha20_ctr32
134+
.type GFp_ChaCha20_ctr32,%function
135135
.align 5
136-
ChaCha20_ctr32:
136+
GFp_ChaCha20_ctr32:
137137
cbz $len,.Labort
138138
adr @x[0],.LGFp_armcap_P
139139
cmp $len,#192
@@ -324,7 +324,7 @@ sub ROUND {
324324
ldp x27,x28,[x29,#80]
325325
ldp x29,x30,[sp],#96
326326
ret
327-
.size ChaCha20_ctr32,.-ChaCha20_ctr32
327+
.size GFp_ChaCha20_ctr32,.-GFp_ChaCha20_ctr32
328328
___
329329

330330
{{{

crypto/chacha/asm/chacha-x86.pl

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ sub QUARTERROUND {
111111
&static_label("ssse3_data");
112112
&static_label("pic_point");
113113

114-
&function_begin("ChaCha20_ctr32");
114+
&function_begin("GFp_ChaCha20_ctr32");
115115
&xor ("eax","eax");
116116
&cmp ("eax",&wparam(2)); # len==0?
117117
&je (&label("no_data"));
@@ -349,7 +349,7 @@ sub QUARTERROUND {
349349
&set_label("done");
350350
&stack_pop(33);
351351
&set_label("no_data");
352-
&function_end("ChaCha20_ctr32");
352+
&function_end("GFp_ChaCha20_ctr32");
353353

354354
if ($xmm) {
355355
my ($xa,$xa_,$xb,$xb_,$xc,$xc_,$xd,$xd_)=map("xmm$_",(0..7));

crypto/chacha/asm/chacha-x86_64.pl

+4-4
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ sub ROUND { # critical path is 24 cycles per round
200200
########################################################################
201201
# Generic code path that handles all lengths on pre-SSSE3 processors.
202202
$code.=<<___;
203-
.globl ChaCha20_ctr32
204-
.type ChaCha20_ctr32,\@function,5
203+
.globl GFp_ChaCha20_ctr32
204+
.type GFp_ChaCha20_ctr32,\@function,5
205205
.align 64
206-
ChaCha20_ctr32:
206+
GFp_ChaCha20_ctr32:
207207
cmp \$0,$len
208208
je .Lno_data
209209
mov GFp_ia32cap_P+4(%rip),%r10
@@ -364,7 +364,7 @@ sub ROUND { # critical path is 24 cycles per round
364364
pop %rbx
365365
.Lno_data:
366366
ret
367-
.size ChaCha20_ctr32,.-ChaCha20_ctr32
367+
.size GFp_ChaCha20_ctr32,.-GFp_ChaCha20_ctr32
368368
___
369369

370370
########################################################################

src/aead/chacha20_poly1305.rs

+21-18
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ fn seal(update: UpdateFn, ctx: &[u64; aead::KEY_CTX_BUF_ELEMS],
124124
debug_assert!(core::mem::align_of_val(chacha20_key) >= 4);
125125
debug_assert!(core::mem::align_of_val(&counter) >= 4);
126126
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);
129129
}
130130
counter[0] = 0;
131131
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],
154154
// https://rt.openssl.org/Ticket/Display.html?id=4362
155155
if cfg!(any(target_arch = "arm", target_arch = "x86")) &&
156156
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);
161161
core::ptr::copy(in_out[in_prefix_len..].as_ptr(),
162162
in_out.as_mut_ptr(), in_out.len() - in_prefix_len);
163163
} 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);
166168
}
167169
}
168170
Ok(())
@@ -195,8 +197,8 @@ fn aead_poly1305(update: UpdateFn, tag_out: &mut [u8; aead::TAG_LEN],
195197
debug_assert!(core::mem::align_of_val(chacha20_key) >= 4);
196198
debug_assert!(core::mem::align_of_val(&counter) >= 4);
197199
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);
200202
}
201203
let mut ctx = [0u8; POLY1305_STATE_LEN];
202204
poly1305_init(&mut ctx, &poly1305_key);
@@ -241,8 +243,9 @@ fn poly1305_update(state: &mut [u8; POLY1305_STATE_LEN], in_: &[u8]) {
241243
}
242244

243245
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]);
246249
fn GFp_poly1305_init(state: &mut [u8; POLY1305_STATE_LEN],
247250
key: &[u8; POLY1305_KEY_LEN]);
248251
fn GFp_poly1305_finish(state: &mut [u8; POLY1305_STATE_LEN],
@@ -254,7 +257,7 @@ extern {
254257
#[cfg(test)]
255258
mod tests {
256259
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};
258261

259262
bssl_test!(test_poly1305, bssl_poly1305_test_main);
260263

@@ -328,8 +331,8 @@ mod tests {
328331
// Straightforward encryption into disjoint buffers is computed
329332
// correctly.
330333
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);
333336
}
334337
assert_eq!(&in_out_buf[..len], expected);
335338

@@ -348,9 +351,9 @@ mod tests {
348351
for offset in 0..(max_offset + 1) {
349352
in_out_buf[alignment+offset..][..len].copy_from_slice(input);
350353
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);
354357
assert_eq!(&in_out_buf[alignment..][..len], expected);
355358
}
356359
}

0 commit comments

Comments
 (0)