diff options
author | tb <> | 2023-08-12 06:28:04 +0000 |
---|---|---|
committer | tb <> | 2023-08-12 06:28:04 +0000 |
commit | 725eaa09b2466cc790c34568af765f98f47f5804 (patch) | |
tree | 6fb58b64b2f18e88b42e0df47b82f78479db2b14 /src | |
parent | 60397ec4d8315868778bccc17bd8b6d5557b7bd0 (diff) | |
download | openbsd-725eaa09b2466cc790c34568af765f98f47f5804.tar.gz openbsd-725eaa09b2466cc790c34568af765f98f47f5804.tar.bz2 openbsd-725eaa09b2466cc790c34568af765f98f47f5804.zip |
a is a silly name for a DH
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/dh/dhtest.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/regress/lib/libcrypto/dh/dhtest.c b/src/regress/lib/libcrypto/dh/dhtest.c index 47203fa574..7bd278b1b6 100644 --- a/src/regress/lib/libcrypto/dh/dhtest.c +++ b/src/regress/lib/libcrypto/dh/dhtest.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dhtest.c,v 1.10 2023/08/12 06:25:26 tb Exp $ */ | 1 | /* $OpenBSD: dhtest.c,v 1.11 2023/08/12 06:28:04 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -96,7 +96,7 @@ int | |||
96 | main(int argc, char *argv[]) | 96 | main(int argc, char *argv[]) |
97 | { | 97 | { |
98 | BN_GENCB *_cb; | 98 | BN_GENCB *_cb; |
99 | DH *a = NULL; | 99 | DH *dh = NULL; |
100 | unsigned char *abuf = NULL; | 100 | unsigned char *abuf = NULL; |
101 | int i, alen, aout; | 101 | int i, alen, aout; |
102 | int ret = 1; | 102 | int ret = 1; |
@@ -105,20 +105,20 @@ main(int argc, char *argv[]) | |||
105 | err(1, "BN_GENCB_new"); | 105 | err(1, "BN_GENCB_new"); |
106 | 106 | ||
107 | BN_GENCB_set(_cb, &cb, NULL); | 107 | BN_GENCB_set(_cb, &cb, NULL); |
108 | if ((a = DH_new()) == NULL) | 108 | if ((dh = DH_new()) == NULL) |
109 | goto err; | 109 | goto err; |
110 | 110 | ||
111 | #ifdef OPENSSL_NO_ENGINE | 111 | #ifdef OPENSSL_NO_ENGINE |
112 | if (DH_get0_engine(a) != NULL) { | 112 | if (DH_get0_engine(dh) != NULL) { |
113 | fprintf(stderr, "ENGINE was not NULL\n"); | 113 | fprintf(stderr, "ENGINE was not NULL\n"); |
114 | goto err; | 114 | goto err; |
115 | } | 115 | } |
116 | #endif | 116 | #endif |
117 | 117 | ||
118 | if (!DH_generate_parameters_ex(a, 64, DH_GENERATOR_5, _cb)) | 118 | if (!DH_generate_parameters_ex(dh, 64, DH_GENERATOR_5, _cb)) |
119 | goto err; | 119 | goto err; |
120 | 120 | ||
121 | if (!DH_check(a, &i)) | 121 | if (!DH_check(dh, &i)) |
122 | goto err; | 122 | goto err; |
123 | if (i & DH_CHECK_P_NOT_PRIME) | 123 | if (i & DH_CHECK_P_NOT_PRIME) |
124 | printf("p value is not prime\n"); | 124 | printf("p value is not prime\n"); |
@@ -130,27 +130,27 @@ main(int argc, char *argv[]) | |||
130 | printf("the g value is not a generator\n"); | 130 | printf("the g value is not a generator\n"); |
131 | 131 | ||
132 | printf("\np = "); | 132 | printf("\np = "); |
133 | if (!BN_print_fp(stdout, DH_get0_p(a))) | 133 | if (!BN_print_fp(stdout, DH_get0_p(dh))) |
134 | goto err; | 134 | goto err; |
135 | printf("\ng = "); | 135 | printf("\ng = "); |
136 | if (!BN_print_fp(stdout, DH_get0_g(a))) | 136 | if (!BN_print_fp(stdout, DH_get0_g(dh))) |
137 | goto err; | 137 | goto err; |
138 | printf("\n"); | 138 | printf("\n"); |
139 | 139 | ||
140 | if (!DH_generate_key(a)) | 140 | if (!DH_generate_key(dh)) |
141 | goto err; | 141 | goto err; |
142 | printf("pri1 = "); | 142 | printf("pri1 = "); |
143 | if (!BN_print_fp(stdout, DH_get0_priv_key(a))) | 143 | if (!BN_print_fp(stdout, DH_get0_priv_key(dh))) |
144 | goto err; | 144 | goto err; |
145 | printf("\npub1 = "); | 145 | printf("\npub1 = "); |
146 | if (!BN_print_fp(stdout, DH_get0_pub_key(a))) | 146 | if (!BN_print_fp(stdout, DH_get0_pub_key(dh))) |
147 | goto err; | 147 | goto err; |
148 | printf("\n"); | 148 | printf("\n"); |
149 | 149 | ||
150 | alen = DH_size(a); | 150 | alen = DH_size(dh); |
151 | if ((abuf = malloc(alen)) == NULL) | 151 | if ((abuf = malloc(alen)) == NULL) |
152 | err(1, "malloc"); | 152 | err(1, "malloc"); |
153 | aout = DH_compute_key(abuf, DH_get0_pub_key(a), a); | 153 | aout = DH_compute_key(abuf, DH_get0_pub_key(dh), dh); |
154 | 154 | ||
155 | printf("key1 = "); | 155 | printf("key1 = "); |
156 | for (i = 0; i < aout; i++) { | 156 | for (i = 0; i < aout; i++) { |
@@ -168,7 +168,7 @@ err: | |||
168 | ERR_print_errors_fp(stderr); | 168 | ERR_print_errors_fp(stderr); |
169 | 169 | ||
170 | free(abuf); | 170 | free(abuf); |
171 | DH_free(a); | 171 | DH_free(dh); |
172 | BN_GENCB_free(_cb); | 172 | BN_GENCB_free(_cb); |
173 | 173 | ||
174 | return (ret); | 174 | return (ret); |