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 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) return parseDeriveEcdhResponse(payload)
case CommandTypeChangeAuthenticationKey: case CommandTypeChangeAuthenticationKey:
return parseChangeAuthenticationKeyResponse(payload) return parseChangeAuthenticationKeyResponse(payload)
case CommandTypeGetPseudoRandom:
return parseGetPseudoRandomResponse(payload), nil
case ErrorResponseCode: case ErrorResponseCode:
return nil, parseErrorResponse(payload) return nil, parseErrorResponse(payload)
default: default:
@ -282,6 +284,10 @@ func parseChangeAuthenticationKeyResponse(payload []byte) (Response, error) {
return &ChangeAuthenticationKeyResponse{ObjectID: objectID}, nil return &ChangeAuthenticationKeyResponse{ObjectID: objectID}, nil
} }
func parseGetPseudoRandomResponse(payload []byte) Response {
return payload
}
// 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 := ""