diff options
Diffstat (limited to 'src/lib/libcrypto/rand')
-rw-r--r-- | src/lib/libcrypto/rand/rand_err.c | 28 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/rand_lib.c | 26 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/randfile.c | 2 |
3 files changed, 32 insertions, 24 deletions
diff --git a/src/lib/libcrypto/rand/rand_err.c b/src/lib/libcrypto/rand/rand_err.c index 95574659ac..97f96e1aee 100644 --- a/src/lib/libcrypto/rand/rand_err.c +++ b/src/lib/libcrypto/rand/rand_err.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* crypto/rand/rand_err.c */ | 1 | /* crypto/rand/rand_err.c */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
@@ -64,22 +64,26 @@ | |||
64 | 64 | ||
65 | /* BEGIN ERROR CODES */ | 65 | /* BEGIN ERROR CODES */ |
66 | #ifndef OPENSSL_NO_ERR | 66 | #ifndef OPENSSL_NO_ERR |
67 | |||
68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_RAND,func,0) | ||
69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_RAND,0,reason) | ||
70 | |||
67 | static ERR_STRING_DATA RAND_str_functs[]= | 71 | static ERR_STRING_DATA RAND_str_functs[]= |
68 | { | 72 | { |
69 | {ERR_PACK(0,RAND_F_FIPS_RAND_BYTES,0), "FIPS_RAND_BYTES"}, | 73 | {ERR_FUNC(RAND_F_FIPS_RAND_BYTES), "FIPS_RAND_BYTES"}, |
70 | {ERR_PACK(0,RAND_F_RAND_GET_RAND_METHOD,0), "RAND_get_rand_method"}, | 74 | {ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"}, |
71 | {ERR_PACK(0,RAND_F_SSLEAY_RAND_BYTES,0), "SSLEAY_RAND_BYTES"}, | 75 | {ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"}, |
72 | {0,NULL} | 76 | {0,NULL} |
73 | }; | 77 | }; |
74 | 78 | ||
75 | static ERR_STRING_DATA RAND_str_reasons[]= | 79 | static ERR_STRING_DATA RAND_str_reasons[]= |
76 | { | 80 | { |
77 | {RAND_R_NON_FIPS_METHOD ,"non fips method"}, | 81 | {ERR_REASON(RAND_R_NON_FIPS_METHOD) ,"non fips method"}, |
78 | {RAND_R_PRNG_ASKING_FOR_TOO_MUCH ,"prng asking for too much"}, | 82 | {ERR_REASON(RAND_R_PRNG_ASKING_FOR_TOO_MUCH),"prng asking for too much"}, |
79 | {RAND_R_PRNG_NOT_REKEYED ,"prng not rekeyed"}, | 83 | {ERR_REASON(RAND_R_PRNG_NOT_REKEYED) ,"prng not rekeyed"}, |
80 | {RAND_R_PRNG_NOT_RESEEDED ,"prng not reseeded"}, | 84 | {ERR_REASON(RAND_R_PRNG_NOT_RESEEDED) ,"prng not reseeded"}, |
81 | {RAND_R_PRNG_NOT_SEEDED ,"PRNG not seeded"}, | 85 | {ERR_REASON(RAND_R_PRNG_NOT_SEEDED) ,"PRNG not seeded"}, |
82 | {RAND_R_PRNG_STUCK ,"prng stuck"}, | 86 | {ERR_REASON(RAND_R_PRNG_STUCK) ,"prng stuck"}, |
83 | {0,NULL} | 87 | {0,NULL} |
84 | }; | 88 | }; |
85 | 89 | ||
@@ -93,8 +97,8 @@ void ERR_load_RAND_strings(void) | |||
93 | { | 97 | { |
94 | init=0; | 98 | init=0; |
95 | #ifndef OPENSSL_NO_ERR | 99 | #ifndef OPENSSL_NO_ERR |
96 | ERR_load_strings(ERR_LIB_RAND,RAND_str_functs); | 100 | ERR_load_strings(0,RAND_str_functs); |
97 | ERR_load_strings(ERR_LIB_RAND,RAND_str_reasons); | 101 | ERR_load_strings(0,RAND_str_reasons); |
98 | #endif | 102 | #endif |
99 | 103 | ||
100 | } | 104 | } |
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c index 88f1b56d91..a21bde79de 100644 --- a/src/lib/libcrypto/rand/rand_lib.c +++ b/src/lib/libcrypto/rand/rand_lib.c | |||
@@ -87,16 +87,6 @@ int RAND_set_rand_method(const RAND_METHOD *meth) | |||
87 | 87 | ||
88 | const RAND_METHOD *RAND_get_rand_method(void) | 88 | const RAND_METHOD *RAND_get_rand_method(void) |
89 | { | 89 | { |
90 | #ifdef OPENSSL_FIPS | ||
91 | if(FIPS_mode() | ||
92 | && default_RAND_meth != FIPS_rand_check()) | ||
93 | { | ||
94 | RANDerr(RAND_F_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD); | ||
95 | return 0; | ||
96 | } | ||
97 | #endif | ||
98 | |||
99 | |||
100 | if (!default_RAND_meth) | 90 | if (!default_RAND_meth) |
101 | { | 91 | { |
102 | #ifndef OPENSSL_NO_ENGINE | 92 | #ifndef OPENSSL_NO_ENGINE |
@@ -114,8 +104,22 @@ const RAND_METHOD *RAND_get_rand_method(void) | |||
114 | funct_ref = e; | 104 | funct_ref = e; |
115 | else | 105 | else |
116 | #endif | 106 | #endif |
117 | default_RAND_meth = RAND_SSLeay(); | 107 | #ifdef OPENSSL_FIPS |
108 | if(FIPS_mode()) | ||
109 | default_RAND_meth=FIPS_rand_method(); | ||
110 | else | ||
111 | #endif | ||
112 | default_RAND_meth = RAND_SSLeay(); | ||
118 | } | 113 | } |
114 | |||
115 | #ifdef OPENSSL_FIPS | ||
116 | if(FIPS_mode() | ||
117 | && default_RAND_meth != FIPS_rand_check()) | ||
118 | { | ||
119 | RANDerr(RAND_F_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD); | ||
120 | return 0; | ||
121 | } | ||
122 | #endif | ||
119 | return default_RAND_meth; | 123 | return default_RAND_meth; |
120 | } | 124 | } |
121 | 125 | ||
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index 9bd89ba495..d847d8ebdf 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c | |||
@@ -57,7 +57,7 @@ | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | /* We need to define this to get macros like S_IFBLK and S_IFCHR */ | 59 | /* We need to define this to get macros like S_IFBLK and S_IFCHR */ |
60 | #define _XOPEN_SOURCE 1 | 60 | #define _XOPEN_SOURCE 500 |
61 | 61 | ||
62 | #include <errno.h> | 62 | #include <errno.h> |
63 | #include <stdio.h> | 63 | #include <stdio.h> |