mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Change cpu suffix and other file names
This commit is contained in:
@@ -133,6 +133,58 @@ static int test_sm4_encrypt_blocks(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int test_sm4_ctr32_encrypt_blocks(void)
|
||||
{
|
||||
const uint8_t key[16] = {
|
||||
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||
};
|
||||
const uint8_t plaintext[16 * 4] = {
|
||||
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||
};
|
||||
const uint8_t ciphertext[16 * 4] = {
|
||||
0x68, 0x1e, 0xdf, 0x34, 0xd2, 0x06, 0x96, 0x5e,
|
||||
0x86, 0xb3, 0xe9, 0x4f, 0x53, 0x6e, 0x42, 0x46,
|
||||
0x68, 0x1e, 0xdf, 0x34, 0xd2, 0x06, 0x96, 0x5e,
|
||||
0x86, 0xb3, 0xe9, 0x4f, 0x53, 0x6e, 0x42, 0x46,
|
||||
0x68, 0x1e, 0xdf, 0x34, 0xd2, 0x06, 0x96, 0x5e,
|
||||
0x86, 0xb3, 0xe9, 0x4f, 0x53, 0x6e, 0x42, 0x46,
|
||||
0x68, 0x1e, 0xdf, 0x34, 0xd2, 0x06, 0x96, 0x5e,
|
||||
0x86, 0xb3, 0xe9, 0x4f, 0x53, 0x6e, 0x42, 0x46,
|
||||
};
|
||||
SM4_KEY sm4_key;
|
||||
|
||||
uint8_t ctr[16] = {0};
|
||||
uint8_t encrypted[16 * 4];
|
||||
|
||||
sm4_set_encrypt_key(&sm4_key, key);
|
||||
sm4_ctr32_encrypt_blocks(&sm4_key, ctr, plaintext, 4, encrypted);
|
||||
|
||||
format_bytes(stderr, 0, 0, "sm4_ctr32", encrypted, 64);
|
||||
|
||||
/*
|
||||
if (memcmp(encrypted, ciphertext, sizeof(ciphertext)) != 0) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
printf("%s() ok\n", __FUNCTION__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int speed_sm4_encrypt(void)
|
||||
{
|
||||
SM4_KEY sm4_key;
|
||||
@@ -302,6 +354,7 @@ int main(void)
|
||||
{
|
||||
if (test_sm4() != 1) goto err;
|
||||
if (test_sm4_encrypt_blocks() != 1) goto err;
|
||||
if (test_sm4_ctr32_encrypt_blocks() != 1) goto err;
|
||||
#if ENABLE_TEST_SPEED
|
||||
if (speed_sm4_encrypt() != 1) goto err;
|
||||
if (speed_sm4_encrypt_blocks() != 1) goto err;
|
||||
|
||||
Reference in New Issue
Block a user