Update 1.1.2

This commit is contained in:
2018-09-12 08:14:17 +09:00
parent a8ed1c4cb9
commit 648f7916df
135 changed files with 688 additions and 233 deletions
+173
View File
@@ -0,0 +1,173 @@
/*
* Copyright 2017-2018 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 <stdio.h>
#include <string.h>
#include <openssl/rand.h>
#include <openssl/asn1t.h>
#include "internal/numbers.h"
#include "testutil.h"
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wunused-function"
#endif
#ifdef __clang__
# pragma clang diagnostic ignored "-Wunused-function"
#endif
/* Badly coded ASN.1 INTEGER zero wrapped in a sequence */
static unsigned char t_invalid_zero[] = {
0x30, 0x02, /* SEQUENCE tag + length */
0x02, 0x00 /* INTEGER tag + length */
};
#if OPENSSL_API_COMPAT < 0x10200000L
/* LONG case ************************************************************* */
typedef struct {
long test_long;
} ASN1_LONG_DATA;
ASN1_SEQUENCE(ASN1_LONG_DATA) = {
ASN1_EMBED(ASN1_LONG_DATA, test_long, LONG),
} static_ASN1_SEQUENCE_END(ASN1_LONG_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_LONG_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_LONG_DATA)
static int test_long(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_LONG_DATA *dectst =
d2i_ASN1_LONG_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_LONG_DATA_free(dectst);
return 1;
}
#endif
/* INT32 case ************************************************************* */
typedef struct {
int32_t test_int32;
} ASN1_INT32_DATA;
ASN1_SEQUENCE(ASN1_INT32_DATA) = {
ASN1_EMBED(ASN1_INT32_DATA, test_int32, INT32),
} static_ASN1_SEQUENCE_END(ASN1_INT32_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_INT32_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_INT32_DATA)
static int test_int32(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_INT32_DATA *dectst =
d2i_ASN1_INT32_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_INT32_DATA_free(dectst);
return 1;
}
/* UINT32 case ************************************************************* */
typedef struct {
uint32_t test_uint32;
} ASN1_UINT32_DATA;
ASN1_SEQUENCE(ASN1_UINT32_DATA) = {
ASN1_EMBED(ASN1_UINT32_DATA, test_uint32, UINT32),
} static_ASN1_SEQUENCE_END(ASN1_UINT32_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_UINT32_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_UINT32_DATA)
static int test_uint32(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_UINT32_DATA *dectst =
d2i_ASN1_UINT32_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_UINT32_DATA_free(dectst);
return 1;
}
/* INT64 case ************************************************************* */
typedef struct {
int64_t test_int64;
} ASN1_INT64_DATA;
ASN1_SEQUENCE(ASN1_INT64_DATA) = {
ASN1_EMBED(ASN1_INT64_DATA, test_int64, INT64),
} static_ASN1_SEQUENCE_END(ASN1_INT64_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_INT64_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_INT64_DATA)
static int test_int64(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_INT64_DATA *dectst =
d2i_ASN1_INT64_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_INT64_DATA_free(dectst);
return 1;
}
/* UINT64 case ************************************************************* */
typedef struct {
uint64_t test_uint64;
} ASN1_UINT64_DATA;
ASN1_SEQUENCE(ASN1_UINT64_DATA) = {
ASN1_EMBED(ASN1_UINT64_DATA, test_uint64, UINT64),
} static_ASN1_SEQUENCE_END(ASN1_UINT64_DATA)
IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_UINT64_DATA)
IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_UINT64_DATA)
static int test_uint64(void)
{
const unsigned char *p = t_invalid_zero;
ASN1_UINT64_DATA *dectst =
d2i_ASN1_UINT64_DATA(NULL, &p, sizeof(t_invalid_zero));
if (dectst == NULL)
return 0; /* Fail */
ASN1_UINT64_DATA_free(dectst);
return 1;
}
int setup_tests(void)
{
#if OPENSSL_API_COMPAT < 0x10200000L
ADD_TEST(test_long);
#endif
ADD_TEST(test_int32);
ADD_TEST(test_uint32);
ADD_TEST(test_int64);
ADD_TEST(test_uint64);
return 1;
}
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 1999-2018 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
+5 -1
View File
@@ -44,7 +44,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
bio_callback_test \
bioprinttest sslapitest dtlstest sslcorrupttest bio_enc_test \
pkey_meth_test pkey_meth_kdf_test uitest cipherbytes_test \
asn1_encode_test asn1_string_table_test \
asn1_encode_test asn1_decode_test asn1_string_table_test \
x509_time_test x509_dup_cert_test x509_check_cert_pkey_test \
recordlentest drbgtest sslbuffertest \
recordlentest drbgtest drbg_cavs_test sslbuffertest \
@@ -410,6 +410,10 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
INCLUDE[asn1_encode_test]=../include
DEPEND[asn1_encode_test]=../libcrypto libtestutil.a
SOURCE[asn1_decode_test]=asn1_decode_test.c
INCLUDE[asn1_decode_test]=../include
DEPEND[asn1_decode_test]=../libcrypto libtestutil.a
SOURCE[asn1_string_table_test]=asn1_string_table_test.c
INCLUDE[asn1_string_table_test]=../include
DEPEND[asn1_string_table_test]=../libcrypto libtestutil.a
+38 -28
View File
@@ -26,10 +26,10 @@ static int cb(int p, int n, BN_GENCB *arg);
static int dh_test(void)
{
DH *dh;
BIGNUM *p, *q, *g;
DH *dh = NULL;
BIGNUM *p = NULL, *q = NULL, *g = NULL;
const BIGNUM *p2, *q2, *g2;
BIGNUM *priv_key;
BIGNUM *priv_key = NULL;
const BIGNUM *pub_key2, *priv_key2;
BN_GENCB *_cb = NULL;
DH *a = NULL;
@@ -49,7 +49,7 @@ static int dh_test(void)
|| !TEST_ptr(q = BN_new())
|| !TEST_ptr(g = BN_new())
|| !TEST_ptr(priv_key = BN_new()))
goto err;
goto err1;
/*
* I) basic tests
@@ -60,40 +60,40 @@ static int dh_test(void)
|| !TEST_true(BN_set_word(q, 2039L))
|| !TEST_true(BN_set_word(g, 3L))
|| !TEST_true(DH_set0_pqg(dh, p, q, g)))
goto err;
goto err1;
/* test the combined getter for p, q, and g */
DH_get0_pqg(dh, &p2, &q2, &g2);
if (!TEST_ptr_eq(p2, p)
|| !TEST_ptr_eq(q2, q)
|| !TEST_ptr_eq(g2, g))
goto err;
goto err2;
/* test the simple getters for p, q, and g */
if (!TEST_ptr_eq(DH_get0_p(dh), p2)
|| !TEST_ptr_eq(DH_get0_q(dh), q2)
|| !TEST_ptr_eq(DH_get0_g(dh), g2))
goto err;
goto err2;
/* set the private key only*/
if (!TEST_true(BN_set_word(priv_key, 1234L))
|| !TEST_true(DH_set0_key(dh, NULL, priv_key)))
goto err;
goto err2;
/* test the combined getter for pub_key and priv_key */
DH_get0_key(dh, &pub_key2, &priv_key2);
if (!TEST_ptr_eq(pub_key2, NULL)
|| !TEST_ptr_eq(priv_key2, priv_key))
goto err;
goto err3;
/* test the simple getters for pub_key and priv_key */
if (!TEST_ptr_eq(DH_get0_pub_key(dh), pub_key2)
|| !TEST_ptr_eq(DH_get0_priv_key(dh), priv_key2))
goto err;
goto err3;
/* now generate a key pair ... */
if (!DH_generate_key(dh))
goto err;
goto err3;
/* ... and check whether the private key was reused: */
@@ -101,14 +101,14 @@ static int dh_test(void)
DH_get0_key(dh, &pub_key2, &priv_key2);
if (!TEST_ptr(pub_key2)
|| !TEST_ptr_eq(priv_key2, priv_key))
goto err;
goto err3;
/* test it the simple getters for pub_key and priv_key */
if (!TEST_ptr_eq(DH_get0_pub_key(dh), pub_key2)
|| !TEST_ptr_eq(DH_get0_priv_key(dh), priv_key2))
goto err;
goto err3;
/* check whether the public key was calculated correclty */
/* check whether the public key was calculated correctly */
TEST_uint_eq(BN_get_word(pub_key2), 3331L);
/*
@@ -117,32 +117,32 @@ static int dh_test(void)
/* generate a DH group ... */
if (!TEST_ptr(_cb = BN_GENCB_new()))
goto err;
goto err3;
BN_GENCB_set(_cb, &cb, NULL);
if (!TEST_ptr(a = DH_new())
|| !TEST_true(DH_generate_parameters_ex(a, 64,
DH_GENERATOR_5, _cb)))
goto err;
goto err3;
/* ... and check whether it is valid */
if (!DH_check(a, &i))
goto err;
goto err3;
if (!TEST_false(i & DH_CHECK_P_NOT_PRIME)
|| !TEST_false(i & DH_CHECK_P_NOT_SAFE_PRIME)
|| !TEST_false(i & DH_UNABLE_TO_CHECK_GENERATOR)
|| !TEST_false(i & DH_NOT_SUITABLE_GENERATOR))
goto err;
goto err3;
DH_get0_pqg(a, &ap, NULL, &ag);
/* now create another copy of the DH group for the peer */
if (!TEST_ptr(b = DH_new()))
goto err;
goto err3;
if (!TEST_ptr(bp = BN_dup(ap))
|| !TEST_ptr(bg = BN_dup(ag))
|| !TEST_true(DH_set0_pqg(b, bp, NULL, bg)))
goto err;
goto err3;
bp = bg = NULL;
/*
@@ -150,43 +150,53 @@ static int dh_test(void)
*/
if (!DH_generate_key(a))
goto err;
goto err3;
DH_get0_key(a, &apub_key, NULL);
if (!DH_generate_key(b))
goto err;
goto err3;
DH_get0_key(b, &bpub_key, &bpriv_key);
/* Also test with a private-key-only copy of |b|. */
if (!TEST_ptr(c = DHparams_dup(b))
|| !TEST_ptr(cpriv_key = BN_dup(bpriv_key))
|| !TEST_true(DH_set0_key(c, NULL, cpriv_key)))
goto err;
goto err3;
cpriv_key = NULL;
alen = DH_size(a);
if (!TEST_ptr(abuf = OPENSSL_malloc(alen))
|| !TEST_true((aout = DH_compute_key(abuf, bpub_key, a)) != -1))
goto err;
goto err3;
blen = DH_size(b);
if (!TEST_ptr(bbuf = OPENSSL_malloc(blen))
|| !TEST_true((bout = DH_compute_key(bbuf, apub_key, b)) != -1))
goto err;
goto err3;
clen = DH_size(c);
if (!TEST_ptr(cbuf = OPENSSL_malloc(clen))
|| !TEST_true((cout = DH_compute_key(cbuf, apub_key, c)) != -1))
goto err;
goto err3;
if (!TEST_true(aout >= 4)
|| !TEST_mem_eq(abuf, aout, bbuf, bout)
|| !TEST_mem_eq(abuf, aout, cbuf, cout))
goto err;
goto err3;
ret = 1;
goto success;
err:
err1:
/* an error occurred before p,q,g were assigned to dh */
BN_free(p);
BN_free(q);
BN_free(g);
err2:
/* an error occured before priv_key was assigned to dh */
BN_free(priv_key);
err3:
success:
OPENSSL_free(abuf);
OPENSSL_free(bbuf);
OPENSSL_free(cbuf);
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL licenses, (the "License");
* you may not use this file except in compliance with the License.
+24 -19
View File
@@ -855,27 +855,32 @@ static int test_EVP_PKEY_check(int i)
p = input;
if (type == 0 &&
(!TEST_ptr(pkey = d2i_AutoPrivateKey(NULL, &p, input_len))
|| !TEST_ptr_eq(p, input + input_len)
|| !TEST_int_eq(EVP_PKEY_id(pkey), expected_id)))
goto done;
switch (type) {
case 0:
if (!TEST_ptr(pkey = d2i_AutoPrivateKey(NULL, &p, input_len))
|| !TEST_ptr_eq(p, input + input_len)
|| !TEST_int_eq(EVP_PKEY_id(pkey), expected_id))
goto done;
break;
#ifndef OPENSSL_NO_EC
if (type == 1 &&
(!TEST_ptr(pubkey = BIO_new_mem_buf(input, input_len))
|| !TEST_ptr(eckey = d2i_EC_PUBKEY_bio(pubkey, NULL))
|| !TEST_ptr(pkey = EVP_PKEY_new())
|| !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey))))
goto done;
if (type == 2 &&
(!TEST_ptr(eckey = d2i_ECParameters(NULL, &p, input_len))
|| !TEST_ptr_eq(p, input + input_len)
|| !TEST_ptr(pkey = EVP_PKEY_new())
|| !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey))))
goto done;
case 1:
if (!TEST_ptr(pubkey = BIO_new_mem_buf(input, input_len))
|| !TEST_ptr(eckey = d2i_EC_PUBKEY_bio(pubkey, NULL))
|| !TEST_ptr(pkey = EVP_PKEY_new())
|| !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey)))
goto done;
break;
case 2:
if (!TEST_ptr(eckey = d2i_ECParameters(NULL, &p, input_len))
|| !TEST_ptr_eq(p, input + input_len)
|| !TEST_ptr(pkey = EVP_PKEY_new())
|| !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey)))
goto done;
break;
#endif
default:
return 0;
}
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new(pkey, NULL)))
goto done;
+22 -1
View File
@@ -73,6 +73,8 @@ static KEY_LIST *public_keys;
static int find_key(EVP_PKEY **ppk, const char *name, KEY_LIST *lst);
static int parse_bin(const char *value, unsigned char **buf, size_t *buflen);
static int pkey_test_ctrl(EVP_TEST *t, EVP_PKEY_CTX *pctx,
const char *value);
/*
* Compare two memory regions for equality, returning zero if they differ.
@@ -843,6 +845,8 @@ typedef struct mac_data_st {
/* Expected output */
unsigned char *output;
size_t output_len;
/* Collection of controls */
STACK_OF(OPENSSL_STRING) *controls;
} MAC_DATA;
static int mac_test_init(EVP_TEST *t, const char *alg)
@@ -878,14 +882,22 @@ static int mac_test_init(EVP_TEST *t, const char *alg)
mdat = OPENSSL_zalloc(sizeof(*mdat));
mdat->type = type;
mdat->controls = sk_OPENSSL_STRING_new_null();
t->data = mdat;
return 1;
}
/* Because OPENSSL_free is a macro, it can't be passed as a function pointer */
static void openssl_free(char *m)
{
OPENSSL_free(m);
}
static void mac_test_cleanup(EVP_TEST *t)
{
MAC_DATA *mdat = t->data;
sk_OPENSSL_STRING_pop_free(mdat->controls, openssl_free);
OPENSSL_free(mdat->alg);
OPENSSL_free(mdat->key);
OPENSSL_free(mdat->input);
@@ -909,6 +921,9 @@ static int mac_test_parse(EVP_TEST *t,
return parse_bin(value, &mdata->input, &mdata->input_len);
if (strcmp(keyword, "Output") == 0)
return parse_bin(value, &mdata->output, &mdata->output_len);
if (strcmp(keyword, "Ctrl") == 0)
return sk_OPENSSL_STRING_push(mdata->controls,
OPENSSL_strdup(value)) != 0;
return 0;
}
@@ -921,6 +936,7 @@ static int mac_test_run(EVP_TEST *t)
const EVP_MD *md = NULL;
unsigned char *got = NULL;
size_t got_len;
int i;
#ifdef OPENSSL_NO_DES
if (expected->alg != NULL && strstr(expected->alg, "DES") != NULL) {
@@ -955,7 +971,12 @@ static int mac_test_run(EVP_TEST *t)
t->err = "DIGESTSIGNINIT_ERROR";
goto err;
}
for (i = 0; i < sk_OPENSSL_STRING_num(expected->controls); i++)
if (!pkey_test_ctrl(t, pctx,
sk_OPENSSL_STRING_value(expected->controls, i))) {
t->err = "EVPPKEYCTXCTRL_ERROR";
goto err;
}
if (!EVP_DigestSignUpdate(mctx, expected->input, expected->input_len)) {
t->err = "DIGESTSIGNUPDATE_ERROR";
goto err;
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2017-2018 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
+12
View File
@@ -0,0 +1,12 @@
#! /usr/bin/env perl
# Copyright 2017-2018 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
use OpenSSL::Test::Simple;
simple_test("test_asn1_decode", "asn1_decode_test");
+1 -1
View File
@@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2015-2018 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
+1 -1
View File
@@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2015-2018 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
+1 -1
View File
@@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2015-2018 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
+2 -1
View File
@@ -1,5 +1,5 @@
#
# Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2001-2018 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
@@ -1184,6 +1184,7 @@ Key = 0000000000000000000000000000000000000000000000000000000000000000
IV = 00000000000000000000000000000000
Plaintext = 0000000000000000000000000000000000000000000000000000000000000000
Ciphertext = 917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e
Result = CIPHERUPDATE_ERROR
Cipher = aes-128-xts
Key = 1111111111111111111111111111111122222222222222222222222222222222
+33 -1
View File
@@ -1,5 +1,5 @@
#
# Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2001-2018 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
@@ -128,6 +128,38 @@ Key = 000102030405060708090A0B0C0D0E0F
Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E
Output = 5150d1772f50834a503e069a973fbd7c
# SIPHASH - default values: 2,4 rounds, explicit 8-byte mac
MAC = SipHash
Ctrl = digestsize:8
Key = 000102030405060708090A0B0C0D0E0F
Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E
Output = B96AB0B9D449A78A
# SIPHASH - default values: 2,4 rounds, explicit 16-byte mac
MAC = SipHash
Ctrl = digestsize:16
Key = 000102030405060708090A0B0C0D0E0F
Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E
Output = 5150d1772f50834a503e069a973fbd7c
# SIPHASH - default values: 2,4 rounds, explicit 16-byte mac (set as 0)
MAC = SipHash
Ctrl = digestsize:0
Key = 000102030405060708090A0B0C0D0E0F
Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E
Output = 5150d1772f50834a503e069a973fbd7c
# SIPHASH - default values: 2,4 rounds, explicit 13-byte mac (invalid size)
MAC = SipHash
Ctrl = digestsize:13
Key = 000102030405060708090A0B0C0D0E0F
Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E
Output = 5150d1772f50834a503e069a973fbd7c
Title = HMAC tests (from RFC2104 and others)
MAC = HMAC
+1 -1
View File
@@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2017 BaishanCloud. All rights reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2015-2018 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
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2015-2018 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
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2017 BaishanCloud. All rights reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
+15 -8
View File
@@ -196,7 +196,8 @@ static int test_siphash(int idx)
for (i = 0; i < inlen; i++)
in[i] = (unsigned char)i;
if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0)))
if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen))
|| !TEST_true(SipHash_Init(&siphash, key, 0, 0)))
return 0;
SipHash_Update(&siphash, in, inlen);
if (!TEST_true(SipHash_Final(&siphash, out, expectedlen))
@@ -204,7 +205,8 @@ static int test_siphash(int idx)
return 0;
if (inlen > 16) {
if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0)))
if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen))
|| !TEST_true(SipHash_Init(&siphash, key, 0, 0)))
return 0;
SipHash_Update(&siphash, in, 1);
SipHash_Update(&siphash, in+1, inlen-1);
@@ -220,7 +222,8 @@ static int test_siphash(int idx)
if (inlen > 32) {
size_t half = inlen / 2;
if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0)))
if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen))
|| !TEST_true(SipHash_Init(&siphash, key, 0, 0)))
return 0;
SipHash_Update(&siphash, in, half);
SipHash_Update(&siphash, in+half, inlen-half);
@@ -233,7 +236,8 @@ static int test_siphash(int idx)
}
for (half = 16; half < inlen; half += 16) {
if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0)))
if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen))
|| !TEST_true(SipHash_Init(&siphash, key, 0, 0)))
return 0;
SipHash_Update(&siphash, in, half);
SipHash_Update(&siphash, in+half, inlen-half);
@@ -258,19 +262,22 @@ static int test_siphash_basic(void)
unsigned char output[SIPHASH_MAX_DIGEST_SIZE];
/* Use invalid hash size */
return TEST_int_eq(SipHash_Init(&siphash, key, 4, 0, 0), 0)
return TEST_int_eq(SipHash_set_hash_size(&siphash, 4), 0)
/* Use hash size = 8 */
&& TEST_true(SipHash_Init(&siphash, key, 8, 0, 0))
&& TEST_true(SipHash_set_hash_size(&siphash, 8))
&& TEST_true(SipHash_Init(&siphash, key, 0, 0))
&& TEST_true(SipHash_Final(&siphash, output, 8))
&& TEST_int_eq(SipHash_Final(&siphash, output, 16), 0)
/* Use hash size = 16 */
&& TEST_true(SipHash_Init(&siphash, key, 16, 0, 0))
&& TEST_true(SipHash_set_hash_size(&siphash, 16))
&& TEST_true(SipHash_Init(&siphash, key, 0, 0))
&& TEST_int_eq(SipHash_Final(&siphash, output, 8), 0)
&& TEST_true(SipHash_Final(&siphash, output, 16))
/* Use hash size = 0 (default = 16) */
&& TEST_true(SipHash_Init(&siphash, key, 0, 0, 0))
&& TEST_true(SipHash_set_hash_size(&siphash, 0))
&& TEST_true(SipHash_Init(&siphash, key, 0, 0))
&& TEST_int_eq(SipHash_Final(&siphash, output, 8), 0)
&& TEST_true(SipHash_Final(&siphash, output, 16));
}
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2016-2018 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