diff --git a/ctatest.c b/ctatest.c index 0583513..a271329 100644 --- a/ctatest.c +++ b/ctatest.c @@ -6,6 +6,7 @@ #include #include "rijndael-api-fst.h" #include +#include "armpmu_lib.h" #include #include #include @@ -78,10 +79,12 @@ int main(int argc, char *argv[]) { if(test == TEST_CASE_P1K1P1K1) { - printf("Execution test case Test1\n"); - Test1(); + /*printf("Execution test case Test1\n");*/ + /*Test1();*/ /*printf("Execution test case Test2\n");*/ /*Test2();*/ + printf("Execution test case Test3\n"); + Test3(); } } @@ -167,6 +170,94 @@ static inline uint32_t Op(FILE* fd, BYTE plaintextCandidat[], cipherInstance *ci return (t2 - t1); } +void Test3() +{ + int i, j, r, k, l; + BYTE block[BLOCK_SIZE]; + BYTE output[BLOCK_SIZE]; + BYTE output2[BLOCK_SIZE]; + char keyMaterial[320]; + keyInstance keyInst; + cipherInstance cipherInst; + + FILE* fd = cyclecounter_open(); + int nLoop = 1000; + int nbOffsets = 8; + uint32_t t1; + FILE *fp = fopen ("/data/local/tmp/trace", "w+"); + + BYTE* keyCandidat; + BYTE* plaintextCandidat; + + + int offset; + int numBlocks; + struct timeval start; + struct timeval end; + long long int tmp = 0, time; + u32 time1, time2, ch1, cm1, o1, dr, dw; + + /*keyCandidat = data[0][65][1];*/ + for(j = 0; j < nLoop; j++) + { + /*keyCandidat[0] = (BYTE)rand()%256;*/ + for(i = 0; i < nLoop; i++) + { + /*memset(keyMaterial, 0, sizeof(keyMaterial));*/ + /*memcpy(keyMaterial, keyCandidat, 16);*/ + + /*r = makeKey(&keyInst, ENCRYPT, AES_KEY_LEN_128, keyMaterial);*/ + /*if(r != TRUE)*/ + /*{*/ + /*printf("[+] makeKey error %d\n", r);*/ + /*return;*/ + /*}*/ + + /*r = cipherInit(&cipherInst, MODE_ECB, NULL);*/ + /*if(r != TRUE)*/ + /*{*/ + /*printf("[+] cipherInit error %d\n", r);*/ + /*return;*/ + /*}*/ + + /*numBlocks = AES_KEY_LEN_128/128;*/ + + cyclecounter_flushall(fd); + /*gettimeofday(&start, NULL);*/ + enable_counters(); + time1 = get_cycle_count(); + + /*for (i = numBlocks; i > 0; i--) {*/ + /*rijndaelEncrypt2((&keyInst)->rk, (&keyInst)->Nr, plaintextCandidat, output);*/ + /**(plaintextCandidat) += 16;*/ + /**(output) += 16;*/ + /*}*/ + + time2 = get_cycle_count(); + disable_counters(); + /*gettimeofday(&end, NULL);*/ + + /*ch1 = read_pmn(0), cm1 = read_pmn(1), o1 = read_flags(), dr = read_pmn(2), dw = read_pmn(3);*/ + /*tmp = end.tv_sec - start.tv_sec;*/ + /*tmp *= 1000000;*/ + /*tmp += end.tv_usec - start.tv_usec;*/ + + /*time += tmp;*/ + + fprintf(fp, "%u %u %u 0x%X %u %u\n", + (time2 - time1), + ch1, cm1, o1, + dr, dw); + } + /*fprintf(fp, "%lld\n", time/nLoop);*/ + } + fclose(fp); + cyclecounter_close(fd); +} + + + + void Test2() { int i, j, r, k, l; diff --git a/rijndael-alg-fst.c b/rijndael-alg-fst.c index bdc546d..0bcbb7c 100644 --- a/rijndael-alg-fst.c +++ b/rijndael-alg-fst.c @@ -28,7 +28,6 @@ #define FULL_UNROLL #include "rijndael-alg-fst.h" -#include "armpmu_lib.h" /* Te0[x] = S [x].[02, 01, 01, 03]; @@ -853,6 +852,195 @@ int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBit return Nr; } +void rijndaelEncrypt2(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]) { + u32 s0, s1, s2, s3, t0, t1, t2, t3, time1, time2, ch1, cm1, o1, dr, dw; +#ifndef FULL_UNROLL + int r; +#endif /* ?FULL_UNROLL */ + + + /* + * map byte array block to cipher state + * and add initial round key: + */ + s0 = GETU32(pt ) ^ rk[0]; + s1 = GETU32(pt + 4) ^ rk[1]; + s2 = GETU32(pt + 8) ^ rk[2]; + s3 = GETU32(pt + 12) ^ rk[3]; +#ifdef FULL_UNROLL + /* round 1: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; + /* round 2: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; + + /* round 3: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; + /* round 4: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; + /* round 5: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; + /* round 6: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; + /* round 7: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; + /* round 8: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; + /* round 9: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; + + + if (Nr > 10) { + /* round 10: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43]; + /* round 11: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47]; + if (Nr > 12) { + /* round 12: */ + s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48]; + s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49]; + s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50]; + s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51]; + /* round 13: */ + t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52]; + t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53]; + t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54]; + t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55]; + } + } + rk += Nr << 2; +#else /* !FULL_UNROLL */ + /* + * Nr - 1 full rounds: + */ + r = Nr >> 1; + for (;;) { + t0 = + Te0[(s0 >> 24) ] ^ + Te1[(s1 >> 16) & 0xff] ^ + Te2[(s2 >> 8) & 0xff] ^ + Te3[(s3 ) & 0xff] ^ + rk[4]; + t1 = + Te0[(s1 >> 24) ] ^ + Te1[(s2 >> 16) & 0xff] ^ + Te2[(s3 >> 8) & 0xff] ^ + Te3[(s0 ) & 0xff] ^ + rk[5]; + t2 = + Te0[(s2 >> 24) ] ^ + Te1[(s3 >> 16) & 0xff] ^ + Te2[(s0 >> 8) & 0xff] ^ + Te3[(s1 ) & 0xff] ^ + rk[6]; + t3 = + Te0[(s3 >> 24) ] ^ + Te1[(s0 >> 16) & 0xff] ^ + Te2[(s1 >> 8) & 0xff] ^ + Te3[(s2 ) & 0xff] ^ + rk[7]; + + rk += 8; + if (--r == 0) { + break; + } + + s0 = + Te0[(t0 >> 24) ] ^ + Te1[(t1 >> 16) & 0xff] ^ + Te2[(t2 >> 8) & 0xff] ^ + Te3[(t3 ) & 0xff] ^ + rk[0]; + s1 = + Te0[(t1 >> 24) ] ^ + Te1[(t2 >> 16) & 0xff] ^ + Te2[(t3 >> 8) & 0xff] ^ + Te3[(t0 ) & 0xff] ^ + rk[1]; + s2 = + Te0[(t2 >> 24) ] ^ + Te1[(t3 >> 16) & 0xff] ^ + Te2[(t0 >> 8) & 0xff] ^ + Te3[(t1 ) & 0xff] ^ + rk[2]; + s3 = + Te0[(t3 >> 24) ] ^ + Te1[(t0 >> 16) & 0xff] ^ + Te2[(t1 >> 8) & 0xff] ^ + Te3[(t2 ) & 0xff] ^ + rk[3]; + } + + +#endif /* ?FULL_UNROLL */ + + + /* + * apply last round and + * map cipher state to byte array block: + */ + s0 = + (Te4[(t0 >> 24) ] & 0xff000000) ^ + (Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t3 ) & 0xff] & 0x000000ff) ^ + rk[0]; + PUTU32(ct , s0); + s1 = + (Te4[(t1 >> 24) ] & 0xff000000) ^ + (Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t0 ) & 0xff] & 0x000000ff) ^ + rk[1]; + PUTU32(ct + 4, s1); + s2 = + (Te4[(t2 >> 24) ] & 0xff000000) ^ + (Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t1 ) & 0xff] & 0x000000ff) ^ + rk[2]; + PUTU32(ct + 8, s2); + s3 = + (Te4[(t3 >> 24) ] & 0xff000000) ^ + (Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ + (Te4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ + (Te4[(t2 ) & 0xff] & 0x000000ff) ^ + rk[3]; + PUTU32(ct + 12, s3); + +} void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16], FILE* fp, FILE* fd) { u32 s0, s1, s2, s3, t0, t1, t2, t3, time1, time2, ch1, cm1, o1, dr, dw; #ifndef FULL_UNROLL @@ -869,9 +1057,9 @@ void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 c s2 = GETU32(pt + 8) ^ rk[2]; s3 = GETU32(pt + 12) ^ rk[3]; - cyclecounter_flushall(fd); - enable_counters(); - time1 = get_cycle_count(); + /*cyclecounter_flushall(fd);*/ + /*enable_counters();*/ + /*time1 = get_cycle_count();*/ #ifdef FULL_UNROLL /* round 1: */ @@ -885,16 +1073,14 @@ void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 c s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; - time2 = get_cycle_count(); - disable_counters(); - ch1 = read_pmn(0), cm1 = read_pmn(1), o1 = read_flags(), dr = read_pmn(2), dw = read_pmn(3); - - fprintf(fp, "%u %u %u 0x%X %u %u\n", - (time2 - time1), - ch1, cm1, o1, - dr, dw); - fflush(fp); + /*time2 = get_cycle_count();*/ + /*disable_counters();*/ + /*ch1 = read_pmn(0), cm1 = read_pmn(1), o1 = read_flags(), dr = read_pmn(2), dw = read_pmn(3);*/ + /*fprintf(fp, "%u %u %u 0x%X %u %u\n", */ + /*(time2 - time1), */ + /*ch1, cm1, o1,*/ + /*dr, dw);*/ /* round 3: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; @@ -1023,6 +1209,7 @@ void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 c #endif /* ?FULL_UNROLL */ + /* * apply last round and * map cipher state to byte array block: diff --git a/rijndael-alg-fst.h b/rijndael-alg-fst.h index 9286c32..7d413f6 100644 --- a/rijndael-alg-fst.h +++ b/rijndael-alg-fst.h @@ -38,6 +38,7 @@ typedef unsigned int u32; int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16], FILE* fd, FILE* fp); +void rijndaelEncrypt2(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]); void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]); #ifdef INTERMEDIATE_VALUE_KAT diff --git a/server.c b/server.c index 72c98a1..c7df091 100644 --- a/server.c +++ b/server.c @@ -1,4 +1,5 @@ #include +#include #include "armpmu_lib.h" #include #include @@ -25,6 +26,9 @@ char in[1537]; int r; char out[40]; FILE* fd; +struct timeval tv_debut; +struct timeval tv_fin; +long long int duree; @@ -43,15 +47,22 @@ void handle(char out[40],char in[],int len, FILE* f) /*for(i = 0; i < len; ++i) printf("%x", in[i]);*/ /*printf(") ==> [AES_encrypt] ==> ");*/ cyclecounter_flushall(fd); - *(unsigned int *) (out + 32) = get_cycle_count(); + /**(unsigned int *) (out + 32) = get_cycle_count();*/ enable_counters(); + gettimeofday(&tv_debut, NULL); + *(unsigned int*) (out + 32) = 1000000 * tv_debut.tv_sec + tv_debut.tv_usec; + AES_encrypt(in,workarea,&expanded); + + gettimeofday(&tv_fin, NULL); + *(unsigned int *) (out + 36) = 1000000 * tv_fin.tv_sec + tv_fin.tv_usec; disable_counters(); - *(unsigned int *) (out + 36) = get_cycle_count(); + + /**(unsigned int *) (out + 36) = get_cycle_count();*/ ch1 = read_pmn(0), cm1 = read_pmn(1), o1 = read_flags(); dr = read_pmn(2), dw = read_pmn(3); fprintf(f, "%u %u %u %u %u\n", ch1, cm1, o1, dr, dw); - fflush(f); + /*fflush(f);*/ /*printf("[");*/ /*for(i = 0; i < 16; ++i) printf("%x", workarea[i]);*/ /*printf("] [");*/ diff --git a/study.c b/study.c index 5212f7f..6d72e05 100644 --- a/study.c +++ b/study.c @@ -57,12 +57,12 @@ void studyinput(FILE *fp) unsigned int timing; timing = *(unsigned int *) (response + 36); timing -= *(unsigned int *) (response + 32); - if (timing < 1400) { /* clip tail to reduce noise */ + /*if (timing < 1400) { [> clip tail to reduce noise <]*/ fprintf(fp, "%u\n", timing); - fflush(fp); + /*fflush(fp);*/ tally(timing); return; - } + /*}*/ } } if (poll(&p,1,0) <= 0) break;