Change #include filenames from <foo.h> to <openssl.h>.
[openssl.git] / ssl / ssl_locl.h
index 71d4c08c09fd54f4b1fd0849616f90509d49b46a..7b270c63d5fb7d3b929538c992f9016bda9d09c0 100644 (file)
 #include <string.h>
 #include <errno.h>
 
-#include "e_os.h"
-
-#include "buffer.h"
-#include "comp.h"
-#include "bio.h"
-#include "crypto.h"
-#include "evp.h"
-#include "stack.h"
-#include "x509.h"
-#include "err.h"
-#include "ssl.h"
+#include <openssl/e_os.h>
+
+#include <openssl/buffer.h>
+#include <openssl/comp.h>
+#include <openssl/bio.h>
+#include <openssl/crypto.h>
+#include <openssl/evp.h>
+#include <openssl/stack.h>
+#include <openssl/x509.h>
+#include <openssl/err.h>
+#include <openssl/ssl.h>
 
 #define PKCS1_CHECK
 
 #define SSL_SHA                        (SSL_SHA1)
 
 #define SSL_EXP_MASK           0x00300000L
-#define SSL_EXP                        0x00100000L
+#define SSL_EXP40              0x00100000L
 #define SSL_NOT_EXP            0x00200000L
-#define SSL_EXPORT             SSL_EXP
+#define SSL_EXP56              0x00300000L
+#define SSL_IS_EXPORT(a)       ((a)&SSL_EXP40)
+#define SSL_IS_EXPORT56(a)     (((a)&SSL_EXP_MASK) == SSL_EXP56)
+#define SSL_IS_EXPORT40(a)     (((a)&SSL_EXP_MASK) == SSL_EXP40)
+#define SSL_C_IS_EXPORT(c)     SSL_IS_EXPORT((c)->algorithms)
+#define SSL_C_IS_EXPORT56(c)   SSL_IS_EXPORT56((c)->algorithms)
+#define SSL_C_IS_EXPORT40(c)   SSL_IS_EXPORT40((c)->algorithms)
+#define SSL_EXPORT_KEYLENGTH(a)        (SSL_IS_EXPORT40(a) ? 5 : \
+                                ((a)&SSL_ENC_MASK) == SSL_DES ? 8 : 7)
+#define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024)
+#define SSL_C_EXPORT_KEYLENGTH(c)      SSL_EXPORT_KEYLENGTH((c)->algorithms)
+#define SSL_C_EXPORT_PKEYLENGTH(c)     SSL_EXPORT_PKEYLENGTH((c)->algorithms)
 
 #define SSL_SSL_MASK           0x00c00000L
 #define SSL_SSLV2              0x00400000L
 #define SSL_SSLV3              0x00800000L
+#define SSL_TLSV1              SSL_SSLV3       /* for now */
 
 #define SSL_STRONG_MASK                0x07000000L
 #define SSL_LOW                        0x01000000L
@@ -264,11 +276,15 @@ typedef struct cert_st
 
        RSA *rsa_tmp;
        DH *dh_tmp;
-       RSA *(*rsa_tmp_cb)();
-       DH *(*dh_tmp_cb)();
+       /* FIXME: Although rsa_tmp and dh_tmp are properties of the cert,
+          callbacks probably aren't, and besides only the context default
+          cert's callbacks are actually used. Too close to a release to fix
+          this now - Ben 6 Mar 1999 */
+       RSA *(*rsa_tmp_cb)(SSL *ssl,int export,int keysize);
+       DH *(*dh_tmp_cb)(SSL *ssl,int export,int keysize);
        CERT_PKEY pkeys[SSL_PKEY_NUM];
 
-       STACK *cert_chain;
+       STACK_OF(X509) *cert_chain;
 
        int references;
        } CERT;
@@ -315,7 +331,7 @@ typedef struct ssl3_enc_method
        int (*alert_value)();
        } SSL3_ENC_METHOD;
 
