for(i=0;i<n;i++){
if(i==3) continue; // tolerate this
if(p1[i]!=p2[i]){
- fprintf(stderr,"at pos 0x%02x, got 0x%02x instead of 0x%02x\n",i,p1[i],p2[i]);
+// fprintf(stderr,"at pos 0x%02x, got 0x%02x instead of 0x%02x\n",i,p1[i],p2[i]);
ok=0;
}
}
int i;
struct timeval tvs,tve;
void *keys=get_key_struct();
+ int ok=1;
fprintf(stderr,"FFdecsa 1.0: testing correctness and speed\n");
memcpy(onebuf,test_1_encrypted,188);
cluster[0]=onebuf;cluster[1]=onebuf+188;cluster[2]=NULL;
decrypt_packets(keys,cluster);
- compare(onebuf,test_1_expected,188,0);
+ ok*=compare(onebuf,test_1_expected,188,0);
set_control_words(keys,test_2_key,test_invalid_key);
memcpy(onebuf,test_2_encrypted,188);
cluster[0]=onebuf;cluster[1]=onebuf+188;cluster[2]=NULL;
decrypt_packets(keys,cluster);
- compare(onebuf,test_2_expected,188,0);
+ ok*=compare(onebuf,test_2_expected,188,0);
set_control_words(keys,test_3_key,test_invalid_key);
memcpy(onebuf,test_3_encrypted,188);
cluster[0]=onebuf;cluster[1]=onebuf+188;cluster[2]=NULL;
decrypt_packets(keys,cluster);
- compare(onebuf,test_3_expected,188,0);
+ ok*=compare(onebuf,test_3_expected,188,0);
set_control_words(keys,test_p_10_0_key,test_invalid_key);
memcpy(onebuf,test_p_10_0_encrypted,188);
cluster[0]=onebuf;cluster[1]=onebuf+188;cluster[2]=NULL;
decrypt_packets(keys,cluster);
- compare(onebuf,test_p_10_0_expected,188,0);
+ ok*=compare(onebuf,test_p_10_0_expected,188,0);
set_control_words(keys,test_p_1_6_key,test_invalid_key);
memcpy(onebuf,test_p_1_6_encrypted,188);
cluster[0]=onebuf;cluster[1]=onebuf+188;cluster[2]=NULL;
decrypt_packets(keys,cluster);
- compare(onebuf,test_p_1_6_expected,188,0);
+ ok*=compare(onebuf,test_p_1_6_expected,188,0);
/* begin speed testing */
compare(megabuf+188*(TS_PKTS_FOR_TEST*2/3),test_3_expected,188,0); /* will fail because we used a wrong key */
#endif
// these should be ok
- compare(megabuf,s_expected,188,0);
- compare(megabuf+188*511,s_expected,188,0);
- compare(megabuf+188*512,s_expected,188,0);
- compare(megabuf+188*319,s_expected,188,0);
- compare(megabuf+188*(TS_PKTS_FOR_TEST-1),s_expected,188,0);
+ ok*=compare(megabuf,s_expected,188,0);
+ ok*=compare(megabuf+188*511,s_expected,188,0);
+ ok*=compare(megabuf+188*512,s_expected,188,0);
+ ok*=compare(megabuf+188*319,s_expected,188,0);
+ ok*=compare(megabuf+188*(TS_PKTS_FOR_TEST-1),s_expected,188,0);
for(i=0;i<TS_PKTS_FOR_TEST;i++){
if(!compare(megabuf+188*i,s_expected,188,1)){
fprintf(stderr,"FAILED COMPARISON OF PACKET %10i\n",i);
+ ok=0;
};
}
- return 0;
+ return ok ? 0 : 10;
}