summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/openssl/openssl_util.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-11-01 13:32:07 +0100
committerYves-Alexis Perez <corsac@debian.org>2013-11-01 13:32:07 +0100
commita54780509260a8cb6f0344f531da168b34410dd5 (patch)
tree477239a312679174252f39f7a80bc8bf33836d9a /src/libstrongswan/plugins/openssl/openssl_util.c
parent6e50941f7ce9c6f2d6888412968c7f4ffb495379 (diff)
parent5313d2d78ca150515f7f5eb39801c100690b6b29 (diff)
downloadvyos-strongswan-a54780509260a8cb6f0344f531da168b34410dd5.tar.gz
vyos-strongswan-a54780509260a8cb6f0344f531da168b34410dd5.zip
Merge tag 'upstream/5.1.1'
Upstream version 5.1.1
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_util.c')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_util.c b/src/libstrongswan/plugins/openssl/openssl_util.c
index bc10dd28c..0e61086b1 100644
--- a/src/libstrongswan/plugins/openssl/openssl_util.c
+++ b/src/libstrongswan/plugins/openssl/openssl_util.c
@@ -126,6 +126,24 @@ bool openssl_bn_split(chunk_t chunk, BIGNUM *a, BIGNUM *b)
/**
* Described in header.
*/
+bool openssl_bn2chunk(BIGNUM *bn, chunk_t *chunk)
+{
+ *chunk = chunk_alloc(BN_num_bytes(bn));
+ if (BN_bn2bin(bn, chunk->ptr) == chunk->len)
+ {
+ if (chunk->len && chunk->ptr[0] & 0x80)
+ { /* if MSB is set, prepend a zero to make it non-negative */
+ *chunk = chunk_cat("cm", chunk_from_chars(0x00), *chunk);
+ }
+ return TRUE;
+ }
+ chunk_free(chunk);
+ return FALSE;
+}
+
+/**
+ * Described in header.
+ */
chunk_t openssl_asn1_obj2chunk(ASN1_OBJECT *asn1)
{
if (asn1)