• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the License); you may
5  *  not use this file except in compliance with the License.
6  *
7  *  http://www.apache.org/licenses/LICENSE-2.0
8  */
9 
10 
11 #ifndef GMSSL_X509_OID_H
12 #define GMSSL_X509_OID_H
13 
14 
15 #include <time.h>
16 #include <string.h>
17 #include <stdint.h>
18 #include <stdlib.h>
19 #include <gmssl/sm2.h>
20 #include <gmssl/oid.h>
21 #include <gmssl/asn1.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*
28 id-at:
29 	OID_at_name
30 	OID_at_surname
31 	OID_at_given_name
32 	OID_at_initials
33 	OID_at_generation_qualifier
34 	OID_at_common_name
35 	OID_at_locality_name
36 	OID_at_state_or_province_name
37 	OID_at_organization_name
38 	OID_at_organizational_unit_name
39 	OID_at_title
40 	OID_at_dn_qualifier
41 	OID_at_country_name
42 	OID_at_serial_number
43 	OID_at_pseudonym
44 	OID_domain_component
45 */
46 const char *x509_name_type_name(int oid);
47 int x509_name_type_from_name(const char *name);
48 int x509_name_type_from_der(int *oid, const uint8_t **in, size_t *inlen);
49 int x509_name_type_to_der(int oid, uint8_t **out, size_t *outlen);
50 
51 /*
52 id-ce:
53 	OID_ce_authority_key_identifier
54 	OID_ce_subject_key_identifier
55 	OID_ce_key_usage
56 	OID_ce_certificate_policies
57 	OID_ce_policy_mappings
58 	OID_ce_subject_alt_name
59 	OID_ce_issuer_alt_name
60 	OID_ce_subject_directory_attributes
61 	OID_ce_basic_constraints
62 	OID_ce_name_constraints
63 	OID_ce_policy_constraints
64 	OID_ce_ext_key_usage
65 	OID_ce_crl_distribution_points
66 	OID_ce_inhibit_any_policy
67 	OID_ce_freshest_crl
68 	OID_netscape_cert_comment
69 */
70 const char *x509_ext_id_name(int oid);
71 int x509_ext_id_from_name(const char *name);
72 int x509_ext_id_from_der(int *oid, uint32_t *nodes, size_t *nodes_count, const uint8_t **in, size_t *inlen);
73 int x509_ext_id_to_der(int oid, uint8_t **out, size_t *outlen);
74 
75 /*
76 id-qt
77 	OID_qt_cps
78 	OID_qt_unotice
79 */
80 const char *x509_qualifier_id_name(int oid);
81 int x509_qualifier_id_from_name(const char *name);
82 int x509_qualifier_id_from_der(int *oid, const uint8_t **in, size_t *inlen);
83 int x509_qualifier_id_to_der(int oid, uint8_t **out, size_t *outlen);
84 
85 /*
86 	OID_any_policy
87 */
88 char *x509_cert_policy_id_name(int oid);
89 int x509_cert_policy_id_from_name(const char *name);
90 int x509_cert_policy_id_from_der(int *oid, uint32_t *nodes, size_t *nodes_cnt, const uint8_t **in, size_t *inlen);
91 int x509_cert_policy_id_to_der(int oid, const uint32_t *nodes, size_t nodes_cnt, uint8_t **out, size_t *outlen);
92 
93 /*
94 id-kp
95 	OID_kp_server_auth
96 	OID_kp_client_auth
97 	OID_kp_code_signing
98 	OID_kp_email_protection
99 	OID_kp_time_stamping
100 	OID_kp_ocsp_signing
101 */
102 const char *x509_key_purpose_name(int oid);
103 const char *x509_key_purpose_text(int oid);
104 int x509_key_purpose_from_name(const char *name);
105 int x509_key_purpose_from_der(int *oid, const uint8_t **in, size_t *inlen);
106 int x509_key_purpose_to_der(int oid, uint8_t **out, size_t *outlen);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 #endif
112