Skip to content

Commit 0e117ee

Browse files
committed
Consistently use cryptogams_ prefix for Andy Polyakov's code (PR weidai11#952)
1 parent 8eeaab2 commit 0e117ee

10 files changed

+115
-115
lines changed

Diff for: aes_armv4.S

+35-35
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,22 @@ AES_Te:
183183
.word 0x1B000000, 0x36000000, 0, 0, 0, 0, 0, 0
184184
.size AES_Te,.-AES_Te
185185

186-
@ void AES_encrypt_block(const unsigned char *in, unsigned char *out,
186+
@ void cryptogams_AES_encrypt_block(const unsigned char *in, unsigned char *out,
187187
@ const AES_KEY *key) {
188-
.globl AES_encrypt_block
189-
.type AES_encrypt_block,%function
188+
.globl cryptogams_AES_encrypt_block
189+
.type cryptogams_AES_encrypt_block,%function
190190
.align 5
191-
AES_encrypt_block:
191+
cryptogams_AES_encrypt_block:
192192
#ifndef __thumb2__
193-
sub r3,pc,#8 @ AES_encrypt_block
193+
sub r3,pc,#8 @ cryptogams_AES_encrypt_block
194194
#else
195195
adr r3,.
196196
#endif
197197
stmdb sp!,{r1,r4-r12,lr}
198198
#if defined(__thumb2__) || defined(__APPLE__)
199199
adr r10,AES_Te
200200
#else
201-
sub r10,r3,#AES_encrypt_block-AES_Te @ Te
201+
sub r10,r3,#cryptogams_AES_encrypt_block-AES_Te @ Te
202202
#endif
203203
mov r12,r0 @ inp
204204
mov r11,r2
@@ -243,7 +243,7 @@ AES_encrypt_block:
243243
rev r3,r3
244244
#endif
245245
#endif
246-
bl _armv4_AES_encrypt_block
246+
bl _cryptogams_armv4_AES_encrypt_block
247247

248248
ldr r12,[sp],#4 @ pop out
249249
#if __ARM_ARCH__>=7
@@ -295,11 +295,11 @@ AES_encrypt_block:
295295
moveq pc,lr @ be binary compatible with V4, yet
296296
.word 0xe12fff1e @ interoperable with Thumb ISA:-)
297297
#endif
298-
.size AES_encrypt_block,.-AES_encrypt_block
298+
.size cryptogams_AES_encrypt_block,.-cryptogams_AES_encrypt_block
299299

300-
.type _armv4_AES_encrypt_block,%function
300+
.type _cryptogams_armv4_AES_encrypt_block,%function
301301
.align 2
302-
_armv4_AES_encrypt_block:
302+
_cryptogams_armv4_AES_encrypt_block:
303303
str lr,[sp,#-4]! @ push lr
304304
ldmia r11!,{r4,r5,r6,r7}
305305
eor r0,r0,r4
@@ -432,12 +432,12 @@ _armv4_AES_encrypt_block:
432432

433433
sub r10,r10,#2
434434
ldr pc,[sp],#4 @ pop and return
435-
.size _armv4_AES_encrypt_block,.-_armv4_AES_encrypt_block
435+
.size _cryptogams_armv4_AES_encrypt_block,.-_cryptogams_armv4_AES_encrypt_block
436436

437-
.globl AES_set_encrypt_key_ARM
438-
.type AES_set_encrypt_key_ARM,%function
437+
.globl cryptogams_AES_set_encrypt_key
438+
.type cryptogams_AES_set_encrypt_key,%function
439439
.align 5
440-
AES_set_encrypt_key_ARM:
440+
cryptogams_AES_set_encrypt_key:
441441
_armv4_AES_set_encrypt_key:
442442
#ifndef __thumb2__
443443
sub r3,pc,#8 @ AES_set_encrypt_key
@@ -738,12 +738,12 @@ _armv4_AES_set_encrypt_key:
738738
moveq pc,lr @ be binary compatible with V4, yet
739739
.word 0xe12fff1e @ interoperable with Thumb ISA:-)
740740
#endif
741-
.size AES_set_encrypt_key_ARM,.-AES_set_encrypt_key_ARM
741+
.size cryptogams_AES_set_encrypt_key,.-cryptogams_AES_set_encrypt_key
742742

743-
.globl AES_set_decrypt_key_ARM
744-
.type AES_set_decrypt_key_ARM,%function
743+
.globl cryptogams_AES_set_decrypt_key
744+
.type cryptogams_AES_set_decrypt_key,%function
745745
.align 5
746-
AES_set_decrypt_key_ARM:
746+
cryptogams_AES_set_decrypt_key:
747747
str lr,[sp,#-4]! @ push lr
748748
bl _armv4_AES_set_encrypt_key
749749
teq r0,#0
@@ -753,13 +753,13 @@ AES_set_decrypt_key_ARM:
753753
mov r0,r2 @ AES_set_encrypt_key preserves r2,
754754
mov r1,r2 @ which is AES_KEY *key
755755
b _armv4_AES_set_enc2dec_key
756-
.size AES_set_decrypt_key_ARM,.-AES_set_decrypt_key_ARM
756+
.size cryptogams_AES_set_decrypt_key,.-cryptogams_AES_set_decrypt_key
757757

758-
@ void AES_set_enc2dec_key_ARM(const AES_KEY *inp,AES_KEY *out)
759-
.globl AES_set_enc2dec_key_ARM
760-
.type AES_set_enc2dec_key_ARM,%function
758+
@ void cryptogams_AES_set_enc2dec_key_ARM(const AES_KEY *inp,AES_KEY *out)
759+
.globl cryptogams_AES_set_enc2dec_key_ARM
760+
.type cryptogams_AES_set_enc2dec_key_ARM,%function
761761
.align 5
762-
AES_set_enc2dec_key_ARM:
762+
cryptogams_AES_set_enc2dec_key_ARM:
763763
_armv4_AES_set_enc2dec_key:
764764
stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr}
765765

@@ -850,7 +850,7 @@ _armv4_AES_set_enc2dec_key:
850850
moveq pc,lr @ be binary compatible with V4, yet
851851
.word 0xe12fff1e @ interoperable with Thumb ISA:-)
852852
#endif
853-
.size AES_set_enc2dec_key_ARM,.-AES_set_enc2dec_key_ARM
853+
.size cryptogams_AES_set_enc2dec_key_ARM,.-cryptogams_AES_set_enc2dec_key_ARM
854854

