Skip to content

Commit

Permalink
WIP: keynote: fix compilation for openssl v3
Browse files Browse the repository at this point in the history
This patches the sources so that the library and the test program
can be compiled with openssl version 3.

There is no new upstream version of the library since 3.2.

The test finishes successful, but I'm not sure, if all parts of the fix
are correct.

Issue genodelabs#342
  • Loading branch information
trimpim committed Oct 2, 2023
1 parent 3edf827 commit 92e90b9
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/mk/keynote.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LIBS += libc libm libcrypto
SHARED_LIB = yes

INC_DIR += $(REP_DIR)/src/lib/keynote
INC_DIR += $(OPENSSL_DIR)/src/lib/openssl/crypto
INC_DIR += $(OPENSSL_DIR)/src/lib/openssl/include

# keynote headres
INC_DIR += $(KEYNOTE_DIR)/include
Expand Down
2 changes: 1 addition & 1 deletion ports/keynote.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3c2238229a41f10ba99b829eb9a9f5efa318888f
4abf2f64ea2e50d63d74e1543f05dff62b0c1b3e
3 changes: 2 additions & 1 deletion ports/keynote.port
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ URL(keynote) := https://www.cs.columbia.edu/~angelos/Code/keynote.tar.gz
SHA(keynote) :=62f7a9d57ceb6bcdd47b604b637a7ac8ed337cef0ab02f1fa28b7e61c9b15821
DIR(keynote) := src/lib/keynote


PATCHES := src/lib/keynote/openss3.patch
PATCH_OPT := -N -p1 -d ${DIR(keynote)}

DIRS := include/keynote
DIR_CONTENT(include/keynote) := src/lib/keynote/keynote.h\
Expand Down
91 changes: 91 additions & 0 deletions src/lib/keynote/openss3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
diff --git a/auxil.c b/auxil.c
index 61f3acc..f444f87 100644
--- a/auxil.c
+++ b/auxil.c
@@ -40,6 +40,10 @@
#include "assertion.h"
#include "signature.h"

+
+#include <dsa/dsa_local.h>
+#include <rsa/rsa_local.h>
+
/*
* Get some sort of key-hash for hash table indexing purposes.
*/
@@ -61,9 +65,9 @@ keynote_keyhash(void *key, int alg)
#ifdef CRYPTO
case KEYNOTE_ALGORITHM_DSA:
dsa = (DSA *) key;
- res += BN_mod_word(dsa->p, HASHTABLESIZE);
- res += BN_mod_word(dsa->q, HASHTABLESIZE);
- res += BN_mod_word(dsa->g, HASHTABLESIZE);
+ res += BN_mod_word(dsa->params.p, HASHTABLESIZE);
+ res += BN_mod_word(dsa->params.q, HASHTABLESIZE);
+ res += BN_mod_word(dsa->params.g, HASHTABLESIZE);
res += BN_mod_word(dsa->pub_key, HASHTABLESIZE);
return res % HASHTABLESIZE;

diff --git a/header.h b/header.h
index 229aad8..c1c138f 100644
--- a/header.h
+++ b/header.h
@@ -32,7 +32,7 @@ extern int kvparse(), kvlex();
extern void kverror(char *);

/* Variables */
-int sessid;
+extern int sessid;

/* Defines */
#define SEED_LEN 40
diff --git a/keynote-verify.c b/keynote-verify.c
index 4233d89..43526f9 100644
--- a/keynote-verify.c
+++ b/keynote-verify.c
@@ -56,6 +56,8 @@
#include "header.h"
#include "keynote.h"

+int sessid;
+
void
verifyusage(void)
{
diff --git a/signature.c b/signature.c
index 3ce3521..57842fd 100644
--- a/signature.c
+++ b/signature.c
@@ -44,6 +44,10 @@
#include "assertion.h"
#include "signature.h"

+#include <crypto/evp.h>
+#include <dsa/dsa_local.h>
+#include <rsa/rsa_local.h>
+
static const char hextab[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
@@ -678,9 +682,9 @@ kn_keycompare(void *key1, void *key2, int algorithm)
#ifdef CRYPTO
p1 = (DSA *) key1;
p2 = (DSA *) key2;
- if (!BN_cmp(p1->p, p2->p) &&
- !BN_cmp(p1->q, p2->q) &&
- !BN_cmp(p1->g, p2->g) &&
+ if (!BN_cmp(p1->params.p, p2->params.p) &&
+ !BN_cmp(p1->params.q, p2->params.q) &&
+ !BN_cmp(p1->params.g, p2->params.g) &&
!BN_cmp(p1->pub_key, p2->pub_key))
return RESULT_TRUE;
else
@@ -1317,7 +1321,7 @@ kn_encode_key(struct keynote_deckey *dc, int iencoding,
return (char *) NULL;
}

- dsa->write_params = 1;
+ dsa->dirty_cnt = 1;
if (keytype == KEYNOTE_PUBLIC_KEY)
i2d_DSAPublicKey(dsa, (unsigned char **) &foo);
else
2 changes: 1 addition & 1 deletion src/test/keynote/target.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TARGET = test-keynote
LIBS =libc keynote libm
LIBS = libc keynote libm libcrypto
SRC_CC = main.cc

vpath main.cc $(PRG_DIR)/..
Expand Down

0 comments on commit 92e90b9

Please sign in to comment.