CVS commit: src/crypto/external/bsd/openssl/dist/test/testutil
Module Name:src Committed By: joerg Date: Mon Mar 23 22:21:34 UTC 2020 Modified Files: src/crypto/external/bsd/openssl/dist/test/testutil: format_output.c main.c output.h tests.c Log Message: Fix format string usage. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 \ src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c \ src/crypto/external/bsd/openssl/dist/test/testutil/main.c \ src/crypto/external/bsd/openssl/dist/test/testutil/tests.c cvs rdiff -u -r1.3 -r1.4 \ src/crypto/external/bsd/openssl/dist/test/testutil/output.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c diff -u src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c:1.4 src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c:1.5 --- src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c:1.4 Sun Mar 22 00:53:11 2020 +++ src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c Mon Mar 23 22:21:34 2020 @@ -31,9 +31,9 @@ static void test_diff_header(const char static void test_string_null_empty(const char *m, char c) { if (m == NULL) -test_printf_stderr("% 4s %c NULL\n", "", c); +test_printf_stderr("%4s %c NULL\n", "", c); else -test_printf_stderr("% 4u:%c ''\n", 0u, c); +test_printf_stderr("%4u:%c ''\n", 0u, c); } static void test_fail_string_common(const char *prefix, const char *file, @@ -94,18 +94,18 @@ static void test_fail_string_common(cons bdiff[i] = '\0'; } if (n1 == n2 && !diff) { -test_printf_stderr("% 4u: '%s'\n", cnt, n2 > n1 ? b2 : b1); +test_printf_stderr("%4u: '%s'\n", cnt, n2 > n1 ? b2 : b1); } else { if (cnt == 0 && (m1 == NULL || *m1 == '\0')) test_string_null_empty(m1, '-'); else if (n1 > 0) -test_printf_stderr("% 4u:- '%s'\n", cnt, b1); +test_printf_stderr("%4u:- '%s'\n", cnt, b1); if (cnt == 0 && (m2 == NULL || *m2 == '\0')) test_string_null_empty(m2, '+'); else if (n2 > 0) -test_printf_stderr("% 4u:+ '%s'\n", cnt, b2); +test_printf_stderr("%4u:+ '%s'\n", cnt, b2); if (diff && i > 0) -test_printf_stderr("% 4s%s\n", "", bdiff); +test_printf_stderr("%4s%s\n", "", bdiff); } m1 += n1; m2 += n2; @@ -410,7 +410,7 @@ void test_output_bignum(const char *name static void test_memory_null_empty(const unsigned char *m, char c) { if (m == NULL) -test_printf_stderr("% 4s %c%s\n", "", c, "NULL"); +test_printf_stderr("%4s %c%s\n", "", c, "NULL"); else test_printf_stderr("%04x %c%s\n", 0u, c, "empty"); } @@ -494,7 +494,7 @@ static void test_fail_memory_common(cons else if (n2 > 0) test_printf_stderr("%04x:+%s\n", cnt, b2); if (diff && i > 0) -test_printf_stderr("% 4s %s\n", "", bdiff); +test_printf_stderr("%4s %s\n", "", bdiff); } m1 += n1; m2 += n2; Index: src/crypto/external/bsd/openssl/dist/test/testutil/main.c diff -u src/crypto/external/bsd/openssl/dist/test/testutil/main.c:1.4 src/crypto/external/bsd/openssl/dist/test/testutil/main.c:1.5 --- src/crypto/external/bsd/openssl/dist/test/testutil/main.c:1.4 Sun Mar 22 00:53:11 2020 +++ src/crypto/external/bsd/openssl/dist/test/testutil/main.c Mon Mar 23 22:21:34 2020 @@ -25,7 +25,7 @@ static void check_arg_usage(void) for (i = 0; i < n; i++) if (!arg_used[i+1]) -test_printf_stderr("Warning ignored command-line argument %d: %s\n", +test_printf_stderr("Warning ignored command-line argument %zu: %s\n", i, args[i+1]); if (i < arg_count) test_printf_stderr("Warning arguments %zu and later unchecked\n", i); Index: src/crypto/external/bsd/openssl/dist/test/testutil/tests.c diff -u src/crypto/external/bsd/openssl/dist/test/testutil/tests.c:1.4 src/crypto/external/bsd/openssl/dist/test/testutil/tests.c:1.5 --- src/crypto/external/bsd/openssl/dist/test/testutil/tests.c:1.4 Sun Mar 22 00:53:11 2020 +++ src/crypto/external/bsd/openssl/dist/test/testutil/tests.c Mon Mar 23 22:21:34 2020 @@ -72,6 +72,7 @@ static void test_fail_message(const char const char *fmt, ...) PRINTF_FORMAT(8, 9); +PRINTF_FORMAT(8, 0) static void test_fail_message_va(const char *prefix, const char *file, int line, const char *type, const char *left, const char *right, Index: src/crypto/external/bsd/openssl/dist/test/testutil/output.h diff -u
CVS commit: src/crypto/external/bsd/openssl/dist/test/testutil
Module Name:src Committed By: joerg Date: Thu Oct 4 13:38:41 UTC 2018 Modified Files: src/crypto/external/bsd/openssl/dist/test/testutil: tests.c Log Message: Add missing format string annotation. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/crypto/external/bsd/openssl/dist/test/testutil/tests.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/external/bsd/openssl/dist/test/testutil/tests.c diff -u src/crypto/external/bsd/openssl/dist/test/testutil/tests.c:1.2 src/crypto/external/bsd/openssl/dist/test/testutil/tests.c:1.3 --- src/crypto/external/bsd/openssl/dist/test/testutil/tests.c:1.2 Sun Sep 23 13:33:03 2018 +++ src/crypto/external/bsd/openssl/dist/test/testutil/tests.c Thu Oct 4 13:38:41 2018 @@ -72,6 +72,7 @@ static void test_fail_message(const char const char *fmt, ...) PRINTF_FORMAT(8, 9); +PRINTF_FORMAT(8, 0) static void test_fail_message_va(const char *prefix, const char *file, int line, const char *type, const char *left, const char *right,
CVS commit: src/crypto/external/bsd/openssl/dist/test
Module Name:src Committed By: christos Date: Tue Oct 2 13:53:51 UTC 2018 Modified Files: src/crypto/external/bsd/openssl/dist/test: hmactest.c Log Message: Use hex string syntax to prevent overflow warnings for character constants >= 128. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/crypto/external/bsd/openssl/dist/test/hmactest.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/external/bsd/openssl/dist/test/hmactest.c diff -u src/crypto/external/bsd/openssl/dist/test/hmactest.c:1.3 src/crypto/external/bsd/openssl/dist/test/hmactest.c:1.4 --- src/crypto/external/bsd/openssl/dist/test/hmactest.c:1.3 Sun Sep 23 09:33:03 2018 +++ src/crypto/external/bsd/openssl/dist/test/hmactest.c Tue Oct 2 09:53:51 2018 @@ -38,10 +38,8 @@ static struct test_st { "e9139d1e6ee064ef8cf514fc7dc83e86", }, { -{ -0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, -0x0b, 0x0b, 0x0b, 0x0b, 0x0b, -}, 16, "Hi There", 8, +"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", +16, "Hi There", 8, "9294727a3638bb1c13f48ef8158bfc9d", }, { @@ -49,10 +47,8 @@ static struct test_st { "750c783e6ab0b503eaa86e310a5db738", }, { -{ -0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, -0xaa, 0xaa, 0xaa, 0xaa, 0xaa, -}, 16, { +"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", +16, { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
CVS commit: src/crypto/external/bsd/openssl/dist/test/testutil
Module Name:src Committed By: christos Date: Sun Sep 30 19:23:13 UTC 2018 Modified Files: src/crypto/external/bsd/openssl/dist/test/testutil: format_output.c main.c output.h Log Message: Annotate format functions and fix format errors. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c cvs rdiff -u -r1.1.1.1 -r1.2 \ src/crypto/external/bsd/openssl/dist/test/testutil/main.c \ src/crypto/external/bsd/openssl/dist/test/testutil/output.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c diff -u src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c:1.2 src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c:1.3 --- src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c:1.2 Sun Sep 23 09:33:03 2018 +++ src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c Sun Sep 30 15:23:13 2018 @@ -31,9 +31,9 @@ static void test_diff_header(const char static void test_string_null_empty(const char *m, char c) { if (m == NULL) -test_printf_stderr("% 4s %c NULL\n", "", c); +test_printf_stderr("%4s %c NULL\n", "", c); else -test_printf_stderr("% 4u:%c ''\n", 0u, c); +test_printf_stderr("%4u:%c ''\n", 0u, c); } static void test_fail_string_common(const char *prefix, const char *file, @@ -94,18 +94,18 @@ static void test_fail_string_common(cons bdiff[i] = '\0'; } if (n1 == n2 && !diff) { -test_printf_stderr("% 4u: '%s'\n", cnt, n2 > n1 ? b2 : b1); +test_printf_stderr("%4u: '%s'\n", cnt, n2 > n1 ? b2 : b1); } else { if (cnt == 0 && (m1 == NULL || *m1 == '\0')) test_string_null_empty(m1, '-'); else if (n1 > 0) -test_printf_stderr("% 4u:- '%s'\n", cnt, b1); +test_printf_stderr("%4u:- '%s'\n", cnt, b1); if (cnt == 0 && (m2 == NULL || *m2 == '\0')) test_string_null_empty(m2, '+'); else if (n2 > 0) -test_printf_stderr("% 4u:+ '%s'\n", cnt, b2); +test_printf_stderr("%4u:+ '%s'\n", cnt, b2); if (diff && i > 0) -test_printf_stderr("% 4s%s\n", "", bdiff); +test_printf_stderr("%4s%s\n", "", bdiff); } m1 += n1; m2 += n2; @@ -410,7 +410,7 @@ void test_output_bignum(const char *name static void test_memory_null_empty(const unsigned char *m, char c) { if (m == NULL) -test_printf_stderr("% 4s %c%s\n", "", c, "NULL"); +test_printf_stderr("%4s %c%s\n", "", c, "NULL"); else test_printf_stderr("%04x %c%s\n", 0u, c, "empty"); } @@ -494,7 +494,7 @@ static void test_fail_memory_common(cons else if (n2 > 0) test_printf_stderr("%04x:+%s\n", cnt, b2); if (diff && i > 0) -test_printf_stderr("% 4s %s\n", "", bdiff); +test_printf_stderr("%4s %s\n", "", bdiff); } m1 += n1; m2 += n2; Index: src/crypto/external/bsd/openssl/dist/test/testutil/main.c diff -u src/crypto/external/bsd/openssl/dist/test/testutil/main.c:1.1.1.1 src/crypto/external/bsd/openssl/dist/test/testutil/main.c:1.2 --- src/crypto/external/bsd/openssl/dist/test/testutil/main.c:1.1.1.1 Sun Sep 23 09:17:35 2018 +++ src/crypto/external/bsd/openssl/dist/test/testutil/main.c Sun Sep 30 15:23:13 2018 @@ -25,7 +25,7 @@ static void check_arg_usage(void) for (i = 0; i < n; i++) if (!arg_used[i+1]) -test_printf_stderr("Warning ignored command-line argument %d: %s\n", +test_printf_stderr("Warning ignored command-line argument %zu: %s\n", i, args[i+1]); if (i < arg_count) test_printf_stderr("Warning arguments %zu and later unchecked\n", i); Index: src/crypto/external/bsd/openssl/dist/test/testutil/output.h diff -u src/crypto/external/bsd/openssl/dist/test/testutil/output.h:1.1.1.1 src/crypto/external/bsd/openssl/dist/test/testutil/output.h:1.2 --- src/crypto/external/bsd/openssl/dist/test/testutil/output.h:1.1.1.1 Sun Sep 23 09:17:35 2018 +++ src/crypto/external/bsd/openssl/dist/test/testutil/output.h Sun Sep 30 15:23:13 2018 @@ -10,8 +10,25 @@ #ifndef HEADER_TU_OUTPUT_H # define HEADER_TU_OUTPUT_H -#include +# include +# define ossl_test__attr__(x) +# if defined(__GNUC__) && defined(__STDC_VERSION__) \ +&& !defined(__APPLE__) +/* + * Because we support the 'z' modifier, which made its appearance in C99, + * we can't use __attribute__ with pre C99 dialects. + */ +# if __STDC_VERSION__ >= 199901L +# undef ossl_test__attr__ +# define ossl_test__attr__ __attribute__ +# if __GNUC__*10 +
CVS commit: src/crypto/external/bsd/openssl/dist/test
Module Name:src Committed By: christos Date: Tue Feb 13 17:39:38 UTC 2018 Added Files: src/crypto/external/bsd/openssl/dist/test: constant_time_test.c evp_extra_test.c heartbeat_test.c Log Message: add missing test files added in the vendor branch. To generate a diff of this commit: cvs rdiff -u -r0 -r1.3 \ src/crypto/external/bsd/openssl/dist/test/constant_time_test.c \ src/crypto/external/bsd/openssl/dist/test/evp_extra_test.c cvs rdiff -u -r0 -r1.4 \ src/crypto/external/bsd/openssl/dist/test/heartbeat_test.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/crypto/external/bsd/openssl/dist/test/constant_time_test.c diff -u /dev/null src/crypto/external/bsd/openssl/dist/test/constant_time_test.c:1.3 --- /dev/null Tue Feb 13 12:39:38 2018 +++ src/crypto/external/bsd/openssl/dist/test/constant_time_test.c Tue Feb 13 12:39:38 2018 @@ -0,0 +1,268 @@ +/* + * Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "internal/constant_time_locl.h" +#include "e_os.h" + +#include +#include +#include + +static const unsigned int CONSTTIME_TRUE = (unsigned)(~0); +static const unsigned int CONSTTIME_FALSE = 0; +static const unsigned char CONSTTIME_TRUE_8 = 0xff; +static const unsigned char CONSTTIME_FALSE_8 = 0; + +static int test_binary_op(unsigned int (*op) (unsigned int a, unsigned int b), + const char *op_name, unsigned int a, unsigned int b, + int is_true) +{ +unsigned c = op(a, b); +if (is_true && c != CONSTTIME_TRUE) { +fprintf(stderr, "Test failed for %s(%du, %du): expected %du " +"(TRUE), got %du\n", op_name, a, b, CONSTTIME_TRUE, c); +return 1; +} else if (!is_true && c != CONSTTIME_FALSE) { +fprintf(stderr, "Test failed for %s(%du, %du): expected %du " +"(FALSE), got %du\n", op_name, a, b, CONSTTIME_FALSE, c); +return 1; +} +return 0; +} + +static int test_binary_op_8(unsigned +char (*op) (unsigned int a, unsigned int b), +const char *op_name, unsigned int a, +unsigned int b, int is_true) +{ +unsigned char c = op(a, b); +if (is_true && c != CONSTTIME_TRUE_8) { +fprintf(stderr, "Test failed for %s(%du, %du): expected %u " +"(TRUE), got %u\n", op_name, a, b, CONSTTIME_TRUE_8, c); +return 1; +} else if (!is_true && c != CONSTTIME_FALSE_8) { +fprintf(stderr, "Test failed for %s(%du, %du): expected %u " +"(FALSE), got %u\n", op_name, a, b, CONSTTIME_FALSE_8, c); +return 1; +} +return 0; +} + +static int test_is_zero(unsigned int a) +{ +unsigned int c = constant_time_is_zero(a); +if (a == 0 && c != CONSTTIME_TRUE) { +fprintf(stderr, "Test failed for constant_time_is_zero(%du): " +"expected %du (TRUE), got %du\n", a, CONSTTIME_TRUE, c); +return 1; +} else if (a != 0 && c != CONSTTIME_FALSE) { +fprintf(stderr, "Test failed for constant_time_is_zero(%du): " +"expected %du (FALSE), got %du\n", a, CONSTTIME_FALSE, c); +return 1; +} +return 0; +} + +static int test_is_zero_8(unsigned int a) +{ +unsigned char c = constant_time_is_zero_8(a); +if (a == 0 && c != CONSTTIME_TRUE_8) { +fprintf(stderr, "Test failed for constant_time_is_zero(%du): " +"expected %u (TRUE), got %u\n", a, CONSTTIME_TRUE_8, c); +return 1; +} else if (a != 0 && c != CONSTTIME_FALSE) { +fprintf(stderr, "Test failed for constant_time_is_zero(%du): " +"expected %u (FALSE), got %u\n", a, CONSTTIME_FALSE_8, c); +return 1; +} +return 0; +} + +static int test_select(unsigned int a, unsigned int b) +{ +unsigned int selected = constant_time_select(CONSTTIME_TRUE, a, b); +if (selected != a) { +fprintf(stderr, "Test failed for constant_time_select(%du, %du," +"%du): expected %du(first value), got %du\n", +CONSTTIME_TRUE, a, b, a, selected); +return 1; +} +selected = constant_time_select(CONSTTIME_FALSE, a, b); +if (selected != b) { +fprintf(stderr, "Test failed for constant_time_select(%du, %du," +"%du): expected %du(second value), got %du\n", +CONSTTIME_FALSE, a, b, b, selected); +return 1; +} +return 0; +} + +static int test_select_8(unsigned char a, unsigned char b) +{ +unsigned char selected = constant_time_select_8(CONSTTIME_TRUE_8, a, b); +