summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorSteffen Jaeckel <s@jaeckel.eu>2020-05-26 17:36:47 +0200
committerSteffen Jaeckel <s@jaeckel.eu>2020-05-26 17:36:47 +0200
commit4f11c927dfb74496017fd1d2e2b18e3afb2a93fd (patch)
treeb448865b4989998f041b159bd913b79542f8623a /buffer.c
parent1de4c3c6588830f9c2c4c7236596f5e0c639e588 (diff)
downloaddropbear-4f11c927dfb74496017fd1d2e2b18e3afb2a93fd.tar.gz
Update LibTomMath to 1.2.0 (#84)
* update C files * update other files * update headers * update makefiles * remove mp_set/get_double() * use ltm 1.2.0 API * update ltm_desc * use bundled tommath if system-tommath is too old * XMALLOC etc. were changed to MP_MALLOC etc.
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/buffer.c b/buffer.c
index dc8b909..135326f 100644
--- a/buffer.c
+++ b/buffer.c
@@ -307,18 +307,18 @@ void buf_putbytes(buffer *buf, const unsigned char *bytes, unsigned int len) {
/* for our purposes we only need positive (or 0) numbers, so will
* fail if we get negative numbers */
void buf_putmpint(buffer* buf, mp_int * mp) {
-
+ size_t written;
unsigned int len, pad = 0;
TRACE2(("enter buf_putmpint"))
dropbear_assert(mp != NULL);
- if (SIGN(mp) == MP_NEG) {
+ if (mp_isneg(mp)) {
dropbear_exit("negative bignum");
}
/* zero check */
- if (USED(mp) == 1 && DIGIT(mp, 0) == 0) {
+ if (mp_iszero(mp)) {
len = 0;
} else {
/* SSH spec requires padding for mpints with the MSB set, this code
@@ -339,10 +339,10 @@ void buf_putmpint(buffer* buf, mp_int * mp) {
if (pad) {
buf_putbyte(buf, 0x00);
}
- if (mp_to_unsigned_bin(mp, buf_getwriteptr(buf, len-pad)) != MP_OKAY) {
+ if (mp_to_ubin(mp, buf_getwriteptr(buf, len-pad), len-pad, &written) != MP_OKAY) {
dropbear_exit("mpint error");
}
- buf_incrwritepos(buf, len-pad);
+ buf_incrwritepos(buf, written);
}
TRACE2(("leave buf_putmpint"))
@@ -370,7 +370,7 @@ int buf_getmpint(buffer* buf, mp_int* mp) {
return DROPBEAR_FAILURE;
}
- if (mp_read_unsigned_bin(mp, buf_getptr(buf, len), len) != MP_OKAY) {
+ if (mp_from_ubin(mp, buf_getptr(buf, len), len) != MP_OKAY) {
return DROPBEAR_FAILURE;
}