// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build gc && !purego

package poly1305

//go:noescape
func update( *macState,  []byte)

// mac is a wrapper for macGeneric that redirects calls that would have gone to
// updateGeneric to update.
//
// Its Write and Sum methods are otherwise identical to the macGeneric ones, but
// using function pointers would carry a major performance cost.
type mac struct{ macGeneric }

func ( *mac) ( []byte) (int, error) {
	 := len()
	if .offset > 0 {
		 := copy(.buffer[.offset:], )
		if .offset+ < TagSize {
			.offset += 
			return , nil
		}
		 = [:]
		.offset = 0
		update(&.macState, .buffer[:])
	}
	if  := len() - (len() % TagSize);  > 0 {
		update(&.macState, [:])
		 = [:]
	}
	if len() > 0 {
		.offset += copy(.buffer[.offset:], )
	}
	return , nil
}

func ( *mac) ( *[16]byte) {
	 := .macState
	if .offset > 0 {
		update(&, .buffer[:.offset])
	}
	finalize(, &.h, &.s)
}