base

package
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SDR_OK   = 0x00000000
	SDR_BASE = 0x01000000
)
View Source
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
)

Variables

This section is empty.

Functions

func CMessage

func CMessage(data []byte) (dataPtr C.SGD_UCHAR_PRT)

func ConvertToECCCipherC

func ConvertToECCCipherC(encData ECCCipher) (pucEncData C.ECCCipher)

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 ToError

func ToError(e C.SGD_RV) error

Types

type Ctx

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

func New

func New(libPath string) *Ctx

func (*Ctx) Destroy

func (c *Ctx) Destroy()

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) 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
}

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
}

type ECCCipher

type ECCCipher struct {
	X string
	Y string
	M string
	L uint
	C string
}

func ConvertToECCCipherGo

func ConvertToECCCipherGo(pucKey C.ECCCipher) (key ECCCipher)

type ECCSignature

type ECCSignature struct {
	R string
	S string
}

func ConvertToECCSignatureGo

func ConvertToECCSignatureGo(pucSignature C.ECCSignature) (signature ECCSignature)

type ECCrefPrivateKey

type ECCrefPrivateKey struct {
	Bits uint
	K    string
}

func ConvertToECCrefPrivateKeyGo

func ConvertToECCrefPrivateKeyGo(pucPrivateKey C.ECCrefPrivateKey) (privateKey ECCrefPrivateKey)

type ECCrefPublicKey

type ECCrefPublicKey struct {
	Bits uint
	X    string
	Y    string
}

func ConvertToECCrefPublicKeyGo

func ConvertToECCrefPublicKeyGo(pucPublicKey C.ECCrefPublicKey) (publicKey ECCrefPublicKey)

type SessionHandle

type SessionHandle C.SGD_HANDLE

Jump to

Keyboard shortcuts

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