crmf.h.in 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*-
  2. * {- join("\n * ", @autowarntext) -}
  3. *
  4. * Copyright 2007-2023 The OpenSSL Project Authors. All Rights Reserved.
  5. * Copyright Nokia 2007-2019
  6. * Copyright Siemens AG 2015-2019
  7. *
  8. * Licensed under the Apache License 2.0 (the "License"). You may not use
  9. * this file except in compliance with the License. You can obtain a copy
  10. * in the file LICENSE in the source distribution or at
  11. * https://www.openssl.org/source/license.html
  12. *
  13. * CRMF (RFC 4211) implementation by M. Peylo, M. Viljanen, and D. von Oheimb.
  14. */
  15. {-
  16. use OpenSSL::stackhash qw(generate_stack_macros);
  17. -}
  18. #ifndef OPENSSL_CRMF_H
  19. # define OPENSSL_CRMF_H
  20. # include <openssl/opensslconf.h>
  21. # ifndef OPENSSL_NO_CRMF
  22. # include <openssl/opensslv.h>
  23. # include <openssl/safestack.h>
  24. # include <openssl/crmferr.h>
  25. # include <openssl/x509v3.h> /* for GENERAL_NAME etc. */
  26. /* explicit #includes not strictly needed since implied by the above: */
  27. # include <openssl/types.h>
  28. # include <openssl/x509.h>
  29. # ifdef __cplusplus
  30. extern "C" {
  31. # endif
  32. # define OSSL_CRMF_POPOPRIVKEY_THISMESSAGE 0
  33. # define OSSL_CRMF_POPOPRIVKEY_SUBSEQUENTMESSAGE 1
  34. # define OSSL_CRMF_POPOPRIVKEY_DHMAC 2
  35. # define OSSL_CRMF_POPOPRIVKEY_AGREEMAC 3
  36. # define OSSL_CRMF_POPOPRIVKEY_ENCRYPTEDKEY 4
  37. # define OSSL_CRMF_SUBSEQUENTMESSAGE_ENCRCERT 0
  38. # define OSSL_CRMF_SUBSEQUENTMESSAGE_CHALLENGERESP 1
  39. typedef struct ossl_crmf_encryptedvalue_st OSSL_CRMF_ENCRYPTEDVALUE;
  40. DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCRYPTEDVALUE)
  41. typedef struct ossl_crmf_msg_st OSSL_CRMF_MSG;
  42. DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_MSG)
  43. DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_MSG)
  44. {-
  45. generate_stack_macros("OSSL_CRMF_MSG");
  46. -}
  47. typedef struct ossl_crmf_attributetypeandvalue_st OSSL_CRMF_ATTRIBUTETYPEANDVALUE;
  48. typedef struct ossl_crmf_pbmparameter_st OSSL_CRMF_PBMPARAMETER;
  49. DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PBMPARAMETER)
  50. typedef struct ossl_crmf_poposigningkey_st OSSL_CRMF_POPOSIGNINGKEY;
  51. typedef struct ossl_crmf_certrequest_st OSSL_CRMF_CERTREQUEST;
  52. typedef struct ossl_crmf_certid_st OSSL_CRMF_CERTID;
  53. DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTID)
  54. DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTID)
  55. {-
  56. generate_stack_macros("OSSL_CRMF_CERTID");
  57. -}
  58. typedef struct ossl_crmf_pkipublicationinfo_st OSSL_CRMF_PKIPUBLICATIONINFO;
  59. DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PKIPUBLICATIONINFO)
  60. typedef struct ossl_crmf_singlepubinfo_st OSSL_CRMF_SINGLEPUBINFO;
  61. DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_SINGLEPUBINFO)
  62. typedef struct ossl_crmf_certtemplate_st OSSL_CRMF_CERTTEMPLATE;
  63. DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTTEMPLATE)
  64. typedef STACK_OF(OSSL_CRMF_MSG) OSSL_CRMF_MSGS;
  65. DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_MSGS)
  66. typedef struct ossl_crmf_optionalvalidity_st OSSL_CRMF_OPTIONALVALIDITY;
  67. /* crmf_pbm.c */
  68. OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(OSSL_LIB_CTX *libctx, size_t slen,
  69. int owfnid, size_t itercnt,
  70. int macnid);
  71. int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq,
  72. const OSSL_CRMF_PBMPARAMETER *pbmp,
  73. const unsigned char *msg, size_t msglen,
  74. const unsigned char *sec, size_t seclen,
  75. unsigned char **mac, size_t *maclen);
  76. /* crmf_lib.c */
  77. int OSSL_CRMF_MSG_set1_regCtrl_regToken(OSSL_CRMF_MSG *msg,
  78. const ASN1_UTF8STRING *tok);
  79. ASN1_UTF8STRING
  80. *OSSL_CRMF_MSG_get0_regCtrl_regToken(const OSSL_CRMF_MSG *msg);
  81. int OSSL_CRMF_MSG_set1_regCtrl_authenticator(OSSL_CRMF_MSG *msg,
  82. const ASN1_UTF8STRING *auth);
  83. ASN1_UTF8STRING
  84. *OSSL_CRMF_MSG_get0_regCtrl_authenticator(const OSSL_CRMF_MSG *msg);
  85. int
  86. OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo(OSSL_CRMF_PKIPUBLICATIONINFO *pi,
  87. OSSL_CRMF_SINGLEPUBINFO *spi);
  88. # define OSSL_CRMF_PUB_METHOD_DONTCARE 0
  89. # define OSSL_CRMF_PUB_METHOD_X500 1
  90. # define OSSL_CRMF_PUB_METHOD_WEB 2
  91. # define OSSL_CRMF_PUB_METHOD_LDAP 3
  92. int OSSL_CRMF_MSG_set0_SinglePubInfo(OSSL_CRMF_SINGLEPUBINFO *spi,
  93. int method, GENERAL_NAME *nm);
  94. # define OSSL_CRMF_PUB_ACTION_DONTPUBLISH 0
  95. # define OSSL_CRMF_PUB_ACTION_PLEASEPUBLISH 1
  96. int OSSL_CRMF_MSG_set_PKIPublicationInfo_action(OSSL_CRMF_PKIPUBLICATIONINFO *pi,
  97. int action);
  98. int OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo(OSSL_CRMF_MSG *msg,
  99. const OSSL_CRMF_PKIPUBLICATIONINFO *pi);
  100. OSSL_CRMF_PKIPUBLICATIONINFO
  101. *OSSL_CRMF_MSG_get0_regCtrl_pkiPublicationInfo(const OSSL_CRMF_MSG *msg);
  102. int OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey(OSSL_CRMF_MSG *msg,
  103. const X509_PUBKEY *pubkey);
  104. X509_PUBKEY
  105. *OSSL_CRMF_MSG_get0_regCtrl_protocolEncrKey(const OSSL_CRMF_MSG *msg);
  106. int OSSL_CRMF_MSG_set1_regCtrl_oldCertID(OSSL_CRMF_MSG *msg,
  107. const OSSL_CRMF_CERTID *cid);
  108. OSSL_CRMF_CERTID
  109. *OSSL_CRMF_MSG_get0_regCtrl_oldCertID(const OSSL_CRMF_MSG *msg);
  110. OSSL_CRMF_CERTID *OSSL_CRMF_CERTID_gen(const X509_NAME *issuer,
  111. const ASN1_INTEGER *serial);
  112. int OSSL_CRMF_MSG_set1_regInfo_utf8Pairs(OSSL_CRMF_MSG *msg,
  113. const ASN1_UTF8STRING *utf8pairs);
  114. ASN1_UTF8STRING
  115. *OSSL_CRMF_MSG_get0_regInfo_utf8Pairs(const OSSL_CRMF_MSG *msg);
  116. int OSSL_CRMF_MSG_set1_regInfo_certReq(OSSL_CRMF_MSG *msg,
  117. const OSSL_CRMF_CERTREQUEST *cr);
  118. OSSL_CRMF_CERTREQUEST
  119. *OSSL_CRMF_MSG_get0_regInfo_certReq(const OSSL_CRMF_MSG *msg);
  120. int OSSL_CRMF_MSG_set0_validity(OSSL_CRMF_MSG *crm,
  121. ASN1_TIME *notBefore, ASN1_TIME *notAfter);
  122. int OSSL_CRMF_MSG_set_certReqId(OSSL_CRMF_MSG *crm, int rid);
  123. int OSSL_CRMF_MSG_get_certReqId(const OSSL_CRMF_MSG *crm);
  124. int OSSL_CRMF_MSG_set0_extensions(OSSL_CRMF_MSG *crm, X509_EXTENSIONS *exts);
  125. int OSSL_CRMF_MSG_push0_extension(OSSL_CRMF_MSG *crm, X509_EXTENSION *ext);
  126. # define OSSL_CRMF_POPO_NONE -1
  127. # define OSSL_CRMF_POPO_RAVERIFIED 0
  128. # define OSSL_CRMF_POPO_SIGNATURE 1
  129. # define OSSL_CRMF_POPO_KEYENC 2
  130. # define OSSL_CRMF_POPO_KEYAGREE 3
  131. int OSSL_CRMF_MSG_create_popo(int meth, OSSL_CRMF_MSG *crm,
  132. EVP_PKEY *pkey, const EVP_MD *digest,
  133. OSSL_LIB_CTX *libctx, const char *propq);
  134. int OSSL_CRMF_MSGS_verify_popo(const OSSL_CRMF_MSGS *reqs,
  135. int rid, int acceptRAVerified,
  136. OSSL_LIB_CTX *libctx, const char *propq);
  137. OSSL_CRMF_CERTTEMPLATE *OSSL_CRMF_MSG_get0_tmpl(const OSSL_CRMF_MSG *crm);
  138. X509_PUBKEY
  139. *OSSL_CRMF_CERTTEMPLATE_get0_publicKey(const OSSL_CRMF_CERTTEMPLATE *tmpl);
  140. const X509_NAME
  141. *OSSL_CRMF_CERTTEMPLATE_get0_subject(const OSSL_CRMF_CERTTEMPLATE *tmpl);
  142. const X509_NAME
  143. *OSSL_CRMF_CERTTEMPLATE_get0_issuer(const OSSL_CRMF_CERTTEMPLATE *tmpl);
  144. const ASN1_INTEGER
  145. *OSSL_CRMF_CERTTEMPLATE_get0_serialNumber(const OSSL_CRMF_CERTTEMPLATE *tmpl);
  146. X509_EXTENSIONS
  147. *OSSL_CRMF_CERTTEMPLATE_get0_extensions(const OSSL_CRMF_CERTTEMPLATE *tmpl);
  148. const X509_NAME
  149. *OSSL_CRMF_CERTID_get0_issuer(const OSSL_CRMF_CERTID *cid);
  150. const ASN1_INTEGER
  151. *OSSL_CRMF_CERTID_get0_serialNumber(const OSSL_CRMF_CERTID *cid);
  152. int OSSL_CRMF_CERTTEMPLATE_fill(OSSL_CRMF_CERTTEMPLATE *tmpl,
  153. EVP_PKEY *pubkey,
  154. const X509_NAME *subject,
  155. const X509_NAME *issuer,
  156. const ASN1_INTEGER *serial);
  157. X509
  158. *OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(const OSSL_CRMF_ENCRYPTEDVALUE *ecert,
  159. OSSL_LIB_CTX *libctx, const char *propq,
  160. EVP_PKEY *pkey);
  161. # ifdef __cplusplus
  162. }
  163. # endif
  164. # endif /* !defined(OPENSSL_NO_CRMF) */
  165. #endif /* !defined(OPENSSL_CRMF_H) */