Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: mozilla/security/nss/lib/softoken/fipstest.c

Issue 10961060: Update NSS to NSS 3.14 Beta 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Merge nss-static2.patch into nss-static.patch Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * PKCS #11 FIPS Power-Up Self Test. 2 * PKCS #11 FIPS Power-Up Self Test.
3 * 3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public 4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* $Id: fipstest.c,v 1.31 2012/06/28 17:55:06 rrelyea%redhat.com Exp $ */ 7 /* $Id: fipstest.c,v 1.31 2012/06/28 17:55:06 rrelyea%redhat.com Exp $ */
8 8
9 #include "softoken.h" /* Required for RC2-ECB, RC2-CBC, RC4, DES-ECB, */ 9 #include "softoken.h" /* Required for RC2-ECB, RC2-CBC, RC4, DES-ECB, */
10 /* DES-CBC, DES3-ECB, DES3-CBC, RSA */ 10 /* DES-CBC, DES3-ECB, DES3-CBC, RSA */
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 return( CKR_DEVICE_ERROR ); 1929 return( CKR_DEVICE_ERROR );
1930 1930
1931 return( CKR_OK ); 1931 return( CKR_OK );
1932 1932
1933 1933
1934 } 1934 }
1935 1935
1936 static CK_RV 1936 static CK_RV
1937 sftk_fips_RNG_PowerUpSelfTest( void ) 1937 sftk_fips_RNG_PowerUpSelfTest( void )
1938 { 1938 {
1939 static const PRUint8 entropy[] = {
1940 0x8e,0x9c,0x0d,0x25,0x75,0x22,0x04,0xf9,
1941 0xc5,0x79,0x10,0x8b,0x23,0x79,0x37,0x14,
1942 0x9f,0x2c,0xc7,0x0b,0x39,0xf8,0xee,0xef,
1943 0x95,0x0c,0x97,0x59,0xfc,0x0a,0x85,0x41,
1944 0x76,0x9d,0x6d,0x67,0x00,0x4e,0x19,0x12,
1945 0x02,0x16,0x53,0xea,0xf2,0x73,0xd7,0xd6,
1946 0x7f,0x7e,0xc8,0xae,0x9c,0x09,0x99,0x7d,
1947 0xbb,0x9e,0x48,0x7f,0xbb,0x96,0x46,0xb3,
1948 0x03,0x75,0xf8,0xc8,0x69,0x45,0x3f,0x97,
1949 0x5e,0x2e,0x48,0xe1,0x5d,0x58,0x97,0x4c };
1950 static const PRUint8 rng_known_result[] = {
1951 0x16,0xe1,0x8c,0x57,0x21,0xd8,0xf1,0x7e,
1952 0x5a,0xa0,0x16,0x0b,0x7e,0xa6,0x25,0xb4,
1953 0x24,0x19,0xdb,0x54,0xfa,0x35,0x13,0x66,
1954 0xbb,0xaa,0x2a,0x1b,0x22,0x33,0x2e,0x4a,
1955 0x14,0x07,0x9d,0x52,0xfc,0x73,0x61,0x48,
1956 0xac,0xc1,0x22,0xfc,0xa4,0xfc,0xac,0xa4,
1957 0xdb,0xda,0x5b,0x27,0x33,0xc4,0xb3 };
1958 static const PRUint8 reseed_entropy[] = {
1959 0xc6,0x0b,0x0a,0x30,0x67,0x07,0xf4,0xe2,
1960 0x24,0xa7,0x51,0x6f,0x5f,0x85,0x3e,0x5d,
1961 0x67,0x97,0xb8,0x3b,0x30,0x9c,0x7a,0xb1,
1962 0x52,0xc6,0x1b,0xc9,0x46,0xa8,0x62,0x79 };
1963 static const PRUint8 additional_input[] = {
1964 0x86,0x82,0x28,0x98,0xe7,0xcb,0x01,0x14,
1965 0xae,0x87,0x4b,0x1d,0x99,0x1b,0xc7,0x41,
1966 0x33,0xff,0x33,0x66,0x40,0x95,0x54,0xc6,
1967 0x67,0x4d,0x40,0x2a,0x1f,0xf9,0xeb,0x65 };
1968 static const PRUint8 rng_reseed_result[] = {
1969 0x02,0x0c,0xc6,0x17,0x86,0x49,0xba,0xc4,
1970 0x7b,0x71,0x35,0x05,0xf0,0xdb,0x4a,0xc2,
1971 0x2c,0x38,0xc1,0xa4,0x42,0xe5,0x46,0x4a,
1972 0x7d,0xf0,0xbe,0x47,0x88,0xb8,0x0e,0xc6,
1973 0x25,0x2b,0x1d,0x13,0xef,0xa6,0x87,0x96,
1974 0xa3,0x7d,0x5b,0x80,0xc2,0x38,0x76,0x61,
1975 0xc7,0x80,0x5d,0x0f,0x05,0x76,0x85 };
1976 static const PRUint8 Q[] = { 1939 static const PRUint8 Q[] = {
1977 0x85,0x89,0x9c,0x77,0xa3,0x79,0xff,0x1a, 1940 0x85,0x89,0x9c,0x77,0xa3,0x79,0xff,0x1a,
1978 0x86,0x6f,0x2f,0x3e,0x2e,0xf9,0x8c,0x9c, 1941 0x86,0x6f,0x2f,0x3e,0x2e,0xf9,0x8c,0x9c,
1979 0x9d,0xef,0xeb,0xed}; 1942 0x9d,0xef,0xeb,0xed};
1980 static const PRUint8 GENX[] = { 1943 static const PRUint8 GENX[] = {
1981 0x65,0x48,0xe3,0xca,0xac,0x64,0x2d,0xf7, 1944 0x65,0x48,0xe3,0xca,0xac,0x64,0x2d,0xf7,
1982 0x7b,0xd3,0x4e,0x79,0xc9,0x7d,0xa6,0xa8, 1945 0x7b,0xd3,0x4e,0x79,0xc9,0x7d,0xa6,0xa8,
1983 0xa2,0xc2,0x1f,0x8f,0xe9,0xb9,0xd3,0xa1, 1946 0xa2,0xc2,0x1f,0x8f,0xe9,0xb9,0xd3,0xa1,
1984 0x3f,0xf7,0x0c,0xcd,0xa6,0xca,0xbf,0xce, 1947 0x3f,0xf7,0x0c,0xcd,0xa6,0xca,0xbf,0xce,
1985 0x84,0x0e,0xb6,0xf1,0x0d,0xbe,0xa9,0xa3}; 1948 0x84,0x0e,0xb6,0xf1,0x0d,0xbe,0xa9,0xa3};
1986 static const PRUint8 rng_known_DSAX[] = { 1949 static const PRUint8 rng_known_DSAX[] = {
1987 0x7a,0x86,0xf1,0x7f,0xbd,0x4e,0x6e,0xd9, 1950 0x7a,0x86,0xf1,0x7f,0xbd,0x4e,0x6e,0xd9,
1988 0x0a,0x26,0x21,0xd0,0x19,0xcb,0x86,0x73, 1951 0x0a,0x26,0x21,0xd0,0x19,0xcb,0x86,0x73,
1989 0x10,0x1f,0x60,0xd7}; 1952 0x10,0x1f,0x60,0xd7};
1990 1953
1991 1954
1992 1955
1993 SECStatus rng_status = SECSuccess; 1956 SECStatus rng_status = SECSuccess;
1994 PR_STATIC_ASSERT(sizeof(rng_known_result) >= sizeof(rng_reseed_result));
1995 PRUint8 result[sizeof(rng_known_result)];
1996 PRUint8 DSAX[FIPS_DSA_SUBPRIME_LENGTH]; 1957 PRUint8 DSAX[FIPS_DSA_SUBPRIME_LENGTH];
1997 1958
1998 /********************************************/ 1959 /*******************************************/
1999 /* Generate random bytes with a known seed. */ 1960 /* Run the SP 800-90 Health tests */
2000 /********************************************/ 1961 /*******************************************/
2001 rng_status = PRNGTEST_Instantiate(entropy, sizeof entropy, 1962 rng_status = PRNGTEST_RunHealthTests();
2002 » » » » NULL, 0, NULL, 0);
2003 if (rng_status != SECSuccess) { 1963 if (rng_status != SECSuccess) {
2004 » return ( CKR_DEVICE_ERROR ); 1964 » return (CKR_DEVICE_ERROR);
2005 }
2006 rng_status = PRNGTEST_Generate(result, sizeof rng_known_result, NULL, 0);
2007 if ( ( rng_status != SECSuccess) ||
2008 ( PORT_Memcmp( result, rng_known_result,
2009 sizeof rng_known_result ) != 0 ) ) {
2010 » PRNGTEST_Uninstantiate();
2011 » return ( CKR_DEVICE_ERROR );
2012 }
2013 rng_status = PRNGTEST_Reseed(reseed_entropy, sizeof reseed_entropy,
2014 » » » » additional_input, sizeof additional_input);
2015 if (rng_status != SECSuccess) {
2016 » PRNGTEST_Uninstantiate();
2017 » return ( CKR_DEVICE_ERROR );
2018 }
2019 rng_status = PRNGTEST_Generate(result, sizeof rng_reseed_result, NULL, 0);
2020 if ( ( rng_status != SECSuccess) ||
2021 ( PORT_Memcmp( result, rng_reseed_result,
2022 sizeof rng_reseed_result ) != 0 ) ) {
2023 » PRNGTEST_Uninstantiate();
2024 » return ( CKR_DEVICE_ERROR );
2025 }
2026 rng_status = PRNGTEST_Uninstantiate();
2027 if (rng_status != SECSuccess) {
2028 » return ( CKR_DEVICE_ERROR );
2029 } 1965 }
2030 1966
2031 /*******************************************/ 1967 /*******************************************/
2032 /* Generate DSAX fow given Q. */ 1968 /* Generate DSAX fow given Q. */
2033 /*******************************************/ 1969 /*******************************************/
2034 1970
2035 rng_status = FIPS186Change_ReduceModQForDSA(GENX, Q, DSAX); 1971 rng_status = FIPS186Change_ReduceModQForDSA(GENX, Q, DSAX);
2036 1972
2037 /* Verify DSAX to perform the RNG integrity check */ 1973 /* Verify DSAX to perform the RNG integrity check */
2038 if( ( rng_status != SECSuccess ) || 1974 if( ( rng_status != SECSuccess ) ||
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 /* Software/Firmware Integrity Test. */ 2092 /* Software/Firmware Integrity Test. */
2157 rv = sftk_fipsSoftwareIntegrityTest(); 2093 rv = sftk_fipsSoftwareIntegrityTest();
2158 2094
2159 if( rv != CKR_OK ) 2095 if( rv != CKR_OK )
2160 return rv; 2096 return rv;
2161 2097
2162 /* Passed Power-Up SelfTest(s). */ 2098 /* Passed Power-Up SelfTest(s). */
2163 return( CKR_OK ); 2099 return( CKR_OK );
2164 } 2100 }
2165 2101
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698