sdf

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

sdf

github.com/053x/sdf is a Go wrapper for the GM/T 0018-2012 Security Device Framework (SDF) API. It follows the same deployment model as github.com/miekg/pkcs11: the application is built once and loads the selected vendor shared library at runtime.

The module deliberately targets the 2012 ABI used by SoftSDF and the referenced vendor-style libraries. GM/T 0018-2012 was superseded by GM/T 0018-2023; this initial release does not claim the 2023 additions or compatibility with a vendor header that changes the 2012 data layouts.

The package is intentionally a thin ABI wrapper. It owns library loading, type-safe handles, Go/C structure conversion, standard error values, and buffer management. Device policy, key lifecycle, cryptographic protocols, and vendor compatibility decisions remain in the caller.

Requirements

  • Go 1.22 or newer.
  • cgo and a C compiler.
  • A GM/T 0018-2012 compatible .so, .dylib, or .dll.

Example

ctx, err := sdf.Open("/usr/local/lib/libsoftsdf.dylib")
if err != nil {
    log.Fatal(err)
}
defer ctx.Close()

device, err := ctx.OpenDevice()
if err != nil {
    log.Fatal(err)
}
defer ctx.CloseDevice(device)

session, err := ctx.OpenSession(device)
if err != nil {
    log.Fatal(err)
}
defer ctx.CloseSession(session)

random, err := ctx.GenerateRandom(session, 32)

Concurrency and lifecycle

Context may be used by multiple goroutines and Close waits for in-flight calls. No concurrency guarantee is made for a vendor device, session, key, or agreement handle. Serialize access to the same handle unless the vendor SDK explicitly documents stronger behavior.

Every successful device/session open and session-key creation must be paired with its matching close or destroy operation. An agreement handle is consumed by the corresponding key-agreement flow. Context.Close only unloads the shared library; it does not silently close device/session handles or destroy keys.

ABI compatibility

SDF vendors are known to ship headers that differ from GM/T 0018-2012 and from one another. This package uses fixed-width 32-bit scalar fields and the SoftSDF 255-byte ECCCipher.C profile. Compare DeviceInfo, RSA/ECC structures, calling convention, and ciphertext capacity with the exact target SDK header before hardware acceptance. Vendor extensions belong in separate packages and must not be inferred by this base wrapper.

Security boundary

The loaded module is trusted native code in the application process. This package does not sandbox the module, validate its transitive dependencies, or make an untrusted library safe. Applications should resolve an absolute path, verify the deployed artifact according to their trust policy, keep device credentials outside logs and command-line arguments, and isolate vendor code in a supervised subprocess when crash or hang containment is required.

Testing with SoftSDF

The default test suite builds and loads a small fake SDF library. An initialized SoftSDF build can be exercised explicitly:

SDF_SOFTSDF_LIBRARY=/absolute/path/to/libsoftsdf.so \
SDF_SOFTSDF_DATA_DIR=/absolute/path/to/initialized/softsdf-data \
go test -run TestSoftSDFIntegration -count=1 -v

This is software compatibility evidence only. It is not a target HSM or vendor device acceptance result.

References

License

Apache License 2.0. See LICENSE and NOTICE.

Documentation

Overview

Package sdf provides Go bindings for the GM/T 0018-2012 Security Device Framework (SDF) API.

The package loads a vendor SDF shared library at runtime. It does not link against a particular device SDK at build time. A Context owns one loaded library; device, session, key, and agreement handles remain owned by the vendor implementation. Device, session, and key handles use their matching close/destroy calls; agreement-handle consumption follows SDF key agreement.

SDF handles are not assumed to be safe for concurrent use. In particular, callers must serialize operations that use the same session, key, or agreement handle unless the device vendor explicitly documents otherwise.

Index

Constants

