4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
33 * This file will exercise the SHA-1 code performing the three
34 * tests documented in FIPS PUB 180-1 plus one which calls
35 * SHA1Input with an exact multiple of 512 bits, plus a few
47 #include "sha1_test.h"
51 * Define patterns for testing
54 #define TEST2a "abcdbcdecdefdefgefghfghighijhi"
55 #define TEST2b "jkijkljklmklmnlmnomnopnopq"
56 #define TEST2 TEST2a TEST2b
58 #define TEST4a "01234567012345670123456701234567"
59 #define TEST4b "01234567012345670123456701234567"
61 /* an exact multiple of 512 bits */
62 #define TEST4 TEST4a TEST4b
64 static char *testarray
[4] = {
71 static int repeatcount
[4] = { 1, 1, 1000000, 10 };
73 static char *resultarray
[4] = {
74 "A9993E364706816ABA3E25717850C26C9CD0D89D",
75 "84983E441C3BD26EBAAE4AA1F95129E5E54670F1",
76 "34AA973CD4C4DAA4F61EEB2BDBAD27316534016F",
77 "DEA356A2CDDD90C7A7ECEDC5EBB563934F460452"
93 for (j
= 0; j
< 4; ++j
) {
95 (void) printf("Test #%d ", j
+1);
99 for (i
= 0; i
< repeatcount
[j
]; ++i
) {
100 SHA1Update(&sha
, (unsigned char *)testarray
[j
],
101 strlen(testarray
[j
]));
104 SHA1Final(digest
, &sha
);
106 getxdata(rdigest
, resultarray
[j
], 20);
107 if (bcmp(digest
, rdigest
, 20) != 0) {
108 (void) printf("FAILED\n");
111 (void) printf("PASSED\n");