-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.0.6: Merge pull request #6 from CODIANZ/development
Global refactoring and test code implementation
- Loading branch information
Showing
9 changed files
with
481 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# Simple APDU handling library | ||
|
||
## Usage | ||
|
||
1. Add this repository's `include` directory to the header search path. | ||
1. Add `#include <apdu_cpp/apdu_cpp.h>` in your file. | ||
1. The library namespace is `apdu_cpp`. Add `using namespace adpu_cpp;` if necessary. | ||
|
||
|
||
## Sample | ||
|
||
```cpp | ||
#include <apdu_cpp/apdu_cpp.h> | ||
using namespace apdu_cpp; | ||
|
||
/* | ||
6F2B800205A0810205A0820139830200008410616263642D313233343536372E637274850100860100870200009000 | ||
6F 2B | ||
80 02 05A0 | ||
81 02 05A0 | ||
82 01 39 | ||
83 02 0000 | ||
84 10 616263642D313233343536372E637274 abcd-1234567.crt | ||
85 01 00 | ||
86 01 00 | ||
87 02 0000 | ||
9000 | ||
*/ | ||
int main() { | ||
auto chunk = data_chunk::from_hex_string( | ||
"6F2B800205A0810205A0820139830200008410616263642D313233343536372E637274850100860100870200009000" | ||
); | ||
auto rapdu = rapdu::create(chunk); | ||
std::cout << "status word: " << rapdu.status_word().data().to_hex_string() << std::endl; | ||
auto _tlv = rapdu.get_tlv(); | ||
std::cout << tlv_descriptor::to_string(_tlv) << std::endl; | ||
} | ||
``` | ||
|
||
```log | ||
status word: 9000 | ||
tag: 6F | ||
- class_type: application | ||
- is_constructed: true | ||
- is_primitive: false | ||
length:2B(43) | ||
value: 800205A0810205A0820139830200008410616263642D313233343536372E63727485010086010087020000 | ||
children: | ||
[0] | ||
tag: 80 | ||
- class_type: context_specific | ||
- is_constructed: false | ||
- is_primitive: true | ||
length:02(2) | ||
value: 05A0 | ||
[1] | ||
tag: 81 | ||
- class_type: context_specific | ||
- is_constructed: false | ||
- is_primitive: true | ||
length:02(2) | ||
value: 05A0 | ||
[2] | ||
tag: 82 | ||
- class_type: context_specific | ||
- is_constructed: false | ||
- is_primitive: true | ||
length:01(1) | ||
value: 39 | ||
[3] | ||
tag: 83 | ||
- class_type: context_specific | ||
- is_constructed: false | ||
- is_primitive: true | ||
length:02(2) | ||
value: 0000 | ||
[4] | ||
tag: 84 | ||
- class_type: context_specific | ||
- is_constructed: false | ||
- is_primitive: true | ||
length:10(16) | ||
value: 616263642D313233343536372E637274 | ||
[5] | ||
tag: 85 | ||
- class_type: context_specific | ||
- is_constructed: false | ||
- is_primitive: true | ||
length:01(1) | ||
value: 00 | ||
[6] | ||
tag: 86 | ||
- class_type: context_specific | ||
- is_constructed: false | ||
- is_primitive: true | ||
length:01(1) | ||
value: 00 | ||
[7] | ||
tag: 87 | ||
- class_type: context_specific | ||
- is_constructed: false | ||
- is_primitive: true | ||
length:02(2) | ||
value: 0000 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#if !defined(__apdu_cpp_h_endian__) | ||
#define __apdu_cpp_h_endian__ | ||
namespace apdu_cpp { | ||
|
||
enum class endian { | ||
big, little, unknown | ||
}; | ||
|
||
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) | ||
constexpr endian system_endian = endian::big; | ||
#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) | ||
constexpr endian system_endian = endian::little; | ||
#else | ||
constexpr endian system_endian = endian::unknown; | ||
#endif | ||
|
||
#if __cplusplus >= 201703L | ||
#define APDU_CPP_CONSTEXPR constexpr | ||
#else | ||
#define APDU_CPP_CONSTEXPR | ||
#endif | ||
|
||
} /** namespace apdu_cpp */ | ||
#endif /** !defined(__apdu_cpp_h_endian__) */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.