Documentation ¶
Index ¶
- Constants
- func HsmClose()
- func HsmInit()
- func LogInit(cfg string)
- type HsmCall05
- func (opr *HsmCall05) ConvPin() error
- func (opr *HsmCall05) ExportWorkKey() error
- func (opr *HsmCall05) GenMac() error
- func (opr *HsmCall05) GenTermTmk() error
- func (opr *HsmCall05) GenTermWorkKey() error
- func (opr *HsmCall05) GetCallResult() bool
- func (opr *HsmCall05) GetCheckValue() []byte
- func (opr *HsmCall05) GetMac() []byte
- func (opr *HsmCall05) GetPinBlock() []byte
- func (opr *HsmCall05) GetReserved() []byte
- func (opr *HsmCall05) GetTmk() []byte
- func (opr *HsmCall05) GetWorkKey() []byte
- func (opr *HsmCall05) ImportWorkKey() error
- func (opr *HsmCall05) SetInChkValue(chkVal []byte)
- func (opr *HsmCall05) SetInKeyIndex(index int)
- func (opr *HsmCall05) SetInKeyLen(len int)
- func (opr *HsmCall05) SetInKeyType(tp byte)
- func (opr *HsmCall05) SetInMac(mac []byte)
- func (opr *HsmCall05) SetInMacAlgo(algo byte)
- func (opr *HsmCall05) SetInMacBlock(block []byte)
- func (opr *HsmCall05) SetInQAcct(acct []byte)
- func (opr *HsmCall05) SetInQPik(pik []byte)
- func (opr *HsmCall05) SetInQPinBlock(block []byte)
- func (opr *HsmCall05) SetInQPinType(tp byte)
- func (opr *HsmCall05) SetInRAcct(acct []byte)
- func (opr *HsmCall05) SetInRPik(pik []byte)
- func (opr *HsmCall05) SetInRPinType(tp byte)
- func (opr *HsmCall05) SetInRand1(rand []byte)
- func (opr *HsmCall05) SetInRand2(rand []byte)
- func (opr *HsmCall05) SetInReserved(resv []byte)
- func (opr *HsmCall05) SetInTekIndex(index int)
- func (opr *HsmCall05) SetInTmk(tmk []byte)
- func (opr *HsmCall05) SetInZmk(zmk []byte)
- func (opr *HsmCall05) SetWorkKey(key []byte)
- func (opr *HsmCall05) VerifyMac() error
- type HsmOper
- type HsmRequest
- type HsmResponse
- func (rsp *HsmResponse) CheckSucc() bool
- func (rsp *HsmResponse) GetAsc(len int) (string, error)
- func (rsp *HsmResponse) GetByte() (byte, error)
- func (rsp *HsmResponse) GetHex(len int) ([]byte, error)
- func (rsp *HsmResponse) GetInt16() (uint16, error)
- func (rsp *HsmResponse) GetInt8() (int, error)
- func (rsp *HsmResponse) GetLByte() []byte
- func (rsp *HsmResponse) GetRetCd() byte
- func (rsp *HsmResponse) String() string
- type HsmServer
Constants ¶
View Source
const ( HSM_SJL05 = "SJL05" HSM_SJL06 = "SJL06" HSM_CONF = "HSM" )
View Source
const ( //MAC向量 IV = "\x00\x00\x00\x00\x00\x00\x00\x00" //MAC算法 MAC_ALGO_XOR = 0x01 MAC_ALGO_99 = 0x02 MAC_ALGO_919 = 0x03 MAC_ALGO_ECB = 0x04 //PIN格式 PIN_BLOCK_01 = 0x01 PIN_BLOCK_02 = 0x02 PIN_BLOCK_03 = 0x03 PIN_BLOCK_04 = 0x04 PIN_BLOCK_05 = 0x05 PIN_BLOCK_06 = 0x06 //指令类型 CMD_ENC = 0x00 CMD_DEC = 0x01 //生成终端主秘钥类型 D181使用 KEY_TEK_TP = 0x00 KEY_TMK_TP = 0x01 KEY_TMK_TEK_TP = 0x02 //工作密钥类型-变种 WK_COM_TP = 0x01 WK_PIK_TP = 0x11 WK_MAK_TP = 0x12 WK_DAT_TP = 0x13 MaxReqLen = 4096 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HsmCall05 ¶
type HsmCall05 struct {
// contains filtered or unexported fields
}
加密机请求报文
func (*HsmCall05) GenTermTmk ¶
func (*HsmCall05) GenTermWorkKey ¶
必输:密钥类型 工作密钥长度 发散因子1 发散因子2 应答: GetTmk() GetWorkKey() GetChkValue()
func (*HsmCall05) SetInQPinBlock ¶
设置转PIN时 源PinBlock
type HsmOper ¶
type HsmOper interface { /* 设置区域主密钥索引*/ SetInKeyIndex(index int) /* 设置TEK主密钥索引*/ SetInTekIndex(index int) /* 设置区域主密钥*/ SetInZmk(zmk []byte) /* 设置终端主密钥*/ SetInTmk(tmk []byte) /* 设置密钥长度*/ SetInKeyLen(len int) /* 设置密钥类型*/ SetInKeyType(tp byte) /* 设置密钥*/ SetWorkKey(key []byte) /* 设置校验值*/ SetInChkValue(chkVal []byte) SetInQPinType(tp byte) SetInQPik(pik []byte) SetInQAcct(acct []byte) SetInQPinBlock(block []byte) SetInRPinType(tp byte) SetInRPik(pik []byte) SetInRAcct(acct []byte) SetInMacAlgo(algo byte) SetInMacBlock(block []byte) SetInMac(mac []byte) SetInRand1(rand []byte) SetInRand2(rand []byte) SetInReserved(resv []byte) /*加密机操作*/ ImportWorkKey() error /* 必输: 密钥长度 密钥索引 通信主密钥 工作密钥 响应: GetWorkKey() GetCheckVal() */ ExportWorkKey() error /* 必输: Mac算法 Mac工作密钥 MacBlock 响应: GetMac */ GenMac() error /* 必输: Mac 算法; 工作密钥; Mac; MacBlock; 得到结果: GetCallResult() */ VerifyMac() error /* 必输:源Pik 源PinType 源PinBlock 源PinAcct 目的Pik 目的PinType 目的PinAcct */ ConvPin() error /* 必输:TMK根索引 TEK根索引 SEK明文(ZMK) Rand1 发散因子 (ASCII) Rand2 发散银子 (ASCII) 应答: GetTmk() GetChkValue() */ GenTermTmk() error /* 必输: 根密钥索引 密钥类型 工作密钥长度 发散因子1 发散因子2 应答: GetTmk() GetWorkKey() GetChkValue() */ GenTermWorkKey() error /*取应答结果*/ GetCallResult() bool GetTmk() []byte GetWorkKey() []byte GetCheckValue() []byte GetMac() []byte GetPinBlock() []byte }
func NewHsmOper ¶
type HsmRequest ¶
type HsmRequest struct {
// contains filtered or unexported fields
}
请求报文
func NewHsmRequest ¶
func NewHsmRequest() *HsmRequest
func (*HsmRequest) Byte ¶
func (req *HsmRequest) Byte() []byte
func (*HsmRequest) SetAsc ¶
func (req *HsmRequest) SetAsc(asc string)
func (*HsmRequest) SetByte ¶
func (req *HsmRequest) SetByte(b byte)
func (*HsmRequest) SetHex ¶
func (req *HsmRequest) SetHex(hex []byte)
func (*HsmRequest) SetInt16 ¶
func (req *HsmRequest) SetInt16(i int)
func (*HsmRequest) SetInt8 ¶
func (req *HsmRequest) SetInt8(i int)
func (*HsmRequest) String ¶
func (req *HsmRequest) String() string
type HsmResponse ¶
type HsmResponse struct {
// contains filtered or unexported fields
}
func NewHsmResponse ¶
func NewHsmResponse(buf []byte) (*HsmResponse, error)
func (*HsmResponse) CheckSucc ¶
func (rsp *HsmResponse) CheckSucc() bool
func (*HsmResponse) GetByte ¶
func (rsp *HsmResponse) GetByte() (byte, error)
func (*HsmResponse) GetInt16 ¶
func (rsp *HsmResponse) GetInt16() (uint16, error)
func (*HsmResponse) GetInt8 ¶
func (rsp *HsmResponse) GetInt8() (int, error)
func (*HsmResponse) GetLByte ¶
func (rsp *HsmResponse) GetLByte() []byte
func (*HsmResponse) GetRetCd ¶
func (rsp *HsmResponse) GetRetCd() byte
func (*HsmResponse) String ¶
func (rsp *HsmResponse) String() string
Click to show internal directories.
Click to hide internal directories.