ocspi.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. /*
  5. * ocspi.h - NSS internal interfaces to OCSP code
  6. */
  7. #ifndef _OCSPI_H_
  8. #define _OCSPI_H_
  9. SECStatus OCSP_InitGlobal(void);
  10. SECStatus OCSP_ShutdownGlobal(void);
  11. ocspResponseData *
  12. ocsp_GetResponseData(CERTOCSPResponse *response, SECItem **tbsResponseDataDER);
  13. ocspSignature *
  14. ocsp_GetResponseSignature(CERTOCSPResponse *response);
  15. SECItem *
  16. ocsp_DigestValue(PLArenaPool *arena, SECOidTag digestAlg,
  17. SECItem *fill, const SECItem *src);
  18. PRBool
  19. ocsp_CertIsOCSPDefaultResponder(CERTCertDBHandle *handle, CERTCertificate *cert);
  20. CERTCertificate *
  21. ocsp_GetSignerCertificate(CERTCertDBHandle *handle, ocspResponseData *tbsData,
  22. ocspSignature *signature, CERTCertificate *issuer);
  23. SECStatus
  24. ocsp_VerifyResponseSignature(CERTCertificate *signerCert,
  25. ocspSignature *signature,
  26. SECItem *tbsResponseDataDER,
  27. void *pwArg);
  28. CERTOCSPRequest *
  29. cert_CreateSingleCertOCSPRequest(CERTOCSPCertID *certID,
  30. CERTCertificate *singleCert,
  31. PRTime time,
  32. PRBool addServiceLocator,
  33. CERTCertificate *signerCert);
  34. typedef enum { ocspMissing,
  35. ocspFresh,
  36. ocspStale } OCSPFreshness;
  37. SECStatus
  38. ocsp_GetCachedOCSPResponseStatus(CERTOCSPCertID *certID,
  39. PRTime time,
  40. PRBool ignoreOcspFailureMode,
  41. SECStatus *rvOcsp,
  42. SECErrorCodes *missingResponseError,
  43. OCSPFreshness *freshness);
  44. /*
  45. * FUNCTION: cert_ProcessOCSPResponse
  46. * Same behavior and basic parameters as CERT_GetOCSPStatusForCertID.
  47. * In addition it can update the OCSP cache (using information
  48. * available internally to this function).
  49. * INPUTS:
  50. * CERTCertDBHandle *handle
  51. * certificate DB of the cert that is being checked
  52. * CERTOCSPResponse *response
  53. * the OCSP response we want to retrieve status from.
  54. * CERTOCSPCertID *certID
  55. * the ID we want to look for from the response.
  56. * CERTCertificate *signerCert
  57. * the certificate that was used to sign the OCSP response.
  58. * must be obtained via a call to CERT_VerifyOCSPResponseSignature.
  59. * PRTime time
  60. * The time at which we're checking the status for.
  61. * PRBool *certIDWasConsumed
  62. * In and Out parameter.
  63. * If certIDWasConsumed is NULL on input,
  64. * this function might produce a deep copy of cert ID
  65. * for storing it in the cache.
  66. * If out value is true, ownership of parameter certID was
  67. * transferred to the OCSP cache.
  68. * SECStatus *cacheUpdateStatus
  69. * This optional out parameter will contain the result
  70. * of the cache update operation (if requested).
  71. * RETURN:
  72. * The return value is not influenced by the cache operation,
  73. * it matches the documentation for CERT_CheckOCSPStatus
  74. */
  75. SECStatus
  76. cert_ProcessOCSPResponse(CERTCertDBHandle *handle,
  77. CERTOCSPResponse *response,
  78. CERTOCSPCertID *certID,
  79. CERTCertificate *signerCert,
  80. PRTime time,
  81. PRBool *certIDWasConsumed,
  82. SECStatus *cacheUpdateStatus);
  83. /*
  84. * FUNCTION: cert_RememberOCSPProcessingFailure
  85. * If an application notices a failure during OCSP processing,
  86. * it should finally call this function. The failure will be recorded
  87. * in the OCSP cache in order to avoid repetitive failures.
  88. * INPUTS:
  89. * CERTOCSPCertID *certID
  90. * the ID that was used for the failed OCSP processing
  91. * PRBool *certIDWasConsumed
  92. * Out parameter, if set to true, ownership of parameter certID was
  93. * transferred to the OCSP cache.
  94. * RETURN:
  95. * Status of the cache update operation.
  96. */
  97. SECStatus
  98. cert_RememberOCSPProcessingFailure(CERTOCSPCertID *certID,
  99. PRBool *certIDWasConsumed);
  100. /*
  101. * FUNCTION: ocsp_GetResponderLocation
  102. * Check ocspx context for user-designated responder URI first. If not
  103. * found, checks cert AIA extension.
  104. * INPUTS:
  105. * CERTCertDBHandle *handle
  106. * certificate DB of the cert that is being checked
  107. * CERTCertificate *cert
  108. * The certificate being examined.
  109. * PRBool *certIDWasConsumed
  110. * Out parameter, if set to true, URI of default responder is
  111. * returned.
  112. * RETURN:
  113. * Responder URI.
  114. */
  115. char *
  116. ocsp_GetResponderLocation(CERTCertDBHandle *handle,
  117. CERTCertificate *cert,
  118. PRBool canUseDefaultLocation,
  119. PRBool *isDefault);
  120. /* FUNCTION: ocsp_FetchingFailureIsVerificationFailure
  121. * The function checks the global ocsp settings and
  122. * tells how to treat an ocsp response fetching failure.
  123. * RETURNS:
  124. * if PR_TRUE is returned, then treat fetching as a
  125. * revoked cert status.
  126. */
  127. PRBool
  128. ocsp_FetchingFailureIsVerificationFailure(void);
  129. size_t
  130. ocsp_UrlEncodeBase64Buf(const char *base64Buf, char *outputBuf);
  131. SECStatus
  132. ocsp_GetVerifiedSingleResponseForCertID(CERTCertDBHandle *handle,
  133. CERTOCSPResponse *response,
  134. CERTOCSPCertID *certID,
  135. CERTCertificate *signerCert,
  136. PRTime time,
  137. CERTOCSPSingleResponse **pSingleResponse);
  138. SECStatus
  139. ocsp_CertHasGoodStatus(ocspCertStatus *status, PRTime time);
  140. void
  141. ocsp_CacheSingleResponse(CERTOCSPCertID *certID,
  142. CERTOCSPSingleResponse *single,
  143. PRBool *certIDWasConsumed);
  144. #endif /* _OCSPI_H_ */