View Source
const (
	SDR_OK               = SDROK
	SDR_BASE             = SDRBase
	SDR_UNKNOWERR        = SDRUnknown
	SDR_NOTSUPPORT       = SDRNotSupported
	SDR_COMMFAIL         = SDRCommunication
	SDR_HARDFAIL         = SDRHardwareFailure
	SDR_OPENDEVICE       = SDROpenDevice
	SDR_OPENSESSION      = SDROpenSession
	SDR_PARDENY          = SDRPermissionDenied
	SDR_KEYNOTEXIST      = SDRKeyNotExist
	SDR_ALGNOTSUPPORT    = SDRAlgorithm
	SDR_ALGMODNOTSUPPORT = SDRAlgorithmMode
	SDR_PKOPERR          = SDRPublicKey
	SDR_SKOPERR          = SDRPrivateKey
	SDR_SIGNERR          = SDRSign
	SDR_VERIFYERR        = SDRVerify
	SDR_SYMOPERR         = SDRSymmetric
	SDR_STEPERR          = SDRStep
	SDR_FILESIZEERR      = SDRFileSize
	SDR_FILENOEXIST      = SDRFileNotExist
	SDR_FILEOFSERR       = SDRFileOffset
	SDR_KEYTYPEERR       = SDRKeyType
	SDR_KEYERR           = SDRKey
	SDR_ENCDATAERR       = SDREncryptedData
	SDR_RANDERR          = SDRRandom
	SDR_PRKRERR          = SDRPrivateKeyAccess
	SDR_MACERR           = SDRMAC
	SDR_FILEEXISTS       = SDRFileExists
	SDR_FILEEXSITS       = SDRFileExists
	SDR_FILEWERR         = SDRFileWrite
	SDR_NOBUFFER         = SDRNoBuffer
	SDR_INARGERR         = SDRInputArgument
	SDR_OUTARGERR        = SDROutputArgument
)

Standard SDF return-code spellings.

View Source
const (
	RSAMaxBits  = 2048
	RSAMaxLen   = (RSAMaxBits + 7) / 8
	RSAMaxPBits = (RSAMaxBits + 1) / 2
	RSAMaxPLen  = (RSAMaxPBits + 7) / 8

	ECCMaxBits       = 512
	ECCMaxLen        = (ECCMaxBits + 7) / 8
	ECCMaxCiphertext = 255

	SM3DigestSize = 32
)
View Source
const (
	SGD_ECB  = SGDECB
	SGD_CBC  = SGDCBC
	SGD_CFB  = SGDCFB
	SGD_OFB  = SGDOFB
	SGD_MAC  = SGDMAC
	SGD_EEA3 = SGDEEA3
	SGD_EIA3 = SGDEIA3

	SGD_SM1   = SGDSM1
	SGD_SSF33 = SGDSSF33
	SGD_SM4   = SGDSM4
	SGD_ZUC   = SGDZUC

	SGD_SM1_ECB   = SGDSM1ECB
	SGD_SM1_CBC   = SGDSM1CBC
	SGD_SM1_CFB   = SGDSM1CFB
	SGD_SM1_OFB   = SGDSM1OFB
	SGD_SM1_MAC   = SGDSM1MAC
	SGD_SSF33_ECB = SGDSSF33ECB
	SGD_SSF33_CBC = SGDSSF33CBC
	SGD_SSF33_CFB = SGDSSF33CFB
	SGD_SSF33_OFB = SGDSSF33OFB
	SGD_SSF33_MAC = SGDSSF33MAC
	SGD_SM4_ECB   = SGDSM4ECB
	SGD_SM4_CBC   = SGDSM4CBC
	SGD_SM4_CFB   = SGDSM4CFB
	SGD_SM4_OFB   = SGDSM4OFB
	SGD_SM4_MAC   = SGDSM4MAC
	SGD_ZUC_EEA3  = SGDZUCEEA3
	SGD_ZUC_EIA3  = SGDZUCEIA3

	SGD_PK_SIGN  = SGDPKSign
	SGD_PK_DH    = SGDPKDH
	SGD_PK_ENC   = SGDPKEnc
	SGD_RSA      = SGDRSA
	SGD_RSA_SIGN = SGDRSASign
	SGD_RSA_ENC  = SGDRSAEnc
	SGD_SM2      = SGDSM2
	SGD_SM2_1    = SGDSM2Sign
	SGD_SM2_2    = SGDSM2Key
	SGD_SM2_3    = SGDSM2Enc

	SGD_SM3        = SGDSM3
	SGD_SHA1       = SGDSHA1
	SGD_SHA256     = SGDSHA256
	SGD_SM3_RSA    = SGDSM3RSA
	SGD_SHA1_RSA   = SGDSHA1RSA
	SGD_SHA256_RSA = SGDSHA256RSA
	SGD_SM3_SM2    = SGDSM3SM2
)

