aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2013-04-08 18:31:34 +0200
committerTobias Brunner <tobias@strongswan.org>2013-05-08 14:53:08 +0200
commitc734c2d875bbea7673dbbc796a88f2f21e5265b1 (patch)
tree256ecb90cb350b3cb5bbf40db5dfde54383b1891 /src
parent4076e3ee91212b100bb601037565dc00abd41e0b (diff)
downloadstrongswan-c734c2d875bbea7673dbbc796a88f2f21e5265b1.tar.bz2
strongswan-c734c2d875bbea7673dbbc796a88f2f21e5265b1.tar.xz
Extract function to convert ASN.1 INTEGER object to u_int64_t
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/asn1/asn1.c16
-rw-r--r--src/libstrongswan/asn1/asn1.h9
-rw-r--r--src/libstrongswan/crypto/pkcs5.c26
3 files changed, 28 insertions, 23 deletions
diff --git a/src/libstrongswan/asn1/asn1.c b/src/libstrongswan/asn1/asn1.c
index f438cb20e..68f37f471 100644
--- a/src/libstrongswan/asn1/asn1.c
+++ b/src/libstrongswan/asn1/asn1.c
@@ -549,6 +549,22 @@ bool asn1_parse_simple_object(chunk_t *object, asn1_t type, u_int level, const c
return TRUE;
}
+/*
+ * Described in header
+ */
+u_int64_t asn1_parse_integer_uint64(chunk_t blob)
+{
+ u_int64_t val = 0;
+ int i;
+
+ for (i = 0; i < blob.len; i++)
+ { /* if it is longer than 8 bytes, we just use the 8 LSBs */
+ val <<= 8;
+ val |= (u_int64_t)blob.ptr[i];
+ }
+ return val;
+}
+
/**
* ASN.1 definition of an algorithmIdentifier
*/
diff --git a/src/libstrongswan/asn1/asn1.h b/src/libstrongswan/asn1/asn1.h
index 15ffff62e..a1d625380 100644
--- a/src/libstrongswan/asn1/asn1.h
+++ b/src/libstrongswan/asn1/asn1.h
@@ -171,6 +171,15 @@ bool asn1_parse_simple_object(chunk_t *object, asn1_t type, u_int level0,
const char* name);
/**
+ * Converts an ASN.1 INTEGER object to an u_int64_t. If the INTEGER is longer
+ * than 8 bytes only the 8 LSBs are returned.
+ *
+ * @param blob body of an ASN.1 coded integer object
+ * @return converted integer
+ */
+u_int64_t asn1_parse_integer_uint64(chunk_t blob);
+
+/**
* Print the value of an ASN.1 simple object
*
* @param object ASN.1 object to be printed
diff --git a/src/libstrongswan/crypto/pkcs5.c b/src/libstrongswan/crypto/pkcs5.c
index 76a67fc4a..5c5d78c28 100644
--- a/src/libstrongswan/crypto/pkcs5.c
+++ b/src/libstrongswan/crypto/pkcs5.c
@@ -347,26 +347,6 @@ METHOD(pkcs5_t, decrypt, bool,
}
/**
- * Converts an ASN.1 INTEGER object to an u_int64_t. If the INTEGER is longer
- * than 8 bytes only the 8 LSBs are returned.
- *
- * @param blob body of an ASN.1 coded integer object
- * @return converted integer
- */
-static u_int64_t parse_asn1_integer_uint64(chunk_t blob)
-{
- u_int64_t val = 0;
- int i;
-
- for (i = 0; i < blob.len; i++)
- { /* if it is longer than 8 bytes, we just use the 8 LSBs */
- val <<= 8;
- val |= (u_int64_t)blob.ptr[i];
- }
- return val;
-}
-
-/**
* ASN.1 definition of a PBEParameter structure
*/
static const asn1Object_t pbeParameterObjects[] = {
@@ -402,7 +382,7 @@ static bool parse_pbes1_params(private_pkcs5_t *this, chunk_t blob, int level0)
}
case PBEPARAM_ITERATION_COUNT:
{
- this->iterations = parse_asn1_integer_uint64(object);
+ this->iterations = asn1_parse_integer_uint64(object);
break;
}
}
@@ -458,12 +438,12 @@ static bool parse_pbkdf2_params(private_pkcs5_t *this, chunk_t blob, int level0)
}
case PBKDF2_ITERATION_COUNT:
{
- this->iterations = parse_asn1_integer_uint64(object);
+ this->iterations = asn1_parse_integer_uint64(object);
break;
}
case PBKDF2_KEYLENGTH:
{
- this->keylen = (size_t)parse_asn1_integer_uint64(object);
+ this->keylen = (size_t)asn1_parse_integer_uint64(object);
break;
}
case PBKDF2_PRF: