diff options
author | Jack Lloyd <[email protected]> | 2017-12-29 11:52:57 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-29 11:52:57 -0500 |
commit | 121700a187df586b0181df0ac791fdd2f9cf2f0e (patch) | |
tree | 114cafcbd168291253eb675297777832edbf5bac /src/tests | |
parent | 33eead87d274cc35842389bbe591585a2cb675a3 (diff) |
Add some tests of ASN1_Pretty_Printer
The output is not fixed and may change in the future, but changes
should at least be noticed.
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/data/asn1_print/input1.der | bin | 0 -> 34 bytes | |||
-rw-r--r-- | src/tests/data/asn1_print/input2.der | bin | 0 -> 40 bytes | |||
-rwxr-xr-x | src/tests/data/asn1_print/input3.der | bin | 0 -> 402 bytes | |||
-rwxr-xr-x | src/tests/data/asn1_print/input4.der | bin | 0 -> 238 bytes | |||
-rw-r--r-- | src/tests/data/asn1_print/output1.txt | 8 | ||||
-rw-r--r-- | src/tests/data/asn1_print/output2.txt | 11 | ||||
-rw-r--r-- | src/tests/data/asn1_print/output3.txt | 20 | ||||
-rw-r--r-- | src/tests/data/asn1_print/output4.txt | 11 | ||||
-rw-r--r-- | src/tests/test_asn1.cpp | 27 |
9 files changed, 77 insertions, 0 deletions
diff --git a/src/tests/data/asn1_print/input1.der b/src/tests/data/asn1_print/input1.der Binary files differnew file mode 100644 index 000000000..35886af48 --- /dev/null +++ b/src/tests/data/asn1_print/input1.der diff --git a/src/tests/data/asn1_print/input2.der b/src/tests/data/asn1_print/input2.der Binary files differnew file mode 100644 index 000000000..0bb89d564 --- /dev/null +++ b/src/tests/data/asn1_print/input2.der diff --git a/src/tests/data/asn1_print/input3.der b/src/tests/data/asn1_print/input3.der Binary files differnew file mode 100755 index 000000000..00f09b618 --- /dev/null +++ b/src/tests/data/asn1_print/input3.der diff --git a/src/tests/data/asn1_print/input4.der b/src/tests/data/asn1_print/input4.der Binary files differnew file mode 100755 index 000000000..09a14bbb4 --- /dev/null +++ b/src/tests/data/asn1_print/input4.der diff --git a/src/tests/data/asn1_print/output1.txt b/src/tests/data/asn1_print/output1.txt new file mode 100644 index 000000000..68f7389ea --- /dev/null +++ b/src/tests/data/asn1_print/output1.txt @@ -0,0 +1,8 @@ + d= 0, l= 32: SEQUENCE + d= 1, l= 1: INTEGER 05 + d= 1, l= 6: PRINTABLE STRING string + d= 1, l= 6: SET + d= 2, l= 1: BOOLEAN true + d= 2, l= 1: INTEGER 63 + d= 1, l= 5: OCTET STRING 0000000000 + d= 1, l= 4: BIT STRING FFFFFF diff --git a/src/tests/data/asn1_print/output2.txt b/src/tests/data/asn1_print/output2.txt new file mode 100644 index 000000000..d2aa9647b --- /dev/null +++ b/src/tests/data/asn1_print/output2.txt @@ -0,0 +1,11 @@ + d= 0, l= 38: SEQUENCE + d= 1, l= 1: INTEGER + d= 1, l= 6: OCTET STRING public + d= 1, l= 25: cons [0] context + d= 2, l= 1: INTEGER 26 + d= 2, l= 1: INTEGER + d= 2, l= 1: INTEGER + d= 2, l= 14: SEQUENCE + d= 3, l= 12: SEQUENCE + d= 4, l= 8: OBJECT 1.3.6.1.2.1.1.2.0 + d= 4, l= 0: NULL diff --git a/src/tests/data/asn1_print/output3.txt b/src/tests/data/asn1_print/output3.txt new file mode 100644 index 000000000..38a5f74fb --- /dev/null +++ b/src/tests/data/asn1_print/output3.txt @@ -0,0 +1,20 @@ + d= 0, l= 397: cons [33] appl + d= 1, l= 333: cons [78] appl + d= 2, l= 1: TAG(41) 5F290100 + d= 2, l= 16: INTEGER Bx10DECVCx7fEPASS00001 + d= 2, l= 253: cons [73] appl + d= 3, l= 10: OBJECT 0.4.0.127.0.7.2.2.2.2.2 + d= 3, l= 28: BOOLEAN 811CD7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF + d= 3, l= 28: INTEGER 821C68A5E62CA9CE6C1C299803A6C1530B514E182AD8B0042A59CAD29F43 + d= 3, l= 28: BIT STRING 831C2580F63CCFE44138870713B1A92369E33E2135D266DBB372386C400B + d= 3, l= 57: OCTET STRING 8439040D9029AD2C7E5CF4340823B2A87DC68C9E4CE3174C1E6EFDEE12C07D58AA56F772C0726F24C6B89E4ECDAC24354B9E99CAA3F6D3761402CD + d= 3, l= 28: NULL 851CD7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F + d= 3, l= 57: OBJECT 8639045FE7B42614096E67E3B25675EFBBD94B9F1244B17228F109F07856D285867B1F72FA60E4929D88C0BF61035A7C3ECF17CA2C81532308C390 + d= 3, l= 1: TAG(7) 870101 + d= 2, l= 16: TAG(32) x5fx20x10DECVCAEPASS00001 + d= 2, l= 14: cons [76] appl + d= 3, l= 9: OBJECT 0.4.0.127.0.7.3.1.2.1 + d= 3, l= 1: PRINTABLE STRING 5301C1 + d= 2, l= 6: TAG(37) 5F2506000700080108 + d= 2, l= 6: TAG(36) 5F2406010000080108 + d= 1, l= 56: TAG(55) 5F37386978982008CBD24950ADBECEE03A1675660B7FAFBD2D77CF17A5D128CFD9609B5BD0518D28D4D212CAE337F4F47495EDE92C0D7D15EA657D diff --git a/src/tests/data/asn1_print/output4.txt b/src/tests/data/asn1_print/output4.txt new file mode 100644 index 000000000..ed27ed5f8 --- /dev/null +++ b/src/tests/data/asn1_print/output4.txt @@ -0,0 +1,11 @@ + d= 0, l= 235: cons [7] appl + d= 1, l= 154: cons [33] appl + d= 2, l= 92: cons [78] appl + d= 3, l= 1: TAG(41) 5F290100 + d= 3, l= 71: cons [73] appl + d= 4, l= 10: OBJECT 0.4.0.127.0.7.2.2.2.2.2 + d= 4, l= 57: OBJECT 8639044E4EC55A2E6596F030E7FA5CD42BBC034891A0A8C1EF7C1A007A8047B6D5A883C1D5E2A8FC7CE08CF7F07B063EB8EE3E2AF1836BE7DA1577 + d= 3, l= 11: TAG(32) 5F200B444531222A20237EFF20AD + d= 2, l= 56: TAG(55) 5F3738571A971D19B664F9B03AEF178D32E5EDF9DB5C4945D449D5E4AE63B102DABFF3D4DF00D1BC83BB582981D6B48ED41F89F0FC628C7F89A0F5 + d= 1, l= 16: INTEGER 4210444531222A20237EFF20AD3030303130 + d= 1, l= 56: TAG(55) 5F3738423A93F9E40B0A3488AF6F716848531A24BAB3A2613BD6D830470D2936B1F93061A00A4B6BAA9C3A180272A60F91FD975DB3CF8D8179370C diff --git a/src/tests/test_asn1.cpp b/src/tests/test_asn1.cpp index 633f57602..4e324f04d 100644 --- a/src/tests/test_asn1.cpp +++ b/src/tests/test_asn1.cpp @@ -12,6 +12,7 @@ #include <botan/asn1_str.h> #include <botan/asn1_print.h> #endif +#include <fstream> namespace Botan_Tests { @@ -290,6 +291,32 @@ class ASN1_Tests final : public Test BOTAN_REGISTER_TEST("asn1", ASN1_Tests); +class ASN1_Printer_Tests final : public Test + { + public: + std::vector<Test::Result> run() override + { + Test::Result result("ASN1_Pretty_Printer"); + + Botan::ASN1_Pretty_Printer printer; + + const size_t num_tests = 4; + + for(size_t i = 1; i <= num_tests; ++i) + { + std::string i_str = std::to_string(i); + const std::vector<uint8_t> input1 = Test::read_binary_data_file("asn1_print/input" + i_str + ".der"); + const std::string expected1 = Test::read_data_file("asn1_print/output" + i_str + ".txt"); + + result.test_eq("Test " + i_str, printer.print(input1), expected1); + } + + return {result}; + } + }; + +BOTAN_REGISTER_TEST("asn1_printer", ASN1_Printer_Tests); + #endif } |