(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func TestEnDecryptBytes(t *testing.T) { |
| 120 | var key [32]byte |
| 121 | cases := [][]byte{ |
| 122 | {}, |
| 123 | {1, 2, 3, 4, 5}, |
| 124 | } |
| 125 | for _, tc := range cases { |
| 126 | var prev []byte |
| 127 | for i := 0; i < 5; i++ { |
| 128 | enc := encryptBytes(tc, &key) |
| 129 | if bytes.Equal(enc, prev) { |
| 130 | t.Error("encryption should not repeat") |
| 131 | } |
| 132 | prev = enc |
| 133 | if len(tc) > 0 && bytes.Contains(enc, tc) { |
| 134 | t.Error("shouldn't contain plaintext") |
| 135 | } |
| 136 | dec, err := DecryptBytes(enc, &key) |
| 137 | if err != nil { |
| 138 | t.Error(err) |
| 139 | } |
| 140 | if !bytes.Equal(dec, tc) { |
| 141 | t.Error("mismatch after decryption") |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | func encFileInfo() FileInfo { |
| 148 | return FileInfo{ |
nothing calls this directly
no test coverage detected