updated Doxyfile
[strongswan.git] / src / libstrongswan / plugins / openssl / openssl_util.h
1 /*
2 * Copyright (C) 2008 Tobias Brunner
3 * 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 * $Id$
16 */
17
18 /**
19 * @defgroup openssl_util openssl_util
20 * @{ @ingroup openssl_p
21 */
22
23 #ifndef OPENSSL_UTIL_H_
24 #define OPENSSL_UTIL_H_
25
26 #include <library.h>
27 #include <openssl/bn.h>
28
29 /**
30 * Returns the length in bytes of a field element
31 */
32 #define EC_FIELD_ELEMENT_LEN(group) ((EC_GROUP_get_degree(group) + 7) / 8)
33
34 /**
35 * Creates a hash of a given type of a chunk of data.
36 *
37 * Note: this function allocates memory for the hash
38 *
39 * @param hash_type NID of the hash
40 * @param data the chunk of data to hash
41 * @param hash chunk that contains the hash
42 * @return TRUE on success, FALSE otherwise
43 */
44 bool openssl_hash_chunk(int hash_type, chunk_t data, chunk_t *hash);
45
46 /**
47 * Concatenates two bignums into a chunk, thereby enfocing the length of
48 * a single BIGNUM, if necessary, by pre-pending it with zeros.
49 *
50 * Note: this function allocates memory for the chunk
51 *
52 * @param len the length of a single BIGNUM
53 * @param a first BIGNUM
54 * @param b second BIGNUM
55 * @param chunk resulting chunk
56 * @return TRUE on success, FALSE otherwise
57 */
58 bool openssl_bn_cat(int len, BIGNUM *a, BIGNUM *b, chunk_t *chunk);
59
60 /**
61 * Splits a chunk into two bignums of equal binary length.
62 *
63 * @param chunk a chunk that contains the two BIGNUMs
64 * @param a first BIGNUM
65 * @param b second BIGNUM
66 * @return TRUE on success, FALSE otherwise
67 */
68 bool openssl_bn_split(chunk_t chunk, BIGNUM *a, BIGNUM *b);
69
70 #endif /** OPENSSL_UTIL_H_ @}*/