[coop] Refactor/reuse mono_value_box_handle/mono_value_box_checked and reduce raw...
[mono-project.git] / mono / btls / btls-x509.h
blob83e8b3c0535dfd75f646f215625326bbe4e40a8e
1 //
2 // btls-x509.h
3 // MonoBtls
4 //
5 // Created by Martin Baulig on 14/11/15.
6 // Copyright (c) 2015 Xamarin. All rights reserved.
7 //
9 #ifndef __btls__btls_x509__
10 #define __btls__btls_x509__
12 #include <stdio.h>
13 #include "btls-ssl.h"
14 #include "btls-x509-name.h"
16 typedef enum {
17 MONO_BTLS_X509_FORMAT_DER = 1,
18 MONO_BTLS_X509_FORMAT_PEM = 2
19 } MonoBtlsX509Format;
21 typedef enum {
22 MONO_BTLS_x509_FILE_TYPE_PEM = 1, // X509_FILETYPE_PEM
23 MONO_BTLS_x509_FILE_TYPE_ASN1 = 2, // X509_FILETYPE_ASN1
24 MONO_BTLS_x509_FILE_TYPE_DEFAULT = 3, // X509_FILETYPE_DEFAULT
25 } MonoBtlsX509FileType;
27 typedef enum {
28 MONO_BTLS_X509_PURPOSE_SSL_CLIENT = 1,
29 MONO_BTLS_X509_PURPOSE_SSL_SERVER = 2,
30 MONO_BTLS_X509_PURPOSE_NS_SSL_SERVER = 3,
31 MONO_BTLS_X509_PURPOSE_SMIME_SIGN = 4,
32 MONO_BTLS_X509_PURPOSE_SMIME_ENCRYPT = 5,
33 MONO_BTLS_X509_PURPOSE_CRL_SIGN = 6,
34 MONO_BTLS_X509_PURPOSE_ANY = 7,
35 MONO_BTLS_X509_PURPOSE_OCSP_HELPER = 8,
36 MONO_BTLS_X509_PURPOSE_TIMESTAMP_SIGN = 9,
37 } MonoBtlsX509Purpose;
39 typedef enum {
40 MONO_BTLS_X509_TRUST_KIND_DEFAULT = 0,
41 MONO_BTLS_X509_TRUST_KIND_TRUST_CLIENT = 1,
42 MONO_BTLS_X509_TRUST_KIND_TRUST_SERVER = 2,
43 MONO_BTLS_X509_TRUST_KIND_TRUST_ALL = 4,
44 MONO_BTLS_X509_TRUST_KIND_REJECT_CLIENT = 32,
45 MONO_BTLS_X509_TRUST_KIND_REJECT_SERVER = 64,
46 MONO_BTLS_X509_TRUST_KIND_REJECT_ALL = 128
47 } MonoBtlsX509TrustKind;
49 MONO_API X509 *
50 mono_btls_x509_from_data (const void *buf, int len, MonoBtlsX509Format format);
52 MONO_API X509 *
53 mono_btls_x509_up_ref (X509 *x509);
55 MONO_API void
56 mono_btls_x509_free (X509 *x509);
58 MONO_API X509 *
59 mono_btls_x509_dup (X509 *x509);
61 MONO_API MonoBtlsX509Name *
62 mono_btls_x509_get_subject_name (X509 *x509);
64 MONO_API MonoBtlsX509Name *
65 mono_btls_x509_get_issuer_name (X509 *x509);
67 MONO_API int
68 mono_btls_x509_get_subject_name_string (X509 *name, char *buffer, int size);
70 MONO_API int
71 mono_btls_x509_get_issuer_name_string (X509 *name, char *buffer, int size);
73 MONO_API int
74 mono_btls_x509_get_raw_data (X509 *x509, BIO *bio, MonoBtlsX509Format format);
76 MONO_API int
77 mono_btls_x509_cmp (const X509 *a, const X509 *b);
79 MONO_API int
80 mono_btls_x509_get_hash (X509 *x509, const void **data);
82 MONO_API int64_t
83 mono_btls_x509_get_not_before (X509 *x509);
85 MONO_API int64_t
86 mono_btls_x509_get_not_after (X509 *x509);
88 MONO_API int
89 mono_btls_x509_get_public_key (X509 *x509, BIO *bio);
91 MONO_API int
92 mono_btls_x509_get_public_key_parameters (X509 *x509, char *out_oid, int oid_len, uint8_t **buffer, int *size);
94 MONO_API int
95 mono_btls_x509_get_serial_number (X509 *x509, char *buffer, int size, int mono_style);
97 MONO_API int
98 mono_btls_x509_get_public_key_algorithm (X509 *x509, char *buffer, int size);
100 MONO_API int
101 mono_btls_x509_get_version (X509 *x509);
103 MONO_API int
104 mono_btls_x509_get_signature_algorithm (X509 *x509, char *buffer, int size);
106 MONO_API int
107 mono_btls_x509_get_public_key_asn1 (X509 *x509, char *out_oid, int oid_len, uint8_t **buffer, int *size);
109 MONO_API EVP_PKEY *
110 mono_btls_x509_get_pubkey (X509 *x509);
112 MONO_API int
113 mono_btls_x509_get_subject_key_identifier (X509 *x509, uint8_t **buffer, int *size);
115 MONO_API int
116 mono_btls_x509_print (X509 *x509, BIO *bio);
118 MONO_API int
119 mono_btls_x509_add_trust_object (X509 *x509, MonoBtlsX509Purpose purpose);
121 MONO_API int
122 mono_btls_x509_add_reject_object (X509 *x509, MonoBtlsX509Purpose purpose);
124 MONO_API int
125 mono_btls_x509_add_explicit_trust (X509 *x509, MonoBtlsX509TrustKind kind);
127 #endif /* defined(__btls__btls_x509__) */