MCPcopy Create free account
hub / github.com/RsyncProject/rsync / driver2

Function driver2

popt/lookup3.c:796–855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794#define MAXPAIR 60
795#define MAXLEN 70
796static void driver2(void)
797{
798 uint8_t qa[MAXLEN+1], qb[MAXLEN+2], *a = &qa[0], *b = &qb[1];
799 uint32_t c[HASHSTATE], d[HASHSTATE], i=0, j=0, k, l, m=0, z;
800 uint32_t e[HASHSTATE],f[HASHSTATE],g[HASHSTATE],h[HASHSTATE];
801 uint32_t x[HASHSTATE],y[HASHSTATE];
802 uint32_t hlen;
803
804 printf("No more than %d trials should ever be needed \n",MAXPAIR/2);
805 for (hlen=0; hlen < MAXLEN; ++hlen) {
806 z=0;
807 for (i=0; i<hlen; ++i) { /*-------------- for each input byte, */
808 for (j=0; j<8; ++j) { /*--------------- for each input bit, */
809 for (m=1; m<8; ++m) { /*---- for several possible initvals, */
810 for (l=0; l<HASHSTATE; ++l)
811 e[l]=f[l]=g[l]=h[l]=x[l]=y[l]=~((uint32_t)0);
812
813 /* check that every output bit is affected by that input bit */
814 for (k=0; k<MAXPAIR; k+=2) {
815 uint32_t finished=1;
816 /* keys have one bit different */
817 for (l=0; l<hlen+1; ++l) {a[l] = b[l] = (uint8_t)0;}
818 /* have a and b be two keys differing in only one bit */
819 a[i] ^= (k<<j);
820 a[i] ^= (k>>(8-j));
821 c[0] = jlu32l(m, a, hlen);
822 b[i] ^= ((k+1)<<j);
823 b[i] ^= ((k+1)>>(8-j));
824 d[0] = jlu32l(m, b, hlen);
825 /* check every bit is 1, 0, set, and not set at least once */
826 for (l=0; l<HASHSTATE; ++l) {
827 e[l] &= (c[l]^d[l]);
828 f[l] &= ~(c[l]^d[l]);
829 g[l] &= c[l];
830 h[l] &= ~c[l];
831 x[l] &= d[l];
832 y[l] &= ~d[l];
833 if (e[l]|f[l]|g[l]|h[l]|x[l]|y[l]) finished=0;
834 }
835 if (finished) break;
836 }
837 if (k>z) z=k;
838 if (k == MAXPAIR) {
839 printf("Some bit didn't change: ");
840 printf("%.8x %.8x %.8x %.8x %.8x %.8x ",
841 e[0],f[0],g[0],h[0],x[0],y[0]);
842 printf("i %u j %u m %u len %u\n", i, j, m, hlen);
843 }
844 if (z == MAXPAIR) goto done;
845 }
846 }
847 }
848 done:
849 if (z < MAXPAIR) {
850 printf("Mix success %2u bytes %2u initvals ",i,m);
851 printf("required %u trials\n", z/2);
852 }
853 }

Callers 1

mainFunction · 0.85

Calls 1

jlu32lFunction · 0.85

Tested by

no test coverage detected