Commit Diff
Diff:
eb54d58a880cf8aad3fea42143f4f42fbd526eda
69ef05307fc8156e1c950ea3bf311f65bdc5fb41
Commit:
69ef05307fc8156e1c950ea3bf311f65bdc5fb41
Tree:
9f7120a816533527e6b6ff25dbf69f6a75715e87
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Wed Jun 27 05:55:18 2018 UTC
Message:
The last 2 commits caused a backward compatibility issue. I found some code online and have added it with: carelessly copied from https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes comment. The GENCB functions are not to be copied into other programs I made those myself and should only work on dddctl.c. Hoping to get beyond this. Tested on OpenBSD-current and NetBSD 7.1.2
blob - 913bd250b9c1daf8e50bb7f8cd9725572942919e
blob + 606f98533edb3b190c576e480bd61bd6e5454aad
--- dddctl.c
+++ dddctl.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: dddctl.c,v 1.17 2018/06/26 08:08:38 pjp Exp $
+ * $Id: dddctl.c,v 1.18 2018/06/27 05:55:18 pjp Exp $
*/
#include "ddd-include.h"
@@ -41,7 +41,6 @@
#include <openssl/err.h>
#include <openssl/sha.h>
-
int debug = 0;
int verbose = 0;
@@ -109,7 +108,21 @@ void init_keys(void);
uint32_t getkeypid(char *);
pid_t getdaemonpid(void);
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+BN_GENCB * BN_GENCB_new(void);
+void BN_GENCB_free(BN_GENCB *);
+
+int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
+int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
+int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
+
+void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);
+void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
+void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp);
+#endif
+
+
struct _mycmdtab {
char *var;
int (*cmd)(int, char **);
@@ -8055,3 +8068,133 @@ bindfile(int argc, char *argv[])
return 0;
}
+
+
+/* carelessly copied from https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes */
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+
+int
+RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d)
+{
+ /* If the fields n and e in r are NULL, the corresponding input
+ * parameters MUST be non-NULL for n and e. d may be
+ * left NULL (in case only the public key is used).
+ */
+ if ((r->n == NULL && n == NULL)
+ || (r->e == NULL && e == NULL))
+ return 0;
+
+ if (n != NULL) {
+ BN_free(r->n);
+ r->n = n;
+ }
+ if (e != NULL) {
+ BN_free(r->e);
+ r->e = e;
+ }
+ if (d != NULL) {
+ BN_free(r->d);
+ r->d = d;
+ }
+
+ return 1;
+}
+
+int
+RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q)
+{
+ /* If the fields p and q in r are NULL, the corresponding input
+ * parameters MUST be non-NULL.
+ */
+ if ((r->p == NULL && p == NULL)
+ || (r->q == NULL && q == NULL))
+ return 0;
+
+ if (p != NULL) {
+ BN_free(r->p);
+ r->p = p;
+ }
+ if (q != NULL) {
+ BN_free(r->q);
+ r->q = q;
+ }
+
+ return 1;
+}
+
+int
+RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp)
+{
+ /* If the fields dmp1, dmq1 and iqmp in r are NULL, the corresponding input
+ * parameters MUST be non-NULL.
+ */
+ if ((r->dmp1 == NULL && dmp1 == NULL)
+ || (r->dmq1 == NULL && dmq1 == NULL)
+ || (r->iqmp == NULL && iqmp == NULL))
+ return 0;
+
+ if (dmp1 != NULL) {
+ BN_free(r->dmp1);
+ r->dmp1 = dmp1;
+ }
+ if (dmq1 != NULL) {
+ BN_free(r->dmq1);
+ r->dmq1 = dmq1;
+ }
+ if (iqmp != NULL) {
+ BN_free(r->iqmp);
+ r->iqmp = iqmp;
+ }
+
+ return 1;
+}
+
+void
+RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
+{
+ if (n != NULL)
+ *n = r->n;
+ if (e != NULL)
+ *e = r->e;
+ if (d != NULL)
+ *d = r->d;
+}
+
+void
+RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q)
+{
+ if (p != NULL)
+ *p = r->p;
+ if (q != NULL)
+ *q = r->q;
+}
+
+void
+RSA_get0_crt_params(const RSA *r,
+ const BIGNUM **dmp1, const BIGNUM **dmq1,
+ const BIGNUM **iqmp)
+{
+ if (dmp1 != NULL)
+ *dmp1 = r->dmp1;
+ if (dmq1 != NULL)
+ *dmq1 = r->dmq1;
+ if (iqmp != NULL)
+ *iqmp = r->iqmp;
+}
+
+BN_GENCB *
+BN_GENCB_new(void)
+{
+ static BN_GENCB cb;
+
+ return (&cb);
+}
+
+void
+BN_GENCB_free(BN_GENCB *cb)
+{
+ return;
+}
+
+
+#endif
repomaster@centroid.eu