diff options
Diffstat (limited to 'src/lib/libssl/ssl_kex.c')
-rw-r--r-- | src/lib/libssl/ssl_kex.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/lib/libssl/ssl_kex.c b/src/lib/libssl/ssl_kex.c index 439c1702b3..9f05fd60c9 100644 --- a/src/lib/libssl/ssl_kex.c +++ b/src/lib/libssl/ssl_kex.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_kex.c,v 1.1 2020/01/30 16:25:09 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_kex.c,v 1.2 2020/04/18 14:07:56 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -19,10 +19,51 @@ | |||
19 | 19 | ||
20 | #include <openssl/ec.h> | 20 | #include <openssl/ec.h> |
21 | #include <openssl/ecdh.h> | 21 | #include <openssl/ecdh.h> |
22 | #include <openssl/evp.h> | ||
23 | #include <openssl/objects.h> | ||
22 | 24 | ||
23 | #include "bytestring.h" | 25 | #include "bytestring.h" |
24 | 26 | ||
25 | int | 27 | int |
28 | ssl_kex_dummy_ecdhe_x25519(EVP_PKEY *pkey) | ||
29 | { | ||
30 | EC_GROUP *group = NULL; | ||
31 | EC_POINT *point = NULL; | ||
32 | EC_KEY *ec_key = NULL; | ||
33 | BIGNUM *order = NULL; | ||
34 | int ret = 0; | ||
35 | |||
36 | /* Fudge up an EC_KEY that looks like X25519... */ | ||
37 | if ((group = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1)) == NULL) | ||
38 | goto err; | ||
39 | if ((point = EC_POINT_new(group)) == NULL) | ||
40 | goto err; | ||
41 | if ((order = BN_new()) == NULL) | ||
42 | goto err; | ||
43 | if (!BN_set_bit(order, 252)) | ||
44 | goto err; | ||
45 | if (!EC_GROUP_set_generator(group, point, order, NULL)) | ||
46 | goto err; | ||
47 | EC_GROUP_set_curve_name(group, NID_X25519); | ||
48 | if ((ec_key = EC_KEY_new()) == NULL) | ||
49 | goto err; | ||
50 | if (!EC_KEY_set_group(ec_key, group)) | ||
51 | goto err; | ||
52 | if (!EVP_PKEY_set1_EC_KEY(pkey, ec_key)) | ||
53 | goto err; | ||
54 | |||
55 | ret = 1; | ||
56 | |||
57 | err: | ||
58 | EC_GROUP_free(group); | ||
59 | EC_POINT_free(point); | ||
60 | EC_KEY_free(ec_key); | ||
61 | BN_free(order); | ||
62 | |||
63 | return ret; | ||
64 | } | ||
65 | |||
66 | int | ||
26 | ssl_kex_generate_ecdhe_ecp(EC_KEY *ecdh, int nid) | 67 | ssl_kex_generate_ecdhe_ecp(EC_KEY *ecdh, int nid) |
27 | { | 68 | { |
28 | EC_GROUP *group; | 69 | EC_GROUP *group; |