Plan 9 from Bell Labs’s /usr/web/sources/contrib/djc/fossil/libventi-sha1.diff

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


--- /n/sources/plan9/sys/include/venti.h	Sat Sep  1 04:42:21 2007
+++ /sys/include/venti.h	Fri Mar 23 00:00:00 2012
@@ -378,6 +378,10 @@
 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.
  */
--- /n/sources/plan9/sys/src/libventi/mkfile	Sat Sep  1 04:43:35 2007
+++ /sys/src/libventi/mkfile	Fri Mar 23 00:00:00 2012
@@ -24,6 +24,7 @@
 	scorefmt.$O\
 	send.$O\
 	server.$O\
+	sha1.$O\
 	srvhello.$O\
 	strdup.$O\
 	string.$O\
--- /sys/src/libventi/sha1.c	Fri Mar 23 08:50:55 2012
+++ /sys/src/libventi/sha1.c	Fri Mar 23 00:00:00 2012
@@ -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;
+}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.