|
|
|
@ -128,17 +128,21 @@ namespace cardos { |
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
class BerValue { |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
enum Class { |
|
|
|
|
UNIVERSAL = 0x00, |
|
|
|
|
APPLICATION = 0x40, |
|
|
|
|
CONTEXT_SPECIFIC = 0x80, |
|
|
|
|
PRIVATE = 0xC0 |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
enum PC { |
|
|
|
|
PRIMITIVE = 0x00, |
|
|
|
|
CONSTRUCTED = 0x20 |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
enum Type { |
|
|
|
|
END_OF_CONTENT = 0x00, |
|
|
|
|
BOOLEAN = 0x01, |
|
|
|
@ -181,6 +185,10 @@ namespace cardos { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BerValue(std::string& content) { |
|
|
|
|
set(content); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void set(std::string& content) { |
|
|
|
|
if (content.size()<2) |
|
|
|
|
throw wrong_dataformat(content, "not a BER, header size too small: \"" |
|
|
|
|
+crypto::binToHex(content)+"\""); |
|
|
|
@ -198,6 +206,11 @@ namespace cardos { |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
BerValue(const std::string& content) { |
|
|
|
|
std::string contentCopy(content); |
|
|
|
|
set(contentCopy); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BerValue(unsigned char t, const std::string& v): |
|
|
|
|
_tag(t), _value(v) { |
|
|
|
|
if (isContainer()) |
|
|
|
@ -274,7 +287,8 @@ namespace cardos { |
|
|
|
|
|
|
|
|
|
std::string print(int indent=0, int indentStep = 4) { |
|
|
|
|
std::stringstream ss; |
|
|
|
|
ss<<std::string(indent*indentStep, ' ')<<'['<<crypto::binToHex(_tag)<<'='; |
|
|
|
|
ss<<std::string(indent*indentStep, ' ')<<'['<<crypto::binToHex(_tag) |
|
|
|
|
<<'='; |
|
|
|
|
switch (tagClass()) { |
|
|
|
|
case UNIVERSAL: ss<<"UNIVERSAL,"; break; |
|
|
|
|
case APPLICATION: ss<<"APPLICATION,"; break; |
|
|
|
@ -1471,8 +1485,8 @@ namespace cardos { |
|
|
|
|
return "No return code received"; |
|
|
|
|
default: |
|
|
|
|
std::stringstream ss; |
|
|
|
|
if ((ret&&0xff00)==0x6100) |
|
|
|
|
ss<<(ret&&0xff)<<" bytes of response data can be received" |
|
|
|
|
if ((ret&0xff00)==0x6100) |
|
|
|
|
ss<<(ret&0xff)<<" bytes of response data can be received" |
|
|
|
|
<<" with GET RESPONSE (only T=0 transmission protocol)"; |
|
|
|
|
else |
|
|
|
|
ss<<"Unknown CardOS error code: 0x"<<std::hex<<ret; |
|
|
|
|