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