commit 83b247a771a514792b972216e1ad32ae1f3fc316 from: David du Colombier <0intro@gmail.com> date: Sat Jan 21 09:01:20 2012 UTC libventi: add functions vtsha1 and vtsha1check These functions are equivalent to vtSha1 and vtSha1Check from the old libventi and are particularly used by Fossil. R=rsc http://codereview.appspot.com/5555064 commit - f4792e43aef14341bb40f32e8583bd4731e1dcb4 commit + 83b247a771a514792b972216e1ad32ae1f3fc316 blob - d6b753b82e255d4b53d72c2c3702de0c4872e39b blob + 45c0aab8287efabf9472fb92cbe1e278c364bab8 --- include/venti.h +++ include/venti.h @@ -380,6 +380,10 @@ Packet* vtreadpacket(VtConn*, uchar score[VtScoreSize] int vtwritepacket(VtConn*, uchar score[VtScoreSize], uint type, Packet *p); int vtsync(VtConn*); int vtping(VtConn*); + +/* sha1 */ +void vtsha1(uchar score[VtScoreSize], uchar*, int); +int vtsha1check(uchar score[VtScoreSize], uchar*, int); /* * Data blocks and block cache. blob - 289262ac3283ec0e4fce18840640d66b4bb64a74 blob + 3788185527d5c38a71f63ee7cea10a89e4760689 --- src/libventi/mkfile +++ src/libventi/mkfile @@ -24,6 +24,7 @@ OFILES=\ scorefmt.$O\ send.$O\ server.$O\ + sha1.$O\ srvhello.$O\ strdup.$O\ string.$O\ blob - /dev/null blob + 358f923d1d6fde2aa480dd64f8a09b62b9ef3409 (mode 644) --- /dev/null +++ src/libventi/sha1.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +void +vtsha1(uchar score[VtScoreSize], uchar *p, int n) +{ + DigestState ds; + + memset(&ds, 0, sizeof ds); + sha1(p, n, score, &ds); +} + +int +vtsha1check(uchar score[VtScoreSize], uchar *p, int n) +{ + DigestState ds; + uchar score2[VtScoreSize]; + + memset(&ds, 0, sizeof ds); + sha1(p, n, score2, &ds); + if(memcmp(score, score2, VtScoreSize) != 0) { + werrstr("vtsha1check failed"); + return -1; + } + return 0; +}