gost_test.c revision 12bf5d4796505b4c20680531da96a31e6c2c1144
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt * Permission to use, copy, modify, and/or distribute this software for any
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * purpose with or without fee is hereby granted, provided that the above
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * copyright notice and this permission notice appear in all copies.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * PERFORMANCE OF THIS SOFTWARE.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt/* ! \file */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#if defined(HAVE_OPENSSL_GOST) || defined(HAVE_PKCS11_GOST)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Test data from Wikipedia GOST (hash function)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntconst char *s;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunttohexstr(unsigned char *d, unsigned int len, char *out);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Precondition: a hexadecimal number in *d, the length of that number in len,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * and a pointer to a character array to put the output (*out).
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Postcondition: A String representation of the given hexadecimal number is
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * placed into the array *out
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * 'out' MUST point to an array of at least len / 2 + 1
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Return values: ISC_R_SUCCESS if the operation is sucessful
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunttohexstr(unsigned char *d, unsigned int len, char *out) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unsigned int i;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt for (i = 0; i < len; i++) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunttypedef struct hash_testcase {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt const char *input;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt const char *result;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "GOST R 34.11-94 examples from Wikipedia");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * These are the various test vectors. All of these are passed
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * through the hash function and the results are compared to the
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * result specified here.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Test 1 */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "0x981E5F3CA30C841487830F84FB433E1"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "3AC1101569B9C13584AC483234CD656C0",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Test 2 */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "0xE74C52DD282183BF37AF0079C9F7805"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "5715A103F17E3133CEFF1AACF2F403011",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Test 3 */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "0xB285056DBF18D7392D7677369524DD1"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "4747459ED8143997E163B2986F92FD42C",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Test 4 */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "0xBC6041DD2AA401EBFA6E9886734174F"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "EBDB4729AA972D60F549AC39B29721BA0",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Test 5 */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "over the lazy dog"),
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "0x9004294A361A508C586FE53D1F1B027"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "46765E71B765472786E4770D565830A76",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Test 6 */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "fghijklmnopqrstuvwxyz0123456789"),
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "0x73B70A39497DE53A6E08C67B6D4DB85"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "3540F03E9389299D9B0156EF7E85D0F61",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Test 7 */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "2345678901234567890123456789012"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "345678901234567890"),
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "0x6BC7B38989B28CF93AE8842BF9D7529"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "05910A7528A61E5BCE0782DE43E610C90",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Test 8 */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "0x2CEFC2F7B7BDC514E18EA57FA74FF35"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "7E7FA17D652C75F69CB1BE7893EDE48EB",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* Test 9 */
testcase++;
dns_test_end();
#ifdef HAVE_OPENSSL_GOST
int len;
p = gost_dummy_key;
q = abuf;
p = privasn1;
dns_test_end();
CKR_OK);
siglen = 0;
dns_test_end();
return (atf_no_error());