sm4: add cbcEncAble interface

This commit is contained in:
Sun Yimin 2022-07-26 08:30:24 +08:00 committed by GitHub
parent 206c8075c3
commit 5b075213c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -10,8 +10,8 @@ import (
"github.com/emmansun/gmsm/internal/xor" "github.com/emmansun/gmsm/internal/xor"
) )
// Assert that sm4CipherAsm implements the cbcDecAble interfaces. // Assert that sm4CipherAsm implements the cbcEncAble and cbcDecAble interfaces.
var _ cbcDecAble = (*sm4CipherAsm)(nil) var _ cbcEncAble = (*sm4CipherAsm)(nil)
var _ cbcDecAble = (*sm4CipherAsm)(nil) var _ cbcDecAble = (*sm4CipherAsm)(nil)
const cbcEncrypt = 1 const cbcEncrypt = 1

View File

@ -2,6 +2,13 @@ package sm4
import "crypto/cipher" 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 // cbcDecAble is implemented by cipher.Blocks that can provide an optimized
// implementation of CBC decryption through the cipher.BlockMode interface. // implementation of CBC decryption through the cipher.BlockMode interface.
// See crypto/cipher/cbc.go. // See crypto/cipher/cbc.go.