OLD | NEW |
1 #include "tunala.h" | 1 #include "tunala.h" |
2 | 2 |
3 #ifndef NO_OPENSSL | 3 #ifndef NO_OPENSSL |
4 | 4 |
5 /* For callbacks generating output, here are their file-descriptors. */ | 5 /* For callbacks generating output, here are their file-descriptors. */ |
6 static FILE *fp_cb_ssl_info = NULL; | 6 static FILE *fp_cb_ssl_info = NULL; |
7 static FILE *fp_cb_ssl_verify = NULL; | 7 static FILE *fp_cb_ssl_verify = NULL; |
8 /* Output level: | 8 /* Output level: |
9 * 0 = nothing, | 9 * 0 = nothing, |
10 * 1 = minimal, just errors, | 10 * 1 = minimal, just errors, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 { | 127 { |
128 if(level < 4) | 128 if(level < 4) |
129 cb_ssl_verify_level = level; | 129 cb_ssl_verify_level = level; |
130 } | 130 } |
131 | 131 |
132 RSA *cb_generate_tmp_rsa(SSL *s, int is_export, int keylength) | 132 RSA *cb_generate_tmp_rsa(SSL *s, int is_export, int keylength) |
133 { | 133 { |
134 /* TODO: Perhaps make it so our global key can be generated on-the-fly | 134 /* TODO: Perhaps make it so our global key can be generated on-the-fly |
135 * after certain intervals? */ | 135 * after certain intervals? */ |
136 static RSA *rsa_tmp = NULL; | 136 static RSA *rsa_tmp = NULL; |
137 » if(!rsa_tmp) | 137 » BIGNUM *bn = NULL; |
138 » » rsa_tmp = RSA_generate_key(keylength, RSA_F4, NULL, NULL); | 138 » int ok = 1; |
| 139 » if(!rsa_tmp) { |
| 140 » » ok = 0; |
| 141 » » if(!(bn = BN_new())) |
| 142 » » » goto end; |
| 143 » » if(!BN_set_word(bn, RSA_F4)) |
| 144 » » » goto end; |
| 145 » » if(!(rsa_tmp = RSA_new())) |
| 146 » » » goto end; |
| 147 » » if(!RSA_generate_key_ex(rsa_tmp, keylength, bn, NULL)) |
| 148 » » » goto end; |
| 149 » » ok = 1; |
| 150 » } |
| 151 end: |
| 152 » if(bn) |
| 153 » » BN_free(bn); |
| 154 » if(!ok) { |
| 155 » » RSA_free(rsa_tmp); |
| 156 » » rsa_tmp = NULL; |
| 157 » } |
139 return rsa_tmp; | 158 return rsa_tmp; |
140 } | 159 } |
141 | 160 |
142 #endif /* !defined(NO_OPENSSL) */ | 161 #endif /* !defined(NO_OPENSSL) */ |
143 | 162 |
OLD | NEW |