nametransform: update comment & simplify tests
The comment still mentioned CBC, which has been removed a long time ago. The test definition can be rewritten using slice literals, saving sume stuttering.
This commit is contained in:
parent
8f5c2a613d
commit
f6b1c680b3
@ -105,8 +105,8 @@ func (n *NameTransform) decryptName(cipherName string, iv []byte) (string, error
|
|||||||
return plain, err
|
return plain, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncryptName encrypts "plainName", returns a base64-encoded "cipherName64".
|
// EncryptName encrypts "plainName", returns a base64-encoded "cipherName64",
|
||||||
// The encryption is either CBC or EME, depending on "useEME".
|
// encrypted using EME (https://github.com/rfjakob/eme).
|
||||||
//
|
//
|
||||||
// This function is exported because in some cases, fusefrontend needs access
|
// This function is exported because in some cases, fusefrontend needs access
|
||||||
// to the full (not hashed) name if longname is used.
|
// to the full (not hashed) name if longname is used.
|
||||||
|
@ -6,10 +6,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPad16(t *testing.T) {
|
func TestPad16(t *testing.T) {
|
||||||
var s [][]byte
|
s := [][]byte{
|
||||||
s = append(s, []byte("foo"))
|
[]byte("foo"),
|
||||||
s = append(s, []byte("12345678901234567"))
|
[]byte("12345678901234567"),
|
||||||
s = append(s, []byte("12345678901234567abcdefg"))
|
[]byte("12345678901234567abcdefg"),
|
||||||
|
}
|
||||||
|
|
||||||
for i := range s {
|
for i := range s {
|
||||||
orig := s[i]
|
orig := s[i]
|
||||||
@ -35,13 +36,14 @@ func TestPad16(t *testing.T) {
|
|||||||
|
|
||||||
// TestUnpad16Garbage - unPad16 should never crash on corrupt or malicious inputs
|
// TestUnpad16Garbage - unPad16 should never crash on corrupt or malicious inputs
|
||||||
func TestUnpad16Garbage(t *testing.T) {
|
func TestUnpad16Garbage(t *testing.T) {
|
||||||
var testCases [][]byte
|
testCases := [][]byte{
|
||||||
testCases = append(testCases, make([]byte, 0))
|
make([]byte, 0),
|
||||||
testCases = append(testCases, make([]byte, 16))
|
make([]byte, 16),
|
||||||
testCases = append(testCases, make([]byte, 1))
|
make([]byte, 1),
|
||||||
testCases = append(testCases, make([]byte, 17))
|
make([]byte, 17),
|
||||||
testCases = append(testCases, bytes.Repeat([]byte{16}, 16))
|
bytes.Repeat([]byte{16}, 16),
|
||||||
testCases = append(testCases, bytes.Repeat([]byte{17}, 16))
|
bytes.Repeat([]byte{17}, 16),
|
||||||
|
}
|
||||||
for _, v := range testCases {
|
for _, v := range testCases {
|
||||||
_, err := unPad16([]byte(v))
|
_, err := unPad16([]byte(v))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user