test: Remove HS decode valid intro point test

The descriptor fields can't be validated properly during encoding because they
are signed by a descriptor signing key that we don't have in the unit test.

Removing the test case for now but ultimately we need an independent
implementation that can encode descriptor and test our decoding functions with
that.

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet 2017-04-07 10:57:27 -04:00
parent 0cc18ef64c
commit 0958e3b208

View File

@ -386,7 +386,7 @@ test_encrypted_data_len(void *arg)
} }
static void static void
test_decode_intro_point(void *arg) test_decode_invalid_intro_point(void *arg)
{ {
int ret; int ret;
char *encoded_ip = NULL; char *encoded_ip = NULL;
@ -397,9 +397,6 @@ test_decode_intro_point(void *arg)
(void) arg; (void) arg;
/* The following certificate expires in 2036. After that, one of the test
* will fail because of the expiry time. */
/* Seperate pieces of a valid encoded introduction point. */ /* Seperate pieces of a valid encoded introduction point. */
const char *intro_point = const char *intro_point =
"introduction-point AQIUMDI5OUYyNjhGQ0E5RDU1Q0QxNTc="; "introduction-point AQIUMDI5OUYyNjhGQ0E5RDU1Q0QxNTc=";
@ -412,13 +409,6 @@ test_decode_intro_point(void *arg)
"-----END ED25519 CERT-----"; "-----END ED25519 CERT-----";
const char *enc_key = const char *enc_key =
"enc-key ntor bpZKLsuhxP6woDQ3yVyjm5gUKSk7RjfAijT2qrzbQk0="; "enc-key ntor bpZKLsuhxP6woDQ3yVyjm5gUKSk7RjfAijT2qrzbQk0=";
const char *enc_key_legacy =
"enc-key legacy\n"
"-----BEGIN RSA PUBLIC KEY-----\n"
"MIGJAoGBAO4bATcW8kW4h6RQQAKEgg+aXCpF4JwbcO6vGZtzXTDB+HdPVQzwqkbh\n"
"XzFM6VGArhYw4m31wcP1Z7IwULir7UMnAFd7Zi62aYfU6l+Y1yAoZ1wzu1XBaAMK\n"
"ejpwQinW9nzJn7c2f69fVke3pkhxpNdUZ+vplSA/l9iY+y+v+415AgMBAAE=\n"
"-----END RSA PUBLIC KEY-----";
const char *enc_key_cert = const char *enc_key_cert =
"enc-key-certification\n" "enc-key-certification\n"
"-----BEGIN ED25519 CERT-----\n" "-----BEGIN ED25519 CERT-----\n"
@ -426,46 +416,6 @@ test_decode_intro_point(void *arg)
"lbTt1DF5nKTE/gU3Fr8ZtlCIOhu1A+F5LM7fqCUupfesg0KTHwyIZOYQbJuM5/he\n" "lbTt1DF5nKTE/gU3Fr8ZtlCIOhu1A+F5LM7fqCUupfesg0KTHwyIZOYQbJuM5/he\n"
"/jDNyLy9woPJdjkxywaY2RPUxGjLYtMQV0E8PUxWyICV+7y52fTCYaKpYQw=\n" "/jDNyLy9woPJdjkxywaY2RPUxGjLYtMQV0E8PUxWyICV+7y52fTCYaKpYQw=\n"
"-----END ED25519 CERT-----"; "-----END ED25519 CERT-----";
const char *enc_key_cert_legacy =
"enc-key-certification\n"
"-----BEGIN CROSSCERT-----\n"
"Sk28JnVolppHj2VLowJ2xWSFUZWtGqiPRjZPhLOugC0ACOhZgFPA5egeRDUXMM1U\n"
"Fn3c7Je0gJS6mVma5FzwlgwggeriF13UZcaT71vEAN/ZJXbxOfQVGMZ0rXuFpjUq\n"
"C8CvqmZIwEUaPE1nDFtmnTcucvNS1YQl9nsjH3ejbxc+4yqps/cXh46FmXsm5yz7\n"
"NZjBM9U1fbJhlNtOvrkf70K8bLk6\n"
"-----END CROSSCERT-----";
(void) enc_key_legacy;
(void) enc_key_cert_legacy;
/* Start by testing the "decode all intro points" function. */
{
char *line;
ret = ed25519_keypair_generate(&signing_kp, 0);
tt_int_op(ret, ==, 0);
desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
tt_assert(desc);
/* Only try to decode an incomplete introduction point section. */
tor_asprintf(&line, "\n%s", intro_point);
ret = decode_intro_points(desc, &desc->encrypted_data, line);
tor_free(line);
tt_int_op(ret, ==, -1);
/* Decode one complete intro point. */
smartlist_t *lines = smartlist_new();
smartlist_add(lines, (char *) intro_point);
smartlist_add(lines, (char *) auth_key);
smartlist_add(lines, (char *) enc_key);
smartlist_add(lines, (char *) enc_key_cert);
encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
tt_assert(encoded_ip);
tor_asprintf(&line, "\n%s", encoded_ip);
tor_free(encoded_ip);
ret = decode_intro_points(desc, &desc->encrypted_data, line);
tor_free(line);
smartlist_free(lines);
tt_int_op(ret, ==, 0);
}
/* Try to decode a junk string. */ /* Try to decode a junk string. */
{ {
@ -579,7 +529,7 @@ test_decode_intro_point(void *arg)
/* Invalid enc-key invalid legacy. */ /* Invalid enc-key invalid legacy. */
{ {
smartlist_t *lines = smartlist_new(); smartlist_t *lines = smartlist_new();
const char *bad_line = "enc-key legacy blah==="; const char *bad_line = "legacy-key blah===";
/* Build intro point text. */ /* Build intro point text. */
smartlist_add(lines, (char *) intro_point); smartlist_add(lines, (char *) intro_point);
smartlist_add(lines, (char *) auth_key); smartlist_add(lines, (char *) auth_key);
@ -593,22 +543,6 @@ test_decode_intro_point(void *arg)
smartlist_free(lines); smartlist_free(lines);
} }
/* Valid object. */
{
smartlist_t *lines = smartlist_new();
/* Build intro point text. */
smartlist_add(lines, (char *) intro_point);
smartlist_add(lines, (char *) auth_key);
smartlist_add(lines, (char *) enc_key);
smartlist_add(lines, (char *) enc_key_cert);
encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
tt_assert(encoded_ip);
ip = decode_introduction_point(desc, encoded_ip);
tt_assert(ip);
tor_free(encoded_ip);
smartlist_free(lines);
}
done: done:
hs_descriptor_free(desc); hs_descriptor_free(desc);
desc_intro_point_free(ip); desc_intro_point_free(ip);
@ -900,7 +834,7 @@ struct testcase_t hs_descriptor[] = {
NULL, NULL }, NULL, NULL },
{ "encrypted_data_len", test_encrypted_data_len, TT_FORK, { "encrypted_data_len", test_encrypted_data_len, TT_FORK,
NULL, NULL }, NULL, NULL },
{ "decode_intro_point", test_decode_intro_point, TT_FORK, { "decode_invalid_intro_point", test_decode_invalid_intro_point, TT_FORK,
NULL, NULL }, NULL, NULL },
{ "decode_plaintext", test_decode_plaintext, TT_FORK, { "decode_plaintext", test_decode_plaintext, TT_FORK,
NULL, NULL }, NULL, NULL },