mirror of
https://github.com/slackhq/nebula.git
synced 2026-08-15 06:17:03 +02:00
Ensure Curve25519 and ChaChaPoly are not used in fips140 enforced mode
Since these some from golang/x/crypto, there is a change that stdlib fips140.Enforced gate won't catch their usage.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package nebula
|
package nebula
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/fips140"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -241,6 +242,9 @@ func newCipherSuite(curve cert.Curve, pkcs11backed bool, cipher string) (noise.C
|
|||||||
var dhFunc noise.DHFunc
|
var dhFunc noise.DHFunc
|
||||||
switch curve {
|
switch curve {
|
||||||
case cert.Curve_CURVE25519:
|
case cert.Curve_CURVE25519:
|
||||||
|
if fips140.Enforced() {
|
||||||
|
panic("pki: use of Curve25519 is not allowed in FIPS 140-only mode")
|
||||||
|
}
|
||||||
dhFunc = noise.DH25519
|
dhFunc = noise.DH25519
|
||||||
case cert.Curve_P256:
|
case cert.Curve_P256:
|
||||||
if pkcs11backed {
|
if pkcs11backed {
|
||||||
@@ -253,6 +257,9 @@ func newCipherSuite(curve cert.Curve, pkcs11backed bool, cipher string) (noise.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cipher == "chachapoly" {
|
if cipher == "chachapoly" {
|
||||||
|
if fips140.Enforced() {
|
||||||
|
panic("pki: use of ChaChaPoly is not allowed in FIPS 140-only mode")
|
||||||
|
}
|
||||||
return noise.NewCipherSuite(dhFunc, noise.CipherChaChaPoly, noise.HashSHA256), nil
|
return noise.NewCipherSuite(dhFunc, noise.CipherChaChaPoly, noise.HashSHA256), nil
|
||||||
}
|
}
|
||||||
return noise.NewCipherSuite(dhFunc, noiseutil.CipherAESGCM, noise.HashSHA256), nil
|
return noise.NewCipherSuite(dhFunc, noiseutil.CipherAESGCM, noise.HashSHA256), nil
|
||||||
|
|||||||
Reference in New Issue
Block a user