diff options
author | David du Colombier <0intro@gmail.com> | 2019-09-06 11:55:18 -0700 |
---|---|---|
committer | David du Colombier <0intro@gmail.com> | 2019-09-06 11:55:18 -0700 |
commit | cb091e75393b176ccb02c68f0ecfcfbb8bc49376 (patch) | |
tree | b64b51c7bf80fc7839b0ebda21412bcd02d82af2 | |
parent | 63ae9ed53a04fac853693f8d319a4bbc1f6b5f49 (diff) |
sys/src/libventi: implement vtsha1 and vtsha1check functions
-rw-r--r-- | sys/include/venti.h | 4 | ||||
-rw-r--r-- | sys/src/libventi/mkfile | 1 | ||||
-rw-r--r-- | sys/src/libventi/sha1.c | 28 |
3 files changed, 33 insertions, 0 deletions
diff --git a/sys/include/venti.h b/sys/include/venti.h index a75973004..3599c348f 100644 --- a/sys/include/venti.h +++ b/sys/include/venti.h @@ -380,6 +380,10 @@ 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. */ diff --git a/sys/src/libventi/mkfile b/sys/src/libventi/mkfile index 3862b8756..e66964e03 100644 --- a/sys/src/libventi/mkfile +++ b/sys/src/libventi/mkfile @@ -24,6 +24,7 @@ OFILES=\ scorefmt.$O\ send.$O\ server.$O\ + sha1.$O\ srvhello.$O\ strdup.$O\ string.$O\ diff --git a/sys/src/libventi/sha1.c b/sys/src/libventi/sha1.c new file mode 100644 index 000000000..358f923d1 --- /dev/null +++ b/sys/src/libventi/sha1.c @@ -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; +} |