mirror of
https://github.com/slackhq/nebula.git
synced 2026-02-14 08:44:24 +01:00
Some checks failed
gofmt / Run gofmt (push) Failing after 3s
smoke-extra / Run extra smoke tests (push) Failing after 2s
smoke / Run multi node smoke test (push) Failing after 3s
Build and test / Build all and test on ubuntu-linux (push) Failing after 2s
Build and test / Build and test on linux with boringcrypto (push) Failing after 3s
Build and test / Build and test on linux with pkcs11 (push) Failing after 2s
Build and test / Build and test on macos-latest (push) Has been cancelled
Build and test / Build and test on windows-latest (push) Has been cancelled
Newly signed P256 based certificates will have their signature clamped to the low-s form. Update CHANGELOG.md
29 lines
565 B
Go
29 lines
565 B
Go
package p256
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
"crypto/elliptic"
|
|
"crypto/rand"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestFlipping(t *testing.T) {
|
|
priv, err1 := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
|
require.NoError(t, err1)
|
|
|
|
out, err := ecdsa.SignASN1(rand.Reader, priv, []byte("big chungus"))
|
|
require.NoError(t, err)
|
|
|
|
r, s, err := parseSignature(out)
|
|
require.NoError(t, err)
|
|
|
|
r, s1, err := swap(r, s)
|
|
require.NoError(t, err)
|
|
r, s2, err := swap(r, s1)
|
|
require.NoError(t, err)
|
|
require.Equal(t, s, s2)
|
|
require.NotEqual(t, s, s1)
|
|
}
|