855855
.type AES_Td,%object
856856
.align 5
@@ -954,22 +954,22 @@ AES_Td:
954954
.byte 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
955955
.size AES_Td,.-AES_Td
956956

957-
@ void AES_decrypt_block(const unsigned char *in, unsigned char *out,
957+
@ void cryptogams_AES_decrypt_block(const unsigned char *in, unsigned char *out,
958958
@ const AES_KEY *key) {
959-
.globl AES_decrypt_block
960-
.type AES_decrypt_block,%function
959+
.globl cryptogams_AES_decrypt_block
960+
.type cryptogams_AES_decrypt_block,%function
961961
.align 5
962-
AES_decrypt_block:
962+
cryptogams_AES_decrypt_block:
963963
#ifndef __thumb2__
964-
sub r3,pc,#8 @ AES_decrypt_block
964+
sub r3,pc,#8 @ cryptogams_AES_decrypt_block
965965
#else
966966
adr r3,.
967967
#endif
968968
stmdb sp!,{r1,r4-r12,lr}
969969
#if defined(__thumb2__) || defined(__APPLE__)
970970
adr r10,AES_Td
971971
#else
972-
sub r10,r3,#AES_decrypt_block-AES_Td @ Td
972+
sub r10,r3,#cryptogams_AES_decrypt_block-AES_Td @ Td
973973
#endif
974974
mov r12,r0 @ inp
975975
mov r11,r2
@@ -1014,7 +1014,7 @@ AES_decrypt_block:
10141014
rev r3,r3
10151015
#endif
10161016
#endif
1017-
bl _armv4_AES_decrypt_block
1017+
bl _cryptogams_armv4_AES_decrypt_block
10181018

10191019
ldr r12,[sp],#4 @ pop out
10201020
#if __ARM_ARCH__>=7
@@ -1066,11 +1066,11 @@ AES_decrypt_block:
10661066
moveq pc,lr @ be binary compatible with V4, yet
10671067
.word 0xe12fff1e @ interoperable with Thumb ISA:-)
10681068
#endif
1069-
.size AES_decrypt_block,.-AES_decrypt_block
1069+
.size cryptogams_AES_decrypt_block,.-cryptogams_AES_decrypt_block
10701070

1071-
.type _armv4_AES_decrypt_block,%function
1071+
.type _cryptogams_armv4_AES_decrypt_block,%function
10721072
.align 2
1073-
_armv4_AES_decrypt_block:
1073+
_cryptogams_armv4_AES_decrypt_block:
10741074
str lr,[sp,#-4]! @ push lr
10751075
ldmia r11!,{r4,r5,r6,r7}
10761076
eor r0,r0,r4
@@ -1212,4 +1212,4 @@ _armv4_AES_decrypt_block:
12121212

12131213
sub r10,r10,#1024
12141214
ldr pc,[sp],#4 @ pop and return
1215-
.size _armv4_AES_decrypt_block,.-_armv4_AES_decrypt_block
1215+
.size _cryptogams_armv4_AES_decrypt_block,.-_cryptogams_armv4_AES_decrypt_block

Diff for: aes_armv4.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ extern "C" {
1818
// Instead of AES_KEY we use a 'word32 rkey[4*15+4]'. It has space for
1919
// both the AES_MAXNR round keys and the number of rounds in the tail.
2020

21-
int AES_set_encrypt_key_ARM(const unsigned char *userKey, const int bits, unsigned int *rkey);
22-
int AES_set_decrypt_key_ARM(const unsigned char *userKey, const int bits, unsigned int *rkey);
23-
void AES_encrypt_block(const unsigned char *in, unsigned char *out, const unsigned int *rkey);
24-
void AES_decrypt_block(const unsigned char *in, unsigned char *out, const unsigned int *rkey);
21+
int cryptogams_AES_set_encrypt_key(const unsigned char *userKey, const int bits, unsigned int *rkey);
22+
int cryptogams_AES_set_decrypt_key(const unsigned char *userKey, const int bits, unsigned int *rkey);
23+
void cryptogams_AES_encrypt_block(const unsigned char *in, unsigned char *out, const unsigned int *rkey);
24+
void cryptogams_AES_decrypt_block(const unsigned char *in, unsigned char *out, const unsigned int *rkey);
2525

2626
#ifdef __cplusplus
2727
}

Diff for: rijndael.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ extern size_t Rijndael_Dec_AdvancedProcessBlocks_ARMV8(const word32 *subkeys, si
330330
#endif
331331

332332
#if (CRYPTOGAMS_ARM_AES)
333-
extern "C" int AES_set_encrypt_key_ARM(const unsigned char *userKey, const int bitLen, word32 *rkey);
334-
extern "C" int AES_set_decrypt_key_ARM(const unsigned char *userKey, const int bitLen, word32 *rkey);
335-
extern "C" void AES_encrypt_block(const unsigned char *in, unsigned char *out, const word32 *rkey);
336-
extern "C" void AES_decrypt_block(const unsigned char *in, unsigned char *out, const word32 *rkey);
333+
extern "C" int cryptogams_AES_set_encrypt_key(const unsigned char *userKey, const int bitLen, word32 *rkey);
334+
extern "C" int cryptogams_AES_set_decrypt_key(const unsigned char *userKey, const int bitLen, word32 *rkey);
335+
extern "C" void cryptogams_AES_encrypt_block(const unsigned char *in, unsigned char *out, const word32 *rkey);
336+
extern "C" void cryptogams_AES_decrypt_block(const unsigned char *in, unsigned char *out, const word32 *rkey);
337337
#endif
338338

339339
#if (CRYPTOPP_POWER8_AES_AVAILABLE)
@@ -349,21 +349,21 @@ extern size_t Rijndael_Dec_AdvancedProcessBlocks128_6x1_ALTIVEC(const word32 *su
349349
#if (CRYPTOGAMS_ARM_AES)
350350
int CRYPTOGAMS_set_encrypt_key(const byte *userKey, const int bitLen, word32 *rkey)
351351
{
352-
return AES_set_encrypt_key_ARM(userKey, bitLen, rkey);
352+
return cryptogams_AES_set_encrypt_key(userKey, bitLen, rkey);
353353
}
354354
int CRYPTOGAMS_set_decrypt_key(const byte *userKey, const int bitLen, word32 *rkey)
355355
{
356-
return AES_set_decrypt_key_ARM(userKey, bitLen, rkey);
356+
return cryptogams_AES_set_decrypt_key(userKey, bitLen, rkey);
357357
}
358358
void CRYPTOGAMS_encrypt(const byte *inBlock, const byte *xorBlock, byte *outBlock, const word32 *rkey)
359359
{
360-
AES_encrypt_block(inBlock, outBlock, rkey);
360+
cryptogams_AES_encrypt_block(inBlock, outBlock, rkey);
361361
if (xorBlock)
362362
xorbuf (outBlock, xorBlock, 16);
363363
}
364364
void CRYPTOGAMS_decrypt(const byte *inBlock, const byte *xorBlock, byte *outBlock, const word32 *rkey)
365365
{
366-
AES_decrypt_block(inBlock, outBlock, rkey);
366+
cryptogams_AES_decrypt_block(inBlock, outBlock, rkey);
367367
if (xorBlock)
368368
xorbuf (outBlock, xorBlock, 16);
369369
}

Diff for: sha.cpp

+24-24
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ extern void SHA256_HashMultipleBlocks_SHANI(word32 *state, const word32 *data, s
6767
#endif
6868

6969
#if CRYPTOGAMS_ARM_SHA1
70-
extern "C" void sha1_block_data_order_ARM(word32* state, const word32 *data, size_t blocks);
71-
extern "C" void sha1_block_data_order_neon(word32* state, const word32 *data, size_t blocks);
70+
extern "C" void cryptogams_sha1_block_data_order(word32* state, const word32 *data, size_t blocks);
71+
extern "C" void cryptogams_sha1_block_data_order_neon(word32* state, const word32 *data, size_t blocks);
7272
#endif
7373

7474
#if CRYPTOPP_ARM_SHA1_AVAILABLE
@@ -80,8 +80,8 @@ extern void SHA256_HashMultipleBlocks_ARMV8(word32 *state, const word32 *data, s
8080
#endif
8181

8282
#if CRYPTOGAMS_ARM_SHA256
83-
extern "C" void sha256_block_data_order(word32* state, const word32 *data, size_t blocks);
84-
extern "C" void sha256_block_data_order_neon(word32* state, const word32 *data, size_t blocks);
83+
extern "C" void cryptogams_sha256_block_data_order(word32* state, const word32 *data, size_t blocks);
84+
extern "C" void cryptogams_sha256_block_data_order_neon(word32* state, const word32 *data, size_t blocks);
8585
#endif
8686

8787
#if CRYPTOPP_ARM_SHA512_AVAILABLE
@@ -94,8 +94,8 @@ extern void SHA512_HashMultipleBlocks_POWER8(word64 *state, const word64 *data,
9494
#endif
9595

9696
#if CRYPTOGAMS_ARM_SHA512
97-
extern "C" void sha512_block_data_order(word64* state, const word64 *data, size_t blocks);
98-
extern "C" void sha512_block_data_order_neon(word64* state, const word64 *data, size_t blocks);
97+
extern "C" void cryptogams_sha512_block_data_order(word64* state, const word64 *data, size_t blocks);
98+
extern "C" void cryptogams_sha512_block_data_order_neon(word64* state, const word64 *data, size_t blocks);
9999
#endif
100100

101101
// We add extern to export table to sha_simd.cpp, but it
@@ -297,9 +297,9 @@ void SHA1::Transform(word32 *state, const word32 *data)
297297
# if defined(CRYPTOPP_LITTLE_ENDIAN)
298298
word32 dataBuf[16];
299299
ByteReverse(dataBuf, data, SHA1::BLOCKSIZE);
300-
sha1_block_data_order_neon(state, data, 1);
300+
cryptogams_sha1_block_data_order_neon(state, data, 1);
301301
# else
302-
sha1_block_data_order_neon(state, data, 1);
302+
cryptogams_sha1_block_data_order_neon(state, data, 1);
303303
# endif
304304
return;
305305
}
@@ -308,9 +308,9 @@ void SHA1::Transform(word32 *state, const word32 *data)
308308
# if defined(CRYPTOPP_LITTLE_ENDIAN)
309309
word32 dataBuf[16];
310310
ByteReverse(dataBuf, data, SHA1::BLOCKSIZE);
311-
sha1_block_data_order_ARM(state, data, 1);
311+
cryptogams_sha1_block_data_order(state, data, 1);
312312
# else
313-
sha1_block_data_order_ARM(state, data, 1);
313+
cryptogams_sha1_block_data_order(state, data, 1);
314314
# endif
315315
return;
316316
}
@@ -341,12 +341,12 @@ size_t SHA1::HashMultipleBlocks(const word32 *input, size_t length)
341341
#if CRYPTOGAMS_ARM_SHA1
342342
if (HasNEON())
343343
{
344-
sha1_block_data_order_neon(m_state, input, length / SHA1::BLOCKSIZE);
344+
cryptogams_sha1_block_data_order_neon(m_state, input, length / SHA1::BLOCKSIZE);
345345
return length & (SHA1::BLOCKSIZE - 1);
346346
}
347347
if (HasARMv7())
348348
{
349-
sha1_block_data_order_ARM(m_state, input, length / SHA1::BLOCKSIZE);
349+
cryptogams_sha1_block_data_order(m_state, input, length / SHA1::BLOCKSIZE);
350350
return length & (SHA1::BLOCKSIZE - 1);
351351
}
352352
#endif
@@ -858,9 +858,9 @@ void SHA256::Transform(word32 *state, const word32 *data)
858858
# if defined(CRYPTOPP_LITTLE_ENDIAN)
859859
word32 dataBuf[16];
860860
ByteReverse(dataBuf, data, SHA256::BLOCKSIZE);
861-
sha256_block_data_order_neon(state, data, 1);
861+
cryptogams_sha256_block_data_order_neon(state, data, 1);
862862
# else
863-
sha256_block_data_order_neon(state, data, 1);
863+
cryptogams_sha256_block_data_order_neon(state, data, 1);
864864
# endif
865865
return;
866866
}
@@ -869,9 +869,9 @@ void SHA256::Transform(word32 *state, const word32 *data)
869869
# if defined(CRYPTOPP_LITTLE_ENDIAN)
870870
word32 dataBuf[16];
871871
ByteReverse(dataBuf, data, SHA256::BLOCKSIZE);
872-
sha256_block_data_order(state, data, 1);
872+
cryptogams_sha256_block_data_order(state, data, 1);
873873
# else
874-
sha256_block_data_order(state, data, 1);
874+
cryptogams_sha256_block_data_order(state, data, 1);
875875
# endif
876876
return;
877877
}
@@ -917,12 +917,12 @@ size_t SHA256::HashMultipleBlocks(const word32 *input, size_t length)
917917
#if CRYPTOGAMS_ARM_SHA256
918918
if (HasNEON())
919919
{
920-
sha256_block_data_order_neon(m_state, input, length / SHA256::BLOCKSIZE);
920+
cryptogams_sha256_block_data_order_neon(m_state, input, length / SHA256::BLOCKSIZE);
921921
return length & (SHA256::BLOCKSIZE - 1);
922922
}
923923
if (HasARMv7())
924924
{
925-
sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE);
925+
cryptogams_sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE);
926926
return length & (SHA256::BLOCKSIZE - 1);
927927
}
928928
#endif
@@ -985,12 +985,12 @@ size_t SHA224::HashMultipleBlocks(const word32 *input, size_t length)
985985
#if CRYPTOGAMS_ARM_SHA256
986986
if (HasNEON())
987987
{
988-
sha256_block_data_order_neon(m_state, input, length / SHA256::BLOCKSIZE);
988+
cryptogams_sha256_block_data_order_neon(m_state, input, length / SHA256::BLOCKSIZE);
989989
return length & (SHA256::BLOCKSIZE - 1);
990990
}
991991
if (HasARMv7())
992992
{
993-
sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE);
993+
cryptogams_sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE);
994994
return length & (SHA256::BLOCKSIZE - 1);
995995
}
996996
#endif
@@ -1356,9 +1356,9 @@ void SHA512::Transform(word64 *state, const word64 *data)
13561356
# if (CRYPTOPP_LITTLE_ENDIAN)
13571357
word64 dataBuf[16];
13581358
ByteReverse(dataBuf, data, SHA512::BLOCKSIZE);
1359-
sha512_block_data_order_neon(state, dataBuf, 1);
1359+
cryptogams_sha512_block_data_order_neon(state, dataBuf, 1);
13601360
# else
1361-
sha512_block_data_order_neon(state, data, 1);
1361+
cryptogams_sha512_block_data_order_neon(state, data, 1);
13621362
# endif
13631363
return;
13641364
}
@@ -1367,9 +1367,9 @@ void SHA512::Transform(word64 *state, const word64 *data)
13671367
# if (CRYPTOPP_LITTLE_ENDIAN)
13681368
word64 dataBuf[16];
13691369
ByteReverse(dataBuf, data, SHA512::BLOCKSIZE);
1370-
sha512_block_data_order(state, dataBuf, 1);
1370+
cryptogams_sha512_block_data_order(state, dataBuf, 1);
13711371
# else
1372-
sha512_block_data_order(state, data, 1);
1372+
cryptogams_sha512_block_data_order(state, data, 1);
13731373
# endif
13741374
return;
13751375
}

0 commit comments

Comments
 (0)