...

Source file src/vendor/golang.org/x/crypto/poly1305/sum_s390x.go

     1	// Copyright 2018 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.
     4	
     5	// +build s390x,go1.11,!gccgo,!appengine
     6	
     7	package poly1305
     8	
     9	import (
    10		"golang.org/x/sys/cpu"
    11	)
    12	
    13	// poly1305vx is an assembly implementation of Poly1305 that uses vector
    14	// instructions. It must only be called if the vector facility (vx) is
    15	// available.
    16	//go:noescape
    17	func poly1305vx(out *[16]byte, m *byte, mlen uint64, key *[32]byte)
    18	
    19	// poly1305vmsl is an assembly implementation of Poly1305 that uses vector
    20	// instructions, including VMSL. It must only be called if the vector facility (vx) is
    21	// available and if VMSL is supported.
    22	//go:noescape
    23	func poly1305vmsl(out *[16]byte, m *byte, mlen uint64, key *[32]byte)
    24	
    25	// Sum generates an authenticator for m using a one-time key and puts the
    26	// 16-byte result into out. Authenticating two different messages with the same
    27	// key allows an attacker to forge messages at will.
    28	func Sum(out *[16]byte, m []byte, key *[32]byte) {
    29		if cpu.S390X.HasVX {
    30			var mPtr *byte
    31			if len(m) > 0 {
    32				mPtr = &m[0]
    33			}
    34			if cpu.S390X.HasVXE && len(m) > 256 {
    35				poly1305vmsl(out, mPtr, uint64(len(m)), key)
    36			} else {
    37				poly1305vx(out, mPtr, uint64(len(m)), key)
    38			}
    39		} else {
    40			sumGeneric(out, m, key)
    41		}
    42	}
    43	

View as plain text