summaryrefslogtreecommitdiff
path: root/key.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2017-05-30 14:16:41 +0000
committerDamien Miller <djm@mindrot.org>2017-05-31 10:49:50 +1000
commit7da5df11ac788bc1133d8d598d298e33500524cc (patch)
tree9c201ad7bfbb674771d3cd17bda0c90d2523ffaa /key.c
parentff7371afd08ac0bbd957d90451d4dcd0da087ef5 (diff)
upstream commit
remove unused wrapper functions from key.[ch]; ok djm@ Upstream-ID: ea0f4016666a6817fc11f439dd4be06bab69707e
Diffstat (limited to 'key.c')
-rw-r--r--key.c177
1 files changed, 1 insertions, 176 deletions
diff --git a/key.c b/key.c
index 93f4ccb24..6e338c495 100644
--- a/key.c
+++ b/key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.c,v 1.130 2016/05/02 09:36:42 djm Exp $ */ 1/* $OpenBSD: key.c,v 1.131 2017/05/30 14:16:41 markus Exp $ */
2/* 2/*
3 * placed in the public domain 3 * placed in the public domain
4 */ 4 */
@@ -20,68 +20,6 @@
20#include "log.h" 20#include "log.h"
21#include "authfile.h" 21#include "authfile.h"
22 22
23void
24key_add_private(Key *k)
25{
26 int r;
27
28 if ((r = sshkey_add_private(k)) != 0)
29 fatal("%s: %s", __func__, ssh_err(r));
30}
31
32Key *
33key_new_private(int type)
34{
35 Key *ret = NULL;
36
37 if ((ret = sshkey_new_private(type)) == NULL)
38 fatal("%s: failed", __func__);
39 return ret;
40}
41
42int
43key_read(Key *ret, char **cpp)
44{
45 return sshkey_read(ret, cpp) == 0 ? 1 : -1;
46}
47
48int
49key_write(const Key *key, FILE *f)
50{
51 return sshkey_write(key, f) == 0 ? 1 : 0;
52}
53
54Key *
55key_generate(int type, u_int bits)
56{
57 int r;
58 Key *ret = NULL;
59
60 if ((r = sshkey_generate(type, bits, &ret)) != 0)
61 fatal("%s: %s", __func__, ssh_err(r));
62 return ret;
63}
64
65void
66key_cert_copy(const Key *from_key, Key *to_key)
67{
68 int r;
69
70 if ((r = sshkey_cert_copy(from_key, to_key)) != 0)
71 fatal("%s: %s", __func__, ssh_err(r));
72}
73
74Key *
75key_from_private(const Key *k)
76{
77 int r;
78 Key *ret = NULL;
79
80 if ((r = sshkey_from_private(k, &ret)) != 0)
81 fatal("%s: %s", __func__, ssh_err(r));
82 return ret;
83}
84
85static void 23static void
86fatal_on_fatal_errors(int r, const char *func, int extra_fatal) 24fatal_on_fatal_errors(int r, const char *func, int extra_fatal)
87{ 25{
@@ -184,19 +122,6 @@ key_demote(const Key *k)
184} 122}
185 123
186int 124int
187key_to_certified(Key *k)
188{
189 int r;
190
191 if ((r = sshkey_to_certified(k)) != 0) {
192 fatal_on_fatal_errors(r, __func__, 0);
193 error("%s: %s", __func__, ssh_err(r));
194 return -1;
195 }
196 return 0;
197}
198
199int
200key_drop_cert(Key *k) 125key_drop_cert(Key *k)
201{ 126{
202 int r; 127 int r;
@@ -210,19 +135,6 @@ key_drop_cert(Key *k)
210} 135}
211 136
212int 137int
213key_certify(Key *k, Key *ca)
214{
215 int r;
216
217 if ((r = sshkey_certify(k, ca, NULL)) != 0) {
218 fatal_on_fatal_errors(r, __func__, 0);
219 error("%s: %s", __func__, ssh_err(r));
220 return -1;
221 }
222 return 0;
223}
224
225int
226key_cert_check_authority(const Key *k, int want_host, int require_principal, 138key_cert_check_authority(const Key *k, int want_host, int require_principal,
227 const char *name, const char **reason) 139 const char *name, const char **reason)
228{ 140{
@@ -237,88 +149,8 @@ key_cert_check_authority(const Key *k, int want_host, int require_principal,
237 return 0; 149 return 0;
238} 150}
239 151
240#if defined(WITH_OPENSSL) && defined(OPENSSL_HAS_ECC)
241int
242key_ec_validate_public(const EC_GROUP *group, const EC_POINT *public)
243{
244 int r;
245
246 if ((r = sshkey_ec_validate_public(group, public)) != 0) {
247 fatal_on_fatal_errors(r, __func__, SSH_ERR_LIBCRYPTO_ERROR);
248 error("%s: %s", __func__, ssh_err(r));
249 return -1;
250 }
251 return 0;
252}
253
254int
255key_ec_validate_private(const EC_KEY *key)
256{
257 int r;
258
259 if ((r = sshkey_ec_validate_private(key)) != 0) {
260 fatal_on_fatal_errors(r, __func__, SSH_ERR_LIBCRYPTO_ERROR);
261 error("%s: %s", __func__, ssh_err(r));
262 return -1;
263 }
264 return 0;
265}
266#endif /* WITH_OPENSSL */
267
268void
269key_private_serialize(const Key *key, struct sshbuf *b)
270{
271 int r;
272
273 if ((r = sshkey_private_serialize(key, b)) != 0)
274 fatal("%s: %s", __func__, ssh_err(r));
275}
276
277Key *
278key_private_deserialize(struct sshbuf *blob)
279{
280 int r;
281 Key *ret = NULL;
282
283 if ((r = sshkey_private_deserialize(blob, &ret)) != 0) {
284 fatal_on_fatal_errors(r, __func__, SSH_ERR_LIBCRYPTO_ERROR);
285 error("%s: %s", __func__, ssh_err(r));
286 return NULL;
287 }
288 return ret;
289}
290
291/* authfile.c */ 152/* authfile.c */
292 153
293int
294key_save_private(Key *key, const char *filename, const char *passphrase,
295 const char *comment, int force_new_format, const char *new_format_cipher,
296 int new_format_rounds)
297{
298 int r;
299
300 if ((r = sshkey_save_private(key, filename, passphrase, comment,
301 force_new_format, new_format_cipher, new_format_rounds)) != 0) {
302 fatal_on_fatal_errors(r, __func__, SSH_ERR_LIBCRYPTO_ERROR);
303 error("%s: %s", __func__, ssh_err(r));
304 return 0;
305 }
306 return 1;
307}
308
309int
310key_load_file(int fd, const char *filename, struct sshbuf *blob)
311{
312 int r;
313
314 if ((r = sshkey_load_file(fd, blob)) != 0) {
315 fatal_on_fatal_errors(r, __func__, SSH_ERR_LIBCRYPTO_ERROR);
316 error("%s: %s", __func__, ssh_err(r));
317 return 0;
318 }
319 return 1;
320}
321
322Key * 154Key *
323key_load_cert(const char *filename) 155key_load_cert(const char *filename)
324{ 156{
@@ -417,10 +249,3 @@ key_load_private_type(int type, const char *filename, const char *passphrase,
417 } 249 }
418 return ret; 250 return ret;
419} 251}
420
421int
422key_perm_ok(int fd, const char *filename)
423{
424 return sshkey_perm_ok(fd, filename) == 0 ? 1 : 0;
425}
426