mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
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
This commit is contained in:
parent
f4792e43ae
commit
83b247a771
3 changed files with 33 additions and 0 deletions
|
@ -381,6 +381,10 @@ int vtwritepacket(VtConn*, uchar score[VtScoreSize], uint type, Packet *p);
|
||||||
int vtsync(VtConn*);
|
int vtsync(VtConn*);
|
||||||
int vtping(VtConn*);
|
int vtping(VtConn*);
|
||||||
|
|
||||||
|
/* sha1 */
|
||||||
|
void vtsha1(uchar score[VtScoreSize], uchar*, int);
|
||||||
|
int vtsha1check(uchar score[VtScoreSize], uchar*, int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data blocks and block cache.
|
* Data blocks and block cache.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,6 +24,7 @@ OFILES=\
|
||||||
scorefmt.$O\
|
scorefmt.$O\
|
||||||
send.$O\
|
send.$O\
|
||||||
server.$O\
|
server.$O\
|
||||||
|
sha1.$O\
|
||||||
srvhello.$O\
|
srvhello.$O\
|
||||||
strdup.$O\
|
strdup.$O\
|
||||||
string.$O\
|
string.$O\
|
||||||
|
|
28
src/libventi/sha1.c
Normal file
28
src/libventi/sha1.c
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <venti.h>
|
||||||
|
#include <libsec.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Reference in a new issue