src/hss_rel14/hsssec/src/kdf.c
inline void
derive_kasme (
  uint8_t ck[16],
  uint8_t ik[16],
  uint8_t plmn[3],
  uint8_t sqn[6],
  uint8_t ak[6],
  uint8_t * kasme)
{
  uint8_t                                 s[14];
  int                                     i;
  uint8_t                                 key[32];

  /*
   * The input key is equal to the concatenation of CK and IK
   */
  memcpy (&key[0], ck, 16);
  memcpy (&key[16], ik, 16);
  /*
   * if (hss_config.valid_opc == 0) {
   * SetOP(hss_config.operator_key);
   * }
   */
  /*
   * FC
   */
  s[0] = 0x10;
  /*
   * SN id is composed of MCC and MNC
   * * * * Octets:
   * * * *   1      MCC digit 2 | MCC digit 1
   * * * *   2      MNC digit 3 | MCC digit 3
   * * * *   3      MNC digit 2 | MNC digit 1
   */
  memcpy (&s[1], plmn, 3);
  /*
   * L0
   */
  s[4] = 0x00;
  s[5] = 0x03;

  /*
   * P1
   */
  for (i = 0; i < 6; i++) {
    s[6 + i] = sqn[i] ^ ak[i];
  }

  /*
   * L1
   */
  s[12] = 0x00;
  s[13] = 0x06;
#if DEBUG_AUC_KDF

  for (i = 0; i < 32; i++)
    printf ("0x%02x ", key[i]);

  printf ("\n");

  for (i = 0; i < 14; i++)
    printf ("0x%02x ", s[i]);

  printf ("\n");
#endif
  kdf (key, 32, s, 14, kasme, 32);
}
/*
   Derive the Kasme using the KDF (key derive function).
   See 3GPP TS.33401 Annex A.2
   The input String S to the KDF is composed of 14 bytes:
   FC = 0x10
   P0 = SN id = PLMN
   L0 = length(SN id) = 0x00 0x03
   P1 = SQN xor AK
   L1 = length(P1) = 0x00 0x06
*/
Derive the Kasme using the KDF (key derive function).
Derive the Kasme using the KDF ( key derive function ) .
inline void
derive_kasme (
  uint8_t ck[16],
  uint8_t ik[16],
  uint8_t plmn[3],
  uint8_t sqn[6],
  uint8_t ak[6],
  uint8_t * kasme)
{
  uint8_t                                 s[14];
  int                                     i;
  uint8_t                                 key[32];
  memcpy (&key[0], ck, 16);
  memcpy (&key[16], ik, 16);
  s[0] = 0x10;
  memcpy (&s[1], plmn, 3);
  s[4] = 0x00;
  s[5] = 0x03;
  for (i = 0; i < 6; i++) {
    s[6 + i] = sqn[i] ^ ak[i];
  }
  s[12] = 0x00;
  s[13] = 0x06;
#if DEBUG_AUC_KDF
  for (i = 0; i < 32; i++)
    printf ("0x%02x ", key[i]);
  printf ("\n");
  for (i = 0; i < 14; i++)
    printf ("0x%02x ", s[i]);
  printf ("\n");
#endif
  kdf (key, 32, s, 14, kasme, 32);
}
inline void derive_kasme ( uint8_t ck [ 16 ] , uint8_t ik [ 16 ] , uint8_t plmn [ 3 ] , uint8_t sqn [ 6 ] , uint8_t ak [ 6 ] , uint8_t * kasme ) { uint8_t s [ 14 ] ; int i ; uint8_t key [ 32 ] ; memcpy ( & key [ 0 ] , ck , 16 ) ; memcpy ( & key [ 16 ] , ik , 16 ) ; s [ 0 ] = 0x10 ; memcpy ( & s [ 1 ] , plmn , 3 ) ; s [ 4 ] = 0x00 ; s [ 5 ] = 0x03 ; for ( i = 0 ; i < 6 ; i ++ ) { s [ 6 + i ] = sqn [ i ] ^ ak [ i ] ; } s [ 12 ] = 0x00 ; s [ 13 ] = 0x06 ; #if DEBUG_AUC_KDF for ( i = 0 ; i < 32 ; i ++ ) printf ( " " , key [ i ] ) ; printf ( " \n " ) ; for ( i = 0 ; i < 14 ; i ++ ) printf ( " " , s [ i ] ) ; printf ( " \n " ) ; #endif kdf ( key , 32 , s , 14 , kasme , 32 ) ; }
Derive the Kasme using the KDF (key derive function).
Derive the Kasme using the KDF ( key derive function ) .
/*
   * The input key is equal to the concatenation of CK and IK
   */ /*
   * if (hss_config.valid_opc == 0) {
   * SetOP(hss_config.operator_key);
   * }
   */ /*
   * FC
   */ /*
   * SN id is composed of MCC and MNC
   * * * * Octets:
   * * * *   1      MCC digit 2 | MCC digit 1
   * * * *   2      MNC digit 3 | MCC digit 3
   * * * *   3      MNC digit 2 | MNC digit 1
   */ /*
   * L0
   */ /*
   * P1
   */ /*
   * L1
   */