|
Line 0
Link Here
|
|
|
1 |
--- src/libstrongswan/plugins/openssl/openssl_rsa_public_key.h.orig 2016-04-22 20:01:35 UTC |
| 2 |
+++ src/libstrongswan/plugins/openssl/openssl_rsa_public_key.h |
| 3 |
@@ -21,6 +21,101 @@ |
| 4 |
#ifndef OPENSSL_RSA_PUBLIC_KEY_H_ |
| 5 |
#define OPENSSL_RSA_PUBLIC_KEY_H_ |
| 6 |
|
| 7 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
| 8 |
+/** |
| 9 |
+ * OpenSSL compat functions |
| 10 |
+ * From https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes |
| 11 |
+*/ |
| 12 |
+ |
| 13 |
+#include <string.h> |
| 14 |
+#include <openssl/engine.h> |
| 15 |
+ |
| 16 |
+int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) |
| 17 |
+{ |
| 18 |
+ /* If the fields n and e in r are NULL, the corresponding input |
| 19 |
+ * parameters MUST be non-NULL for n and e. d may be |
| 20 |
+ * left NULL (in case only the public key is used). |
| 21 |
+ */ |
| 22 |
+ if ((r->n == NULL && n == NULL) |
| 23 |
+ || (r->e == NULL && e == NULL)) |
| 24 |
+ return 0; |
| 25 |
+ |
| 26 |
+ if (n != NULL) { |
| 27 |
+ BN_free(r->n); |
| 28 |
+ r->n = n; |
| 29 |
+ } |
| 30 |
+ if (e != NULL) { |
| 31 |
+ BN_free(r->e); |
| 32 |
+ r->e = e; |
| 33 |
+ } |
| 34 |
+ if (d != NULL) { |
| 35 |
+ BN_free(r->d); |
| 36 |
+ r->d = d; |
| 37 |
+ } |
| 38 |
+ |
| 39 |
+ return 1; |
| 40 |
+} |
| 41 |
+ |
| 42 |
+int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) |
| 43 |
+{ |
| 44 |
+ /* If the fields p and q in r are NULL, the corresponding input |
| 45 |
+ * parameters MUST be non-NULL. |
| 46 |
+ */ |
| 47 |
+ if ((r->p == NULL && p == NULL) |
| 48 |
+ || (r->q == NULL && q == NULL)) |
| 49 |
+ return 0; |
| 50 |
+ |
| 51 |
+ if (p != NULL) { |
| 52 |
+ BN_free(r->p); |
| 53 |
+ r->p = p; |
| 54 |
+ } |
| 55 |
+ if (q != NULL) { |
| 56 |
+ BN_free(r->q); |
| 57 |
+ r->q = q; |
| 58 |
+ } |
| 59 |
+ |
| 60 |
+ return 1; |
| 61 |
+} |
| 62 |
+ |
| 63 |
+int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) |
| 64 |
+{ |
| 65 |
+ /* If the fields dmp1, dmq1 and iqmp in r are NULL, the corresponding input |
| 66 |
+ * parameters MUST be non-NULL. |
| 67 |
+ */ |
| 68 |
+ if ((r->dmp1 == NULL && dmp1 == NULL) |
| 69 |
+ || (r->dmq1 == NULL && dmq1 == NULL) |
| 70 |
+ || (r->iqmp == NULL && iqmp == NULL)) |
| 71 |
+ return 0; |
| 72 |
+ |
| 73 |
+ if (dmp1 != NULL) { |
| 74 |
+ BN_free(r->dmp1); |
| 75 |
+ r->dmp1 = dmp1; |
| 76 |
+ } |
| 77 |
+ if (dmq1 != NULL) { |
| 78 |
+ BN_free(r->dmq1); |
| 79 |
+ r->dmq1 = dmq1; |
| 80 |
+ } |
| 81 |
+ if (iqmp != NULL) { |
| 82 |
+ BN_free(r->iqmp); |
| 83 |
+ r->iqmp = iqmp; |
| 84 |
+ } |
| 85 |
+ |
| 86 |
+ return 1; |
| 87 |
+} |
| 88 |
+ |
| 89 |
+void RSA_get0_key(const RSA *r, |
| 90 |
+ const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) |
| 91 |
+{ |
| 92 |
+ if (n != NULL) |
| 93 |
+ *n = r->n; |
| 94 |
+ if (e != NULL) |
| 95 |
+ *e = r->e; |
| 96 |
+ if (d != NULL) |
| 97 |
+ *d = r->d; |
| 98 |
+} |
| 99 |
+ |
| 100 |
+#endif |
| 101 |
+ |
| 102 |
typedef struct openssl_rsa_public_key_t openssl_rsa_public_key_t; |
| 103 |
|
| 104 |
#include <credentials/keys/public_key.h> |