Remove redundant definitions. Give error code if DRBG sefltest fails.
[openssl.git] / fips / rand / fips_rand_lcl.h
index 34f1c59991fa6a6cbc5d1f19152475cb21ebe5ab..a946ac1ed89b5202130ede9d5869020aebb72838 100644 (file)
@@ -84,8 +84,8 @@ struct drbg_ctr_ctx_st
 
 /* DRBG flags */
 
-/* PRNG is in test state */
-#define        DRBG_FLAG_TEST                  0x2
+/* Functions shouldn't call err library */
+#define        DRBG_FLAG_NOERR                 0x4
 
 /* DRBG status values */
 /* not initialised */
@@ -97,13 +97,9 @@ struct drbg_ctr_ctx_st
 /* fatal error condition */
 #define DRBG_STATUS_ERROR              3
 
-/* Maximum values for temp entropy and nonce */
-#define DRBG_MAX_ENTROPY               1024
-#define DRBG_MAX_NONCE                 1024
-
 /* A default maximum length: larger than any reasonable value used in pratice */
 
-#define DRBG_MAX_LENGTH                        0x7fffffff
+#define DRBG_MAX_LENGTH                        0x7ffffff0
 
 /* DRBG context structure */
 
@@ -153,20 +149,27 @@ struct drbg_ctx_st
        /* uninstantiate */
        int (*uninstantiate)(DRBG_CTX *ctx);
 
-       unsigned char entropy[DRBG_MAX_ENTROPY];
-
        /* entropy gathering function */
-       size_t (*get_entropy)(DRBG_CTX *ctx, unsigned char *out,
+       size_t (*get_entropy)(DRBG_CTX *ctx, unsigned char **pout,
                                int entropy, size_t min_len, size_t max_len);
-
-       unsigned char nonce[DRBG_MAX_NONCE];
+       /* Indicates we have finished with entropy buffer */
+       void (*cleanup_entropy)(DRBG_CTX *ctx, unsigned char *out, size_t olen);
 
        /* nonce gathering function */
-       size_t (*get_nonce)(DRBG_CTX *ctx, unsigned char *out,
+       size_t (*get_nonce)(DRBG_CTX *ctx, unsigned char **pout,
                                int entropy, size_t min_len, size_t max_len);
+       /* Indicates we have finished with nonce buffer */
+       void (*cleanup_nonce)(DRBG_CTX *ctx, unsigned char *out, size_t olen);
+
+       /* Continuous random number test temporary area */
+       /* Last block */        
+       unsigned char lb[16];
+       /* set if lb is valid */
+       int lb_valid;
 
        };
 
 
 int fips_drbg_ctr_init(DRBG_CTX *dctx);
 int fips_drbg_hash_init(DRBG_CTX *dctx);
+int fips_drbg_kat(DRBG_CTX *dctx, int nid, unsigned int flags);