Hi, 2014-12-16 10:30 GMT+01:00 supraja reddy <supraja0...@gmail.com>: > Hi, > > Attached patch adds some missing spaces in the cast5.c and cast5.h > > Please let me know if any further changes needed.
apart from what Michael already pointed out: > -static void decipher(AVCAST5* cs,uint8_t* dst,const uint8_t* src) > +static void decipher(AVCAST5* cs, uint8_t* dst, const uint8_t* src) > { > - uint32_t f,I,r,l; > - l=AV_RB32(src); > - r=AV_RB32(src+4); > - if (cs->rounds==16) { > - F1(l,r,16); > - F3(r,l,15); > - F2(l,r,14); > - F1(r,l,13); > + uint32_t f, I, r, l; > + l = AV_RB32(src); > + r = AV_RB32(src + 4); > + if (cs->rounds == 16) { > + F1(l, r, 16); > + F3(r, l, 15); > + F2(l, r, 14); > + F1(r, l, 13); > } > - F3(l,r,12); > - F2(r,l,11); > - F1(l,r,10); > - F3(r,l,9); > - F2(l,r,8); > - F1(r,l,7); > - F3(l,r,6); > - F2(r,l,5); > - F1(l,r,4); > - F3(r,l,3); > - F2(l,r,2); > - F1(r,l,1); > - > - AV_WB32(dst,r); > - AV_WB32(dst+4,l); > + F3(l, r, 12); > + F2(r, l, 11); > + F1(l, r, 10); > + F3(r, l, 9); > + F2(l, r, 8); > + F1(r, l, 7); > + F3(l, r, 6); > + F2(r, l, 5); > + F1(l, r, 4); > + F3(r, l, 3); > + F2(l, r, 2); > + F1(r, l, 1); > + You can probably delete the previous blank line, to be consistent > + AV_WB32(dst, r); > + AV_WB32(dst + 4, l); > And this one too. > } > @@ -483,55 +491,55 @@ void av_cast5_crypt(AVCAST5* cs, uint8_t* dst, const > uint8_t* src, int count, in > int main(int argc, char** argv) > { > > - static const uint8_t > Key[3][16]={{0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9a}, > - {0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,0x23,0x45}, > - {0x01,0x23,0x45,0x67,0x12}}; > - static const uint8_t rpt[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; > - static const uint8_t > rct[3][8]={{0x23,0x8b,0x4f,0xe5,0x84,0x7e,0x44,0xb2}, > - {0xeb,0x6a,0x71,0x1a,0x2c,0x02,0x27,0x1b}, > - {0x7a,0xc8,0x16,0xd1,0x6e,0x9b,0x30,0x2e}}; > - static const uint8_t > rct2[2][16]={{0xee,0xa9,0xd0,0xa2,0x49,0xfd,0x3b,0xa6,0xb3,0x43,0x6f,0xb8,0x9d,0x6d,0xca,0x92}, > - > {0xb2,0xc9,0x5e,0xb0,0x0c,0x31,0xad,0x71,0x80,0xac,0x05,0xb8,0xe8,0x3d,0x69,0x6e}}; > + static const uint8_t Key[3][16] = {{0x01, 0x23, 0x45, 0x67, 0x12, 0x34, > 0x56, 0x78, 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a}, Minor nit: maybe add a \n after the first {, so that each 16 bytes vector is in its own line > + {0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, 0x23, 0x45}, > + {0x01, 0x23, 0x45, 0x67, 0x12}}; and add another \n before }; . The same for the other vectors. > + static const uint8_t rpt[8] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, > 0xef}; > + static const uint8_t rct[3][8] = {{0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, > 0x44, 0xb2}, > + {0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b}, > + {0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e}}; > + static const uint8_t rct2[2][16] = {{0xee, 0xa9, 0xd0, 0xa2, 0x49, 0xfd, > 0x3b, 0xa6, 0xb3, 0x43, 0x6f, 0xb8, 0x9d, 0x6d, 0xca, 0x92}, > + {0xb2, 0xc9, 0x5e, 0xb0, 0x0c, 0x31, 0xad, 0x71, 0x80, 0xac, 0x05, > 0xb8, 0xe8, 0x3d, 0x69, 0x6e}}; > static uint8_t rpt2[2][16]; > - int i,j,err=0; > - static int key_bits[3]={128,80,40}; > + int i, j, err = 0; > + static int key_bits[3] = {128, 80, 40}; > uint8_t temp[8]; > AVCAST5 *cs; > - cs=av_cast5_alloc(); > + cs = av_cast5_alloc(); > if (!cs) > return 1; > - for (j=0;j<3;j++){ > - > - av_cast5_init(cs,Key[j],key_bits[j]); > - av_cast5_crypt(cs,temp,rpt,1,0); > - for (i=0;i<8;i++){ > - if (rct[j][i]!=temp[i]){ > - av_log(NULL,AV_LOG_ERROR,"%d %02x > %02x\n",i,rct[j][i],temp[i]); > - err=1; > + for (j = 0; j < 3; j++){ > + > + av_cast5_init(cs, Key[j], key_bits[j]); > + av_cast5_crypt(cs, temp, rpt, 1, 0); > + for (i = 0;i < 8; i++){ > + if (rct[j][i] != temp[i]){ > + av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct[j][i], > temp[i]); > + err = 1; > } > } > > - av_cast5_crypt(cs,temp,rct[j],1,1); > - for (i=0;i<8;i++){ > - if (rpt[i]!=temp[i]){ > - av_log(NULL,AV_LOG_ERROR,"%d %02x %02x\n",i,rpt[i],temp[i]); > - err=1; > + av_cast5_crypt(cs, temp, rct[j], 1, 1); > + for (i =0; i < 8; i++) { Missing space between = and 0. > + if (rpt[i] != temp[i]) { > + av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rpt[i], > temp[i]); > + err = 1; > } > } > } > - memcpy(rpt2[0],Key[0],16); > - memcpy(rpt2[1],Key[0],16); > - for (i=0;i<1000000;i++){ > - av_cast5_init(cs,rpt2[1],128); > - av_cast5_crypt(cs,rpt2[0],rpt2[0],2,0); > - av_cast5_init(cs,rpt2[0],128); > - av_cast5_crypt(cs,rpt2[1],rpt2[1],2,0); > + memcpy(rpt2[0], Key[0], 16); > + memcpy(rpt2[1], Key[0], 16); > + for (i = 0; i < 1000000; i++){ > + av_cast5_init(cs, rpt2[1], 128); > + av_cast5_crypt(cs, rpt2[0], rpt2[0], 2, 0); > + av_cast5_init(cs, rpt2[0], 128); > + av_cast5_crypt(cs, rpt2[1], rpt2[1], 2, 0); > } > - for (j=0;j<2;j++){ > - for (i=0;i<16;i++){ > - if (rct2[j][i]!=rpt2[j][i]){ > - av_log(NULL,AV_LOG_ERROR,"%d %02x > %02x\n",i,rct2[j][i],rpt2[j][i]); > - err=1; > + for (j = 0; j < 2; j++) { > + for (i = 0; i < 16; i++) { > + if (rct2[j][i] != rpt2[j][i]) { > + av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct2[j][i], > rpt2[j][i]); > + err = 1; > } > } > } The rest looks good to me, thanks. Giorgio Vazzana _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel