2
0

v3_pku.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 1999-2016 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. #include <stdio.h>
  10. #include "internal/cryptlib.h"
  11. #include <openssl/asn1.h>
  12. #include <openssl/asn1t.h>
  13. #include <openssl/x509v3.h>
  14. #include "ext_dat.h"
  15. static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
  16. PKEY_USAGE_PERIOD *usage, BIO *out,
  17. int indent);
  18. const X509V3_EXT_METHOD v3_pkey_usage_period = {
  19. NID_private_key_usage_period, 0, ASN1_ITEM_ref(PKEY_USAGE_PERIOD),
  20. 0, 0, 0, 0,
  21. 0, 0, 0, 0,
  22. (X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD, NULL,
  23. NULL
  24. };
  25. ASN1_SEQUENCE(PKEY_USAGE_PERIOD) = {
  26. ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notBefore, ASN1_GENERALIZEDTIME, 0),
  27. ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notAfter, ASN1_GENERALIZEDTIME, 1)
  28. } ASN1_SEQUENCE_END(PKEY_USAGE_PERIOD)
  29. IMPLEMENT_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
  30. static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
  31. PKEY_USAGE_PERIOD *usage, BIO *out,
  32. int indent)
  33. {
  34. BIO_printf(out, "%*s", indent, "");
  35. if (usage->notBefore) {
  36. BIO_write(out, "Not Before: ", 12);
  37. ASN1_GENERALIZEDTIME_print(out, usage->notBefore);
  38. if (usage->notAfter)
  39. BIO_write(out, ", ", 2);
  40. }
  41. if (usage->notAfter) {
  42. BIO_write(out, "Not After: ", 11);
  43. ASN1_GENERALIZEDTIME_print(out, usage->notAfter);
  44. }
  45. return 1;
  46. }