src/hss_rel14/hsssec/src/fx.c
void
f2345 (
  uint8_t const opc[16],
  uint8_t const k[16],
  uint8_t const _rand[16],
  uint8_t res[8],
  uint8_t ck[16],
  uint8_t ik[16],
  uint8_t ak[6])
{
  uint8_t                                 temp[16];
  uint8_t                                 out[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);

  /*
   * To obtain output block OUT2: XOR OPc and TEMP,
   * * * * rotate by r2=0, and XOR on the constant c2 (which *
   * * * * is all zeroes except that the last bit is 1).
   */
  for (i = 0; i < 16; i++)
    rijndaelInput[i] = temp[i] ^ opc[i];

  rijndaelInput[15] ^= 1;
  RijndaelEncrypt (rijndaelInput, out);

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

  for (i = 0; i < 8; i++)
    res[i] = out[i + 8];

  for (i = 0; i < 6; i++)
    ak[i] = out[i];

  /*
   * To obtain output block OUT3: XOR OPc and TEMP,
   * * * * rotate by r3=32, and XOR on the constant c3 (which *
   * * * * is all zeroes except that the next to last bit is 1).
   */

  for (i = 0; i < 16; i++)
    rijndaelInput[(i + 12) % 16] = temp[i] ^ opc[i];

  rijndaelInput[15] ^= 2;
  RijndaelEncrypt (rijndaelInput, out);

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

  for (i = 0; i < 16; i++)
    ck[i] = out[i];

  /*
   * To obtain output block OUT4: XOR OPc and TEMP,
   * * * * rotate by r4=64, and XOR on the constant c4 (which *
   * * * * is all zeroes except that the 2nd from last bit is 1).
   */
  for (i = 0; i < 16; i++)
    rijndaelInput[(i + 8) % 16] = temp[i] ^ opc[i];

  rijndaelInput[15] ^= 4;
  RijndaelEncrypt (rijndaelInput, out);

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

  for (i = 0; i < 16; i++)
    ik[i] = out[i];

  return;
}
/*-------------------------------------------------------------------
   Algorithms f2-f5
  -------------------------------------------------------------------

   Takes key K and random challenge RAND, and returns response RES,
   confidentiality key CK, integrity key IK and anonymity key AK.

  -----------------------------------------------------------------*/
Algorithms f2-f5
Takes key K and random challenge RAND, and returns response RES,
confidentiality key CK, integrity key IK and anonymity key AK.
Algorithms f2 - f5 Takes key K and random challenge RAND and returns response RES confidentiality key CK integrity key IK and anonymity key AK .
void
f2345 (
  uint8_t const opc[16],
  uint8_t const k[16],
  uint8_t const _rand[16],
  uint8_t res[8],
  uint8_t ck[16],
  uint8_t ik[16],
  uint8_t ak[6])
{
  uint8_t                                 temp[16];
  uint8_t                                 out[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 < 16; i++)
    rijndaelInput[i] = temp[i] ^ opc[i];
  rijndaelInput[15] ^= 1;
  RijndaelEncrypt (rijndaelInput, out);
  for (i = 0; i < 16; i++)
    out[i] ^= opc[i];
  for (i = 0; i < 8; i++)
    res[i] = out[i + 8];
  for (i = 0; i < 6; i++)
    ak[i] = out[i];
  for (i = 0; i < 16; i++)
    rijndaelInput[(i + 12) % 16] = temp[i] ^ opc[i];
  rijndaelInput[15] ^= 2;
  RijndaelEncrypt (rijndaelInput, out);
  for (i = 0; i < 16; i++)
    out[i] ^= opc[i];
  for (i = 0; i < 16; i++)
    ck[i] = out[i];
  for (i = 0; i < 16; i++)
    rijndaelInput[(i + 8) % 16] = temp[i] ^ opc[i];
  rijndaelInput[15] ^= 4;
  RijndaelEncrypt (rijndaelInput, out);
  for (i = 0; i < 16; i++)
    out[i] ^= opc[i];
  for (i = 0; i < 16; i++)
    ik[i] = out[i];
  return;
}
void f2345 ( uint8_t const opc [ 16 ] , uint8_t const k [ 16 ] , uint8_t const _rand [ 16 ] , uint8_t res [ 8 ] , uint8_t ck [ 16 ] , uint8_t ik [ 16 ] , uint8_t ak [ 6 ] ) { uint8_t temp [ 16 ] ; uint8_t out [ 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 < 16 ; i ++ ) rijndaelInput [ i ] = temp [ i ] ^ opc [ i ] ; rijndaelInput [ 15 ] ^= 1 ; RijndaelEncrypt ( rijndaelInput , out ) ; for ( i = 0 ; i < 16 ; i ++ ) out [ i ] ^= opc [ i ] ; for ( i = 0 ; i < 8 ; i ++ ) res [ i ] = out [ i + 8 ] ; for ( i = 0 ; i < 6 ; i ++ ) ak [ i ] = out [ i ] ; for ( i = 0 ; i < 16 ; i ++ ) rijndaelInput [ ( i + 12 ) % 16 ] = temp [ i ] ^ opc [ i ] ; rijndaelInput [ 15 ] ^= 2 ; RijndaelEncrypt ( rijndaelInput , out ) ; for ( i = 0 ; i < 16 ; i ++ ) out [ i ] ^= opc [ i ] ; for ( i = 0 ; i < 16 ; i ++ ) ck [ i ] = out [ i ] ; for ( i = 0 ; i < 16 ; i ++ ) rijndaelInput [ ( i + 8 ) % 16 ] = temp [ i ] ^ opc [ i ] ; rijndaelInput [ 15 ] ^= 4 ; RijndaelEncrypt ( rijndaelInput , out ) ; for ( i = 0 ; i < 16 ; i ++ ) out [ i ] ^= opc [ i ] ; for ( i = 0 ; i < 16 ; i ++ ) ik [ i ] = out [ i ] ; return ; }
Algorithms f2-f5
Takes key K and random challenge RAND, and returns response RES,
confidentiality key CK, integrity key IK and anonymity key AK.
Algorithms f2 - f5 Takes key K and random challenge RAND and returns response RES confidentiality key CK integrity key IK and anonymity key AK .
/*
   * To obtain output block OUT2: XOR OPc and TEMP,
   * * * * rotate by r2=0, and XOR on the constant c2 (which *
   * * * * is all zeroes except that the last bit is 1).
   */ /*
   * To obtain output block OUT3: XOR OPc and TEMP,
   * * * * rotate by r3=32, and XOR on the constant c3 (which *
   * * * * is all zeroes except that the next to last bit is 1).
   */ /*
   * To obtain output block OUT4: XOR OPc and TEMP,
   * * * * rotate by r4=64, and XOR on the constant c4 (which *
   * * * * is all zeroes except that the 2nd from last bit is 1).
   */