File tree 1 file changed +7
-13
lines changed
1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -10,21 +10,10 @@ import (
10
10
"testing"
11
11
12
12
"github.com/stretchr/testify/assert"
13
+ "github.com/unknwon/com" //nolint:depguard
13
14
)
14
15
15
- func TestAESGCMEncrypt (t * testing.T ) {
16
- t .Parallel ()
17
-
18
- key := make ([]byte , aes .BlockSize )
19
- _ , err := rand .Read (key )
20
- assert .NoError (t , err )
21
-
22
- plaintext := []byte ("this will be encrypted" )
23
- _ , err = AESGCMEncrypt (key , plaintext )
24
- assert .NoError (t , err )
25
- }
26
-
27
- func TestAESGCMDecrypt (t * testing.T ) {
16
+ func TestAESGCM (t * testing.T ) {
28
17
t .Parallel ()
29
18
30
19
key := make ([]byte , aes .BlockSize )
@@ -40,4 +29,9 @@ func TestAESGCMDecrypt(t *testing.T) {
40
29
assert .NoError (t , err )
41
30
42
31
assert .Equal (t , plaintext , decrypted )
32
+
33
+ // at the moment, we make sure the result is the same as the legacy package, this assertion can be removed in next round refactoring
34
+ legacy , err := com .AESGCMDecrypt (key , ciphertext )
35
+ assert .NoError (t , err )
36
+ assert .Equal (t , legacy , plaintext )
43
37
}
You can’t perform that action at this time.
0 commit comments