bdb_test.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. /* Copyright 2015 The Chromium OS Authors. All rights reserved.
  2. * Use of this source code is governed by a BSD-style license that can be
  3. * found in the LICENSE file.
  4. *
  5. * Unit tests
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include "2sha.h"
  11. #include "bdb.h"
  12. #include "host.h"
  13. #include "test_common.h"
  14. void check_header_tests(void)
  15. {
  16. struct bdb_header sgood = {
  17. .struct_magic = BDB_HEADER_MAGIC,
  18. .struct_major_version = BDB_HEADER_VERSION_MAJOR,
  19. .struct_minor_version = BDB_HEADER_VERSION_MINOR,
  20. .struct_size = sizeof(struct bdb_header),
  21. .bdb_load_address = -1,
  22. .bdb_size = 1024,
  23. .signed_size = 512,
  24. .oem_area_0_size = 256,
  25. };
  26. const size_t ssize = sgood.struct_size;
  27. struct bdb_header s;
  28. s = sgood;
  29. TEST_EQ_S(bdb_check_header(&s, ssize), BDB_SUCCESS);
  30. TEST_EQ_S(bdb_check_header(&s, ssize - 1), BDB_ERROR_BUF_SIZE);
  31. s = sgood;
  32. s.struct_size++;
  33. TEST_EQ_S(bdb_check_header(&s, ssize), BDB_ERROR_BUF_SIZE);
  34. s = sgood;
  35. s.struct_size--;
  36. TEST_EQ_S(bdb_check_header(&s, ssize), BDB_ERROR_STRUCT_SIZE);
  37. s = sgood;
  38. s.struct_magic++;
  39. TEST_EQ_S(bdb_check_header(&s, ssize), BDB_ERROR_STRUCT_MAGIC);
  40. s = sgood;
  41. s.struct_major_version++;
  42. TEST_EQ_S(bdb_check_header(&s, ssize), BDB_ERROR_STRUCT_VERSION);
  43. s = sgood;
  44. s.oem_area_0_size++;
  45. TEST_EQ_S(bdb_check_header(&s, ssize), BDB_ERROR_OEM_AREA_SIZE);
  46. s = sgood;
  47. s.bdb_size = ssize - 1;
  48. TEST_EQ_S(bdb_check_header(&s, ssize), BDB_ERROR_BDB_SIZE);
  49. }
  50. void check_key_tests(void)
  51. {
  52. struct bdb_key sgood = {
  53. .struct_magic = BDB_KEY_MAGIC,
  54. .struct_major_version = BDB_KEY_VERSION_MAJOR,
  55. .struct_minor_version = BDB_KEY_VERSION_MINOR,
  56. .struct_size = (sizeof(struct bdb_key) +
  57. BDB_RSA4096_KEY_DATA_SIZE),
  58. .hash_alg = BDB_HASH_ALG_SHA256,
  59. .sig_alg = BDB_SIG_ALG_RSA4096,
  60. .key_version = 1,
  61. .description = "Test key",
  62. };
  63. const size_t ssize = sgood.struct_size;
  64. struct bdb_key s;
  65. s = sgood;
  66. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_SUCCESS);
  67. TEST_EQ_S(bdb_check_key(&s, ssize - 1), BDB_ERROR_BUF_SIZE);
  68. s = sgood;
  69. s.struct_size++;
  70. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_ERROR_BUF_SIZE);
  71. s = sgood;
  72. s.struct_size--;
  73. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_ERROR_STRUCT_SIZE);
  74. s = sgood;
  75. s.struct_magic++;
  76. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_ERROR_STRUCT_MAGIC);
  77. s = sgood;
  78. s.struct_major_version++;
  79. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_ERROR_STRUCT_VERSION);
  80. /* Description must contain a null */
  81. s = sgood;
  82. memset(s.description, 'x', sizeof(s.description));
  83. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_ERROR_DESCRIPTION);
  84. /* Data AFTER the null is explicitly allowed, though */
  85. s = sgood;
  86. s.description[100] = 'x';
  87. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_SUCCESS);
  88. /* Limited algorithm choices at present */
  89. s = sgood;
  90. s.hash_alg = BDB_HASH_ALG_INVALID;
  91. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_ERROR_HASH_ALG);
  92. /* This works because ECDSA521 signatures are smaller than RSA4096 */
  93. s = sgood;
  94. s.sig_alg = BDB_SIG_ALG_ECSDSA521;
  95. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_SUCCESS);
  96. s = sgood;
  97. s.sig_alg = BDB_SIG_ALG_INVALID;
  98. TEST_EQ_S(bdb_check_key(&s, ssize), BDB_ERROR_SIG_ALG);
  99. }
  100. void check_sig_tests(void)
  101. {
  102. struct bdb_sig sgood = {
  103. .struct_magic = BDB_SIG_MAGIC,
  104. .struct_major_version = BDB_SIG_VERSION_MAJOR,
  105. .struct_minor_version = BDB_SIG_VERSION_MINOR,
  106. .struct_size = sizeof(struct bdb_sig) + BDB_RSA4096_SIG_SIZE,
  107. .hash_alg = BDB_HASH_ALG_SHA256,
  108. .sig_alg = BDB_SIG_ALG_RSA4096,
  109. .signed_size = 123,
  110. .description = "Test sig",
  111. };
  112. const size_t ssize = sgood.struct_size;
  113. struct bdb_sig s;
  114. s = sgood;
  115. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_SUCCESS);
  116. TEST_EQ_S(bdb_check_sig(&s, ssize - 1), BDB_ERROR_BUF_SIZE);
  117. s = sgood;
  118. s.struct_size++;
  119. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_ERROR_BUF_SIZE);
  120. s = sgood;
  121. s.struct_size--;
  122. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_ERROR_STRUCT_SIZE);
  123. s = sgood;
  124. s.struct_magic++;
  125. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_ERROR_STRUCT_MAGIC);
  126. s = sgood;
  127. s.struct_major_version++;
  128. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_ERROR_STRUCT_VERSION);
  129. /* Description must contain a null */
  130. s = sgood;
  131. memset(s.description, 'x', sizeof(s.description));
  132. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_ERROR_DESCRIPTION);
  133. /* Data AFTER the null is explicitly allowed, though */
  134. s = sgood;
  135. s.description[100] = 'x';
  136. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_SUCCESS);
  137. /* Limited algorithm choices at present */
  138. s = sgood;
  139. s.hash_alg = BDB_HASH_ALG_INVALID;
  140. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_ERROR_HASH_ALG);
  141. /* This works because ECDSA521 signatures are smaller than RSA4096 */
  142. s = sgood;
  143. s.sig_alg = BDB_SIG_ALG_ECSDSA521;
  144. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_SUCCESS);
  145. s = sgood;
  146. s.sig_alg = BDB_SIG_ALG_INVALID;
  147. TEST_EQ_S(bdb_check_sig(&s, ssize), BDB_ERROR_SIG_ALG);
  148. }
  149. void check_data_tests(void)
  150. {
  151. struct bdb_data sgood = {
  152. .struct_magic = BDB_DATA_MAGIC,
  153. .struct_major_version = BDB_DATA_VERSION_MAJOR,
  154. .struct_minor_version = BDB_DATA_VERSION_MINOR,
  155. .struct_size = sizeof(struct bdb_data),
  156. .data_version = 1,
  157. .oem_area_1_size = 256,
  158. .num_hashes = 3,
  159. .hash_entry_size = sizeof(struct bdb_hash),
  160. .signed_size = 2048,
  161. .description = "Test data",
  162. };
  163. const size_t ssize = sgood.signed_size;
  164. struct bdb_data s;
  165. s = sgood;
  166. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_SUCCESS);
  167. TEST_EQ_S(bdb_check_data(&s, ssize - 1), BDB_ERROR_BUF_SIZE);
  168. s = sgood;
  169. s.struct_size--;
  170. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_ERROR_STRUCT_SIZE);
  171. s = sgood;
  172. s.struct_magic++;
  173. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_ERROR_STRUCT_MAGIC);
  174. s = sgood;
  175. s.struct_major_version++;
  176. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_ERROR_STRUCT_VERSION);
  177. /* Description must contain a null */
  178. s = sgood;
  179. memset(s.description, 'x', sizeof(s.description));
  180. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_ERROR_DESCRIPTION);
  181. /* Data AFTER the null is explicitly allowed, though */
  182. s = sgood;
  183. s.description[100] = 'x';
  184. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_SUCCESS);
  185. s = sgood;
  186. s.hash_entry_size--;
  187. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_ERROR_HASH_ENTRY_SIZE);
  188. s = sgood;
  189. s.oem_area_1_size++;
  190. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_ERROR_OEM_AREA_SIZE);
  191. /* Check exact size needed */
  192. s = sgood;
  193. s.signed_size = sizeof(s) + s.num_hashes * sizeof(struct bdb_hash) +
  194. s.oem_area_1_size;
  195. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_SUCCESS);
  196. s.signed_size--;
  197. TEST_EQ_S(bdb_check_data(&s, ssize), BDB_ERROR_SIGNED_SIZE);
  198. /*
  199. * TODO: Verify wraparound check works. That can only be tested on a
  200. * platform where size_t is uint32_t, because otherwise a 32-bit
  201. * oem_area_1_size can't cause wraparound.
  202. */
  203. }
  204. /**
  205. * Test bdb_verify() and bdb_create()
  206. */
  207. void check_bdb_verify(const char *key_dir)
  208. {
  209. uint8_t oem_area_0[32] = "Some OEM area.";
  210. uint8_t oem_area_1[64] = "Some other OEM area.";
  211. char filename[1024];
  212. struct bdb_hash hash[2] = {
  213. {
  214. .offset = 0x10000,
  215. .size = 0x18000,
  216. .partition = 1,
  217. .type = BDB_DATA_SP_RW,
  218. .load_address = 0x100000,
  219. .digest = {0x11, 0x11, 0x11, 0x10},
  220. },
  221. {
  222. .offset = 0x28000,
  223. .size = 0x20000,
  224. .partition = 1,
  225. .type = BDB_DATA_AP_RW,
  226. .load_address = 0x200000,
  227. .digest = {0x22, 0x22, 0x22, 0x20},
  228. },
  229. };
  230. struct bdb_create_params p = {
  231. .bdb_load_address = 0x11223344,
  232. .oem_area_0 = oem_area_0,
  233. .oem_area_0_size = sizeof(oem_area_0),
  234. .oem_area_1 = oem_area_1,
  235. .oem_area_1_size = sizeof(oem_area_1),
  236. .header_sig_description = "The header sig",
  237. .data_sig_description = "The data sig",
  238. .data_description = "Test BDB data",
  239. .data_version = 3,
  240. .hash = hash,
  241. .num_hashes = 2,
  242. };
  243. uint8_t bdbkey_digest[BDB_SHA256_DIGEST_SIZE];
  244. struct bdb_header *hgood, *h;
  245. size_t hsize;
  246. /* Load keys */
  247. snprintf(filename, sizeof(filename), "%s/bdbkey.keyb", key_dir);
  248. p.bdbkey = bdb_create_key(filename, 100, "BDB key");
  249. snprintf(filename, sizeof(filename), "%s/datakey.keyb", key_dir);
  250. p.datakey = bdb_create_key(filename, 200, "datakey");
  251. snprintf(filename, sizeof(filename), "%s/bdbkey.pem", key_dir);
  252. p.private_bdbkey = read_pem(filename);
  253. snprintf(filename, sizeof(filename), "%s/datakey.pem", key_dir);
  254. p.private_datakey = read_pem(filename);
  255. if (!p.bdbkey || !p.datakey || !p.private_bdbkey || !p.private_datakey) {
  256. fprintf(stderr, "Unable to load test keys\n");
  257. exit(2);
  258. }
  259. vb2_digest_buffer((uint8_t *)p.bdbkey, p.bdbkey->struct_size,
  260. VB2_HASH_SHA256,
  261. bdbkey_digest, BDB_SHA256_DIGEST_SIZE);
  262. /* Create the test BDB */
  263. hgood = bdb_create(&p);
  264. if (!hgood) {
  265. fprintf(stderr, "Unable to create test BDB\n");
  266. exit(2);
  267. }
  268. hsize = hgood->bdb_size;
  269. /* Allocate a copy we can mangle */
  270. h = calloc(hsize, 1);
  271. /* As created, it should pass */
  272. memcpy(h, hgood, hsize);
  273. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_SUCCESS);
  274. /* It can accept a NULL pointer as bdb_key_digest */
  275. memcpy(h, hgood, hsize);
  276. TEST_EQ_S(bdb_verify(h, hsize, NULL), BDB_GOOD_OTHER_THAN_KEY);
  277. /* Mangle each component in turn */
  278. memcpy(h, hgood, hsize);
  279. h->struct_magic++;
  280. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_HEADER);
  281. memcpy(h, hgood, hsize);
  282. ((struct bdb_key *)bdb_get_bdbkey(h))->struct_magic++;
  283. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_BDBKEY);
  284. memcpy(h, hgood, hsize);
  285. ((struct bdb_key *)bdb_get_bdbkey(h))->key_version++;
  286. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_GOOD_OTHER_THAN_KEY);
  287. memcpy(h, hgood, hsize);
  288. h->oem_area_0_size += hsize;
  289. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_OEM_AREA_0);
  290. memcpy(h, hgood, hsize);
  291. ((struct bdb_key *)bdb_get_datakey(h))->struct_magic++;
  292. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_DATAKEY);
  293. memcpy(h, hgood, hsize);
  294. ((struct bdb_key *)bdb_get_datakey(h))->struct_size += 4;
  295. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_BDB_SIGNED_SIZE);
  296. memcpy(h, hgood, hsize);
  297. ((struct bdb_sig *)bdb_get_header_sig(h))->struct_magic++;
  298. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_HEADER_SIG);
  299. memcpy(h, hgood, hsize);
  300. ((struct bdb_sig *)bdb_get_header_sig(h))->signed_size--;
  301. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_HEADER_SIG);
  302. memcpy(h, hgood, hsize);
  303. ((struct bdb_sig *)bdb_get_header_sig(h))->sig_data[0] ^= 0x42;
  304. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_HEADER_SIG);
  305. /* Also make sure the header sig really covers all the fields */
  306. memcpy(h, hgood, hsize);
  307. ((struct bdb_key *)bdb_get_datakey(h))->key_version++;
  308. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_HEADER_SIG);
  309. memcpy(h, hgood, hsize);
  310. ((uint8_t *)bdb_get_oem_area_0(h))[0] ^= 0x42;
  311. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_HEADER_SIG);
  312. memcpy(h, hgood, hsize);
  313. ((uint8_t *)bdb_get_oem_area_0(h))[p.oem_area_0_size - 1] ^= 0x24;
  314. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_HEADER_SIG);
  315. /* Check data header */
  316. memcpy(h, hgood, hsize);
  317. ((struct bdb_data *)bdb_get_data(h))->struct_magic++;
  318. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_DATA);
  319. memcpy(h, hgood, hsize);
  320. ((struct bdb_sig *)bdb_get_data_sig(h))->struct_magic++;
  321. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest),
  322. BDB_ERROR_DATA_CHECK_SIG);
  323. memcpy(h, hgood, hsize);
  324. ((struct bdb_sig *)bdb_get_data_sig(h))->signed_size--;
  325. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest),
  326. BDB_ERROR_DATA_SIGNED_SIZE);
  327. memcpy(h, hgood, hsize);
  328. ((struct bdb_sig *)bdb_get_data_sig(h))->sig_data[0] ^= 0x42;
  329. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_DATA_SIG);
  330. /* Also make sure the data sig really covers all the fields */
  331. memcpy(h, hgood, hsize);
  332. ((struct bdb_data *)bdb_get_data(h))->data_version--;
  333. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_DATA_SIG);
  334. memcpy(h, hgood, hsize);
  335. ((uint8_t *)bdb_get_oem_area_1(h))[0] ^= 0x42;
  336. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_DATA_SIG);
  337. memcpy(h, hgood, hsize);
  338. ((uint8_t *)bdb_get_oem_area_1(h))[p.oem_area_1_size - 1] ^= 0x24;
  339. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_DATA_SIG);
  340. memcpy(h, hgood, hsize);
  341. ((struct bdb_hash *)bdb_get_hash_by_type(h, BDB_DATA_SP_RW))->offset++;
  342. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_DATA_SIG);
  343. memcpy(h, hgood, hsize);
  344. ((struct bdb_hash *)bdb_get_hash_by_type(h, BDB_DATA_AP_RW))
  345. ->digest[0] ^= 0x96;
  346. TEST_EQ_S(bdb_verify(h, hsize, bdbkey_digest), BDB_ERROR_DATA_SIG);
  347. /*
  348. * This is also a convenient place to test that all the parameters we
  349. * fed into bdb_create() also worked. That also tests all the
  350. * bdb_get_*() functions.
  351. */
  352. memcpy(h, hgood, hsize);
  353. TEST_EQ_S(h->bdb_load_address, p.bdb_load_address);
  354. TEST_EQ_S(strcmp(bdb_get_bdbkey(h)->description, p.bdbkey->description),
  355. 0);
  356. TEST_EQ_S(bdb_get_bdbkey(h)->key_version, p.bdbkey->key_version);
  357. TEST_EQ_S(h->oem_area_0_size, p.oem_area_0_size);
  358. TEST_EQ_S(memcmp(bdb_get_oem_area_0(h), oem_area_0, sizeof(oem_area_0)),
  359. 0);
  360. TEST_EQ_S(strcmp(bdb_get_datakey(h)->description, p.datakey->description),
  361. 0);
  362. TEST_EQ_S(bdb_get_datakey(h)->key_version, p.datakey->key_version);
  363. TEST_EQ_S(strcmp(bdb_get_header_sig(h)->description,
  364. p.header_sig_description), 0);
  365. TEST_EQ_S(strcmp(bdb_get_data(h)->description, p.data_description), 0);
  366. TEST_EQ_S(bdb_get_data(h)->data_version, p.data_version);
  367. TEST_EQ_S(bdb_get_data(h)->num_hashes, p.num_hashes);
  368. TEST_EQ_S(bdb_get_data(h)->oem_area_1_size, p.oem_area_1_size);
  369. TEST_EQ_S(memcmp(bdb_get_oem_area_1(h), oem_area_1, sizeof(oem_area_1)),
  370. 0);
  371. TEST_EQ_S(strcmp(bdb_get_data_sig(h)->description,
  372. p.data_sig_description), 0);
  373. /* Test getting hash entries */
  374. memcpy(h, hgood, hsize);
  375. TEST_EQ_S(bdb_get_hash_by_type(h, BDB_DATA_SP_RW)
  376. ->offset, hash[0].offset);
  377. TEST_EQ_S(bdb_get_hash_by_index(h, 0)
  378. ->offset, hash[0].offset);
  379. TEST_EQ_S(bdb_get_hash_by_type(h, BDB_DATA_AP_RW)
  380. ->offset, hash[1].offset);
  381. TEST_EQ_S(bdb_get_hash_by_index(h, 1)
  382. ->offset, hash[1].offset);
  383. /* And a non-existent one */
  384. TEST_PTR_EQ(bdb_get_hash_by_type(h, BDB_DATA_MCU), NULL, NULL);
  385. TEST_PTR_EQ(bdb_get_hash_by_index(h, 2), NULL, NULL);
  386. /*
  387. * TODO: Verify wraparound checks works. That can only be tested on a
  388. * platform where size_t is uint32_t, because otherwise a 32-bit
  389. * oem_area_1_size can't cause wraparound.
  390. */
  391. /* Free keys and buffers */
  392. free(p.bdbkey);
  393. free(p.datakey);
  394. RSA_free(p.private_bdbkey);
  395. RSA_free(p.private_datakey);
  396. free(hgood);
  397. free(h);
  398. }
  399. /*****************************************************************************/
  400. int main(int argc, char *argv[])
  401. {
  402. if (argc != 2) {
  403. fprintf(stderr, "Usage: %s <keys_dir>", argv[0]);
  404. return -1;
  405. }
  406. printf("Running BDB tests...\n");
  407. check_header_tests();
  408. check_key_tests();
  409. check_sig_tests();
  410. check_data_tests();
  411. check_bdb_verify(argv[1]);
  412. printf("All tests passed!\n");
  413. return gTestSuccess ? 0 : 255;
  414. }