Some tiny clean-ups related to the cert_st / sess_cert_st change.
[openssl.git] / ssl / ssl_locl.h
index 28e05615facba88345f2d4c25469ea7e23513483..076129c8ea346d6600a93e26ad949c1c9878f0fd 100644 (file)
 typedef struct cert_pkey_st
        {
        X509 *x509;
-/*     EVP_PKEY *publickey; *//* when extracted */
        EVP_PKEY *privatekey;
        } CERT_PKEY;
 
 typedef struct cert_st
        {
-       int cert_type;
-
-#ifdef undef
-       X509 *x509;
-       EVP_PKEY *publickey; /* when extracted */
-       EVP_PKEY *privatekey;
-
-       pkeys[SSL_PKEY_RSA_ENC].x509
-/*     pkeys[SSL_PKEY_RSA_ENC].publickey */
-       pkeys[SSL_PKEY_RSA_ENC].privatekey
-#endif
-
        /* Current active set */
-       CERT_PKEY *key;
+       CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array
+                                        * Probably it would make more sense to store
+                                        * an index, not a pointer. */
 
        /* The following masks are for the key and auth
         * algorithms that are supported by the certs below */
@@ -279,19 +268,38 @@ typedef struct cert_st
 #endif
 #ifndef NO_DH
        DH *dh_tmp;
-       /* 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 */
        DH *(*dh_tmp_cb)(SSL *ssl,int export,int keysize);
 #endif
-       CERT_PKEY pkeys[SSL_PKEY_NUM];
 
-       STACK_OF(X509) *cert_chain;
+       CERT_PKEY pkeys[SSL_PKEY_NUM];
 
-       int references;
+       int references; /* >1 only if SSL_copy_session_id is used */
        } CERT;
 
+
+typedef struct sess_cert_st
+       {
+       STACK_OF(X509) *cert_chain; /* as received from peer (not for SSL2) */
+
+       /* The 'peer_...' members are used only by clients. */
+       int peer_cert_type;
+
+       CERT_PKEY *peer_key; /* points to an element of peer_pkeys (never NULL!) */
+       CERT_PKEY peer_pkeys[SSL_PKEY_NUM];
+       /* Obviously we don't have the private keys of these,
+        * so maybe we shouldn't even use the CERT_PKEY type here. */
+
+#ifndef NO_RSA
+       RSA *peer_rsa_tmp; /* not used for SSL 2 */
+#endif
+#ifndef NO_DH
+       DH *peer_dh_tmp; /* not used for SSL 2 */
+#endif
+
+       int references; /* actually always 1 at the moment */
+       } SESS_CERT;
+
+
 /*#define MAC_DEBUG    */
 
 /*#define ERR_DEBUG    */
@@ -337,9 +345,14 @@ typedef struct ssl3_comp_st
        COMP_METHOD *method; /* The method :-) */
        } SSL3_COMP;
 
-extern SSL3_ENC_METHOD ssl3_undef_enc_method;
-extern SSL_CIPHER ssl2_ciphers[];
-extern SSL_CIPHER ssl3_ciphers[];
+EXTERN SSL3_ENC_METHOD ssl3_undef_enc_method;
+EXTERN SSL_CIPHER ssl2_ciphers[];
+EXTERN SSL_CIPHER ssl3_ciphers[];
+
+#ifdef VMS
+#undef SSL_COMP_get_compression_methods
+#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods
+#endif
 
 
 SSL_METHOD *ssl_bad_method(int ver);
@@ -350,9 +363,12 @@ 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);
+CERT *ssl_cert_dup(CERT *cert);
+int ssl_cert_inst(CERT **o);
 void ssl_cert_free(CERT *c);
-int ssl_set_cert_type(CERT *c, int type);
+SESS_CERT *ssl_sess_cert_new(void);
+void ssl_sess_cert_free(SESS_CERT *sc);
+int ssl_set_peer_cert_type(SESS_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);
@@ -372,7 +388,7 @@ 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,CERT *default_cert,SSL_CIPHER *cipher);
+void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher);
 STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s);
 int ssl_verify_alarm_type(long type);