Pass SIM/AKA crypto helper to constructor of message
[strongswan.git] / src / libsimaka / simaka_crypto.h
1 /*
2 * Copyright (C) 2009 Martin Willi
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
16 /**
17 * @defgroup simaka_crypto simaka_crypto
18 * @{ @ingroup libsimaka
19 */
20
21 #ifndef SIMAKA_CRYPTO_H_
22 #define SIMAKA_CRYPTO_H_
23
24 #include <library.h>
25
26 typedef struct simaka_crypto_t simaka_crypto_t;
27
28 /**
29 * EAP-SIM/AKA crypto helper and key derivation class.
30 */
31 struct simaka_crypto_t {
32
33 /**
34 * Get the signer to use for AT_MAC calculation/verification.
35 *
36 * @return signer reference, NULL if no keys have been derived
37 */
38 signer_t* (*get_signer)(simaka_crypto_t *this);
39
40 /**
41 * Get the signer to use for AT_ENCR_DATA encryption/decryption.
42 *
43 * @return crypter reference, NULL if no keys have been derived
44 */
45 crypter_t* (*get_crypter)(simaka_crypto_t *this);
46
47 /**
48 * Get the random number generator.
49 *
50 * @return rng reference
51 */
52 rng_t* (*get_rng)(simaka_crypto_t *this);
53
54 /**
55 * Derive keys after full authentication.
56 *
57 * This methods derives the k_encr/k_auth keys and loads them into the
58 * internal crypter/signer instances. The passed data is method specific:
59 * For EAP-SIM, it is "n*Kc|NONCE_MT|Version List|Selected Version", for
60 * EAP-AKA it is "IK|CK".
61 *
62 * @param id peer identity
63 * @param data method specific data
64 * @return allocated MSK value
65 */
66 chunk_t (*derive_keys_full)(simaka_crypto_t *this, identification_t *id,
67 chunk_t data);
68
69 /**
70 * Destroy a simaka_crypto_t.
71 */
72 void (*destroy)(simaka_crypto_t *this);
73 };
74
75 /**
76 * Create a simaka_crypto instance.
77 *
78 * @return EAP-SIM/AKA crypto instance, NULL if algorithms missing
79 */
80 simaka_crypto_t *simaka_crypto_create();
81
82 #endif /** SIMAKA_CRYPTO_H_ @}*/