test_hs_descriptor.c 33 KB

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