summaryrefslogtreecommitdiff
path: root/sshkey.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-07-16 13:18:39 +0000
committerDamien Miller <djm@mindrot.org>2019-07-16 23:23:05 +1000
commit16dd8b2c78a0de106c7429e2a294d203f6bda3c7 (patch)
treec1f6e71fe7aa7985f055b6a66926def4c876dcb7 /sshkey.c
parent45478898f9590b5cc8bc7104e573b84be67443b0 (diff)
upstream: remove mostly vestigal uuencode.[ch]; moving the only unique
functionality there (wrapping of base64-encoded data) to sshbuf functions; feedback and ok markus@ OpenBSD-Commit-ID: 4dba6735d88c57232f6fccec8a08bdcfea44ac4c
Diffstat (limited to 'sshkey.c')
-rw-r--r--sshkey.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/sshkey.c b/sshkey.c
index a0cea9257..9956a08b9 100644
--- a/sshkey.c
+++ b/sshkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshkey.c,v 1.80 2019/07/15 13:16:29 djm Exp $ */ 1/* $OpenBSD: sshkey.c,v 1.81 2019/07/16 13:18:39 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved. 4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved.
@@ -1402,7 +1402,7 @@ sshkey_to_base64(const struct sshkey *key, char **b64p)
1402 return SSH_ERR_ALLOC_FAIL; 1402 return SSH_ERR_ALLOC_FAIL;
1403 if ((r = sshkey_putb(key, b)) != 0) 1403 if ((r = sshkey_putb(key, b)) != 0)
1404 goto out; 1404 goto out;
1405 if ((uu = sshbuf_dtob64(b)) == NULL) { 1405 if ((uu = sshbuf_dtob64_string(b, 0)) == NULL) {
1406 r = SSH_ERR_ALLOC_FAIL; 1406 r = SSH_ERR_ALLOC_FAIL;
1407 goto out; 1407 goto out;
1408 } 1408 }
@@ -3709,25 +3709,12 @@ sshkey_private_to_blob2(struct sshkey *prv, struct sshbuf *blob,
3709 sshbuf_ptr(encrypted), sshbuf_len(encrypted), 0, authlen)) != 0) 3709 sshbuf_ptr(encrypted), sshbuf_len(encrypted), 0, authlen)) != 0)
3710 goto out; 3710 goto out;
3711 3711
3712 /* uuencode */
3713 if ((b64 = sshbuf_dtob64(encoded)) == NULL) {
3714 r = SSH_ERR_ALLOC_FAIL;
3715 goto out;
3716 }
3717
3718 sshbuf_reset(blob); 3712 sshbuf_reset(blob);
3719 if ((r = sshbuf_put(blob, MARK_BEGIN, MARK_BEGIN_LEN)) != 0) 3713
3720 goto out; 3714 /* assemble uuencoded key */
3721 for (i = 0; i < strlen(b64); i++) { 3715 if ((r = sshbuf_put(blob, MARK_BEGIN, MARK_BEGIN_LEN)) != 0 ||
3722 if ((r = sshbuf_put_u8(blob, b64[i])) != 0) 3716 (r = sshbuf_dtob64(encoded, blob, 1)) != 0 ||
3723 goto out; 3717 (r = sshbuf_put(blob, MARK_END, MARK_END_LEN)) != 0)
3724 /* insert line breaks */
3725 if (i % 70 == 69 && (r = sshbuf_put_u8(blob, '\n')) != 0)
3726 goto out;
3727 }
3728 if (i % 70 != 69 && (r = sshbuf_put_u8(blob, '\n')) != 0)
3729 goto out;
3730 if ((r = sshbuf_put(blob, MARK_END, MARK_END_LEN)) != 0)
3731 goto out; 3718 goto out;
3732 3719
3733 /* success */ 3720 /* success */