Merge pull request #9 from gdbelvin/getpseudorandom
Suppport for GetPseudoRandom
This commit is contained in:
commit
fb117c8072
|
@ -1,2 +1,3 @@
|
||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
|
*.swp
|
||||||
|
|
|
@ -15,6 +15,7 @@ Currently the following commands are implemented:
|
||||||
* Echo
|
* Echo
|
||||||
* ChangeAuthenticationKey
|
* ChangeAuthenticationKey
|
||||||
* Authentication & Session related commands
|
* Authentication & Session related commands
|
||||||
|
* GetPseudoRandom
|
||||||
|
|
||||||
Implementing new commands is really easy. Please consult `commands/constructors.go` and `commands/response.go` for reference.
|
Implementing new commands is really easy. Please consult `commands/constructors.go` and `commands/response.go` for reference.
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
@ -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 := ""
|
||||||
|
|
Loading…
Reference in New Issue