2
0

x509_internal_test.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. /* Internal tests for the x509 and x509v3 modules */
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <openssl/x509.h>
  13. #include <openssl/x509v3.h>
  14. #include "testutil.h"
  15. #include "internal/nelem.h"
  16. /**********************************************************************
  17. *
  18. * Test of x509v3
  19. *
  20. ***/
  21. #include "../crypto/x509v3/ext_dat.h"
  22. #include "../crypto/x509v3/standard_exts.h"
  23. static int test_standard_exts(void)
  24. {
  25. size_t i;
  26. int prev = -1, good = 1;
  27. const X509V3_EXT_METHOD **tmp;
  28. tmp = standard_exts;
  29. for (i = 0; i < OSSL_NELEM(standard_exts); i++, tmp++) {
  30. if ((*tmp)->ext_nid < prev)
  31. good = 0;
  32. prev = (*tmp)->ext_nid;
  33. }
  34. if (!good) {
  35. tmp = standard_exts;
  36. TEST_error("Extensions out of order!");
  37. for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++)
  38. TEST_note("%d : %s", (*tmp)->ext_nid, OBJ_nid2sn((*tmp)->ext_nid));
  39. }
  40. return good;
  41. }
  42. int setup_tests(void)
  43. {
  44. ADD_TEST(test_standard_exts);
  45. return 1;
  46. }