Skip to content

Commit

Permalink
Don't need to set identity in fr_sim_crypto_keys_init_kdf_0_reauth
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Dec 15, 2017
1 parent 30b87df commit 5354383
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
22 changes: 2 additions & 20 deletions src/modules/rlm_eap/lib/sim/crypto.c
Expand Up @@ -481,42 +481,24 @@ int fr_sim_crypto_kdf_0_gsm(fr_sim_keys_t *keys)
* @param[in] identity reauthentication identity.
* @param[in] identity_len length of the reauthentication identity.
* @param[in] counter re-authentication counter.
* @return
* - 0 on success.
* - -1 on failure.
*/
int fr_sim_crypto_keys_init_kdf_0_reauth(TALLOC_CTX *ctx, fr_sim_keys_t *keys,
uint8_t const *master_key[20],
char const *identity, size_t identity_len, uint16_t counter)
void fr_sim_crypto_keys_init_kdf_0_reauth(fr_sim_keys_t *keys,
uint8_t const master_key[SIM_MK_SIZE], uint16_t counter)
{
uint32_t nonce_s[4];

/*
* Zero out keys
*/
memset(keys, 0, sizeof(*keys));

/*
* Copy in master key
*/
memcpy(keys->master_key, master_key, sizeof(keys->master_key));

keys->identity = (uint8_t const *)talloc_bstrndup(ctx, identity, identity_len);
if (!keys->identity) {
fr_strerror_printf("Out of memory");
return -1;
}
keys->identity_len = identity_len;

keys->reauth.counter = counter;

nonce_s[0] = fr_rand();
nonce_s[1] = fr_rand();
nonce_s[2] = fr_rand();
nonce_s[3] = fr_rand();
memcpy(keys->reauth.nonce_s, (uint8_t *)&nonce_s, sizeof(keys->reauth.nonce_s));

return 0;
}

/** Re-Derive keys from the master key
Expand Down
9 changes: 5 additions & 4 deletions src/modules/rlm_eap/lib/sim/sim_proto.h
Expand Up @@ -44,6 +44,8 @@ RCSIDH(sim_h, "$Id$")
#define SIM_SQN_AK_SIZE 6
#define SIM_NONCE_S_SIZE 16 //!< Length of re-authentication nonce

#define SIM_MK_SIZE 20 //!< Master key size

#define SIM_SKIPPABLE_MAX 127 //!< The last non-skippable attribute.

#define SIM_VECTOR_GSM_RAND_SIZE 16 //!< Length of RAND in GSM triplet.
Expand Down Expand Up @@ -184,7 +186,7 @@ typedef struct {
/*
* Outputs
*/
uint8_t master_key[20]; //!< Master key from session attributes.
uint8_t master_key[SIM_MK_SIZE]; //!< Master key from session attributes.

uint8_t k_aut[32]; //!< Derived authentication key.
size_t k_aut_len; //!< Length of k_aut. 16 for AKA/SIM, 32 for AKA'.
Expand Down Expand Up @@ -264,9 +266,8 @@ ssize_t fr_sim_crypto_sign_packet(uint8_t out[16], eap_packet_t *eap_packet, bo

int fr_sim_crypto_kdf_0_gsm(fr_sim_keys_t *keys);

int fr_sim_crypto_keys_init_kdf_0_reauth(TALLOC_CTX *ctx, fr_sim_keys_t *keys,
uint8_t const *master_key[20],
char const *identity, size_t identity_len, uint16_t counter);
void fr_sim_crypto_keys_init_kdf_0_reauth(fr_sim_keys_t *keys,
uint8_t const master_key[SIM_MK_SIZE], uint16_t counter);

int fr_sim_crypto_kdf_0_reauth(fr_sim_keys_t *keys);

Expand Down

0 comments on commit 5354383

Please sign in to comment.