scep.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2012 Tobias Brunner
  3. * Copyright (C) 2005 Jan Hutter, Martin Willi
  4. * HSR Hochschule fuer Technik Rapperswil
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  13. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14. * for more details.
  15. */
  16. #ifndef _SCEP_H
  17. #define _SCEP_H
  18. #include <credentials/containers/pkcs7.h>
  19. #include <credentials/certificates/certificate.h>
  20. /* supported SCEP operation types */
  21. typedef enum {
  22. SCEP_PKI_OPERATION,
  23. SCEP_GET_CA_CERT
  24. } scep_op_t;
  25. /* SCEP pkiStatus values */
  26. typedef enum {
  27. SCEP_SUCCESS,
  28. SCEP_FAILURE,
  29. SCEP_PENDING,
  30. SCEP_UNKNOWN
  31. } pkiStatus_t;
  32. /* SCEP messageType values */
  33. typedef enum {
  34. SCEP_CertRep_MSG,
  35. SCEP_PKCSReq_MSG,
  36. SCEP_GetCertInitial_MSG,
  37. SCEP_GetCert_MSG,
  38. SCEP_GetCRL_MSG,
  39. SCEP_Unknown_MSG
  40. } scep_msg_t;
  41. /* SCEP failure reasons */
  42. typedef enum {
  43. SCEP_badAlg_REASON = 0,
  44. SCEP_badMessageCheck_REASON = 1,
  45. SCEP_badRequest_REASON = 2,
  46. SCEP_badTime_REASON = 3,
  47. SCEP_badCertId_REASON = 4,
  48. SCEP_unknown_REASON = 5
  49. } failInfo_t;
  50. /* SCEP attributes */
  51. typedef struct {
  52. scep_msg_t msgType;
  53. pkiStatus_t pkiStatus;
  54. failInfo_t failInfo;
  55. chunk_t transID;
  56. chunk_t senderNonce;
  57. chunk_t recipientNonce;
  58. } scep_attributes_t;
  59. extern const scep_attributes_t empty_scep_attributes;
  60. bool parse_attributes(chunk_t blob, scep_attributes_t *attrs);
  61. void scep_generate_transaction_id(public_key_t *key,
  62. chunk_t *transID,
  63. chunk_t *serialNumber);
  64. chunk_t scep_generate_pkcs10_fingerprint(chunk_t pkcs10);
  65. chunk_t scep_transId_attribute(chunk_t transaction_id);
  66. chunk_t scep_messageType_attribute(scep_msg_t m);
  67. chunk_t scep_senderNonce_attribute(void);
  68. chunk_t scep_build_request(chunk_t data, chunk_t transID, scep_msg_t msg,
  69. certificate_t *enc_cert, encryption_algorithm_t enc_alg,
  70. size_t key_size, certificate_t *signer_cert,
  71. hash_algorithm_t digest_alg, private_key_t *private_key);
  72. bool scep_http_request(const char *url, chunk_t msg, scep_op_t op,
  73. bool http_get_request, u_int timeout, char *src,
  74. chunk_t *response);
  75. err_t scep_parse_response(chunk_t response, chunk_t transID,
  76. container_t **out, scep_attributes_t *attrs);
  77. #endif /* _SCEP_H */