diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2009-05-06 22:46:51 +0200 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2009-05-06 22:46:51 +0200 |
commit | 38a7792d8a7797abe945f4ff938afefa1af5bc5e (patch) | |
tree | 7752dabf477f0a9a286c96507ca6955dfa75b424 /src/pluto/ike_alg.c | |
parent | ab87051f235f580761d6a6dc21ca014a0a1f9261 (diff) | |
download | strongswan-38a7792d8a7797abe945f4ff938afefa1af5bc5e.tar.bz2 strongswan-38a7792d8a7797abe945f4ff938afefa1af5bc5e.tar.xz |
removed all hash function code from pluto
Diffstat (limited to 'src/pluto/ike_alg.c')
-rw-r--r-- | src/pluto/ike_alg.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/pluto/ike_alg.c b/src/pluto/ike_alg.c index 740bae8c1..5056e82ab 100644 --- a/src/pluto/ike_alg.c +++ b/src/pluto/ike_alg.c @@ -148,22 +148,6 @@ ike_alg_register_hash(struct hash_desc *hash_desc) return_on(ret,-EINVAL); } - if (hash_desc->hash_ctx_size > sizeof (union hash_ctx)) - { - plog ("ike_alg: hash alg=%d has ctx_size=%d > hash_ctx=%d" - , hash_desc->algo_id - , (int)hash_desc->hash_ctx_size - , (int)sizeof (union hash_ctx)); - return_on(ret,-EOVERFLOW); - } - - if (!(hash_desc->hash_init && hash_desc->hash_update && hash_desc->hash_final)) - { - plog ("ike_alg: hash alg=%d needs hash_init(), hash_update() and hash_final()" - , hash_desc->algo_id); - return_on(ret,-EINVAL); - } - alg_name = enum_name(&oakley_hash_names, hash_desc->algo_id); if (!alg_name) { @@ -447,25 +431,32 @@ ike_hash_test(const struct hash_desc *desc) if (desc->hash_testvectors == NULL) { - plog(" %s hash self-test not available", enum_name(&oakley_hash_names, desc->algo_id)); + plog(" %s hash self-test not available", + enum_name(&oakley_hash_names, desc->algo_id)); } else { int i; + hash_algorithm_t hash_alg; + hasher_t *hasher; + hash_alg = oakley_to_hash_algorithm(desc->algo_id); + hasher = lib->crypto->create_hasher(lib->crypto, hash_alg); + if (hasher == NULL) + { + plog(" %s hash function not available", + enum_name(&oakley_hash_names, desc->algo_id)); + return FALSE; + } + for (i = 0; desc->hash_testvectors[i].msg_digest != NULL; i++) { u_char digest[MAX_DIGEST_LEN]; chunk_t msg = { desc->hash_testvectors[i].msg, desc->hash_testvectors[i].msg_size }; - hash_algorithm_t hash_alg; - hasher_t *hasher; bool result; - hash_alg = oakley_to_hash_algorithm(desc->algo_id); - hasher = lib->crypto->create_hasher(lib->crypto, hash_alg); hasher->get_hash(hasher, msg, digest); - hasher->destroy(hasher); result = memeq(digest, desc->hash_testvectors[i].msg_digest , desc->hash_digest_size); DBG(DBG_CRYPT, @@ -473,8 +464,9 @@ ike_hash_test(const struct hash_desc *desc) ) hash_results &= result; } - plog(" %s hash self-test %s", enum_name(&oakley_hash_names, desc->algo_id) - , hash_results ? "passed":"failed"); + hasher->destroy(hasher); + plog(" %s hash self-test %s", enum_name(&oakley_hash_names, desc->algo_id), + hash_results ? "passed":"failed"); } if (desc->hmac_testvectors == NULL) @@ -484,6 +476,9 @@ ike_hash_test(const struct hash_desc *desc) else { int i; + pseudo_random_function_t prf_alg; + + prf_alg = oakley_to_prf(desc->algo_id); for (i = 0; desc->hmac_testvectors[i].hmac != NULL; i++) { @@ -492,12 +487,16 @@ ike_hash_test(const struct hash_desc *desc) desc->hmac_testvectors[i].key_size }; chunk_t msg = { desc->hmac_testvectors[i].msg, desc->hmac_testvectors[i].msg_size }; - pseudo_random_function_t prf_alg; prf_t *prf; bool result; - prf_alg = oakley_to_prf(desc->algo_id); prf = lib->crypto->create_prf(lib->crypto, prf_alg); + if (prf == NULL) + { + plog(" %s hmac function not available", + enum_name(&oakley_hash_names, desc->algo_id)); + return FALSE; + } prf->set_key(prf, key); prf->get_bytes(prf, msg, digest); prf->destroy(prf); |