diff mbox

libstb: Fix build in OpenSSL 1.1

Message ID 20170517061455.4513-1-ruscur@russell.cc
State Accepted
Headers show

Commit Message

Russell Currey May 17, 2017, 6:14 a.m. UTC
OpenSSL has some API changes which causes a build break in libstb.
Specifically, directly accessing some members of a signature now requires using
a helper.

This fixes things in OpenSSL 1.1 and has no effect on OpenSSL 1.0.

The build failure was as follows:

[ HOSTCC ] libstb/create-container.c
In file included from /usr/include/openssl/asn1.h:24:0,
                 from /usr/include/openssl/ec.h:30,
                 from libstb/create-container.c:36:
libstb/create-container.c: In function ‘getSigRaw’:
libstb/create-container.c:104:31: error: dereferencing pointer to incomplete
				  type ‘ECDSA_SIG {aka struct ECDSA_SIG_st}’
  rlen = BN_num_bytes(signature->r);
                               ^

Signed-off-by: Russell Currey <ruscur@russell.cc>
---
 libstb/create-container.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Stewart Smith May 18, 2017, 6:45 a.m. UTC | #1
Russell Currey <ruscur@russell.cc> writes:
> OpenSSL has some API changes which causes a build break in libstb.
> Specifically, directly accessing some members of a signature now requires using
> a helper.
>
> This fixes things in OpenSSL 1.1 and has no effect on OpenSSL 1.0.
>
> The build failure was as follows:
>
> [ HOSTCC ] libstb/create-container.c
> In file included from /usr/include/openssl/asn1.h:24:0,
>                  from /usr/include/openssl/ec.h:30,
>                  from libstb/create-container.c:36:
> libstb/create-container.c: In function ‘getSigRaw’:
> libstb/create-container.c:104:31: error: dereferencing pointer to incomplete
> 				  type ‘ECDSA_SIG {aka struct ECDSA_SIG_st}’
>   rlen = BN_num_bytes(signature->r);
>                                ^
>
> Signed-off-by: Russell Currey <ruscur@russell.cc>

Sweet - this fixes the last build failure on fedora-rawhide in travis!

Merged to master as of 40cf5a391a80a75f8827d2427e49a92e73871b00
Russell Currey May 18, 2017, 6:47 a.m. UTC | #2
On Thu, 2017-05-18 at 16:45 +1000, Stewart Smith wrote:
> Russell Currey <ruscur@russell.cc> writes:
> > OpenSSL has some API changes which causes a build break in libstb.
> > Specifically, directly accessing some members of a signature now requires
> > using
> > a helper.
> > 
> > This fixes things in OpenSSL 1.1 and has no effect on OpenSSL 1.0.
> > 
> > The build failure was as follows:
> > 
> > [ HOSTCC ] libstb/create-container.c
> > In file included from /usr/include/openssl/asn1.h:24:0,
> >                  from /usr/include/openssl/ec.h:30,
> >                  from libstb/create-container.c:36:
> > libstb/create-container.c: In function ‘getSigRaw’:
> > libstb/create-container.c:104:31: error: dereferencing pointer to incomplete
> > 				  type ‘ECDSA_SIG {aka struct ECDSA_SIG_st}’
> >   rlen = BN_num_bytes(signature->r);
> >                                ^
> > 
> > Signed-off-by: Russell Currey <ruscur@russell.cc>
> 
> Sweet - this fixes the last build failure on fedora-rawhide in travis!

The joys of being an Arch user, I hit this before everyone else :)

> 
> Merged to master as of 40cf5a391a80a75f8827d2427e49a92e73871b00
>
Stewart Smith May 19, 2017, 1:37 a.m. UTC | #3
Russell Currey <ruscur@russell.cc> writes:
> On Thu, 2017-05-18 at 16:45 +1000, Stewart Smith wrote:
>> Russell Currey <ruscur@russell.cc> writes:
>> > OpenSSL has some API changes which causes a build break in libstb.
>> > Specifically, directly accessing some members of a signature now requires
>> > using
>> > a helper.
>> > 
>> > This fixes things in OpenSSL 1.1 and has no effect on OpenSSL 1.0.
>> > 
>> > The build failure was as follows:
>> > 
>> > [ HOSTCC ] libstb/create-container.c
>> > In file included from /usr/include/openssl/asn1.h:24:0,
>> >                  from /usr/include/openssl/ec.h:30,
>> >                  from libstb/create-container.c:36:
>> > libstb/create-container.c: In function ‘getSigRaw’:
>> > libstb/create-container.c:104:31: error: dereferencing pointer to incomplete
>> > 				  type ‘ECDSA_SIG {aka struct ECDSA_SIG_st}’
>> >   rlen = BN_num_bytes(signature->r);
>> >                                ^
>> > 
>> > Signed-off-by: Russell Currey <ruscur@russell.cc>
>> 
>> Sweet - this fixes the last build failure on fedora-rawhide in travis!
>
> The joys of being an Arch user, I hit this before everyone else :)

Feel free to add arch to the platforms build tested in travis.

Catching these things early is why I added rawhide :)
diff mbox

Patch

diff --git a/libstb/create-container.c b/libstb/create-container.c
index 437a425c..5cf80a06 100644
--- a/libstb/create-container.c
+++ b/libstb/create-container.c
@@ -88,6 +88,7 @@  void getSigRaw(ecc_signature_t *sigraw, char *inFile)
 	void *infile;
 	unsigned char outbuf[2*EC_COORDBYTES];
 	int r, rlen, roff, slen, soff;
+	const BIGNUM *sr, *ss;
 
 	fdin = open(inFile, O_RDONLY);
 	assert(fdin > 0);
@@ -101,13 +102,19 @@  void getSigRaw(ecc_signature_t *sigraw, char *inFile)
 
 	memset(&outbuf, 0, sizeof(outbuf));
 
-	rlen = BN_num_bytes(signature->r);
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+	ECDSA_SIG_get0(signature, &sr, &ss);
+#else
+	sr = signature->r;
+	ss = signature->s;
+#endif
+	rlen = BN_num_bytes(sr);
 	roff = 66 - rlen;
-	BN_bn2bin(signature->r, &outbuf[roff]);
+	BN_bn2bin(sr, &outbuf[roff]);
 
-	slen = BN_num_bytes(signature->s);
+	slen = BN_num_bytes(ss);
 	soff = 66 + (66 - slen);
-	BN_bn2bin(signature->s, &outbuf[soff]);
+	BN_bn2bin(sr, &outbuf[soff]);
 
 	if (debug)
 		printBytes((char *)"sig (RAW)    = ", outbuf, sizeof(outbuf), 32);