softRandUtil.c revision 7b79d84636ec82b45f00c982cf6810db81852d17
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <fcntl.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <errno.h>
#include <security/cryptoki.h>
#include <bignum.h>
#include <cryptoutil.h>
#include "softGlobal.h"
#include "softRandom.h"
#include "softCrypt.h"
{
/*
* When random-number generator is called by asymmetric token
*/
if (token) {
return (CKR_DEVICE_ERROR);
} else {
return (CKR_DEVICE_ERROR);
}
return (CKR_OK);
}
/*
* Generate random number in BIGNUM format. length is in bits
*/
{
/* Convert length of bits to length of word to hold valid data. */
/* len1 is the byte count. */
/* Generate len1 bytes of data and store in memory pointed by value. */
return (convert_brv(rv));
}
/*
* If the bit length is not on word boundary, shift the existing
* bits in last word to right adjusted.
*/
if ((length % BIG_CHUNK_SIZE) != 0)
r->sign = 1;
return (BIG_OK);
}