summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_kex.c
diff options
context:
space:
mode:
authorjsing <>2020-04-18 14:07:56 +0000
committerjsing <>2020-04-18 14:07:56 +0000
commitd82ca953a5e7d61a103ae2e7c9744db82d74f016 (patch)
treeb56b281a4429eb0ae90ce91eefde6f9a80d7d18f /src/lib/libssl/ssl_kex.c
parent33d8c111a77ac681a8ecffcda0713ec96c6fe953 (diff)
downloadopenbsd-d82ca953a5e7d61a103ae2e7c9744db82d74f016.tar.gz
openbsd-d82ca953a5e7d61a103ae2e7c9744db82d74f016.tar.bz2
openbsd-d82ca953a5e7d61a103ae2e7c9744db82d74f016.zip
Expose the peer ephemeral public key used for TLSv1.3 key exchange.
SSL_get_server_tmp_key() provides the peer ephemeral public key used for key exchange. In the case of TLSv1.3 this is essentially the peer public key from the key share used for TLSv1.3 key exchange, hence make it availaable via SSL_get_server_tmp_key(). ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/ssl_kex.c')
-rw-r--r--src/lib/libssl/ssl_kex.c43
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
25int 27int
28ssl_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
66int
26ssl_kex_generate_ecdhe_ecp(EC_KEY *ecdh, int nid) 67ssl_kex_generate_ecdhe_ecp(EC_KEY *ecdh, int nid)
27{ 68{
28 EC_GROUP *group; 69 EC_GROUP *group;