Partially sync files.el from XEmacs 21.5 for wildcard support.
[sxemacs] / src / openssl.h
1 /*
2   openssl.h -- Emacs Lisp binding to OpenSSL ciphers and digests
3   Copyright (C) 2005 Sebastian Freundt
4
5   Author:  Sebastian Freundt <hroptatyr@sxemacs.org>
6
7 This file is part of SXEmacs
8
9 SXEmacs is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 SXEmacs is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
21
22
23 #ifndef INCLUDED_openssl_h_
24 #define INCLUDED_openssl_h_ 1
25
26 /* this is to determine what has been configured */
27 #include <openssl/opensslconf.h>
28
29 #include <openssl/evp.h>
30 #include <openssl/rand.h>
31 #include <openssl/hmac.h>
32
33 /* special asymmetric crypto systems */
34 #ifndef OPENSSL_NO_RSA
35 #include <openssl/rsa.h>
36 #endif
37
38 #ifndef OPENSSL_NO_DSA
39 #include <openssl/dsa.h>
40 #endif
41
42 #ifndef OPENSSL_NO_EC
43 #include <openssl/ec.h>
44 #endif
45
46 #ifndef OPENSSL_NO_ECDH
47 #include <openssl/ecdh.h>
48 #endif
49
50 #ifndef OPENSSL_NO_ECDSA
51 #include <openssl/ecdsa.h>
52 #endif
53
54 #ifndef OPENSSL_NO_DH
55 #include <openssl/dh.h>
56 #endif
57
58 #if defined HAVE_OPENSSL_X509_H
59 # include <openssl/x509.h>
60 #endif
61 #if defined HAVE_OPENSSL_PEM_H
62 # include <openssl/pem.h>
63 #endif
64 #if defined HAVE_OPENSSL_SSL_H
65 # include <openssl/ssl.h>
66 #endif
67 #if defined HAVE_OPENSSL_BIO_H
68 # include <openssl/bio.h>
69 #endif
70
71 /* opaque EVP_PKEY object structure */
72 struct Lisp_EVP_PKEY {
73         struct lcrecord_header header;
74         EVP_PKEY *evp_pkey;
75         X509 *x509;
76 };
77 typedef struct Lisp_EVP_PKEY Lisp_EVP_PKEY;
78
79 DECLARE_LRECORD(evp_pkey, Lisp_EVP_PKEY);
80
81 #define XEVPPKEY(x)             XRECORD (x, evp_pkey, Lisp_EVP_PKEY)
82 #define XSETEVPPKEY(x, p)       XSETRECORD (x, p, evp_pkey)
83 #define EVPPKEYP(x)             RECORDP (x, evp_pkey)
84 #define CHECK_EVPPKEY(x)        CHECK_RECORD (x, evp_pkey)
85 #define wrap_evppkey(p)         wrap_object(p)
86
87
88 #if !defined(OPENSSL_NO_SSL2) || !defined(OPENSSL_NO_SSL3)
89 /* opaque SSL_CONN object structure
90  * this is just an ssl-ish wrap around the process object
91  */
92 struct Lisp_SSL_CONN {
93         struct lcrecord_header header;
94         SSL_METHOD *ssl_meth;
95         SSL_CTX *ssl_ctx;
96         SSL *ssl_conn;
97         Lisp_Object parent;
98         int infd, outfd;
99         BIO *ssl_bio;
100         int connected_p;
101         int protected_p;
102
103         /* Low level streams used in input and output,
104            backup streams if network stream is proselytised */
105         Lisp_Object pipe_instream;
106         Lisp_Object pipe_outstream;
107 #ifdef FILE_CODING
108         /* Data end streams, decoding and encoding pipe_* streams */
109         Lisp_Object coding_instream;
110         Lisp_Object coding_outstream;
111 #endif  /* FILE_CODING */
112 };
113 typedef struct Lisp_SSL_CONN Lisp_SSL_CONN;
114
115 Lisp_Object make_ssl_conn(Lisp_SSL_CONN *ssl_conn);
116 Lisp_SSL_CONN *allocate_ssl_conn(void);
117 void finalize_ssl_conn(void *header, int for_disksave);
118 Lisp_Object ossl_ssl_handshake(Lisp_Object, Lisp_Object);
119
120 extern Lisp_Object make_ssl_input_stream(SSL*, int);
121 extern Lisp_Object make_ssl_output_stream(SSL*, int);
122 EXFUN(Fset_process_coding_system, 3);
123 extern void ssl_verify_cert_chain(SSL*, void*);
124
125 DECLARE_LRECORD(ssl_conn, Lisp_SSL_CONN);
126
127 #define XSSLCONN(x)             XRECORD (x, ssl_conn, Lisp_SSL_CONN)
128 #define XSETSSLCONN(x, p)       XSETRECORD (x, p, ssl_conn)
129 #define SSLCONNP(x)             RECORDP (x, ssl_conn)
130 #define CHECK_SSLCONN(x)        CHECK_RECORD (x, ssl_conn)
131 #define wrap_sslconn(p)         wrap_object(p)
132
133 #ifdef ALL_DEBUG_FLAGS
134 #undef OSSL_DEBUG_FLAG
135 #define OSSL_DEBUG_FLAG
136 #endif
137
138 #endif  /* !OPENSSL_NO_SSL2 || !OPENSSL_NO_SSL3 */
139 #endif /* INCLUDED_openssl_h_ */