コード例 #1
0
ファイル: bcache_utils_t.c プロジェクト: tasleson/lvm2
static void _test_set_several_whole_blocks(void *fixture)
{
        _set_cycle(fixture, byte(5, 0), byte(10, 0));
}
コード例 #2
0
ファイル: pelican.c プロジェクト: Kazu-zamasu/kinomajs
static void four_rounds(pelican_state *pelmac)
{
    ulong32 s0, s1, s2, s3, t0, t1, t2, t3;
    int r;

    LOAD32H(s0, pelmac->state      );
    LOAD32H(s1, pelmac->state  +  4);
    LOAD32H(s2, pelmac->state  +  8);
    LOAD32H(s3, pelmac->state  + 12);
    for (r = 0; r < 4; r++) {
        t0 =
            Te0(byte(s0, 3)) ^
            Te1(byte(s1, 2)) ^
            Te2(byte(s2, 1)) ^
            Te3(byte(s3, 0));
        t1 =
            Te0(byte(s1, 3)) ^
            Te1(byte(s2, 2)) ^
            Te2(byte(s3, 1)) ^
            Te3(byte(s0, 0));
        t2 =
            Te0(byte(s2, 3)) ^
            Te1(byte(s3, 2)) ^
            Te2(byte(s0, 1)) ^
            Te3(byte(s1, 0));
        t3 =
            Te0(byte(s3, 3)) ^
            Te1(byte(s0, 2)) ^
            Te2(byte(s1, 1)) ^
            Te3(byte(s2, 0));
        s0 = t0; s1 = t1; s2 = t2; s3 = t3;
    }
    STORE32H(s0, pelmac->state      );
    STORE32H(s1, pelmac->state  +  4);
    STORE32H(s2, pelmac->state  +  8);
    STORE32H(s3, pelmac->state  + 12);
}
コード例 #3
0
ファイル: aes.c プロジェクト: jamesyan84/mt36k_android_4.0.4
 /**
    Initialize the AES (Rijndael) block cipher
    @param key The symmetric key you wish to pass
    @param keylen The key length in bytes
    @param num_rounds The number of rounds desired (0 for default)
    @param skey The key in as scheduled by this function.
    @return CRYPT_OK if successful
 */
