Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/crypto/libcrypto adjust tests for 1.1



details:   https://anonhg.NetBSD.org/src/rev/58c43f2ad852
branches:  trunk
changeset: 359402:58c43f2ad852
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Feb 08 21:59:10 2018 +0000

description:
adjust tests for 1.1

diffstat:

 tests/crypto/libcrypto/Makefile         |   10 +-
 tests/crypto/libcrypto/Makefile.inc     |    6 +-
 tests/crypto/libcrypto/bf/Makefile      |    4 +-
 tests/crypto/libcrypto/bn/div/divtest.c |   46 ++
 tests/crypto/libcrypto/conf/test.c      |   98 +++++
 tests/crypto/libcrypto/ecdh/ecdhtest.c  |  576 ++++++++++++++++++++++++++++++++
 tests/crypto/libcrypto/threads/Makefile |    9 +-
 tests/crypto/libcrypto/x509v3/Makefile  |    3 +-
 8 files changed, 742 insertions(+), 10 deletions(-)

diffs (truncated from 826 to 300 lines):

diff -r f228e8c28d7a -r 58c43f2ad852 tests/crypto/libcrypto/Makefile
--- a/tests/crypto/libcrypto/Makefile   Thu Feb 08 21:57:23 2018 +0000
+++ b/tests/crypto/libcrypto/Makefile   Thu Feb 08 21:59:10 2018 +0000
@@ -1,13 +1,17 @@
-# $NetBSD: Makefile,v 1.11 2017/05/21 15:28:42 riastradh Exp $
+# $NetBSD: Makefile,v 1.12 2018/02/08 21:59:10 christos Exp $
 
 .include <bsd.own.mk>
 
-SUBDIR+=bf bn cast conf des dh dsa ec ecdh ecdsa engine evp hmac lhash \
-       md2 md4 md5 rand rc2 rc4 ripemd rsa sha sha1 srp threads x509v3
+SUBDIR+=bf bn cast conf des dh dsa ec ecdh ecdsa engine evp hmac \
+       md2 md4 md5 rand rc2 rc4 ripemd rsa sha1 srp threads
 
 SUBDIR+=idea mdc2
 SUBDIR+=rc5
 
+.if ${HAVE_OPENSSL} == 10
+SUBDIR += lhash sha x509v3
+.endif
+
 TESTSDIR=      ${TESTSBASE}/crypto/libcrypto
 
 TESTS_SH=      t_certs
diff -r f228e8c28d7a -r 58c43f2ad852 tests/crypto/libcrypto/Makefile.inc
--- a/tests/crypto/libcrypto/Makefile.inc       Thu Feb 08 21:57:23 2018 +0000
+++ b/tests/crypto/libcrypto/Makefile.inc       Thu Feb 08 21:59:10 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.6 2011/06/11 18:03:17 christos Exp $
+# $NetBSD: Makefile.inc,v 1.7 2018/02/08 21:59:10 christos Exp $
 
 .include <bsd.own.mk>
 .include "../Makefile.inc"
@@ -20,9 +20,11 @@
 
 CPPFLAGS+=     -DOPENSSL_FIPS
 CPPFLAGS+=     -I${OPENSSLSRC} -I${OPENSSLSRC}/crypto
+CPPFLAGS+=     -I${OPENSSLSRC}/include -I${OPENSSLSRC}/../include
+CPPFLAGS+=     -I${OPENSSLSRC}/crypto/include
 CRYPTODIST=    ${NETBSDSRCDIR}/crypto
 .include "${NETBSDSRCDIR}/crypto/Makefile.openssl"
-.PATH: ${OPENSSLSRC}/crypto/${HELPER_DIR}
+.PATH: ${OPENSSLSRC}/test ${OPENSSLSRC}/crypto/${HELPER_DIR}
 
 .include <bsd.test.mk>
 .include <bsd.prog.mk>
diff -r f228e8c28d7a -r 58c43f2ad852 tests/crypto/libcrypto/bf/Makefile
--- a/tests/crypto/libcrypto/bf/Makefile        Thu Feb 08 21:57:23 2018 +0000
+++ b/tests/crypto/libcrypto/bf/Makefile        Thu Feb 08 21:59:10 2018 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.1 2009/02/13 20:58:14 jmmv Exp $
+# $NetBSD: Makefile,v 1.2 2018/02/08 21:59:10 christos Exp $
 
 HELPER_NAME=   bftest
-HELPER_DIR=    bf
+HELPER_DIR=    test
 
 .include <bsd.init.mk>
