| 27 |
|
#include <openssl/pem.h> |
| 28 |
|
#include <openssl/rand.h> |
| 29 |
|
#include <openssl/rsa.h> |
| 30 |
– |
#include <openssl/md5.h> |
| 30 |
|
#include <openssl/bn.h> |
| 31 |
|
#include <openssl/evp.h> |
| 32 |
|
#include <openssl/err.h> |
| 33 |
+ |
#include <openssl/opensslv.h> |
| 34 |
|
|
| 35 |
|
#include "memory.h" |
| 36 |
|
#include "rsa.h" |
| 37 |
– |
#include "tools.h" |
| 37 |
|
#include "s_conf.h" |
| 38 |
|
#include "s_log.h" |
| 39 |
|
#include "client.h" /* CIPHERKEYLEN .. eww */ |
| 40 |
|
#include "ircd.h" /* bio_spare_fd */ |
| 41 |
|
|
| 43 |
– |
static void binary_to_hex(unsigned char *bin, char *hex, int length); |
| 42 |
|
|
| 43 |
|
/* |
| 44 |
|
* report_crypto_errors - Dump crypto error list to log |
| 98 |
|
return -1; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
< |
/* |
| 104 |
< |
* jdc -- Let's do this a little differently. According to the |
| 105 |
< |
* OpenSSL documentation, you need to METHOD_free(key) before |
| 106 |
< |
* assigning it. Don't believe me? Check out the following |
| 107 |
< |
* URL: http://www.openssl.org/docs/crypto/pem.html#BUGS |
| 108 |
< |
* P.S. -- I have no idea why the key= assignment has to be typecasted. |
| 109 |
< |
* For some reason the system thinks PEM_read_bio_RSAPrivateKey |
| 110 |
< |
* is returning an int, not a RSA *. |
| 111 |
< |
* androsyn -- Thats because you didn't have a prototype and including |
| 112 |
< |
* pem.h breaks things for some reason.. |
| 113 |
< |
*/ |
| 114 |
< |
key = (RSA *) PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL); |
| 101 |
> |
key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL); |
| 102 |
|
|
| 103 |
|
if (key == NULL) |
| 104 |
|
{ |
| 123 |
|
mkey->pad, key->pad); |
| 124 |
|
|
| 125 |
|
if (mkey->version != key->version) |
| 139 |
– |
{ |
| 140 |
– |
#if (OPENSSL_VERSION_NUMBER & 0x00907000) == 0x00907000 |
| 126 |
|
ilog(L_CRIT, "Private key corrupted: version %li != version %li", |
| 127 |
|
mkey->version, key->version); |
| 143 |
– |
#else |
| 144 |
– |
ilog(L_CRIT, "Private key corrupted: version %i != version %i", |
| 145 |
– |
mkey->version, key->version); |
| 146 |
– |
#endif |
| 147 |
– |
} |
| 128 |
|
|
| 129 |
|
if (BN_cmp(mkey->n, key->n)) |
| 130 |
|
ilog(L_CRIT, "Private key corrupted: n differs"); |
| 154 |
|
static const char trans[] = "0123456789ABCDEF"; |
| 155 |
|
int i; |
| 156 |
|
|
| 157 |
< |
for(i = 0; i < length; i++) |
| 157 |
> |
for (i = 0; i < length; i++) |
| 158 |
|
{ |
| 159 |
|
hex[i << 1] = trans[bin[i] >> 4]; |
| 160 |
|
hex[(i << 1) + 1] = trans[bin[i] & 0xf]; |