crmf.h 6.3 KB

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