archrelease: copy trunk to community-any
[ArchLinux/community.git] / ecryptfs-utils / trunk / openssl-1.1.x.patch
blob5c3e419a91d1849605fe0ff0cdaaa7aebf9f1cb8
1 === modified file 'src/key_mod/ecryptfs_key_mod_openssl.c'
2 --- src/key_mod/ecryptfs_key_mod_openssl.c 2013-10-25 19:45:09 +0000
3 +++ src/key_mod/ecryptfs_key_mod_openssl.c 2017-03-13 20:34:27 +0000
4 @@ -50,6 +50,20 @@
5 #include "../include/ecryptfs.h"
6 #include "../include/decision_graph.h"
8 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
9 +void RSA_get0_key(const RSA *r,
10 + const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
12 + if (n != NULL)
13 + *n = r->n;
14 + if (e != NULL)
15 + *e = r->e;
16 + if (d != NULL)
17 + *d = r->d;
19 +#endif
22 struct openssl_data {
23 char *path;
24 char *passphrase;
25 @@ -142,6 +156,7 @@
27 int len, nbits, ebits, i;
28 int nbytes, ebytes;
29 + const BIGNUM *key_n, *key_e;
30 unsigned char *hash;
31 unsigned char *data = NULL;
32 int rc = 0;
33 @@ -152,11 +167,13 @@
34 rc = -ENOMEM;
35 goto out;
37 - nbits = BN_num_bits(key->n);
38 + RSA_get0_key(key, &key_n, NULL, NULL);
39 + nbits = BN_num_bits(key_n);
40 nbytes = nbits / 8;
41 if (nbits % 8)
42 nbytes++;
43 - ebits = BN_num_bits(key->e);
44 + RSA_get0_key(key, NULL, &key_e, NULL);
45 + ebits = BN_num_bits(key_e);
46 ebytes = ebits / 8;
47 if (ebits % 8)
48 ebytes++;
49 @@ -179,11 +196,13 @@
50 data[i++] = '\02';
51 data[i++] = (nbits >> 8);
52 data[i++] = nbits;
53 - BN_bn2bin(key->n, &(data[i]));
54 + RSA_get0_key(key, &key_n, NULL, NULL);
55 + BN_bn2bin(key_n, &(data[i]));
56 i += nbytes;
57 data[i++] = (ebits >> 8);
58 data[i++] = ebits;
59 - BN_bn2bin(key->e, &(data[i]));
60 + RSA_get0_key(key, NULL, &key_e, NULL);
61 + BN_bn2bin(key_e, &(data[i]));
62 i += ebytes;
63 SHA1(data, len + 3, hash);
64 to_hex(sig, (char *)hash, ECRYPTFS_SIG_SIZE);
65 @@ -278,7 +297,9 @@
66 BIO *in = NULL;
67 int rc;
69 + #if OPENSSL_VERSION_NUMBER < 0x10100000L
70 CRYPTO_malloc_init();
71 + #endif
72 ERR_load_crypto_strings();
73 OpenSSL_add_all_algorithms();
74 ENGINE_load_builtin_engines();