normalized and extended pts_meas_algo functions
[strongswan.git] / src / libpts / pts / pts_meas_algo.h
1 /*
2 * Copyright (C) 2011 Sansar Choinyambuu
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 pts_meas_algo pts_meas_algo
18 * @{ @ingroup pts
19 */
20
21 #ifndef PTS_MEAS_ALGO_H_
22 #define PTS_MEAS_ALGO_H_
23
24 #include <library.h>
25 #include <crypto/hashers/hasher.h>
26
27 typedef enum pts_meas_algorithms_t pts_meas_algorithms_t;
28
29 /**
30 * PTS Measurement Algorithms
31 */
32 enum pts_meas_algorithms_t {
33 PTS_MEAS_ALGO_NONE = 0,
34 PTS_MEAS_ALGO_SHA1 = (1<<15),
35 PTS_MEAS_ALGO_SHA256 = (1<<14),
36 PTS_MEAS_ALGO_SHA384 = (1<<13),
37 };
38
39 /**
40 * Diffie-Hellman Hash Algorithm Values
41 * see section 3.8.5 of PTS Protocol: Binding to TNC IF-M Specification
42 *
43 * 1
44 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * |1|2|3|R|R|R|R|R|R|R|R|R|R|R|R|R|
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 *
49 */
50
51 /**
52 * Probe available PTS measurement algorithms
53 *
54 * @param algorithms set of available algorithms
55 * @return TRUE if mandatory algorithms are available
56 */
57 bool pts_meas_algo_probe(pts_meas_algorithms_t *algorithms);
58
59 /**
60 * Update supported PTS measurement algorithms according to configuration
61 *
62 * @param hash_alg configured hash algorithm
63 * @param algorithms returns set of available PTS measurement algorithms
64 */
65 bool pts_meas_algo_update(char *hash_alg, pts_meas_algorithms_t *algorithms);
66
67 /**
68 * Select the strongest PTS measurement algorithm
69 * among a set of offered PTS measurement algorithms
70 *
71 * @param supported_algos set of supported PTS measurement algorithms
72 * @param offered_algos set of offered PTS measurements algorithms
73 * @return selected algorithm
74 */
75 pts_meas_algorithms_t pts_meas_algo_select(pts_meas_algorithms_t supported_algos,
76 pts_meas_algorithms_t offered_algos);
77
78 /**
79 * Convert pts_meas_algorithms_t to hash_algorithm_t
80 *
81 * @param algorithm PTS measurement algorithm type
82 * @return libstrongswan hash algorithm type
83 */
84 hash_algorithm_t pts_meas_algo_to_hash(pts_meas_algorithms_t algorithm);
85
86 #endif /** PTS_MEAS_ALGO_H_ @}*/