From 11bd9d2fb6478bbd5a8073d9b8025a1a0d781996 Mon Sep 17 00:00:00 2001 From: Gary Belvin Date: Mon, 1 Mar 2021 11:47:30 +0000 Subject: [PATCH] Add GetPseudoRandom Command --- commands/constructors.go | 12 ++++++++++++ commands/response.go | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/commands/constructors.go b/commands/constructors.go index caf69d7..0f3c238 100644 --- a/commands/constructors.go +++ b/commands/constructors.go @@ -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 +} diff --git a/commands/response.go b/commands/response.go index bbdf3d4..276f031 100644 --- a/commands/response.go +++ b/commands/response.go @@ -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 := ""