sm

package
v1.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2022 License: Apache-2.0, MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SM2_ECPOINT_SIZE           = 65
	SM2_PRIVKEY_SIZE           = 32
	SM2_SIGNATUREDIGEST_SIZE   = 64
	SM2_HASHDIGEST_SIZE        = 32
	SM2_PUBKEY_LENGTH          = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + SM2_ECPOINT_SIZE
	SM2_PRIVKEY_LENGTH         = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + SM2_PRIVKEY_SIZE
	SM2_SIGNATUREDIGEST_LENGTH = framework.ALGORYTHM_CODE_SIZE + SM2_SIGNATUREDIGEST_SIZE
)
View Source
var (
	SM3_DIGEST_BYTES  = 256 / 8
	SM3_DIGEST_LENGTH = framework.ALGORYTHM_CODE_SIZE + SM3_DIGEST_BYTES
)
View Source
var (
	SM4_KEY_SIZE   = 128 / 8
	SM4_BLOCK_SIZE = 128 / 8
	// SM4-CBC
	SM4_PLAINTEXT_BUFFER_LENGTH  = 256
	SM4_CIPHERTEXT_BUFFER_LENGTH = 256 + 32 + 2
	SM4_SYMMETRICKEY_LENGTH      = framework.ALGORYTHM_CODE_SIZE + framework.KEY_TYPE_BYTES + SM4_KEY_SIZE
)
View Source
var (
	SM2_ALGORITHM = framework.DefineSignature("SM2", true, 2)
	SM3_ALGORITHM = framework.DefineHash("SM3", 3)
	SM4_ALGORITHM = framework.DefineSymmetricEncryption("SM4", 4)
)

Functions

This section is empty.

Types

type SM2CryptoFunction

type SM2CryptoFunction struct {
}

func (SM2CryptoFunction) Decrypt

func (S SM2CryptoFunction) Decrypt(privKey *framework.PrivKey, ciphertext *framework.AsymmetricCiphertext) ([]byte, error)

func (SM2CryptoFunction) Encrypt

func (SM2CryptoFunction) GenerateKeypair

func (S SM2CryptoFunction) GenerateKeypair() (*framework.AsymmetricKeypair, error)

func (SM2CryptoFunction) GenerateKeypairWithSeed

func (S SM2CryptoFunction) GenerateKeypairWithSeed(seed []byte) (keypair *framework.AsymmetricKeypair, err error)

func (SM2CryptoFunction) GetAlgorithm

func (S SM2CryptoFunction) GetAlgorithm() framework.CryptoAlgorithm

func (SM2CryptoFunction) ParseCiphertext

func (S SM2CryptoFunction) ParseCiphertext(ciphertextBytes []byte) (*framework.AsymmetricCiphertext, error)

func (SM2CryptoFunction) ParseDigest

func (S SM2CryptoFunction) ParseDigest(digestBytes []byte) (*framework.SignatureDigest, error)

func (SM2CryptoFunction) ParsePrivKey

func (S SM2CryptoFunction) ParsePrivKey(privKeyBytes []byte) (*framework.PrivKey, error)

func (SM2CryptoFunction) ParsePubKey

func (S SM2CryptoFunction) ParsePubKey(pubKeyBytes []byte) (*framework.PubKey, error)

func (SM2CryptoFunction) RetrieveEncrypedPrivKey added in v1.3.0

func (S SM2CryptoFunction) RetrieveEncrypedPrivKey(privateKey string, pwd []byte) (*framework.PrivKey, error)

func (SM2CryptoFunction) RetrievePrivKey added in v1.3.0

func (S SM2CryptoFunction) RetrievePrivKey(privateKey string) (*framework.PrivKey, error)

func (SM2CryptoFunction) RetrievePubKey

func (S SM2CryptoFunction) RetrievePubKey(privKey *framework.PrivKey) (*framework.PubKey, error)

func (SM2CryptoFunction) RetrievePubKeyFromCA added in v1.3.0

func (S SM2CryptoFunction) RetrievePubKeyFromCA(cert *ca.Certificate) (*framework.PubKey, error)

func (SM2CryptoFunction) Sign

func (S SM2CryptoFunction) Sign(privKey *framework.PrivKey, data []byte) (*framework.SignatureDigest, error)

func (SM2CryptoFunction) SupportCiphertext

func (S SM2CryptoFunction) SupportCiphertext(ciphertextBytes []byte) bool

func (SM2CryptoFunction) SupportDigest

func (S SM2CryptoFunction) SupportDigest(digestBytes []byte) bool

func (SM2CryptoFunction) SupportPrivKey

func (S SM2CryptoFunction) SupportPrivKey(privKeyBytes []byte) bool

func (SM2CryptoFunction) SupportPubKey

func (S SM2CryptoFunction) SupportPubKey(pubKeyBytes []byte) bool

func (SM2CryptoFunction) Verify

func (S SM2CryptoFunction) Verify(pubKey *framework.PubKey, data []byte, digest *framework.SignatureDigest) bool

type SM3HashFunction

type SM3HashFunction struct {
}

func (SM3HashFunction) GetAlgorithm

func (S SM3HashFunction) GetAlgorithm() framework.CryptoAlgorithm

func (SM3HashFunction) Hash

func (S SM3HashFunction) Hash(data []byte) *framework.HashDigest

func (SM3HashFunction) ParseHashDigest

func (S SM3HashFunction) ParseHashDigest(digestBytes []byte) (*framework.HashDigest, error)

func (SM3HashFunction) SupportHashDigest

func (S SM3HashFunction) SupportHashDigest(digestBytes []byte) bool

func (SM3HashFunction) Verify

func (S SM3HashFunction) Verify(digest *framework.HashDigest, data []byte) bool

type SM4EncryptionFunction

type SM4EncryptionFunction struct {
}

func (SM4EncryptionFunction) Decrypt

func (SM4EncryptionFunction) Encrypt

func (SM4EncryptionFunction) GenerateSymmetricKey

func (S SM4EncryptionFunction) GenerateSymmetricKey() *framework.SymmetricKey

func (SM4EncryptionFunction) GetAlgorithm

func (SM4EncryptionFunction) ParseCiphertext

func (S SM4EncryptionFunction) ParseCiphertext(ciphertextBytes []byte) (*framework.SymmetricCiphertext, error)

func (SM4EncryptionFunction) ParseSymmetricKey

func (S SM4EncryptionFunction) ParseSymmetricKey(symmetricKeyBytes []byte) (*framework.SymmetricKey, error)

func (SM4EncryptionFunction) SupportCiphertext

func (S SM4EncryptionFunction) SupportCiphertext(ciphertextBytes []byte) bool

func (SM4EncryptionFunction) SupportSymmetricKey

func (S SM4EncryptionFunction) SupportSymmetricKey(symmetricKeyBytes []byte) bool

type SMCryptoService

type SMCryptoService struct {
	// contains filtered or unexported fields
}

func NewSMCryptoService

func NewSMCryptoService() SMCryptoService

func (SMCryptoService) GetFunctions

func (c SMCryptoService) GetFunctions() []framework.CryptoFunction

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL