Versions in this module Expand all Collapse all v0 v0.1.0 Aug 1, 2026 Changes in this version + const ECCMaxBits + const ECCMaxCiphertext + const ECCMaxLen + const MaxFileNameLength + const RSAMaxBits + const RSAMaxLen + const RSAMaxPBits + const RSAMaxPLen + const SDR_ALGMODNOTSUPPORT + const SDR_ALGNOTSUPPORT + const SDR_BASE + const SDR_COMMFAIL + const SDR_ENCDATAERR + const SDR_FILEEXISTS + const SDR_FILEEXSITS + const SDR_FILENOEXIST + const SDR_FILEOFSERR + const SDR_FILESIZEERR + const SDR_FILEWERR + const SDR_HARDFAIL + const SDR_INARGERR + const SDR_KEYERR + const SDR_KEYNOTEXIST + const SDR_KEYTYPEERR + const SDR_MACERR + const SDR_NOBUFFER + const SDR_NOTSUPPORT + const SDR_OK + const SDR_OPENDEVICE + const SDR_OPENSESSION + const SDR_OUTARGERR + const SDR_PARDENY + const SDR_PKOPERR + const SDR_PRKRERR + const SDR_RANDERR + const SDR_SIGNERR + const SDR_SKOPERR + const SDR_STEPERR + const SDR_SYMOPERR + const SDR_UNKNOWERR + const SDR_VERIFYERR + const SGD_CBC + const SGD_CFB + const SGD_ECB + const SGD_EEA3 + const SGD_EIA3 + const SGD_MAC + const SGD_OFB + const SGD_PK_DH + const SGD_PK_ENC + const SGD_PK_SIGN + const SGD_RSA + const SGD_RSA_ENC + const SGD_RSA_SIGN + const SGD_SHA1 + const SGD_SHA1_RSA + const SGD_SHA256 + const SGD_SHA256_RSA + const SGD_SM1 + const SGD_SM1_CBC + const SGD_SM1_CFB + const SGD_SM1_ECB + const SGD_SM1_MAC + const SGD_SM1_OFB + const SGD_SM2 + const SGD_SM2_1 + const SGD_SM2_2 + const SGD_SM2_3 + const SGD_SM3 + const SGD_SM3_RSA + const SGD_SM3_SM2 + const SGD_SM4 + const SGD_SM4_CBC + const SGD_SM4_CFB + const SGD_SM4_ECB + const SGD_SM4_MAC + const SGD_SM4_OFB + const SGD_SSF33 + const SGD_SSF33_CBC + const SGD_SSF33_CFB + const SGD_SSF33_ECB + const SGD_SSF33_MAC + const SGD_SSF33_OFB + const SGD_ZUC + const SGD_ZUC_EEA3 + const SGD_ZUC_EIA3 + const SM3DigestSize + var ErrCGODisabled = errors.New("sdf: cgo is required") + var ErrClosed = errors.New("sdf: context is closed") + var ErrInvalidArgument = errors.New("sdf: invalid argument") + type ALGID = Algorithm + type AgreementHandle uintptr + type Algorithm uint32 + const SGDCBC + const SGDCFB + const SGDECB + const SGDEEA3 + const SGDEIA3 + const SGDMAC + const SGDOFB + const SGDPKDH + const SGDPKEnc + const SGDPKSign + const SGDRSA + const SGDRSAEnc + const SGDRSASign + const SGDSHA1 + const SGDSHA1RSA + const SGDSHA256 + const SGDSHA256RSA + const SGDSM1 + const SGDSM1CBC + const SGDSM1CFB + const SGDSM1ECB + const SGDSM1MAC + const SGDSM1OFB + const SGDSM2 + const SGDSM2Enc + const SGDSM2Key + const SGDSM2Sign + const SGDSM3 + const SGDSM3RSA + const SGDSM3SM2 + const SGDSM4 + const SGDSM4CBC + const SGDSM4CFB + const SGDSM4ECB + const SGDSM4MAC + const SGDSM4OFB + const SGDSSF33 + const SGDSSF33CBC + const SGDSSF33CFB + const SGDSSF33ECB + const SGDSSF33MAC + const SGDSSF33OFB + const SGDZUC + const SGDZUCEEA3 + const SGDZUCEIA3 + type Context struct + func New(module string) *Context + func Open(module string) (*Context, error) + func (c *Context) CalculateMAC(session SessionHandle, key KeyHandle, algorithm Algorithm, iv, data []byte, ...) ([]byte, error) + func (c *Context) Close() error + func (c *Context) CloseDevice(device DeviceHandle) error + func (c *Context) CloseSession(session SessionHandle) error + func (c *Context) CreateFile(session SessionHandle, name []byte, size uint32) error + func (c *Context) Decrypt(session SessionHandle, key KeyHandle, algorithm Algorithm, ...) ([]byte, error) + func (c *Context) DeleteFile(session SessionHandle, name []byte) error + func (c *Context) Destroy() + func (c *Context) DestroyKey(session SessionHandle, key KeyHandle) error + func (c *Context) Encrypt(session SessionHandle, key KeyHandle, algorithm Algorithm, ...) ([]byte, error) + func (c *Context) ExchangeDigitEnvelopeECC(session SessionHandle, keyIndex uint32, algorithm Algorithm, ...) (ECCCipher, error) + func (c *Context) ExchangeDigitEnvelopeRSA(session SessionHandle, keyIndex uint32, publicKey RSAPublicKey, input []byte, ...) ([]byte, error) + func (c *Context) ExportEncPublicKeyECC(session SessionHandle, keyIndex uint32) (ECCPublicKey, error) + func (c *Context) ExportEncPublicKeyRSA(session SessionHandle, keyIndex uint32) (RSAPublicKey, error) + func (c *Context) ExportSignPublicKeyECC(session SessionHandle, keyIndex uint32) (ECCPublicKey, error) + func (c *Context) ExportSignPublicKeyRSA(session SessionHandle, keyIndex uint32) (RSAPublicKey, error) + func (c *Context) ExternalEncryptECC(session SessionHandle, algorithm Algorithm, publicKey ECCPublicKey, ...) (ECCCipher, error) + func (c *Context) ExternalPublicKeyOperationRSA(session SessionHandle, publicKey RSAPublicKey, input []byte, ...) ([]byte, error) + func (c *Context) ExternalVerifyECC(session SessionHandle, algorithm Algorithm, publicKey ECCPublicKey, ...) error + func (c *Context) GenerateAgreementDataAndKeyECC(session SessionHandle, keyIndex, bits uint32, responseID, sponsorID []byte, ...) (ECCPublicKey, ECCPublicKey, KeyHandle, error) + func (c *Context) GenerateAgreementDataECC(session SessionHandle, keyIndex, bits uint32, sponsorID []byte) (ECCPublicKey, ECCPublicKey, AgreementHandle, error) + func (c *Context) GenerateKeyECC(session SessionHandle, responseID []byte, ...) (KeyHandle, error) + func (c *Context) GenerateKeyPairECC(session SessionHandle, algorithm Algorithm, bits uint32) (ECCPublicKey, ECCPrivateKey, error) + func (c *Context) GenerateKeyPairRSA(session SessionHandle, bits uint32) (RSAPublicKey, RSAPrivateKey, error) + func (c *Context) GenerateKeyWithEPKECC(session SessionHandle, bits uint32, algorithm Algorithm, ...) (ECCCipher, KeyHandle, error) + func (c *Context) GenerateKeyWithEPKRSA(session SessionHandle, bits uint32, publicKey RSAPublicKey, outputCapacity int) ([]byte, KeyHandle, error) + func (c *Context) GenerateKeyWithIPKECC(session SessionHandle, keyIndex, bits uint32) (ECCCipher, KeyHandle, error) + func (c *Context) GenerateKeyWithIPKRSA(session SessionHandle, keyIndex, bits uint32, outputCapacity int) ([]byte, KeyHandle, error) + func (c *Context) GenerateKeyWithKEK(session SessionHandle, bits uint32, algorithm Algorithm, keyIndex uint32, ...) ([]byte, KeyHandle, error) + func (c *Context) GenerateRandom(session SessionHandle, length int) ([]byte, error) + func (c *Context) GetDeviceInfo(session SessionHandle) (DeviceInfo, error) + func (c *Context) GetPrivateKeyAccessRight(session SessionHandle, keyIndex uint32, password []byte) error + func (c *Context) HasFunction(name string) bool + func (c *Context) HashFinal(session SessionHandle, outputCapacity int) ([]byte, error) + func (c *Context) HashInit(session SessionHandle, algorithm Algorithm, publicKey *ECCPublicKey, id []byte) error + func (c *Context) HashUpdate(session SessionHandle, data []byte) error + func (c *Context) ImportKeyWithISKECC(session SessionHandle, keyIndex uint32, encrypted ECCCipher) (KeyHandle, error) + func (c *Context) ImportKeyWithISKRSA(session SessionHandle, keyIndex uint32, encryptedKey []byte) (KeyHandle, error) + func (c *Context) ImportKeyWithKEK(session SessionHandle, algorithm Algorithm, keyIndex uint32, ...) (KeyHandle, error) + func (c *Context) InternalDecryptECC(session SessionHandle, keyIndex uint32, algorithm Algorithm, ...) ([]byte, error) + func (c *Context) InternalEncryptECC(session SessionHandle, keyIndex uint32, algorithm Algorithm, data []byte) (ECCCipher, error) + func (c *Context) InternalPrivateKeyOperationRSA(session SessionHandle, keyIndex uint32, input []byte, outputCapacity int) ([]byte, error) + func (c *Context) InternalPublicKeyOperationRSA(session SessionHandle, keyIndex uint32, input []byte, outputCapacity int) ([]byte, error) + func (c *Context) InternalSignECC(session SessionHandle, keyIndex uint32, data []byte) (ECCSignature, error) + func (c *Context) InternalVerifyECC(session SessionHandle, keyIndex uint32, data []byte, signature ECCSignature) error + func (c *Context) OpenDevice() (DeviceHandle, error) + func (c *Context) OpenSession(device DeviceHandle) (SessionHandle, error) + func (c *Context) ReadFile(session SessionHandle, name []byte, offset uint32, length int) ([]byte, error) + func (c *Context) ReleasePrivateKeyAccessRight(session SessionHandle, keyIndex uint32) error + func (c *Context) WriteFile(session SessionHandle, name []byte, offset uint32, data []byte) error + type DEVICEINFO = DeviceInfo + type DeviceHandle uintptr + type DeviceInfo struct + AsymAlgAbility [2]uint32 + BufferSize uint32 + DeviceName [16]byte + DeviceSerial [16]byte + DeviceVersion uint32 + HashAlgAbility uint32 + IssuerName [40]byte + StandardVersion uint32 + SymAlgAbility uint32 + type ECCCipher struct + C [ECCMaxCiphertext]byte + L uint32 + M [SM3DigestSize]byte + X [ECCMaxLen]byte + Y [ECCMaxLen]byte + type ECCPrivateKey struct + Bits uint32 + K [ECCMaxLen]byte + type ECCPublicKey struct + Bits uint32 + X [ECCMaxLen]byte + Y [ECCMaxLen]byte + type ECCSignature struct + R [ECCMaxLen]byte + S [ECCMaxLen]byte + type ECCrefPrivateKey = ECCPrivateKey + type ECCrefPublicKey = ECCPublicKey + type Error uint32 + const SDRAlgorithm + const SDRAlgorithmMode + const SDRBase + const SDRCommunication + const SDREncryptedData + const SDRFileExists + const SDRFileNotExist + const SDRFileOffset + const SDRFileSize + const SDRFileWrite + const SDRHardwareFailure + const SDRInputArgument + const SDRKey + const SDRKeyNotExist + const SDRKeyType + const SDRMAC + const SDRNoBuffer + const SDRNotSupported + const SDROK + const SDROpenDevice + const SDROpenSession + const SDROutputArgument + const SDRPermissionDenied + const SDRPrivateKey + const SDRPrivateKeyAccess + const SDRPublicKey + const SDRRandom + const SDRSign + const SDRStep + const SDRSymmetric + const SDRUnknown + const SDRVerify + func (e Error) Error() string + func (e Error) Is(target error) bool + type KeyHandle uintptr + type RSAPrivateKey struct + Bits uint32 + Coef [RSAMaxPLen]byte + D [RSAMaxLen]byte + E [RSAMaxLen]byte + M [RSAMaxLen]byte + PExp [2][RSAMaxPLen]byte + Prime [2][RSAMaxPLen]byte + type RSAPublicKey struct + Bits uint32 + E [RSAMaxLen]byte + M [RSAMaxLen]byte + type RSArefPrivateKey = RSAPrivateKey + type RSArefPublicKey = RSAPublicKey + type SessionHandle uintptr