/* Build the sponge recursively */ void sponge(GLfloat v[8][3], int m) { GLfloat vv[8][3]; static GLfloat scale = 1.0 / 3.0; int i, j, k, l; if(m > 0) { for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) { /* leave holes in the right places */ if (i%2 + j%2 + k%2 < 2) { for (l = 0; l < 8; l++) { vv[l][0] = (v[l][0] + i) * scale; vv[l][1] = (v[l][1] + j) * scale; vv[l][2] = (v[l][2] + k) * scale; } sponge(vv, m - 1); } } } } } else { (cube(v)); /* draw cube at end of recursion */ } }
void genSpongeKAT() { std::cout << "*-- genSpongeKAT() --------------------------------------*\n"; { KeccakF keccakF(1600); //OldDiversifiedKeccakPadding pad(0); MultiRatePadding pad; Sponge sponge(&keccakF, &pad, 1024); genSpongeKAT(sponge, "r1024c576"); } }
int HashSumAndCompare(uint32_t *SHA1KEY, unsigned char *inbuf, size_t inlen) { uint8_t *hash; hash=sponge((uint8_t *)inbuf,inlen); for(int32_t i=0;i<64;i++){ //printf("(%s) if %02x == %02x\n",inbuf,SHA1KEY[i],hash[i]); if (SHA1KEY[i] != hash[i]) return 1==0; } return 0==0; }
/* display callback */ void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(0, 0, 0); glRotatef(rotationAngleRotateX, 0.0, 1.0, 0.0); glRotatef(-rotationAngleRotateY, 1.0, 0.0, 0.0); glBegin(GL_QUADS); sponge(c, n); glEnd(); glPopMatrix(); glPushMatrix(); glLoadIdentity(); glDisable(GL_DEPTH_TEST); //char buf[100]; //print(-3, 3, 0, buf, 300); glEnable(GL_DEPTH_TEST); glPopMatrix(); //glutBitmapCharacter( GLUT_BITMAP_8_BY_13 , n); glFlush(); }
int main() { uint8_t phrase[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; uint8_t* expected = sponge(phrase, 10); }