summaryrefslogtreecommitdiff
path: root/usr/src/common/crypto
diff options
context:
space:
mode:
authorDina K Nimeh <Dina.Nimeh@Sun.COM>2009-03-20 11:56:57 -0700
committerDina K Nimeh <Dina.Nimeh@Sun.COM>2009-03-20 11:56:57 -0700
commit7b79d84636ec82b45f00c982cf6810db81852d17 (patch)
tree9e090007ba93df8148d15dd065d5051f8abd44ee /usr/src/common/crypto
parent47e946e784719ae402ace34695f67b0e6e76ae5c (diff)
downloadillumos-joyent-7b79d84636ec82b45f00c982cf6810db81852d17.tar.gz
6666204 meta slot opens and closes /dev/urandom needlessly for every read
6722460 finish moving /dev/random and /dev/urandom seeding and usage to libcryptoutil
Diffstat (limited to 'usr/src/common/crypto')
-rw-r--r--usr/src/common/crypto/ecc/ecc_impl.h9
-rw-r--r--usr/src/common/crypto/rsa/rsa_impl.c9
2 files changed, 9 insertions, 9 deletions
diff --git a/usr/src/common/crypto/ecc/ecc_impl.h b/usr/src/common/crypto/ecc/ecc_impl.h
index 506267c4a8..01728001d9 100644
--- a/usr/src/common/crypto/ecc/ecc_impl.h
+++ b/usr/src/common/crypto/ecc/ecc_impl.h
@@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Sun elects to use this software under the MPL license.
@@ -45,8 +45,6 @@
#ifndef _ECC_IMPL_H
#define _ECC_IMPL_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -207,7 +205,8 @@ typedef enum _SECStatus {
#ifdef _KERNEL
#define RNG_GenerateGlobalRandomBytes(p,l) ecc_knzero_random_generator((p), (l))
#else
-#define RNG_GenerateGlobalRandomBytes(p,l) soft_nzero_random_generator((p), (l))
+#define RNG_GenerateGlobalRandomBytes(p,l) \
+ (pkcs11_get_nzero_urandom((p), (l)) < 0 ? CKR_DEVICE_ERROR : CKR_OK)
#endif
#define CHECK_MPI_OK(func) if (MP_OKAY > (err = func)) goto cleanup
#define MP_TO_SEC_ERROR(err)
@@ -216,7 +215,7 @@ typedef enum _SECStatus {
CHECK_MPI_OK(mp_read_unsigned_octets((mp), (it).data, (it).len))
extern int ecc_knzero_random_generator(uint8_t *, size_t);
-extern ulong_t soft_nzero_random_generator(uint8_t *, ulong_t);
+extern int pkcs11_get_nzero_urandom(void *, size_t);
extern SECStatus EC_DecodeParams(const SECItem *, ECParams **, int);
extern SECItem * SECITEM_AllocItem(PRArenaPool *, SECItem *, unsigned int, int);
diff --git a/usr/src/common/crypto/rsa/rsa_impl.c b/usr/src/common/crypto/rsa/rsa_impl.c
index 39f47ba3ae..8ff3823eba 100644
--- a/usr/src/common/crypto/rsa/rsa_impl.c
+++ b/usr/src/common/crypto/rsa/rsa_impl.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains RSA helper routines common to
* the PKCS11 soft token code and the kernel RSA code.
@@ -37,6 +35,7 @@
#include <sys/param.h>
#else
#include <strings.h>
+#include <cryptoutil.h>
#include "softRandom.h"
#endif
@@ -197,7 +196,9 @@ soft_encrypt_rsa_pkcs_encode(uint8_t *databuf,
#ifdef _KERNEL
rv = knzero_random_generator(padbuf + 2, padbuflen - 3);
#else
- rv = soft_nzero_random_generator(padbuf + 2, padbuflen - 3);
+ rv = CKR_OK;
+ if (pkcs11_get_nzero_urandom(padbuf + 2, padbuflen - 3) < 0)
+ rv = CKR_DEVICE_ERROR;
#endif
if (rv != CKR_OK) {
return (rv);