-/* Used for holding the relevent compression methods loaded into SSL_CTX */
+/* Used for holding the relevant compression methods loaded into SSL_CTX */
 typedef struct ssl3_comp_st
        {
        int comp_id;    /* The identifer byte for this compression type */
@@ -337,33 +353,38 @@ SSL_METHOD *sslv3_base_method(void);
 void ssl_clear_cipher_ctx(SSL *s);
 int ssl_clear_bad_session(SSL *s);
 CERT *ssl_cert_new(void);
+int ssl_cert_instantiate(CERT **o, CERT *d);
 void ssl_cert_free(CERT *c);
 int ssl_set_cert_type(CERT *c, int type);
 int ssl_get_new_session(SSL *s, int session);
 int ssl_get_prev_session(SSL *s, unsigned char *session,int len);
 int ssl_cipher_id_cmp(SSL_CIPHER *a,SSL_CIPHER *b);
 int ssl_cipher_ptr_id_cmp(SSL_CIPHER **ap,SSL_CIPHER **bp);
-STACK *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,STACK **skp);
-int ssl_cipher_list_to_bytes(SSL *s,STACK *sk,unsigned char *p);
-STACK *ssl_create_cipher_list(SSL_METHOD *meth,STACK **pref,
-       STACK **sorted,char *str);
+STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,
+                                              STACK_OF(SSL_CIPHER) **skp);
+int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p);
+STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *meth,
+                                            STACK_OF(SSL_CIPHER) **pref,
+                                            STACK_OF(SSL_CIPHER) **sorted,
+                                            char *str);
 void ssl_update_cache(SSL *s, int mode);
-int ssl_cipher_get_evp(SSL_CIPHER *c, EVP_CIPHER **enc, EVP_MD **md);
-int ssl_verify_cert_chain(SSL *s,STACK *sk);
+int ssl_cipher_get_evp(SSL_SESSION *s,const EVP_CIPHER **enc,const EVP_MD **md,
+                      SSL_COMP **comp);
+int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk);
 int ssl_undefined_function(SSL *s);
 X509 *ssl_get_server_send_cert(SSL *);
 EVP_PKEY *ssl_get_sign_pkey(SSL *,SSL_CIPHER *);
 int ssl_cert_type(X509 *x,EVP_PKEY *pkey);
-void ssl_set_cert_masks(CERT *c);
-STACK *ssl_get_ciphers_by_id(SSL *s);
+void ssl_set_cert_masks(CERT *c,CERT *default_cert,SSL_CIPHER *cipher);
+STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s);
 int ssl_verify_alarm_type(long type);
 
 int ssl2_enc_init(SSL *s, int client);
 void ssl2_generate_key_material(SSL *s);
 void ssl2_enc(SSL *s,int send_data);
 void ssl2_mac(SSL *s,unsigned char *mac,int send_data);
-SSL_CIPHER *ssl2_get_cipher_by_char(unsigned char *p);
-int ssl2_put_cipher_by_char(SSL_CIPHER *c,unsigned char *p);
+SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p);
+int ssl2_put_cipher_by_char(const SSL_CIPHER *c,unsigned char *p);
 int ssl2_part_read(SSL *s, unsigned long f, int i);
 int ssl2_do_write(SSL *s);
 int ssl2_set_certificate(SSL *s, int type, int len, unsigned char *data);
@@ -375,17 +396,17 @@ int       ssl2_new(SSL *s);
 void   ssl2_free(SSL *s);
 int    ssl2_accept(SSL *s);
 int    ssl2_connect(SSL *s);
-int    ssl2_read(SSL *s, char *buf, int len);
+int    ssl2_read(SSL *s, void *buf, int len);
 int    ssl2_peek(SSL *s, char *buf, int len);
-int    ssl2_write(SSL *s, char *buf, int len);
+int    ssl2_write(SSL *s, const void *buf, int len);
 int    ssl2_shutdown(SSL *s);
 void   ssl2_clear(SSL *s);
 long   ssl2_ctrl(SSL *s,int cmd, long larg, char *parg);
 long   ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg);
 int    ssl2_pending(SSL *s);
 