int SETUP(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
{
    int i, j;
    ulong32 temp, *rk;
#ifndef ENCRYPT_ONLY
    ulong32 *rrk;
#endif    
    LTC_ARGCHK(key  != NULL);
    LTC_ARGCHK(skey != NULL);
  
    if (keylen != 16 && keylen != 24 && keylen != 32) {
       return CRYPT_INVALID_KEYSIZE;
    }
    
    if (num_rounds != 0 && num_rounds != (10 + ((keylen/8)-2)*2)) {
       return CRYPT_INVALID_ROUNDS;
    }
    
    skey->rijndael.Nr = 10 + ((keylen/8)-2)*2;
        
    /* setup the forward key */
    i                 = 0;
    rk                = skey->rijndael.eK;
    LOAD32H(rk[0], key     );
    LOAD32H(rk[1], key +  4);
    LOAD32H(rk[2], key +  8);
    LOAD32H(rk[3], key + 12);
    if (keylen == 16) {
        j = 44;
        for (;;) {
            temp  = rk[3];
            rk[4] = rk[0] ^ setup_mix(temp) ^ rcon[i];
            rk[5] = rk[1] ^ rk[4];
            rk[6] = rk[2] ^ rk[5];
            rk[7] = rk[3] ^ rk[6];
            if (++i == 10) {
               break;
            }
            rk += 4;
        }
    } else if (keylen == 24) {
        j = 52;   
        LOAD32H(rk[4], key + 16);
        LOAD32H(rk[5], key + 20);
        for (;;) {
        #ifdef _MSC_VER
            temp = skey->rijndael.eK[rk - skey->rijndael.eK + 5]; 
        #else
            temp = rk[5];
        #endif
            rk[ 6] = rk[ 0] ^ setup_mix(temp) ^ rcon[i];
            rk[ 7] = rk[ 1] ^ rk[ 6];
            rk[ 8] = rk[ 2] ^ rk[ 7];
            rk[ 9] = rk[ 3] ^ rk[ 8];
            if (++i == 8) {
                break;
            }
            rk[10] = rk[ 4] ^ rk[ 9];
            rk[11] = rk[ 5] ^ rk[10];
            rk += 6;
        }
    } else if (keylen == 32) {
        j = 60;
        LOAD32H(rk[4], key + 16);
        LOAD32H(rk[5], key + 20);
        LOAD32H(rk[6], key + 24);
        LOAD32H(rk[7], key + 28);
        for (;;) {
        #ifdef _MSC_VER
            temp = skey->rijndael.eK[rk - skey->rijndael.eK + 7]; 
        #else
            temp = rk[7];
        #endif
            rk[ 8] = rk[ 0] ^ setup_mix(temp) ^ rcon[i];
            rk[ 9] = rk[ 1] ^ rk[ 8];
            rk[10] = rk[ 2] ^ rk[ 9];
            rk[11] = rk[ 3] ^ rk[10];
            if (++i == 7) {
                break;
            }
            temp = rk[11];
            rk[12] = rk[ 4] ^ setup_mix(RORc(temp, 8));
            rk[13] = rk[ 5] ^ rk[12];
            rk[14] = rk[ 6] ^ rk[13];
            rk[15] = rk[ 7] ^ rk[14];
            rk += 8;
        }
    } else {
       /* this can't happen */
       return CRYPT_ERROR;
    }

#ifndef ENCRYPT_ONLY    
    /* setup the inverse key now */
    rk   = skey->rijndael.dK;
    rrk  = skey->rijndael.eK + j - 4; 
    
    /* apply the inverse MixColumn transform to all round keys but the first and the last: */
    /* copy first */
    *rk++ = *rrk++;
    *rk++ = *rrk++;
    *rk++ = *rrk++;
    *rk   = *rrk;
    rk -= 3; rrk -= 3;
    
    for (i = 1; i < skey->rijndael.Nr; i++) {
        rrk -= 4;
        rk  += 4;
    #ifdef LTC_SMALL_CODE        
        temp = rrk[0];
        rk[0] = setup_mix2(temp);
        temp = rrk[1];
        rk[1] = setup_mix2(temp);
        temp = rrk[2];
        rk[2] = setup_mix2(temp);
        temp = rrk[3];
        rk[3] = setup_mix2(temp);
     #else
        temp = rrk[0];
        rk[0] =
            Tks0[byte(temp, 3)] ^
            Tks1[byte(temp, 2)] ^
            Tks2[byte(temp, 1)] ^
            Tks3[byte(temp, 0)];
        temp = rrk[1];
        rk[1] =
            Tks0[byte(temp, 3)] ^
            Tks1[byte(temp, 2)] ^
            Tks2[byte(temp, 1)] ^
            Tks3[byte(temp, 0)];
        temp = rrk[2];
        rk[2] =
            Tks0[byte(temp, 3)] ^
            Tks1[byte(temp, 2)] ^
            Tks2[byte(temp, 1)] ^
            Tks3[byte(temp, 0)];
        temp = rrk[3];
        rk[3] =
            Tks0[byte(temp, 3)] ^
            Tks1[byte(temp, 2)] ^
            Tks2[byte(temp, 1)] ^
            Tks3[byte(temp, 0)];
      #endif            
     
    }

    /* copy last */
    rrk -= 4;
    rk  += 4;
    *rk++ = *rrk++;
    *rk++ = *rrk++;
    *rk++ = *rrk++;
    *rk   = *rrk;
#endif /* ENCRYPT_ONLY */

    return CRYPT_OK;   
}
コード例 #4
0
ファイル: CBulletVolume.cpp プロジェクト: Dragonji/jaymod
void
CBulletVolume::render( centity_t& ent )
{
    entityState_t& es = ent.currentState;

    if (!(es.groundEntityNum & BVF_ENABLED))
        return;

    // Setup refent.
    refEntity_t re;
    memset( &re, 0, sizeof(re) );

    re.reType            = RT_MODEL;
    re.renderfx          = RF_NOSHADOW;
    re.hModel            = cgs.media.polygonCubeFO;
    re.nonNormalizedAxes = qtrue;
    re.customShader      = cgs.media.bulletVolumeShader;

    re.shaderRGBA[3] = byte(es.angles2[2] * 255.0f);
    switch (es.modelindex) {
        default: // UNKNWON -> GRAY
        case 0:
            re.shaderRGBA[0] = byte(0.5f * 255.0f);
            re.shaderRGBA[1] = byte(0.5f * 255.0f);
            re.shaderRGBA[2] = byte(0.5f * 255.0f);
            break;

        case 1: // NOHIT -> BLUE
            re.shaderRGBA[0] = byte(0.0f * 255.0f);
            re.shaderRGBA[1] = byte(0.0f * 255.0f);
            re.shaderRGBA[2] = byte(1.0f * 255.0f);
            break;

        case 2: // HIT -> RED
            re.shaderRGBA[0] = byte(1.0f * 255.0f);
            re.shaderRGBA[1] = byte(0.0f * 255.0f);
            re.shaderRGBA[2] = byte(0.0f * 255.0f);
            break;

        case 3: // REFERENCE NOHIT -> GREEN
            re.shaderRGBA[0] = byte(0.0f * 255.0f);
            re.shaderRGBA[1] = byte(1.0f * 255.0f);
            re.shaderRGBA[2] = byte(0.0f * 255.0f);
            break;

        case 4: // REFERENCE HIT -> YELLOW
            re.shaderRGBA[0] = byte(1.0f * 255.0f);
            re.shaderRGBA[1] = byte(1.0f * 255.0f);
            re.shaderRGBA[2] = byte(0.0f * 255.0f);
            break;
    }

    // Apply entity rotation.
    AxisClear( re.axis );
    AnglesToAxis( es.angles, re.axis );

    // Apply scaling matrix.
    vec3_t smatrix[3];
    AxisClear( smatrix );

    smatrix[0][0] *= es.origin2[0];
    smatrix[1][1] *= es.origin2[1];
    smatrix[2][2] *= es.origin2[2];

    vec3_t tmp[3];
    MatrixMultiply( smatrix, re.axis, tmp );
    AxisCopy( tmp, re.axis );

    // Set origins.
    VectorCopy( es.origin, re.origin );
    VectorCopy( es.origin, re.oldorigin );
    VectorCopy( es.origin, re.lightingOrigin );

    trap_R_AddRefEntityToScene( &re );
}
コード例 #5
0
ファイル: decoder.c プロジェクト: puring0815/OpenKore
int onebyteinstr()
{
int r, b, x, y, y1, y2;
   b=PeekOneByte();
   //fprintf(stderr, "b=%02X",b),getch();
   switch(opcodeTable[b])
   {
      case  0: r=op();     if(!r) return 0; x=result; 
               //fprintf(stderr, "x=%02X",x),getch();
               i_opclass=0; i_opcode=x;                
               break;
      case  1: r=op();     if(!r) return 0; x=result; 
               r=byte();   if(!r) return 0; y=result;
               i_opclass=1; i_opcode=x; i_byte=y;      
               break;
      case  2: r=op();     if(!r) return 0; x=result;
               r=word();   if(!r) return 0; y=result;
               i_opclass=2; i_opcode=x; i_word=y;      
               break;
      case  3: r=op();     if(!r) return 0; x=result;
               r=word();   if(!r) return 0; y1=result;
               r=byte();   if(!r) return 0; y2=result;
               i_opclass=3; i_opcode=x; i_word=y1; i_byte=y2; 
               break;
      case     4: r=op();     if(!r) return 0; x=result;
               r=wdword(); if(!r) return 0; y=result;
               i_opclass=4; i_opcode=x; i_dword=y;
               break;
      case 44: r=op();     if(!r) return 0; x=result;
               r=adword(); if(!r) return 0; y=result;
               i_opclass=4; i_opcode=x; i_dword=y;
               break;
      case  5: r=op();     if(!r) return 0; x=result;
               r=pword();  if(!r) return 0; 
               i_opclass=5; i_opcode=x; 
               break;
      case  6: r=op();     if(!r) return 0; x=result;
               r=modrm();  if(!r) return 0; 
               i_opclass=6; i_opcode=x; 
               break;
      case  7: r=op();     if(!r) return 0; x=result;
               r=modrm();  if(!r) return 0;
               r=byte();   if(!r) return 0; y=result;
               i_opclass=7; i_opcode=x; i_byte=y; 
               break;
      case  8: r=op();     if(!r) return 0; x=result;
               r=modrm();  if(!r) return 0;
               r=wdword(); if(!r) return 0; y=result;
               i_opclass=8; i_opcode=x; i_dword=y; 
               break;
      case  9: r=op();     if(!r) return 0; x=result;
               r=opext();  if(!r) return 0;
               i_opclass=9; i_opcode=x;  
               break;
      case 10: r=op();     if(!r) return 0; x=result;
               r=opext();  if(!r) return 0;
               r=byte();   if(!r) return 0; y=result;
               i_opclass=10; i_opcode=x; i_byte=y; 
               break;
      case 11: r=op();     if(!r) return 0; x=result;
               r=opext();  if(!r) return 0;
               r=wdword(); if(!r) return 0; y=result;
               i_opclass=11; i_opcode=x; i_dword=y; 
               break;
      case 12: r=op();     if(!r) return 0; x=result;
               r=opextg(); if(!r) return 0;
               i_opclass=12; i_opcode=x;  
               break;
      case 13: r=op();     if(!r) return 0; x=result; // case jump block
               b=PeekOneByte();
               if (b==36) 
               { 
                  b=PeekSecondByte();
                  if (rmTable[b]==5)
                  {
                     r=op(); if(!r) return 0; y1=result;
                     r=op(); if(!r) return 0; y2=result;
                     i_opclass=13;
                     i_opcode=x;
                     i_mod=y1;
                     i_sib=y2;
                     r=labelstartposition(); if(!r) return 0;
   // ..................................................................            
                     if (nextMode) 
                     {
                        r=label1(); 
                        finished=1;
                        if(!r) return 1;   // need to be careful ...
                     }
                     return 1;
                  }
               }
               //else
               {
                  b=PeekOneByte();
                  if (regTable[b]<7)
                  {
                     r=opext(); if(!r) return 0;
                     i_opclass=13; i_opcode=x;
                  }
                  else return 0;
               }
               break;
      case 14: r=op();     if(!r) return 0; x=result; // test group
               if (x==246)
               {
                  b=PeekOneByte();
                  if (regTable[b]==0)
                  {
                     r=opext();   if(!r) return 0;
                     r=byte();    if(!r) return 0; y=result;
                     i_opclass=14; i_opcode=x; i_byte=y;
                  }
                  else if (regTable[b]>1)
                  {
                     r=opext();   if(!r) return 0;
                     i_opclass=14; i_opcode=x;
                  }
                  else return 0;
               }
               else
               {
                  b=PeekOneByte();
                  if (regTable[b]==0)
                  {
                     r=opext();   if(!r) return 0;
                     r=wdword();    if(!r) return 0; y=result;
                     i_opclass=14; i_opcode=x; i_dword=y;
                  }
                  else 
                  {
                     r=opext();   if(!r) return 0;
                     i_opclass=14; i_opcode=x;
                  }
               }
               break;
      case 15: r=op();     if(!r) return 0; x=result; // wait group
               i_opclass=15; i_opcode=x;
               b=PeekOneByte();
               if (b==217)
               {
                  b=PeekSecondByte();
                  if (regTable[b]==6||regTable[b]==7)
                  {
                     r=op();    if(!r) return 0; y=result;
                     r=opext(); if(!r) return 0;
                     i_opcode=y; prefixStack[i_psp++]=x;
                  }
               }
               else if (b==219)
               {
                  b=PeekSecondByte();
                  if (b==226||b==227)
                  {
                     r=op();    if(!r) return 0; y1=result;
                     r=op();    if(!r) return 0; y2=result;
                     i_opcode=y1; i_mod=y2; prefixStack[i_psp++]=x;   
                  }
               }
               else if (b==221)
               {
                  b=PeekSecondByte();
                  if (regTable[b]==6||regTable[b]==7)
                  {
                     r=op();    if(!r) return 0; y=result;
                     r=opext(); if(!r) return 0;
                     i_opcode=y; prefixStack[i_psp++]=x;
                  }
               }
               else if (b==223)
               {
                  b=PeekSecondByte();
                  if (b==224)
                  {
                     r=op();    if(!r) return 0; y1=result;
                     r=op();    if(!r) return 0; y2=result;
                     i_opcode=y1; i_mod=y2; prefixStack[i_psp++]=x;
                  }
               }
               break;
      case 16: r=op();     if(!r) return 0; x=result; // repeat group
               if (x==242)
               {
                  while(prefixes());
                  b=PeekOneByte();
                  if (repeatgroupTable[b]==1)
                  {
                     r=op();      if(!r) return 0; y=result;
                     i_opclass=16; i_opcode=y; prefixStack[i_psp++]=x;
                  }
                  else return 0;
               }
               else
               {
                  while(prefixes());
                  b=PeekOneByte();
                  if (repeatgroupTable[b]>0)
                  {
                     r=op();      if(!r) return 0; y=result;
                     i_opclass=16; i_opcode=y; prefixStack[i_psp++]=x;  
                  }
                  else return 0;
               }
               break;
      default: return 0;
   }
   return 1;
}
コード例 #6
0
ファイル: lamp.cpp プロジェクト: BenoitGour/RGBLamp
void Lamp::drawCycle()
{

  long hTime;
  long fTime;


  switch (getDisplayMode())
  {
  case lCYCLE:
    hTime = getCycleHoldTime();
    fTime = getCycleFadeTime();
    break;
  case lRANDOM:
    hTime = getRandomHoldTime();
    fTime = getRandomFadeTime();      
    break;
  default:
    break;
  }


  long totalCycleLen = (hTime + fTime)*1000;
  totalCycleLen &=0x0000FFFF;
  long _step = millis() % totalCycleLen;

  //end of cycle;
  if (_step >= hTime*1000  && _step <=(hTime*1000)+10 && _stepped==false)
  {
    _stepped = true;
    switch (getDisplayMode())
    {
    case lCYCLE:
      _targetHue += getCycleSteps();  
      break;
    case lRANDOM:
      _targetHue += random(-getCycleSteps()*2,getCycleSteps()*2);

      break;
    default:
      break;
    }

    //  Serial.println(_targetHue);

    _fadeDirection =0;
    _fadeSteps = 0;

    unsigned char _tmp = 0;
    unsigned char _a = _currentHue;
    while (_a != _targetHue)
    {
      _a++;
      _tmp++;
    }
    _fadeSteps = _tmp;
    _fadeDirection = 1;

    _tmp = 0;
    _a = _currentHue;
    while (_a != _targetHue)
    {
      _a--;
      _tmp++;
    }

    if (_tmp < _fadeSteps)
    {
      _fadeSteps = _tmp;
      _fadeDirection = -1;
    }
  }
  //fade
  else if (_step >= (hTime*1000)+15)
  {
    _stepped=false;
    if (_currentHue != _targetHue)
    {
      long incStep =(fTime*1000)/_fadeSteps ;
      if (_step % incStep < _prevSubStep) _currentHue+= _fadeDirection;
      _prevSubStep = _step % incStep;

    }
  }

  _ledColors[0] = hsbToRGB(getColorHue() +_currentHue,getColorSat(),ambBrightness);
  _ledColors[1] = hsbToRGB(byte(getColorHue() +_currentHue  - (getCycleSteps()*(PI/1.5f) )),byte(getColorSat()/1.2f),ambBrightness);

  _prevStep = _step;

}
コード例 #7
0
//===========================================================================
// DS_Load
//===========================================================================
void DS_Load(sfxbuffer_t *buf, struct sfxsample_s *sample)
{
#define SAMPLE_SILENCE	16		// Samples to interpolate to silence.
#define SAMPLE_ROUNDOFF	32		// The length is a multiple of this.
	LPDIRECTSOUNDBUFFER newSound = NULL;
	LPDIRECTSOUND3DBUFFER newSound3D = NULL;
	bool play3d = !!(buf->flags & SFXBF_3D);
	void *writePtr1 = NULL, *writePtr2 = NULL;
	DWORD writeBytes1, writeBytes2;
	unsigned int safeNumSamples = sample->numsamples + SAMPLE_SILENCE;
	unsigned int safeSize, i;
	int last, delta;

	// Does the buffer already have a sample loaded?
	if(buf->sample)
	{	
		// Is the same one?
		if(buf->sample->id == sample->id) return; 
	}

	// The safe number of samples is rounded to the next highest 
	// count of SAMPLE_ROUNDOFF.
	if((i = safeNumSamples % SAMPLE_ROUNDOFF) != 0)
	{
		safeNumSamples += SAMPLE_ROUNDOFF - i;
/*#if _DEBUG
		Con_Message("Safelen = %i\n", safeNumSamples);
#endif*/
	}
	safeSize = safeNumSamples * sample->bytesper;
/*#if _DEBUG
	Con_Message("Safesize = %i\n", safeSize);
#endif*/

	// If a sample has already been loaded, unload it.
	FreeDSBuffers(buf);

	// Create the DirectSound buffer. Its length will match the sample 
	// exactly.
	if(FAILED(hr = CreateDSBuffer(DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY 
		| DSBCAPS_STATIC | (play3d? DSBCAPS_CTRL3D 
		| DSBCAPS_MUTE3DATMAXDISTANCE : DSBCAPS_CTRLPAN),
		safeNumSamples, buf->freq, buf->bytes*8, 1, &newSound)))
	{
		if(verbose) Error("DS_Load", "Couldn't create a new buffer.");
		return;
	}
	if(play3d)
	{
		// Query the 3D interface.
		if(FAILED(hr = newSound->QueryInterface(IID_IDirectSound3DBuffer, 
			(void**) &newSound3D)))
		{
			if(verbose) Error("DS_Load", "Couldn't get 3D buffer interface.");
			newSound->Release();
			return;
		}
	}

	// Lock and load!
	newSound->Lock(0, 0, &writePtr1, &writeBytes1, 
		&writePtr2, &writeBytes2, DSBLOCK_ENTIREBUFFER);
	if(writePtr2 && verbose) Error("DS_Load", "Unexpected buffer lock behavior.");

	// Copy the sample data.
	memcpy(writePtr1, sample->data, sample->size);

	/*Con_Message("Fill %i bytes (orig=%i).\n", safeSize - sample->size,
			sample->size);*/

	// Interpolate to silence.
	// numSafeSamples includes at least SAMPLE_ROUNDOFF extra samples.
	last = sample->bytesper==1? ((byte*)sample->data)[sample->numsamples - 1]
		: ((short*)sample->data)[sample->numsamples - 1];
	delta = sample->bytesper==1? 0x80 - last : -last;
	//Con_Message("last = %i\n", last);
	for(i = 0; i < safeNumSamples - sample->numsamples; i++)
	{
		float pos = i/(float)SAMPLE_SILENCE;
		if(pos > 1) pos = 1;
		if(sample->bytesper == 1) // 8-bit sample.
		{
			((byte*)writePtr1)[sample->numsamples + i] = 
				byte( last + delta*pos );
		}
		else // 16-bit sample.
		{
			((short*)writePtr1)[sample->numsamples + i] = 
				short( last + delta*pos );
		}
	}

	// Unlock the buffer.
	newSound->Unlock(writePtr1, writeBytes1, writePtr2, writeBytes2);

	buf->ptr = newSound;
	buf->ptr3d = newSound3D;
	buf->sample = sample;
}
コード例 #8
0
ファイル: Leds.cpp プロジェクト: Onkeliroh/Projekt-SS2013
void LEDS::fade()
{
    int colorScenario;

    setBlueRedGreenComp(Color1);

    colorScenario = findColorCase();
 
    adjustFadeDelta();

    switch (colorScenario)
    {
           case 1: 
               greenComp = greenComp + fadeDelta;
               break;
           case 2:
               redComp = redComp + fadeDelta;               
               break;
           case 3:  
               if(greenComp +fadeDelta*(greenComp/redComp) < 0)
               {
                   fadeDelta = FADINGDELTA;                   
               }  
               if(greenComp +fadeDelta*(greenComp/redComp) > 31)
               {
                   fadeDelta = -FADINGDELTA;                               
               }  
               greenComp = byte(greenComp + fadeDelta*(greenComp/redComp));
               redComp = redComp + fadeDelta;
               break;              
           case 4:  
               blueComp = blueComp + fadeDelta;
               break;
           case 5:   
               if(greenComp +fadeDelta*(greenComp/blueComp) < 0)
               {
                   fadeDelta = FADINGDELTA;
               }  
               if(greenComp +fadeDelta*(greenComp/blueComp) > 31)
               {
                   fadeDelta = -FADINGDELTA;
               }             
               greenComp = byte(greenComp + fadeDelta*(greenComp/blueComp));
               blueComp = blueComp + fadeDelta;
               break;
           case 6:  
               if(redComp +fadeDelta*(redComp/blueComp) < 0)
               {
                   fadeDelta = FADINGDELTA;
               }  
               if(redComp +fadeDelta*(redComp/blueComp) > 31)
               {
                   fadeDelta = -FADINGDELTA;
               } 
               redComp = byte(redComp + fadeDelta*(redComp/blueComp));
	       blueComp = blueComp + fadeDelta;
               break;
           case 7:                   
               redComp = byte(redComp + fadeDelta*(redComp/blueComp));
               greenComp = byte(greenComp + fadeDelta*(greenComp/blueComp));
               blueComp = blueComp + fadeDelta;
               break;   
           default:
               break;  
      }
 
      Color1 = Color(blueComp, redComp, greenComp);
      setOneColorForAll(Color1); 
  
}
コード例 #9
0
ファイル: Leds.cpp プロジェクト: Onkeliroh/Projekt-SS2013
byte LEDS::getBlueComp(uint16_t Color)
{
    return byte(Color & 0x1F);
}
コード例 #10
0
ファイル: digipot_mcp4451.cpp プロジェクト: ClumsyApe/Marlin
static byte current_to_wiper(float current) {
  return byte(ceil(float((DIGIPOT_I2C_FACTOR * current))));
}
コード例 #11
0
ファイル: EXROM_write.cpp プロジェクト: jfis/dmc3xl_timeline
void EXROMClass::write(int writePointer, char writeDataStore)                   //write a char to EEPROM
{
  write(writePointer, byte(writeDataStore));
}
コード例 #12
0
ファイル: bcache_utils_t.c プロジェクト: tasleson/lvm2
static void _test_set_many_boundaries(void *fixture)
{
        _set_cycle(fixture, byte(13, 13), byte(23, 13));
}
コード例 #13
0
ファイル: bcache_utils_t.c プロジェクト: tasleson/lvm2
static void _test_set_cross_one_boundary(void *fixture)
{
        _set_cycle(fixture, byte(13, 43), byte(14, 43));
}
コード例 #14
0
ファイル: bcache_utils_t.c プロジェクト: tasleson/lvm2
static void _test_set_within_single_block(void *fixture)
{
        _set_cycle(fixture, byte(7, 3), byte(7, T_BLOCK_SIZE / 2));
}
コード例 #15
0
ファイル: lamp.cpp プロジェクト: BenoitGour/RGBLamp
long Lamp::hsbToRGB(unsigned char h, unsigned char s, unsigned char b)
{

  float fH = (float(h) /255.00f)*360.0f;
  if (fH == 360) fH = 0;
  float fS = float(s) / 255.00f;
  float fB = float(b) / 255.00f;
  float R,G,B;
  byte cR,cG,cB;
  int i;
  float f,p,q,t;

  if (fS ==0 )
  {
    cR = cG = cB = fB;
  }
  else
  {
    fH /= 60;
    i = floor(fH);

    f = fH-i;
    p = fB * (1-fS);
    q = fB * (1-fS*f);
    t = fB * (1-fS * (1-f));

    switch(i){
    case 0:
      R = fB;
      G = t;
      B = p;
      break;
    case 1:
      R = q;
      G = fB;
      B = p;
      break;
    case 2:
      R = p;
      G = fB;
      B = t;
      break;
    case 3:
      R = p;
      G = q;
      B = fB;
      break;
    case 4:
      R = t;
      G = p;
      B = fB;
      break;
    default:        // case 5:
      R = fB;
      G = p;
      B = q;
      break;
    }

    cR = byte(R*255);
    cG = byte(G*255);
    cB = byte(B*255);
  }

  long color = 0x0;
  color = cR;
  color = color << 8;
  color |= cG;
  color = color << 8;
  color |= cB;
  color &= 0xFFFFFF;

  return color;

}
コード例 #16
0
ファイル: WaspRFID13.cpp プロジェクト: ferrangb/waspmoteapi
	//!Calculates the length checksum and sotres it in the buffer. 
	uint8_t WaspRFID::lengthCheckSum(uint8_t *dataTX)
	{
		  dataTX[1] = byte(0x100 - dataTX[0]); 
	}
コード例 #17
0
ファイル: lamp.cpp プロジェクト: BenoitGour/RGBLamp
void Lamp::drawSolid()
{

  _ledColors[0] = hsbToRGB(getColorHue() ,getColorSat(),ambBrightness);
  _ledColors[1] = hsbToRGB(getColorHue() ,byte(getColorSat()/1.2f),ambBrightness);
}
コード例 #18
0
ファイル: dwarf.cpp プロジェクト: simonwelsh/hhvm
void DwarfBuf::dwarf_cfa_def_cfa(uint8_t reg, uint8_t offset) {
  byte(DW_CFA_def_cfa);
  byte(reg);
  byte(offset);
}
コード例 #19
0
ファイル: lex.c プロジェクト: cglinden/autocook
int
gram_lex(void)
{
    static char     *paren;
    static long     paren_max;
    long            paren_depth;
    int             c;
    long            linum;
    int             bol_was;
    int             first_was;
    string_ty       *s;
    int             token;
    int             start_of_line = 0;

    trace(("gram_lex()\n{\n"));
    for (;;)
    {
        linum = line_number;
        bol_was = bol;
        first_was = first;
        c = byte();
        switch (c)
        {
        case INPUT_EOF:
            token = 0;
            goto done;

        case '\t':
            if (!bol_was || within_define)
                continue;
            sa_open();
            for (;;)
            {
                c = byte();
                switch (c)
                {
                case INPUT_EOF:
                case '\n':
                    break;

                case ' ':
                case '\t':
                case '\f':
#if __STDC__ >= 1
                case '\v':
#endif
                    if (sa_data_length)
                        sa_char(c);
                    continue;

                default:
                    sa_char(c);
                    continue;
                }
                break;
            }
            gram_lval.lv_line =
                blob_alloc(sa_close(), input_filename(input), linum);
            token = COMMAND;
            goto done;

        case '#':
            sa_open();
          more_comment:
            start_of_line = 1;
            for (;;)
            {
                c = byte();
                switch (c)
                {
                case INPUT_EOF:
                case '\n':
                    break;

                case '#':
                    if (!start_of_line)
                        sa_char(c);
                    continue;

                case ' ':
                case '\t':
                case '\f':
#if __STDC__ >= 1
                case '\v':
#endif
                    if (!start_of_line)
                        sa_char(' ');
                    continue;

                default:
                    sa_char(c);
                    start_of_line = 0;
                    continue;
                }
                break;
            }
            if (!first_was)
            {
                /*
                 * If the comment did not start at the
                 * beginning of the line, throw it away.
                 */
                byte_undo('\n');
                continue;
            }
            token = COMMENT;
            if (c == '\n')
            {
                /*
                 * Take a peek at the next character.
                 * If it is '#', we have more comment.
                 * If it is '\t', we have a code comment.
                 */
                c = byte();
                if (c == '#')
                {
                    sa_char('\n');
                    goto more_comment;
                }
                if (c == '\t')
                    token = COMMAND_COMMENT;
                byte_undo(c);

                /* need to restore this state, too */
                bol = 1;
                first = 1;
                colon_special = 1;
            }
            gram_lval.lv_line =
                blob_alloc(sa_close(), input_filename(input), linum);
            goto done;

        case ' ':
        case '\f':
#if __STDC__ >= 1
        case '\v':
#endif
            break;

        case '\n':
            token = EOLN;
            goto done;

        case ';':
            if (!colon_special)
                goto normal;
            byte_undo('\t');
            bol = 1;
            first = 1;
            colon_special = 1;
            token = EOLN;
            goto done;

        case ':':
            if (!colon_special)
                goto normal;
            c = byte();
            if (c == ':')
            {
                token = COLON_COLON;
                goto done;
            }
            if (c == '=')
            {
                token = COLON_EQUALS;
                colon_special = 0;
                goto done;
            }
            byte_undo(c);
            token = COLON;
            goto done;

        case '=':
            token = EQUALS;
            colon_special = 0;
            goto done;

        case '+':
            c = byte();
            if (c == '=')
            {
                token = PLUS_EQUALS;
                colon_special = 0;
                goto done;
            }
            byte_undo(c);
            c = '+';
            /* fall through... */

        default:
          normal:
            sa_open();
            paren_depth = 0;
            for (;;)
            {
                switch (c)
                {
                case INPUT_EOF:
                case '\n':
                    break;

                case ' ':
                case '\t':
                case '\f':
#if __STDC__ >= 1
                case '\v':
#endif
                    if (!within_define && !paren_depth)
                        break;
                    sa_char(c);
                    c = byte();
                    continue;

                case ';':
                case ':':
                case '=':
                    if (colon_special && !within_define && !paren_depth)
                        break;
                    sa_char(c);
                    c = byte();
                    continue;

                default:
                    sa_char(c);
                    c = byte();
                    continue;

                case '(':
                    sa_char(c);
                    if (paren_depth >= paren_max)
                    {
                        paren_max = paren_max * 2 + 16;
                        paren = mem_change_size(paren, paren_max);
                    }
                    paren[paren_depth++] = ')';
                    c = byte();
                    continue;

                case ')':
                case '}':
                    sa_char(c);
                    if (paren_depth && c == paren[paren_depth - 1])
                        --paren_depth;
                    c = byte();
                    continue;

                case '{':
                    sa_char(c);
                    if (paren_depth >= paren_max)
                    {
                        paren_max = paren_max * 2 + 16;
                        paren = mem_change_size(paren, paren_max);
                    }
                    paren[paren_depth++] = '}';
                    c = byte();
                    continue;
                }
                break;
            }
            byte_undo(c);
            s = sa_close();
            if (first_was && (token = reserved(s)) != 0)
            {
                switch (token)
                {
                case DEFINE:
                    str_free(s);
                    ++within_define;
                    break;

                case ENDDEF:
                    str_free(s);
                    --within_define;
                    break;

                case IF:
                    gram_lval.lv_line =
                        blob_alloc(s, input_filename(input), linum);
                    break;

                case VPATH:
                    colon_special = 0;
                    break;

                default:
                    str_free(s);
                    break;
                }
                goto done;
            }
            gram_lval.lv_line = blob_alloc(s, input_filename(input), linum);
            token = WORD;
            goto done;
        }
    }

    /*
     * here for all exits
     */
  done:
#ifdef DEBUG
    if (token == WORD || token == COMMENT || token == COMMAND)
        trace(("text = \"%s\";\n", gram_lval.lv_line->text->str_text));
#endif
    trace(("return %d;\n", token));
    trace(("}\n"));
    return token;
}
コード例 #20
0
ファイル: dwarf.cpp プロジェクト: simonwelsh/hhvm
void DwarfBuf::dwarf_cfa_same_value(uint8_t reg) {
  byte(DW_CFA_same_value);
  byte(reg);
}
コード例 #21
0
ファイル: file.hpp プロジェクト: dariaphoebe/gitflip
 uint8_t operator[] ( const off_t index ) const { return byte( index ); }
コード例 #22
0
ファイル: dwarf.cpp プロジェクト: simonwelsh/hhvm
void DwarfBuf::dwarf_cfa_offset_extended_sf(uint8_t reg, int8_t offset) {
  byte(DW_CFA_offset_extended_sf);
  byte(reg);
  byte(offset & 0x7f);
}
コード例 #23
0
ファイル: imgloadgif.cpp プロジェクト: turbanoff/X-plore
   bool ReadStack(){

                              //reset output stack
      stack_top = 0;
                              //get next code
      word code;
      assert(code_size <= 12);
      if(!ReadBits(code_size, code))
         return false;

                              //index of first free entry in table
      const word first_entry = clear_code + 2;

                              //switch, different posibilities for code:
      if(code == clear_code+1)
         return true;         //exit LZW decompression loop
      if(code == clear_code){
         code_size = init_code_size + 1;  //reset code size
         next_entry_index = first_entry;        //reset Translation Table
         prev_code = code;                //Prevent next to be added to table.
                              //restart, to get another code
         return ReadStack();
      }
      word out_code;          //0 - 4096
      if(code < next_entry_index){
                           //code is in table
                           //set code to output
         out_code = code;
      }else{
                           //code is not in table
                           //keep first character of previous output
         ++stack_top;
                           //set prev_code to be output
         out_code = prev_code;
      }
                           //expand outcode in out_stack

                           // - Elements up to first_entry are Raw-Codes and are not expanded
                           // - Table Prefices contain indexes to other codes
                           // - Table Suffices contain the raw codes to be output
      while(out_code >= first_entry){
         if(stack_top > 4096)
            return false;
                           //add suffix to output stack
         out_stack[stack_top++] = suffix[out_code];
                           //loop with preffix
         out_code = prefix[out_code];
                              //watch for corruption
         if(out_code >= 4096)
            out_code = 0;
      }

                           //now outcode is a raw code, add it to output stack
      if(stack_top > 4096)
         return false;
      out_stack[stack_top++] = byte(out_code);

                           //add new entry to table (prev_code + outcode)
                           // (except if previous code was a clearcode)
      if(prev_code!=clear_code){
                           //prevent translation table overflow
         if(next_entry_index>=4096)
            //return false;
            next_entry_index = 4095;

         prefix[next_entry_index] = prev_code;
         suffix[next_entry_index] = byte(out_code);
         ++next_entry_index;
                           //increase codesize if next_entry_index is invalid with current codesize
         if(next_entry_index >= dword(1<<code_size)){
            if(code_size < 12)
               ++code_size;
         }
      }
      prev_code = code;
      return true;
   }
コード例 #24
0
// GET_STATE: returns the current state of the switch and prints the state to serial monitor
// RETURN: current state
float InputElement::get_print_byte_state() {
    Serial.print(byte(int(output_state)));
    return get_state();
}
コード例 #25
0
ファイル: decoder.c プロジェクト: puring0815/OpenKore
int sib()
{
   return byte();
}
コード例 #26
0
ファイル: image.hpp プロジェクト: huangpanxx/face3d_old
// CIE conversion to gray using integer arithmetic, add 500 to take care of rounding
static const inline byte RgbToGray (RGB_TRIPLE Rgb)
{ return byte((299 * Rgb.Red + 587 * Rgb.Green + 114 * Rgb.Blue + 500) / 1000); }
コード例 #27
0
ファイル: NIF_IO.cpp プロジェクト: CruxAnsata/niflib
void NifStream( ShortString const & val, ostream& out, const NifInfo & info ) {
	WriteByte( byte(val.str.size() + 1), out );
	out.write( val.str.c_str(), std::streamsize(val.str.size()) );
	WriteByte( 0, out );
};
コード例 #28
0
ファイル: config.cpp プロジェクト: houzhenggang/ESP8266-2
void CONFIG::print_config()
{
 //use bigest size for buffer
  char sbuf[MAX_PASSWORD_LENGTH+1];
  byte bbuf=0;
  int ibuf=0;
  if (CONFIG::read_byte(EP_WIFI_MODE, &bbuf ))
	{
	 if (byte(bbuf)==CLIENT_MODE) Serial.println("Mode: Station");
	 else  if (byte(bbuf)==AP_MODE) Serial.println("Mode: Access Point");
	 else Serial.println("Mode: ???");
	}
  else Serial.println("Error reading mode");
  if (CONFIG::read_string(EP_SSID, sbuf , MAX_SSID_LENGTH))
  {
   Serial.print("SSID: ");
  Serial.println(sbuf);
  }
  else  Serial.println("Error reading SSID");
  //if (CONFIG::read_string(EP_PASSWORD, sbuf , MAX_PASSWORD_LENGTH))Serial.println(sbuf);
  
  if (CONFIG::read_byte(EP_IP_MODE, &bbuf ))
  {
	 if (byte(bbuf)==STATIC_IP_MODE) Serial.println("IP Mode: Static");
	 else  if (byte(bbuf)==DHCP_MODE) Serial.println("IP Mode: DHCP");
	 else Serial.println("IP mode: ???");
  }
  else  Serial.println("Error reading IP mode");
  if (CONFIG::read_buffer(EP_IP_VALUE,(byte *)sbuf , IP_LENGTH))
  {
	Serial.print("IP: ");
	Serial.println(wifi_config.ip2str((byte *)sbuf));
	}
  else Serial.println("Error reading IP");
  if (CONFIG::read_buffer(EP_MASK_VALUE, (byte *)sbuf  , IP_LENGTH))
  {
	Serial.print("Subnet: ");
	Serial.println(wifi_config.ip2str((byte *)sbuf));
   }
  else Serial.println("Error reading subnet");
  if (CONFIG::read_buffer(EP_GATEWAY_VALUE, (byte *)sbuf  , IP_LENGTH))
  {
	Serial.print("Gateway : ");
   Serial.println(wifi_config.ip2str((byte *)sbuf));
    }
  else Serial.println("Error reading gateway");
  if (CONFIG::read_buffer(EP_BAUD_RATE,  (byte *)&ibuf , INTEGER_LENGTH))
  {
	Serial.print("Baud rate : ");
  Serial.println(ibuf);
  }
  else Serial.println("Error reading baud rate");
  if (CONFIG::read_byte(EP_PHY_MODE, &bbuf ))
  {
	  Serial.print("Phy mode : ");
	  if (byte(bbuf)==PHY_MODE_11B)Serial.println("11b");
	  else if (byte(bbuf)==PHY_MODE_11G)Serial.println("11g");
	  else if (byte(bbuf)==PHY_MODE_11N)Serial.println("11n");
	  else Serial.println("???");
    }
  else Serial.println("Error reading phy mode");
  if (CONFIG::read_byte(EP_SLEEP_MODE, &bbuf ))
  {
	Serial.print("Sleep mode : ");
	  if (byte(bbuf)==NONE_SLEEP_T)Serial.println("None");
	  else if (byte(bbuf)==LIGHT_SLEEP_T)Serial.println("Light");
	  else if (byte(bbuf)==MODEM_SLEEP_T)Serial.println("Modem");
	  else Serial.println("???");
  }
  else Serial.println("Error reading sleep mode");
  if (CONFIG::read_byte(EP_CHANNEL, &bbuf ))
  {
	 Serial.print("Channel : ");
	Serial.println(byte(bbuf));
   }
  else Serial.println("Error reading channel");
  
  if (CONFIG::read_byte(EP_AUTH_TYPE, &bbuf ))
  {
	Serial.print("Authentification : ");
	if (byte(bbuf)==AUTH_OPEN)Serial.println("None");
	else if (byte(bbuf)==AUTH_WEP)Serial.println("WEP");
	else if (byte(bbuf)==AUTH_WPA_PSK)Serial.println("WPA");
	else if (byte(bbuf)==AUTH_WPA2_PSK)Serial.println("WPA2");
	else if (byte(bbuf)==AUTH_WPA_WPA2_PSK)Serial.println("WPA/WPA2");
	else if (byte(bbuf)==AUTH_MAX)Serial.println("Max");
	else Serial.println("???");
  }
  else Serial.println("Error reading authentification");
  if (CONFIG::read_byte(EP_SSID_VISIBLE, &bbuf ))
  {
	  Serial.print("SSID visibility: ");
	  if (bbuf==0)Serial.println("Hidden");
	  else if (bbuf==1)Serial.println("Visible");
	  else Serial.println(bbuf);
      }
  else Serial.println("Error reading SSID visibility");
  if (CONFIG::read_buffer(EP_WEB_PORT,  (byte *)&ibuf , INTEGER_LENGTH))
  {
	  Serial.print("Web port: ");
	  Serial.println(ibuf);
       }
  else Serial.println("Error reading web port");
  if (CONFIG::read_buffer(EP_DATA_PORT,  (byte *)&ibuf , INTEGER_LENGTH))
  {
  Serial.print("Data port: ");
	  Serial.println(ibuf);
  }
  else Serial.println("Error reading data port");
  if (CONFIG::read_byte(EP_REFRESH_PAGE_TIME, &bbuf ))
  {
	Serial.print("Web page refresh time: ");
	  Serial.println(byte(bbuf));
	    }
  else Serial.println("Error reading refesh page");
  if (CONFIG::read_string(EP_HOSTNAME, sbuf , MAX_HOSTNAME_LENGTH))
  {
	  Serial.print("Hostname : ");
	  Serial.println(sbuf);
   }
  else Serial.println("Error reading hostname");
  
  if (CONFIG::read_buffer(EP_XY_FEEDRATE,  (byte *)&ibuf , INTEGER_LENGTH))
  {
   Serial.print("XY feed rate: ");
   Serial.println(ibuf);
     }
  else Serial.println("Error reading XY feed rate");
  if (CONFIG::read_buffer(EP_Z_FEEDRATE,  (byte *)&ibuf , INTEGER_LENGTH))
  {
	Serial.print("Z feed rate: ");
   Serial.println(ibuf);
  }
  else Serial.println("Error reading Z feed rate");
  if (CONFIG::read_buffer(EP_E_FEEDRATE,  (byte *)&ibuf , INTEGER_LENGTH))
  {
   Serial.print("E feed rate: ");
    Serial.println(ibuf);
      }
  else Serial.println("Error reading E feed rate");
  
Serial.print("Captive portal : ");
 #ifdef CAPTIVE_PORTAL_FEATURE
    Serial.println("Enabled");
 #else
	Serial.println("Disabled");
#endif
Serial.print("SSDP : ");
#ifdef SSDP_FEATURE
    Serial.println("Enabled");
 #else
	Serial.println("Disabled");
#endif
Serial.print("mDNS : ");
#ifdef MDNS_FEATURE
    Serial.println("Enabled");
 #else
	Serial.println("Disabled");
#endif
} 
コード例 #29
0
ファイル: aes.c プロジェクト: jamesyan84/mt36k_android_4.0.4
int ECB_DEC(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
#endif
{
    ulong32 s0, s1, s2, s3, t0, t1, t2, t3, *rk;
    int Nr, r;

    LTC_ARGCHK(pt != NULL);
    LTC_ARGCHK(ct != NULL);
    LTC_ARGCHK(skey != NULL);
    
    Nr = skey->rijndael.Nr;
    rk = skey->rijndael.dK;

    /*
     * map byte array block to cipher state
     * and add initial round key:
     */
    LOAD32H(s0, ct      ); s0 ^= rk[0];
    LOAD32H(s1, ct  +  4); s1 ^= rk[1];
    LOAD32H(s2, ct  +  8); s2 ^= rk[2];
    LOAD32H(s3, ct  + 12); s3 ^= rk[3];

#ifdef LTC_SMALL_CODE
    for (r = 0; ; r++) {
        rk += 4;
        t0 =
            Td0(byte(s0, 3)) ^
            Td1(byte(s3, 2)) ^
            Td2(byte(s2, 1)) ^
            Td3(byte(s1, 0)) ^
            rk[0];
        t1 =
            Td0(byte(s1, 3)) ^
            Td1(byte(s0, 2)) ^
            Td2(byte(s3, 1)) ^
            Td3(byte(s2, 0)) ^
            rk[1];
        t2 =
            Td0(byte(s2, 3)) ^
            Td1(byte(s1, 2)) ^
            Td2(byte(s0, 1)) ^
            Td3(byte(s3, 0)) ^
            rk[2];
        t3 =
            Td0(byte(s3, 3)) ^
            Td1(byte(s2, 2)) ^
            Td2(byte(s1, 1)) ^
            Td3(byte(s0, 0)) ^
            rk[3];
        if (r == Nr-2) {
           break; 
        }
        s0 = t0; s1 = t1; s2 = t2; s3 = t3;
    }
    rk += 4;

#else       

    /*
     * Nr - 1 full rounds:
     */
    r = Nr >> 1;
    for (;;) {

        t0 =
            Td0(byte(s0, 3)) ^
            Td1(byte(s3, 2)) ^
            Td2(byte(s2, 1)) ^
            Td3(byte(s1, 0)) ^
            rk[4];
        t1 =
            Td0(byte(s1, 3)) ^
            Td1(byte(s0, 2)) ^
            Td2(byte(s3, 1)) ^
            Td3(byte(s2, 0)) ^
            rk[5];
        t2 =
            Td0(byte(s2, 3)) ^
            Td1(byte(s1, 2)) ^
            Td2(byte(s0, 1)) ^
            Td3(byte(s3, 0)) ^
            rk[6];
        t3 =
            Td0(byte(s3, 3)) ^
            Td1(byte(s2, 2)) ^
            Td2(byte(s1, 1)) ^
            Td3(byte(s0, 0)) ^
            rk[7];

        rk += 8;
        if (--r == 0) {
            break;
        }


        s0 =
            Td0(byte(t0, 3)) ^
            Td1(byte(t3, 2)) ^
            Td2(byte(t2, 1)) ^
            Td3(byte(t1, 0)) ^
            rk[0];
        s1 =
            Td0(byte(t1, 3)) ^
            Td1(byte(t0, 2)) ^
            Td2(byte(t3, 1)) ^
            Td3(byte(t2, 0)) ^
            rk[1];
        s2 =
            Td0(byte(t2, 3)) ^
            Td1(byte(t1, 2)) ^
            Td2(byte(t0, 1)) ^
            Td3(byte(t3, 0)) ^
            rk[2];
        s3 =
            Td0(byte(t3, 3)) ^
            Td1(byte(t2, 2)) ^
            Td2(byte(t1, 1)) ^
            Td3(byte(t0, 0)) ^
            rk[3];
    }
#endif

    /*
     * apply last round and
     * map cipher state to byte array block:
     */
    s0 =
        (Td4[byte(t0, 3)] & 0xff000000) ^
        (Td4[byte(t3, 2)] & 0x00ff0000) ^
        (Td4[byte(t2, 1)] & 0x0000ff00) ^
        (Td4[byte(t1, 0)] & 0x000000ff) ^
        rk[0];
    STORE32H(s0, pt);
    s1 =
        (Td4[byte(t1, 3)] & 0xff000000) ^
        (Td4[byte(t0, 2)] & 0x00ff0000) ^
        (Td4[byte(t3, 1)] & 0x0000ff00) ^
        (Td4[byte(t2, 0)] & 0x000000ff) ^
        rk[1];
    STORE32H(s1, pt+4);
    s2 =
        (Td4[byte(t2, 3)] & 0xff000000) ^
        (Td4[byte(t1, 2)] & 0x00ff0000) ^
        (Td4[byte(t0, 1)] & 0x0000ff00) ^
        (Td4[byte(t3, 0)] & 0x000000ff) ^
        rk[2];
    STORE32H(s2, pt+8);
    s3 =
        (Td4[byte(t3, 3)] & 0xff000000) ^
        (Td4[byte(t2, 2)] & 0x00ff0000) ^
        (Td4[byte(t1, 1)] & 0x0000ff00) ^
        (Td4[byte(t0, 0)] & 0x000000ff) ^
        rk[3];
    STORE32H(s3, pt+12);

    return CRYPT_OK;
}
コード例 #30
0
ファイル: bcache_utils_t.c プロジェクト: tasleson/lvm2
static void _test_set_last_block(void *fixture)
{
        uint64_t last_block = NR_BLOCKS - 1;
	_set_cycle(fixture, byte(last_block, 0), byte(last_block, T_BLOCK_SIZE)); 
}