diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/data/x509_dn.vec | 24 | ||||
-rw-r--r-- | src/tests/test_x509_dn.cpp | 15 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/tests/data/x509_dn.vec b/src/tests/data/x509_dn.vec index ab9e2dec3..e71510dbb 100644 --- a/src/tests/data/x509_dn.vec +++ b/src/tests/data/x509_dn.vec @@ -1,8 +1,29 @@ [Equal] +# Empty +DN1 = 3000 +DN2 = 3000 + +# Equal binary DN1 = 301C310B3009060355040613025654310D300B0603550403130454455354 DN2 = 301C310B3009060355040613025654310D300B0603550403130454455354 +# Different string types, same contents +DN1 = 302E3111300F06035504061C0800000056000000543119301706035504031C1000000054000000450000005300000054 +DN2 = 301C310B3009060355040613025654310D300B0603550403130454455354 + +# Same contents, different casing (X.500 demands case-insensitive), different order +DN1 = 301C310B3009060355040613025654310D300B0603550403130454455354 +DN2 = 301C310D300B0603550403130474457354310B3009060355040613027674 + +# Empty, different encodings +DN1 = 3000 +DN2 = 3080 + +# Empty, one using EOC encoding +DN1 = 0000308100 +DN2 = 3000 + [Unequal] DN1 = 301C310B3009060355040613025654310D300B0603550403130454450054 DN2 = 301C310B3009060355040613025600310D300B0603550403130454455354 @@ -12,3 +33,6 @@ DN2 = 3019311730150603550403130E4141202020202020202020202020 DN1 = 3018311630140603550403130D41412041414141414141414141 DN2 = 3019311730150603550403130E4141202020202020202020202020 + +DN1 = 3080318030800604307A7AFD1E808080300080208080800F0029000B800000000001000000D60680FF7FFFFF00040404040404040404040404230404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404000000 +DN2 = 000000000000000000000000000000000000000030803180308006047A7A30FD1E808080300080208080810F0000000B800000000001000000D60680FF7FFF040404040404040404040404040404040404040404040404000000000000000404040404040404040404890880 diff --git a/src/tests/test_x509_dn.cpp b/src/tests/test_x509_dn.cpp index 662c11e74..7e93d2c24 100644 --- a/src/tests/test_x509_dn.cpp +++ b/src/tests/test_x509_dn.cpp @@ -23,6 +23,7 @@ class X509_DN_Comparisons_Tests final : public Text_Based_Test { const std::vector<uint8_t> dn_bits1 = vars.get_req_bin("DN1"); const std::vector<uint8_t> dn_bits2 = vars.get_req_bin("DN2"); + const bool dn_same = (type == "Equal"); Test::Result result("X509_DN comparisons"); @@ -38,6 +39,20 @@ class X509_DN_Comparisons_Tests final : public Text_Based_Test const bool compared_same = (dn1 == dn2); result.test_eq("Comparison matches expected", dn_same, compared_same); + + const bool lt1 = (dn1 < dn2); + const bool lt2 = (dn2 < dn1); + + if(dn_same) + { + result.test_eq("same means neither is less than", lt1, false); + result.test_eq("same means neither is less than", lt2, false); + } + else + { + result.test_eq("different means one is less than", lt1 || lt2, true); + result.test_eq("different means only one is less than", lt1 && lt2, false); + } } catch(Botan::Exception& e) { |