-SSL_CIPHER *ssl3_get_cipher_by_char(unsigned char *p);
-int ssl3_put_cipher_by_char(SSL_CIPHER *c,unsigned char *p);
+SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p);
+int ssl3_put_cipher_by_char(const SSL_CIPHER *c,unsigned char *p);
 void ssl3_init_finished_mac(SSL *s);
 int ssl3_send_server_certificate(SSL *s);
 int ssl3_get_finished(SSL *s,int state_a,int state_b);
@@ -405,25 +426,26 @@ SSL_CIPHER *ssl3_get_cipher(unsigned int u);
 int ssl3_renegotiate(SSL *ssl); 
 int ssl3_renegotiate_check(SSL *ssl); 
 int ssl3_dispatch_alert(SSL *s);
-int ssl3_read_bytes(SSL *s, int type, char *buf, int len);
+int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len);
 int ssl3_part_read(SSL *s, int i);
-int ssl3_write_bytes(SSL *s, int type, char *buf, int len);
+int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
 int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1,EVP_MD_CTX *ctx2,
        unsigned char *sender, int slen,unsigned char *p);
 int ssl3_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p);
-void ssl3_finish_mac(SSL *s, unsigned char *buf, int len);
+void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len);
 int ssl3_enc(SSL *s, int send_data);
 int ssl3_mac(SSL *ssl, unsigned char *md, int send_data);
 unsigned long ssl3_output_cert_chain(SSL *s, X509 *x);
-SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,STACK *have,STACK *pref);
+SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,STACK_OF(SSL_CIPHER) *have,
+                              STACK_OF(SSL_CIPHER) *pref);
 int    ssl3_setup_buffers(SSL *s);
 int    ssl3_new(SSL *s);
 void   ssl3_free(SSL *s);
 int    ssl3_accept(SSL *s);
 int    ssl3_connect(SSL *s);
-int    ssl3_read(SSL *s, char *buf, int len);
+int    ssl3_read(SSL *s, void *buf, int len);
 int    ssl3_peek(SSL *s,char *buf, int len);
-int    ssl3_write(SSL *s, char *buf, int len);
+int    ssl3_write(SSL *s, const void *buf, int len);
 int    ssl3_shutdown(SSL *s);
 void   ssl3_clear(SSL *s);
 long   ssl3_ctrl(SSL *s,int cmd, long larg, char *parg);
@@ -442,6 +464,7 @@ long tls1_ctrl(SSL *s,int cmd, long larg, char *parg);
 SSL_METHOD *tlsv1_base_method(void );
 
 int ssl_init_wbio_buffer(SSL *s, int push);
+void ssl_free_wbio_buffer(SSL *s);
 
 int tls1_change_cipher_state(SSL *s, int which);
 int tls1_setup_key_block(SSL *s);
@@ -456,6 +479,9 @@ int tls1_alert_code(int code);
 int ssl3_alert_code(int code);
 int ssl_ok(SSL *s);
 
+SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n);
+STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);
+
 
 #else
 
@@ -467,6 +493,7 @@ SSL_METHOD *sslv3_base_method();
 void ssl_clear_cipher_ctx();
 int ssl_clear_bad_session();
 CERT *ssl_cert_new();
+int ssl_cert_instantiate();
 void ssl_cert_free();
 int ssl_set_cert_type();
 int ssl_get_new_session();
@@ -562,10 +589,8 @@ int ssl23_read_bytes();
 int ssl23_write_bytes();
 
 int ssl_init_wbio_buffer();
+void ssl_free_wbio_buffer();
 
-#endif
-
-#endif
 int ssl3_cert_verify_mac();
 int ssl3_alert_code();
 int tls1_new();
@@ -582,3 +607,9 @@ int tls1_mac();
 int tls1_generate_master_secret();
 int tls1_alert_code();
 int ssl_ok();
+SSL_COMP *ssl3_comp_find();
+STACK *SSL_COMP_get_compression_methods();
+
+#endif
+
+#endif