void vtSha1(uchar sha1[VtScoreSize], uchar *p, int n) { VtSha1 s; vtSha1Init(&s); vtSha1Update(&s, p, n); vtSha1Final(&s, sha1); }
int vtSha1Check(uchar score[VtScoreSize], uchar *p, int n) { VtSha1 s; uchar score2[VtScoreSize]; vtSha1Init(&s); vtSha1Update(&s, p, n); vtSha1Final(&s, score2); if(memcmp(score, score2, VtScoreSize) != 0) { vtSetError("vtSha1Check failed"); return 0; } return 1; }
void packetSha1(Packet *p, uint8_t sha1[VtScoreSize]) { Frag *f; VtSha1 *s; int size; NOTFREE(p); s = vtSha1Alloc(); size = p->size; for(f=p->first; f; f=f->next) { vtSha1Update(s, f->rp, FRAGSIZE(f)); size -= FRAGSIZE(f); } assert(size == 0); vtSha1Final(s, sha1); vtSha1Free(s); }