3PO / vdr-plugin-sc

GNU General Public License v2.0
12 stars 25 forks source link

OPENSSL_ALGORITHM_DEFINES no longer supported #4

Open Kibarak1 opened 5 years ago

Kibarak1 commented 5 years ago

Compile-Error: In file included from /usr/include/openssl/aes.h:13:0, from crypto.h:86, from crypto.c:24: /usr/include/x86_64-linux-gnu/openssl/opensslconf.h:18:3: error: #error OPENSSL_ALGORITHM_DEFINES no longer supported

error OPENSSL_ALGORITHM_DEFINES no longer supported

^~~~~ crypto.c:91:2: warning: #warning ** openssl lacks IDEA support. Using deprecated static support code. Update your openssl package. [-Wcpp]

warning ** openssl lacks IDEA support. Using deprecated static support code. Update your openssl package.

^~~ In file included from crypto.h:39:0, from crypto.c:24: crypto-bn.h:34:10: error: field ‘big’ has incomplete type ‘BIGNUM {aka bignum_st}’ BIGNUM big; ^~~ In file included from /usr/include/openssl/bn.h:32:0, from crypto-bn.h:23, from crypto.h:39, from crypto.c:24: /usr/include/openssl/ossl_typ.h:80:16: note: forward declaration of ‘BIGNUM {aka struct bignum_st}’ typedef struct bignum_st BIGNUM; ^~~~~ In file included from crypto.h:39:0, from crypto.c:24: crypto-bn.h: In constructor ‘cBN::cBN()’: crypto-bn.h:36:15: error: ‘BN_init’ was not declared in this scope cBN(void) { BN_init(&big); } ^~~ crypto-bn.h:36:15: note: suggested alternative: ‘BN_print’ cBN(void) { BN_init(&big); } ^~~ BN_print Makefile:97: recipe for target 'crypto.o' failed make[1]: *** [crypto.o] Error 1

Unter Debian Stretch. kernel-4.9.0-8-amd64,openssl (1.1.0j-1~deb9u1),libssl-dev (1.1.0j-1~deb9u1), VDR 2.4

Kibarak1 commented 5 years ago

Hinweis; BN_init() was removed in OpenSSL 1.1.0; use BN_new() instead. https://www.openssl.org/docs/man1.1.0/man3/BN_new.html

MikeDK commented 5 years ago

I ran into the same problem, and wrote a patch ...:

