@@ -28,6 +28,7 @@ func EncryptECB(key cryptox.Bytes, padding cryptox.Padding, bs cryptox.Bytes) (c
2828 return nil , err
2929 }
3030
31+ bs = bs .Clone ()
3132 src := padding .Padding (bs , blockSize )
3233 dst := src .Clone ()
3334
@@ -80,6 +81,7 @@ func EncryptCBC(key cryptox.Bytes, iv cryptox.Bytes, padding cryptox.Padding, bs
8081 return nil , err
8182 }
8283
84+ bs = bs .Clone ()
8385 src := padding .Padding (bs , blockSize )
8486 dst := src .Clone ()
8587
@@ -106,6 +108,7 @@ func EncryptCFB(key cryptox.Bytes, iv cryptox.Bytes, padding cryptox.Padding, bs
106108 return nil , err
107109 }
108110
111+ bs = bs .Clone ()
109112 src := padding .Padding (bs , blockSize )
110113 dst := src .Clone ()
111114
@@ -132,6 +135,7 @@ func EncryptOFB(key cryptox.Bytes, iv cryptox.Bytes, padding cryptox.Padding, bs
132135 return nil , err
133136 }
134137
138+ bs = bs .Clone ()
135139 src := padding .Padding (bs , blockSize )
136140 dst := src .Clone ()
137141
@@ -158,6 +162,7 @@ func EncryptCTR(key cryptox.Bytes, iv cryptox.Bytes, padding cryptox.Padding, bs
158162 return nil , err
159163 }
160164
165+ bs = bs .Clone ()
161166 src := padding .Padding (bs , blockSize )
162167 dst := src .Clone ()
163168
@@ -179,7 +184,6 @@ func DecryptCTR(key cryptox.Bytes, iv cryptox.Bytes, padding cryptox.Padding, bs
179184}
180185
181186// EncryptGCM uses gcm mode to encrypt bs.
182- // NOTICE: This is an experimental function, and we haven't tested it enough yet, so be careful when using it.
183187func EncryptGCM (key cryptox.Bytes , nonce cryptox.Bytes , additional cryptox.Bytes , bs cryptox.Bytes ) (cryptox.Bytes , error ) {
184188 block , _ , err := newBlock (key )
185189 if err != nil {
@@ -199,7 +203,6 @@ func EncryptGCM(key cryptox.Bytes, nonce cryptox.Bytes, additional cryptox.Bytes
199203}
200204
201205// DecryptGCM uses gcm mode to decrypt bs.
202- // NOTICE: This is an experimental function, and we haven't tested it enough yet, so be careful when using it.
203206func DecryptGCM (key cryptox.Bytes , nonce cryptox.Bytes , additional cryptox.Bytes , bs cryptox.Bytes ) (cryptox.Bytes , error ) {
204207 block , _ , err := newBlock (key )
205208 if err != nil {
0 commit comments