diff options
Diffstat (limited to 'tests/dane.c')
-rw-r--r-- | tests/dane.c | 607 |
1 files changed, 573 insertions, 34 deletions
diff --git a/tests/dane.c b/tests/dane.c index 3c8ca58631..941b2b58f9 100644 --- a/tests/dane.c +++ b/tests/dane.c @@ -32,67 +32,606 @@ #include "utils.h" -char * const data_entries[] = { - (char*)"\x00\x00\x01\x19\x40\x0b\xe5\xb7\xa3\x1f\xb7\x33\x91\x77\x00\x78\x9d\x2f\x0a\x24\x71\xc0\xc9\xd5\x06\xc0\xe5\x04\xc0\x6c\x16\xd7\xcb\x17\xc0", - (char*)"\x03\x00\x01\x03\x32\xaa\x2d\x58\xb3\xe0\x54\x4b\x65\x65\x64\x38\x93\x70\x68\xba\x44\xce\x2f\x14\x46\x9c\x4f\x50\xc9\xcc\x69\x33\xc8\x08\xd3", - (char*)"\x03\x01\x01\x46\x25\x73\x19\x5c\x86\xe8\x61\xab\xab\x8e\xcc\xfb\xc7\xf0\x48\x69\x58\xef\xdf\xf9\x44\x9a\xc1\x07\x29\xb3\xa0\xf9\x06\xf3\x88", - NULL +#define MAX_QUERIES 8 + +struct data_entry_st { + const char *name; + char *const queries[MAX_QUERIES]; + int q_size[MAX_QUERIES]; + int expected_ret; + unsigned no_queries; + int secure; + int bogus; + const char *cert; + const char *ca; + unsigned expected_status; /* if cert is non-null */ + int expected_verify_ret; /* if cert is non-null */ }; -int data_entries_size[] = { - 35, - 35, - 35, - 0 +const struct data_entry_st data_entries[] = { + { + .name = "Entry parsing", + .queries = { + (char *) + "\x00\x00\x01\x19\x40\x0b\xe5\xb7\xa3\x1f\xb7\x33\x91\x77\x00\x78\x9d\x2f\x0a\x24\x71\xc0\xc9\xd5\x06\xc0\xe5\x04\xc0\x6c\x16\xd7\xcb\x17\xc0", + (char *) + "\x03\x00\x01\x03\x32\xaa\x2d\x58\xb3\xe0\x54\x4b\x65\x65\x64\x38\x93\x70\x68\xba\x44\xce\x2f\x14\x46\x9c\x4f\x50\xc9\xcc\x69\x33\xc8\x08\xd3", + (char *) + "\x03\x01\x01\x46\x25\x73\x19\x5c\x86\xe8\x61\xab\xab\x8e\xcc\xfb\xc7\xf0\x48\x69\x58\xef\xdf\xf9\x44\x9a\xc1\x07\x29\xb3\xa0\xf9\x06\xf3\x88", + NULL}, + .q_size = { + 35, + 35, + 35, + 0}, + .expected_ret = 0, + .no_queries = 3, + .secure = 1, + .bogus = 0 + }, + { /* as the previous but with first byte invalid */ + .name = "Cert verification (single entry)", + .queries = { + (char *) + "\x03\x01\x01\x54\x4f\x28\x4d\x66\xaf\x2d\xe0\x8c\x17\xe7\x48\x6a\xed\xfa\x2e\x00\xaa\x1a\xc6\xbb\xf3\xaf\x5c\xa6\x2b\x55\xab\x7a\xc2\x69\xbe", + NULL}, + .q_size = { + 35, + 35, + 35, + 0}, + .expected_ret = 0, + .no_queries = 1, + .secure = 1, + .bogus = 0, + .expected_verify_ret = 0, + .expected_status = 0, + .cert = "-----BEGIN CERTIFICATE-----\n" + "MIIE+DCCA+CgAwIBAgISESHVV5p9ybDcuT+A7ITU5IQYMA0GCSqGSIb3DQEBCwUA\n" + "MGAxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTYwNAYD\n" + "VQQDEy1HbG9iYWxTaWduIERvbWFpbiBWYWxpZGF0aW9uIENBIC0gU0hBMjU2IC0g\n" + "RzIwHhcNMTUxMDIxMDkxOTAwWhcNMTYxMjE4MTY1NDU2WjA8MSEwHwYDVQQLExhE\n" + "b21haW4gQ29udHJvbCBWYWxpZGF0ZWQxFzAVBgNVBAMMDioubmxuZXRsYWJzLm5s\n" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzHpmwd7SC6vLKde0IcYD\n" + "rrVcSSZFNrmP6Wtw5rR7KTBGfj70lCzo1Tu4KzOeFL23cB/Y8kWPojw73eYM+lnr\n" + "woZmdG28q+nYeZYRNjFpeLmwK87bpWxw760FrdQSdPrgM9uZS02AWD8PWIW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Szl+RqNinvM2VjkjreWP2AFmIvbZxjMQDAtSs+5l1Qd+xR3Qxrim\n" + "5XFIaS7lR8ediLKO0trf7TcbXYZ72u3pxVxm7y2Vzi4mC+lcEcc6409b1yeSRbx/\n" + "9N6pYa8Uk3ZaeR6hZHx/g448vVwAqmKrsyJZOayDwHxrFeFWPfJSrFlT8kLmkr5A\n" + "VKOWjR5fslCGWqONiFHhyujZocIw03v5+kD9lw==\n" + "-----END CERTIFICATE-----\n" + }, + { + .name = "Cert verification (multi entries)", + .queries = { + (char *) + "\x00\x00\x01\x19\x40\x0b\xe5\xb7\xa3\x1f\xb7\x33\x91\x77\x00\x78\x9d\x2f\x0a\x24\x71\xc0\xc9\xd5\x06\xc0\xe5\x04\xc0\x6c\x16\xd7\xcb\x17\xc0", + (char *) + "\x03\x01\x01\x54\x4f\x28\x4d\x66\xaf\x2d\xe0\x8c\x17\xe7\x48\x6a\xed\xfa\x2e\x00\xaa\x1a\xc6\xbb\xf3\xaf\x5c\xa6\x2b\x55\xab\x7a\xc2\x69\xbe", + (char *) + "\x03\x00\x01\x03\x32\xaa\x2d\x58\xb3\xe0\x54\x4b\x65\x65\x64\x38\x93\x70\x68\xba\x44\xce\x2f\x14\x46\x9c\x4f\x50\xc9\xcc\x69\x33\xc8\x08\xd3", + NULL}, + .q_size = { + 35, + 35, + 35, + 0}, + .expected_ret = 0, + .no_queries = 3, + .secure = 1, + .bogus = 0, + .expected_verify_ret = 0, + .expected_status = 0, + .cert = "-----BEGIN CERTIFICATE-----\n" + "MIIE+DCCA+CgAwIBAgISESHVV5p9ybDcuT+A7ITU5IQYMA0GCSqGSIb3DQEBCwUA\n" + "MGAxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTYwNAYD\n" + "VQQDEy1HbG9iYWxTaWduIERvbWFpbiBWYWxpZGF0aW9uIENBIC0gU0hBMjU2IC0g\n" + "RzIwHhcNMTUxMDIxMDkxOTAwWhcNMTYxMjE4MTY1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Z24uY29tL2dzZG9tYWludmFsc2hhMmcyMB0GA1UdDgQWBBR8k4wtqr2L7in153sI\n" + "aE9Eo+ZB5zAfBgNVHSMEGDAWgBTqTnzUgC3lFYGGJoyCbcCYpM+XDzANBgkqhkiG\n" + "9w0BAQsFAAOCAQEAHgjG+iHJ8INGp/J0VskjmMItSdcTJhsQbAf1Pz1eu87cXhFa\n" + "Vro1xRN9KcsKhnd6TbflDpZkM0g9kX1nGZUWLxMmDbx6N/Y+0X9XHBkgTcVgo1gn\n" + "DkzBfMq/Qmy6Szl+RqNinvM2VjkjreWP2AFmIvbZxjMQDAtSs+5l1Qd+xR3Qxrim\n" + "5XFIaS7lR8ediLKO0trf7TcbXYZ72u3pxVxm7y2Vzi4mC+lcEcc6409b1yeSRbx/\n" + "9N6pYa8Uk3ZaeR6hZHx/g448vVwAqmKrsyJZOayDwHxrFeFWPfJSrFlT8kLmkr5A\n" + "VKOWjR5fslCGWqONiFHhyujZocIw03v5+kD9lw==\n" + "-----END CERTIFICATE-----\n" + }, + { + .name = "Cert verification (invalid hash)", + .queries = { + (char *) + "\x03\x01\x01\x54\x4f\x28\x4d\x66\xaf\x2d\xe0\x8c\x17\xe7\x49\x6a\xed\xfa\x2e\x00\xaa\x1a\xc6\xbb\xf3\xaf\x5c\xa6\x2b\x55\xab\x7a\xc2\x69\xbe", + NULL}, + .q_size = { + 35, + 0}, + .expected_ret = 0, + .no_queries = 1, + .secure = 1, + .bogus = 0, + .expected_verify_ret = 0, + .expected_status = DANE_VERIFY_CERT_DIFFERS, + .cert = "-----BEGIN CERTIFICATE-----\n" + "MIIE+DCCA+CgAwIBAgISESHVV5p9ybDcuT+A7ITU5IQYMA0GCSqGSIb3DQEBCwUA\n" + "MGAxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTYwNAYD\n" + "VQQDEy1HbG9iYWxTaWduIERvbWFpbiBWYWxpZGF0aW9uIENBIC0gU0hBMjU2IC0g\n" + "RzIw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wAYYtaHR0cDovL29jc3AyLmdsb2JhbHNp\n" + "Z24uY29tL2dzZG9tYWludmFsc2hhMmcyMB0GA1UdDgQWBBR8k4wtqr2L7in153sI\n" + "aE9Eo+ZB5zAfBgNVHSMEGDAWgBTqTnzUgC3lFYGGJoyCbcCYpM+XDzANBgkqhkiG\n" + "9w0BAQsFAAOCAQEAHgjG+iHJ8INGp/J0VskjmMItSdcTJhsQbAf1Pz1eu87cXhFa\n" + "Vro1xRN9KcsKhnd6TbflDpZkM0g9kX1nGZUWLxMmDbx6N/Y+0X9XHBkgTcVgo1gn\n" + "DkzBfMq/Qmy6Szl+RqNinvM2VjkjreWP2AFmIvbZxjMQDAtSs+5l1Qd+xR3Qxrim\n" + "5XFIaS7lR8ediLKO0trf7TcbXYZ72u3pxVxm7y2Vzi4mC+lcEcc6409b1yeSRbx/\n" + "9N6pYa8Uk3ZaeR6hZHx/g448vVwAqmKrsyJZOayDwHxrFeFWPfJSrFlT8kLmkr5A\n" + "VKOWjR5fslCGWqONiFHhyujZocIw03v5+kD9lw==\n" + "-----END CERTIFICATE-----\n" + }, + { + .name = "Cert verification (bogus data)", + .queries = { + (char *) + "\x00\x00\x01\x19\x40\x0b\xe5\xb7\xa3\x1f\xb7\x33\x91\x77\x00\x78\x9d\x2f\x0a\x24\x71\xc0\xc9\xd5\x06\xc0\xe5\x04\xc0\x6c\x16\xd7\xcb\x17\xc0", + NULL}, + .q_size = { + 35, + 0}, + .expected_ret = 0, + .no_queries = 1, + .secure = 1, + .bogus = 0, + .expected_verify_ret = DANE_E_REQUESTED_DATA_NOT_AVAILABLE, + .expected_status = -1, + .cert = "-----BEGIN CERTIFICATE-----\n" + "MIIE+DCCA+CgAwIBAgISESHVV5p9ybDcuT+A7ITU5IQYMA0GCSqGSIb3DQEBCwUA\n" + "MGAxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTYwNAYD\n" + "VQQDEy1HbG9iYWxTaWduIERvbWFpbiBW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FpbnZh\n" + "bHNoYTJnMnIxLmNydDA5BggrBgEFBQcwAYYtaHR0cDovL29jc3AyLmdsb2JhbHNp\n" + "Z24uY29tL2dzZG9tYWludmFsc2hhMmcyMB0GA1UdDgQWBBR8k4wtqr2L7in153sI\n" + "aE9Eo+ZB5zAfBgNVHSMEGDAWgBTqTnzUgC3lFYGGJoyCbcCYpM+XDzANBgkqhkiG\n" + "9w0BAQsFAAOCAQEAHgjG+iHJ8INGp/J0VskjmMItSdcTJhsQbAf1Pz1eu87cXhFa\n" + "Vro1xRN9KcsKhnd6TbflDpZkM0g9kX1nGZUWLxMmDbx6N/Y+0X9XHBkgTcVgo1gn\n" + "DkzBfMq/Qmy6Szl+RqNinvM2VjkjreWP2AFmIvbZxjMQDAtSs+5l1Qd+xR3Qxrim\n" + "5XFIaS7lR8ediLKO0trf7TcbXYZ72u3pxVxm7y2Vzi4mC+lcEcc6409b1yeSRbx/\n" + "9N6pYa8Uk3ZaeR6hZHx/g448vVwAqmKrsyJZOayDwHxrFeFWPfJSrFlT8kLmkr5A\n" + "VKOWjR5fslCGWqONiFHhyujZocIw03v5+kD9lw==\n" + "-----END CERTIFICATE-----\n" + }, + { + .name = "CA verification (valid)", + .queries = { + (char*)"\x00\x00\x01\x19\x40\x0b\xe5\xb7\xa3\x1f\xb7\x33\x91\x77\x00\x78\x9d\x2f\x0a\x24\x71\xc0\xc9\xd5\x06\xc0\xe5\x04\xc0\x6c\x16\xd7\xcb\x17\xc0", + NULL}, + .q_size = { + 35, + 0}, + .expected_ret = 0, + .no_queries = 1, + .secure = 1, + .bogus = 0, + .expected_verify_ret = 0, + .expected_status = 0, + .cert = "-----BEGIN CERTIFICATE-----\n" + "MIIGXjCCBUagAwIBAgIQBNO3A71kyzonos0JsLRHrjANBgkqhkiG9w0BAQsFADBw\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMS8wL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dBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIw\n" + "NAYIKwYBBQUHAQEEKDAmMCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5kaWdpY2Vy\n" + "dC5jb20wSwYDVR0fBEQwQjBAoD6gPIY6aHR0cDovL2NybDQuZGlnaWNlcnQuY29t\n" + "L0RpZ2lDZXJ0SGlnaEFzc3VyYW5jZUVWUm9vdENBLmNybDA9BgNVHSAENjA0MDIG\n" + "BFUdIAAwKjAoBggrBgEFBQcCARYcaHR0cHM6Ly93d3cuZGlnaWNlcnQuY29tL0NQ\n" + "UzAdBgNVHQ4EFgQUUWj/kK8CB3U8zNllZGKiErhZcjswHwYDVR0jBBgwFoAUsT7D\n" + "aQP4v0cB1JgmGggC72NkK8MwDQYJKoZIhvcNAQELBQADggEBABiKlYkD5m3fXPwd\n" + "aOpKj4PWUS+Na0QWnqxj9dJubISZi6qBcYRb7TROsLd5kinMLYBq8I4g4Xmk/gNH\n" + "E+r1hspZcX30BJZr01lYPf7TMSVcGDiEo+afgv2MW5gxTs14nhr9hctJqvIni5ly\n" + "/D6q1UEL2tU2ob8cbkdJf17ZSHwD2f2LSaCYJkJA69aSEaRkCldUxPUd1gJea6zu\n" + "xICaEnL6VpPX/78whQYwvwt/Tv9XBZ0k7YXDK/umdaisLRbvfXknsuvCnQsH6qqF\n" + "0wGjIChBWUMo0oHjqvbsezt3tkBigAVBRQHvFwY+3sAzm2fTYS5yh+Rp/BIAV0Ae\n" + "cPUeybQ=\n" + "-----END CERTIFICATE-----\n" + }, + { + .name = "CA verification (invalid)", + .queries = { + (char*)"\x00\x00\x01\x19\x40\x0b\xe5\xb7\xa3\x1f\xb7\x33\x92\x77\x00\x78\x9d\x2f\x0a\x24\x71\xc0\xc9\xd5\x06\xc0\xe5\x04\xc0\x6c\x16\xd7\xcb\x17\xc0", + NULL}, + .q_size = { + 35, + 0}, + .expected_ret = 0, + .no_queries = 1, + .secure = 1, + .bogus = 0, + .expected_verify_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}, + { /* as the previous but with first byte invalid */ + .name = "CA verification (multiple entries)", + .queries = { + (char *) + "\x00\x00\x01\x19\x40\x0b\xe5\xb7\xa3\x1f\xb7\x33\x91\x77\x00\x78\x9d\x2f\x0a\x24\x71\xc0\xc9\xd5\x06\xc0\xe5\x04\xc0\x6c\x16\xd7\xcb\x17\xc0", + (char *) + "\x03\x01\x01\x54\x4f\x28\x4d\x66\xaf\x2d\xe0\x8c\x17\xe7\x48\x6a\xed\xfa\x2e\x00\xaa\x1a\xc6\xbb\xf3\xaf\x5c\xa6\x2b\x55\xab\x7a\xc2\x69\xbe", + (char *) + "\x00\x00\x01\x19\x40\x0b\xe5\xb7\xa3\x1f\xb7\x33\x91\x77\x00\x78\x9d\x2f\x0a\x24\x71\xc0\xc9\xd5\x06\xc0\xe5\x04\xc0\x6c\x16\xd7\xcb\x17\xc0", + (char*) + "\x03\x00\x01\x03\x32\xaa\x2d\x58\xb3\xe0\x54\x4b\x65\x65\x64\x38\x93\x70\x68\xba\x44\xce\x2f\x14\x46\x9c\x4f\x50\xc9\xcc\x69\x33\xc8\x08\xd3", + NULL}, + .q_size = { + 35, + 35, + 35, + 35, + 0}, + .expected_ret = 0, + .no_queries = 4, + .secure = 1, + .bogus = 0, + .expected_verify_ret = 0, + .expected_status = 0, + .cert = "-----BEGIN CERTIFICATE-----\n" + "MIIGXjCCBUagAwIBAgIQBNO3A71kyzonos0JsLRHrjANBgkqhkiG9w0BAQsFADBw\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMS8wLQYDVQQDEyZEaWdpQ2VydCBTSEEyIEhpZ2ggQXNz\n" + "dXJhbmNlIFNlcnZlciBDQTAeFw0xNDA0MjIwMDAwMDBaFw0xNzA0MjYxMjAwMDBa\n" + "MG0xCzAJBgNVBAYTAlVTMRcwFQYDVQQIEw5Ob3J0aCBDYXJvbGluYTEQMA4GA1UE\n"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RpZ2lDZXJ0SGlnaEFzc3VyYW5jZUVWUm9vdENBLmNybDA9BgNVHSAENjA0MDIG\n" + "BFUdIAAwKjAoBggrBgEFBQcCARYcaHR0cHM6Ly93d3cuZGlnaWNlcnQuY29tL0NQ\n" + "UzAdBgNVHQ4EFgQUUWj/kK8CB3U8zNllZGKiErhZcjswHwYDVR0jBBgwFoAUsT7D\n" + "aQP4v0cB1JgmGggC72NkK8MwDQYJKoZIhvcNAQELBQADggEBABiKlYkD5m3fXPwd\n" + "aOpKj4PWUS+Na0QWnqxj9dJubISZi6qBcYRb7TROsLd5kinMLYBq8I4g4Xmk/gNH\n" + "E+r1hspZcX30BJZr01lYPf7TMSVcGDiEo+afgv2MW5gxTs14nhr9hctJqvIni5ly\n" + "/D6q1UEL2tU2ob8cbkdJf17ZSHwD2f2LSaCYJkJA69aSEaRkCldUxPUd1gJea6zu\n" + "xICaEnL6VpPX/78whQYwvwt/Tv9XBZ0k7YXDK/umdaisLRbvfXknsuvCnQsH6qqF\n" + "0wGjIChBWUMo0oHjqvbsezt3tkBigAVBRQHvFwY+3sAzm2fTYS5yh+Rp/BIAV0Ae\n" + "cPUeybQ=\n" + "-----END CERTIFICATE-----\n" + } }; +static time_t mytime(time_t * t) +{ + time_t then = 1461671166; + + if (t) + *t = then; + + return then; +} + +static void crt_to_der(gnutls_datum_t *chain, const char *pem, unsigned size) +{ + int ret; + gnutls_x509_crt_t crt; + gnutls_datum_t input = {(void*)pem, size}; + + gnutls_x509_crt_init(&crt); + + ret = gnutls_x509_crt_import(crt, &input, GNUTLS_X509_FMT_PEM); + if (ret < 0) { + fail("%d: %s\n", __LINE__, gnutls_strerror(ret)); + exit(1); + } + + ret = gnutls_x509_crt_export2(crt, GNUTLS_X509_FMT_DER, chain); + if (ret < 0) { + fail("%d: %s\n", __LINE__, gnutls_strerror(ret)); + exit(1); + } + + gnutls_x509_crt_deinit(crt); +} + static void dane_raw_check(void) { dane_state_t s; dane_query_t r; int ret; - unsigned int entries, i; + unsigned int entries, i, j; char **r_data; int *r_data_len; int secure; int bogus; + gnutls_global_set_time_function(mytime); + ret = dane_state_init(&s, DANE_F_IGNORE_LOCAL_RESOLVER); if (ret < 0) { fail("dane_state_init: %s\n", dane_strerror(ret)); } - ret = dane_raw_tlsa(s, &r, data_entries, data_entries_size, 1, 0); - if (ret < 0) { - fail("%d: %s\n", __LINE__, dane_strerror(ret)); - } + for (j = 0; j < sizeof(data_entries) / sizeof(data_entries[0]); j++) { + if (debug) + success("running test[%d]: %s\n", j, data_entries[j].name); - ret = dane_query_to_raw_tlsa(r, &entries, &r_data, &r_data_len, &secure, &bogus); - if (ret < 0) { - fail("%d: %s\n", __LINE__, dane_strerror(ret)); - } + ret = + dane_raw_tlsa(s, &r, data_entries[j].queries, + data_entries[j].q_size, data_entries[j].secure, + data_entries[j].bogus); + if (ret != data_entries[j].expected_ret) { + fail("test[%d]: %d: %s\n", j, __LINE__, dane_strerror(ret)); + } - if (entries != 3) - fail("%d: %s\n", __LINE__, dane_strerror(ret)); + ret = + dane_query_to_raw_tlsa(r, &entries, &r_data, &r_data_len, + &secure, &bogus); + if (ret < 0) { + fail("test[%d]: %d: %s\n", j, __LINE__, dane_strerror(ret)); + } - if (secure != 1) - fail("%d: %s\n", __LINE__, dane_strerror(ret)); + if (entries != data_entries[j].no_queries) + fail("test[%d]: %d\n", j, __LINE__); - if (bogus != 0) - fail("%d: %s\n", __LINE__, dane_strerror(ret)); + if (secure != data_entries[j].secure) + fail("test[%d]: %d\n", j, __LINE__); - for (i=0;i<entries;i++) { - if (r_data_len[i] != data_entries_size[i]) - fail("%d: %s\n", __LINE__, dane_strerror(ret)); + if (bogus != data_entries[j].bogus) + fail("test[%d]: %d\n", j, __LINE__); - if (memcmp(r_data[i], data_entries[i], r_data_len[i]) != 0) - fail("%d: %s\n", __LINE__, dane_strerror(ret)); - } + for (i = 0; i < entries; i++) { + if (r_data_len[i] != data_entries[j].q_size[i]) + fail("test[%d]: %d: %s\n", j, __LINE__, dane_strerror(ret)); - gnutls_free(r_data); - gnutls_free(r_data_len); + if (memcmp + (r_data[i], data_entries[j].queries[i], + r_data_len[i]) != 0) + fail("test[%d]: %d: %s\n", j, __LINE__, dane_strerror(ret)); + } - dane_query_deinit(r); + if (data_entries[j].cert) { /* verify cert */ + gnutls_datum_t chain[2]; + unsigned status = 0; + unsigned chain_size = 1; + + crt_to_der(&chain[0], data_entries[j].cert, strlen(data_entries[j].cert)); + + if (data_entries[j].ca) { + crt_to_der(&chain[1], data_entries[j].ca, strlen(data_entries[j].ca)); + chain_size++; + } + + ret = dane_verify_crt_raw(NULL, chain, chain_size, GNUTLS_CRT_X509, r, + 0, 0, &status); + + if (ret != data_entries[j].expected_verify_ret) + fail("test[%d]: %d: %s\n", j, __LINE__, dane_strerror(ret)); + + if (ret >= 0 && status != data_entries[j].expected_status) { + fail("tests[%d]: expected verif. status %x, got %x\n", j, data_entries[j].expected_status, status); + } + free(chain[0].data); + if (chain_size == 2) + free(chain[1].data); + } + + if (debug) + success("completed test[%d]: %s\n", j, data_entries[j].name); + + gnutls_free(r_data); + gnutls_free(r_data_len); + + dane_query_deinit(r); + } dane_state_deinit(s); } |