1 /* $OpenBSD: bufbn.c,v 1.12 2014/04/30 05:29:56 djm Exp $ */
4 * Copyright (c) 2012 Damien Miller <djm@mindrot.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 /* Emulation wrappers for legacy OpenSSH buffer API atop sshbuf */
23 #include <sys/types.h>
30 buffer_put_bignum_ret(Buffer
*buffer
, const BIGNUM
*value
)
34 if ((ret
= sshbuf_put_bignum1(buffer
, value
)) != 0) {
35 error("%s: %s", __func__
, ssh_err(ret
));
42 buffer_put_bignum(Buffer
*buffer
, const BIGNUM
*value
)
44 if (buffer_put_bignum_ret(buffer
, value
) == -1)
45 fatal("%s: buffer error", __func__
);
49 buffer_get_bignum_ret(Buffer
*buffer
, BIGNUM
*value
)
53 if ((ret
= sshbuf_get_bignum1(buffer
, value
)) != 0) {
54 error("%s: %s", __func__
, ssh_err(ret
));
61 buffer_get_bignum(Buffer
*buffer
, BIGNUM
*value
)
63 if (buffer_get_bignum_ret(buffer
, value
) == -1)
64 fatal("%s: buffer error", __func__
);
68 buffer_put_bignum2_ret(Buffer
*buffer
, const BIGNUM
*value
)
72 if ((ret
= sshbuf_put_bignum2(buffer
, value
)) != 0) {
73 error("%s: %s", __func__
, ssh_err(ret
));
80 buffer_put_bignum2(Buffer
*buffer
, const BIGNUM
*value
)
82 if (buffer_put_bignum2_ret(buffer
, value
) == -1)
83 fatal("%s: buffer error", __func__
);
87 buffer_get_bignum2_ret(Buffer
*buffer
, BIGNUM
*value
)
91 if ((ret
= sshbuf_get_bignum2(buffer
, value
)) != 0) {
92 error("%s: %s", __func__
, ssh_err(ret
));
99 buffer_get_bignum2(Buffer
*buffer
, BIGNUM
*value
)
101 if (buffer_get_bignum2_ret(buffer
, value
) == -1)
102 fatal("%s: buffer error", __func__
);