Standard SDF/SGD spellings are provided alongside the Go-style names so callers can map vendor documentation without translating constants.

View Source
const MaxFileNameLength = 128

Variables

View Source
var (
	ErrClosed          = errors.New("sdf: context is closed")
	ErrInvalidArgument = errors.New("sdf: invalid argument")
	ErrCGODisabled     = errors.New("sdf: cgo is required")
)

Functions

This section is empty.

Types

type ALGID

type ALGID = Algorithm

ALGID is the conventional SDF name for Algorithm.

type AgreementHandle

type AgreementHandle uintptr

AgreementHandle is an opaque handle returned by SDF key agreement setup.

type Algorithm

type Algorithm uint32

Algorithm identifies an algorithm or algorithm mode from GM/T 0006.

const (
	SGDECB  Algorithm = 0x00000001
	SGDCBC  Algorithm = 0x00000002
	SGDCFB  Algorithm = 0x00000004
	SGDOFB  Algorithm = 0x00000008
	SGDMAC  Algorithm = 0x00000010
	SGDEEA3 Algorithm = 0x00000001
	SGDEIA3 Algorithm = 0x00000002

	SGDSM1   Algorithm = 0x00000100
	SGDSSF33 Algorithm = 0x00000200
	SGDSM4   Algorithm = 0x00000400
	SGDZUC   Algorithm = 0x00000800

	SGDSM1ECB   Algorithm = SGDSM1 | SGDECB
	SGDSM1CBC   Algorithm = SGDSM1 | SGDCBC
	SGDSM1CFB   Algorithm = SGDSM1 | SGDCFB
	SGDSM1OFB   Algorithm = SGDSM1 | SGDOFB
	SGDSM1MAC   Algorithm = SGDSM1 | SGDMAC
	SGDSSF33ECB Algorithm = SGDSSF33 | SGDECB
	SGDSSF33CBC Algorithm = SGDSSF33 | SGDCBC
	SGDSSF33CFB Algorithm = SGDSSF33 | SGDCFB
	SGDSSF33OFB Algorithm = SGDSSF33 | SGDOFB
	SGDSSF33MAC Algorithm = SGDSSF33 | SGDMAC
	SGDSM4ECB   Algorithm = SGDSM4 | SGDECB
	SGDSM4CBC   Algorithm = SGDSM4 | SGDCBC
	SGDSM4CFB   Algorithm = SGDSM4 | SGDCFB
	SGDSM4OFB   Algorithm = SGDSM4 | SGDOFB
	SGDSM4MAC   Algorithm = SGDSM4 | SGDMAC
	SGDZUCEEA3  Algorithm = SGDZUC | SGDEEA3
	SGDZUCEIA3  Algorithm = SGDZUC | SGDEIA3

	SGDPKSign  Algorithm = 0x00000100
	SGDPKDH    Algorithm = 0x00000200
	SGDPKEnc   Algorithm = 0x00000400
	SGDRSA     Algorithm = 0x00010000
	SGDRSASign           = SGDRSA | SGDPKSign
	SGDRSAEnc            = SGDRSA | SGDPKEnc
	SGDSM2     Algorithm = 0x00020100
	SGDSM2Sign Algorithm = 0x00020200
	SGDSM2Key  Algorithm = 0x00020400
	SGDSM2Enc  Algorithm = 0x00020800

	SGDSM3       Algorithm = 0x00000001
	SGDSHA1      Algorithm = 0x00000002
	SGDSHA256    Algorithm = 0x00000004
	SGDSM3RSA              = SGDSM3 | SGDRSA
	SGDSHA1RSA             = SGDSHA1 | SGDRSA
	SGDSHA256RSA           = SGDSHA256 | SGDRSA
	SGDSM3SM2              = SGDSM3 | SGDSM2
)

