x509_internal_test.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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. #ifdef __VMS
  22. # pragma names save
  23. # pragma names as_is,shortened
  24. #endif
  25. #include "../crypto/x509v3/ext_dat.h"
  26. #include "../crypto/x509v3/standard_exts.h"
  27. #ifdef __VMS
  28. # pragma names restore
  29. #endif
  30. static int test_standard_exts(void)
  31. {
  32. size_t i;
  33. int prev = -1, good = 1;
  34. const X509V3_EXT_METHOD **tmp;
  35. tmp = standard_exts;
  36. for (i = 0; i < OSSL_NELEM(standard_exts); i++, tmp++) {
  37. if ((*tmp)->ext_nid < prev)
  38. good = 0;
  39. prev = (*tmp)->ext_nid;
  40. }
  41. if (!good) {
  42. tmp = standard_exts;
  43. TEST_error("Extensions out of order!");
  44. for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++)
  45. TEST_note("%d : %s", (*tmp)->ext_nid, OBJ_nid2sn((*tmp)->ext_nid));
  46. }
  47. return good;
  48. }
  49. int setup_tests()
  50. {
  51. ADD_TEST(test_standard_exts);
  52. return 1;
  53. }