func sumGeneric(out *[TagSize]byte, msg []byte, key *[32]byte) { … } func newMACGeneric(key *[32]byte) macGeneric { … } type macState … type macGeneric … // Write splits the incoming message into TagSize chunks, and passes them to // update. It buffers incomplete chunks. func (h *macGeneric) Write(p []byte) (int, error) { … } // Sum flushes the last incomplete chunk from the buffer, if any, and generates // the MAC output. It does not modify its state, in order to allow for multiple // calls to Sum, even if no Write is allowed after Sum. func (h *macGeneric) Sum(out *[TagSize]byte) { … } const rMask0 … const rMask1 … // initialize loads the 256-bit key into the two 128-bit secret values r and s. func initialize(key *[32]byte, m *macState) { … } type uint128 … func mul64(a, b uint64) uint128 { … } func add128(a, b uint128) uint128 { … } func shiftRightBy2(a uint128) uint128 { … } // updateGeneric absorbs msg into the state.h accumulator. For each chunk m of // 128 bits of message, it computes // // h₊ = (h + m) * r mod 2¹³⁰ - 5 // // If the msg length is not a multiple of TagSize, it assumes the last // incomplete chunk is the final one. func updateGeneric(state *macState, msg []byte) { … } const maskLow2Bits … const maskNotLow2Bits … // select64 returns x if v == 1 and y if v == 0, in constant time. func select64(v, x, y uint64) uint64 { … } const p0 … const p1 … const p2 … // finalize completes the modular reduction of h and computes // // out = h + s mod 2¹²⁸ func finalize(out *[TagSize]byte, h *[3]uint64, s *[2]uint64) { … }