mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-05-08 15:39:41 +00:00
Update the internal chacha test to use the framework
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3195)
This commit is contained in:
parent
c983bc4fb2
commit
bea4ac2b2e
@ -358,7 +358,7 @@ IF[{- !$disabled{tests} -}]
|
|||||||
INCLUDE[poly1305_internal_test]=.. ../include ../crypto/include
|
INCLUDE[poly1305_internal_test]=.. ../include ../crypto/include
|
||||||
DEPEND[poly1305_internal_test]=../libcrypto.a
|
DEPEND[poly1305_internal_test]=../libcrypto.a
|
||||||
|
|
||||||
SOURCE[chacha_internal_test]=chacha_internal_test.c
|
SOURCE[chacha_internal_test]=chacha_internal_test.c testutil.c test_main.c
|
||||||
INCLUDE[chacha_internal_test]=.. ../include ../crypto/include
|
INCLUDE[chacha_internal_test]=.. ../include ../crypto/include
|
||||||
DEPEND[chacha_internal_test]=../libcrypto.a
|
DEPEND[chacha_internal_test]=../libcrypto.a
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
* complete 32-byte blocks. This test goes per byte...
|
* complete 32-byte blocks. This test goes per byte...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
|
#include "test_main.h"
|
||||||
|
#include "testutil.h"
|
||||||
#include "internal/chacha.h"
|
#include "internal/chacha.h"
|
||||||
|
|
||||||
const static unsigned int key[] = {
|
const static unsigned int key[] = {
|
||||||
@ -158,17 +158,11 @@ const static unsigned char ref[] = {
|
|||||||
0xd3, 0x3e, 0xa2, 0x15, 0x5d, 0x10, 0x5d, 0x4e
|
0xd3, 0x3e, 0xa2, 0x15, 0x5d, 0x10, 0x5d, 0x4e
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(void)
|
static int test_cha_cha_internal(int n)
|
||||||
{
|
{
|
||||||
unsigned char buf[sizeof(ref)];
|
unsigned char buf[sizeof(ref)];
|
||||||
unsigned int i,j;
|
unsigned int i = n + 1, j;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
#ifdef CPUID_OBJ
|
|
||||||
OPENSSL_cpuid_setup();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 1; i <= sizeof(ref); i++) {
|
|
||||||
memset(buf, 0, i);
|
memset(buf, 0, i);
|
||||||
memcpy(buf + i, ref + i, sizeof(ref) - i);
|
memcpy(buf + i, ref + i, sizeof(ref) - i);
|
||||||
|
|
||||||
@ -178,14 +172,19 @@ int main(void)
|
|||||||
* Idea behind checking for whole sizeof(ref) is that if
|
* Idea behind checking for whole sizeof(ref) is that if
|
||||||
* ChaCha20_ctr32 oversteps i-th byte, then we'd know
|
* ChaCha20_ctr32 oversteps i-th byte, then we'd know
|
||||||
*/
|
*/
|
||||||
for (j = 0; j < sizeof(ref); j++) {
|
for (j = 0; j < sizeof(ref); j++)
|
||||||
if (buf[j] != ref[j]) {
|
if (!TEST_uchar_eq(buf[j], ref[j])) {
|
||||||
fprintf(stderr, "%u failed at %u (%02x)\n", i, j, buf[j]);
|
TEST_info("%d failed at %u (%02x)\n", i, j, buf[j]);
|
||||||
ret = 1;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
void register_tests(void)
|
||||||
|
{
|
||||||
|
#ifdef CPUID_OBJ
|
||||||
|
OPENSSL_cpuid_setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ADD_ALL_TESTS(test_cha_cha_internal, sizeof(ref));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user