Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 1 | /* $OpenBSD: bufaux.c,v 1.60 2014/04/30 05:29:56 djm Exp $ */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 2 | /* |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 3 | * Copyright (c) 2012 Damien Miller <djm@mindrot.org> |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 4 | * |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 5 | * Permission to use, copy, modify, and distribute this software for any |
| 6 | * purpose with or without fee is hereby granted, provided that the above |
| 7 | * copyright notice and this permission notice appear in all copies. |
Damien Miller | b38eff8 | 2000-04-01 11:09:21 +1000 | [diff] [blame] | 8 | * |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 16 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 17 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 18 | /* Emulation wrappers for legacy OpenSSH buffer API atop sshbuf */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 19 | |
Darren Tucker | 58538d7 | 2014-06-11 13:39:24 +1000 | [diff] [blame] | 20 | #include "includes.h" |
| 21 | |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 22 | #include <sys/types.h> |
| 23 | |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 24 | #include "buffer.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 25 | #include "log.h" |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 26 | #include "ssherr.h" |
Damien Miller | 3b23566 | 2002-04-23 20:42:36 +1000 | [diff] [blame] | 27 | |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 28 | int |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 29 | buffer_get_short_ret(u_short *v, Buffer *buffer) |
Damien Miller | 3b23566 | 2002-04-23 20:42:36 +1000 | [diff] [blame] | 30 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 31 | int ret; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 32 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 33 | if ((ret = sshbuf_get_u16(buffer, v)) != 0) { |
| 34 | error("%s: %s", __func__, ssh_err(ret)); |
| 35 | return -1; |
| 36 | } |
| 37 | return 0; |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | u_short |
| 41 | buffer_get_short(Buffer *buffer) |
| 42 | { |
| 43 | u_short ret; |
| 44 | |
| 45 | if (buffer_get_short_ret(&ret, buffer) == -1) |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 46 | fatal("%s: buffer error", __func__); |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 47 | |
| 48 | return (ret); |
| 49 | } |
| 50 | |
| 51 | int |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 52 | buffer_get_int_ret(u_int *v, Buffer *buffer) |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 53 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 54 | int ret; |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 55 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 56 | if ((ret = sshbuf_get_u32(buffer, v)) != 0) { |
| 57 | error("%s: %s", __func__, ssh_err(ret)); |
| 58 | return -1; |
| 59 | } |
| 60 | return 0; |
Damien Miller | 3b23566 | 2002-04-23 20:42:36 +1000 | [diff] [blame] | 61 | } |
| 62 | |
Ben Lindstrom | 46c1622 | 2000-12-22 01:43:59 +0000 | [diff] [blame] | 63 | u_int |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 64 | buffer_get_int(Buffer *buffer) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 65 | { |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 66 | u_int ret; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 67 | |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 68 | if (buffer_get_int_ret(&ret, buffer) == -1) |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 69 | fatal("%s: buffer error", __func__); |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 70 | |
| 71 | return (ret); |
| 72 | } |
| 73 | |
| 74 | int |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 75 | buffer_get_int64_ret(u_int64_t *v, Buffer *buffer) |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 76 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 77 | int ret; |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 78 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 79 | if ((ret = sshbuf_get_u64(buffer, v)) != 0) { |
| 80 | error("%s: %s", __func__, ssh_err(ret)); |
| 81 | return -1; |
| 82 | } |
| 83 | return 0; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 84 | } |
| 85 | |
Ben Lindstrom | 2f959b4 | 2001-01-11 06:20:23 +0000 | [diff] [blame] | 86 | u_int64_t |
| 87 | buffer_get_int64(Buffer *buffer) |
| 88 | { |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 89 | u_int64_t ret; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 90 | |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 91 | if (buffer_get_int64_ret(&ret, buffer) == -1) |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 92 | fatal("%s: buffer error", __func__); |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 93 | |
| 94 | return (ret); |
Ben Lindstrom | 2f959b4 | 2001-01-11 06:20:23 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Damien Miller | 5f05637 | 2000-04-16 12:31:48 +1000 | [diff] [blame] | 97 | void |
Damien Miller | 3b23566 | 2002-04-23 20:42:36 +1000 | [diff] [blame] | 98 | buffer_put_short(Buffer *buffer, u_short value) |
| 99 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 100 | int ret; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 101 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 102 | if ((ret = sshbuf_put_u16(buffer, value)) != 0) |
| 103 | fatal("%s: %s", __func__, ssh_err(ret)); |
Damien Miller | 3b23566 | 2002-04-23 20:42:36 +1000 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | void |
Ben Lindstrom | 46c1622 | 2000-12-22 01:43:59 +0000 | [diff] [blame] | 107 | buffer_put_int(Buffer *buffer, u_int value) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 108 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 109 | int ret; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 110 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 111 | if ((ret = sshbuf_put_u32(buffer, value)) != 0) |
| 112 | fatal("%s: %s", __func__, ssh_err(ret)); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 113 | } |
| 114 | |
Ben Lindstrom | 2f959b4 | 2001-01-11 06:20:23 +0000 | [diff] [blame] | 115 | void |
| 116 | buffer_put_int64(Buffer *buffer, u_int64_t value) |
| 117 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 118 | int ret; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 119 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 120 | if ((ret = sshbuf_put_u64(buffer, value)) != 0) |
| 121 | fatal("%s: %s", __func__, ssh_err(ret)); |
Ben Lindstrom | 2f959b4 | 2001-01-11 06:20:23 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Damien Miller | 5a6b4fe | 2001-12-21 14:56:54 +1100 | [diff] [blame] | 124 | void * |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 125 | buffer_get_string_ret(Buffer *buffer, u_int *length_ptr) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 126 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 127 | size_t len; |
| 128 | int ret; |
Damien Miller | 5a6b4fe | 2001-12-21 14:56:54 +1100 | [diff] [blame] | 129 | u_char *value; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 130 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 131 | if ((ret = sshbuf_get_string(buffer, &value, &len)) != 0) { |
| 132 | error("%s: %s", __func__, ssh_err(ret)); |
| 133 | return NULL; |
Damien Miller | 17751bc | 2010-02-12 07:35:08 +1100 | [diff] [blame] | 134 | } |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 135 | if (length_ptr != NULL) |
| 136 | *length_ptr = len; /* Safe: sshbuf never stores len > 2^31 */ |
| 137 | return value; |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | void * |
| 141 | buffer_get_string(Buffer *buffer, u_int *length_ptr) |
| 142 | { |
| 143 | void *ret; |
| 144 | |
| 145 | if ((ret = buffer_get_string_ret(buffer, length_ptr)) == NULL) |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 146 | fatal("%s: buffer error", __func__); |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 147 | return (ret); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 148 | } |
| 149 | |
Damien Miller | da108ec | 2010-08-31 22:36:39 +1000 | [diff] [blame] | 150 | char * |
| 151 | buffer_get_cstring_ret(Buffer *buffer, u_int *length_ptr) |
| 152 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 153 | size_t len; |
| 154 | int ret; |
| 155 | char *value; |
Damien Miller | da108ec | 2010-08-31 22:36:39 +1000 | [diff] [blame] | 156 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 157 | if ((ret = sshbuf_get_cstring(buffer, &value, &len)) != 0) { |
| 158 | error("%s: %s", __func__, ssh_err(ret)); |
Damien Miller | da108ec | 2010-08-31 22:36:39 +1000 | [diff] [blame] | 159 | return NULL; |
Damien Miller | da108ec | 2010-08-31 22:36:39 +1000 | [diff] [blame] | 160 | } |
| 161 | if (length_ptr != NULL) |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 162 | *length_ptr = len; /* Safe: sshbuf never stores len > 2^31 */ |
| 163 | return value; |
Damien Miller | da108ec | 2010-08-31 22:36:39 +1000 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | char * |
| 167 | buffer_get_cstring(Buffer *buffer, u_int *length_ptr) |
| 168 | { |
| 169 | char *ret; |
| 170 | |
| 171 | if ((ret = buffer_get_cstring_ret(buffer, length_ptr)) == NULL) |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 172 | fatal("%s: buffer error", __func__); |
Damien Miller | da108ec | 2010-08-31 22:36:39 +1000 | [diff] [blame] | 173 | return ret; |
| 174 | } |
| 175 | |
Damien Miller | 633de33 | 2014-05-15 13:48:26 +1000 | [diff] [blame] | 176 | const void * |
Darren Tucker | ebc71d9 | 2010-01-12 19:45:59 +1100 | [diff] [blame] | 177 | buffer_get_string_ptr_ret(Buffer *buffer, u_int *length_ptr) |
Damien Miller | db255ca | 2008-05-19 14:59:37 +1000 | [diff] [blame] | 178 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 179 | size_t len; |
| 180 | int ret; |
| 181 | const u_char *value; |
Damien Miller | db255ca | 2008-05-19 14:59:37 +1000 | [diff] [blame] | 182 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 183 | if ((ret = sshbuf_get_string_direct(buffer, &value, &len)) != 0) { |
| 184 | error("%s: %s", __func__, ssh_err(ret)); |
Darren Tucker | ebc71d9 | 2010-01-12 19:45:59 +1100 | [diff] [blame] | 185 | return NULL; |
| 186 | } |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 187 | if (length_ptr != NULL) |
| 188 | *length_ptr = len; /* Safe: sshbuf never stores len > 2^31 */ |
| 189 | return value; |
Damien Miller | db255ca | 2008-05-19 14:59:37 +1000 | [diff] [blame] | 190 | } |
| 191 | |
Damien Miller | 633de33 | 2014-05-15 13:48:26 +1000 | [diff] [blame] | 192 | const void * |
Darren Tucker | ebc71d9 | 2010-01-12 19:45:59 +1100 | [diff] [blame] | 193 | buffer_get_string_ptr(Buffer *buffer, u_int *length_ptr) |
| 194 | { |
Damien Miller | 633de33 | 2014-05-15 13:48:26 +1000 | [diff] [blame] | 195 | const void *ret; |
Darren Tucker | ebc71d9 | 2010-01-12 19:45:59 +1100 | [diff] [blame] | 196 | |
| 197 | if ((ret = buffer_get_string_ptr_ret(buffer, length_ptr)) == NULL) |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 198 | fatal("%s: buffer error", __func__); |
Darren Tucker | ebc71d9 | 2010-01-12 19:45:59 +1100 | [diff] [blame] | 199 | return (ret); |
| 200 | } |
| 201 | |
Damien Miller | 5f05637 | 2000-04-16 12:31:48 +1000 | [diff] [blame] | 202 | void |
Ben Lindstrom | 46c1622 | 2000-12-22 01:43:59 +0000 | [diff] [blame] | 203 | buffer_put_string(Buffer *buffer, const void *buf, u_int len) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 204 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 205 | int ret; |
| 206 | |
| 207 | if ((ret = sshbuf_put_string(buffer, buf, len)) != 0) |
| 208 | fatal("%s: %s", __func__, ssh_err(ret)); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 209 | } |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 210 | |
Damien Miller | 5f05637 | 2000-04-16 12:31:48 +1000 | [diff] [blame] | 211 | void |
Damien Miller | b38eff8 | 2000-04-01 11:09:21 +1000 | [diff] [blame] | 212 | buffer_put_cstring(Buffer *buffer, const char *s) |
| 213 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 214 | int ret; |
| 215 | |
| 216 | if ((ret = sshbuf_put_cstring(buffer, s)) != 0) |
| 217 | fatal("%s: %s", __func__, ssh_err(ret)); |
Damien Miller | b38eff8 | 2000-04-01 11:09:21 +1000 | [diff] [blame] | 218 | } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 219 | |
Damien Miller | 5f05637 | 2000-04-16 12:31:48 +1000 | [diff] [blame] | 220 | int |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 221 | buffer_get_char_ret(char *v, Buffer *buffer) |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 222 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 223 | int ret; |
| 224 | |
| 225 | if ((ret = sshbuf_get_u8(buffer, (u_char *)v)) != 0) { |
| 226 | error("%s: %s", __func__, ssh_err(ret)); |
| 227 | return -1; |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 228 | } |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 229 | return 0; |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | int |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 233 | buffer_get_char(Buffer *buffer) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 234 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 235 | char ch; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 236 | |
Darren Tucker | 50dbe83 | 2004-11-05 20:41:24 +1100 | [diff] [blame] | 237 | if (buffer_get_char_ret(&ch, buffer) == -1) |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 238 | fatal("%s: buffer error", __func__); |
| 239 | return (u_char) ch; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 240 | } |
| 241 | |
Damien Miller | 5f05637 | 2000-04-16 12:31:48 +1000 | [diff] [blame] | 242 | void |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 243 | buffer_put_char(Buffer *buffer, int value) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 244 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 245 | int ret; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 246 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 247 | if ((ret = sshbuf_put_u8(buffer, value)) != 0) |
| 248 | fatal("%s: %s", __func__, ssh_err(ret)); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 249 | } |
Damien Miller | 91b580e | 2014-01-12 19:21:22 +1100 | [diff] [blame] | 250 | |
Damien Miller | 91b580e | 2014-01-12 19:21:22 +1100 | [diff] [blame] | 251 | void |
| 252 | buffer_put_bignum2_from_string(Buffer *buffer, const u_char *s, u_int l) |
| 253 | { |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 254 | int ret; |
Damien Miller | 91b580e | 2014-01-12 19:21:22 +1100 | [diff] [blame] | 255 | |
Damien Miller | 05e82c3 | 2014-05-15 14:33:43 +1000 | [diff] [blame] | 256 | if ((ret = sshbuf_put_bignum2_bytes(buffer, s, l)) != 0) |
| 257 | fatal("%s: %s", __func__, ssh_err(ret)); |
Damien Miller | 91b580e | 2014-01-12 19:21:22 +1100 | [diff] [blame] | 258 | } |
| 259 | |