summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2016-11-04 14:43:57 +0200
committerTanu Kaskinen <tanuk@iki.fi>2016-11-04 16:30:37 +0200
commite262379eb880b9a9eaf2142899872dc927ef809d (patch)
tree6d5c18149c77e70b0466f4360bb92e6935928d21
parent11a0c2ef5d29e346673f40179f97272db19784b0 (diff)
raop: add compatibility with openssl 1.1.0
Openssl 1.1.0 made all structs opaque, which caused a build failure in raop_client.c. The struct member assignments are now replaced with a call to RSA_set0_key(). BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=96726 Reviewed-by: Felipe Sateler <fsateler@debian.org>
-rw-r--r--src/modules/raop/raop_client.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/modules/raop/raop_client.c b/src/modules/raop/raop_client.c
index 3b6c36ecc..864c5580c 100644
--- a/src/modules/raop/raop_client.c
+++ b/src/modules/raop/raop_client.c
@@ -68,6 +68,21 @@
#define RAOP_PORT 5000
+/* Openssl 1.1.0 broke compatibility. Before 1.1.0 we had to set RSA->n and
+ * RSA->e manually, but after 1.1.0 the RSA struct is opaque and we have to use
+ * RSA_set0_key(). RSA_set0_key() is a new function added in 1.1.0. We could
+ * depend on openssl 1.1.0, but it may take some time before distributions will
+ * be able to upgrade to the new openssl version. To insulate ourselves from
+ * such transition problems, let's implement RSA_set0_key() ourselves if it's
+ * not available. */
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+static int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) {
+ r->n = n;
+ r->e = e;
+ return 1;
+}
+#endif
+
struct pa_raop_client {
pa_core *core;
char *host;
@@ -161,12 +176,15 @@ static int rsa_encrypt(uint8_t *text, int len, uint8_t *res) {
uint8_t exponent[8];
int size;
RSA *rsa;
+ BIGNUM *n_bn;
+ BIGNUM *e_bn;
rsa = RSA_new();
size = pa_base64_decode(n, modules);
- rsa->n = BN_bin2bn(modules, size, NULL);
+ n_bn = BN_bin2bn(modules, size, NULL);
size = pa_base64_decode(e, exponent);
- rsa->e = BN_bin2bn(exponent, size, NULL);
+ e_bn = BN_bin2bn(exponent, size, NULL);
+ RSA_set0_key(rsa, n_bn, e_bn, NULL);
size = RSA_public_encrypt(len, text, res, rsa, RSA_PKCS1_OAEP_PADDING);
RSA_free(rsa);