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