Add GetPseudoRandom Command

This commit is contained in:
Gary Belvin 2021-03-01 11:47:30 +00:00
parent bfa73afdb9
commit 11bd9d2fb6
2 changed files with 18 additions and 0 deletions

View File

@ -236,3 +236,15 @@ func CreateChangeAuthenticationKeyCommand(objID uint16, newPassword string) (*Co
return command, nil
}
func CreateGetPseudoRandomCommand(numBytes uint16) *CommandMessage {
command := &CommandMessage{
CommandType: CommandTypeGetPseudoRandom,
}
payload := bytes.NewBuffer([]byte{})
binary.Write(payload, binary.BigEndian, numBytes)
command.Data = payload.Bytes()
return command
}

View File

@ -137,6 +137,8 @@ func ParseResponse(data []byte) (Response, error) {
return parseDeriveEcdhResponse(payload)
case CommandTypeChangeAuthenticationKey:
return parseChangeAuthenticationKeyResponse(payload)
case CommandTypeGetPseudoRandom:
return parseGetPseudoRandomResponse(payload), nil
case ErrorResponseCode:
return nil, parseErrorResponse(payload)
default:
@ -282,6 +284,10 @@ func parseChangeAuthenticationKeyResponse(payload []byte) (Response, error) {
return &ChangeAuthenticationKeyResponse{ObjectID: objectID}, nil
}
func parseGetPseudoRandomResponse(payload []byte) Response {
return payload
}
// Error formats a card error message into a human readable format
func (e *Error) Error() string {
message := ""