diff --git a/sm4/cbc_cipher_asm.go b/sm4/cbc_cipher_asm.go index 7ec8155..5a65b02 100644 --- a/sm4/cbc_cipher_asm.go +++ b/sm4/cbc_cipher_asm.go @@ -10,8 +10,8 @@ import ( "github.com/emmansun/gmsm/internal/xor" ) -// Assert that sm4CipherAsm implements the cbcDecAble interfaces. -var _ cbcDecAble = (*sm4CipherAsm)(nil) +// Assert that sm4CipherAsm implements the cbcEncAble and cbcDecAble interfaces. +var _ cbcEncAble = (*sm4CipherAsm)(nil) var _ cbcDecAble = (*sm4CipherAsm)(nil) const cbcEncrypt = 1 diff --git a/sm4/modes.go b/sm4/modes.go index 93bfdd7..61e58e2 100644 --- a/sm4/modes.go +++ b/sm4/modes.go @@ -2,6 +2,13 @@ package sm4 import "crypto/cipher" +// cbcEncAble is implemented by cipher.Blocks that can provide an optimized +// implementation of CBC encryption through the cipher.BlockMode interface. +// See crypto/cipher/cbc.go. +type cbcEncAble interface { + NewCBCEncrypter(iv []byte) cipher.BlockMode +} + // cbcDecAble is implemented by cipher.Blocks that can provide an optimized // implementation of CBC decryption through the cipher.BlockMode interface. // See crypto/cipher/cbc.go.