6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Copyright 2001 hereUare Communications, Inc. <raghud@hereuare.com>
26 void cbtls_info(const SSL *s, int where, int ret)
28 const char *str, *state;
31 w = where & ~SSL_ST_MASK;
32 if (w & SSL_ST_CONNECT) str=" TLS_connect";
33 else if (w & SSL_ST_ACCEPT) str=" TLS_accept";
36 state = SSL_state_string_long(s);
37 state = state ? state : "NULL";
39 if (where & SSL_CB_LOOP) {
40 DEBUG2("%s: %s\n", str, state);
41 } else if (where & SSL_CB_HANDSHAKE_START) {
42 DEBUG2("%s: %s\n", str, state);
43 } else if (where & SSL_CB_HANDSHAKE_DONE) {
44 DEBUG2("%s: %s\n", str, state);
45 } else if (where & SSL_CB_ALERT) {
46 str=(where & SSL_CB_READ)?"read":"write";
47 radlog(L_ERR,"TLS Alert %s:%s:%s\n", str,
48 SSL_alert_type_string_long(ret),
49 SSL_alert_desc_string_long(ret));
50 } else if (where & SSL_CB_EXIT) {
52 radlog(L_ERR, "%s:failed in %s\n", str, state);
54 radlog(L_ERR, "%s:error in %s\n", str, state);
59 * Fill in our 'info' with TLS data.
61 void cbtls_msg(int write_p, int msg_version, int content_type,
62 const void *buf, size_t len,
63 SSL *ssl UNUSED, void *arg)
65 tls_session_t *state = (tls_session_t *)arg;
68 * Work around bug #298, where we may be called with a NULL
69 * argument. We should really log a serious error
73 state->info.origin = (unsigned char)write_p;
74 state->info.content_type = (unsigned char)content_type;
75 state->info.record_len = len;
76 state->info.version = msg_version;
77 state->info.initialized = 1;
79 if (content_type == SSL3_RT_ALERT) {
80 state->info.alert_level = ((const unsigned char*)buf)[0];
81 state->info.alert_description = ((const unsigned char*)buf)[1];
82 state->info.handshake_type = 0x00;
84 } else if (content_type == SSL3_RT_HANDSHAKE) {
85 state->info.handshake_type = ((const unsigned char*)buf)[0];
86 state->info.alert_level = 0x00;
87 state->info.alert_description = 0x00;
89 tls_session_information(state);
92 int cbtls_password(char *buf,
97 strcpy(buf, (char *)userdata);
98 return(strlen((char *)userdata));
101 RSA *cbtls_rsa(SSL *s UNUSED, int is_export UNUSED, int keylength)
103 static RSA *rsa_tmp=NULL;
105 if (rsa_tmp == NULL) {
106 DEBUG2("Generating temp (%d bit) RSA key...", keylength);
107 rsa_tmp=RSA_generate_key(keylength, RSA_F4, NULL, NULL);
112 #endif /* !defined(NO_OPENSSL) */