Ejemplo n.º 1
0
void AES_CMAC_Final(u_int8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX *ctx)
{
	u_int8_t K[16];
	unsigned char in[16];
	/* generate subkey K1 */
	memset1(K, '\0', 16);

	// rijndael_encrypt(&ctx->rijndael, K, K);

	aes_encrypt( K, K, &ctx->rijndael);

	if (K[0] & 0x80)
	{
		LSHIFT(K, K);
		K[15] ^= 0x87;
	} else
		LSHIFT(K, K);

	if (ctx->M_n == 16)
	{
		/* last block was a complete block */
		XOR(K, ctx->M_last);
	} else {
		/* generate subkey K2 */
		if (K[0] & 0x80)
		{
			LSHIFT(K, K);
			K[15] ^= 0x87;
		} else
			LSHIFT(K, K);

		/* padding(M_last) */
		ctx->M_last[ctx->M_n] = 0x80;
		while (++ctx->M_n < 16)
			ctx->M_last[ctx->M_n] = 0;

		XOR(K, ctx->M_last);
	}
	XOR(ctx->M_last, ctx->X);

	// rijndael_encrypt(&ctx->rijndael, ctx->X, digest);

	memcpy1(in, &ctx->X[0], 16); //Bestela ez du ondo iten
	aes_encrypt(in, digest, &ctx->rijndael);
	memset1(K, 0, sizeof K);
}
Ejemplo n.º 2
0
int f_mult(int An, int SRn)
{
  register int  EXP;
  register int  WAnMANT;
  int           AnS, MAG, AnMANT;

  AnS = SIGNBIT(An, 15);
  MAG = AnS? (16384 - (An >> 2)) & 8191 : An >> 2;
/*  {
    register int mag = MAG << 1;
 
    for (EXP = 0; mag >>= 1; EXP++)
        ;
  } */

  AnMANT = MAG ? LSHIFT(MAG, EXP - 6) : 1 << 5;
  EXP += ((SRn >> 6) & 15);
  WAnMANT = (((SRn & 63) * AnMANT) + 48) >> 4;
  MAG = LSHIFT(WAnMANT, 19 - EXP) & 32767;
  return ((SRn >> 10) ^ AnS ? (65536 - MAG) & 65535 : MAG);
}
Ejemplo n.º 3
0
inline ostream &operator<< ( ostream &os, const ciRecord &doc )
{
   os << doc._bson.toString() << "  " ;
   for ( int idx = 0 ; idx < MAX_NODE_COUNT ; ++idx )
   {
      os << ( 0 != ( doc._state & LSHIFT( idx ) ) ) ;
   }

   if ( NULL != doc._next )
   {
      os << std::endl << *doc._next << std::endl ;
   }

   return os ;
}
Ejemplo n.º 4
0
static BOOL 
doGaussianElimination (int* x, const POINT* src_pts, const POINT* dst_pts)
{
    int x12, x23, y12, y23, nx12, nx23, ny12, ny23;
    int numerator, denominator1, denominator2;

    x12 = (src_pts [0].x - src_pts [1].x);
    x23 = (src_pts [1].x - src_pts [2].x);
    y12 = (src_pts [0].y - src_pts [1].y);
    y23 = (src_pts [1].y - src_pts [2].y);

    nx12 = (dst_pts [0].x - dst_pts [1].x);
    nx23 = (dst_pts [1].x - dst_pts [2].x);
    ny12 = (dst_pts [0].y - dst_pts [1].y);
    ny23 = (dst_pts [1].y - dst_pts [2].y);

    denominator1 = x12*y23 - x23*y12;
    if (denominator1 == 0)
        return FALSE;

    denominator2 = y12*x23 - y23*x12;
    if (denominator2 == 0)
        return FALSE;

    numerator = nx12*y23 - nx23*y12;
    x [0] = LSHIFT (numerator) / denominator1;
    numerator = nx12*x23 - nx23*x12;
    x [1] = LSHIFT (numerator) / denominator2;
    x [2] = LSHIFT (dst_pts [0].x) - x [0] * src_pts [0].x - x [1] * src_pts [0].y;
    
    numerator = ny12*y23 - ny23*y12;
    x [3] = LSHIFT (numerator) / denominator1;
    numerator = ny12*x23 - ny23*x12;
    x [4] = LSHIFT (numerator) / denominator2;
    x [5] = LSHIFT (dst_pts [0].y) - x [3] * src_pts [0].x - x [4] * src_pts [0].y;

    return TRUE;
}
Ejemplo n.º 5
0
    case MACRO_ACTION_STEP_TAPCODE:
      readKeyCodeAndPlay(macro_p++, 0, IS_PRESSED | WAS_PRESSED, false);
      break;

    case MACRO_ACTION_END:
    default:
      return;
    }

    delay(interval);
  }
}

static const Key ascii_to_key_map[] PROGMEM = {
  // 0x21 - 0x30
  LSHIFT(Key_1),
  LSHIFT(Key_Quote),
  LSHIFT(Key_3),
  LSHIFT(Key_4),
  LSHIFT(Key_5),
  LSHIFT(Key_7),
  Key_Quote,
  LSHIFT(Key_9),
  LSHIFT(Key_0),
  LSHIFT(Key_8),
  LSHIFT(Key_Equals),
  Key_Comma,
  Key_Minus,
  Key_Period,
  Key_Slash,
  Key_0,
Ejemplo n.º 6
0
/*------------------------------------------------------------------------------
 Подготовка ADC к работе

 ------------------------------------------------------------------------------*/
void ADC_prepere(void)
{
  // Назначаем источник запускабщих сигналов для ADC
  // Это будет PIT0 канал 0
  SIM_SOPT |= LSHIFT(1, 8);
}
Ejemplo n.º 7
0
 BOOLEAN hit( INT32 index )
 {
    return ( 0 != ( _state & LSHIFT( index ) ) ) ;
 }
Ejemplo n.º 8
0
 void set( INT32 index )
 {
    _state |= LSHIFT( index ) ;
 }