b68401ccae92ee0e92c699a10d28ce44badbc4aaTinderbox User * Copyright (C) 2011-2018 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt/* ! \file */
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * Test data from RFC6234
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Huntconst char *s;
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * Precondition: a hexadecimal number in *d, the length of that number in len,
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * and a pointer to a character array to put the output (*out).
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * Postcondition: A String representation of the given hexadecimal number is
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * placed into the array *out
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * 'out' MUST point to an array of at least len * 2 + 1
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * Return values: ISC_R_SUCCESS if the operation is sucessful
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunttohexstr(unsigned char *d, unsigned int len, char *out, size_t out_size) {
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt unsigned int i;
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt for (i = 0; i < len; i++) {
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt/* non-hmac tests */
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt atf_tc_set_md_var(tc, "descr", "sha1 examples from RFC4634");
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * These are the various test vectors. All of these are passed
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * through the hash function and the results are compared to the
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * result specified here.
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt /* Test 1 */
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt "0xA9993E364706816ABA3E25717850C26C9CD0D89D",
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt /* Test 2 */
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt "ljklmklmnlmnomnopnopq"),
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt "0x84983E441C3BD26EBAAE4AA1F95129E5E54670F1",
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt /* Test 3 */
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt "0x34AA973CD4C4DAA4F61EEB2BDBAD27316534016F",
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt /* Test 4 -- exact multiple of 512 bits */
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt "0xDEA356A2CDDD90C7A7ECEDC5EBB563934F460452",
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt /* Test 5 -- optional feature, not implemented */
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt /* "extrabits": 0x98 , "numberextrabits": 5 */
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt "0x29826B003B906E660EFF4027CE98AF3531AC75BA",
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt /* Test 6 */
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt "0x5E6F80A34A9798CAFC6A5DB96CC57BA4C4DB59C2",
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt /* Test 7 -- optional feature, not implemented */
3525200d9fb0e70aec4f6a3c7e0ed5a7dd8398afEvan Hunt "\x3b\x11\x75\x42\xd9\x4a\xc8"),
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* "extrabits": 0x80, "numberextrabits": 3 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0x6239781E03729919C01955B3FFA8ACB60B988340", 1 },
3525200d9fb0e70aec4f6a3c7e0ed5a7dd8398afEvan Hunt /* Test 8 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews TEST_INPUT("\x9a\x7d\xfd\xf1\xec\xea\xd0\x6e\xd6\x46"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xaa\x55\xfe\x75\x71\x46"),
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0x82ABFF6605DBE1C17DEF12A394FA22A82B544A35",
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 9 -- optional feature, not implemented */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews TEST_INPUT("\x65\xf9\x32\x99\x5b\xa4\xce\x2c\xb1\xb4"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xa2\xe7\x1a\xe7\x02\x20\xaa\xce\xc8\x96"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x2d\xd4\x49\x9c\xbd\x7c\x88\x7a\x94\xea"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xaa\x10\x1e\xa5\xaa\xbc\x52\x9b\x4e\x7e"
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews "\x43\x66\x5a\x5a\xf2\xcd\x03\xfe\x67\x8e"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xa6\xa5\x00\x5b\xba\x3b\x08\x22\x04\xc2"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x8b\x91\x09\xf4\x69\xda\xc9\x2a\xaa\xb3"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xaa\x7c\x11\xa1\xb3\x2a"),
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews /* "extrabits": 0xE0 , "numberextrabits": 3 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0x8C5B2A5DDAE5A97FC7F9D85661C672ADBF7933D4",
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 10 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews TEST_INPUT("\xf7\x8f\x92\x14\x1b\xcd\x17\x0a\xe8\x9b"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x4f\xba\x15\xa1\xd5\x9f\x3f\xd8\x4d\x22"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x3c\x92\x51\xbd\xac\xbb\xae\x61\xd0\x5e"
3525200d9fb0e70aec4f6a3c7e0ed5a7dd8398afEvan Hunt "\xd1\x15\xa0\x6a\x7c\xe1\x17\xb7\xbe\xea"
3525200d9fb0e70aec4f6a3c7e0ed5a7dd8398afEvan Hunt "\xd2\x44\x21\xde\xd9\xc3\x25\x92\xbd\x57"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xed\xea\xe3\x9c\x39\xfa\x1f\xe8\x94\x6a"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x84\xd0\xcf\x1f\x7b\xee\xad\x17\x13\xe2"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xe0\x95\x98\x97\x34\x7f\x67\xc8\x0b\x04"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x00\xc2\x09\x81\x5d\x6b\x10\xa6\x83\x83"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x6f\xd5\x56\x2a\x56\xca\xb1\xa2\x8e\x81"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xb6\x57\x66\x54\x63\x1c\xf1\x65\x66\xb8"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x6e\x3b\x33\xa1\x08\xb0\x53\x07\xc0\x0a"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xff\x14\xa7\x68\xed\x73\x50\x60\x6a\x0f"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x85\xe6\xa9\x1d\x39\x6f\x5b\x5c\xbe\x57"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x7f\x9b\x38\x80\x7c\x7d\x52\x3d\x6d\x79"
3525200d9fb0e70aec4f6a3c7e0ed5a7dd8398afEvan Hunt "\x2f\x6e\xbc\x24\xa4\xec\xf2\xb3\xa4\x27"
3525200d9fb0e70aec4f6a3c7e0ed5a7dd8398afEvan Hunt "\xcd\xbb\xfb"),
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0xCB0082C8F197D260991BA6A460E76E202BAD27B3",
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews while (testcase->input != NULL && testcase->result != NULL) {
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews tohexstr(digest, ISC_SHA1_DIGESTLENGTH, str, sizeof(str));
02ceed9f83f82f0de35c7bd73c27a33d4f0fe9cbMark Andrews atf_tc_set_md_var(tc, "descr", "sha224 examples from RFC4634");
02ceed9f83f82f0de35c7bd73c27a33d4f0fe9cbMark Andrews * These are the various test vectors. All of these are passed
02ceed9f83f82f0de35c7bd73c27a33d4f0fe9cbMark Andrews * through the hash function and the results are compared to the
02ceed9f83f82f0de35c7bd73c27a33d4f0fe9cbMark Andrews * result specified here.
02ceed9f83f82f0de35c7bd73c27a33d4f0fe9cbMark Andrews /* Test 1 */
02ceed9f83f82f0de35c7bd73c27a33d4f0fe9cbMark Andrews "0x23097D223405D8228642A477BDA255B32AADBCE4BDA0B3F7"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 2 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews TEST_INPUT("abcdbcdecdefdefgefghfghighijhijkijklj"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "klmklmnlmnomnopnopq"),
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0x75388B16512776CC5DBA5DA1FD890150B0C6455CB4F58B"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "1952522525",
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 3 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0x20794655980C91D8BBB4C1EA97618A4BF03F42581948B2"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "EE4EE7AD67",
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 4 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews TEST_INPUT("01234567012345670123456701234567"),
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0x567F69F168CD7844E65259CE658FE7AADFA25216E68ECA"
02ceed9f83f82f0de35c7bd73c27a33d4f0fe9cbMark Andrews "0EB7AB8262",
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 5 -- unimplemented optional functionality */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 6 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0x00ECD5F138422B8AD74C9799FD826C531BAD2FCABC7450"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "BEE2AA8C2A",
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 7 -- unimplemented optional functionality */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 8 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews TEST_INPUT("\x18\x80\x40\x05\xdd\x4f\xbd\x15\x56\x29"
3525200d9fb0e70aec4f6a3c7e0ed5a7dd8398afEvan Hunt "\x9d\x6f\x9d\x93\xdf\x62"),
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0xDF90D78AA78821C99B40BA4C966921ACCD8FFB1E98AC38"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "8E56191DB1",
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 9 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews /* Test 10 */
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews TEST_INPUT("\x55\xb2\x10\x07\x9c\x61\xb5\x3a\xdd\x52"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x06\x22\xd1\xac\x97\xd5\xcd\xbe\x8c\xb3"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x3a\xa0\xae\x34\x45\x17\xbe\xe4\xd7\xba"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x09\xab\xc8\x53\x3c\x52\x50\x88\x7a\x43"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xbe\xbb\xac\x90\x6c\x2e\x18\x37\xf2\x6b"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x36\xa5\x9a\xe3\xbe\x78\x14\xd5\x06\x89"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x6b\x71\x8b\x2a\x38\x3e\xcd\xac\x16\xb9"
02ceed9f83f82f0de35c7bd73c27a33d4f0fe9cbMark Andrews "\x61\x25\x55\x3f\x41\x6f\xf3\x2c\x66\x74"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xc7\x45\x99\xa9\x00\x53\x86\xd9\xce\x11"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x12\x24\x5f\x48\xee\x47\x0d\x39\x6c\x1e"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xd6\x3b\x92\x67\x0c\xa5\x6e\xc8\x4d\xee"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xa8\x14\xb6\x13\x5e\xca\x54\x39\x2b\xde"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xdb\x94\x89\xbc\x9b\x87\x5a\x8b\xaf\x0d"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xc1\xae\x78\x57\x36\x91\x4a\xb7\xda\xa2"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x64\xbc\x07\x9d\x26\x9f\x2c\x0d\x7e\xdd"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\xd8\x10\xa4\x26\x14\x5a\x07\x76\xf6\x7c"
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "\x87\x82\x73"),
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews "0x0B31894EC8937AD9B91BDFBCBA294D9ADEFAA18E09305E"
3525200d9fb0e70aec4f6a3c7e0ed5a7dd8398afEvan Hunt "9F20D5C3A4",
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews while (testcase->input != NULL && testcase->result != NULL) {
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt *API inconsistency BUG HERE
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * in order to be consistant with the other isc_hash_final
35c014cb1d151983c455ad1ac99093591cbda97aMark Andrews * functions the call should be
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt * isc_sha224_final(&sha224, digest);
testcase++;
testcase++;
testcase++;
testcase++;
#ifndef PK11_MD5_DISABLE
testcase++;
testcase++;
test_key++;
testcase++;
test_key++;
testcase++;
test_key++;
testcase++;
test_key++;
testcase++;
test_key++;
#ifndef PK11_MD5_DISABLE
testcase++;
test_key++;
testcase++;
#ifndef PK11_MD5_DISABLE
#ifndef PK11_MD5_DISABLE
#ifndef PK11_MD5_DISABLE
#ifndef PK11_MD5_DISABLE
return (atf_no_error());