src/hss_rel14/hsssec/src/fx.c
void
f1 (
  uint8_t const opc[16],
  uint8_t const k[16],
  uint8_t const _rand[16],
  uint8_t const sqn[6],
  uint8_t const amf[2],
  uint8_t mac_a[8])
{
  uint8_t                                 temp[16];
  uint8_t                                 in1[16];
  uint8_t                                 out1[16];
  uint8_t                                 rijndaelInput[16];
  uint8_t                                 i;

  RijndaelKeySchedule (k);

  for (i = 0; i < 16; i++)
    rijndaelInput[i] = _rand[i] ^ opc[i];

  RijndaelEncrypt (rijndaelInput, temp);

  for (i = 0; i < 6; i++) {
    in1[i] = sqn[i];
    in1[i + 8] = sqn[i];
  }

  for (i = 0; i < 2; i++) {
    in1[i + 6] = amf[i];
    in1[i + 14] = amf[i];
  }

  /*
   * XOR op_c and in1, rotate by r1=64, and XOR
   * * * * on the constant c1 (which is all zeroes)
   */
  for (i = 0; i < 16; i++)
    rijndaelInput[(i + 8) % 16] = in1[i] ^ opc[i];

  /*
   * XOR on the value temp computed before
   */
  for (i = 0; i < 16; i++)
    rijndaelInput[i] ^= temp[i];

  RijndaelEncrypt (rijndaelInput, out1);

  for (i = 0; i < 16; i++)
    out1[i] ^= opc[i];

  for (i = 0; i < 8; i++)
    mac_a[i] = out1[i];

  return;
}
/*-------------------------------------------------------------------
   Algorithm f1
  -------------------------------------------------------------------

   Computes network authentication code MAC-A from key K, random
   challenge RAND, sequence number SQN and authentication management
   field AMF.

  -----------------------------------------------------------------*/
Algorithm f1
Computes network authentication code MAC-A from key K, random
challenge RAND, sequence number SQN and authentication management
field AMF.
Algorithm f1 Computes network authentication code MAC - A from key K random challenge RAND sequence number SQN and authentication management field AMF .
void
f1 (
  uint8_t const opc[16],
  uint8_t const k[16],
  uint8_t const _rand[16],
  uint8_t const sqn[6],
  uint8_t const amf[2],
  uint8_t mac_a[8])
{
  uint8_t                                 temp[16];
  uint8_t                                 in1[16];
  uint8_t                                 out1[16];
  uint8_t                                 rijndaelInput[16];
  uint8_t                                 i;
  RijndaelKeySchedule (k);
  for (i = 0; i < 16; i++)
    rijndaelInput[i] = _rand[i] ^ opc[i];
  RijndaelEncrypt (rijndaelInput, temp);
  for (i = 0; i < 6; i++) {
    in1[i] = sqn[i];
    in1[i + 8] = sqn[i];
  }
  for (i = 0; i < 2; i++) {
    in1[i + 6] = amf[i];
    in1[i + 14] = amf[i];
  }
  for (i = 0; i < 16; i++)
    rijndaelInput[(i + 8) % 16] = in1[i] ^ opc[i];
  for (i = 0; i < 16; i++)
    rijndaelInput[i] ^= temp[i];
  RijndaelEncrypt (rijndaelInput, out1);
  for (i = 0; i < 16; i++)
    out1[i] ^= opc[i];
  for (i = 0; i < 8; i++)
    mac_a[i] = out1[i];
  return;
}
void f1 ( uint8_t const opc [ 16 ] , uint8_t const k [ 16 ] , uint8_t const _rand [ 16 ] , uint8_t const sqn [ 6 ] , uint8_t const amf [ 2 ] , uint8_t mac_a [ 8 ] ) { uint8_t temp [ 16 ] ; uint8_t in1 [ 16 ] ; uint8_t out1 [ 16 ] ; uint8_t rijndaelInput [ 16 ] ; uint8_t i ; RijndaelKeySchedule ( k ) ; for ( i = 0 ; i < 16 ; i ++ ) rijndaelInput [ i ] = _rand [ i ] ^ opc [ i ] ; RijndaelEncrypt ( rijndaelInput , temp ) ; for ( i = 0 ; i < 6 ; i ++ ) { in1 [ i ] = sqn [ i ] ; in1 [ i + 8 ] = sqn [ i ] ; } for ( i = 0 ; i < 2 ; i ++ ) { in1 [ i + 6 ] = amf [ i ] ; in1 [ i + 14 ] = amf [ i ] ; } for ( i = 0 ; i < 16 ; i ++ ) rijndaelInput [ ( i + 8 ) % 16 ] = in1 [ i ] ^ opc [ i ] ; for ( i = 0 ; i < 16 ; i ++ ) rijndaelInput [ i ] ^= temp [ i ] ; RijndaelEncrypt ( rijndaelInput , out1 ) ; for ( i = 0 ; i < 16 ; i ++ ) out1 [ i ] ^= opc [ i ] ; for ( i = 0 ; i < 8 ; i ++ ) mac_a [ i ] = out1 [ i ] ; return ; }
Algorithm f1
Computes network authentication code MAC-A from key K, random
challenge RAND, sequence number SQN and authentication management
field AMF.
Algorithm f1 Computes network authentication code MAC - A from key K random challenge RAND sequence number SQN and authentication management field AMF .
/*
   * XOR op_c and in1, rotate by r1=64, and XOR
   * * * * on the constant c1 (which is all zeroes)
   */ /*
   * XOR on the value temp computed before
   */