Exemplo n.º 1
0
static PyObject*
_split(PyObject* self, PyObject* arg) {
	char *src = PyString_AS_STRING(arg), *s = src, digitBuffer[32], *d = digitBuffer, *dEnd = digitBuffer + 32, *bPtr;

	PROCESS_TIME(PyInt_FromString);
}
Exemplo n.º 2
0
void guess_enc( int level, int timeg, int ticksg)
{
	int		p1[P1SIZE];
	int		p2[P2SIZE];
	int		p3[P3SIZE];
	int*	saved_ptr;

	unsigned int  dt;
	unsigned int  v;
	unsigned char b;
	unsigned int  saved_t;
	int			  i,k;

	unsigned int size = sizes[ level ];
	int lw = PROCESS_TIME(size) - DELTA(size) ;
	unsigned int low_t;
	unsigned int up_t = PROCESS_TIME(size) + DELTA(size) ;

	low_t = lw <= 0 ? 0 : lw;

	low_t = ROUND( low_t );
	up_t =  ROUND( up_t ) + 10;

	delta_history[level] = (up_t-low_t);

//	printf("low %d up %d \n",low_t, up_t);

	for(dt=low_t;dt<=up_t;dt+=10)
	{
		saved_t = t;
		save_buffers(p1,p2,p3);		
		saved_ptr = ptr;
		

		t = t+dt;
		randomize(timeg, ticksg);
		//memcpy( rand_data[level+2], ptr, 4*10 );

		dt_history[level] = dt;
		ticks_history[ level ] = (ticksg == NO_TICKS_GLITCH ? 0 : 1);
		time_history[ level ] = (timeg == NO_TIME_GLITCH ? 0 : 1);

		for(i=0;i<10;i++)
		{
			if( *ptr < 0)
				initialize_P2();
			if(i==0) v=*ptr;
			rand_data[level+2][i]=*ptr;
			ptr++;
		}

		_asm{ 
			sar v,16h
		}
		b = (v&0x000000FF) ^ k3;
		if( b == seeds[level+2] )
		{		
			stat[level+2]++;

			if( level == MAX_LEVEL - 3)
			{
				/* candidate succeded */
				printf("----\n");
				printf("Succes for (time + ticks) = %X and PID = %d\n", init_time + init_ticks, pid);
				
				printf("dt sequence:   ");
				for(i=0;i<(MAX_LEVEL-2);i++)
					printf("%02d ",dt_history[i]);
				printf("\n");
				
				printf("delta:         ");
				for(i=0;i<(MAX_LEVEL-2);i++)
					printf("%02d ",delta_history[i]);
				printf("\n");

				printf("ticks glitches:");
				for(i=0;i<(MAX_LEVEL-2);i++)
					printf("%02d ",ticks_history[i]);
				printf("\n");

				printf("time glitches: ");
				for(i=0;i<(MAX_LEVEL-2);i++)
					printf("%02d ",time_history[i]);
				printf("\n");

				printf("random data for file 1:");
				for(k=0;k<5;k++)
				{
					for(i=0;i<10;i++)
					{
						v = rand_data[k][i];
						_asm{ 
							sar v,16h
						}
						b=v&0x000000FF;
						rand_suc[k][i]=b;
					}
				}
				for(i=0;i<10;i++)
					printf("%02X ",rand_suc[0][i]);
				printf("\n");



				success++;

				return;
			}

			/* propagate or generate glitches */

			if( timeg == NO_TIME_GLITCH )
			{
				if( ticksg == NO_TICKS_GLITCH )
					guess_enc( level+1, NO_TIME_GLITCH, NO_TICKS_GLITCH );
				guess_enc( level+1, NO_TIME_GLITCH, TICKS_GLITCH );
			}
			if( ticksg == NO_TICKS_GLITCH )
				guess_enc( level+1, TIME_GLITCH, NO_TICKS_GLITCH );
			guess_enc( level+1, TIME_GLITCH, TICKS_GLITCH );
			
		
		}	
		
		restore_buffers(p1,p2,p3);
		t = saved_t;
		ptr = saved_ptr;
	}
	return;
}
Exemplo n.º 3
0
static PyObject*
_split_u(PyObject* self, PyObject* arg) {
	Py_UNICODE *src = PyUnicode_AS_UNICODE(arg), *s = src, digitBuffer[32], *d = digitBuffer, *dEnd = digitBuffer + 32, *bPtr;

	PROCESS_TIME(PyInt_FromUnicode);
}