X-Git-Url: http://www.git.cypherpunks.ru/?p=gohpenc.git;a=blobdiff_plain;f=poly1305.go;fp=poly1305.go;h=3efbeb52748b379e123365b20c9c42be7552aac4;hp=0000000000000000000000000000000000000000;hb=d863cee82aad34900144198abf740bb7f75a4642;hpb=43162227c8405de5a2d835ee306459993ff0ba6d diff --git a/poly1305.go b/poly1305.go new file mode 100644 index 0000000..3efbeb5 --- /dev/null +++ b/poly1305.go @@ -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[:]) +}