1*10500SHai-May.Chao@Sun.COM /*
2*10500SHai-May.Chao@Sun.COM * CDDL HEADER START
3*10500SHai-May.Chao@Sun.COM *
4*10500SHai-May.Chao@Sun.COM * The contents of this file are subject to the terms of the
5*10500SHai-May.Chao@Sun.COM * Common Development and Distribution License (the "License").
6*10500SHai-May.Chao@Sun.COM * You may not use this file except in compliance with the License.
7*10500SHai-May.Chao@Sun.COM *
8*10500SHai-May.Chao@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*10500SHai-May.Chao@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*10500SHai-May.Chao@Sun.COM * See the License for the specific language governing permissions
11*10500SHai-May.Chao@Sun.COM * and limitations under the License.
12*10500SHai-May.Chao@Sun.COM *
13*10500SHai-May.Chao@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*10500SHai-May.Chao@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*10500SHai-May.Chao@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*10500SHai-May.Chao@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*10500SHai-May.Chao@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*10500SHai-May.Chao@Sun.COM *
19*10500SHai-May.Chao@Sun.COM * CDDL HEADER END
20*10500SHai-May.Chao@Sun.COM */
21*10500SHai-May.Chao@Sun.COM /*
22*10500SHai-May.Chao@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23*10500SHai-May.Chao@Sun.COM * Use is subject to license terms.
24*10500SHai-May.Chao@Sun.COM */
25*10500SHai-May.Chao@Sun.COM
26*10500SHai-May.Chao@Sun.COM #include <sys/types.h>
27*10500SHai-May.Chao@Sun.COM #include <sys/param.h>
28*10500SHai-May.Chao@Sun.COM #include <sys/errno.h>
29*10500SHai-May.Chao@Sun.COM #include <sys/kmem.h>
30*10500SHai-May.Chao@Sun.COM #include <sys/systm.h>
31*10500SHai-May.Chao@Sun.COM #include <sys/sha1.h>
32*10500SHai-May.Chao@Sun.COM #include <sys/crypto/common.h>
33*10500SHai-May.Chao@Sun.COM #include <sys/cmn_err.h>
34*10500SHai-May.Chao@Sun.COM #ifndef _KERNEL
35*10500SHai-May.Chao@Sun.COM #include <stdlib.h>
36*10500SHai-May.Chao@Sun.COM #include <string.h>
37*10500SHai-May.Chao@Sun.COM #include <strings.h>
38*10500SHai-May.Chao@Sun.COM #include <stdio.h>
39*10500SHai-May.Chao@Sun.COM #include <security/cryptoki.h>
40*10500SHai-May.Chao@Sun.COM #include <cryptoutil.h>
41*10500SHai-May.Chao@Sun.COM #include "softMAC.h"
42*10500SHai-May.Chao@Sun.COM #endif
43*10500SHai-May.Chao@Sun.COM #include <rng/fips_random.h>
44*10500SHai-May.Chao@Sun.COM
45*10500SHai-May.Chao@Sun.COM
46*10500SHai-May.Chao@Sun.COM int
fips_rng_post(void)47*10500SHai-May.Chao@Sun.COM fips_rng_post(void)
48*10500SHai-May.Chao@Sun.COM {
49*10500SHai-May.Chao@Sun.COM static uint8_t XKeyValue[] = {
50*10500SHai-May.Chao@Sun.COM 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51*10500SHai-May.Chao@Sun.COM 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52*10500SHai-May.Chao@Sun.COM 0x00, 0x00, 0x00, 0x00
53*10500SHai-May.Chao@Sun.COM };
54*10500SHai-May.Chao@Sun.COM
55*10500SHai-May.Chao@Sun.COM static uint8_t XSeed[] = {
56*10500SHai-May.Chao@Sun.COM 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57*10500SHai-May.Chao@Sun.COM 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58*10500SHai-May.Chao@Sun.COM 0x00, 0x00, 0x00, 0x00
59*10500SHai-May.Chao@Sun.COM };
60*10500SHai-May.Chao@Sun.COM
61*10500SHai-May.Chao@Sun.COM static uint8_t rng_known_GENX[] = {
62*10500SHai-May.Chao@Sun.COM 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d,
63*10500SHai-May.Chao@Sun.COM 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90,
64*10500SHai-May.Chao@Sun.COM 0xaf, 0xd8, 0x07, 0x09
65*10500SHai-May.Chao@Sun.COM };
66*10500SHai-May.Chao@Sun.COM
67*10500SHai-May.Chao@Sun.COM uint8_t GENX[SHA1_HASH_SIZE];
68*10500SHai-May.Chao@Sun.COM uint8_t XKey[SHA1_HASH_SIZE];
69*10500SHai-May.Chao@Sun.COM
70*10500SHai-May.Chao@Sun.COM (void) memcpy(XKey, XKeyValue, SHA1_HASH_SIZE);
71*10500SHai-May.Chao@Sun.COM
72*10500SHai-May.Chao@Sun.COM /* Generate X with a known seed. */
73*10500SHai-May.Chao@Sun.COM fips_random_inner(
74*10500SHai-May.Chao@Sun.COM /* LINTED E_BAD_PTR_CAST_ALIGN */
75*10500SHai-May.Chao@Sun.COM (uint32_t *)
76*10500SHai-May.Chao@Sun.COM XKey,
77*10500SHai-May.Chao@Sun.COM /* LINTED E_BAD_PTR_CAST_ALIGN */
78*10500SHai-May.Chao@Sun.COM (uint32_t *)
79*10500SHai-May.Chao@Sun.COM GENX,
80*10500SHai-May.Chao@Sun.COM /* LINTED E_BAD_PTR_CAST_ALIGN */
81*10500SHai-May.Chao@Sun.COM (uint32_t *)
82*10500SHai-May.Chao@Sun.COM XSeed);
83*10500SHai-May.Chao@Sun.COM
84*10500SHai-May.Chao@Sun.COM /* Verify GENX to perform the RNG integrity check */
85*10500SHai-May.Chao@Sun.COM if ((memcmp(GENX, rng_known_GENX, (SHA1_HASH_SIZE)) != 0))
86*10500SHai-May.Chao@Sun.COM return (CKR_DEVICE_ERROR);
87*10500SHai-May.Chao@Sun.COM else
88*10500SHai-May.Chao@Sun.COM return (CKR_OK);
89*10500SHai-May.Chao@Sun.COM }
90