1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build amd64,!gccgo,!appengine
10 func initialize(state *[7]uint64, key *[32]byte)
13 func update(state *[7]uint64, msg []byte)
16 func finalize(tag *[TagSize]byte, state *[7]uint64)
18 // Sum generates an authenticator for m using a one-time key and puts the
19 // 16-byte result into out. Authenticating two different messages with the same
20 // key allows an attacker to forge messages at will.
21 func Sum(out *[16]byte, m []byte, key *[32]byte) {
27 func newMAC(key *[32]byte) (h mac) {
28 initialize(&h.state, key)
33 state [7]uint64 // := uint64{ h0, h1, h2, r0, r1, pad0, pad1 }
39 func (h *mac) Write(p []byte) (n int, err error) {
42 remaining := TagSize - h.offset
44 h.offset += copy(h.buffer[h.offset:], p)
47 copy(h.buffer[h.offset:], p[:remaining])
50 update(&h.state, h.buffer[:])
52 if nn := len(p) - (len(p) % TagSize); nn > 0 {
53 update(&h.state, p[:nn])
57 h.offset += copy(h.buffer[h.offset:], p)
62 func (h *mac) Sum(out *[16]byte) {
65 update(&state, h.buffer[:h.offset])