/* * Setup state for decoding a strip. */ int DECLARE1(FaxPreDecode, TIFF*, tif) { Fax3DecodeState *sp = &fax; sp->b.bit = 0; /* force initial read */ sp->b.data = 0; sp->b.tag = G3_1D; if (sp->b.refline) bset(sp->b.refline, sp->b.rowbytes, sp->b.white ? 0xff : 0x00); /* * If image has EOL codes, they precede each line * of data. We skip over the first one here so that * when we decode rows, we can use an EOL to signal * that less than the expected number of pixels are * present for the scanline. */ if ((fax.options & FAX3_NOEOL) == 0) { skiptoeol(tif, 0); if (is2DEncoding(tif)) /* tag should always be 1D! */ sp->b.tag = nextbit(tif) ? G3_1D : G3_2D; } return (1); }
void format_message2(unsigned char *in, int length, unsigned char out[26]) { int i,j; unsigned char M1[20], M2[20]; unsigned char V[23]; crypto_hash_sha1(M1,in,length / 8); crypto_hash_sha1(M2,M1,160 / 8); /* calcule V sur 182 bits soit 22.75 octets*/ memset(V,33,0); for(i=0;i<20;i++) { V[i] = M1[i]; } V[20] = M2[0]; V[21] = M2[1]; V[22] = (unsigned char) (M2[2] & 0xFC); for(i=0,j=0;i<26;i++) { out[i] = 0; out[i] ^= 64 * nextbit(V,&j); out[i] ^= 32 * nextbit(V,&j); out[i] ^= 16 * nextbit(V,&j); out[i] ^= 8 * nextbit(V,&j); out[i] ^= 4 * nextbit(V,&j); out[i] ^= 2 * nextbit(V,&j); out[i] ^= 1 * nextbit(V,&j); } }
void format_message1(const unsigned char *in, int length, unsigned char out[37], unsigned char delta[11]) { int i,j; unsigned char M1[20], M2[20], W[20]; unsigned char V[33]; crypto_hash_sha1(M1,in,length / 8); crypto_hash_sha1(M2,M1,160 / 8); /* calcule V sur 182 bits soit 22.75 octets*/ memset(V,33,0); for(i=0;i<20;i++) { V[i] = M1[i]; } V[20] = M2[0]; V[21] = M2[1]; V[22] = (unsigned char) (M2[2] & 0xFC); V[22] |= delta[0]; for(i=23;i<33;i++) { V[i] = delta[i-22]; } crypto_hash_sha1(W,V,33); for(i=0,j=0;i<26;i++) { out[i] = 0; out[i] ^= 64 * nextbit(V,&j); out[i] ^= 32 * nextbit(V,&j); out[i] ^= 16 * nextbit(V,&j); out[i] ^= 8 * nextbit(V,&j); out[i] ^= 4 * nextbit(V,&j); out[i] ^= 2 * nextbit(V,&j); out[i] ^= 1 * nextbit(V,&j); } for(i=26,j=0;i<37;i++) { out[i] = 0; out[i] ^= 64 * nextbit(W,&j); out[i] ^= 32 * nextbit(W,&j); out[i] ^= 16 * nextbit(W,&j); out[i] ^= 8 * nextbit(W,&j); out[i] ^= 4 * nextbit(W,&j); out[i] ^= 2 * nextbit(W,&j); out[i] ^= 1 * nextbit(W,&j); } }