summaryrefslogtreecommitdiff
path: root/src/regress/lib
diff options
context:
space:
mode:
authortb <>2021-11-26 16:52:07 +0000
committertb <>2021-11-26 16:52:07 +0000
commit6a2276e5a7885ebbd30cb16c476c7652740dc5ef (patch)
tree88e6b36c84fb7f1efc3531842c68c994edc8ceb9 /src/regress/lib
parente84f8ffa4a738212bdc72ac70cde22346dc369dd (diff)
downloadopenbsd-6a2276e5a7885ebbd30cb16c476c7652740dc5ef.tar.gz
openbsd-6a2276e5a7885ebbd30cb16c476c7652740dc5ef.tar.bz2
openbsd-6a2276e5a7885ebbd30cb16c476c7652740dc5ef.zip
make the bn/mont test compile with opaque DH.
Diffstat (limited to 'src/regress/lib')
-rw-r--r--src/regress/lib/libcrypto/bn/mont/mont.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/regress/lib/libcrypto/bn/mont/mont.c b/src/regress/lib/libcrypto/bn/mont/mont.c
index 54626b5c38..2c311af417 100644
--- a/src/regress/lib/libcrypto/bn/mont/mont.c
+++ b/src/regress/lib/libcrypto/bn/mont/mont.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mont.c,v 1.4 2021/04/04 19:36:09 tb Exp $ */ 1/* $OpenBSD: mont.c,v 1.5 2021/11/26 16:52:07 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 Miodrag Vallat. 4 * Copyright (c) 2014 Miodrag Vallat.
@@ -35,6 +35,8 @@ int
35main(int argc, char *argv[]) 35main(int argc, char *argv[])
36{ 36{
37 DH *dh = NULL; 37 DH *dh = NULL;
38 BIGNUM *priv_key = NULL;
39 const BIGNUM *pub_key;
38 unsigned char *key = NULL; 40 unsigned char *key = NULL;
39 unsigned char r[32 + 16 * 8]; 41 unsigned char r[32 + 16 * 8];
40 size_t privsz; 42 size_t privsz;
@@ -50,16 +52,21 @@ main(int argc, char *argv[])
50 goto err; 52 goto err;
51 53
52 /* force private key to be much larger than public one */ 54 /* force private key to be much larger than public one */
53 dh->priv_key = BN_bin2bn(r, privsz, NULL); 55 priv_key = BN_bin2bn(r, privsz, NULL);
54 if (dh->priv_key == NULL) 56 if (priv_key == NULL)
55 goto err; 57 goto err;
56 58
59 if (!DH_set0_key(dh, NULL, priv_key))
60 goto err;
61 priv_key = NULL;
62
57 if (DH_generate_key(dh) == 0) 63 if (DH_generate_key(dh) == 0)
58 goto err; 64 goto err;
59 key = malloc(DH_size(dh)); 65 key = malloc(DH_size(dh));
60 if (key == NULL) 66 if (key == NULL)
61 err(1, "malloc"); 67 err(1, "malloc");
62 if (DH_compute_key(key, dh->pub_key, dh) == -1) 68 DH_get0_key(dh, &pub_key, NULL);
69 if (DH_compute_key(key, pub_key, dh) == -1)
63 goto err; 70 goto err;
64 71
65 free(key); 72 free(key);
@@ -73,6 +80,7 @@ main(int argc, char *argv[])
73 err: 80 err:
74 ERR_print_errors_fp(stderr); 81 ERR_print_errors_fp(stderr);
75 free(key); 82 free(key);
83 BN_free(priv_key);
76 DH_free(dh); 84 DH_free(dh);
77 return 1; 85 return 1;
78} 86}