commands: do not check SW manually, use send_apdu_checksw()
The transport layer provides a method send_apdu_checksw to send APDUs and to be sure the SW is the expected one. Given that, there is no need to verify the SW manually. The exception of send_apdu_checksw will catch the problem and also display the SW in a human readable form. Change-Id: I9ce556ac0b7bb21c5c5a27170c32af0152255b79 Related: OS#5275
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import json
|
||||
import abc
|
||||
import string
|
||||
from io import BytesIO
|
||||
from typing import Optional, List, Dict, Any, Tuple
|
||||
|
||||
@@ -89,6 +90,20 @@ def lpad(s:str, l:int, c='f') -> str:
|
||||
def half_round_up(n:int) -> int:
|
||||
return (n + 1)//2
|
||||
|
||||
def str_sanitize(s:str) -> str:
|
||||
"""replace all non printable chars, line breaks and whitespaces, with ' ', make sure that
|
||||
there are no whitespaces at the end and at the beginning of the string.
|
||||
|
||||
Args:
|
||||
s : string to sanitize
|
||||
Returns:
|
||||
filtered result of string 's'
|
||||
"""
|
||||
|
||||
chars_to_keep = string.digits + string.ascii_letters + string.punctuation
|
||||
res = ''.join([c if c in chars_to_keep else ' ' for c in s])
|
||||
return res.strip()
|
||||
|
||||
#########################################################################
|
||||
# poor man's COMPREHENSION-TLV decoder.
|
||||
#########################################################################
|
||||
|
||||
Reference in New Issue
Block a user