void bunny24_bruteForce(bit plain[block_length] , bit crypt[block_length]){ unsigned int i, end = 1024 * 1024 * 16; bit test[block_length]; bit testp[block_length]; for(i = 0; i < end; i++) { arrayCopy(plain , testp , 24); int j; for(j = 0; j < 24; j++) { if(i & (1 << j)) test[j] = 1; else test[j] = 0; } //printArray(test , 24); bunny24_encrypt(testp , test); if(arrayEqual(testp , crypt , 24) == 0) { printHex(test , 24); return; } //printf("fail key %d \n " , i); } }
int main(int argc, char* argv[]) { int size = 5; Point p(0, 0, 0); bool full = true; int sizeX = 9; int sizeY = 9; int sizeZ = 9; Cube c(size, p, full, sizeX, sizeY, sizeZ); int X = sizeX; int Y = sizeY; int Z = sizeZ; bool ***cmp = new bool**[c.getSizeX()]; for (int x = 0; x < X; ++x) { cmp[x] = new bool *[c.getSizeY()]; for (int y = 0; y < Y; ++y) cmp[x][y] = new bool [c.getSizeZ()]; } /* TEST 1 : Full c ube of size 5 and from the origin (0, 0, 0) */ for (int x = 0; x < X; x++) for (int y = 0; y < Y; y++) for (int z = 0; z < Z; z++) if (x < 5 && y < 5 && z < 5) cmp[x][y][z] = true; else cmp[x][y][z] = false; assert(arrayEqual(c.getStatus(), cmp, X, Y, Z)); /* TEST 2 : Try to go down */ assert(!c.moveDown()); /* TEST 3 : Try to go left */ assert(!c.moveLeft()); /* TEST 4 : Increase size */ assert(c.incrSize()); for (int x = 0; x < c.getSizeX(); ++x) { for (int y = 0; y < c.getSizeY(); ++y) { delete[] cmp[x][y]; } delete[] cmp[x]; } delete[] cmp; DeviceShape ds; ds.copyLedStatus(c); assert(arrayEqual(c.getStatus(), ds.getLedStatus(), X, Y, Z)); std::cout << "Test : PASSED" << std::endl; return EXIT_SUCCESS; }