diff -r f228e8c28d7a -r 58c43f2ad852 tests/crypto/libcrypto/bn/div/divtest.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/crypto/libcrypto/bn/div/divtest.c   Thu Feb 08 21:59:10 2018 +0000
@@ -0,0 +1,46 @@
+#include <openssl/bn.h>
+#include <openssl/rand.h>
+
+static int Rand(void)
+{
+    unsigned char x[2];
+    RAND_bytes(x, 2);
+    return (x[0] + 2 * x[1]);
+}
+
+static void bug(const char *m, BIGNUM *a, BIGNUM *b)
+{
+    printf("%s!\na=", m);
+    BN_print_fp(stdout, a);
+    printf("\nb=");
+    BN_print_fp(stdout, b);
+    printf("\n");
+    fflush(stdout);
+    exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+    BIGNUM *a = BN_new(), *b = BN_new(), *c = BN_new(), *d = BN_new(),
+        *C = BN_new(), *D = BN_new();
+    BN_RECP_CTX *recp = BN_RECP_CTX_new();
+    BN_CTX *ctx = BN_CTX_new();
+    int i = 0;
+
+    for (i = 0; i < 10000; i++) {
+        BN_pseudo_rand(a, Rand(), 0, 0);
+        BN_pseudo_rand(b, Rand(), 0, 0);
+        if (BN_is_zero(b))
+            continue;
+
+        BN_RECP_CTX_set(recp, b, ctx);
+        if (BN_div(C, D, a, b, ctx) != 1)
+            bug("BN_div failed", a, b);
+        if (BN_div_recp(c, d, a, recp, ctx) != 1)
+            bug("BN_div_recp failed", a, b);
+        else if (BN_cmp(c, C) != 0 || BN_cmp(c, C) != 0)
+            bug("mismatch", a, b);
+    }
+    exit(0);
+}
diff -r f228e8c28d7a -r 58c43f2ad852 tests/crypto/libcrypto/conf/test.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/crypto/libcrypto/conf/test.c        Thu Feb 08 21:59:10 2018 +0000
@@ -0,0 +1,98 @@
+/* crypto/conf/test.c */
+/* Copyright (C) 1995-1998 Eric Young (eay%cryptsoft.com@localhost)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay%cryptsoft.com@localhost).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to.  The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh%cryptsoft.com@localhost).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *    "This product includes cryptographic software written by
+ *     Eric Young (eay%cryptsoft.com@localhost)"
+ *    The word 'cryptographic' can be left out if the rouines from the library
+ *    being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ *    the apps directory (application code) you must include an acknowledgement:
+ *    "This product includes software written by Tim Hudson (tjh%cryptsoft.com@localhost)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed.  i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <openssl/conf.h>
+#include <openssl/err.h>
+
+int
+main(void)
+{
+    LHASH_OF(CONF_VALUE) *conf;
+    long eline;
+    char *s;
+
+#ifdef USE_WIN32
+    CONF_set_default_method(CONF_WIN32);
+#endif
+    conf = CONF_load(NULL, "ssleay.cnf", &eline);
+    if (conf == NULL) {
+        ERR_load_crypto_strings();
+        printf("unable to load configuration, line %ld\n", eline);
+        ERR_print_errors_fp(stderr);
+        exit(1);
+    }
+    lh_stats((_LHASH *)conf,stdout);
+    lh_node_stats((_LHASH *)conf,stdout);
+    lh_node_usage_stats((_LHASH *)conf,stdout);
+
+    s = CONF_get_string(conf, NULL, "init2");
+    printf("init2=%s\n", (s == NULL) ? "NULL" : s);
+
+    s = CONF_get_string(conf, NULL, "cipher1");
+    printf("cipher1=%s\n", (s == NULL) ? "NULL" : s);
+
+    s = CONF_get_string(conf, "s_client", "cipher1");
+    printf("s_client:cipher1=%s\n", (s == NULL) ? "NULL" : s);
+
+    printf("---------------------------- DUMP ------------------------\n");
+    CONF_dump_fp(conf, stdout);
+
+    exit(0);
+}
diff -r f228e8c28d7a -r 58c43f2ad852 tests/crypto/libcrypto/ecdh/ecdhtest.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/crypto/libcrypto/ecdh/ecdhtest.c    Thu Feb 08 21:59:10 2018 +0000
@@ -0,0 +1,576 @@
+/* crypto/ecdh/ecdhtest.c */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ *
+ * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
+ * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
+ * to the OpenSSL project.
+ *
+ * The ECC Code is licensed pursuant to the OpenSSL open source
+ * license provided below.
+ *
+ * The ECDH software is originally written by Douglas Stebila of
+ * Sun Microsystems Laboratories.
+ *
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2003 The OpenSSL Project.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgment:
+ *    "This product includes software developed by the OpenSSL Project
+ *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For written permission, please contact
+ *    openssl-core%openssl.org@localhost.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ *    nor may "OpenSSL" appear in their names without prior written
+ *    permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ *    acknowledgment:
+ *    "This product includes software developed by the OpenSSL Project
+ *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay%cryptsoft.com@localhost).  This product includes software written by Tim
+ * Hudson (tjh%cryptsoft.com@localhost).
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../e_os.h"
+
+#include <openssl/opensslconf.h> /* for OPENSSL_NO_ECDH */
+#include <openssl/crypto.h>
+#include <openssl/bio.h>
+#include <openssl/bn.h>
+#include <openssl/objects.h>
+#include <openssl/rand.h>
+#include <openssl/sha.h>
+#include <openssl/err.h>
+
+#ifdef OPENSSL_NO_ECDH
+int main(int argc, char *argv[])



Home | Main Index | Thread Index | Old Index