]> Cypherpunks.ru repositories - gohpenc.git/blobdiff - poly1305.go
More secure and faster version
[gohpenc.git] / poly1305.go
diff --git a/poly1305.go b/poly1305.go
new file mode 100644 (file)
index 0000000..3efbeb5
--- /dev/null
@@ -0,0 +1,22 @@
+package main
+
+import (
+       "encoding/binary"
+
+       "golang.org/x/crypto/poly1305"
+)
+
+func writeWithPadding(p *poly1305.MAC, b []byte) {
+       p.Write(b)
+       if rem := len(b) % 16; rem != 0 {
+               var buf [16]byte
+               padLen := 16 - rem
+               p.Write(buf[:padLen])
+       }
+}
+
+func writeUint64(p *poly1305.MAC, n int) {
+       var buf [8]byte
+       binary.LittleEndian.PutUint64(buf[:], uint64(n))
+       p.Write(buf[:])
+}