summaryrefslogtreecommitdiffstats
path: root/crypto/rand/rand_lcl.h
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2017-07-18 15:39:21 +0200
committerRich Salz <rsalz@openssl.org>2017-07-22 20:00:07 +0200
commit8389ec4b4950b9474e72a959eb0b0a6ce77ac1e8 (patch)
tree433fb30336963d2bd5a8cd7bb87a4dba32313f92 /crypto/rand/rand_lcl.h
parentsha/asm/keccak1600-avx512.pl: absorb bug-fix and minor optimization. (diff)
downloadopenssl-8389ec4b4950b9474e72a959eb0b0a6ce77ac1e8.tar.xz
openssl-8389ec4b4950b9474e72a959eb0b0a6ce77ac1e8.zip
Add --with-rand-seed
Add a new config param to specify how the CSPRNG should be seeded. Illegal values or nonsensical combinations (e.g., anything other than "os" on VMS or HP VOS etc) result in build failures. Add RDSEED support. Add RDTSC but leave it disabled for now pending more investigation. Refactor and reorganization all seeding files (rand_unix/win/vms) so that they are simpler. Only require 128 bits of seeding material. Many document improvements, including why to not use RAND_add() and the limitations around using load_file/write_file. Document RAND_poll(). Cleanup Windows RAND_poll and return correct status More completely initialize the default DRBG. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/3965)
Diffstat (limited to 'crypto/rand/rand_lcl.h')
-rw-r--r--crypto/rand/rand_lcl.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/crypto/rand/rand_lcl.h b/crypto/rand/rand_lcl.h
index de1f2cd4e6..b9df5d18e2 100644
--- a/crypto/rand/rand_lcl.h
+++ b/crypto/rand/rand_lcl.h
@@ -17,21 +17,24 @@
# include <openssl/ec.h>
# include "internal/rand.h"
-/* we require 256 bits of randomness */
-# define RANDOMNESS_NEEDED (256 / 8)
+/* Amount of randomness (in bytes) we want for initial seeding. */
+# define RANDOMNESS_NEEDED (128 / 8)
/* Maximum count allowed in reseeding */
#define MAX_RESEED (1 << 24)
/* DRBG status values */
-#define DRBG_STATUS_UNINITIALISED 0
-#define DRBG_STATUS_READY 1
-#define DRBG_STATUS_RESEED 2
-#define DRBG_STATUS_ERROR 3
+# define DRBG_STATUS_UNINITIALISED 0
+# define DRBG_STATUS_READY 1
+# define DRBG_STATUS_RESEED 2
+# define DRBG_STATUS_ERROR 3
/* A default maximum length: larger than any reasonable value used in pratice */
-#define DRBG_MAX_LENGTH 0x7ffffff0
+# define DRBG_MAX_LENGTH 0x7ffffff0
+/*
+ * The context for DRBG AES-CTR
+ */
typedef struct drbg_ctr_ctx_st {
AES_KEY ks;
size_t keylen;
@@ -46,6 +49,10 @@ typedef struct drbg_ctr_ctx_st {
unsigned char KX[48];
} DRBG_CTR_CTX;
+
+/*
+ * The context for all DRBG's
+ */
struct drbg_ctx_st {
CRYPTO_RWLOCK *lock;
DRBG_CTX *parent;
@@ -84,9 +91,12 @@ struct drbg_ctx_st {
extern RAND_METHOD openssl_rand_meth;
void rand_drbg_cleanup(void);
+/* Hardware-based seeding functions. */
+void rand_rdtsc(void);
+int rand_rdcpu(void);
+
+/* DRBG functions implementing AES-CTR */
int ctr_init(DRBG_CTX *dctx);
-int drbg_hash_init(DRBG_CTX *dctx);
-int drbg_hmac_init(DRBG_CTX *dctx);
int ctr_uninstantiate(DRBG_CTX *dctx);
int ctr_instantiate(DRBG_CTX *dctx,
const unsigned char *ent, size_t entlen,