mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-03 17:58:30 +00:00
Make numerous improvements
- Python static hello world now 1.8mb - Python static fully loaded now 10mb - Python HTTPS client now uses MbedTLS - Python REPL now completes import stmts - Increase stack size for Python for now - Begin synthesizing posixpath and ntpath - Restore Python \N{UNICODE NAME} support - Restore Python NFKD symbol normalization - Add optimized code path for Intel SHA-NI - Get more Python unit tests passing faster - Get Python help() pagination working on NT - Python hashlib now supports MbedTLS PBKDF2 - Make memcpy/memmove/memcmp/bcmp/etc. faster - Add Mersenne Twister and Vigna to LIBC_RAND - Provide privileged __printf() for error code - Fix zipos opendir() so that it reports ENOTDIR - Add basic chmod() implementation for Windows NT - Add Cosmo's best functions to Python cosmo module - Pin function trace indent depth to that of caller - Show memory diagram on invalid access in MODE=dbg - Differentiate stack overflow on crash in MODE=dbg - Add stb_truetype and tools for analyzing font files - Upgrade to UNICODE 13 and reduce its binary footprint - COMPILE.COM now logs resource usage of build commands - Start implementing basic poll() support on bare metal - Set getauxval(AT_EXECFN) to GetModuleFileName() on NT - Add descriptions to strerror() in non-TINY build modes - Add COUNTBRANCH() macro to help with micro-optimizations - Make error / backtrace / asan / memory code more unbreakable - Add fast perfect C implementation of μ-Law and a-Law audio codecs - Make strtol() functions consistent with other libc implementations - Improve Linenoise implementation (see also github.com/jart/bestline) - COMPILE.COM now suppresses stdout/stderr of successful build commands
This commit is contained in:
parent
fa7b4f5bd1
commit
39bf41f4eb
806 changed files with 77494 additions and 63859 deletions
21
third_party/mbedtls/test/lib.c
vendored
21
third_party/mbedtls/test/lib.c
vendored
|
@ -21,12 +21,15 @@
|
|||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/backtrace.internal.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/rand/rand.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/stdio/append.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
@ -46,6 +49,8 @@ Copyright ARM Limited\\n\
|
|||
Copyright Mbed TLS Contributors\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
STATIC_YOINK("zip_uri_support");
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
static mbedtls_platform_context platform_ctx;
|
||||
#endif
|
||||
|
@ -67,7 +72,7 @@ struct Buffer {
|
|||
|
||||
char *output;
|
||||
jmp_buf jmp_tmp;
|
||||
int option_verbose;
|
||||
int option_verbose = 1;
|
||||
mbedtls_test_info_t mbedtls_test_info;
|
||||
|
||||
static uint64_t Rando(void) {
|
||||
|
@ -81,11 +86,10 @@ static uint64_t Rando(void) {
|
|||
int mbedtls_test_platform_setup(void) {
|
||||
char *p;
|
||||
int ret = 0;
|
||||
static char mybuf[2][BUFSIZ];
|
||||
showcrashreports();
|
||||
setvbuf(stdout, (p = malloc(BUFSIZ)), _IOLBF, BUFSIZ);
|
||||
__cxa_atexit(free, p, 0);
|
||||
setvbuf(stderr, (p = malloc(BUFSIZ)), _IOLBF, BUFSIZ);
|
||||
__cxa_atexit(free, p, 0);
|
||||
setvbuf(stdout, mybuf[0], _IOLBF, BUFSIZ);
|
||||
setvbuf(stderr, mybuf[1], _IOLBF, BUFSIZ);
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
ret = mbedtls_platform_setup(&platform_ctx);
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
|
@ -101,6 +105,7 @@ void mbedtls_test_platform_teardown(void) {
|
|||
wontreturn void exit(int rc) {
|
||||
if (rc) xwrite(1, output, appendz(output).i);
|
||||
free(output);
|
||||
output = 0;
|
||||
__cxa_finalize(0);
|
||||
_Exit(rc);
|
||||
}
|
||||
|
@ -131,8 +136,8 @@ int mbedtls_hardware_poll(void *wut, unsigned char *p, size_t n, size_t *olen) {
|
|||
}
|
||||
|
||||
int mbedtls_test_write(const char *fmt, ...) {
|
||||
char *p;
|
||||
int i, n;
|
||||
char *p;
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
if (option_verbose) {
|
||||
|
@ -1004,7 +1009,9 @@ int execute_tests(int argc, const char **argv, const char *default_filename) {
|
|||
test_filename = test_files[testfile_index];
|
||||
file = fopen(test_filename, "r");
|
||||
if (file == NULL) {
|
||||
WRITE("Failed to open test file: %s\n", test_filename);
|
||||
WRITE("%s (%s) failed to open test file: %s %m\n",
|
||||
program_invocation_short_name, program_executable_name,
|
||||
test_filename);
|
||||
if (outcome_file != NULL) fclose(outcome_file);
|
||||
return 1;
|
||||
}
|
||||
|
|
20
third_party/mbedtls/test/test.mk
vendored
20
third_party/mbedtls/test/test.mk
vendored
|
@ -40,7 +40,6 @@ THIRD_PARTY_MBEDTLS_TEST_COMS = \
|
|||
o/$(MODE)/third_party/mbedtls/test/test_suite_dhm.com \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecdh.com \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecdsa.com \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecjpake.com \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecp.com \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_entropy.com \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_error.com \
|
||||
|
@ -468,17 +467,6 @@ o/$(MODE)/third_party/mbedtls/test/test_suite_ecdsa.com.dbg: \
|
|||
$(APE)
|
||||
@$(APELINK)
|
||||
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecjpake.com: o/$(MODE)/third_party/mbedtls/test/test_suite_ecjpake.com.dbg
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecjpake.com.dbg: \
|
||||
$(THIRD_PARTY_MBEDTLS_TEST_DEPS) \
|
||||
o/$(MODE)/third_party/mbedtls/test/lib.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecjpake.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecjpake.datax.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/test.pkg \
|
||||
$(CRT) \
|
||||
$(APE)
|
||||
@$(APELINK)
|
||||
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecp.com: o/$(MODE)/third_party/mbedtls/test/test_suite_ecp.com.dbg
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_ecp.com.dbg: \
|
||||
$(THIRD_PARTY_MBEDTLS_TEST_DEPS) \
|
||||
|
@ -1039,6 +1027,7 @@ o/$(MODE)/third_party/mbedtls/test/test_suite_x509parse.com.dbg: \
|
|||
o/$(MODE)/third_party/mbedtls/test/lib.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_x509parse.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/test_suite_x509parse.datax.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/bitstring-in-dn.pem.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/cert_example_multi.crt.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/cert_example_multi_nocn.crt.zip.o \
|
||||
|
@ -1082,6 +1071,7 @@ o/$(MODE)/third_party/mbedtls/test/test_suite_x509parse.com.dbg: \
|
|||
o/$(MODE)/third_party/mbedtls/test/data/crl_sha256.pem.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/crl_sha384.pem.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/crl_sha512.pem.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir-maxpath/.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir-maxpath/00.crt.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir-maxpath/00.key.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir-maxpath/01.crt.zip.o \
|
||||
|
@ -1148,6 +1138,10 @@ o/$(MODE)/third_party/mbedtls/test/test_suite_x509parse.com.dbg: \
|
|||
o/$(MODE)/third_party/mbedtls/test/data/dir-maxpath/c20.pem.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir-maxpath/int.opensslconf.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir-maxpath/long.sh.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir1/.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir2/.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir3/.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir4/.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir1/test-ca.crt.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir2/test-ca.crt.zip.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/data/dir2/test-ca2.crt.zip.o \
|
||||
|
@ -1353,6 +1347,7 @@ o/$(MODE)/third_party/mbedtls/test/everest_test.com.dbg: \
|
|||
$(THIRD_PARTY_MBEDTLS_TEST_DEPS) \
|
||||
o/$(MODE)/third_party/mbedtls/test/everest_test.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/everest_unravaged.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/test.pkg \
|
||||
$(LIBC_TESTMAIN) \
|
||||
$(CRT) \
|
||||
$(APE)
|
||||
|
@ -1362,6 +1357,7 @@ o/$(MODE)/third_party/mbedtls/test/secp384r1_test.com: o/$(MODE)/third_party/mbe
|
|||
o/$(MODE)/third_party/mbedtls/test/secp384r1_test.com.dbg: \
|
||||
$(THIRD_PARTY_MBEDTLS_TEST_DEPS) \
|
||||
o/$(MODE)/third_party/mbedtls/test/secp384r1_test.o \
|
||||
o/$(MODE)/third_party/mbedtls/test/test.pkg \
|
||||
$(LIBC_TESTMAIN) \
|
||||
$(CRT) \
|
||||
$(APE)
|
||||
|
|
|
@ -200,7 +200,7 @@ void test_aes_encrypt_xts( char *hex_key_string, char *hex_data_unit_string,
|
|||
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, src_len,
|
||||
data_unit, src, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( memcmp( output, dst, dst_len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( output, dst, dst_len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_aes_xts_free( &ctx );
|
||||
|
@ -249,7 +249,7 @@ void test_aes_decrypt_xts( char *hex_key_string, char *hex_data_unit_string,
|
|||
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_DECRYPT, src_len,
|
||||
data_unit, src, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( memcmp( output, dst, dst_len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( output, dst, dst_len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_aes_xts_free( &ctx );
|
||||
|
@ -463,7 +463,7 @@ void test_aes_encrypt_ofb( int fragment_size, data_t *key_str,
|
|||
TEST_ASSERT( mbedtls_aes_crypt_ofb( &ctx, fragment_size, &iv_offset,
|
||||
iv_str->x, src_str_next, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( memcmp( output, expected_output->x, fragment_size ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( output, expected_output->x, fragment_size ) == 0 );
|
||||
|
||||
in_buffer_len -= fragment_size;
|
||||
expected_output->x += fragment_size;
|
||||
|
|
6
third_party/mbedtls/test/test_suite_base64.c
vendored
6
third_party/mbedtls/test/test_suite_base64.c
vendored
|
@ -118,7 +118,7 @@ void test_base64_encode_hex( data_t * src, char * dst, int dst_buf_size,
|
|||
if( result == 0 )
|
||||
{
|
||||
TEST_ASSERT( len == strlen( dst ) );
|
||||
TEST_ASSERT( memcmp( dst, res, len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( dst, res, len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -144,7 +144,7 @@ void test_base64_decode_hex( char * src, data_t * dst, int dst_buf_size,
|
|||
if( result == 0 )
|
||||
{
|
||||
TEST_ASSERT( len == dst->len );
|
||||
TEST_ASSERT( memcmp( dst->x, res, len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( dst->x, res, len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -166,7 +166,7 @@ void test_base64_decode_hex_src( data_t * src, char * dst_ref, int result )
|
|||
if( result == 0 )
|
||||
{
|
||||
TEST_ASSERT( len == strlen( dst_ref ) );
|
||||
TEST_ASSERT( memcmp( dst, dst_ref, len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( dst, dst_ref, len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
|
|
@ -866,7 +866,7 @@ void test_enc_dec_buf( int cipher_id, char * cipher_string, int key_len,
|
|||
|
||||
/* check result */
|
||||
TEST_ASSERT( total_len == length );
|
||||
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp(inbuf, decbuf, length) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1114,7 +1114,7 @@ void test_enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_va
|
|||
|
||||
TEST_ASSERT( totaloutlen == length );
|
||||
|
||||
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp(inbuf, decbuf, length) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx_dec );
|
||||
|
@ -1175,7 +1175,7 @@ void test_decrypt_test_vec( int cipher_id, int pad_mode, data_t * key,
|
|||
if( 0 == finish_result && 0 == tag_result )
|
||||
{
|
||||
TEST_ASSERT( total_len == clear->len );
|
||||
TEST_ASSERT( 0 == memcmp( output, clear->x, clear->len ) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, clear->x, clear->len ) );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -1384,8 +1384,8 @@ void test_auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
TEST_ASSERT( outlen == cipher->len + tag->len );
|
||||
TEST_ASSERT( memcmp( encrypt_buf, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( encrypt_buf + cipher->len,
|
||||
TEST_ASSERT( timingsafe_bcmp( encrypt_buf, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( encrypt_buf + cipher->len,
|
||||
tag->x, tag->len ) == 0 );
|
||||
|
||||
mbedtls_free( encrypt_buf );
|
||||
|
@ -1504,8 +1504,8 @@ void test_auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||
|
||||
TEST_ASSERT( outlen == cipher->len );
|
||||
if( cipher->len != 0 )
|
||||
TEST_ASSERT( memcmp( tmp_cipher, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( tmp_tag, tag->x, tag->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( tmp_cipher, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( tmp_tag, tag->x, tag->len ) == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1569,7 +1569,7 @@ void test_test_vec_ecb( int cipher_id, int operation, data_t * key,
|
|||
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result->x,
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, result->x,
|
||||
mbedtls_cipher_get_block_size( &ctx ) ) );
|
||||
|
||||
exit:
|
||||
|
@ -1622,7 +1622,7 @@ void test_test_vec_crypt( int cipher_id, int operation, data_t *key,
|
|||
TEST_ASSERT( result->len == outlen );
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result->x, outlen ) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, result->x, outlen ) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx );
|
||||
|
|
|
@ -866,7 +866,7 @@ void test_enc_dec_buf( int cipher_id, char * cipher_string, int key_len,
|
|||
|
||||
/* check result */
|
||||
TEST_ASSERT( total_len == length );
|
||||
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp(inbuf, decbuf, length) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1114,7 +1114,7 @@ void test_enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_va
|
|||
|
||||
TEST_ASSERT( totaloutlen == length );
|
||||
|
||||
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp(inbuf, decbuf, length) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx_dec );
|
||||
|
@ -1175,7 +1175,7 @@ void test_decrypt_test_vec( int cipher_id, int pad_mode, data_t * key,
|
|||
if( 0 == finish_result && 0 == tag_result )
|
||||
{
|
||||
TEST_ASSERT( total_len == clear->len );
|
||||
TEST_ASSERT( 0 == memcmp( output, clear->x, clear->len ) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, clear->x, clear->len ) );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -1384,8 +1384,8 @@ void test_auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
TEST_ASSERT( outlen == cipher->len + tag->len );
|
||||
TEST_ASSERT( memcmp( encrypt_buf, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( encrypt_buf + cipher->len,
|
||||
TEST_ASSERT( timingsafe_bcmp( encrypt_buf, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( encrypt_buf + cipher->len,
|
||||
tag->x, tag->len ) == 0 );
|
||||
|
||||
mbedtls_free( encrypt_buf );
|
||||
|
@ -1504,8 +1504,8 @@ void test_auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||
|
||||
TEST_ASSERT( outlen == cipher->len );
|
||||
if( cipher->len != 0 )
|
||||
TEST_ASSERT( memcmp( tmp_cipher, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( tmp_tag, tag->x, tag->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( tmp_cipher, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( tmp_tag, tag->x, tag->len ) == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1569,7 +1569,7 @@ void test_test_vec_ecb( int cipher_id, int operation, data_t * key,
|
|||
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result->x,
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, result->x,
|
||||
mbedtls_cipher_get_block_size( &ctx ) ) );
|
||||
|
||||
exit:
|
||||
|
@ -1622,7 +1622,7 @@ void test_test_vec_crypt( int cipher_id, int operation, data_t *key,
|
|||
TEST_ASSERT( result->len == outlen );
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result->x, outlen ) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, result->x, outlen ) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx );
|
||||
|
|
18
third_party/mbedtls/test/test_suite_cipher.des.c
vendored
18
third_party/mbedtls/test/test_suite_cipher.des.c
vendored
|
@ -846,7 +846,7 @@ void test_enc_dec_buf( int cipher_id, char * cipher_string, int key_len,
|
|||
|
||||
/* check result */
|
||||
TEST_ASSERT( total_len == length );
|
||||
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp(inbuf, decbuf, length) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1094,7 +1094,7 @@ void test_enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_va
|
|||
|
||||
TEST_ASSERT( totaloutlen == length );
|
||||
|
||||
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp(inbuf, decbuf, length) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx_dec );
|
||||
|
@ -1155,7 +1155,7 @@ void test_decrypt_test_vec( int cipher_id, int pad_mode, data_t * key,
|
|||
if( 0 == finish_result && 0 == tag_result )
|
||||
{
|
||||
TEST_ASSERT( total_len == clear->len );
|
||||
TEST_ASSERT( 0 == memcmp( output, clear->x, clear->len ) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, clear->x, clear->len ) );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -1356,8 +1356,8 @@ void test_auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
TEST_ASSERT( outlen == cipher->len + tag->len );
|
||||
TEST_ASSERT( memcmp( encrypt_buf, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( encrypt_buf + cipher->len,
|
||||
TEST_ASSERT( timingsafe_bcmp( encrypt_buf, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( encrypt_buf + cipher->len,
|
||||
tag->x, tag->len ) == 0 );
|
||||
|
||||
mbedtls_free( encrypt_buf );
|
||||
|
@ -1453,8 +1453,8 @@ void test_auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||
|
||||
TEST_ASSERT( outlen == cipher->len );
|
||||
if( cipher->len != 0 )
|
||||
TEST_ASSERT( memcmp( tmp_cipher, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( tmp_tag, tag->x, tag->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( tmp_cipher, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( tmp_tag, tag->x, tag->len ) == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1513,7 +1513,7 @@ void test_test_vec_ecb( int cipher_id, int operation, data_t * key,
|
|||
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result->x,
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, result->x,
|
||||
mbedtls_cipher_get_block_size( &ctx ) ) );
|
||||
|
||||
exit:
|
||||
|
@ -1555,7 +1555,7 @@ void test_test_vec_crypt( int cipher_id, int operation, data_t *key,
|
|||
TEST_ASSERT( result->len == outlen );
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result->x, outlen ) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, result->x, outlen ) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx );
|
||||
|
|
|
@ -849,7 +849,7 @@ void test_enc_dec_buf( int cipher_id, char * cipher_string, int key_len,
|
|||
|
||||
/* check result */
|
||||
TEST_ASSERT( total_len == length );
|
||||
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp(inbuf, decbuf, length) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1097,7 +1097,7 @@ void test_enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_va
|
|||
|
||||
TEST_ASSERT( totaloutlen == length );
|
||||
|
||||
TEST_ASSERT( 0 == memcmp(inbuf, decbuf, length) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp(inbuf, decbuf, length) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx_dec );
|
||||
|
@ -1158,7 +1158,7 @@ void test_decrypt_test_vec( int cipher_id, int pad_mode, data_t * key,
|
|||
if( 0 == finish_result && 0 == tag_result )
|
||||
{
|
||||
TEST_ASSERT( total_len == clear->len );
|
||||
TEST_ASSERT( 0 == memcmp( output, clear->x, clear->len ) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, clear->x, clear->len ) );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -1367,8 +1367,8 @@ void test_auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
TEST_ASSERT( outlen == cipher->len + tag->len );
|
||||
TEST_ASSERT( memcmp( encrypt_buf, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( encrypt_buf + cipher->len,
|
||||
TEST_ASSERT( timingsafe_bcmp( encrypt_buf, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( encrypt_buf + cipher->len,
|
||||
tag->x, tag->len ) == 0 );
|
||||
|
||||
mbedtls_free( encrypt_buf );
|
||||
|
@ -1487,8 +1487,8 @@ void test_auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||
|
||||
TEST_ASSERT( outlen == cipher->len );
|
||||
if( cipher->len != 0 )
|
||||
TEST_ASSERT( memcmp( tmp_cipher, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( tmp_tag, tag->x, tag->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( tmp_cipher, cipher->x, cipher->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( tmp_tag, tag->x, tag->len ) == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1552,7 +1552,7 @@ void test_test_vec_ecb( int cipher_id, int operation, data_t * key,
|
|||
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result->x,
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, result->x,
|
||||
mbedtls_cipher_get_block_size( &ctx ) ) );
|
||||
|
||||
exit:
|
||||
|
@ -1605,7 +1605,7 @@ void test_test_vec_crypt( int cipher_id, int operation, data_t *key,
|
|||
TEST_ASSERT( result->len == outlen );
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result->x, outlen ) );
|
||||
TEST_ASSERT( 0 == timingsafe_bcmp( output, result->x, outlen ) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx );
|
||||
|
|
|
@ -125,7 +125,7 @@ static void ctr_drbg_validate_internal( int reseed_mode, data_t * nonce,
|
|||
&ctx,
|
||||
buf, result->len,
|
||||
add2->x, add2->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( buf, result->x, result->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( buf, result->x, result->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_ctr_drbg_free( &ctx );
|
||||
|
|
6
third_party/mbedtls/test/test_suite_dhm.c
vendored
6
third_party/mbedtls/test/test_suite_dhm.c
vendored
|
@ -214,7 +214,7 @@ void test_dhm_do_dhm( int radix_P, char *input_P,
|
|||
|
||||
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
||||
TEST_ASSERT( sec_srv_len != 0 );
|
||||
TEST_ASSERT( memcmp( sec_srv, sec_cli, sec_srv_len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( sec_srv, sec_cli, sec_srv_len ) == 0 );
|
||||
|
||||
/* Re-do calc_secret on server a few times to test update of blinding values */
|
||||
for( i = 0; i < 3; i++ )
|
||||
|
@ -227,7 +227,7 @@ void test_dhm_do_dhm( int radix_P, char *input_P,
|
|||
|
||||
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
||||
TEST_ASSERT( sec_srv_len != 0 );
|
||||
TEST_ASSERT( memcmp( sec_srv, sec_cli, sec_srv_len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( sec_srv, sec_cli, sec_srv_len ) == 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -255,7 +255,7 @@ void test_dhm_do_dhm( int radix_P, char *input_P,
|
|||
|
||||
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
||||
TEST_ASSERT( sec_srv_len != 0 );
|
||||
TEST_ASSERT( memcmp( sec_srv, sec_cli, sec_srv_len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( sec_srv, sec_cli, sec_srv_len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_dhm_free( &ctx_srv );
|
||||
|
|
662
third_party/mbedtls/test/test_suite_ecjpake.c
vendored
662
third_party/mbedtls/test/test_suite_ecjpake.c
vendored
|
@ -1,662 +0,0 @@
|
|||
/* clang-format off */
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "third_party/mbedtls/test/test.inc"
|
||||
/*
|
||||
* *** THIS FILE WAS MACHINE GENERATED ***
|
||||
*
|
||||
* This file has been machine generated using the script:
|
||||
* generate_test_code.py and then mbedtls_test_suite.sh and then mbedtls_test_suite.sh
|
||||
*
|
||||
* Test file : ./test_suite_ecjpake.c
|
||||
*
|
||||
* The following files were used to create this file.
|
||||
*
|
||||
* Main code file : suites/main_test.function
|
||||
* Platform code file : suites/host_test.function
|
||||
* Helper file : suites/helpers.function
|
||||
* Test suite file : suites/test_suite_ecjpake.function
|
||||
* Test suite data : suites/test_suite_ecjpake.data
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define TEST_SUITE_ACTIVE
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C)
|
||||
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && defined(MBEDTLS_SHA256_C)
|
||||
static const unsigned char ecjpake_test_x1[] = {
|
||||
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
|
||||
0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
|
||||
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x21
|
||||
};
|
||||
|
||||
static const unsigned char ecjpake_test_x2[] = {
|
||||
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
|
||||
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
|
||||
0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x81
|
||||
};
|
||||
|
||||
static const unsigned char ecjpake_test_x3[] = {
|
||||
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
|
||||
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
|
||||
0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x81
|
||||
};
|
||||
|
||||
static const unsigned char ecjpake_test_x4[] = {
|
||||
0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc,
|
||||
0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
|
||||
0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe1
|
||||
};
|
||||
|
||||
static const unsigned char ecjpake_test_X1[] = {
|
||||
0x04, 0xac, 0xcf, 0x01, 0x06, 0xef, 0x85, 0x8f, 0xa2, 0xd9, 0x19, 0x33,
|
||||
0x13, 0x46, 0x80, 0x5a, 0x78, 0xb5, 0x8b, 0xba, 0xd0, 0xb8, 0x44, 0xe5,
|
||||
0xc7, 0x89, 0x28, 0x79, 0x14, 0x61, 0x87, 0xdd, 0x26, 0x66, 0xad, 0xa7,
|
||||
0x81, 0xbb, 0x7f, 0x11, 0x13, 0x72, 0x25, 0x1a, 0x89, 0x10, 0x62, 0x1f,
|
||||
0x63, 0x4d, 0xf1, 0x28, 0xac, 0x48, 0xe3, 0x81, 0xfd, 0x6e, 0xf9, 0x06,
|
||||
0x07, 0x31, 0xf6, 0x94, 0xa4
|
||||
};
|
||||
|
||||
static const unsigned char ecjpake_test_X2[] = {
|
||||
0x04, 0x7e, 0xa6, 0xe3, 0xa4, 0x48, 0x70, 0x37, 0xa9, 0xe0, 0xdb, 0xd7,
|
||||
0x92, 0x62, 0xb2, 0xcc, 0x27, 0x3e, 0x77, 0x99, 0x30, 0xfc, 0x18, 0x40,
|
||||
0x9a, 0xc5, 0x36, 0x1c, 0x5f, 0xe6, 0x69, 0xd7, 0x02, 0xe1, 0x47, 0x79,
|
||||
0x0a, 0xeb, 0x4c, 0xe7, 0xfd, 0x65, 0x75, 0xab, 0x0f, 0x6c, 0x7f, 0xd1,
|
||||
0xc3, 0x35, 0x93, 0x9a, 0xa8, 0x63, 0xba, 0x37, 0xec, 0x91, 0xb7, 0xe3,
|
||||
0x2b, 0xb0, 0x13, 0xbb, 0x2b
|
||||
};
|
||||
|
||||
static const unsigned char ecjpake_test_X3[] = {
|
||||
0x04, 0x7e, 0xa6, 0xe3, 0xa4, 0x48, 0x70, 0x37, 0xa9, 0xe0, 0xdb, 0xd7,
|
||||
0x92, 0x62, 0xb2, 0xcc, 0x27, 0x3e, 0x77, 0x99, 0x30, 0xfc, 0x18, 0x40,
|
||||
0x9a, 0xc5, 0x36, 0x1c, 0x5f, 0xe6, 0x69, 0xd7, 0x02, 0xe1, 0x47, 0x79,
|
||||
0x0a, 0xeb, 0x4c, 0xe7, 0xfd, 0x65, 0x75, 0xab, 0x0f, 0x6c, 0x7f, 0xd1,
|
||||
0xc3, 0x35, 0x93, 0x9a, 0xa8, 0x63, 0xba, 0x37, 0xec, 0x91, 0xb7, 0xe3,
|
||||
0x2b, 0xb0, 0x13, 0xbb, 0x2b
|
||||
};
|
||||
|
||||
static const unsigned char ecjpake_test_X4[] = {
|
||||
0x04, 0x19, 0x0a, 0x07, 0x70, 0x0f, 0xfa, 0x4b, 0xe6, 0xae, 0x1d, 0x79,
|
||||
0xee, 0x0f, 0x06, 0xae, 0xb5, 0x44, 0xcd, 0x5a, 0xdd, 0xaa, 0xbe, 0xdf,
|
||||
0x70, 0xf8, 0x62, 0x33, 0x21, 0x33, 0x2c, 0x54, 0xf3, 0x55, 0xf0, 0xfb,
|
||||
0xfe, 0xc7, 0x83, 0xed, 0x35, 0x9e, 0x5d, 0x0b, 0xf7, 0x37, 0x7a, 0x0f,
|
||||
0xc4, 0xea, 0x7a, 0xce, 0x47, 0x3c, 0x9c, 0x11, 0x2b, 0x41, 0xcc, 0xd4,
|
||||
0x1a, 0xc5, 0x6a, 0x56, 0x12
|
||||
};
|
||||
|
||||
/* Load my private and public keys, and peer's public keys */
|
||||
static int ecjpake_test_load( mbedtls_ecjpake_context *ctx,
|
||||
const unsigned char *xm1, size_t len_xm1,
|
||||
const unsigned char *xm2, size_t len_xm2,
|
||||
const unsigned char *Xm1, size_t len_Xm1,
|
||||
const unsigned char *Xm2, size_t len_Xm2,
|
||||
const unsigned char *Xp1, size_t len_Xp1,
|
||||
const unsigned char *Xp2, size_t len_Xp2 )
|
||||
{
|
||||
int ret;
|
||||
|
||||
MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->xm1, xm1, len_xm1 ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->xm2, xm2, len_xm2 ) );
|
||||
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_point_read_binary( &ctx->grp,
|
||||
&ctx->Xm1, Xm1, len_Xm1 ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_point_read_binary( &ctx->grp,
|
||||
&ctx->Xm2, Xm2, len_Xm2 ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_point_read_binary( &ctx->grp,
|
||||
&ctx->Xp1, Xp1, len_Xp1 ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_point_read_binary( &ctx->grp,
|
||||
&ctx->Xp2, Xp2, len_Xp2 ) );
|
||||
|
||||
cleanup:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
#define ADD_SIZE( x ) x, sizeof( x )
|
||||
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED && MBEDTLS_SHA256_C */
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
#if !defined(MBEDTLS_PARAM_FAILED_ALT)
|
||||
void test_ecjpake_invalid_param( )
|
||||
{
|
||||
mbedtls_ecjpake_context ctx;
|
||||
unsigned char buf[42] = { 0 };
|
||||
size_t olen;
|
||||
size_t const len = sizeof( buf );
|
||||
mbedtls_ecjpake_role valid_role = MBEDTLS_ECJPAKE_SERVER;
|
||||
mbedtls_ecjpake_role invalid_role = (mbedtls_ecjpake_role) 42;
|
||||
mbedtls_md_type_t valid_md = MBEDTLS_MD_SHA256;
|
||||
mbedtls_ecp_group_id valid_group = MBEDTLS_ECP_DP_SECP256R1;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_ecjpake_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_ecjpake_free( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_setup( NULL,
|
||||
valid_role,
|
||||
valid_md,
|
||||
valid_group,
|
||||
buf, len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_setup( &ctx,
|
||||
invalid_role,
|
||||
valid_md,
|
||||
valid_group,
|
||||
buf, len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_setup( &ctx,
|
||||
valid_role,
|
||||
valid_md,
|
||||
valid_group,
|
||||
NULL, len ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_check( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( NULL, buf, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( &ctx, NULL, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( &ctx, buf, len, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( NULL, buf, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx, NULL, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx, buf, len, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_read_round_one( NULL,
|
||||
buf, len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_read_round_one( &ctx,
|
||||
NULL, len ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_read_round_two( NULL,
|
||||
buf, len ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_read_round_two( &ctx,
|
||||
NULL, len ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( NULL, buf, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( &ctx, NULL, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( &ctx, buf, len, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void test_ecjpake_invalid_param_wrapper( void ** params )
|
||||
{
|
||||
(void)params;
|
||||
|
||||
test_ecjpake_invalid_param( );
|
||||
}
|
||||
#endif /* !MBEDTLS_PARAM_FAILED_ALT */
|
||||
#endif /* MBEDTLS_CHECK_PARAMS */
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
void test_ecjpake_selftest( )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_ecjpake_self_test( 1 ) == 0 );
|
||||
exit:
|
||||
;
|
||||
}
|
||||
|
||||
void test_ecjpake_selftest_wrapper( void ** params )
|
||||
{
|
||||
(void)params;
|
||||
|
||||
test_ecjpake_selftest( );
|
||||
}
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
void test_read_bad_md( data_t *msg )
|
||||
{
|
||||
mbedtls_ecjpake_context corrupt_ctx;
|
||||
const unsigned char * pw = NULL;
|
||||
const size_t pw_len = 0;
|
||||
int any_role = MBEDTLS_ECJPAKE_CLIENT;
|
||||
|
||||
mbedtls_ecjpake_init( &corrupt_ctx );
|
||||
TEST_ASSERT( mbedtls_ecjpake_setup( &corrupt_ctx, any_role,
|
||||
MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 );
|
||||
corrupt_ctx.md_info = NULL;
|
||||
|
||||
TEST_ASSERT( mbedtls_ecjpake_read_round_one( &corrupt_ctx, msg->x,
|
||||
msg->len ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
||||
|
||||
exit:
|
||||
mbedtls_ecjpake_free( &corrupt_ctx );
|
||||
}
|
||||
|
||||
void test_read_bad_md_wrapper( void ** params )
|
||||
{
|
||||
data_t data0 = {(uint8_t *) params[0], *( (uint32_t *) params[1] )};
|
||||
|
||||
test_read_bad_md( &data0 );
|
||||
}
|
||||
#endif /* MBEDTLS_SHA256_C */
|
||||
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
void test_read_round_one( int role, data_t * msg, int ref_ret )
|
||||
{
|
||||
mbedtls_ecjpake_context ctx;
|
||||
const unsigned char * pw = NULL;
|
||||
const size_t pw_len = 0;
|
||||
|
||||
mbedtls_ecjpake_init( &ctx );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecjpake_setup( &ctx, role,
|
||||
MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecjpake_read_round_one( &ctx, msg->x, msg->len ) == ref_ret );
|
||||
|
||||
exit:
|
||||
mbedtls_ecjpake_free( &ctx );
|
||||
}
|
||||
|
||||
void test_read_round_one_wrapper( void ** params )
|
||||
{
|
||||
data_t data1 = {(uint8_t *) params[1], *( (uint32_t *) params[2] )};
|
||||
|
||||
test_read_round_one( *( (int *) params[0] ), &data1, *( (int *) params[3] ) );
|
||||
}
|
||||
#endif /* MBEDTLS_SHA256_C */
|
||||
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
void test_read_round_two_cli( data_t * msg, int ref_ret )
|
||||
{
|
||||
mbedtls_ecjpake_context ctx;
|
||||
const unsigned char * pw = NULL;
|
||||
const size_t pw_len = 0;
|
||||
|
||||
mbedtls_ecjpake_init( &ctx );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecjpake_setup( &ctx, MBEDTLS_ECJPAKE_CLIENT,
|
||||
MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 );
|
||||
|
||||
TEST_ASSERT( ecjpake_test_load( &ctx,
|
||||
ADD_SIZE( ecjpake_test_x1 ), ADD_SIZE( ecjpake_test_x2 ),
|
||||
ADD_SIZE( ecjpake_test_X1 ), ADD_SIZE( ecjpake_test_X2 ),
|
||||
ADD_SIZE( ecjpake_test_X3 ), ADD_SIZE( ecjpake_test_X4 ) )
|
||||
== 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecjpake_read_round_two( &ctx, msg->x, msg->len ) == ref_ret );
|
||||
|
||||
exit:
|
||||
mbedtls_ecjpake_free( &ctx );
|
||||
}
|
||||
|
||||
void test_read_round_two_cli_wrapper( void ** params )
|
||||
{
|
||||
data_t data0 = {(uint8_t *) params[0], *( (uint32_t *) params[1] )};
|
||||
|
||||
test_read_round_two_cli( &data0, *( (int *) params[2] ) );
|
||||
}
|
||||
#endif /* MBEDTLS_SHA256_C */
|
||||
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
|
||||
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
void test_read_round_two_srv( data_t * msg, int ref_ret )
|
||||
{
|
||||
mbedtls_ecjpake_context ctx;
|
||||
const unsigned char * pw = NULL;
|
||||
const size_t pw_len = 0;
|
||||
|
||||
mbedtls_ecjpake_init( &ctx );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecjpake_setup( &ctx, MBEDTLS_ECJPAKE_SERVER,
|
||||
MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 );
|
||||
|
||||
TEST_ASSERT( ecjpake_test_load( &ctx,
|
||||
ADD_SIZE( ecjpake_test_x3 ), ADD_SIZE( ecjpake_test_x4 ),
|
||||
ADD_SIZE( ecjpake_test_X3 ), ADD_SIZE( ecjpake_test_X4 ),
|
||||
ADD_SIZE( ecjpake_test_X1 ), ADD_SIZE( ecjpake_test_X2 ) )
|
||||
== 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecjpake_read_round_two( &ctx, msg->x, msg->len ) == ref_ret );
|
||||
|
||||
exit:
|
||||
mbedtls_ecjpake_free( &ctx );
|
||||
}
|
||||
|
||||
void test_read_round_two_srv_wrapper( void ** params )
|
||||
{
|
||||
data_t data0 = {(uint8_t *) params[0], *( (uint32_t *) params[1] )};
|
||||
|
||||
test_read_round_two_srv( &data0, *( (int *) params[2] ) );
|
||||
}
|
||||
#endif /* MBEDTLS_SHA256_C */
|
||||
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
|
||||
#endif /* MBEDTLS_ECJPAKE_C */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Test dispatch code */
|
||||
|
||||
|
||||
/**
|
||||
* \brief Evaluates an expression/macro into its literal integer value.
|
||||
* For optimizing space for embedded targets each expression/macro
|
||||
* is identified by a unique identifier instead of string literals.
|
||||
* Identifiers and evaluation code is generated by script:
|
||||
* generate_test_code.py and then mbedtls_test_suite.sh and then mbedtls_test_suite.sh
|
||||
*
|
||||
* \param exp_id Expression identifier.
|
||||
* \param out_value Pointer to int to hold the integer.
|
||||
*
|
||||
* \return 0 if exp_id is found. 1 otherwise.
|
||||
*/
|
||||
int get_expression( int32_t exp_id, int32_t * out_value )
|
||||
{
|
||||
int ret = KEY_VALUE_MAPPING_FOUND;
|
||||
|
||||
(void) exp_id;
|
||||
(void) out_value;
|
||||
|
||||
switch( exp_id )
|
||||
{
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C)
|
||||
|
||||
case 0:
|
||||
{
|
||||
*out_value = MBEDTLS_ECJPAKE_CLIENT;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
*out_value = MBEDTLS_ECJPAKE_SERVER;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
*out_value = MBEDTLS_ERR_ECP_VERIFY_FAILED;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
*out_value = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
*out_value = MBEDTLS_ERR_ECP_INVALID_KEY;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
*out_value = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
{
|
||||
ret = KEY_VALUE_MAPPING_NOT_FOUND;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Checks if the dependency i.e. the compile flag is set.
|
||||
* For optimizing space for embedded targets each dependency
|
||||
* is identified by a unique identifier instead of string literals.
|
||||
* Identifiers and check code is generated by script:
|
||||
* generate_test_code.py and then mbedtls_test_suite.sh and then mbedtls_test_suite.sh
|
||||
*
|
||||
* \param dep_id Dependency identifier.
|
||||
*
|
||||
* \return DEPENDENCY_SUPPORTED if set else DEPENDENCY_NOT_SUPPORTED
|
||||
*/
|
||||
int dep_check( int dep_id )
|
||||
{
|
||||
int ret = DEPENDENCY_NOT_SUPPORTED;
|
||||
|
||||
(void) dep_id;
|
||||
|
||||
switch( dep_id )
|
||||
{
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C)
|
||||
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Function pointer type for test function wrappers.
|
||||
*
|
||||
* A test function wrapper decodes the parameters and passes them to the
|
||||
* underlying test function. Both the wrapper and the underlying function
|
||||
* return void. Test wrappers assume that they are passed a suitable
|
||||
* parameter array and do not perform any error detection.
|
||||
*
|
||||
* \param param_array The array of parameters. Each element is a `void *`
|
||||
* which the wrapper casts to the correct type and
|
||||
* dereferences. Each wrapper function hard-codes the
|
||||
* number and types of the parameters.
|
||||
*/
|
||||
typedef void (*TestWrapper_t)( void **param_array );
|
||||
|
||||
|
||||
/**
|
||||
* \brief Table of test function wrappers. Used by dispatch_test().
|
||||
* This table is populated by script:
|
||||
* generate_test_code.py and then mbedtls_test_suite.sh and then mbedtls_test_suite.sh
|
||||
*
|
||||
*/
|
||||
TestWrapper_t test_funcs[] =
|
||||
{
|
||||
/* Function Id: 0 */
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C) && defined(MBEDTLS_CHECK_PARAMS) && !defined(MBEDTLS_PARAM_FAILED_ALT)
|
||||
test_ecjpake_invalid_param_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
/* Function Id: 1 */
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C) && defined(MBEDTLS_SELF_TEST)
|
||||
test_ecjpake_selftest_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
/* Function Id: 2 */
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C) && defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && defined(MBEDTLS_SHA256_C)
|
||||
test_read_bad_md_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
/* Function Id: 3 */
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C) && defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && defined(MBEDTLS_SHA256_C)
|
||||
test_read_round_one_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
/* Function Id: 4 */
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C) && defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && defined(MBEDTLS_SHA256_C)
|
||||
test_read_round_two_cli_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
/* Function Id: 5 */
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C) && defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && defined(MBEDTLS_SHA256_C)
|
||||
test_read_round_two_srv_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Execute the test function.
|
||||
*
|
||||
* This is a wrapper function around the test function execution
|
||||
* to allow the setjmp() call used to catch any calls to the
|
||||
* parameter failure callback, to be used. Calls to setjmp()
|
||||
* can invalidate the state of any local auto variables.
|
||||
*
|
||||
* \param fp Function pointer to the test function.
|
||||
* \param params Parameters to pass to the #TestWrapper_t wrapper function.
|
||||
*
|
||||
*/
|
||||
void execute_function_ptr(TestWrapper_t fp, void **params)
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
mbedtls_test_enable_insecure_external_rng( );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
mbedtls_test_param_failed_location_record_t location_record;
|
||||
|
||||
if ( setjmp( mbedtls_test_param_failed_get_state_buf( ) ) == 0 )
|
||||
{
|
||||
fp( params );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unexpected parameter validation error */
|
||||
mbedtls_test_param_failed_get_location_record( &location_record );
|
||||
mbedtls_test_fail( location_record.failure_condition,
|
||||
location_record.line,
|
||||
location_record.file );
|
||||
}
|
||||
|
||||
mbedtls_test_param_failed_reset_state( );
|
||||
#else
|
||||
fp( params );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
||||
mbedtls_test_mutex_usage_check( );
|
||||
#endif /* MBEDTLS_TEST_MUTEX_USAGE */
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Dispatches test functions based on function index.
|
||||
*
|
||||
* \param func_idx Test function index.
|
||||
* \param params The array of parameters to pass to the test function.
|
||||
* It will be decoded by the #TestWrapper_t wrapper function.
|
||||
*
|
||||
* \return DISPATCH_TEST_SUCCESS if found
|
||||
* DISPATCH_TEST_FN_NOT_FOUND if not found
|
||||
* DISPATCH_UNSUPPORTED_SUITE if not compile time enabled.
|
||||
*/
|
||||
int dispatch_test( size_t func_idx, void ** params )
|
||||
{
|
||||
int ret = DISPATCH_TEST_SUCCESS;
|
||||
TestWrapper_t fp = NULL;
|
||||
|
||||
if ( func_idx < (int)( sizeof( test_funcs ) / sizeof( TestWrapper_t ) ) )
|
||||
{
|
||||
fp = test_funcs[func_idx];
|
||||
if ( fp )
|
||||
execute_function_ptr(fp, params);
|
||||
else
|
||||
ret = DISPATCH_UNSUPPORTED_SUITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = DISPATCH_TEST_FN_NOT_FOUND;
|
||||
}
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Checks if test function is supported in this build-time
|
||||
* configuration.
|
||||
*
|
||||
* \param func_idx Test function index.
|
||||
*
|
||||
* \return DISPATCH_TEST_SUCCESS if found
|
||||
* DISPATCH_TEST_FN_NOT_FOUND if not found
|
||||
* DISPATCH_UNSUPPORTED_SUITE if not compile time enabled.
|
||||
*/
|
||||
int check_test( size_t func_idx )
|
||||
{
|
||||
int ret = DISPATCH_TEST_SUCCESS;
|
||||
TestWrapper_t fp = NULL;
|
||||
|
||||
if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) )
|
||||
{
|
||||
fp = test_funcs[func_idx];
|
||||
if ( fp == NULL )
|
||||
ret = DISPATCH_UNSUPPORTED_SUITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = DISPATCH_TEST_FN_NOT_FOUND;
|
||||
}
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
int main( int argc, const char *argv[] )
|
||||
{
|
||||
int ret;
|
||||
mbedtls_test_platform_setup();
|
||||
ret = execute_tests( argc, argv, "/zip/third_party/mbedtls/test/test_suite_ecjpake.datax" );
|
||||
mbedtls_test_platform_teardown();
|
||||
return( ret );
|
||||
}
|
237
third_party/mbedtls/test/test_suite_ecjpake.datax
vendored
237
third_party/mbedtls/test/test_suite_ecjpake.datax
vendored
|
@ -1,237 +0,0 @@
|
|||
ECJPAKE parameter validation
|
||||
0
|
||||
|
||||
ECJPAKE selftest
|
||||
1
|
||||
|
||||
ECJPAKE fail read corrupt MD
|
||||
2:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51620934d74eb43e54df424fd96306c0117bf131afabf90a9d33d1198d905193735144104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb12"
|
||||
|
||||
ECJPAKE round one: client, valid
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51620934d74eb43e54df424fd96306c0117bf131afabf90a9d33d1198d905193735144104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb12":int:0
|
||||
|
||||
ECJPAKE round one: server, valid
|
||||
3:exp:1:hex:"4104accf0106ef858fa2d919331346805a78b58bbad0b844e5c7892879146187dd2666ada781bb7f111372251a8910621f634df128ac48e381fd6ef9060731f694a441041dd0bd5d4566c9bed9ce7de701b5e82e08e84b730466018ab903c79eb982172236c0c1728ae4bf73610d34de44246ef3d9c05a2236fb66a6583d7449308babce2072fe16662992e9235c25002f11b15087b82738e03c945bf7a2995dda1e98345841047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b4104a49558d32ed1ebfc1816af4ff09b55fcb4ca47b2a02d1e7caf1179ea3fe1395b22b861964016fabaf72c975695d93d4df0e5197fe9f040634ed59764937787be20bc4deebbf9b8d60a335f046ca3aa941e45864c7cadef9cf75b3d8b010e443ef0":int:0
|
||||
|
||||
ECJPAKE round one: role mismatch
|
||||
3:exp:0:hex:"4104accf0106ef858fa2d919331346805a78b58bbad0b844e5c7892879146187dd2666ada781bb7f111372251a8910621f634df128ac48e381fd6ef9060731f694a441041dd0bd5d4566c9bed9ce7de701b5e82e08e84b730466018ab903c79eb982172236c0c1728ae4bf73610d34de44246ef3d9c05a2236fb66a6583d7449308babce2072fe16662992e9235c25002f11b15087b82738e03c945bf7a2995dda1e98345841047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b4104a49558d32ed1ebfc1816af4ff09b55fcb4ca47b2a02d1e7caf1179ea3fe1395b22b861964016fabaf72c975695d93d4df0e5197fe9f040634ed59764937787be20bc4deebbf9b8d60a335f046ca3aa941e45864c7cadef9cf75b3d8b010e443ef0":exp:2
|
||||
|
||||
ECJPAKE round one: trailing byte
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51620934d74eb43e54df424fd96306c0117bf131afabf90a9d33d1198d905193735144104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1200":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: no data
|
||||
3:exp:0:hex:"":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: length of first point too small
|
||||
3:exp:0:hex:"00":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: length of first point too big
|
||||
3:exp:0:hex:"01":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: no point data
|
||||
3:exp:0:hex:"0104":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: first point is zero
|
||||
3:exp:0:hex:"0100":exp:4
|
||||
|
||||
ECJPAKE round one: KKP1: unknown first point format
|
||||
3:exp:0:hex:"41057ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b":exp:5
|
||||
|
||||
ECJPAKE round one: KKP1: nothing after first point
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: length of second point too small
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b00":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: length of second point too big
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b01":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: no second point data
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b0104":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: unknow second point format
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410509f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb516":exp:5
|
||||
|
||||
ECJPAKE round one: KKP1: nothing after second point
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb516":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: zero-length r
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51600":exp:4
|
||||
|
||||
ECJPAKE round one: KKP1: no data for r
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51601":exp:3
|
||||
|
||||
ECJPAKE round one: KKP1: corrupted r
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51620934d74eb43e54df424fd96306c0117bf131afabf90a9d33d1198d90519373515":exp:2
|
||||
|
||||
ECJPAKE round one: KKP1: X not on the curve
|
||||
3:exp:0:hex:"41047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2a410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51620934d74eb43e54df424fd96306c0117bf131afabf90a9d33d1198d90519373514":exp:4
|
||||
|
||||
ECJPAKE round one: KKP2: no data
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb12":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: length of first point too small
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1200":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: length of first point too big
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1201":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: no point data
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb120104":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: first point is zero
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb120100":exp:4
|
||||
|
||||
ECJPAKE round one: KKP2: unknown first point format
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241057ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b":exp:5
|
||||
|
||||
ECJPAKE round one: KKP2: nothing after first point
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: length of second point too small
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b00":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: length of second point too big
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b01":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: no second point data
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b0104":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: unknow second point format
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410509f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb516":exp:5
|
||||
|
||||
ECJPAKE round one: KKP2: nothing after second point
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb516":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: zero-length r
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51600":exp:4
|
||||
|
||||
ECJPAKE round one: KKP2: no data for r
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51601":exp:3
|
||||
|
||||
ECJPAKE round one: KKP2: corrupted r
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2b410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51620934d74eb43e54df424fd96306c0117bf131afabf90a9d33d1198d90519373515":exp:2
|
||||
|
||||
ECJPAKE round one: KKP2: X not on the curve
|
||||
3:exp:0:hex:"4104190a07700ffa4be6ae1d79ee0f06aeb544cd5addaabedf70f8623321332c54f355f0fbfec783ed359e5d0bf7377a0fc4ea7ace473c9c112b41ccd41ac56a56124104360a1cea33fce641156458e0a4eac219e96831e6aebc88b3f3752f93a0281d1bf1fb106051db9694a8d6e862a5ef1324a3d9e27894f1ee4f7c59199965a8dd4a2091847d2d22df3ee55faa2a3fb33fd2d1e055a07a7c61ecfb8d80ec00c2c9eb1241047ea6e3a4487037a9e0dbd79262b2cc273e779930fc18409ac5361c5fe669d702e147790aeb4ce7fd6575ab0f6c7fd1c335939aa863ba37ec91b7e32bb013bb2a410409f85b3d20ebd7885ce464c08d056d6428fe4dd9287aa365f131f4360ff386d846898bc4b41583c2a5197f65d78742746c12a5ec0a4ffe2f270a750a1d8fb51620934d74eb43e54df424fd96306c0117bf131afabf90a9d33d1198d90519373514":exp:4
|
||||
|
||||
ECJPAKE round two client: valid
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a641045516ea3e54a0d5d8b2ce786b38d383370029a5dbe4459c9dd601b408a24ae6465c8ac905b9eb03b5d3691c139ef83f1cd4200f6c9cd4ec392218a59ed243d3c820ff724a9a70b88cb86f20b434c6865aa1cd7906dd7c9bce3525f508276f26836c":int:0
|
||||
|
||||
ECJPAKE round two client: trailing byte
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a641045516ea3e54a0d5d8b2ce786b38d383370029a5dbe4459c9dd601b408a24ae6465c8ac905b9eb03b5d3691c139ef83f1cd4200f6c9cd4ec392218a59ed243d3c820ff724a9a70b88cb86f20b434c6865aa1cd7906dd7c9bce3525f508276f26836c00":exp:3
|
||||
|
||||
ECJPAKE round two client: no data
|
||||
4:hex:"":exp:3
|
||||
|
||||
ECJPAKE round two client: ECParams too short
|
||||
4:hex:"0300":exp:3
|
||||
|
||||
ECJPAKE round two client: ECParams not named curve
|
||||
4:hex:"010017":exp:3
|
||||
|
||||
ECJPAKE round two client: ECParams wrong curve
|
||||
4:hex:"030016":exp:5
|
||||
|
||||
ECJPAKE round two client: no data after ECParams
|
||||
4:hex:"030017":exp:3
|
||||
|
||||
ECJPAKE round two client: length of first point too small
|
||||
4:hex:"03001700":exp:3
|
||||
|
||||
ECJPAKE round two client: length of first point too big
|
||||
4:hex:"03001701":exp:3
|
||||
|
||||
ECJPAKE round two client: no first point data
|
||||
4:hex:"0300170104":exp:3
|
||||
|
||||
ECJPAKE round two client: first point is zero
|
||||
4:hex:"0300170100":exp:4
|
||||
|
||||
ECJPAKE round two client: unknown first point format
|
||||
4:hex:"03001741050fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a6":exp:5
|
||||
|
||||
ECJPAKE round two client: nothing after first point
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a6":exp:3
|
||||
|
||||
ECJPAKE round two client: length of second point too small
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a600":exp:3
|
||||
|
||||
ECJPAKE round two client: length of second point too big
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a601":exp:3
|
||||
|
||||
ECJPAKE round two client: no second point data
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a60104":exp:3
|
||||
|
||||
ECJPAKE round two client: unknown second point format
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a641055516ea3e54a0d5d8b2ce786b38d383370029a5dbe4459c9dd601b408a24ae6465c8ac905b9eb03b5d3691c139ef83f1cd4200f6c9cd4ec392218a59ed243d3c8":exp:5
|
||||
|
||||
ECJPAKE round two client: nothing after second point
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a641045516ea3e54a0d5d8b2ce786b38d383370029a5dbe4459c9dd601b408a24ae6465c8ac905b9eb03b5d3691c139ef83f1cd4200f6c9cd4ec392218a59ed243d3c8":exp:3
|
||||
|
||||
ECJPAKE round two client: zero-length r
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a641045516ea3e54a0d5d8b2ce786b38d383370029a5dbe4459c9dd601b408a24ae6465c8ac905b9eb03b5d3691c139ef83f1cd4200f6c9cd4ec392218a59ed243d3c800":exp:4
|
||||
|
||||
ECJPAKE round two client: no data for r
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a641045516ea3e54a0d5d8b2ce786b38d383370029a5dbe4459c9dd601b408a24ae6465c8ac905b9eb03b5d3691c139ef83f1cd4200f6c9cd4ec392218a59ed243d3c801":exp:3
|
||||
|
||||
ECJPAKE round two client: corrupted r
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a641045516ea3e54a0d5d8b2ce786b38d383370029a5dbe4459c9dd601b408a24ae6465c8ac905b9eb03b5d3691c139ef83f1cd4200f6c9cd4ec392218a59ed243d3c820ff724a9a70b88cb86f20b434c6865aa1cd7906dd7c9bce3525f508276f26836d":exp:2
|
||||
|
||||
ECJPAKE round two client: X not on the curve
|
||||
4:hex:"03001741040fb22b1d5d1123e0ef9feb9d8a2e590a1f4d7ced2c2b06586e8f2a16d4eb2fda4328a20b07d8fd667654ca18c54e32a333a0845451e926ee8804fd7af0aaa7a741045516ea3e54a0d5d8b2ce786b38d383370029a5dbe4459c9dd601b408a24ae6465c8ac905b9eb03b5d3691c139ef83f1cd4200f6c9cd4ec392218a59ed243d3c820ff724a9a70b88cb86f20b434c6865aa1cd7906dd7c9bce3525f508276f26836c":exp:4
|
||||
|
||||
ECJPAKE round two server: valid
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee4104077e8c31e20e6bedb760c13593e69f15be85c27d68cd09ccb8c4183608917c5c3d409fac39fefee82f7292d36f0d23e055913f45a52b85dd8a2052e9e129bb4d200f011f19483535a6e89a580c9b0003baf21462ece91a82cc38dbdcae60d9c54c":int:0
|
||||
|
||||
ECJPAKE round two server: trailing byte
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee4104077e8c31e20e6bedb760c13593e69f15be85c27d68cd09ccb8c4183608917c5c3d409fac39fefee82f7292d36f0d23e055913f45a52b85dd8a2052e9e129bb4d200f011f19483535a6e89a580c9b0003baf21462ece91a82cc38dbdcae60d9c54c00":exp:3
|
||||
|
||||
ECJPAKE round two server: no data
|
||||
5:hex:"":exp:3
|
||||
|
||||
ECJPAKE round two server: length of forst point too small
|
||||
5:hex:"00":exp:3
|
||||
|
||||
ECJPAKE round two server: length of first point too big
|
||||
5:hex:"01":exp:3
|
||||
|
||||
ECJPAKE round two server: no first point data
|
||||
5:hex:"0104":exp:3
|
||||
|
||||
ECJPAKE round two server: first point is zero
|
||||
5:hex:"0100":exp:4
|
||||
|
||||
ECJPAKE round two server: unknown first point format
|
||||
5:hex:"410569d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee":exp:5
|
||||
|
||||
ECJPAKE round two server: nothing after first point
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee":exp:3
|
||||
|
||||
ECJPAKE round two server: length of second point too small
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee00":exp:3
|
||||
|
||||
ECJPAKE round two server: length of second point too big
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee01":exp:3
|
||||
|
||||
ECJPAKE round two server: no second point data
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee0104":exp:3
|
||||
|
||||
ECJPAKE round two server: unknown second point format
|
||||
5:hex:"410569d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee4104077e8c31e20e6bedb760c13593e69f15be85c27d68cd09ccb8c4183608917c5c3d409fac39fefee82f7292d36f0d23e055913f45a52b85dd8a2052e9e129bb4d":exp:5
|
||||
|
||||
ECJPAKE round two server: nothing after second point
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee4104077e8c31e20e6bedb760c13593e69f15be85c27d68cd09ccb8c4183608917c5c3d409fac39fefee82f7292d36f0d23e055913f45a52b85dd8a2052e9e129bb4d":exp:3
|
||||
|
||||
ECJPAKE round two server: zero-length r
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee4104077e8c31e20e6bedb760c13593e69f15be85c27d68cd09ccb8c4183608917c5c3d409fac39fefee82f7292d36f0d23e055913f45a52b85dd8a2052e9e129bb4d00":exp:4
|
||||
|
||||
ECJPAKE round two server: no data for r
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee4104077e8c31e20e6bedb760c13593e69f15be85c27d68cd09ccb8c4183608917c5c3d409fac39fefee82f7292d36f0d23e055913f45a52b85dd8a2052e9e129bb4d20":exp:3
|
||||
|
||||
ECJPAKE round two server: corrupted r
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ee4104077e8c31e20e6bedb760c13593e69f15be85c27d68cd09ccb8c4183608917c5c3d409fac39fefee82f7292d36f0d23e055913f45a52b85dd8a2052e9e129bb4d200f011f19483535a6e89a580c9b0003baf21462ece91a82cc38dbdcae60d9c54d":exp:2
|
||||
|
||||
ECJPAKE round two server: X not on curve
|
||||
5:hex:"410469d54ee85e90ce3f1246742de507e939e81d1dc1c5cb988b58c310c9fdd9524d93720b45541c83ee8841191da7ced86e3312d43623c1d63e74989aba4affd1ef4104077e8c31e20e6bedb760c13593e69f15be85c27d68cd09ccb8c4183608917c5c3d409fac39fefee82f7292d36f0d23e055913f45a52b85dd8a2052e9e129bb4d200f011f19483535a6e89a580c9b0003baf21462ece91a82cc38dbdcae60d9c54c":exp:4
|
||||
|
99
third_party/mbedtls/test/test_suite_hkdf.c
vendored
99
third_party/mbedtls/test/test_suite_hkdf.c
vendored
|
@ -39,25 +39,20 @@
|
|||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
#include "third_party/mbedtls/hkdf.h"
|
||||
|
||||
void test_test_hkdf( int md_alg, data_t *ikm, data_t *salt, data_t *info,
|
||||
data_t *expected_okm )
|
||||
data_t *expected_okm )
|
||||
{
|
||||
int ret;
|
||||
unsigned char okm[128] = { '\0' };
|
||||
|
||||
const mbedtls_md_info_t *md = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md != NULL );
|
||||
|
||||
TEST_ASSERT( expected_okm->len <= sizeof( okm ) );
|
||||
|
||||
ret = mbedtls_hkdf( md, salt->x, salt->len, ikm->x, ikm->len,
|
||||
info->x, info->len, okm, expected_okm->len );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
ASSERT_COMPARE( okm , expected_okm->len,
|
||||
expected_okm->x, expected_okm->len );
|
||||
exit:
|
||||
;
|
||||
}
|
||||
|
||||
void test_test_hkdf_wrapper( void ** params )
|
||||
|
@ -66,11 +61,11 @@ void test_test_hkdf_wrapper( void ** params )
|
|||
data_t data3 = {(uint8_t *) params[3], *( (uint32_t *) params[4] )};
|
||||
data_t data5 = {(uint8_t *) params[5], *( (uint32_t *) params[6] )};
|
||||
data_t data7 = {(uint8_t *) params[7], *( (uint32_t *) params[8] )};
|
||||
|
||||
test_test_hkdf( *( (int *) params[0] ), &data1, &data3, &data5, &data7 );
|
||||
}
|
||||
|
||||
void test_test_hkdf_extract( int md_alg, char *hex_ikm_string,
|
||||
char *hex_salt_string, char *hex_prk_string )
|
||||
char *hex_salt_string, char *hex_prk_string )
|
||||
{
|
||||
int ret;
|
||||
unsigned char *ikm = NULL;
|
||||
|
@ -78,22 +73,16 @@ void test_test_hkdf_extract( int md_alg, char *hex_ikm_string,
|
|||
unsigned char *prk = NULL;
|
||||
unsigned char *output_prk = NULL;
|
||||
size_t ikm_len, salt_len, prk_len, output_prk_len;
|
||||
|
||||
const mbedtls_md_info_t *md = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md != NULL );
|
||||
|
||||
output_prk_len = mbedtls_md_get_size( md );
|
||||
output_prk = mbedtls_calloc( 1, output_prk_len );
|
||||
|
||||
ikm = mbedtls_test_unhexify_alloc( hex_ikm_string, &ikm_len );
|
||||
salt = mbedtls_test_unhexify_alloc( hex_salt_string, &salt_len );
|
||||
prk = mbedtls_test_unhexify_alloc( hex_prk_string, &prk_len );
|
||||
|
||||
ret = mbedtls_hkdf_extract( md, salt, salt_len, ikm, ikm_len, output_prk );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
ASSERT_COMPARE( output_prk, output_prk_len, prk, prk_len );
|
||||
|
||||
exit:
|
||||
mbedtls_free(ikm);
|
||||
mbedtls_free(salt);
|
||||
|
@ -103,36 +92,34 @@ exit:
|
|||
|
||||
void test_test_hkdf_extract_wrapper( void ** params )
|
||||
{
|
||||
|
||||
test_test_hkdf_extract( *( (int *) params[0] ), (char *) params[1], (char *) params[2], (char *) params[3] );
|
||||
test_test_hkdf_extract( *( (int *) params[0] ),
|
||||
(char *) params[1],
|
||||
(char *) params[2],
|
||||
(char *) params[3] );
|
||||
}
|
||||
|
||||
void test_test_hkdf_expand( int md_alg, char *hex_info_string,
|
||||
char *hex_prk_string, char *hex_okm_string )
|
||||
{
|
||||
enum { OKM_LEN = 1024 };
|
||||
enum { OKM_LEN = 1024 };
|
||||
int ret;
|
||||
unsigned char *info = NULL;
|
||||
unsigned char *prk = NULL;
|
||||
unsigned char *okm = NULL;
|
||||
unsigned char *output_okm = NULL;
|
||||
size_t info_len, prk_len, okm_len;
|
||||
|
||||
const mbedtls_md_info_t *md = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md != NULL );
|
||||
|
||||
output_okm = mbedtls_calloc( OKM_LEN, 1 );
|
||||
|
||||
prk = mbedtls_test_unhexify_alloc( hex_prk_string, &prk_len );
|
||||
info = mbedtls_test_unhexify_alloc( hex_info_string, &info_len );
|
||||
okm = mbedtls_test_unhexify_alloc( hex_okm_string, &okm_len );
|
||||
TEST_ASSERT( prk_len == mbedtls_md_get_size( md ) );
|
||||
TEST_ASSERT( okm_len < OKM_LEN );
|
||||
|
||||
ret = mbedtls_hkdf_expand( md, prk, prk_len, info, info_len,
|
||||
output_okm, OKM_LEN );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
ASSERT_COMPARE( output_okm, okm_len, okm, okm_len );
|
||||
|
||||
exit:
|
||||
mbedtls_free(info);
|
||||
mbedtls_free(prk);
|
||||
|
@ -142,9 +129,12 @@ exit:
|
|||
|
||||
void test_test_hkdf_expand_wrapper( void ** params )
|
||||
{
|
||||
|
||||
test_test_hkdf_expand( *( (int *) params[0] ), (char *) params[1], (char *) params[2], (char *) params[3] );
|
||||
test_test_hkdf_expand( *( (int *) params[0] ),
|
||||
(char *) params[1],
|
||||
(char *) params[2],
|
||||
(char *) params[3] );
|
||||
}
|
||||
|
||||
void test_test_hkdf_extract_ret( int hash_len, int ret )
|
||||
{
|
||||
int output_ret;
|
||||
|
@ -153,28 +143,25 @@ void test_test_hkdf_extract_ret( int hash_len, int ret )
|
|||
unsigned char *prk = NULL;
|
||||
size_t salt_len, ikm_len;
|
||||
struct mbedtls_md_info_t fake_md_info;
|
||||
|
||||
memset( &fake_md_info, 0, sizeof( fake_md_info ) );
|
||||
fake_md_info.type = MBEDTLS_MD_NONE;
|
||||
fake_md_info.size = hash_len;
|
||||
|
||||
prk = mbedtls_calloc( MBEDTLS_MD_MAX_SIZE, 1 );
|
||||
salt_len = 0;
|
||||
ikm_len = 0;
|
||||
|
||||
output_ret = mbedtls_hkdf_extract( &fake_md_info, salt, salt_len,
|
||||
ikm, ikm_len, prk );
|
||||
TEST_ASSERT( output_ret == ret );
|
||||
|
||||
exit:
|
||||
mbedtls_free(prk);
|
||||
}
|
||||
|
||||
void test_test_hkdf_extract_ret_wrapper( void ** params )
|
||||
{
|
||||
|
||||
test_test_hkdf_extract_ret( *( (int *) params[0] ), *( (int *) params[1] ) );
|
||||
test_test_hkdf_extract_ret( *( (int *) params[0] ),
|
||||
*( (int *) params[1] ) );
|
||||
}
|
||||
|
||||
void test_test_hkdf_expand_ret( int hash_len, int prk_len, int okm_len, int ret )
|
||||
{
|
||||
int output_ret;
|
||||
|
@ -183,23 +170,17 @@ void test_test_hkdf_expand_ret( int hash_len, int prk_len, int okm_len, int ret
|
|||
unsigned char *okm = NULL;
|
||||
size_t info_len;
|
||||
struct mbedtls_md_info_t fake_md_info;
|
||||
|
||||
memset( &fake_md_info, 0, sizeof( fake_md_info ) );
|
||||
fake_md_info.type = MBEDTLS_MD_NONE;
|
||||
fake_md_info.size = hash_len;
|
||||
|
||||
info_len = 0;
|
||||
|
||||
if (prk_len > 0)
|
||||
prk = mbedtls_calloc( prk_len, 1 );
|
||||
|
||||
if (okm_len > 0)
|
||||
okm = mbedtls_calloc( okm_len, 1 );
|
||||
|
||||
output_ret = mbedtls_hkdf_expand( &fake_md_info, prk, prk_len,
|
||||
info, info_len, okm, okm_len );
|
||||
TEST_ASSERT( output_ret == ret );
|
||||
|
||||
exit:
|
||||
mbedtls_free(prk);
|
||||
mbedtls_free(okm);
|
||||
|
@ -207,15 +188,10 @@ exit:
|
|||
|
||||
void test_test_hkdf_expand_ret_wrapper( void ** params )
|
||||
{
|
||||
|
||||
test_test_hkdf_expand_ret( *( (int *) params[0] ), *( (int *) params[1] ), *( (int *) params[2] ), *( (int *) params[3] ) );
|
||||
}
|
||||
#endif /* MBEDTLS_HKDF_C */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Test dispatch code */
|
||||
|
||||
|
||||
/**
|
||||
* \brief Evaluates an expression/macro into its literal integer value.
|
||||
* For optimizing space for embedded targets each expression/macro
|
||||
|
@ -231,32 +207,20 @@ void test_test_hkdf_expand_ret_wrapper( void ** params )
|
|||
int get_expression( int32_t exp_id, int32_t * out_value )
|
||||
{
|
||||
int ret = KEY_VALUE_MAPPING_FOUND;
|
||||
|
||||
(void) exp_id;
|
||||
(void) out_value;
|
||||
|
||||
switch( exp_id )
|
||||
{
|
||||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
|
||||
case 0:
|
||||
{
|
||||
*out_value = MBEDTLS_ERR_HKDF_BAD_INPUT_DATA;
|
||||
}
|
||||
*out_value = MBEDTLS_ERR_HKDF_BAD_INPUT_DATA;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
{
|
||||
ret = KEY_VALUE_MAPPING_NOT_FOUND;
|
||||
}
|
||||
ret = KEY_VALUE_MAPPING_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Checks if the dependency i.e. the compile flag is set.
|
||||
* For optimizing space for embedded targets each dependency
|
||||
|
@ -271,14 +235,9 @@ int get_expression( int32_t exp_id, int32_t * out_value )
|
|||
int dep_check( int dep_id )
|
||||
{
|
||||
int ret = DEPENDENCY_NOT_SUPPORTED;
|
||||
|
||||
(void) dep_id;
|
||||
|
||||
switch( dep_id )
|
||||
{
|
||||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
|
||||
case 0:
|
||||
{
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
|
@ -298,14 +257,12 @@ int dep_check( int dep_id )
|
|||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Function pointer type for test function wrappers.
|
||||
*
|
||||
|
@ -321,7 +278,6 @@ int dep_check( int dep_id )
|
|||
*/
|
||||
typedef void (*TestWrapper_t)( void **param_array );
|
||||
|
||||
|
||||
/**
|
||||
* \brief Table of test function wrappers. Used by dispatch_test().
|
||||
* This table is populated by script:
|
||||
|
@ -331,41 +287,35 @@ typedef void (*TestWrapper_t)( void **param_array );
|
|||
TestWrapper_t test_funcs[] =
|
||||
{
|
||||
/* Function Id: 0 */
|
||||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
test_test_hkdf_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
/* Function Id: 1 */
|
||||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
test_test_hkdf_extract_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
/* Function Id: 2 */
|
||||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
test_test_hkdf_expand_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
/* Function Id: 3 */
|
||||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
test_test_hkdf_extract_ret_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
/* Function Id: 4 */
|
||||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
test_test_hkdf_expand_ret_wrapper,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -385,10 +335,8 @@ void execute_function_ptr(TestWrapper_t fp, void **params)
|
|||
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
mbedtls_test_enable_insecure_external_rng( );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
mbedtls_test_param_failed_location_record_t location_record;
|
||||
|
||||
if ( setjmp( mbedtls_test_param_failed_get_state_buf( ) ) == 0 )
|
||||
{
|
||||
fp( params );
|
||||
|
@ -401,12 +349,10 @@ void execute_function_ptr(TestWrapper_t fp, void **params)
|
|||
location_record.line,
|
||||
location_record.file );
|
||||
}
|
||||
|
||||
mbedtls_test_param_failed_reset_state( );
|
||||
#else
|
||||
fp( params );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
||||
mbedtls_test_mutex_usage_check( );
|
||||
#endif /* MBEDTLS_TEST_MUTEX_USAGE */
|
||||
|
@ -427,7 +373,6 @@ int dispatch_test( size_t func_idx, void ** params )
|
|||
{
|
||||
int ret = DISPATCH_TEST_SUCCESS;
|
||||
TestWrapper_t fp = NULL;
|
||||
|
||||
if ( func_idx < (int)( sizeof( test_funcs ) / sizeof( TestWrapper_t ) ) )
|
||||
{
|
||||
fp = test_funcs[func_idx];
|
||||
|
@ -440,11 +385,9 @@ int dispatch_test( size_t func_idx, void ** params )
|
|||
{
|
||||
ret = DISPATCH_TEST_FN_NOT_FOUND;
|
||||
}
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Checks if test function is supported in this build-time
|
||||
* configuration.
|
||||
|
@ -459,7 +402,6 @@ int check_test( size_t func_idx )
|
|||
{
|
||||
int ret = DISPATCH_TEST_SUCCESS;
|
||||
TestWrapper_t fp = NULL;
|
||||
|
||||
if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) )
|
||||
{
|
||||
fp = test_funcs[func_idx];
|
||||
|
@ -470,7 +412,6 @@ int check_test( size_t func_idx )
|
|||
{
|
||||
ret = DISPATCH_TEST_FN_NOT_FOUND;
|
||||
}
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ void test_hmac_drbg_no_reseed( int md_alg, data_t * entropy,
|
|||
/* Reset context for second run */
|
||||
mbedtls_hmac_drbg_free( &ctx );
|
||||
|
||||
TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( my_output, output->x, output->len ) == 0 );
|
||||
|
||||
/* And now the normal entropy-based variant */
|
||||
TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
|
||||
|
@ -256,7 +256,7 @@ void test_hmac_drbg_no_reseed( int md_alg, data_t * entropy,
|
|||
add1->x, add1->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
|
||||
add2->x, add2->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( my_output, output->x, output->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_hmac_drbg_free( &ctx );
|
||||
|
@ -297,7 +297,7 @@ void test_hmac_drbg_nopr( int md_alg, data_t * entropy, data_t * custom,
|
|||
TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
|
||||
add3->x, add3->len ) == 0 );
|
||||
|
||||
TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( my_output, output->x, output->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_hmac_drbg_free( &ctx );
|
||||
|
@ -338,7 +338,7 @@ void test_hmac_drbg_pr( int md_alg, data_t * entropy, data_t * custom,
|
|||
TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len,
|
||||
add2->x, add2->len ) == 0 );
|
||||
|
||||
TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( my_output, output->x, output->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_hmac_drbg_free( &ctx );
|
||||
|
|
|
@ -267,9 +267,8 @@ void test_pkcs1_v15_decode( int mode,
|
|||
if( expected_result == 0 )
|
||||
{
|
||||
TEST_ASSERT( output_length == expected_plaintext_length );
|
||||
TEST_ASSERT( memcmp( original + sizeof( N ) - output_length,
|
||||
final,
|
||||
output_length ) == 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( original + sizeof( N ) - output_length,
|
||||
final, output_length ) == 0 );
|
||||
}
|
||||
else if( expected_result == MBEDTLS_ERR_RSA_INVALID_PADDING ||
|
||||
expected_result == MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE )
|
||||
|
|
7
third_party/mbedtls/test/test_suite_pkcs5.c
vendored
7
third_party/mbedtls/test/test_suite_pkcs5.c
vendored
|
@ -40,24 +40,19 @@
|
|||
#if defined(MBEDTLS_PKCS5_C)
|
||||
#include "third_party/mbedtls/pkcs5.h"
|
||||
void test_pbkdf2_hmac( int hash, data_t * pw_str, data_t * salt_str,
|
||||
int it_cnt, int key_len, data_t * result_key_string )
|
||||
int it_cnt, int key_len, data_t * result_key_string )
|
||||
{
|
||||
mbedtls_md_context_t ctx;
|
||||
const mbedtls_md_info_t *info;
|
||||
|
||||
unsigned char key[100];
|
||||
|
||||
mbedtls_md_init( &ctx );
|
||||
|
||||
info = mbedtls_md_info_from_type( hash );
|
||||
TEST_ASSERT( info != NULL );
|
||||
TEST_ASSERT( mbedtls_md_setup( &ctx, info, 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_pkcs5_pbkdf2_hmac( &ctx, pw_str->x, pw_str->len, salt_str->x, salt_str->len,
|
||||
it_cnt, key_len, key ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( key, result_key_string->x,
|
||||
key_len, result_key_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_md_free( &ctx );
|
||||
}
|
||||
|
|
8
third_party/mbedtls/test/test_suite_random.c
vendored
8
third_party/mbedtls/test/test_suite_random.c
vendored
|
@ -85,7 +85,7 @@ void test_random_twice_with_ctr_drbg( )
|
|||
mbedtls_entropy_free( &entropy );
|
||||
|
||||
/* The two rounds must generate different random data. */
|
||||
TEST_ASSERT( memcmp( output1, output2, OUTPUT_SIZE ) != 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( output1, output2, OUTPUT_SIZE ) != 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_ctr_drbg_free( &drbg );
|
||||
|
@ -135,7 +135,7 @@ void test_random_twice_with_hmac_drbg( int md_type )
|
|||
mbedtls_entropy_free( &entropy );
|
||||
|
||||
/* The two rounds must generate different random data. */
|
||||
TEST_ASSERT( memcmp( output1, output2, OUTPUT_SIZE ) != 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( output1, output2, OUTPUT_SIZE ) != 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_hmac_drbg_free( &drbg );
|
||||
|
@ -171,7 +171,7 @@ void test_random_twice_with_psa_from_classic( )
|
|||
PSA_DONE( );
|
||||
|
||||
/* The two rounds must generate different random data. */
|
||||
TEST_ASSERT( memcmp( output1, output2, OUTPUT_SIZE ) != 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( output1, output2, OUTPUT_SIZE ) != 0 );
|
||||
|
||||
exit:
|
||||
PSA_DONE( );
|
||||
|
@ -205,7 +205,7 @@ void test_random_twice_with_psa_from_psa( )
|
|||
PSA_DONE( );
|
||||
|
||||
/* The two rounds must generate different random data. */
|
||||
TEST_ASSERT( memcmp( output1, output2, OUTPUT_SIZE ) != 0 );
|
||||
TEST_ASSERT( timingsafe_bcmp( output1, output2, OUTPUT_SIZE ) != 0 );
|
||||
|
||||
exit:
|
||||
PSA_DONE( );
|
||||
|
|
|
@ -425,7 +425,7 @@ int parse_crt_ext_cb( void *p_ctx, mbedtls_x509_crt const *crt, mbedtls_x509_buf
|
|||
return( parse_ret );
|
||||
}
|
||||
else if( new_oid != NULL && new_oid->tag == oid->tag && new_oid->len == oid->len &&
|
||||
memcmp( new_oid->p, oid->p, oid->len ) == 0 )
|
||||
timingsafe_bcmp( new_oid->p, oid->p, oid->len ) == 0 )
|
||||
return( 0 );
|
||||
else
|
||||
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue