Merge pull request #88 from actions/dependabot/go_modules/github.com/cloudflare/circl-1.3.7

Bump github.com/cloudflare/circl from 1.3.3 to 1.3.7
This commit is contained in:
Shawn Hartsell
2024-01-16 17:01:18 -06:00
committed by GitHub
9 changed files with 98 additions and 10 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ require (
dario.cat/mergo v1.0.0 // indirect dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/cloudflare/circl v1.3.3 // indirect github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect
+2 -1
View File
@@ -50,8 +50,9 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
+1 -1
View File
@@ -9,7 +9,7 @@ import (
fp "github.com/cloudflare/circl/math/fp448" fp "github.com/cloudflare/circl/math/fp448"
) )
// twistCurve is -x^2+y^2=1-39082x^2y^2 and is 4-isogeneous to Goldilocks. // twistCurve is -x^2+y^2=1-39082x^2y^2 and is 4-isogenous to Goldilocks.
type twistCurve struct{} type twistCurve struct{}
// Identity returns the identity point. // Identity returns the identity point.
+10 -2
View File
@@ -6,13 +6,21 @@ package sha3
// KeccakF1600 applies the Keccak permutation to a 1600b-wide // KeccakF1600 applies the Keccak permutation to a 1600b-wide
// state represented as a slice of 25 uint64s. // state represented as a slice of 25 uint64s.
// If turbo is true, applies the 12-round variant instead of the
// regular 24-round variant.
// nolint:funlen // nolint:funlen
func KeccakF1600(a *[25]uint64) { func KeccakF1600(a *[25]uint64, turbo bool) {
// Implementation translated from Keccak-inplace.c // Implementation translated from Keccak-inplace.c
// in the keccak reference code. // in the keccak reference code.
var t, bc0, bc1, bc2, bc3, bc4, d0, d1, d2, d3, d4 uint64 var t, bc0, bc1, bc2, bc3, bc4, d0, d1, d2, d3, d4 uint64
for i := 0; i < 24; i += 4 { i := 0
if turbo {
i = 12
}
for ; i < 24; i += 4 {
// Combines the 5 steps in each round into 2 steps. // Combines the 5 steps in each round into 2 steps.
// Unrolls 4 rounds per loop and spreads some steps across rounds. // Unrolls 4 rounds per loop and spreads some steps across rounds.
+8 -3
View File
@@ -51,6 +51,7 @@ type State struct {
// Specific to SHA-3 and SHAKE. // Specific to SHA-3 and SHAKE.
outputLen int // the default output size in bytes outputLen int // the default output size in bytes
state spongeDirection // whether the sponge is absorbing or squeezing state spongeDirection // whether the sponge is absorbing or squeezing
turbo bool // Whether we're using 12 rounds instead of 24
} }
// BlockSize returns the rate of sponge underlying this hash function. // BlockSize returns the rate of sponge underlying this hash function.
@@ -86,11 +87,11 @@ func (d *State) permute() {
xorIn(d, d.buf()) xorIn(d, d.buf())
d.bufe = 0 d.bufe = 0
d.bufo = 0 d.bufo = 0
KeccakF1600(&d.a) KeccakF1600(&d.a, d.turbo)
case spongeSqueezing: case spongeSqueezing:
// If we're squeezing, we need to apply the permutation before // If we're squeezing, we need to apply the permutation before
// copying more output. // copying more output.
KeccakF1600(&d.a) KeccakF1600(&d.a, d.turbo)
d.bufe = d.rate d.bufe = d.rate
d.bufo = 0 d.bufo = 0
copyOut(d, d.buf()) copyOut(d, d.buf())
@@ -136,7 +137,7 @@ func (d *State) Write(p []byte) (written int, err error) {
// The fast path; absorb a full "rate" bytes of input and apply the permutation. // The fast path; absorb a full "rate" bytes of input and apply the permutation.
xorIn(d, p[:d.rate]) xorIn(d, p[:d.rate])
p = p[d.rate:] p = p[d.rate:]
KeccakF1600(&d.a) KeccakF1600(&d.a, d.turbo)
} else { } else {
// The slow path; buffer the input until we can fill the sponge, and then xor it in. // The slow path; buffer the input until we can fill the sponge, and then xor it in.
todo := d.rate - bufl todo := d.rate - bufl
@@ -193,3 +194,7 @@ func (d *State) Sum(in []byte) []byte {
_, _ = dup.Read(hash) _, _ = dup.Read(hash)
return append(in, hash...) return append(in, hash...)
} }
func (d *State) IsAbsorbing() bool {
return d.state == spongeAbsorbing
}
+40
View File
@@ -57,6 +57,17 @@ func NewShake128() State {
return State{rate: rate128, dsbyte: dsbyteShake} return State{rate: rate128, dsbyte: dsbyteShake}
} }
// NewTurboShake128 creates a new TurboSHAKE128 variable-output-length ShakeHash.
// Its generic security strength is 128 bits against all attacks if at
// least 32 bytes of its output are used.
// D is the domain separation byte and must be between 0x01 and 0x7f inclusive.
func NewTurboShake128(D byte) State {
if D == 0 || D > 0x7f {
panic("turboshake: D out of range")
}
return State{rate: rate128, dsbyte: D, turbo: true}
}
// NewShake256 creates a new SHAKE256 variable-output-length ShakeHash. // NewShake256 creates a new SHAKE256 variable-output-length ShakeHash.
// Its generic security strength is 256 bits against all attacks if // Its generic security strength is 256 bits against all attacks if
// at least 64 bytes of its output are used. // at least 64 bytes of its output are used.
@@ -64,6 +75,17 @@ func NewShake256() State {
return State{rate: rate256, dsbyte: dsbyteShake} return State{rate: rate256, dsbyte: dsbyteShake}
} }
// NewTurboShake256 creates a new TurboSHAKE256 variable-output-length ShakeHash.
// Its generic security strength is 256 bits against all attacks if
// at least 64 bytes of its output are used.
// D is the domain separation byte and must be between 0x01 and 0x7f inclusive.
func NewTurboShake256(D byte) State {
if D == 0 || D > 0x7f {
panic("turboshake: D out of range")
}
return State{rate: rate256, dsbyte: D, turbo: true}
}
// ShakeSum128 writes an arbitrary-length digest of data into hash. // ShakeSum128 writes an arbitrary-length digest of data into hash.
func ShakeSum128(hash, data []byte) { func ShakeSum128(hash, data []byte) {
h := NewShake128() h := NewShake128()
@@ -77,3 +99,21 @@ func ShakeSum256(hash, data []byte) {
_, _ = h.Write(data) _, _ = h.Write(data)
_, _ = h.Read(hash) _, _ = h.Read(hash)
} }
// TurboShakeSum128 writes an arbitrary-length digest of data into hash.
func TurboShakeSum128(hash, data []byte, D byte) {
h := NewTurboShake128(D)
_, _ = h.Write(data)
_, _ = h.Read(hash)
}
// TurboShakeSum256 writes an arbitrary-length digest of data into hash.
func TurboShakeSum256(hash, data []byte, D byte) {
h := NewTurboShake256(D)
_, _ = h.Write(data)
_, _ = h.Read(hash)
}
func (d *State) SwitchDS(D byte) {
d.dsbyte = D
}
+34
View File
@@ -0,0 +1,34 @@
package math
import (
"crypto/rand"
"io"
"math/big"
)
// IsSafePrime reports whether p is (probably) a safe prime.
// The prime p=2*q+1 is safe prime if both p and q are primes.
// Note that ProbablyPrime is not suitable for judging primes
// that an adversary may have crafted to fool the test.
func IsSafePrime(p *big.Int) bool {
pdiv2 := new(big.Int).Rsh(p, 1)
return p.ProbablyPrime(20) && pdiv2.ProbablyPrime(20)
}
// SafePrime returns a number of the given bit length that is a safe prime with high probability.
// The number returned p=2*q+1 is a safe prime if both p and q are primes.
// SafePrime will return error for any error returned by rand.Read or if bits < 2.
func SafePrime(random io.Reader, bits int) (*big.Int, error) {
one := big.NewInt(1)
p := new(big.Int)
for {
q, err := rand.Prime(random, bits-1)
if err != nil {
return nil, err
}
p.Lsh(q, 1).Add(p, one)
if p.ProbablyPrime(20) {
return p, nil
}
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
// Package ed25519 implements Ed25519 signature scheme as described in RFC-8032. // Package ed25519 implements Ed25519 signature scheme as described in RFC-8032.
// //
// This package provides optimized implementations of the three signature // This package provides optimized implementations of the three signature
// variants and maintaining closer compatiblilty with crypto/ed25519. // variants and maintaining closer compatibility with crypto/ed25519.
// //
// | Scheme Name | Sign Function | Verification | Context | // | Scheme Name | Sign Function | Verification | Context |
// |-------------|-------------------|---------------|-------------------| // |-------------|-------------------|---------------|-------------------|
Generated Vendored
+1 -1
View File
@@ -28,7 +28,7 @@ github.com/ProtonMail/go-crypto/openpgp/internal/ecc
github.com/ProtonMail/go-crypto/openpgp/internal/encoding github.com/ProtonMail/go-crypto/openpgp/internal/encoding
github.com/ProtonMail/go-crypto/openpgp/packet github.com/ProtonMail/go-crypto/openpgp/packet
github.com/ProtonMail/go-crypto/openpgp/s2k github.com/ProtonMail/go-crypto/openpgp/s2k
# github.com/cloudflare/circl v1.3.3 # github.com/cloudflare/circl v1.3.7
## explicit; go 1.19 ## explicit; go 1.19
github.com/cloudflare/circl/dh/x25519 github.com/cloudflare/circl/dh/x25519
github.com/cloudflare/circl/dh/x448 github.com/cloudflare/circl/dh/x448