type Context

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

Context owns one loaded SDF shared library. A Context must not be copied after first use.

func New

func New(module string) *Context

New loads an SDF library and returns nil on failure. Open should be preferred when the loader error is useful to the caller.

func Open

func Open(module string) (*Context, error)

Open loads an SDF shared library. Individual SDF entry points are resolved independently; calling an entry point absent from the library returns SDRNotSupported.

func (*Context) CalculateMAC

func (c *Context) CalculateMAC(session SessionHandle, key KeyHandle, algorithm Algorithm, iv, data []byte, outputCapacity int) ([]byte, error)

func (*Context) Close

func (c *Context) Close() error

Close unloads the shared library after all in-flight calls finish. It does not close device/session handles or destroy key/agreement handles.

func (*Context) CloseDevice

func (c *Context) CloseDevice(device DeviceHandle) error

CloseDevice calls SDF_CloseDevice.

func (*Context) CloseSession

func (c *Context) CloseSession(session SessionHandle) error

CloseSession calls SDF_CloseSession.

func (*Context) CreateFile

func (c *Context) CreateFile(session SessionHandle, name []byte, size uint32) error

func (*Context) Decrypt

func (c *Context) Decrypt(session SessionHandle, key KeyHandle, algorithm Algorithm, iv, ciphertext []byte, outputCapacity int) ([]byte, error)

Decrypt calls SDF_Decrypt. Some vendor implementations mutate iv; callers that need to preserve it must pass a copy.

func (*Context) DeleteFile

func (c *Context) DeleteFile(session SessionHandle, name []byte) error

func (*Context) Destroy

func (c *Context) Destroy()

Destroy is an alias for Close, matching the lifecycle vocabulary used by some dynamic cryptographic-library wrappers.

func (*Context) DestroyKey

func (c *Context) DestroyKey(session SessionHandle, key KeyHandle) error

func (*Context) Encrypt

func (c *Context) Encrypt(session SessionHandle, key KeyHandle, algorithm Algorithm, iv, plaintext []byte, outputCapacity int) ([]byte, error)

Encrypt calls SDF_Encrypt. Some vendor implementations mutate iv; callers that need to preserve it must pass a copy.

func (*Context) ExchangeDigitEnvelopeECC

func (c *Context) ExchangeDigitEnvelopeECC(session SessionHandle, keyIndex uint32, algorithm Algorithm, publicKey ECCPublicKey, input ECCCipher) (ECCCipher, error)

func (*Context) ExchangeDigitEnvelopeRSA

func (c *Context) ExchangeDigitEnvelopeRSA(session SessionHandle, keyIndex uint32, publicKey RSAPublicKey, input []byte, outputCapacity int) ([]byte, error)

func (*Context) ExportEncPublicKeyECC

func (c *Context) ExportEncPublicKeyECC(session SessionHandle, keyIndex uint32) (ECCPublicKey, error)

func (*Context) ExportEncPublicKeyRSA

func (c *Context) ExportEncPublicKeyRSA(session SessionHandle, keyIndex uint32) (RSAPublicKey, error)

func (*Context) ExportSignPublicKeyECC

func (c *Context) ExportSignPublicKeyECC(session SessionHandle, keyIndex uint32) (ECCPublicKey, error)

func (*Context) ExportSignPublicKeyRSA

func (c *Context) ExportSignPublicKeyRSA(session SessionHandle, keyIndex uint32) (RSAPublicKey, error)

func (*Context) ExternalEncryptECC

func (c *Context) ExternalEncryptECC(session SessionHandle, algorithm Algorithm, publicKey ECCPublicKey, data []byte) (ECCCipher, error)

func (*Context) ExternalPublicKeyOperationRSA

func (c *Context) ExternalPublicKeyOperationRSA(session SessionHandle, publicKey RSAPublicKey, input []byte, outputCapacity int) ([]byte, error)

