Temporary fix to the ADBU status call
This commit is contained in:
parent
5617dca1c9
commit
42c76a2ba1
@ -847,10 +847,31 @@ func (s *Session) walletStatus() (*walletStatus, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
status := new(walletStatus)
|
// There is an issue with ASN1 decoding that I am struggling with,
|
||||||
if _, err := asn1.UnmarshalWithParams(response.Data, status, "tag:3"); err != nil {
|
// so I unpack it manually, like is being done in the status-im
|
||||||
return nil, err
|
// card management code.
|
||||||
|
if len(response.Data) != int(response.Data[1])-1 {
|
||||||
|
return nil, fmt.Errorf("invalid response length %d", len(response.Data))
|
||||||
}
|
}
|
||||||
|
if response.Data[0] != 0xA3 {
|
||||||
|
return nil, fmt.Errorf("invalid tag %v, expected 0xA3", response.Data[0])
|
||||||
|
}
|
||||||
|
if response.Data[2] != 2 || response.Data[3] != 1 || response.Data[5] != 2 || response.Data[6] != 1 || response.Data[8] != 1 || response.Data[9] != 1 {
|
||||||
|
return nil, fmt.Errorf("invalid response tag format")
|
||||||
|
}
|
||||||
|
fmt.Println("asn1 response", response)
|
||||||
|
status := &walletStatus{
|
||||||
|
PinRetryCount: int(response.Data[4]),
|
||||||
|
PukRetryCount: int(response.Data[7]),
|
||||||
|
Initialized: (response.Data[10] == 0xff),
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if _, err := asn1.Unmarshal(response.Data, status); err != nil {
|
||||||
|
//if _, err := asn1.UnmarshalWithParams(response.Data, status, "tag:3"); err != nil {
|
||||||
|
fmt.Println("###### asn1 err", err)
|
||||||
|
return nil, err
|
||||||
|
}*/
|
||||||
return status, nil
|
return status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user