Skip to content

Commit

Permalink
904: openssl3 support
Browse files Browse the repository at this point in the history
Don't build the Windows stuff with openssl yet. Should give some
time for people to move away from blowfish first.

Change-Id: I947ffef949f2fe3c37e48dced25c925c6d64fca4
  • Loading branch information
grke committed Aug 23, 2022
1 parent af31e12 commit e7ef998
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 16 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ runner_SOURCES = \
utest/test_handy_extra.c \
utest/test_hexmap.c \
utest/test_lock.c \
utest/test_md5.c \
utest/test_pathcmp.c \
utest/test_rs_buf.c \
utest/test_slist.c \
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Blowfish has been deprecated by openssl.
Burp will now encrypt new files with AES-CBC-256, but will still be able
to decrypt files encrypted with blowfish as long as your openssl library
supports it.
The Windows installer will continue to come with openssl-1.1 for a few months,
to allow time for people to switch from blowfish.

3.1.0
-----
Expand Down
2 changes: 0 additions & 2 deletions src/handy_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
#include "handy_extra.h"
#include "sbuf.h"

/* Not ready yet
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
#include <openssl/provider.h>
#endif
*/

static int do_encryption(struct asfd *asfd, EVP_CIPHER_CTX *ctx,
uint8_t *inbuf, int inlen, uint8_t *outbuf, int *outlen,
Expand Down
12 changes: 5 additions & 7 deletions src/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
#include "log.h"
#include "md5.h"

/* Not ready yet
#if OPENSSL_VERSION_NUMBER < 0x30000000L
*/
#if 1

struct md5 *md5_alloc(
const char *func
Expand Down Expand Up @@ -58,7 +55,7 @@ struct md5 *md5_alloc(
struct md5 *md5;
if(!(md5=(struct md5 *)calloc_w(1, sizeof(struct md5), func)))
return NULL;
if((md5->ctx=EVP_MD_CTX_new()))
if((md5->ctx=EVP_MD_CTX_create()))
{
#ifdef UTEST
alloc_count++;
Expand All @@ -75,8 +72,9 @@ void md5_free(
) {
if(!md5 || !*md5)
return;
free_v((void **)&(*md5)->ctx);
EVP_MD_CTX_free((*md5)->ctx);
if ((*md5)->ctx)
EVP_MD_CTX_free((*md5)->ctx);
free_v((void **)md5);
#ifdef UTEST
alloc_count--;
#endif
Expand All @@ -86,7 +84,7 @@ void md5_free(
int md5_init(
struct md5 *md5
) {
return EVP_MD_CTX_init(md5->ctx);
return EVP_DigestInit_ex(md5->ctx, EVP_md5(), NULL);
}

int md5_update(
Expand Down
3 changes: 0 additions & 3 deletions src/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

#include <openssl/md5.h>

/* Not ready yet
#if OPENSSL_VERSION_NUMBER < 0x30000000L
*/
#if 1
struct md5 {
MD5_CTX *ctx;
};
Expand Down
5 changes: 1 addition & 4 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ int ssl_do_accept(SSL *ssl)
}
}

/* Not ready yet
#if OPENSSL_VERSION_NUMBER < 0x30000000L
*/
#if 1
int ssl_load_dh_params(SSL_CTX *ctx, struct conf **confs)
{
DH *ret=0;
Expand Down Expand Up @@ -84,7 +81,7 @@ int ssl_load_dh_params(SSL_CTX *ctx, struct conf **confs)
return -1;
}

if(!OSSL_DECODER_from_bio(dctx, bio))
if(OSSL_DECODER_from_bio(dctx, bio))
{
logp_ssl_err("Decoding failure for: %s\n", ssl_dhfile);
BIO_free(bio);
Expand Down
1 change: 1 addition & 0 deletions src/win32/utest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ CLIENT_OBJS = \
$(OBJDIR)/utest/test_fzp.o \
$(OBJDIR)/utest/test_handy_extra.o \
$(OBJDIR)/utest/test_hexmap.o \
$(OBJDIR)/utest/test_md5.o \
$(OBJDIR)/utest/test_pathcmp.o \
$(OBJDIR)/utest/test_rs_buf.o \
$(OBJDIR)/utest/test_slist.o \
Expand Down
1 change: 1 addition & 0 deletions utest/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ int main(int argc, char *argv[], char *envp[])
srunner_add_suite(sr, suite_fzp());
srunner_add_suite(sr, suite_handy_extra());
srunner_add_suite(sr, suite_hexmap());
srunner_add_suite(sr, suite_md5());
srunner_add_suite(sr, suite_pathcmp());
srunner_add_suite(sr, suite_rs_buf());
srunner_add_suite(sr, suite_slist());
Expand Down
1 change: 1 addition & 0 deletions utest/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Suite *suite_fzp(void);
Suite *suite_handy_extra(void);
Suite *suite_hexmap(void);
Suite *suite_lock(void);
Suite *suite_md5(void);
Suite *suite_pathcmp(void);
Suite *suite_rs_buf(void);
Suite *suite_server_auth(void);
Expand Down
42 changes: 42 additions & 0 deletions utest/test_md5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <check.h>
#include <stdlib.h>
#include <string.h>
#include "../src/alloc.h"
#include "../src/hexmap.h"
#include "../src/md5.h"
#include "test.h"

START_TEST(test_md5)
{
uint8_t checksum[MD5_DIGEST_LENGTH];
struct md5 *md5;
fail_unless((md5=md5_alloc(__func__))!=NULL);
fail_unless(md5_init(md5));

fail_unless(md5_update(md5, "blah", strlen("blah"))!=4);
fail_unless(md5_final(md5, checksum)!=16);
ck_assert_str_eq(
"6f1ed002ab5595859014ebf0951522d9",
bytes_to_md5str(checksum)
);

md5_free(&md5);
fail_unless(md5==NULL);
alloc_check();
}
END_TEST

Suite *suite_md5(void)
{
Suite *s;
TCase *tc_core;

s=suite_create("md5");

tc_core=tcase_create("Core");

tcase_add_test(tc_core, test_md5);
suite_add_tcase(s, tc_core);

return s;
}

0 comments on commit e7ef998

Please sign in to comment.