Function to convert PRFs to hash algorithms added
This commit is contained in:
@@ -65,6 +65,36 @@ hash_algorithm_t hasher_algorithm_from_oid(int oid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Described in header.
|
||||||
|
*/
|
||||||
|
hash_algorithm_t hasher_algorithm_from_prf(pseudo_random_function_t alg)
|
||||||
|
{
|
||||||
|
switch (alg)
|
||||||
|
{
|
||||||
|
case PRF_HMAC_MD5:
|
||||||
|
return HASH_MD5;
|
||||||
|
case PRF_HMAC_SHA1:
|
||||||
|
case PRF_FIPS_SHA1_160:
|
||||||
|
case PRF_KEYED_SHA1:
|
||||||
|
return HASH_SHA1;
|
||||||
|
case PRF_HMAC_SHA2_256:
|
||||||
|
return HASH_SHA256;
|
||||||
|
case PRF_HMAC_SHA2_384:
|
||||||
|
return HASH_SHA384;
|
||||||
|
case PRF_HMAC_SHA2_512:
|
||||||
|
return HASH_SHA512;
|
||||||
|
case PRF_HMAC_TIGER:
|
||||||
|
case PRF_AES128_XCBC:
|
||||||
|
case PRF_AES128_CMAC:
|
||||||
|
case PRF_FIPS_DES:
|
||||||
|
case PRF_CAMELLIA128_XCBC:
|
||||||
|
case PRF_UNDEFINED:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return HASH_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Described in header.
|
* Described in header.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ typedef enum hash_algorithm_t hash_algorithm_t;
|
|||||||
typedef struct hasher_t hasher_t;
|
typedef struct hasher_t hasher_t;
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
|
#include <crypto/prfs/prf.h>
|
||||||
#include <crypto/signers/signer.h>
|
#include <crypto/signers/signer.h>
|
||||||
#include <credentials/keys/public_key.h>
|
#include <credentials/keys/public_key.h>
|
||||||
|
|
||||||
@@ -119,6 +120,14 @@ struct hasher_t {
|
|||||||
*/
|
*/
|
||||||
hash_algorithm_t hasher_algorithm_from_oid(int oid);
|
hash_algorithm_t hasher_algorithm_from_oid(int oid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversion of PRF algorithm to hash algorithm (if based on one).
|
||||||
|
*
|
||||||
|
* @param alg prf algorithm
|
||||||
|
* @return hash algorithm, HASH_UNKNOWN if not based on a hash
|
||||||
|
*/
|
||||||
|
hash_algorithm_t hasher_algorithm_from_prf(pseudo_random_function_t alg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conversion of integrity algorithm to hash algorithm (if based on one).
|
* Conversion of integrity algorithm to hash algorithm (if based on one).
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user