diff --git a/.gitignore b/.gitignore index 29b636a..78d47ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea -*.iml \ No newline at end of file +*.iml +*.swp diff --git a/README.md b/README.md index f69205c..7dea693 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Currently the following commands are implemented: * Echo * ChangeAuthenticationKey * Authentication & Session related commands + * GetPseudoRandom Implementing new commands is really easy. Please consult `commands/constructors.go` and `commands/response.go` for reference. 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 := ""