github.com/emmansun/gmsm@v0.29.1/internal/bigmod/nat_noasm.go (about) 1 // Copyright 2023 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 //go:build purego || !(386 || amd64 || arm || arm64 || ppc64 || ppc64le || riscv64 || s390x) 6 7 package bigmod 8 9 import "unsafe" 10 11 // TODO: will use unsafe.Slice directly once upgrade golang sdk to 1.17+ 12 func slice256(ptr *uint) []uint { 13 return (*[256 / _W]uint)(unsafe.Pointer(ptr))[:] 14 } 15 16 func slice1024(ptr *uint) []uint { 17 return (*[1024 / _W]uint)(unsafe.Pointer(ptr))[:] 18 } 19 20 func slice1536(ptr *uint) []uint { 21 return (*[1536 / _W]uint)(unsafe.Pointer(ptr))[:] 22 } 23 24 func slice2048(ptr *uint) []uint { 25 return (*[2048 / _W]uint)(unsafe.Pointer(ptr))[:] 26 } 27 28 func addMulVVW256(z, x *uint, y uint) (c uint) { 29 return addMulVVW(slice256(z), slice256(x), y) 30 } 31 32 func addMulVVW1024(z, x *uint, y uint) (c uint) { 33 return addMulVVW(slice1024(z), slice1024(x), y) 34 } 35 36 func addMulVVW1536(z, x *uint, y uint) (c uint) { 37 return addMulVVW(slice1536(z), slice1536(x), y) 38 } 39 40 func addMulVVW2048(z, x *uint, y uint) (c uint) { 41 return addMulVVW(slice2048(z), slice2048(x), y) 42 }