func (*Context) ExternalVerifyECC

func (c *Context) ExternalVerifyECC(session SessionHandle, algorithm Algorithm, publicKey ECCPublicKey, data []byte, signature ECCSignature) error

func (*Context) GenerateAgreementDataAndKeyECC

func (c *Context) GenerateAgreementDataAndKeyECC(session SessionHandle, keyIndex, bits uint32, responseID, sponsorID []byte, responsePublicKey, responseTemporaryPublicKey ECCPublicKey) (ECCPublicKey, ECCPublicKey, KeyHandle, error)

func (*Context) GenerateAgreementDataECC

func (c *Context) GenerateAgreementDataECC(session SessionHandle, keyIndex, bits uint32, sponsorID []byte) (ECCPublicKey, ECCPublicKey, AgreementHandle, error)

func (*Context) GenerateKeyECC

func (c *Context) GenerateKeyECC(session SessionHandle, responseID []byte, responsePublicKey, responseTemporaryPublicKey ECCPublicKey, agreement AgreementHandle) (KeyHandle, error)

func (*Context) GenerateKeyPairECC

func (c *Context) GenerateKeyPairECC(session SessionHandle, algorithm Algorithm, bits uint32) (ECCPublicKey, ECCPrivateKey, error)

func (*Context) GenerateKeyPairRSA

func (c *Context) GenerateKeyPairRSA(session SessionHandle, bits uint32) (RSAPublicKey, RSAPrivateKey, error)

func (*Context) GenerateKeyWithEPKECC

func (c *Context) GenerateKeyWithEPKECC(session SessionHandle, bits uint32, algorithm Algorithm, publicKey ECCPublicKey) (ECCCipher, KeyHandle, error)

func (*Context) GenerateKeyWithEPKRSA

func (c *Context) GenerateKeyWithEPKRSA(session SessionHandle, bits uint32, publicKey RSAPublicKey, outputCapacity int) ([]byte, KeyHandle, error)

func (*Context) GenerateKeyWithIPKECC

func (c *Context) GenerateKeyWithIPKECC(session SessionHandle, keyIndex, bits uint32) (ECCCipher, KeyHandle, error)

func (*Context) GenerateKeyWithIPKRSA

func (c *Context) GenerateKeyWithIPKRSA(session SessionHandle, keyIndex, bits uint32, outputCapacity int) ([]byte, KeyHandle, error)

func (*Context) GenerateKeyWithKEK

func (c *Context) GenerateKeyWithKEK(session SessionHandle, bits uint32, algorithm Algorithm, keyIndex uint32, outputCapacity int) ([]byte, KeyHandle, error)

func (*Context) GenerateRandom

func (c *Context) GenerateRandom(session SessionHandle, length int) ([]byte, error)

GenerateRandom calls SDF_GenerateRandom.

func (*Context) GetDeviceInfo

func (c *Context) GetDeviceInfo(session SessionHandle) (DeviceInfo, error)

GetDeviceInfo calls SDF_GetDeviceInfo.

func (*Context) GetPrivateKeyAccessRight

func (c *Context) GetPrivateKeyAccessRight(session SessionHandle, keyIndex uint32, password []byte) error

GetPrivateKeyAccessRight calls SDF_GetPrivateKeyAccessRight.

func (*Context) HasFunction

func (c *Context) HasFunction(name string) bool

HasFunction reports whether the loaded module exports an exact symbol name, such as "SDF_OpenDevice".

func (*Context) HashFinal

func (c *Context) HashFinal(session SessionHandle, outputCapacity int) ([]byte, error)

func (*Context) HashInit

func (c *Context) HashInit(session SessionHandle, algorithm Algorithm, publicKey *ECCPublicKey, id []byte) error

func (*Context) HashUpdate

func (c *Context) HashUpdate(session SessionHandle, data []byte) error

func (*Context) ImportKeyWithISKECC

func (c *Context) ImportKeyWithISKECC(session SessionHandle, keyIndex uint32, encrypted ECCCipher) (KeyHandle, error)

