mirror of
https://github.com/slackhq/nebula.git
synced 2026-08-15 22:57:03 +02:00
cleanup
This commit is contained in:
@@ -168,12 +168,12 @@ func init() {
|
|||||||
// reusePanics reports whether re-encrypting with an already-used counter panics,
|
// reusePanics reports whether re-encrypting with an already-used counter panics,
|
||||||
// as GCMWithXORCounterNonce is expected to.
|
// as GCMWithXORCounterNonce is expected to.
|
||||||
func reusePanics(c noise.Cipher) (panicked bool) {
|
func reusePanics(c noise.Cipher) (panicked bool) {
|
||||||
|
c.Encrypt(nil, 2, nil, nil)
|
||||||
defer func() {
|
defer func() {
|
||||||
if recover() != nil {
|
if recover() != nil {
|
||||||
panicked = true
|
panicked = true
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
c.Encrypt(nil, 2, nil, nil)
|
c.Encrypt(nil, 2, nil, nil)
|
||||||
c.Encrypt(nil, 2, nil, nil)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-7
@@ -16,34 +16,35 @@ func TestNewCipherSuite(t *testing.T) {
|
|||||||
cipher string
|
cipher string
|
||||||
fips140Enforced bool
|
fips140Enforced bool
|
||||||
wantErr string
|
wantErr string
|
||||||
// wantName is a substring expected in the resulting CipherSuite name
|
// wantName is the full expected CipherSuite name (<DH>_<Cipher>_<Hash>),
|
||||||
// (e.g. "P256" or "AESGCM"), only checked when wantErr is empty.
|
// only checked when wantErr is empty. Asserting the whole name makes both
|
||||||
|
// the curve and cipher selection load-bearing.
|
||||||
wantName string
|
wantName string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "curve25519 aesgcm, not enforced",
|
name: "curve25519 aesgcm, not enforced",
|
||||||
curve: cert.Curve_CURVE25519,
|
curve: cert.Curve_CURVE25519,
|
||||||
cipher: "aesgcm",
|
cipher: "aesgcm",
|
||||||
wantName: "AESGCM",
|
wantName: "25519_AESGCM_SHA256",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "curve25519 chachapoly, not enforced",
|
name: "curve25519 chachapoly, not enforced",
|
||||||
curve: cert.Curve_CURVE25519,
|
curve: cert.Curve_CURVE25519,
|
||||||
cipher: "chachapoly",
|
cipher: "chachapoly",
|
||||||
wantName: "ChaChaPoly",
|
wantName: "25519_ChaChaPoly_SHA256",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "p256 aesgcm, not enforced",
|
name: "p256 aesgcm, not enforced",
|
||||||
curve: cert.Curve_P256,
|
curve: cert.Curve_P256,
|
||||||
cipher: "aesgcm",
|
cipher: "aesgcm",
|
||||||
wantName: "P256",
|
wantName: "P256_AESGCM_SHA256",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "p256 aesgcm, enforced is allowed",
|
name: "p256 aesgcm, enforced is allowed",
|
||||||
curve: cert.Curve_P256,
|
curve: cert.Curve_P256,
|
||||||
cipher: "aesgcm",
|
cipher: "aesgcm",
|
||||||
fips140Enforced: true,
|
fips140Enforced: true,
|
||||||
wantName: "P256",
|
wantName: "P256_AESGCM_SHA256",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "curve25519 rejected when enforced",
|
name: "curve25519 rejected when enforced",
|
||||||
@@ -80,7 +81,7 @@ func TestNewCipherSuite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, cs)
|
require.NotNil(t, cs)
|
||||||
assert.Contains(t, string(cs.Name()), tt.wantName)
|
assert.Equal(t, tt.wantName, string(cs.Name()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user