go_chacha20poly1305_openssh/algos_test.go

35 lines
1.1 KiB
Go
Raw Permalink Normal View History

2023-01-10 07:24:12 -05:00
package cc20p1305ssh
import (
`testing`
`golang.org/x/crypto/chacha20`
`golang.org/x/crypto/chacha20poly1305`
)
func TestChaCha20FixedNonceSize(t *testing.T) {
if NonceSize != chacha20.NonceSize {
t.Fatal(
"Mismatched ChaCha20 nonce sizes;\n" +
"\tgolang.org/x/crypto/chacha20 only supports 12 or 24 bytes nonce size,\n\t" +
"the chacha20poly1305@openssh.com variant only supports a nonce of 16 bytes.\n\t" +
"vendor/golang.org/x/crypto/chacha20/chacha_generic.go:NonceSize must be modified.",
)
}
t.Log("The nonce size modification for chacha20 is correct.")
}
func TestChaCha20Poly1305FixedNonceSize(t *testing.T) {
if NonceSize != chacha20poly1305.NonceSize {
t.Fatal(
"Mismatched ChaCha20Poly1305 nonce sizes;\n" +
"\tgolang.org/x/crypto/chacha20poly1305 only supports 12 or 24 bytes nonce size,\n\t" +
"the chacha20poly1305@openssh.com variant only supports a nonce of 16 bytes.\n\t" +
"vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305.go:NonceSize must be modified.",
)
}
t.Log("The nonce size modification for chacha20poly1305 is correct.")
}