func (*Context) ImportKeyWithISKRSA

func (c *Context) ImportKeyWithISKRSA(session SessionHandle, keyIndex uint32, encryptedKey []byte) (KeyHandle, error)

func (*Context) ImportKeyWithKEK

func (c *Context) ImportKeyWithKEK(session SessionHandle, algorithm Algorithm, keyIndex uint32, encryptedKey []byte) (KeyHandle, error)

func (*Context) InternalDecryptECC

func (c *Context) InternalDecryptECC(session SessionHandle, keyIndex uint32, algorithm Algorithm, encrypted ECCCipher, outputCapacity int) ([]byte, error)

func (*Context) InternalEncryptECC

func (c *Context) InternalEncryptECC(session SessionHandle, keyIndex uint32, algorithm Algorithm, data []byte) (ECCCipher, error)

func (*Context) InternalPrivateKeyOperationRSA

func (c *Context) InternalPrivateKeyOperationRSA(session SessionHandle, keyIndex uint32, input []byte, outputCapacity int) ([]byte, error)

func (*Context) InternalPublicKeyOperationRSA

func (c *Context) InternalPublicKeyOperationRSA(session SessionHandle, keyIndex uint32, input []byte, outputCapacity int) ([]byte, error)

func (*Context) InternalSignECC

func (c *Context) InternalSignECC(session SessionHandle, keyIndex uint32, data []byte) (ECCSignature, error)

func (*Context) InternalVerifyECC

func (c *Context) InternalVerifyECC(session SessionHandle, keyIndex uint32, data []byte, signature ECCSignature) error

func (*Context) OpenDevice

func (c *Context) OpenDevice() (DeviceHandle, error)

OpenDevice calls SDF_OpenDevice.

func (*Context) OpenSession

func (c *Context) OpenSession(device DeviceHandle) (SessionHandle, error)

OpenSession calls SDF_OpenSession.

func (*Context) ReadFile

func (c *Context) ReadFile(session SessionHandle, name []byte, offset uint32, length int) ([]byte, error)

func (*Context) ReleasePrivateKeyAccessRight

func (c *Context) ReleasePrivateKeyAccessRight(session SessionHandle, keyIndex uint32) error

ReleasePrivateKeyAccessRight calls SDF_ReleasePrivateKeyAccessRight.

func (*Context) WriteFile

func (c *Context) WriteFile(session SessionHandle, name []byte, offset uint32, data []byte) error

type DEVICEINFO

type DEVICEINFO = DeviceInfo

Conventional aliases mirror the structure names used by SDF headers.

type DeviceHandle

type DeviceHandle uintptr

DeviceHandle is an opaque handle returned by SDF_OpenDevice.

type DeviceInfo

type DeviceInfo struct {
	IssuerName      [40]byte
	DeviceName      [16]byte
	DeviceSerial    [16]byte
	DeviceVersion   uint32
	StandardVersion uint32
	AsymAlgAbility  [2]uint32
	SymAlgAbility   uint32
	HashAlgAbility  uint32
	BufferSize      uint32
}

DeviceInfo is the GM/T 0018-2012 DEVICEINFO structure.

type ECCCipher

type ECCCipher struct {
	X [ECCMaxLen]byte
	Y [ECCMaxLen]byte
	M [SM3DigestSize]byte
	L uint32
	C [ECCMaxCiphertext]byte
}

ECCCipher is the GM/T 0018-2012 ECCCipher structure using the SoftSDF 255-byte ciphertext ABI profile. Vendors are known to ship incompatible structure definitions; compare this layout with the target SDK header.

type ECCPrivateKey

type ECCPrivateKey struct {
	Bits uint32
	K    [ECCMaxLen]byte
}

ECCPrivateKey is the GM/T 0018-2012 ECCrefPrivateKey structure.

type ECCPublicKey

type ECCPublicKey struct {
	Bits uint32
	X    [ECCMaxLen]byte
	Y    [ECCMaxLen]byte
}

ECCPublicKey is the GM/T 0018-2012 ECCrefPublicKey structure.