diff --git a/crypto-bn.h b/crypto-bn.h
index bf9bd62..c7dff61 100644
--- a/crypto-bn.h
+++ b/crypto-bn.h
@@ -31,13 +31,13 @@ void RotateBytes(unsigned char *out, const unsigned char *in, int n);

 class cBN {
 private:
-  BIGNUM big;
+  BIGNUM *big;
 public:
-  cBN(void) { BN_init(&big); }
-  ~cBN() { BN_free(&big); }
-  operator BIGNUM* () { return &big; }
-  BIGNUM *operator->() { return &big; }
-  BIGNUM *BN(void) { return &big; }
+  cBN(void) : big(BN_new()) { }
+  ~cBN() { BN_free(big); }
+  operator BIGNUM* () { return big; }
+  BIGNUM *operator->() { return big; }
+  BIGNUM *BN(void) { return big; }
   bool Get(const unsigned char *in, int n);
   bool GetLE(const unsigned char *in, int n);
   int Put(unsigned char *out, int n) const;
diff --git a/crypto.c b/crypto.c
index 84defb3..1c4e706 100644
--- a/crypto.c
+++ b/crypto.c
@@ -51,23 +51,23 @@ void RotateBytes(unsigned char *in, int n)

 bool cBN::Get(const unsigned char *in, int n)
 {
-  return BN_bin2bn(in,n,&big)!=0;
+  return BN_bin2bn(in,n,big)!=0;
 }

 int cBN::Put(unsigned char *out, int n) const
 {
-  int s=BN_num_bytes(&big);
+  int s=BN_num_bytes(big);
   if(s>n) {
     unsigned char *buff=AUTOMEM(s);
-    BN_bn2bin(&big,buff);
+    BN_bn2bin(big,buff);
     memcpy(out,buff+s-n,n);
     }
   else if(s<n) {
     int l=n-s;
     memset(out,0,l);
-    BN_bn2bin(&big,out+l);
+    BN_bn2bin(big,out+l);
     }
-  else BN_bn2bin(&big,out);
+  else BN_bn2bin(big,out);
   return s;
 }

@@ -75,7 +75,7 @@ bool cBN::GetLE(const unsigned char *in, int n)
 {
   unsigned char *tmp=AUTOMEM(n);
   RotateBytes(tmp,in,n);
-  return BN_bin2bn(tmp,n,&big)!=0;
+  return BN_bin2bn(tmp,n,big)!=0;
 }

 int cBN::PutLE(unsigned char *out, int n) const
diff --git a/crypto.h b/crypto.h
index 5603b9e..9662186 100644
--- a/crypto.h
+++ b/crypto.h
@@ -28,7 +28,7 @@
 //       (as AES_KEY is const there), but SetKey is not. Be carefull.
 //

-#define OPENSSL_ALGORITHM_DEFINES
+//#define OPENSSL_ALGORITHM_DEFINES
 #include <openssl/opensslconf.h>
 #include <openssl/opensslv.h>

diff --git a/systems/nagra/nagra2.c b/systems/nagra/nagra2.c
index 222f22b..b78e008 100644
--- a/systems/nagra/nagra2.c
+++ b/systems/nagra/nagra2.c
@@ -387,7 +387,8 @@ void cMapReg::ClearFullReg(int wsize)

 void cMapReg::PrepTmp(BIGNUM *val, int wsize)
 {
-  if(val->neg) {
+//  if(val->neg) {
+  if(BN_is_negative(val)) {
     BN_clear(tmp);
     BN_set_bit(tmp,wsize*64);
     BN_add(tmp,tmp,val);
@@ -502,7 +503,7 @@ void cMapMath::MakeJ0(BIGNUM *j, BIGNUM *d, BIGNUM *c, int bits)
 #error BN_mod_inverse is probably buggy in your openssl version
 #endif
   BN_zero(x);
-  BN_sub(j,x,d); j->neg=1;
+  BN_sub(j,x,d); BN_set_negative(j,1); //j->neg=1;
   BN_set_bit(j,0);
   BN_set_bit(x,bits);
   BN_mod_inverse(j,j,x,ctx);

If wanted, I could also generate a pull request so this gets merged ... @3PO ?

By the way ... I managed to get this running on an RockPro64 with Armbian aarch64 ... Makefile should be patched with following for aarch64...:

diff --git a/Makefile b/Makefile
index 4e9c10a..aa899f9 100644
--- a/Makefile
+++ b/Makefile
@@ -80,8 +80,9 @@ OBJS = $(PLUGIN).o data.o filter.o system.o misc.o cam.o device.o sc-version.o \
 MAXCAID := 64

 # FFdeCSA
-PARALLEL   ?= PARALLEL_128_SSE2
-CSAFLAGS   ?= -fexpensive-optimizations -fomit-frame-pointer -funroll-loops -O3 -mmmx -msse -msse2 -msse3
+CPUOPT     ?= armv8-a+crc+simd+crypto
+PARALLEL   ?= PARALLEL_128_2LONG
+CSAFLAGS   ?= -fexpensive-optimizations -fomit-frame-pointer -funroll-loops -O3
 FFDECSADIR  = FFdecsa
 FFDECSA     = $(FFDECSADIR)/FFdecsa.o
 DECSALIB    = $(FFDECSA)
3PO commented 5 years ago

THX @MikeDK,

i merged your Patch, but i didn't test it, because i do not us the sc plugin anymore.

--> https://github.com/3PO/vdr-plugin-sc/commit/f21b6ac405e146d14d8213c5769037252fe84ecd