summaryrefslogtreecommitdiff
path: root/kexkemc.c
diff options
context:
space:
mode:
Diffstat (limited to 'kexkemc.c')
-rw-r--r--kexkemc.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/kexkemc.c b/kexkemc.c
index 47f15c30c..13f36a116 100644
--- a/kexkemc.c
+++ b/kexkemc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexkemc.c,v 1.1 2019/01/21 10:20:12 djm Exp $ */ 1/* $OpenBSD: kexkemc.c,v 1.2 2019/01/21 10:24:09 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2019 Markus Friedl. All rights reserved. 3 * Copyright (c) 2019 Markus Friedl. All rights reserved.
4 * 4 *
@@ -47,7 +47,18 @@ kex_kem_client(struct ssh *ssh)
47 struct kex *kex = ssh->kex; 47 struct kex *kex = ssh->kex;
48 int r; 48 int r;
49 49
50 if ((r = kex_kem_sntrup4591761x25519_keypair(kex)) != 0) 50 switch (kex->kex_type) {
51 case KEX_C25519_SHA256:
52 r = kex_c25519_keypair(kex);
53 break;
54 case KEX_KEM_SNTRUP4591761X25519_SHA512:
55 r = kex_kem_sntrup4591761x25519_keypair(kex);
56 break;
57 default:
58 r = SSH_ERR_INVALID_ARGUMENT;
59 break;
60 }
61 if (r != 0)
51 return r; 62 return r;
52 if ((r = sshpkt_start(ssh, SSH2_MSG_KEX_ECDH_INIT)) != 0 || 63 if ((r = sshpkt_start(ssh, SSH2_MSG_KEX_ECDH_INIT)) != 0 ||
53 (r = sshpkt_put_stringb(ssh, kex->kem_client_pub)) != 0 || 64 (r = sshpkt_put_stringb(ssh, kex->kem_client_pub)) != 0 ||
@@ -87,8 +98,19 @@ input_kex_kem_reply(int type, u_int32_t seq, struct ssh *ssh)
87 goto out; 98 goto out;
88 99
89 /* compute shared secret */ 100 /* compute shared secret */
90 if ((r = kex_kem_sntrup4591761x25519_dec(kex, server_pubkey, pklen, 101 switch (kex->kex_type) {
91 &shared_secret)) != 0) 102 case KEX_C25519_SHA256:
103 r = kex_c25519_dec(kex, server_pubkey, pklen, &shared_secret);
104 break;
105 case KEX_KEM_SNTRUP4591761X25519_SHA512:
106 r = kex_kem_sntrup4591761x25519_dec(kex, server_pubkey, pklen,
107 &shared_secret);
108 break;
109 default:
110 r = SSH_ERR_INVALID_ARGUMENT;
111 break;
112 }
113 if (r !=0 )
92 goto out; 114 goto out;
93 115
94 /* calc and verify H */ 116 /* calc and verify H */