2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
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>.
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
17 * @defgroup simaka_crypto simaka_crypto
18 * @{ @ingroup libsimaka
21 #ifndef SIMAKA_CRYPTO_H_
22 #define SIMAKA_CRYPTO_H_
26 typedef struct simaka_crypto_t simaka_crypto_t
;
29 * EAP-SIM/AKA crypto helper and key derivation class.
31 struct simaka_crypto_t
{
34 * Get the signer to use for AT_MAC calculation/verification.
36 * @return signer reference, NULL if no keys have been derived
38 signer_t
* (*get_signer
)(simaka_crypto_t
*this);
41 * Get the signer to use for AT_ENCR_DATA encryption/decryption.
43 * @return crypter reference, NULL if no keys have been derived
45 crypter_t
* (*get_crypter
)(simaka_crypto_t
*this);
48 * Get the random number generator.
50 * @return rng reference
52 rng_t
* (*get_rng
)(simaka_crypto_t
*this);
55 * Derive keys after full authentication.
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".
62 * @param id peer identity
63 * @param data method specific data
64 * @param mk chunk receiving allocated master key MK
65 * @return allocated MSK value
67 chunk_t (*derive_keys_full
)(simaka_crypto_t
*this, identification_t
*id
,
68 chunk_t data
, chunk_t
*mk
);
71 * Derive k_encr/k_auth keys from MK using fast reauthentication.
73 * This methods derives the k_encr/k_auth keys and loads them into the
74 * internal crypter/signer instances.
76 * @param mk master key
78 void (*derive_keys_reauth
)(simaka_crypto_t
*this, chunk_t mk
);
81 * Derive MSK using fast reauthentication.
83 * @param id fast reauthentication identity
84 * @param counter fast reauthentication counter value, network order
85 * @param nonce_s server generated NONCE_S value
86 * @param mk master key of last full authentication
88 chunk_t (*derive_keys_reauth_msk
)(simaka_crypto_t
*this,
89 identification_t
*id
, chunk_t counter
,
90 chunk_t nonce_s
, chunk_t mk
);
93 * Clear keys (partially) derived.
95 void (*clear_keys
)(simaka_crypto_t
*this);
98 * Destroy a simaka_crypto_t.
100 void (*destroy
)(simaka_crypto_t
*this);
104 * Create a simaka_crypto instance.
106 * @return EAP-SIM/AKA crypto instance, NULL if algorithms missing
108 simaka_crypto_t
*simaka_crypto_create();
110 #endif /** SIMAKA_CRYPTO_H_ @}*/