diff --git a/.travis.yml b/.travis.yml index c43927f..86a202e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ language: go jobs: include: -# - arch: ppc64le -# go: 1.17.x + - arch: ppc64le + go: 1.17.x - arch: arm64-graviton2 virt: vm os: linux diff --git a/README.md b/README.md index 57f7570..f857e00 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # GM-Standards SM2/SM3/SM4 for Go -[![Build Status](https://app.travis-ci.com/emmansun/gmsm.svg?branch=main)](https://app.travis-ci.com/emmansun/gmsm) CI [![Documentation](https://godoc.org/github.com/emmansun/gmsm?status.svg)](https://godoc.org/github.com/emmansun/gmsm) [![Release](https://img.shields.io/github/release/emmansun/gmsm/all.svg)](https://github.com/emmansun/gmsm/releases) +[![Travis CI](https://app.travis-ci.com/emmansun/gmsm.svg?branch=main)](https://app.travis-ci.com/emmansun/gmsm) +[![Github CI](https://github.com/emmansun/gmsm/actions/workflows/ci.yml/badge.svg)](https://github.com/emmansun/gmsm/actions/workflows/ci.yml) +[![Documentation](https://godoc.org/github.com/emmansun/gmsm?status.svg)](https://godoc.org/github.com/emmansun/gmsm) +[![Release](https://img.shields.io/github/release/emmansun/gmsm/all.svg)](https://github.com/emmansun/gmsm/releases) This is a **SM2 sm2p256v1** implementation whose performance is similar like golang native NIST P256 under **amd64** and **arm64**, for implementation detail, please refer [SM2实现细节](https://github.com/emmansun/gmsm/wiki/SM2%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96). diff --git a/sm2/p256.go b/sm2/p256.go index 5473290..923f46a 100644 --- a/sm2/p256.go +++ b/sm2/p256.go @@ -896,20 +896,14 @@ func p256Invert(out, in *[p256Limbs]uint32) { } // 2^128 - 2^64 p256Mul(&ftmp, &ftmp, &e64) // 2^128 - 1 - for i := 0; i < 32; i++ { + for i := 0; i < 96; i++ { p256Square(&ftmp, &ftmp) - } // 2^160 - 2^32 - - p256Mul(&ftmp, &ftmp, &e32m2) // 2^160 - 2 - - for i := 0; i < 95; i++ { - p256Square(&ftmp, &ftmp) - } // 2^255 - 2^96 + } // 2^224 - 2^96 p256Assign(&ftmp2, &e32m2) - for i := 0; i < 223; i++ { + for i := 0; i < 224; i++ { p256Square(&ftmp2, &ftmp2) - } // 2^255 - 2^224 + } // 2^256 - 2^225 p256Mul(&ftmp, &ftmp, &ftmp2) // 2^256 - 2^224 - 2^96 diff --git a/sm2/p256_asm.go b/sm2/p256_asm.go index 5e4b812..7bdbe5e 100644 --- a/sm2/p256_asm.go +++ b/sm2/p256_asm.go @@ -389,13 +389,11 @@ func p256Inverse(out, in []uint64) { p256Sqr(out, p32, 32) //2^64 - 2^32 p256Mul(p64, out, p32) // 2^64 - 2^0 - p256Sqr(out, p64, 64) //2^128 - 2^64 - p256Mul(out, out, p64) // 2^128 - 2^0 - p256Sqr(out, out, 32) //2^160 - 2^32 - p256Mul(out, out, p32m2) //2^160 - 2^1 - p256Sqr(ptmp, out, 95) //2^255 - 2^96 + p256Sqr(out, p64, 64) //2^128 - 2^64 + p256Mul(out, out, p64) // 2^128 - 2^0 + p256Sqr(ptmp, out, 96) // 2^224 - 2^96 - p256Sqr(out, p32m2, 223) //2^255 - 2^224 + p256Sqr(out, p32m2, 224) //2^256 - 2^225 p256Mul(ptmp, ptmp, out) //2^256 - 2^224 - 2^96 p256Sqr(out, p32, 16) // 2^48 - 2^16