aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2007-10-12 23:18:42 +0000
committerAndreas Steffen <andreas.steffen@strongswan.org>2007-10-12 23:18:42 +0000
commitf39e4d3209a28701168a182a1e9cfcfee62c291c (patch)
tree55e3a2634db5e7e2b79e10100bd9291a2a13e906
parentbad1a23f020dabec8fa88fd92d8f13cf361b22b0 (diff)
downloadstrongswan-f39e4d3209a28701168a182a1e9cfcfee62c291c.tar.bz2
strongswan-f39e4d3209a28701168a182a1e9cfcfee62c291c.tar.xz
added hasher_signature_algorithm_to_oid() function
-rw-r--r--src/libstrongswan/crypto/hashers/hasher.c36
-rw-r--r--src/libstrongswan/crypto/hashers/hasher.h14
2 files changed, 50 insertions, 0 deletions
diff --git a/src/libstrongswan/crypto/hashers/hasher.c b/src/libstrongswan/crypto/hashers/hasher.c
index f386a3fe3..fa91ec245 100644
--- a/src/libstrongswan/crypto/hashers/hasher.c
+++ b/src/libstrongswan/crypto/hashers/hasher.c
@@ -19,6 +19,8 @@
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
+ *
+ * RCSID $Id$
*/
@@ -104,3 +106,37 @@ hash_algorithm_t hasher_algorithm_from_oid(int oid)
}
return algorithm;
}
+
+/*
+ * Described in header.
+ */
+int hasher_signature_algorithm_to_oid(hash_algorithm_t alg)
+{
+ int oid;
+
+ switch (alg)
+ {
+ case HASH_MD2:
+ oid = OID_MD2_WITH_RSA;
+ break;
+ case HASH_MD5:
+ oid = OID_MD5_WITH_RSA;
+ break;
+ case HASH_SHA1:
+ oid = OID_SHA1_WITH_RSA;
+ break;
+ case HASH_SHA256:
+ oid = OID_SHA256_WITH_RSA;
+ break;
+ case HASH_SHA384:
+ oid = OID_SHA384_WITH_RSA;
+ break;
+ case HASH_SHA512:
+ oid = OID_SHA512_WITH_RSA;
+ break;
+ default:
+ oid = OID_UNKNOWN;
+ }
+ return oid;
+}
+
diff --git a/src/libstrongswan/crypto/hashers/hasher.h b/src/libstrongswan/crypto/hashers/hasher.h
index 4adc22afa..66660a1b7 100644
--- a/src/libstrongswan/crypto/hashers/hasher.h
+++ b/src/libstrongswan/crypto/hashers/hasher.h
@@ -19,6 +19,8 @@
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
+ *
+ * RCSID $Id$
*/
#ifndef HASHER_H_
@@ -168,4 +170,16 @@ hasher_t *hasher_create(hash_algorithm_t hash_algorithm);
*/
hash_algorithm_t hasher_algorithm_from_oid(int oid);
+/**
+ * @brief Conversion of hash signature algorithm ASN.1 OID.
+ *
+ * @param alg hash algorithm
+ * @return
+ * - ASN.1 OID if known hash algorithm
+ * - OID_UNKNOW
+ *
+ * @ingroup hashers
+ */
+int hasher_signature_algorithm_to_oid(hash_algorithm_t alg);
+
#endif /* HASHER_H_ */