extended asn1_algorithmIdentifier() to SHA-2

This commit is contained in:
Andreas Steffen
2008-01-22 10:32:37 +00:00
parent 2d49eaa131
commit cd543a69a2
12 changed files with 444 additions and 143 deletions
+35 -1
View File
@@ -6,8 +6,9 @@
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Copyright (C) 2005-2006 Martin Willi
*
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -107,6 +108,39 @@ hash_algorithm_t hasher_algorithm_from_oid(int oid)
return algorithm;
}
/*
* Described in header.
*/
int hasher_algorithm_to_oid(hash_algorithm_t alg)
{
int oid;
switch (alg)
{
case HASH_MD2:
oid = OID_MD2;
break;
case HASH_MD5:
oid = OID_MD5;
break;
case HASH_SHA1:
oid = OID_SHA1;
break;
case HASH_SHA256:
oid = OID_SHA256;
break;
case HASH_SHA384:
oid = OID_SHA384;
break;
case HASH_SHA512:
oid = OID_SHA512;
break;
default:
oid = OID_UNKNOWN;
}
return oid;
}
/*
* Described in header.
*/
+16 -3
View File
@@ -6,8 +6,9 @@
*/
/*
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Copyright (C) 2005-2006 Martin Willi
*
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -171,11 +172,23 @@ 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.
* @brief Conversion of hash algorithm into ASN.1 OID.
*
* @param alg hash algorithm
* @return
* - ASN.1 OID if known hash algorithm
* - ASN.1 hash OID if known hash algorithm
* - OID_UNKNOW
*
* @ingroup hashers
*/
int hasher_algorithm_to_oid(hash_algorithm_t alg);
/**
* @brief Conversion of hash signature algorithm into ASN.1 OID.
*
* @param alg hash algorithm
* @return
* - ASN.1 signature OID if known hash algorithm
* - OID_UNKNOW
*
* @ingroup hashers