1# This file is dual licensed under the terms of the Apache License, Version
2# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3# for complete details.
4
5from __future__ import absolute_import, division, print_function
6
7INCLUDES = """
8#include <openssl/x509.h>
9
10/*
11 * See the comment above Cryptography_STACK_OF_X509 in x509.py
12 */
13typedef STACK_OF(X509_NAME) Cryptography_STACK_OF_X509_NAME;
14typedef STACK_OF(X509_NAME_ENTRY) Cryptography_STACK_OF_X509_NAME_ENTRY;
15"""
16
17TYPES = """
18typedef ... Cryptography_STACK_OF_X509_NAME_ENTRY;
19typedef ... X509_NAME;
20typedef ... X509_NAME_ENTRY;
21typedef ... Cryptography_STACK_OF_X509_NAME;
22"""
23
24FUNCTIONS = """
25X509_NAME *X509_NAME_new(void);
26void X509_NAME_free(X509_NAME *);
27
28unsigned long X509_NAME_hash(X509_NAME *);
29
30int i2d_X509_NAME(X509_NAME *, unsigned char **);
31int X509_NAME_add_entry_by_txt(X509_NAME *, const char *, int,
32                               const unsigned char *, int, int, int);
33X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *, int);
34void X509_NAME_ENTRY_free(X509_NAME_ENTRY *);
35int X509_NAME_get_index_by_NID(X509_NAME *, int, int);
36int X509_NAME_cmp(const X509_NAME *, const X509_NAME *);
37X509_NAME *X509_NAME_dup(X509_NAME *);
38int Cryptography_X509_NAME_ENTRY_set(X509_NAME_ENTRY *);
39/* These became const X509_NAME * in 1.1.0 */
40int X509_NAME_entry_count(X509_NAME *);
41X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *, int);
42char *X509_NAME_oneline(X509_NAME *, char *, int);
43int X509_NAME_print_ex(BIO *, X509_NAME *, int, unsigned long);
44
45/* These became const X509_NAME_ENTRY * in 1.1.0 */
46ASN1_OBJECT *X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *);
47ASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *);
48int X509_NAME_add_entry(X509_NAME *, X509_NAME_ENTRY *, int, int);
49
50/* this became const unsigned char * in 1.1.0 */
51int X509_NAME_add_entry_by_NID(X509_NAME *, int, int, unsigned char *,
52                               int, int, int);
53
54/* These became const ASN1_OBJECT * in 1.1.0 */
55X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **,
56                                               ASN1_OBJECT *, int,
57                                               const unsigned char *, int);
58int X509_NAME_add_entry_by_OBJ(X509_NAME *, ASN1_OBJECT *, int,
59                               unsigned char *, int, int, int);
60
61Cryptography_STACK_OF_X509_NAME *sk_X509_NAME_new_null(void);
62int sk_X509_NAME_num(Cryptography_STACK_OF_X509_NAME *);
63int sk_X509_NAME_push(Cryptography_STACK_OF_X509_NAME *, X509_NAME *);
64X509_NAME *sk_X509_NAME_value(Cryptography_STACK_OF_X509_NAME *, int);
65void sk_X509_NAME_free(Cryptography_STACK_OF_X509_NAME *);
66int sk_X509_NAME_ENTRY_num(Cryptography_STACK_OF_X509_NAME_ENTRY *);
67Cryptography_STACK_OF_X509_NAME_ENTRY *sk_X509_NAME_ENTRY_new_null(void);
68int sk_X509_NAME_ENTRY_push(Cryptography_STACK_OF_X509_NAME_ENTRY *,
69                            X509_NAME_ENTRY *);
70X509_NAME_ENTRY *sk_X509_NAME_ENTRY_value(
71    Cryptography_STACK_OF_X509_NAME_ENTRY *, int);
72Cryptography_STACK_OF_X509_NAME_ENTRY *sk_X509_NAME_ENTRY_dup(
73    Cryptography_STACK_OF_X509_NAME_ENTRY *
74);
75"""
76
77CUSTOMIZATIONS = """
78#if CRYPTOGRAPHY_OPENSSL_110_OR_GREATER
79int Cryptography_X509_NAME_ENTRY_set(X509_NAME_ENTRY *ne) {
80    return X509_NAME_ENTRY_set(ne);
81}
82#else
83int Cryptography_X509_NAME_ENTRY_set(X509_NAME_ENTRY *ne) {
84    return ne->set;
85}
86#endif
87"""
88