openssl: Add helper to determine EVP_MD from hash_algorithm_t
[strongswan.git] / src / libstrongswan / plugins / openssl / openssl_hasher.h
1 /*
2 * Copyright (C) 2008-2017 Tobias Brunner
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup openssl_hasher openssl_hasher
18 * @{ @ingroup openssl_p
19 */
20
21 #ifndef OPENSSL_HASHER_H_
22 #define OPENSSL_HASHER_H_
23
24 typedef struct openssl_hasher_t openssl_hasher_t;
25
26 #include <crypto/hashers/hasher.h>
27
28 #include <openssl/evp.h>
29
30 /**
31 * Implementation of hashers using OpenSSL.
32 */
33 struct openssl_hasher_t {
34
35 /**
36 * Implements hasher_t interface.
37 */
38 hasher_t hasher;
39 };
40
41 /**
42 * Determine EVP_MD for the given hash algorithm
43 *
44 * @param hash hash algorithm
45 * @return EVP_MD or NULL if not found/supported
46 */
47 const EVP_MD *openssl_get_md(hash_algorithm_t hash);
48
49 /**
50 * Constructor to create openssl_hasher_t.
51 *
52 * @param algo algorithm
53 * @return openssl_hasher_t, NULL if not supported
54 */
55 openssl_hasher_t *openssl_hasher_create(hash_algorithm_t algo);
56
57 #endif /** OPENSSL_HASHER_H_ @}*/