summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/openssl/openssl_util.c
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:34:14 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:34:14 +0000
commited7d79f96177044949744da10f4431c1d6242241 (patch)
tree3aabaa55ed3b5291daef891cfee9befb5235e2b8 /src/libstrongswan/plugins/openssl/openssl_util.c
parent7410d3c6d6a9a1cd7aa55083c938946af6ff9498 (diff)
downloadvyos-strongswan-ed7d79f96177044949744da10f4431c1d6242241.tar.gz
vyos-strongswan-ed7d79f96177044949744da10f4431c1d6242241.zip
[svn-upgrade] Integrating new upstream version, strongswan (4.3.6)
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_util.c')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_util.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_util.c b/src/libstrongswan/plugins/openssl/openssl_util.c
index c8c453f64..55b18a524 100644
--- a/src/libstrongswan/plugins/openssl/openssl_util.c
+++ b/src/libstrongswan/plugins/openssl/openssl_util.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2009 Martin Willi
* Copyright (C) 2008 Tobias Brunner
* Hochschule fuer Technik Rapperswil
*
@@ -18,6 +19,7 @@
#include <debug.h>
#include <openssl/evp.h>
+#include <openssl/x509.h>
/**
* Described in header.
@@ -31,30 +33,30 @@ bool openssl_hash_chunk(int hash_type, chunk_t data, chunk_t *hash)
{
return FALSE;
}
-
- ctx = EVP_MD_CTX_create();
+
+ ctx = EVP_MD_CTX_create();
if (!ctx)
{
goto error;
}
-
+
if (!EVP_DigestInit_ex(ctx, hasher, NULL))
{
goto error;
}
-
+
if (!EVP_DigestUpdate(ctx, data.ptr, data.len))
{
goto error;
}
-
+
*hash = chunk_alloc(hasher->md_size);
if (!EVP_DigestFinal_ex(ctx, hash->ptr, NULL))
{
chunk_free(hash);
goto error;
}
-
+
ret = TRUE;
error:
if (ctx)
@@ -70,18 +72,18 @@ error:
bool openssl_bn_cat(int len, BIGNUM *a, BIGNUM *b, chunk_t *chunk)
{
int offset;
-
+
chunk->len = len + (b ? len : 0);
chunk->ptr = malloc(chunk->len);
memset(chunk->ptr, 0, chunk->len);
-
+
/* convert a */
offset = len - BN_num_bytes(a);
if (!BN_bn2bin(a, chunk->ptr + offset))
{
goto error;
}
-
+
/* optionally convert and concatenate b */
if (b)
{
@@ -90,8 +92,8 @@ bool openssl_bn_cat(int len, BIGNUM *a, BIGNUM *b, chunk_t *chunk)
{
goto error;
}
- }
-
+ }
+
return TRUE;
error:
chunk_free(chunk);
@@ -105,19 +107,20 @@ error:
bool openssl_bn_split(chunk_t chunk, BIGNUM *a, BIGNUM *b)
{
int len;
-
+
if ((chunk.len % 2) != 0)
{
return FALSE;
}
-
+
len = chunk.len / 2;
-
+
if (!BN_bin2bn(chunk.ptr, len, a) ||
!BN_bin2bn(chunk.ptr + len, len, b))
{
return FALSE;
}
-
+
return TRUE;
}
+