summaryrefslogtreecommitdiff
path: root/kexc25519.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-01-21 10:40:11 +0000
committerDamien Miller <djm@mindrot.org>2019-01-21 23:13:03 +1100
commitaaca72d6f1279b842066e07bff797019efeb2c23 (patch)
tree1c052b62822f198ac6cfc33235345703f86e7925 /kexc25519.c
parent70867e1ca2eb08bbd494fe9c568df4fd3b35b867 (diff)
upstream: rename kex->kem_client_pub -> kex->client_pub now that
KEM has been renamed to kexgen from markus@ ok djm@ OpenBSD-Commit-ID: fac6da5dc63530ad0da537db022a9a4cfbe8bed8
Diffstat (limited to 'kexc25519.c')
-rw-r--r--kexc25519.c55
1 files changed, 2 insertions, 53 deletions
diff --git a/kexc25519.c b/kexc25519.c
index ec5bb574f..f13d766d7 100644
--- a/kexc25519.c
+++ b/kexc25519.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexc25519.c,v 1.15 2019/01/21 10:35:09 djm Exp $ */ 1/* $OpenBSD: kexc25519.c,v 1.17 2019/01/21 10:40:11 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2019 Markus Friedl. All rights reserved. 3 * Copyright (c) 2019 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved. 4 * Copyright (c) 2010 Damien Miller. All rights reserved.
@@ -89,57 +89,6 @@ kexc25519_shared_key(const u_char key[CURVE25519_SIZE],
89} 89}
90 90
91int 91int
92kex_c25519_hash(
93 int hash_alg,
94 const struct sshbuf *client_version,
95 const struct sshbuf *server_version,
96 const u_char *ckexinit, size_t ckexinitlen,
97 const u_char *skexinit, size_t skexinitlen,
98 const u_char *serverhostkeyblob, size_t sbloblen,
99 const struct sshbuf *client_pub,
100 const struct sshbuf *server_pub,
101 const struct sshbuf *shared_secret,
102 u_char *hash, size_t *hashlen)
103{
104 struct sshbuf *b;
105 int r;
106
107 if (*hashlen < ssh_digest_bytes(hash_alg))
108 return SSH_ERR_INVALID_ARGUMENT;
109 if ((b = sshbuf_new()) == NULL)
110 return SSH_ERR_ALLOC_FAIL;
111 if ((r = sshbuf_put_stringb(b, client_version)) != 0 ||
112 (r = sshbuf_put_stringb(b, server_version)) != 0 ||
113 /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */
114 (r = sshbuf_put_u32(b, ckexinitlen+1)) != 0 ||
115 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||
116 (r = sshbuf_put(b, ckexinit, ckexinitlen)) != 0 ||
117 (r = sshbuf_put_u32(b, skexinitlen+1)) != 0 ||
118 (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||
119 (r = sshbuf_put(b, skexinit, skexinitlen)) != 0 ||
120 (r = sshbuf_put_string(b, serverhostkeyblob, sbloblen)) != 0 ||
121 (r = sshbuf_put_stringb(b, client_pub)) != 0 ||
122 (r = sshbuf_put_stringb(b, server_pub)) != 0 ||
123 (r = sshbuf_putb(b, shared_secret)) != 0) {
124 sshbuf_free(b);
125 return r;
126 }
127#ifdef DEBUG_KEX
128 sshbuf_dump(b, stderr);
129#endif
130 if (ssh_digest_buffer(hash_alg, b, hash, *hashlen) != 0) {
131 sshbuf_free(b);
132 return SSH_ERR_LIBCRYPTO_ERROR;
133 }
134 sshbuf_free(b);
135 *hashlen = ssh_digest_bytes(hash_alg);
136#ifdef DEBUG_KEX
137 dump_digest("hash", hash, *hashlen);
138#endif
139 return 0;
140}
141
142int
143kex_c25519_keypair(struct kex *kex) 92kex_c25519_keypair(struct kex *kex)
144{ 93{
145 struct sshbuf *buf = NULL; 94 struct sshbuf *buf = NULL;
@@ -154,7 +103,7 @@ kex_c25519_keypair(struct kex *kex)
154#ifdef DEBUG_KEXECDH 103#ifdef DEBUG_KEXECDH
155 dump_digest("client public key c25519:", cp, CURVE25519_SIZE); 104 dump_digest("client public key c25519:", cp, CURVE25519_SIZE);
156#endif 105#endif
157 kex->kem_client_pub = buf; 106 kex->client_pub = buf;
158 buf = NULL; 107 buf = NULL;
159 out: 108 out:
160 sshbuf_free(buf); 109 sshbuf_free(buf);