2
0

ocsp_asn.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright 2000-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 <openssl/asn1.h>
  10. #include <openssl/asn1t.h>
  11. #include <openssl/ocsp.h>
  12. #include "ocsp_local.h"
  13. ASN1_SEQUENCE(OCSP_SIGNATURE) = {
  14. ASN1_EMBED(OCSP_SIGNATURE, signatureAlgorithm, X509_ALGOR),
  15. ASN1_SIMPLE(OCSP_SIGNATURE, signature, ASN1_BIT_STRING),
  16. ASN1_EXP_SEQUENCE_OF_OPT(OCSP_SIGNATURE, certs, X509, 0)
  17. } ASN1_SEQUENCE_END(OCSP_SIGNATURE)
  18. IMPLEMENT_ASN1_FUNCTIONS(OCSP_SIGNATURE)
  19. ASN1_SEQUENCE(OCSP_CERTID) = {
  20. ASN1_EMBED(OCSP_CERTID, hashAlgorithm, X509_ALGOR),
  21. ASN1_EMBED(OCSP_CERTID, issuerNameHash, ASN1_OCTET_STRING),
  22. ASN1_EMBED(OCSP_CERTID, issuerKeyHash, ASN1_OCTET_STRING),
  23. ASN1_EMBED(OCSP_CERTID, serialNumber, ASN1_INTEGER)
  24. } ASN1_SEQUENCE_END(OCSP_CERTID)
  25. IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTID)
  26. ASN1_SEQUENCE(OCSP_ONEREQ) = {
  27. ASN1_SIMPLE(OCSP_ONEREQ, reqCert, OCSP_CERTID),
  28. ASN1_EXP_SEQUENCE_OF_OPT(OCSP_ONEREQ, singleRequestExtensions, X509_EXTENSION, 0)
  29. } ASN1_SEQUENCE_END(OCSP_ONEREQ)
  30. IMPLEMENT_ASN1_FUNCTIONS(OCSP_ONEREQ)
  31. ASN1_SEQUENCE(OCSP_REQINFO) = {
  32. ASN1_EXP_OPT(OCSP_REQINFO, version, ASN1_INTEGER, 0),
  33. ASN1_EXP_OPT(OCSP_REQINFO, requestorName, GENERAL_NAME, 1),
  34. ASN1_SEQUENCE_OF(OCSP_REQINFO, requestList, OCSP_ONEREQ),
  35. ASN1_EXP_SEQUENCE_OF_OPT(OCSP_REQINFO, requestExtensions, X509_EXTENSION, 2)
  36. } ASN1_SEQUENCE_END(OCSP_REQINFO)
  37. IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQINFO)
  38. ASN1_SEQUENCE(OCSP_REQUEST) = {
  39. ASN1_EMBED(OCSP_REQUEST, tbsRequest, OCSP_REQINFO),
  40. ASN1_EXP_OPT(OCSP_REQUEST, optionalSignature, OCSP_SIGNATURE, 0)
  41. } ASN1_SEQUENCE_END(OCSP_REQUEST)
  42. IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQUEST)
  43. /* OCSP_RESPONSE templates */
  44. ASN1_SEQUENCE(OCSP_RESPBYTES) = {
  45. ASN1_SIMPLE(OCSP_RESPBYTES, responseType, ASN1_OBJECT),
  46. ASN1_SIMPLE(OCSP_RESPBYTES, response, ASN1_OCTET_STRING)
  47. } ASN1_SEQUENCE_END(OCSP_RESPBYTES)
  48. IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPBYTES)
  49. ASN1_SEQUENCE(OCSP_RESPONSE) = {
  50. ASN1_SIMPLE(OCSP_RESPONSE, responseStatus, ASN1_ENUMERATED),
  51. ASN1_EXP_OPT(OCSP_RESPONSE, responseBytes, OCSP_RESPBYTES, 0)
  52. } ASN1_SEQUENCE_END(OCSP_RESPONSE)
  53. IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPONSE)
  54. ASN1_CHOICE(OCSP_RESPID) = {
  55. ASN1_EXP(OCSP_RESPID, value.byName, X509_NAME, 1),
  56. ASN1_EXP(OCSP_RESPID, value.byKey, ASN1_OCTET_STRING, 2)
  57. } ASN1_CHOICE_END(OCSP_RESPID)
  58. IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPID)
  59. ASN1_SEQUENCE(OCSP_REVOKEDINFO) = {
  60. ASN1_SIMPLE(OCSP_REVOKEDINFO, revocationTime, ASN1_GENERALIZEDTIME),
  61. ASN1_EXP_OPT(OCSP_REVOKEDINFO, revocationReason, ASN1_ENUMERATED, 0)
  62. } ASN1_SEQUENCE_END(OCSP_REVOKEDINFO)
  63. IMPLEMENT_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
  64. ASN1_CHOICE(OCSP_CERTSTATUS) = {
  65. ASN1_IMP(OCSP_CERTSTATUS, value.good, ASN1_NULL, 0),
  66. ASN1_IMP(OCSP_CERTSTATUS, value.revoked, OCSP_REVOKEDINFO, 1),
  67. ASN1_IMP(OCSP_CERTSTATUS, value.unknown, ASN1_NULL, 2)
  68. } ASN1_CHOICE_END(OCSP_CERTSTATUS)
  69. IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
  70. ASN1_SEQUENCE(OCSP_SINGLERESP) = {
  71. ASN1_SIMPLE(OCSP_SINGLERESP, certId, OCSP_CERTID),
  72. ASN1_SIMPLE(OCSP_SINGLERESP, certStatus, OCSP_CERTSTATUS),
  73. ASN1_SIMPLE(OCSP_SINGLERESP, thisUpdate, ASN1_GENERALIZEDTIME),
  74. ASN1_EXP_OPT(OCSP_SINGLERESP, nextUpdate, ASN1_GENERALIZEDTIME, 0),
  75. ASN1_EXP_SEQUENCE_OF_OPT(OCSP_SINGLERESP, singleExtensions, X509_EXTENSION, 1)
  76. } ASN1_SEQUENCE_END(OCSP_SINGLERESP)
  77. IMPLEMENT_ASN1_FUNCTIONS(OCSP_SINGLERESP)
  78. ASN1_SEQUENCE(OCSP_RESPDATA) = {
  79. ASN1_EXP_OPT(OCSP_RESPDATA, version, ASN1_INTEGER, 0),
  80. ASN1_EMBED(OCSP_RESPDATA, responderId, OCSP_RESPID),
  81. ASN1_SIMPLE(OCSP_RESPDATA, producedAt, ASN1_GENERALIZEDTIME),
  82. ASN1_SEQUENCE_OF(OCSP_RESPDATA, responses, OCSP_SINGLERESP),
  83. ASN1_EXP_SEQUENCE_OF_OPT(OCSP_RESPDATA, responseExtensions, X509_EXTENSION, 1)
  84. } ASN1_SEQUENCE_END(OCSP_RESPDATA)
  85. IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPDATA)
  86. ASN1_SEQUENCE(OCSP_BASICRESP) = {
  87. ASN1_EMBED(OCSP_BASICRESP, tbsResponseData, OCSP_RESPDATA),
  88. ASN1_EMBED(OCSP_BASICRESP, signatureAlgorithm, X509_ALGOR),
  89. ASN1_SIMPLE(OCSP_BASICRESP, signature, ASN1_BIT_STRING),
  90. ASN1_EXP_SEQUENCE_OF_OPT(OCSP_BASICRESP, certs, X509, 0)
  91. } ASN1_SEQUENCE_END(OCSP_BASICRESP)
  92. IMPLEMENT_ASN1_FUNCTIONS(OCSP_BASICRESP)
  93. ASN1_SEQUENCE(OCSP_CRLID) = {
  94. ASN1_EXP_OPT(OCSP_CRLID, crlUrl, ASN1_IA5STRING, 0),
  95. ASN1_EXP_OPT(OCSP_CRLID, crlNum, ASN1_INTEGER, 1),
  96. ASN1_EXP_OPT(OCSP_CRLID, crlTime, ASN1_GENERALIZEDTIME, 2)
  97. } ASN1_SEQUENCE_END(OCSP_CRLID)
  98. IMPLEMENT_ASN1_FUNCTIONS(OCSP_CRLID)
  99. ASN1_SEQUENCE(OCSP_SERVICELOC) = {
  100. ASN1_SIMPLE(OCSP_SERVICELOC, issuer, X509_NAME),
  101. ASN1_SEQUENCE_OF_OPT(OCSP_SERVICELOC, locator, ACCESS_DESCRIPTION)
  102. } ASN1_SEQUENCE_END(OCSP_SERVICELOC)
  103. IMPLEMENT_ASN1_FUNCTIONS(OCSP_SERVICELOC)