Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- func CMessage(data []byte) (dataPtr C.SGD_UCHAR_PRT)
- func ConvertToECCCipherC(encData ECCCipher) (pucEncData C.ECCCipher)
- func ConvertToECCSignatureC(signature ECCSignature) (pSignature C.ECCSignature)
- func ConvertToECCrefPrivateKeyC(privateKey ECCrefPrivateKey) (pucPrivateKey C.ECCrefPrivateKey)
- func ConvertToECCrefPublicKeyC(publicKey ECCrefPublicKey) (pucPublicKey C.ECCrefPublicKey)
- func ExportECDSAPublicKey(c *Ctx, s SessionHandle, keyIndex uint) (*sm2.PublicKey, error)
- func GenerateRandom(c *Ctx, s SessionHandle, length int) ([]byte, error)
- func PKCS5Padding(data []byte, blockSize int) []byte
- func PKCS5UnPadding(data []byte) ([]byte, error)
- func SM2Dec(c *Ctx, s SessionHandle, keyIndex uint, keyPwd, cipherText []byte) ([]byte, error)
- func SM2Enc(c *Ctx, s SessionHandle, keyIndex uint, keyPwd, plainText []byte) ([]byte, error)
- func SM2Sign(c *Ctx, s SessionHandle, keyIndex uint, keyPwd, origin []byte) (sign []byte, err error)
- func SM2Verify(c *Ctx, s SessionHandle, keyIndex uint, origin, sign []byte) (bool, error)
- func SM3HMac(c *Ctx, s SessionHandle, keyIndex uint, origin []byte) (mac []byte, err error)
- func SM3Hash(c *Ctx, s SessionHandle, origin []byte) ([]byte, error)
- func SM4Decrypt(c *Ctx, s SessionHandle, keyIndex uint, ciphertext []byte, blockMode string) ([]byte, error)
- func SM4Encrypt(c *Ctx, s SessionHandle, keyIndex uint, origin []byte, blockMode string) ([]byte, error)
- func SM4GenKey(c *Ctx, s SessionHandle, keySize uint) ([]byte, error)
- func ToError(e C.SGD_RV) error
- type Ctx
- func (c *Ctx) Destroy()
- func (c *Ctx) SDFCalculateMAC(sessionHandle SessionHandle, hKeyHandle SessionHandle, uiAlgID uint, iv []byte, ...) (mac []byte, macLength uint, err error)
- func (c *Ctx) SDFCloseDevice(deviceHandle SessionHandle) (err error)
- func (c *Ctx) SDFCloseSession(sessionHandle SessionHandle) (err error)
- func (c *Ctx) SDFDecrypt(sessionHandle SessionHandle, hKeyHandle SessionHandle, uiAlgID uint, iv []byte, ...) (data []byte, dataLength uint, err error)
- func (c *Ctx) SDFDestroyKey(sessionHandle SessionHandle, hKeyHandle SessionHandle) (err error)
- func (c *Ctx) SDFEncrypt(sessionHandle SessionHandle, keyHandle SessionHandle, algID uint, iv []byte, ...) (encData []byte, encDataLength uint, err error)
- func (c *Ctx) SDFExportEncPublicKey_ECC(sessionHandle SessionHandle, uiKeyIndex uint) (publicKey ECCrefPublicKey, err error)
- func (c *Ctx) SDFExportSignPublicKey_ECC(sessionHandle SessionHandle, uiKeyIndex uint) (publicKey ECCrefPublicKey, err error)
- func (c *Ctx) SDFExternalDecrypt_ECC(sessionHandle SessionHandle, uiAlgID uint, privateKey ECCrefPrivateKey, ...) (data []byte, dataLength uint, err error)
- func (c *Ctx) SDFExternalEncrypt_ECC(sessionHandle SessionHandle, uiAlgID uint, publicKey ECCrefPublicKey, ...) (encData ECCCipher, err error)
- func (c *Ctx) SDFExternalSign_ECC(sessionHandle SessionHandle, uiAlgID uint, privateKey ECCrefPrivateKey, ...) (signature ECCSignature, err error)
- func (c *Ctx) SDFExternalVerify_ECC(sessionHandle SessionHandle, uiAlgID uint, publicKey ECCrefPublicKey, ...) (err error)
- func (c *Ctx) SDFGenerateKeyPair_ECC(sessionHandle SessionHandle, uiAlgID uint, uiKeyBits uint) (publicKey ECCrefPublicKey, privateKey ECCrefPrivateKey, err error)
- func (c *Ctx) SDFGenerateRandom(sessionHandle SessionHandle, length uint) (randomData []byte, err error)
- func (c *Ctx) SDFGetDeviceInfo(sessionHandle SessionHandle) (deviceInfo DeviceInfo, err error)
- func (c *Ctx) SDFGetPrivateKeyAccessRight(sessionHandle SessionHandle, keyIndex uint, password []byte, pwdLength uint) (err error)
- func (c *Ctx) SDFGetSymmKeyHandle(sessionHandle SessionHandle, uiKeyIndex uint) (keyHandle SessionHandle, err error)
- func (c *Ctx) SDFHMAC(sessionHandle SessionHandle, hKeyHandle SessionHandle, uiAlgID uint, ...) (mac []byte, macLength uint, err error)
- func (c *Ctx) SDFHashFinal(sessionHandle SessionHandle) (hash []byte, hashLength uint, err error)
- func (c *Ctx) SDFHashInit(sessionHandle SessionHandle, uiAlgID uint, pucID []byte, uiIDLength uint) (publicKey ECCrefPublicKey, err error)
- func (c *Ctx) SDFHashUpdate(sessionHandle SessionHandle, pucData []byte, uiDataLength uint) (err error)
- func (c *Ctx) SDFImportKey(sessionHandle SessionHandle, pucKey []byte, uiKeyLength uint) (keyHandle SessionHandle, err error)
- func (c *Ctx) SDFInternalDecrypt_ECC(sessionHandle SessionHandle, uiISKIndex uint, uiAlgID uint, encData ECCCipher) (data []byte, dataLength uint, err error)
- func (c *Ctx) SDFInternalEncrypt_ECC(sessionHandle SessionHandle, uiISKIndex uint, uiAlgID uint, pucData []byte, ...) (encData ECCCipher, err error)
- func (c *Ctx) SDFInternalSign_ECC(sessionHandle SessionHandle, uiISKIndex uint, pucData []byte, ...) (signature ECCSignature, err error)
- func (c *Ctx) SDFInternalVerify_ECC(sessionHandle SessionHandle, uiISKIndex uint, pucData []byte, ...) (err error)
- func (c *Ctx) SDFOpenDevice() (deviceHandle SessionHandle, err error)
- func (c *Ctx) SDFOpenSession(deviceHandle SessionHandle) (SessionHandle, error)
- func (c *Ctx) SDFReleasePrivateKeyAccessRight(sessionHandle SessionHandle, keyIndex uint) (err error)
- type DeviceInfo
- type DeviceRunStatus
- type ECCCipher
- type ECCSignature
- type ECCrefPrivateKey
- type ECCrefPublicKey
- type SessionHandle
Constants ¶
const ( SDR_OK = 0x00000000 SDR_BASE = 0x01000000 )
const ( SGD_TRUE = 0x00000001 SGD_FALSE = 0x00000000 SGD_SM1_ECB = 0x00000101 SGD_SM1_CBC = 0x00000102 SGD_SM1_CFB = 0x00000104 SGD_SM1_OFB = 0x00000108 SGD_SM1_MAC = 0x00000110 SGD_SM1_CTR = 0x00000120 SGD_SSF33_ECB = 0x00000201 SGD_SSF33_CBC = 0x00000202 SGD_SSF33_CFB = 0x00000204 SGD_SSF33_OFB = 0x00000208 SGD_SSF33_MAC = 0x00000210 SGD_SSF33_CTR = 0x00000220 SGD_SMS4_ECB = 0x00000401 SGD_SMS4_CBC = 0x00000402 SGD_SMS4_CFB = 0x00000404 SGD_SMS4_OFB = 0x00000408 SGD_SMS4_MAC = 0x00000410 SGD_SMS4_CTR = 0x00000420 SGD_3DES_ECB = 0x00000801 SGD_3DES_CBC = 0x00000802 SGD_3DES_CFB = 0x00000804 SGD_3DES_OFB = 0x00000808 SGD_3DES_MAC = 0x00000810 SGD_3DES_CTR = 0x00000820 SGD_AES_ECB = 0x00002001 SGD_AES_CBC = 0x00002002 SGD_AES_CFB = 0x00002004 SGD_AES_OFB = 0x00002008 SGD_AES_MAC = 0x00002010 SGD_AES_CTR = 0x00002020 SGD_RSA = 0x00010000 SGD_RSA_SIGN = 0x00010100 SGD_RSA_ENC = 0x00010200 SGD_SM2 = 0x00020100 SGD_SM2_1 = 0x00020200 SGD_SM2_2 = 0x00020400 SGD_SM2_3 = 0x00020800 SGD_SM9 = 0x00100000 SGD_SM9_1 = 0x00100100 SGD_SM9_2 = 0x00100200 SGD_SM9_3 = 0x00100400 SGD_SM9_4 = 0x00100800 SGD_SM3 = 0x00000001 SGD_SHA1 = 0x00000002 SGD_SHA256 = 0x00000004 SGD_SHA512 = 0x00000008 SGD_SHA384 = 0x00000010 SGD_SHA224 = 0x00000020 SGD_MD5 = 0x00000080 )
const (
BLOCK_SIZE = 16
)
const (
CRYPTO_DEFAULT_UID = "1234567812345678"
)
Variables ¶
This section is empty.
Functions ¶
func CMessage ¶
func CMessage(data []byte) (dataPtr C.SGD_UCHAR_PRT)
func ConvertToECCCipherC ¶
func ConvertToECCSignatureC ¶
func ConvertToECCSignatureC(signature ECCSignature) (pSignature C.ECCSignature)
func ConvertToECCrefPrivateKeyC ¶
func ConvertToECCrefPrivateKeyC(privateKey ECCrefPrivateKey) (pucPrivateKey C.ECCrefPrivateKey)
func ConvertToECCrefPublicKeyC ¶
func ConvertToECCrefPublicKeyC(publicKey ECCrefPublicKey) (pucPublicKey C.ECCrefPublicKey)
func ExportECDSAPublicKey ¶
ExportECDSAPublicKey export a ecc publickey
func GenerateRandom ¶
func GenerateRandom(c *Ctx, s SessionHandle, length int) ([]byte, error)
GenerateRandom return a random bytes with fixed length
func PKCS5Padding ¶
PKCS5Padding padding with pkcs5
func PKCS5UnPadding ¶
PKCS5UnPadding un padding with pkcs5
func SM4Decrypt ¶
func SM4Encrypt ¶
Types ¶
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
func (*Ctx) SDFCalculateMAC ¶
func (c *Ctx) SDFCalculateMAC(sessionHandle SessionHandle, hKeyHandle SessionHandle, uiAlgID uint, iv []byte, data []byte, dataLength uint) (mac []byte, macLength uint, err error)
func (*Ctx) SDFCloseDevice ¶
func (c *Ctx) SDFCloseDevice(deviceHandle SessionHandle) (err error)
SDFCloseDevice 2.关闭设备
func (*Ctx) SDFCloseSession ¶
func (c *Ctx) SDFCloseSession(sessionHandle SessionHandle) (err error)
SDFCloseSession 4.关闭会话
func (*Ctx) SDFDecrypt ¶
func (c *Ctx) SDFDecrypt(sessionHandle SessionHandle, hKeyHandle SessionHandle, uiAlgID uint, iv []byte, encData []byte, encDataLength uint) (data []byte, dataLength uint, err error)
SDFDecrypt 41.对称解密
func (*Ctx) SDFDestroyKey ¶
func (c *Ctx) SDFDestroyKey(sessionHandle SessionHandle, hKeyHandle SessionHandle) (err error)
SDFDestroyKey 29.销毁会话密钥
func (*Ctx) SDFEncrypt ¶
func (c *Ctx) SDFEncrypt(sessionHandle SessionHandle, keyHandle SessionHandle, algID uint, iv []byte, data []byte, dataLength uint) (encData []byte, encDataLength uint, err error)
SDFEncrypt 40.对称加密
func (*Ctx) SDFExportEncPublicKey_ECC ¶
func (c *Ctx) SDFExportEncPublicKey_ECC(sessionHandle SessionHandle, uiKeyIndex uint) (publicKey ECCrefPublicKey, err error)
SDFExportEncPublicKey_ECC 17.导出 ECC加密公钥
func (*Ctx) SDFExportSignPublicKey_ECC ¶
func (c *Ctx) SDFExportSignPublicKey_ECC(sessionHandle SessionHandle, uiKeyIndex uint) (publicKey ECCrefPublicKey, err error)
SDFExportSignPublicKey_ECC 16.导出 ECC签名公钥
func (*Ctx) SDFExternalDecrypt_ECC ¶
func (c *Ctx) SDFExternalDecrypt_ECC(sessionHandle SessionHandle, uiAlgID uint, privateKey ECCrefPrivateKey, encData ECCCipher) (data []byte, dataLength uint, err error)
SDFExternalDecrypt_ECC 39.外部密钥 ECC解密
func (*Ctx) SDFExternalEncrypt_ECC ¶
func (c *Ctx) SDFExternalEncrypt_ECC(sessionHandle SessionHandle, uiAlgID uint, publicKey ECCrefPublicKey, data []byte, dataLength uint) (encData ECCCipher, err error)
SDFExternalEncrypt_ECC 38.外部密钥 ECC加密
func (*Ctx) SDFExternalSign_ECC ¶
func (c *Ctx) SDFExternalSign_ECC(sessionHandle SessionHandle, uiAlgID uint, privateKey ECCrefPrivateKey, pucData []byte, uiDataLength uint) (signature ECCSignature, err error)
SDFExternalSign_ECC 34. 外部密钥ECC签名
func (*Ctx) SDFExternalVerify_ECC ¶
func (c *Ctx) SDFExternalVerify_ECC(sessionHandle SessionHandle, uiAlgID uint, publicKey ECCrefPublicKey, inputData []byte, uiInputLength uint, signature ECCSignature) (err error)
SDFExternalVerify_ECC 35.外部密钥 ECC验证
func (*Ctx) SDFGenerateKeyPair_ECC ¶
func (c *Ctx) SDFGenerateKeyPair_ECC(sessionHandle SessionHandle, uiAlgID uint, uiKeyBits uint) (publicKey ECCrefPublicKey, privateKey ECCrefPrivateKey, err error)
SDFGenerateKeyPair_ECC 18.产生 ECC非对称密钥对并输出
func (*Ctx) SDFGenerateRandom ¶
func (c *Ctx) SDFGenerateRandom(sessionHandle SessionHandle, length uint) (randomData []byte, err error)
SDFGenerateRandom 6.产生随机数
func (*Ctx) SDFGetDeviceInfo ¶
func (c *Ctx) SDFGetDeviceInfo(sessionHandle SessionHandle) (deviceInfo DeviceInfo, err error)
SDFGetDeviceInfo 5.获取设备信息
func (*Ctx) SDFGetPrivateKeyAccessRight ¶
func (c *Ctx) SDFGetPrivateKeyAccessRight(sessionHandle SessionHandle, keyIndex uint, password []byte, pwdLength uint) (err error)
SDFGetPrivateKeyAccessRight 7.获取私钥使用权限
func (*Ctx) SDFGetSymmKeyHandle ¶
func (c *Ctx) SDFGetSymmKeyHandle(sessionHandle SessionHandle, uiKeyIndex uint) (keyHandle SessionHandle, err error)
SDFGetSymmKeyHandle 50.
func (*Ctx) SDFHMAC ¶
func (c *Ctx) SDFHMAC(sessionHandle SessionHandle, hKeyHandle SessionHandle, uiAlgID uint, data []byte, dataLength uint) (mac []byte, macLength uint, err error)
HMAC SDFHMAC used to calculate HMAC-SM3
func (*Ctx) SDFHashFinal ¶
func (c *Ctx) SDFHashFinal(sessionHandle SessionHandle) (hash []byte, hashLength uint, err error)
SDFHashFinal 45
func (*Ctx) SDFHashInit ¶
func (c *Ctx) SDFHashInit(sessionHandle SessionHandle, uiAlgID uint, pucID []byte, uiIDLength uint) (publicKey ECCrefPublicKey, err error)
SDFHashInit 43
func (*Ctx) SDFHashUpdate ¶
func (c *Ctx) SDFHashUpdate(sessionHandle SessionHandle, pucData []byte, uiDataLength uint) (err error)
SDFHashUpdate 44
func (*Ctx) SDFImportKey ¶
func (c *Ctx) SDFImportKey(sessionHandle SessionHandle, pucKey []byte, uiKeyLength uint) (keyHandle SessionHandle, err error)
SDFImportKey 28.导入明文会话密钥
func (*Ctx) SDFInternalDecrypt_ECC ¶
func (c *Ctx) SDFInternalDecrypt_ECC(sessionHandle SessionHandle, uiISKIndex uint, uiAlgID uint, encData ECCCipher) (data []byte, dataLength uint, err error)
SDFInternalDecrypt_ECC 52. ECC方式的解密
func (*Ctx) SDFInternalEncrypt_ECC ¶
func (c *Ctx) SDFInternalEncrypt_ECC(sessionHandle SessionHandle, uiISKIndex uint, uiAlgID uint, pucData []byte, uiDataLength uint) (encData ECCCipher, err error)
SDFInternalEncrypt_ECC 51. ECC方式的加密
func (*Ctx) SDFInternalSign_ECC ¶
func (c *Ctx) SDFInternalSign_ECC(sessionHandle SessionHandle, uiISKIndex uint, pucData []byte, uiDataLength uint) (signature ECCSignature, err error)
SDFInternalSign_ECC 36.内部密钥 ECC签名
func (*Ctx) SDFInternalVerify_ECC ¶
func (c *Ctx) SDFInternalVerify_ECC(sessionHandle SessionHandle, uiISKIndex uint, pucData []byte, uiDataLength uint, signature ECCSignature) (err error)
SDFInternalVerify_ECC 37.内部密钥 ECC验证
func (*Ctx) SDFOpenDevice ¶
func (c *Ctx) SDFOpenDevice() (deviceHandle SessionHandle, err error)
SDFOpenDevice 1.打开设备
func (*Ctx) SDFOpenSession ¶
func (c *Ctx) SDFOpenSession(deviceHandle SessionHandle) (SessionHandle, error)
SDFOpenSession 3.创建会话
func (*Ctx) SDFReleasePrivateKeyAccessRight ¶
func (c *Ctx) SDFReleasePrivateKeyAccessRight(sessionHandle SessionHandle, keyIndex uint) (err error)
SDFReleasePrivateKeyAccessRight 8.释放私钥使用权限
type DeviceInfo ¶
type DeviceInfo struct { IssuerName string DeviceName string DeviceSerial string DeviceVersion uint StandardVersion uint AsymAlgAbility [2]uint SymAlgAbility uint HashAlgAbility uint BufferSize uint }
DeviceInfo sdf device info
func ConvertToDeviceInfoGo ¶
func ConvertToDeviceInfoGo(deviceInfo1 C.DEVICEINFO) (deviceInfo DeviceInfo)
type DeviceRunStatus ¶
type DeviceRunStatus struct { Onboot uint Service uint Concurrency uint Memtotal uint Memfree uint Cpu uint Reserve1 uint Reserve2 uint }
DeviceRunStatus sdf device status
type ECCSignature ¶
ECCSignature ecc signature
func ConvertToECCSignatureGo ¶
func ConvertToECCSignatureGo(pucSignature C.ECCSignature) (signature ECCSignature)
type ECCrefPrivateKey ¶
ECCrefPrivateKey ecc private key
func ConvertToECCrefPrivateKeyGo ¶
func ConvertToECCrefPrivateKeyGo(pucPrivateKey C.ECCrefPrivateKey) (privateKey ECCrefPrivateKey)
type ECCrefPublicKey ¶
ECCrefPublicKey ecc public key
func ConvertToECCrefPublicKeyGo ¶
func ConvertToECCrefPublicKeyGo(pucPublicKey C.ECCrefPublicKey) (publicKey ECCrefPublicKey)
type SessionHandle ¶
type SessionHandle C.SGD_HANDLE