| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#pragma once |
| 17 |
|
| 18 |
#include <openssl/x509.h> |
| 19 |
#include <stdint.h> |
| 20 |
|
| 21 |
#include "api/s2n.h" |
| 22 |
#include "crypto/s2n_pkey.h" |
| 23 |
#include "stuffer/s2n_stuffer.h" |
| 24 |
|
| 25 |
#define S2N_CERT_TYPE_COUNT S2N_PKEY_TYPE_SENTINEL |
| 26 |
|
| 27 |
struct s2n_cert_info { |
| 28 |
int signature_nid; |
| 29 |
|
| 30 |
int signature_digest_nid; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
int public_key_nid; |
| 35 |
int public_key_bits; |
| 36 |
bool self_signed; |
| 37 |
}; |
| 38 |
|
| 39 |
struct s2n_cert { |
| 40 |
s2n_pkey_type pkey_type; |
| 41 |
s2n_cert_public_key public_key; |
| 42 |
struct s2n_cert_info info; |
| 43 |
struct s2n_blob raw; |
| 44 |
struct s2n_cert *next; |
| 45 |
}; |
| 46 |
|
| 47 |
struct s2n_cert_chain { |
| 48 |
uint32_t chain_size; |
| 49 |
struct s2n_cert *head; |
| 50 |
}; |
| 51 |
|
| 52 |
struct s2n_cert_chain_and_key { |
| 53 |
struct s2n_cert_chain *cert_chain; |
| 54 |
s2n_cert_private_key *private_key; |
| 55 |
struct s2n_blob ocsp_status; |
| 56 |
struct s2n_blob sct_list; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
struct s2n_array *san_names; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
struct s2n_array *cn_names; |
| 66 |
|
| 67 |
void *context; |
| 68 |
}; |
| 69 |
|
| 70 |
struct certs_by_type { |
| 71 |
struct s2n_cert_chain_and_key *certs[S2N_CERT_TYPE_COUNT]; |
| 72 |
}; |
| 73 |
|
| 74 |
|
| 75 |
int s2n_cert_chain_and_key_load_cns(struct s2n_cert_chain_and_key *chain_and_key, X509 *x509_cert); |
| 76 |
int s2n_cert_chain_and_key_load_sans(struct s2n_cert_chain_and_key *chain_and_key, X509 *x509_cert); |
| 77 |
int s2n_cert_chain_and_key_matches_dns_name(const struct s2n_cert_chain_and_key *chain_and_key, const struct s2n_blob *dns_name); |
| 78 |
|
| 79 |
S2N_CLEANUP_RESULT s2n_cert_chain_and_key_ptr_free(struct s2n_cert_chain_and_key **cert_and_key); |
| 80 |
int s2n_cert_set_cert_type(struct s2n_cert *cert, s2n_pkey_type pkey_type); |
| 81 |
int s2n_send_cert_chain(struct s2n_connection *conn, struct s2n_stuffer *out, struct s2n_cert_chain_and_key *chain_and_key); |
| 82 |
int s2n_send_empty_cert_chain(struct s2n_stuffer *out); |
| 83 |
int s2n_create_cert_chain_from_stuffer(struct s2n_cert_chain *cert_chain_out, struct s2n_stuffer *chain_in_stuffer); |
| 84 |
int s2n_cert_chain_and_key_set_cert_chain_bytes(struct s2n_cert_chain_and_key *cert_and_key, uint8_t *cert_chain_pem, uint32_t cert_chain_len); |
| 85 |
int s2n_cert_chain_and_key_set_private_key_bytes(struct s2n_cert_chain_and_key *cert_and_key, uint8_t *private_key_pem, uint32_t private_key_len); |
| 86 |
int s2n_cert_chain_and_key_set_cert_chain(struct s2n_cert_chain_and_key *cert_and_key, const char *cert_chain_pem); |
| 87 |
int s2n_cert_chain_and_key_set_private_key(struct s2n_cert_chain_and_key *cert_and_key, const char *private_key_pem); |
| 88 |
s2n_pkey_type s2n_cert_chain_and_key_get_pkey_type(struct s2n_cert_chain_and_key *chain_and_key); |
| 89 |
int s2n_cert_chain_get_length(const struct s2n_cert_chain_and_key *chain_and_key, uint32_t *cert_length); |
| 90 |
int s2n_cert_chain_get_cert(const struct s2n_cert_chain_and_key *chain_and_key, struct s2n_cert **out_cert, const uint32_t cert_idx); |
| 91 |
int s2n_cert_get_der(const struct s2n_cert *cert, const uint8_t **out_cert_der, uint32_t *cert_length); |
| 92 |
int s2n_cert_chain_free(struct s2n_cert_chain *cert_chain); |
| 93 |
int s2n_cert_get_x509_extension_value_length(struct s2n_cert *cert, const uint8_t *oid, uint32_t *ext_value_len); |
| 94 |
int s2n_cert_get_x509_extension_value(struct s2n_cert *cert, const uint8_t *oid, uint8_t *ext_value, uint32_t *ext_value_len, bool *critical); |
| 95 |
int s2n_cert_get_utf8_string_from_extension_data_length(const uint8_t *extension_data, uint32_t extension_len, uint32_t *utf8_str_len); |
| 96 |
int s2n_cert_get_utf8_string_from_extension_data(const uint8_t *extension_data, uint32_t extension_len, uint8_t *out_data, uint32_t *out_len); |