aboutsummaryrefslogtreecommitdiff
path: root/src/libventi/sha1.c
diff options
context:
space:
mode:
authorDavid du Colombier <0intro@gmail.com>2012-01-21 10:01:20 +0100
committerDavid du Colombier <0intro@gmail.com>2012-01-21 10:01:20 +0100
commit83b247a771a514792b972216e1ad32ae1f3fc316 (patch)
treed2fdc922d7beec267d013b83f04ada86465d6784 /src/libventi/sha1.c
parentf4792e43aef14341bb40f32e8583bd4731e1dcb4 (diff)
downloadplan9port-83b247a771a514792b972216e1ad32ae1f3fc316.tar.gz
plan9port-83b247a771a514792b972216e1ad32ae1f3fc316.tar.bz2
plan9port-83b247a771a514792b972216e1ad32ae1f3fc316.zip
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
Diffstat (limited to 'src/libventi/sha1.c')
-rw-r--r--src/libventi/sha1.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libventi/sha1.c b/src/libventi/sha1.c
new file mode 100644
index 00000000..358f923d
--- /dev/null
+++ b/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;
+}