core: ltc: acipher_helpers.h: add macro mp_to_unsigned_bin2()

Writing a bignum to a fixed size integer buffer in big endian order is
slightly cumbersome, because one has to take into account the actual
size of the bignum in order to have the zero padding on the left.
Let's say I am working with 256-bit numbers:

 unsigned char buf[32] = { };
 void *n = compute_some_bignum(...);

 mp_to_unsigned_bin(n, buf + sizeof(buf) - mp_unsigned_bin_size(n));

This commit introduces mp_to_unsigned_bin2() which can be used like so:

 unsigned char buf[32] = { };
 void *n = compute_some_bignum(...);

 mp_to_unsigned_bin2(n, buf, sizeof(buf));

Signed-off-by: Jerome Forissier <jerome@forissier.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/core/lib/libtomcrypt/acipher_helpers.h b/core/lib/libtomcrypt/acipher_helpers.h
index ecd12d7..7781e82 100644
--- a/core/lib/libtomcrypt/acipher_helpers.h
+++ b/core/lib/libtomcrypt/acipher_helpers.h
@@ -43,4 +43,11 @@
 				       uint32_t algo, size_t *key_size_bytes);
 #endif
 
+/* Write bignum to fixed size buffer in big endian order */
+#define mp_to_unsigned_bin2(a, b, c) \
+        do { \
+                void *_a = (a); \
+                mp_to_unsigned_bin(_a, (b) + (c) - mp_unsigned_bin_size(_a)); \
+        } while(0)
+
 #endif /* ACIPHER_HELPERS_H */