test_hs_descriptor.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. /* Copyright (c) 2016, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file test_hs_descriptor.c
  5. * \brief Test hidden service descriptor encoding and decoding.
  6. */
  7. #define HS_DESCRIPTOR_PRIVATE
  8. #include "crypto_ed25519.h"
  9. #include "ed25519_cert.h"
  10. #include "or.h"
  11. #include "hs_descriptor.h"
  12. #include "test.h"
  13. #include "torcert.h"
  14. static hs_desc_intro_point_t *
  15. helper_build_intro_point(const ed25519_keypair_t *blinded_kp, time_t now,
  16. const char *addr, int legacy)
  17. {
  18. int ret;
  19. ed25519_keypair_t auth_kp;
  20. hs_desc_intro_point_t *intro_point = NULL;
  21. hs_desc_intro_point_t *ip = tor_malloc_zero(sizeof(*ip));
  22. ip->link_specifiers = smartlist_new();
  23. {
  24. hs_desc_link_specifier_t *ls = tor_malloc_zero(sizeof(*ls));
  25. if (legacy) {
  26. ls->type = LS_LEGACY_ID;
  27. memcpy(ls->u.legacy_id, "0299F268FCA9D55CD157976D39AE92B4B455B3A8",
  28. DIGEST_LEN);
  29. } else {
  30. ls->u.ap.port = 9001;
  31. int family = tor_addr_parse(&ls->u.ap.addr, addr);
  32. switch (family) {
  33. case AF_INET:
  34. ls->type = LS_IPV4;
  35. break;
  36. case AF_INET6:
  37. ls->type = LS_IPV6;
  38. break;
  39. default:
  40. /* Stop the test, not suppose to have an error. */
  41. tt_int_op(family, OP_EQ, AF_INET);
  42. }
  43. }
  44. smartlist_add(ip->link_specifiers, ls);
  45. }
  46. ret = ed25519_keypair_generate(&auth_kp, 0);
  47. tt_int_op(ret, ==, 0);
  48. ip->auth_key_cert = tor_cert_create(blinded_kp, CERT_TYPE_AUTH_HS_IP_KEY,
  49. &auth_kp.pubkey, now,
  50. HS_DESC_CERT_LIFETIME,
  51. CERT_FLAG_INCLUDE_SIGNING_KEY);
  52. tt_assert(ip->auth_key_cert);
  53. if (legacy) {
  54. ip->enc_key.legacy = crypto_pk_new();
  55. ip->enc_key_type = HS_DESC_KEY_TYPE_LEGACY;
  56. tt_assert(ip->enc_key.legacy);
  57. ret = crypto_pk_generate_key(ip->enc_key.legacy);
  58. tt_int_op(ret, ==, 0);
  59. } else {
  60. ret = curve25519_keypair_generate(&ip->enc_key.curve25519, 0);
  61. tt_int_op(ret, ==, 0);
  62. ip->enc_key_type = HS_DESC_KEY_TYPE_CURVE25519;
  63. }
  64. intro_point = ip;
  65. done:
  66. return intro_point;
  67. }
  68. /* Return a valid hs_descriptor_t object. If no_ip is set, no introduction
  69. * points are added. */
  70. static hs_descriptor_t *
  71. helper_build_hs_desc(unsigned int no_ip, ed25519_public_key_t *signing_pubkey)
  72. {
  73. int ret;
  74. time_t now = time(NULL);
  75. ed25519_keypair_t blinded_kp;
  76. hs_descriptor_t *descp = NULL, *desc = tor_malloc_zero(sizeof(*desc));
  77. desc->plaintext_data.version = HS_DESC_SUPPORTED_FORMAT_VERSION_MAX;
  78. /* Copy only the public key into the descriptor. */
  79. memcpy(&desc->plaintext_data.signing_pubkey, signing_pubkey,
  80. sizeof(ed25519_public_key_t));
  81. ret = ed25519_keypair_generate(&blinded_kp, 0);
  82. tt_int_op(ret, ==, 0);
  83. /* Copy only the public key into the descriptor. */
  84. memcpy(&desc->plaintext_data.blinded_pubkey, &blinded_kp.pubkey,
  85. sizeof(ed25519_public_key_t));
  86. desc->plaintext_data.signing_key_cert =
  87. tor_cert_create(&blinded_kp, CERT_TYPE_SIGNING_HS_DESC, signing_pubkey,
  88. now, 3600, CERT_FLAG_INCLUDE_SIGNING_KEY);
  89. tt_assert(desc->plaintext_data.signing_key_cert);
  90. desc->plaintext_data.revision_counter = 42;
  91. desc->plaintext_data.lifetime_sec = 3 * 60 * 60;
  92. /* Setup encrypted data section. */
  93. desc->encrypted_data.create2_ntor = 1;
  94. desc->encrypted_data.auth_types = smartlist_new();
  95. desc->encrypted_data.single_onion_service = 1;
  96. smartlist_add(desc->encrypted_data.auth_types, tor_strdup("ed25519"));
  97. desc->encrypted_data.intro_points = smartlist_new();
  98. if (!no_ip) {
  99. /* Add four intro points. */
  100. smartlist_add(desc->encrypted_data.intro_points,
  101. helper_build_intro_point(&blinded_kp, now, "1.2.3.4", 0));
  102. smartlist_add(desc->encrypted_data.intro_points,
  103. helper_build_intro_point(&blinded_kp, now, "[2600::1]", 0));
  104. smartlist_add(desc->encrypted_data.intro_points,
  105. helper_build_intro_point(&blinded_kp, now, "3.2.1.4", 1));
  106. smartlist_add(desc->encrypted_data.intro_points,
  107. helper_build_intro_point(&blinded_kp, now, "", 1));
  108. }
  109. descp = desc;
  110. done:
  111. return descp;
  112. }
  113. static void
  114. helper_compare_hs_desc(const hs_descriptor_t *desc1,
  115. const hs_descriptor_t *desc2)
  116. {
  117. char *addr1 = NULL, *addr2 = NULL;
  118. /* Plaintext data section. */
  119. tt_int_op(desc1->plaintext_data.version, OP_EQ,
  120. desc2->plaintext_data.version);
  121. tt_uint_op(desc1->plaintext_data.lifetime_sec, OP_EQ,
  122. desc2->plaintext_data.lifetime_sec);
  123. tt_assert(tor_cert_eq(desc1->plaintext_data.signing_key_cert,
  124. desc2->plaintext_data.signing_key_cert));
  125. tt_mem_op(desc1->plaintext_data.signing_pubkey.pubkey, OP_EQ,
  126. desc2->plaintext_data.signing_pubkey.pubkey,
  127. ED25519_PUBKEY_LEN);
  128. tt_mem_op(desc1->plaintext_data.blinded_pubkey.pubkey, OP_EQ,
  129. desc2->plaintext_data.blinded_pubkey.pubkey,
  130. ED25519_PUBKEY_LEN);
  131. tt_u64_op(desc1->plaintext_data.revision_counter, ==,
  132. desc2->plaintext_data.revision_counter);
  133. /* NOTE: We can't compare the encrypted blob because when encoding the
  134. * descriptor, the object is immutable thus we don't update it with the
  135. * encrypted blob. As contrast to the decoding process where we populate a
  136. * descriptor object. */
  137. /* Encrypted data section. */
  138. tt_uint_op(desc1->encrypted_data.create2_ntor, ==,
  139. desc2->encrypted_data.create2_ntor);
  140. /* Authentication type. */
  141. tt_int_op(!!desc1->encrypted_data.auth_types, ==,
  142. !!desc2->encrypted_data.auth_types);
  143. if (desc1->encrypted_data.auth_types && desc2->encrypted_data.auth_types) {
  144. tt_int_op(smartlist_len(desc1->encrypted_data.auth_types), ==,
  145. smartlist_len(desc2->encrypted_data.auth_types));
  146. for (int i = 0; i < smartlist_len(desc1->encrypted_data.auth_types); i++) {
  147. tt_str_op(smartlist_get(desc1->encrypted_data.auth_types, i), OP_EQ,
  148. smartlist_get(desc2->encrypted_data.auth_types, i));
  149. }
  150. }
  151. /* Introduction points. */
  152. {
  153. tt_assert(desc1->encrypted_data.intro_points);
  154. tt_assert(desc2->encrypted_data.intro_points);
  155. tt_int_op(smartlist_len(desc1->encrypted_data.intro_points), ==,
  156. smartlist_len(desc2->encrypted_data.intro_points));
  157. for (int i=0; i < smartlist_len(desc1->encrypted_data.intro_points); i++) {
  158. hs_desc_intro_point_t *ip1 = smartlist_get(desc1->encrypted_data
  159. .intro_points, i),
  160. *ip2 = smartlist_get(desc2->encrypted_data
  161. .intro_points, i);
  162. tt_assert(tor_cert_eq(ip1->auth_key_cert, ip2->auth_key_cert));
  163. tt_int_op(ip1->enc_key_type, OP_EQ, ip2->enc_key_type);
  164. tt_assert(ip1->enc_key_type == HS_DESC_KEY_TYPE_LEGACY ||
  165. ip1->enc_key_type == HS_DESC_KEY_TYPE_CURVE25519);
  166. switch (ip1->enc_key_type) {
  167. case HS_DESC_KEY_TYPE_LEGACY:
  168. tt_int_op(crypto_pk_cmp_keys(ip1->enc_key.legacy, ip2->enc_key.legacy),
  169. OP_EQ, 0);
  170. break;
  171. case HS_DESC_KEY_TYPE_CURVE25519:
  172. tt_mem_op(ip1->enc_key.curve25519.pubkey.public_key, OP_EQ,
  173. ip2->enc_key.curve25519.pubkey.public_key,
  174. CURVE25519_PUBKEY_LEN);
  175. break;
  176. }
  177. tt_int_op(smartlist_len(ip1->link_specifiers), ==,
  178. smartlist_len(ip2->link_specifiers));
  179. for (int j = 0; j < smartlist_len(ip1->link_specifiers); j++) {
  180. hs_desc_link_specifier_t *ls1 = smartlist_get(ip1->link_specifiers, j),
  181. *ls2 = smartlist_get(ip2->link_specifiers, j);
  182. tt_int_op(ls1->type, ==, ls2->type);
  183. switch (ls1->type) {
  184. case LS_IPV4:
  185. case LS_IPV6:
  186. {
  187. addr1 = tor_addr_to_str_dup(&ls1->u.ap.addr);
  188. addr2 = tor_addr_to_str_dup(&ls2->u.ap.addr);
  189. tt_str_op(addr1, OP_EQ, addr2);
  190. tor_free(addr1);
  191. tor_free(addr2);
  192. tt_int_op(ls1->u.ap.port, ==, ls2->u.ap.port);
  193. }
  194. break;
  195. case LS_LEGACY_ID:
  196. tt_mem_op(ls1->u.legacy_id, OP_EQ, ls2->u.legacy_id,
  197. sizeof(ls1->u.legacy_id));
  198. break;
  199. default:
  200. /* Unknown type, caught it and print its value. */
  201. tt_int_op(ls1->type, OP_EQ, -1);
  202. }
  203. }
  204. }
  205. }
  206. done:
  207. tor_free(addr1);
  208. tor_free(addr2);
  209. }
  210. /* Test certificate encoding put in a descriptor. */
  211. static void
  212. test_cert_encoding(void *arg)
  213. {
  214. int ret;
  215. char *encoded = NULL;
  216. time_t now = time(NULL);
  217. ed25519_keypair_t kp;
  218. ed25519_public_key_t signed_key;
  219. ed25519_secret_key_t secret_key;
  220. tor_cert_t *cert = NULL;
  221. (void) arg;
  222. ret = ed25519_keypair_generate(&kp, 0);
  223. tt_int_op(ret, == , 0);
  224. ret = ed25519_secret_key_generate(&secret_key, 0);
  225. tt_int_op(ret, == , 0);
  226. ret = ed25519_public_key_generate(&signed_key, &secret_key);
  227. tt_int_op(ret, == , 0);
  228. cert = tor_cert_create(&kp, CERT_TYPE_SIGNING_AUTH, &signed_key,
  229. now, 3600 * 2, CERT_FLAG_INCLUDE_SIGNING_KEY);
  230. tt_assert(cert);
  231. /* Test the certificate encoding function. */
  232. ret = tor_cert_encode_ed22519(cert, &encoded);
  233. tt_int_op(ret, ==, 0);
  234. /* Validated the certificate string. */
  235. {
  236. char *end, *pos = encoded;
  237. char *b64_cert, buf[256];
  238. size_t b64_cert_len;
  239. tor_cert_t *parsed_cert;
  240. tt_int_op(strcmpstart(pos, "-----BEGIN ED25519 CERT-----\n"), ==, 0);
  241. pos += strlen("-----BEGIN ED25519 CERT-----\n");
  242. /* Isolate the base64 encoded certificate and try to decode it. */
  243. end = strstr(pos, "-----END ED25519 CERT-----");
  244. tt_assert(end);
  245. b64_cert = pos;
  246. b64_cert_len = end - pos;
  247. ret = base64_decode(buf, sizeof(buf), b64_cert, b64_cert_len);
  248. tt_int_op(ret, >, 0);
  249. /* Parseable? */
  250. parsed_cert = tor_cert_parse((uint8_t *) buf, ret);
  251. tt_assert(parsed_cert);
  252. /* Signature is valid? */
  253. ret = tor_cert_checksig(parsed_cert, &kp.pubkey, now + 10);
  254. tt_int_op(ret, ==, 0);
  255. ret = tor_cert_eq(cert, parsed_cert);
  256. tt_int_op(ret, ==, 1);
  257. /* The cert did have the signing key? */
  258. ret= ed25519_pubkey_eq(&parsed_cert->signing_key, &kp.pubkey);
  259. tt_int_op(ret, ==, 1);
  260. tor_cert_free(parsed_cert);
  261. /* Get to the end part of the certificate. */
  262. pos += b64_cert_len;
  263. tt_int_op(strcmpstart(pos, "-----END ED25519 CERT-----"), ==, 0);
  264. pos += strlen("-----END ED25519 CERT-----");
  265. }
  266. done:
  267. tor_cert_free(cert);
  268. tor_free(encoded);
  269. }
  270. /* Test the descriptor padding. */
  271. static void
  272. test_descriptor_padding(void *arg)
  273. {
  274. char *plaintext;
  275. size_t plaintext_len, padded_len;
  276. uint8_t *padded_plaintext = NULL;
  277. /* Example: if l = 129, the ceiled division gives 2 and then multiplied by 128
  278. * to give 256. With l = 127, ceiled division gives 1 then times 128. */
  279. #define PADDING_EXPECTED_LEN(l) \
  280. CEIL_DIV(l, HS_DESC_PLAINTEXT_PADDING_MULTIPLE) * \
  281. HS_DESC_PLAINTEXT_PADDING_MULTIPLE
  282. (void) arg;
  283. { /* test #1: no padding */
  284. plaintext_len = HS_DESC_PLAINTEXT_PADDING_MULTIPLE;
  285. plaintext = tor_malloc(plaintext_len);
  286. padded_len = build_plaintext_padding(plaintext, plaintext_len,
  287. &padded_plaintext);
  288. tt_assert(padded_plaintext);
  289. tor_free(plaintext);
  290. /* Make sure our padding has been zeroed. */
  291. tt_int_op(tor_mem_is_zero((char *) padded_plaintext + plaintext_len,
  292. padded_len - plaintext_len), OP_EQ, 1);
  293. tor_free(padded_plaintext);
  294. /* Never never have a padded length smaller than the plaintext. */
  295. tt_int_op(padded_len, OP_GE, plaintext_len);
  296. tt_int_op(padded_len, OP_EQ, PADDING_EXPECTED_LEN(plaintext_len));
  297. }
  298. { /* test #2: one byte padding? */
  299. plaintext_len = HS_DESC_PLAINTEXT_PADDING_MULTIPLE - 1;
  300. plaintext = tor_malloc(plaintext_len);
  301. padded_plaintext = NULL;
  302. padded_len = build_plaintext_padding(plaintext, plaintext_len,
  303. &padded_plaintext);
  304. tt_assert(padded_plaintext);
  305. tor_free(plaintext);
  306. /* Make sure our padding has been zeroed. */
  307. tt_int_op(tor_mem_is_zero((char *) padded_plaintext + plaintext_len,
  308. padded_len - plaintext_len), OP_EQ, 1);
  309. tor_free(padded_plaintext);
  310. /* Never never have a padded length smaller than the plaintext. */
  311. tt_int_op(padded_len, OP_GE, plaintext_len);
  312. tt_int_op(padded_len, OP_EQ, PADDING_EXPECTED_LEN(plaintext_len));
  313. }
  314. { /* test #3: Lots more bytes of padding? */
  315. plaintext_len = HS_DESC_PLAINTEXT_PADDING_MULTIPLE + 1;
  316. plaintext = tor_malloc(plaintext_len);
  317. padded_plaintext = NULL;
  318. padded_len = build_plaintext_padding(plaintext, plaintext_len,
  319. &padded_plaintext);
  320. tt_assert(padded_plaintext);
  321. tor_free(plaintext);
  322. /* Make sure our padding has been zeroed. */
  323. tt_int_op(tor_mem_is_zero((char *) padded_plaintext + plaintext_len,
  324. padded_len - plaintext_len), OP_EQ, 1);
  325. tor_free(padded_plaintext);
  326. /* Never never have a padded length smaller than the plaintext. */
  327. tt_int_op(padded_len, OP_GE, plaintext_len);
  328. tt_int_op(padded_len, OP_EQ, PADDING_EXPECTED_LEN(plaintext_len));
  329. }
  330. done:
  331. return;
  332. }
  333. static void
  334. test_link_specifier(void *arg)
  335. {
  336. ssize_t ret;
  337. hs_desc_link_specifier_t spec;
  338. smartlist_t *link_specifiers = smartlist_new();
  339. (void) arg;
  340. /* Always this port. */
  341. spec.u.ap.port = 42;
  342. smartlist_add(link_specifiers, &spec);
  343. /* Test IPv4 for starter. */
  344. {
  345. char *b64, buf[256];
  346. uint32_t ipv4;
  347. link_specifier_t *ls;
  348. spec.type = LS_IPV4;
  349. ret = tor_addr_parse(&spec.u.ap.addr, "1.2.3.4");
  350. tt_int_op(ret, ==, AF_INET);
  351. b64 = encode_link_specifiers(link_specifiers);
  352. tt_assert(b64);
  353. /* Decode it and validate the format. */
  354. ret = base64_decode(buf, sizeof(buf), b64, strlen(b64));
  355. tt_int_op(ret, >, 0);
  356. /* First byte is the number of link specifier. */
  357. tt_int_op(get_uint8(buf), ==, 1);
  358. ret = link_specifier_parse(&ls, (uint8_t *) buf + 1, ret - 1);
  359. tt_int_op(ret, ==, 8);
  360. /* Should be 2 bytes for port and 4 bytes for IPv4. */
  361. tt_int_op(link_specifier_get_ls_len(ls), ==, 6);
  362. ipv4 = link_specifier_get_un_ipv4_addr(ls);
  363. tt_int_op(tor_addr_to_ipv4h(&spec.u.ap.addr), ==, ipv4);
  364. tt_int_op(link_specifier_get_un_ipv4_port(ls), ==, spec.u.ap.port);
  365. link_specifier_free(ls);
  366. tor_free(b64);
  367. }
  368. /* Test IPv6. */
  369. {
  370. char *b64, buf[256];
  371. uint8_t ipv6[16];
  372. link_specifier_t *ls;
  373. spec.type = LS_IPV6;
  374. ret = tor_addr_parse(&spec.u.ap.addr, "[1:2:3:4::]");
  375. tt_int_op(ret, ==, AF_INET6);
  376. b64 = encode_link_specifiers(link_specifiers);
  377. tt_assert(b64);
  378. /* Decode it and validate the format. */
  379. ret = base64_decode(buf, sizeof(buf), b64, strlen(b64));
  380. tt_int_op(ret, >, 0);
  381. /* First byte is the number of link specifier. */
  382. tt_int_op(get_uint8(buf), ==, 1);
  383. ret = link_specifier_parse(&ls, (uint8_t *) buf + 1, ret - 1);
  384. tt_int_op(ret, ==, 20);
  385. /* Should be 2 bytes for port and 16 bytes for IPv6. */
  386. tt_int_op(link_specifier_get_ls_len(ls), ==, 18);
  387. for (unsigned int i = 0; i < sizeof(ipv6); i++) {
  388. ipv6[i] = link_specifier_get_un_ipv6_addr(ls, i);
  389. }
  390. tt_mem_op(tor_addr_to_in6_addr8(&spec.u.ap.addr), ==, ipv6, sizeof(ipv6));
  391. tt_int_op(link_specifier_get_un_ipv6_port(ls), ==, spec.u.ap.port);
  392. link_specifier_free(ls);
  393. tor_free(b64);
  394. }
  395. /* Test legacy. */
  396. {
  397. char *b64, buf[256];
  398. uint8_t *id;
  399. link_specifier_t *ls;
  400. spec.type = LS_LEGACY_ID;
  401. memset(spec.u.legacy_id, 'Y', sizeof(spec.u.legacy_id));
  402. b64 = encode_link_specifiers(link_specifiers);
  403. tt_assert(b64);
  404. /* Decode it and validate the format. */
  405. ret = base64_decode(buf, sizeof(buf), b64, strlen(b64));
  406. tt_int_op(ret, >, 0);
  407. /* First byte is the number of link specifier. */
  408. tt_int_op(get_uint8(buf), ==, 1);
  409. ret = link_specifier_parse(&ls, (uint8_t *) buf + 1, ret - 1);
  410. /* 20 bytes digest + 1 byte type + 1 byte len. */
  411. tt_int_op(ret, ==, 22);
  412. tt_int_op(link_specifier_getlen_un_legacy_id(ls), OP_EQ, DIGEST_LEN);
  413. /* Digest length is 20 bytes. */
  414. tt_int_op(link_specifier_get_ls_len(ls), OP_EQ, DIGEST_LEN);
  415. id = link_specifier_getarray_un_legacy_id(ls);
  416. tt_mem_op(spec.u.legacy_id, OP_EQ, id, DIGEST_LEN);
  417. link_specifier_free(ls);
  418. tor_free(b64);
  419. }
  420. done:
  421. smartlist_free(link_specifiers);
  422. }
  423. static void
  424. test_encode_descriptor(void *arg)
  425. {
  426. int ret;
  427. char *encoded = NULL;
  428. ed25519_keypair_t signing_kp;
  429. hs_descriptor_t *desc = NULL;
  430. (void) arg;
  431. ret = ed25519_keypair_generate(&signing_kp, 0);
  432. tt_int_op(ret, ==, 0);
  433. desc = helper_build_hs_desc(0, &signing_kp.pubkey);
  434. ret = hs_desc_encode_descriptor(desc, &signing_kp, &encoded);
  435. tt_int_op(ret, ==, 0);
  436. tt_assert(encoded);
  437. done:
  438. hs_descriptor_free(desc);
  439. tor_free(encoded);
  440. }
  441. static void
  442. test_decode_descriptor(void *arg)
  443. {
  444. int ret;
  445. char *encoded = NULL;
  446. ed25519_keypair_t signing_kp;
  447. hs_descriptor_t *desc = NULL;
  448. hs_descriptor_t *decoded = NULL;
  449. hs_descriptor_t *desc_no_ip = NULL;
  450. (void) arg;
  451. ret = ed25519_keypair_generate(&signing_kp, 0);
  452. tt_int_op(ret, ==, 0);
  453. desc = helper_build_hs_desc(0, &signing_kp.pubkey);
  454. /* Give some bad stuff to the decoding function. */
  455. ret = hs_desc_decode_descriptor("hladfjlkjadf", NULL, &decoded);
  456. tt_int_op(ret, OP_EQ, -1);
  457. ret = hs_desc_encode_descriptor(desc, &signing_kp, &encoded);
  458. tt_int_op(ret, ==, 0);
  459. tt_assert(encoded);
  460. ret = hs_desc_decode_descriptor(encoded, NULL, &decoded);
  461. tt_int_op(ret, ==, 0);
  462. tt_assert(decoded);
  463. helper_compare_hs_desc(desc, decoded);
  464. /* Decode a descriptor with _no_ introduction points. */
  465. {
  466. ed25519_keypair_t signing_kp_no_ip;
  467. ret = ed25519_keypair_generate(&signing_kp_no_ip, 0);
  468. tt_int_op(ret, ==, 0);
  469. desc_no_ip = helper_build_hs_desc(1, &signing_kp_no_ip.pubkey);
  470. tt_assert(desc_no_ip);
  471. tor_free(encoded);
  472. ret = hs_desc_encode_descriptor(desc_no_ip, &signing_kp_no_ip, &encoded);
  473. tt_int_op(ret, ==, 0);
  474. tt_assert(encoded);
  475. hs_descriptor_free(decoded);
  476. ret = hs_desc_decode_descriptor(encoded, NULL, &decoded);
  477. tt_int_op(ret, ==, 0);
  478. tt_assert(decoded);
  479. }
  480. done:
  481. hs_descriptor_free(desc);
  482. hs_descriptor_free(desc_no_ip);
  483. hs_descriptor_free(decoded);
  484. tor_free(encoded);
  485. }
  486. static void
  487. test_supported_version(void *arg)
  488. {
  489. int ret;
  490. (void) arg;
  491. /* Unsupported. */
  492. ret = hs_desc_is_supported_version(42);
  493. tt_int_op(ret, OP_EQ, 0);
  494. /* To early. */
  495. ret = hs_desc_is_supported_version(HS_DESC_SUPPORTED_FORMAT_VERSION_MIN - 1);
  496. tt_int_op(ret, OP_EQ, 0);
  497. /* One too new. */
  498. ret = hs_desc_is_supported_version(HS_DESC_SUPPORTED_FORMAT_VERSION_MAX + 1);
  499. tt_int_op(ret, OP_EQ, 0);
  500. /* Valid version. */
  501. ret = hs_desc_is_supported_version(3);
  502. tt_int_op(ret, OP_EQ, 1);
  503. done:
  504. ;
  505. }
  506. static void
  507. test_encrypted_data_len(void *arg)
  508. {
  509. int ret;
  510. size_t value;
  511. (void) arg;
  512. /* No length, error. */
  513. ret = encrypted_data_length_is_valid(0);
  514. tt_int_op(ret, OP_EQ, 0);
  515. /* Not a multiple of our encryption algorithm (thus no padding). It's
  516. * suppose to be aligned on HS_DESC_PLAINTEXT_PADDING_MULTIPLE. */
  517. value = HS_DESC_PLAINTEXT_PADDING_MULTIPLE * 10 - 1;
  518. ret = encrypted_data_length_is_valid(value);
  519. tt_int_op(ret, OP_EQ, 0);
  520. /* Valid value. */
  521. value = HS_DESC_PADDED_PLAINTEXT_MAX_LEN + HS_DESC_ENCRYPTED_SALT_LEN +
  522. DIGEST256_LEN;
  523. ret = encrypted_data_length_is_valid(value);
  524. tt_int_op(ret, OP_EQ, 1);
  525. /* XXX: Test maximum possible size. */
  526. done:
  527. ;
  528. }
  529. static void
  530. test_decode_intro_point(void *arg)
  531. {
  532. int ret;
  533. char *encoded_ip = NULL;
  534. size_t len_out;
  535. hs_desc_intro_point_t *ip = NULL;
  536. ed25519_keypair_t signing_kp;
  537. hs_descriptor_t *desc = NULL;
  538. (void) arg;
  539. /* The following certificate expires in 2036. After that, one of the test
  540. * will fail because of the expiry time. */
  541. /* Seperate pieces of a valid encoded introduction point. */
  542. const char *intro_point =
  543. "introduction-point AQIUMDI5OUYyNjhGQ0E5RDU1Q0QxNTc=";
  544. const char *auth_key =
  545. "auth-key\n"
  546. "-----BEGIN ED25519 CERT-----\n"
  547. "AQkACOhAAQW8ltYZMIWpyrfyE/b4Iyi8CNybCwYs6ADk7XfBaxsFAQAgBAD3/BE4\n"
  548. "XojGE/N2bW/wgnS9r2qlrkydGyuCKIGayYx3haZ39LD4ZTmSMRxwmplMAqzG/XNP\n"
  549. "0Kkpg4p2/VnLFJRdU1SMFo1lgQ4P0bqw7Tgx200fulZ4KUM5z5V7m+a/mgY=\n"
  550. "-----END ED25519 CERT-----";
  551. const char *enc_key =
  552. "enc-key ntor bpZKLsuhxP6woDQ3yVyjm5gUKSk7RjfAijT2qrzbQk0=";
  553. const char *enc_key_legacy =
  554. "enc-key legacy\n"
  555. "-----BEGIN RSA PUBLIC KEY-----\n"
  556. "MIGJAoGBAO4bATcW8kW4h6RQQAKEgg+aXCpF4JwbcO6vGZtzXTDB+HdPVQzwqkbh\n"
  557. "XzFM6VGArhYw4m31wcP1Z7IwULir7UMnAFd7Zi62aYfU6l+Y1yAoZ1wzu1XBaAMK\n"
  558. "ejpwQinW9nzJn7c2f69fVke3pkhxpNdUZ+vplSA/l9iY+y+v+415AgMBAAE=\n"
  559. "-----END RSA PUBLIC KEY-----";
  560. const char *enc_key_cert =
  561. "enc-key-certification\n"
  562. "-----BEGIN ED25519 CERT-----\n"
  563. "AQsACOhZAUpNvCZ1aJaaR49lS6MCdsVkhVGVrRqoj0Y2T4SzroAtAQAgBABFOcGg\n"
  564. "lbTt1DF5nKTE/gU3Fr8ZtlCIOhu1A+F5LM7fqCUupfesg0KTHwyIZOYQbJuM5/he\n"
  565. "/jDNyLy9woPJdjkxywaY2RPUxGjLYtMQV0E8PUxWyICV+7y52fTCYaKpYQw=\n"
  566. "-----END ED25519 CERT-----";
  567. const char *enc_key_cert_legacy =
  568. "enc-key-certification\n"
  569. "-----BEGIN CROSSCERT-----\n"
  570. "Sk28JnVolppHj2VLowJ2xWSFUZWtGqiPRjZPhLOugC0ACOhZgFPA5egeRDUXMM1U\n"
  571. "Fn3c7Je0gJS6mVma5FzwlgwggeriF13UZcaT71vEAN/ZJXbxOfQVGMZ0rXuFpjUq\n"
  572. "C8CvqmZIwEUaPE1nDFtmnTcucvNS1YQl9nsjH3ejbxc+4yqps/cXh46FmXsm5yz7\n"
  573. "NZjBM9U1fbJhlNtOvrkf70K8bLk6\n"
  574. "-----END CROSSCERT-----";
  575. (void) enc_key_legacy;
  576. (void) enc_key_cert_legacy;
  577. /* Start by testing the "decode all intro points" function. */
  578. {
  579. char *line;
  580. ret = ed25519_keypair_generate(&signing_kp, 0);
  581. tt_int_op(ret, ==, 0);
  582. desc = helper_build_hs_desc(0, &signing_kp.pubkey);
  583. tt_assert(desc);
  584. /* Only try to decode an incomplete introduction point section. */
  585. tor_asprintf(&line, "\n%s", intro_point);
  586. ret = decode_intro_points(desc, &desc->encrypted_data, line);
  587. tor_free(line);
  588. tt_int_op(ret, ==, -1);
  589. /* Decode one complete intro point. */
  590. smartlist_t *lines = smartlist_new();
  591. smartlist_add(lines, (char *) intro_point);
  592. smartlist_add(lines, (char *) auth_key);
  593. smartlist_add(lines, (char *) enc_key);
  594. smartlist_add(lines, (char *) enc_key_cert);
  595. encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
  596. tt_assert(encoded_ip);
  597. tor_asprintf(&line, "\n%s", encoded_ip);
  598. tor_free(encoded_ip);
  599. ret = decode_intro_points(desc, &desc->encrypted_data, line);
  600. tor_free(line);
  601. smartlist_free(lines);
  602. tt_int_op(ret, ==, 0);
  603. }
  604. /* Try to decode a junk string. */
  605. {
  606. hs_descriptor_free(desc);
  607. desc = NULL;
  608. ret = ed25519_keypair_generate(&signing_kp, 0);
  609. tt_int_op(ret, ==, 0);
  610. desc = helper_build_hs_desc(0, &signing_kp.pubkey);
  611. const char *junk = "this is not a descriptor";
  612. ip = decode_introduction_point(desc, junk);
  613. tt_assert(!ip);
  614. desc_intro_point_free(ip);
  615. ip = NULL;
  616. }
  617. /* Invalid link specifiers. */
  618. {
  619. smartlist_t *lines = smartlist_new();
  620. const char *bad_line = "introduction-point blah";
  621. smartlist_add(lines, (char *) bad_line);
  622. smartlist_add(lines, (char *) auth_key);
  623. smartlist_add(lines, (char *) enc_key);
  624. smartlist_add(lines, (char *) enc_key_cert);
  625. encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
  626. tt_assert(encoded_ip);
  627. ip = decode_introduction_point(desc, encoded_ip);
  628. tt_assert(!ip);
  629. tor_free(encoded_ip);
  630. smartlist_free(lines);
  631. desc_intro_point_free(ip);
  632. ip = NULL;
  633. }
  634. /* Invalid auth key type. */
  635. {
  636. smartlist_t *lines = smartlist_new();
  637. /* Try to put a valid object that our tokenize function will be able to
  638. * parse but that has nothing to do with the auth_key. */
  639. const char *bad_line =
  640. "auth-key\n"
  641. "-----BEGIN UNICORN CERT-----\n"
  642. "MIGJAoGBAO4bATcW8kW4h6RQQAKEgg+aXCpF4JwbcO6vGZtzXTDB+HdPVQzwqkbh\n"
  643. "XzFM6VGArhYw4m31wcP1Z7IwULir7UMnAFd7Zi62aYfU6l+Y1yAoZ1wzu1XBaAMK\n"
  644. "ejpwQinW9nzJn7c2f69fVke3pkhxpNdUZ+vplSA/l9iY+y+v+415AgMBAAE=\n"
  645. "-----END UNICORN CERT-----";
  646. /* Build intro point text. */
  647. smartlist_add(lines, (char *) intro_point);
  648. smartlist_add(lines, (char *) bad_line);
  649. smartlist_add(lines, (char *) enc_key);
  650. smartlist_add(lines, (char *) enc_key_cert);
  651. encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
  652. tt_assert(encoded_ip);
  653. ip = decode_introduction_point(desc, encoded_ip);
  654. tt_assert(!ip);
  655. tor_free(encoded_ip);
  656. smartlist_free(lines);
  657. }
  658. /* Invalid enc-key. */
  659. {
  660. smartlist_t *lines = smartlist_new();
  661. const char *bad_line =
  662. "enc-key unicorn bpZKLsuhxP6woDQ3yVyjm5gUKSk7RjfAijT2qrzbQk0=";
  663. /* Build intro point text. */
  664. smartlist_add(lines, (char *) intro_point);
  665. smartlist_add(lines, (char *) auth_key);
  666. smartlist_add(lines, (char *) bad_line);
  667. smartlist_add(lines, (char *) enc_key_cert);
  668. encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
  669. tt_assert(encoded_ip);
  670. ip = decode_introduction_point(desc, encoded_ip);
  671. tt_assert(!ip);
  672. tor_free(encoded_ip);
  673. smartlist_free(lines);
  674. }
  675. /* Invalid enc-key object. */
  676. {
  677. smartlist_t *lines = smartlist_new();
  678. const char *bad_line = "enc-key ntor";
  679. /* Build intro point text. */
  680. smartlist_add(lines, (char *) intro_point);
  681. smartlist_add(lines, (char *) auth_key);
  682. smartlist_add(lines, (char *) bad_line);
  683. smartlist_add(lines, (char *) enc_key_cert);
  684. encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
  685. tt_assert(encoded_ip);
  686. ip = decode_introduction_point(desc, encoded_ip);
  687. tt_assert(!ip);
  688. tor_free(encoded_ip);
  689. smartlist_free(lines);
  690. }
  691. /* Invalid enc-key base64 curv25519 key. */
  692. {
  693. smartlist_t *lines = smartlist_new();
  694. const char *bad_line = "enc-key ntor blah===";
  695. /* Build intro point text. */
  696. smartlist_add(lines, (char *) intro_point);
  697. smartlist_add(lines, (char *) auth_key);
  698. smartlist_add(lines, (char *) bad_line);
  699. smartlist_add(lines, (char *) enc_key_cert);
  700. encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
  701. tt_assert(encoded_ip);
  702. ip = decode_introduction_point(desc, encoded_ip);
  703. tt_assert(!ip);
  704. tor_free(encoded_ip);
  705. smartlist_free(lines);
  706. }
  707. /* Invalid enc-key invalid legacy. */
  708. {
  709. smartlist_t *lines = smartlist_new();
  710. const char *bad_line = "enc-key legacy blah===";
  711. /* Build intro point text. */
  712. smartlist_add(lines, (char *) intro_point);
  713. smartlist_add(lines, (char *) auth_key);
  714. smartlist_add(lines, (char *) bad_line);
  715. smartlist_add(lines, (char *) enc_key_cert);
  716. encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
  717. tt_assert(encoded_ip);
  718. ip = decode_introduction_point(desc, encoded_ip);
  719. tt_assert(!ip);
  720. tor_free(encoded_ip);
  721. smartlist_free(lines);
  722. }
  723. /* Valid object. */
  724. {
  725. smartlist_t *lines = smartlist_new();
  726. /* Build intro point text. */
  727. smartlist_add(lines, (char *) intro_point);
  728. smartlist_add(lines, (char *) auth_key);
  729. smartlist_add(lines, (char *) enc_key);
  730. smartlist_add(lines, (char *) enc_key_cert);
  731. encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
  732. tt_assert(encoded_ip);
  733. ip = decode_introduction_point(desc, encoded_ip);
  734. tt_assert(ip);
  735. tor_free(encoded_ip);
  736. smartlist_free(lines);
  737. }
  738. done:
  739. hs_descriptor_free(desc);
  740. desc_intro_point_free(ip);
  741. }
  742. static void
  743. test_decode_plaintext(void *arg)
  744. {
  745. int ret;
  746. hs_desc_plaintext_data_t desc_plaintext;
  747. const char *bad_value = "unicorn";
  748. (void) arg;
  749. #define template \
  750. "hs-descriptor %s\n" \
  751. "descriptor-lifetime %s\n" \
  752. "descriptor-signing-key-cert\n" \
  753. "-----BEGIN ED25519 CERT-----\n" \
  754. "AQgABjvPAQaG3g+dc6oV/oJV4ODAtkvx56uBnPtBT9mYVuHVOhn7AQAgBABUg3mQ\n" \
  755. "myBr4bu5LCr53wUEbW2EXui01CbUgU7pfo9LvJG3AcXRojj6HlfsUs9BkzYzYdjF\n" \
  756. "A69Apikgu0ewHYkFFASt7Il+gB3w6J8YstQJZT7dtbtl+doM7ug8B68Qdg8=\n" \
  757. "-----END ED25519 CERT-----\n" \
  758. "revision-counter %s\n" \
  759. "encrypted\n" \
  760. "-----BEGIN %s-----\n" \
  761. "UNICORN\n" \
  762. "-----END MESSAGE-----\n" \
  763. "signature m20WJH5agqvwhq7QeuEZ1mYyPWQDO+eJOZUjLhAiKu8DbL17DsDfJE6kXbWy" \
  764. "HimbNj2we0enV3cCOOAsmPOaAw\n"
  765. /* Invalid version. */
  766. {
  767. char *plaintext;
  768. tor_asprintf(&plaintext, template, bad_value, "180", "42", "MESSAGE");
  769. ret = hs_desc_decode_plaintext(plaintext, &desc_plaintext);
  770. tor_free(plaintext);
  771. tt_int_op(ret, OP_EQ, -1);
  772. }
  773. /* Missing fields. */
  774. {
  775. const char *plaintext = "hs-descriptor 3\n";
  776. ret = hs_desc_decode_plaintext(plaintext, &desc_plaintext);
  777. tt_int_op(ret, OP_EQ, -1);
  778. }
  779. /* Max length. */
  780. {
  781. size_t big = 64000;
  782. /* Must always be bigger than HS_DESC_MAX_LEN. */
  783. tt_int_op(HS_DESC_MAX_LEN, <, big);
  784. char *plaintext = tor_malloc_zero(big);
  785. memset(plaintext, 'a', big);
  786. plaintext[big - 1] = '\0';
  787. ret = hs_desc_decode_plaintext(plaintext, &desc_plaintext);
  788. tor_free(plaintext);
  789. tt_int_op(ret, OP_EQ, -1);
  790. }
  791. /* Bad lifetime value. */
  792. {
  793. char *plaintext;
  794. tor_asprintf(&plaintext, template, "3", bad_value, "42", "MESSAGE");
  795. ret = hs_desc_decode_plaintext(plaintext, &desc_plaintext);
  796. tor_free(plaintext);
  797. tt_int_op(ret, OP_EQ, -1);
  798. }
  799. /* Huge lifetime value. */
  800. {
  801. char *plaintext;
  802. tor_asprintf(&plaintext, template, "3", "7181615", "42", "MESSAGE");
  803. ret = hs_desc_decode_plaintext(plaintext, &desc_plaintext);
  804. tor_free(plaintext);
  805. tt_int_op(ret, OP_EQ, -1);
  806. }
  807. /* Invalid encrypted section. */
  808. {
  809. char *plaintext;
  810. tor_asprintf(&plaintext, template, "3", "180", "42", bad_value);
  811. ret = hs_desc_decode_plaintext(plaintext, &desc_plaintext);
  812. tor_free(plaintext);
  813. tt_int_op(ret, OP_EQ, -1);
  814. }
  815. /* Invalid revision counter. */
  816. {
  817. char *plaintext;
  818. tor_asprintf(&plaintext, template, "3", "180", bad_value, "MESSAGE");
  819. ret = hs_desc_decode_plaintext(plaintext, &desc_plaintext);
  820. tor_free(plaintext);
  821. tt_int_op(ret, OP_EQ, -1);
  822. }
  823. done:
  824. ;
  825. }
  826. static void
  827. test_validate_cert(void *arg)
  828. {
  829. int ret;
  830. time_t now = time(NULL);
  831. ed25519_keypair_t kp;
  832. tor_cert_t *cert = NULL;
  833. (void) arg;
  834. ret = ed25519_keypair_generate(&kp, 0);
  835. tt_int_op(ret, ==, 0);
  836. /* Cert of type CERT_TYPE_AUTH_HS_IP_KEY. */
  837. cert = tor_cert_create(&kp, CERT_TYPE_AUTH_HS_IP_KEY,
  838. &kp.pubkey, now, 3600,
  839. CERT_FLAG_INCLUDE_SIGNING_KEY);
  840. tt_assert(cert);
  841. /* Test with empty certificate. */
  842. ret = cert_is_valid(NULL, CERT_TYPE_AUTH_HS_IP_KEY, "unicorn");
  843. tt_int_op(ret, OP_EQ, 0);
  844. /* Test with a bad type. */
  845. ret = cert_is_valid(cert, CERT_TYPE_SIGNING_HS_DESC, "unicorn");
  846. tt_int_op(ret, OP_EQ, 0);
  847. /* Normal validation. */
  848. ret = cert_is_valid(cert, CERT_TYPE_AUTH_HS_IP_KEY, "unicorn");
  849. tt_int_op(ret, OP_EQ, 1);
  850. /* Break signing key so signature verification will fails. */
  851. memset(&cert->signing_key, 0, sizeof(cert->signing_key));
  852. ret = cert_is_valid(cert, CERT_TYPE_AUTH_HS_IP_KEY, "unicorn");
  853. tt_int_op(ret, OP_EQ, 0);
  854. tor_cert_free(cert);
  855. /* Try a cert without including the signing key. */
  856. cert = tor_cert_create(&kp, CERT_TYPE_AUTH_HS_IP_KEY, &kp.pubkey, now,
  857. 3600, 0);
  858. tt_assert(cert);
  859. /* Test with a bad type. */
  860. ret = cert_is_valid(cert, CERT_TYPE_AUTH_HS_IP_KEY, "unicorn");
  861. tt_int_op(ret, OP_EQ, 0);
  862. done:
  863. tor_cert_free(cert);
  864. }
  865. static void
  866. test_desc_signature(void *arg)
  867. {
  868. int ret;
  869. char *data = NULL, *desc = NULL;
  870. char sig_b64[ED25519_SIG_BASE64_LEN + 1];
  871. ed25519_keypair_t kp;
  872. ed25519_signature_t sig;
  873. (void) arg;
  874. ed25519_keypair_generate(&kp, 0);
  875. /* Setup a phoony descriptor but with a valid signature token that is the
  876. * signature is verifiable. */
  877. tor_asprintf(&data, "This is a signed descriptor\n");
  878. ret = ed25519_sign_prefixed(&sig, (const uint8_t *) data, strlen(data),
  879. "Tor onion service descriptor sig v3", &kp);
  880. tt_int_op(ret, ==, 0);
  881. ret = ed25519_signature_to_base64(sig_b64, &sig);
  882. tt_int_op(ret, ==, 0);
  883. /* Build the descriptor that should be valid. */
  884. tor_asprintf(&desc, "%ssignature %s\n", data, sig_b64);
  885. ret = desc_sig_is_valid(sig_b64, &kp.pubkey, desc, strlen(desc));
  886. tt_int_op(ret, ==, 1);
  887. /* Junk signature. */
  888. ret = desc_sig_is_valid("JUNK", &kp.pubkey, desc, strlen(desc));
  889. tt_int_op(ret, ==, 0);
  890. done:
  891. tor_free(desc);
  892. tor_free(data);
  893. }
  894. struct testcase_t hs_descriptor[] = {
  895. /* Encoding tests. */
  896. { "cert_encoding", test_cert_encoding, TT_FORK,
  897. NULL, NULL },
  898. { "link_specifier", test_link_specifier, TT_FORK,
  899. NULL, NULL },
  900. { "encode_descriptor", test_encode_descriptor, TT_FORK,
  901. NULL, NULL },
  902. { "descriptor_padding", test_descriptor_padding, TT_FORK,
  903. NULL, NULL },
  904. /* Decoding tests. */
  905. { "decode_descriptor", test_decode_descriptor, TT_FORK,
  906. NULL, NULL },
  907. { "encrypted_data_len", test_encrypted_data_len, TT_FORK,
  908. NULL, NULL },
  909. { "decode_intro_point", test_decode_intro_point, TT_FORK,
  910. NULL, NULL },
  911. { "decode_plaintext", test_decode_plaintext, TT_FORK,
  912. NULL, NULL },
  913. /* Misc. */
  914. { "version", test_supported_version, TT_FORK,
  915. NULL, NULL },
  916. { "validate_cert", test_validate_cert, TT_FORK,
  917. NULL, NULL },
  918. { "desc_signature", test_desc_signature, TT_FORK,
  919. NULL, NULL },
  920. END_OF_TESTCASES
  921. };