aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tests/data/x509test/cyrillic.pem24
-rw-r--r--src/tests/test_asn1.cpp4
-rw-r--r--src/tests/unit_x509.cpp35
3 files changed, 61 insertions, 2 deletions
diff --git a/src/tests/data/x509test/cyrillic.pem b/src/tests/data/x509test/cyrillic.pem
new file mode 100644
index 000000000..ddcd4b046
--- /dev/null
+++ b/src/tests/data/x509test/cyrillic.pem
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIID9DCCAtwCCQD6cbgDx1XA/jANBgkqhkiG9w0BAQUFADCBuzEkMCIGA1UEAwwb
+0J7Qv9C40YHQsNC90LjQtSDRgdCw0LnRgtCwMSEwHwYJKoZIhvcNAQkBFhJ0ZXN0
+QHJhbmRvbWNvcnAucnUxIDAeBgNVBAoMF9Cc0L7RjyDQutC+0LzQv9Cw0L3QuNGP
+MSowKAYDVQQLDCHQnNC+0ZEg0L/QvtC00YDQsNC30LTQtdC70LXQvdC40LUxFTAT
+BgNVBAcMDNCc0L7RgdC60LLQsDELMAkGA1UEBhMCUlUwHhcNMTcxMDExMjAzNTQ5
+WhcNMTgxMDExMjAzNTQ5WjCBuzEkMCIGA1UEAwwb0J7Qv9C40YHQsNC90LjQtSDR
+gdCw0LnRgtCwMSEwHwYJKoZIhvcNAQkBFhJ0ZXN0QHJhbmRvbWNvcnAucnUxIDAe
+BgNVBAoMF9Cc0L7RjyDQutC+0LzQv9Cw0L3QuNGPMSowKAYDVQQLDCHQnNC+0ZEg
+0L/QvtC00YDQsNC30LTQtdC70LXQvdC40LUxFTATBgNVBAcMDNCc0L7RgdC60LLQ
+sDELMAkGA1UEBhMCUlUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDL
+K3xsfEoH/+mjq3scoZ6TfKvlTugzjOSirenGsSdw6IuxEy6ywEFb9YDSKyvMSDOG
+LhbotiKvn3n9WwKYhEMkNhMJDavb4s+CRYPtM4iBhzO3gTuNMqBAjKayykOWWNEq
+b6lgRivfo62iCetvp0zoXHVEyomfSUCl11sQ21etwOdnloocyRqKfDHHp2jO5J0g
+0HEQx2klxuivDU3lpEHRhH4cE5zUMStOdXaHm5nYnPUYnSrFinGLE01l7/MXsJwX
+AOVwBv3ErIh173KuwtyPci8AK16UNQqqvGy9QDEvH3TxMxrl7416K/iqCZg5d0FG
+HmsAbrGfT9pUA3IScSphAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAHM8W84yxiIV
+o87x6usP+BCQ5T7IIb7NgjnseJUS+dl0gJEyFdLBa4mz5FDdtaYEi3firc3NOJ6l
+yA4kEQ49k4I3yaDEjMuc1+qpzThdtC/+cycLCYuoaYxR/kx4/zoLcELsk8rud9Dq
+8N6g7q7MR6Nno3to3kHzrka/P0W6X8jfWmYm2RDTKhBPlcobTvgIyupn6uadWhY8
+Ahte186a2ylV/feFHIBuFr9jLzWKPMQm6MmPv86ZatdfqSNOU/YtKAQyLouoT45b
+urVwAyOlYDyiXsTfzTcsOAa9sHHAzofK2E+tZ0gY3s7JT1kEWVG5XoJWx+hKM5Ht
+hGah1kV664Y=
+-----END CERTIFICATE-----
diff --git a/src/tests/test_asn1.cpp b/src/tests/test_asn1.cpp
index a034a64ce..eae1d96f8 100644
--- a/src/tests/test_asn1.cpp
+++ b/src/tests/test_asn1.cpp
@@ -82,7 +82,7 @@ Test::Result test_asn1_utf8_parsing()
{
// \x0C - ASN1 tag for 'UTF8 string'
// \x0C - 12 characters of payload
- // ... - UTF-8 encoded russian word for Moscow in cyrilic script
+ // ... - UTF-8 encoded russian word for Moscow in cyrillic script
const std::string moscow =
"\x0C\x0C\xD0\x9C\xD0\xBE\xD1\x81\xD0\xBA\xD0\xB2\xD0\xB0";
Botan::DataSource_Memory input(moscow.data());
@@ -138,7 +138,7 @@ Test::Result test_asn1_utf8_encoding()
try
{
- // UTF-8 encoded russian word for Moscow in cyrilic script
+ // UTF-8 encoded russian word for Moscow in cyrillic script
const std::string moscow =
"\xD0\x9C\xD0\xBE\xD1\x81\xD0\xBA\xD0\xB2\xD0\xB0";
Botan::ASN1_String str(moscow);
diff --git a/src/tests/unit_x509.cpp b/src/tests/unit_x509.cpp
index b9aa1709e..dd16e4988 100644
--- a/src/tests/unit_x509.cpp
+++ b/src/tests/unit_x509.cpp
@@ -358,6 +358,40 @@ Test::Result test_x509_dates()
return result;
}
+Test::Result test_x509_utf8()
+ {
+ Test::Result result("X509 with UTF-8 encoded fields");
+
+ try
+ {
+ Botan::X509_Certificate utf8_cert(Test::data_file("x509test/cyrillic.pem"));
+
+ // UTF-8 encoded fields of test certificate (contains cyrillic letters)
+ const std::string organization =
+ "\xD0\x9C\xD0\xBE\xD1\x8F\x20\xD0\xBA\xD0\xBE\xD0"
+ "\xBC\xD0\xBF\xD0\xB0\xD0\xBD\xD0\xB8\xD1\x8F";
+ const std::string organization_unit =
+ "\xD0\x9C\xD0\xBE\xD1\x91\x20\xD0\xBF\xD0\xBE\xD0\xB4\xD1\x80\xD0\xB0"
+ "\xD0\xB7\xD0\xB4\xD0\xB5\xD0\xBB\xD0\xB5\xD0\xBD\xD0\xB8\xD0\xB5";
+ const std::string common_name =
+ "\xD0\x9E\xD0\xBF\xD0\xB8\xD1\x81\xD0\xB0\xD0\xBD\xD0\xB8"
+ "\xD0\xB5\x20\xD1\x81\xD0\xB0\xD0\xB9\xD1\x82\xD0\xB0";
+ const std::string location =
+ "\xD0\x9C\xD0\xBE\xD1\x81\xD0\xBA\xD0\xB2\xD0\xB0";
+
+ result.test_eq("O", utf8_cert.issuer_info("O").at(0), organization);
+ result.test_eq("OU", utf8_cert.issuer_info("OU").at(0), organization_unit);
+ result.test_eq("CN", utf8_cert.issuer_info("CN").at(0), common_name);
+ result.test_eq("L", utf8_cert.issuer_info("L").at(0), location);
+ }
+ catch (const Botan::Decoding_Error &ex)
+ {
+ result.test_failure(ex.what());
+ }
+
+ return result;
+ }
+
Test::Result test_x509_cert(const std::string& sig_algo, const std::string& hash_fn = "SHA-256")
{
Test::Result result("X509 Unit");
@@ -1135,6 +1169,7 @@ class X509_Cert_Unit_Tests final : public Test
results.push_back(test_x509_dates());
results.push_back(test_cert_status_strings());
results.push_back(test_hashes("ECDSA"));
+ results.push_back(test_x509_utf8());
return results;
}