ExportWrapped
This commit is contained in:
parent
278b0ae2f2
commit
d3f55e54bd
|
@ -411,7 +411,20 @@ func CreateSignAttestationCertCommand(keyObjID, attestationObjID uint16) (*Comma
|
||||||
payload := bytes.NewBuffer([]byte{})
|
payload := bytes.NewBuffer([]byte{})
|
||||||
binary.Write(payload, binary.BigEndian, keyObjID)
|
binary.Write(payload, binary.BigEndian, keyObjID)
|
||||||
binary.Write(payload, binary.BigEndian, attestationObjID)
|
binary.Write(payload, binary.BigEndian, attestationObjID)
|
||||||
|
command.Data = payload.Bytes()
|
||||||
|
|
||||||
|
return command, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateExportWrappedCommand(wrapObjID uint16, objType uint8, objID uint16) (*CommandMessage, error) {
|
||||||
|
command := &CommandMessage{
|
||||||
|
CommandType: CommandTypeExportWrapped,
|
||||||
|
}
|
||||||
|
|
||||||
|
payload := bytes.NewBuffer([]byte{})
|
||||||
|
binary.Write(payload, binary.BigEndian, wrapObjID)
|
||||||
|
binary.Write(payload, binary.BigEndian, objType)
|
||||||
|
binary.Write(payload, binary.BigEndian, objID)
|
||||||
command.Data = payload.Bytes()
|
command.Data = payload.Bytes()
|
||||||
|
|
||||||
return command, nil
|
return command, nil
|
||||||
|
|
|
@ -107,6 +107,11 @@ type (
|
||||||
SignAttestationCertResponse struct {
|
SignAttestationCertResponse struct {
|
||||||
Cert []byte
|
Cert []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExportWrappedResponse struct {
|
||||||
|
Nonce []byte
|
||||||
|
Data []byte
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseResponse parses the binary response from the card to the relevant Response type.
|
// ParseResponse parses the binary response from the card to the relevant Response type.
|
||||||
|
@ -175,6 +180,8 @@ func ParseResponse(data []byte) (Response, error) {
|
||||||
return parseGetOpaqueResponse(payload)
|
return parseGetOpaqueResponse(payload)
|
||||||
case CommandTypeAttestAsymmetric:
|
case CommandTypeAttestAsymmetric:
|
||||||
return parseAttestationCertResponse(payload)
|
return parseAttestationCertResponse(payload)
|
||||||
|
case CommandTypeExportWrapped:
|
||||||
|
return parseExportWrappedResponse(payload)
|
||||||
case ErrorResponseCode:
|
case ErrorResponseCode:
|
||||||
return nil, parseErrorResponse(payload)
|
return nil, parseErrorResponse(payload)
|
||||||
default:
|
default:
|
||||||
|
@ -397,6 +404,17 @@ func parseAttestationCertResponse(payload []byte) (Response, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseExportWrappedResponse(payload []byte) (Response, error) {
|
||||||
|
if len(payload) < 13 {
|
||||||
|
return nil, errors.New("invalid response payload length")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ExportWrappedResponse{
|
||||||
|
Nonce: payload[:13],
|
||||||
|
Data: payload[13:],
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Error formats a card error message into a human readable format
|
// Error formats a card error message into a human readable format
|
||||||
func (e *Error) Error() string {
|
func (e *Error) Error() string {
|
||||||
message := ""
|
message := ""
|
||||||
|
|
Loading…
Reference in New Issue