type ECCSignature

type ECCSignature struct {
	R [ECCMaxLen]byte
	S [ECCMaxLen]byte
}

ECCSignature is the GM/T 0018-2012 ECCSignature structure.

type ECCrefPrivateKey

type ECCrefPrivateKey = ECCPrivateKey

Conventional aliases mirror the structure names used by SDF headers.

type ECCrefPublicKey

type ECCrefPublicKey = ECCPublicKey

Conventional aliases mirror the structure names used by SDF headers.

type Error

type Error uint32

Error is an SDF return value. The standard values can be inspected with errors.Is because Error implements Is by numeric return code.

const (
	SDROK               Error = 0x00000000
	SDRBase             Error = 0x01000000
	SDRUnknown          Error = SDRBase + 0x00000001
	SDRNotSupported     Error = SDRBase + 0x00000002
	SDRCommunication    Error = SDRBase + 0x00000003
	SDRHardwareFailure  Error = SDRBase + 0x00000004
	SDROpenDevice       Error = SDRBase + 0x00000005
	SDROpenSession      Error = SDRBase + 0x00000006
	SDRPermissionDenied Error = SDRBase + 0x00000007
	SDRKeyNotExist      Error = SDRBase + 0x00000008
	SDRAlgorithm        Error = SDRBase + 0x00000009
	SDRAlgorithmMode    Error = SDRBase + 0x0000000a
	SDRPublicKey        Error = SDRBase + 0x0000000b
	SDRPrivateKey       Error = SDRBase + 0x0000000c
	SDRSign             Error = SDRBase + 0x0000000d
	SDRVerify           Error = SDRBase + 0x0000000e
	SDRSymmetric        Error = SDRBase + 0x0000000f
	SDRStep             Error = SDRBase + 0x00000010
	SDRFileSize         Error = SDRBase + 0x00000011
	SDRFileNotExist     Error = SDRBase + 0x00000012
	SDRFileOffset       Error = SDRBase + 0x00000013
	SDRKeyType          Error = SDRBase + 0x00000014
	SDRKey              Error = SDRBase + 0x00000015
	SDREncryptedData    Error = SDRBase + 0x00000016
	SDRRandom           Error = SDRBase + 0x00000017
	SDRPrivateKeyAccess Error = SDRBase + 0x00000018
	SDRMAC              Error = SDRBase + 0x00000019
	SDRFileExists       Error = SDRBase + 0x0000001a
	SDRFileWrite        Error = SDRBase + 0x0000001b
	SDRNoBuffer         Error = SDRBase + 0x0000001c
	SDRInputArgument    Error = SDRBase + 0x0000001d
	SDROutputArgument   Error = SDRBase + 0x0000001e
)

func (Error) Error

func (e Error) Error() string

func (Error) Is

func (e Error) Is(target error) bool

type KeyHandle

type KeyHandle uintptr

KeyHandle is an opaque session-key handle returned by an SDF key operation.

type RSAPrivateKey

type RSAPrivateKey struct {
	Bits  uint32
	M     [RSAMaxLen]byte
	E     [RSAMaxLen]byte
	D     [RSAMaxLen]byte
	Prime [2][RSAMaxPLen]byte
	PExp  [2][RSAMaxPLen]byte
	Coef  [RSAMaxPLen]byte
}

RSAPrivateKey is the GM/T 0018-2012 RSArefPrivateKey structure.

type RSAPublicKey

type RSAPublicKey struct {
	Bits uint32
	M    [RSAMaxLen]byte
	E    [RSAMaxLen]byte
}

RSAPublicKey is the GM/T 0018-2012 RSArefPublicKey structure.

type RSArefPrivateKey

type RSArefPrivateKey = RSAPrivateKey

Conventional aliases mirror the structure names used by SDF headers.

type RSArefPublicKey

type RSArefPublicKey = RSAPublicKey

Conventional aliases mirror the structure names used by SDF headers.

type SessionHandle

type SessionHandle uintptr

SessionHandle is an opaque handle returned by SDF_OpenSession.

Jump to

Keyboard shortcuts

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