summaryrefslogtreecommitdiff
path: root/dss.c
diff options
context:
space:
mode:
Diffstat (limited to 'dss.c')
-rw-r--r--dss.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/dss.c b/dss.c
index 5bd358a..0cb437c 100644
--- a/dss.c
+++ b/dss.c
@@ -261,6 +261,25 @@ out:
}
#endif /* DROPBEAR_SIGNKEY_VERIFY */
+/* convert an unsigned mp into an array of bytes, malloced.
+ * This array must be freed after use, len contains the length of the array,
+ * if len != NULL */
+static unsigned char* mptobytes(mp_int *mp, int *len) {
+
+ unsigned char* ret;
+ int size;
+
+ size = mp_unsigned_bin_size(mp);
+ ret = m_malloc(size);
+ if (mp_to_unsigned_bin(mp, ret) != MP_OKAY) {
+ dropbear_exit("mem alloc error");
+ }
+ if (len != NULL) {
+ *len = size;
+ }
+ return ret;
+}
+
/* Sign the data presented with key, writing the signature contents
* to the buffer
*