tls/ssl parser modifications/fixes. We now have just one file doing all the ssl parsing stuff, i.e. app-layer-tls.[ch], instead of app-layer-ssl.[ch] and app-layer-tls.[ch]

remotes/origin/master-1.1.x
Anoop Saldanha 14 years ago committed by Victor Julien
parent 8b17275451
commit 4e8de99dcd

File diff suppressed because it is too large Load Diff

@ -15,65 +15,65 @@
* 02110-1301, USA.
*/
/**
* \file
*
* \author Gurvinder Singh <gurvindersinghdahiya@gmail.com>
*/
#ifndef _APP_LAYER_SSL_H
#define _APP_LAYER_SSL_H
#define SSL_CLIENT_VERSION 0x0002
#define SSL_SERVER_VERSION 0x0002
/* SSL message types */
#define SSL_ERROR 0
#define SSL_CLIENT_HELLO 1
#define SSL_CLIENT_MASTER_KEY 2
#define SSL_CLIENT_FINISHED 3
#define SSL_SERVER_HELLO 4
#define SSL_SERVER_VERIFY 5
#define SSL_SERVER_FINISHED 6
#define SSL_REQUEST_CERTIFICATE 7
#define SSL_CLIENT_CERTIFICATE 8
/* structure to store the SSL state values */
typedef struct SslState_ {
uint8_t flags; /**< Flags to indicate the current SSL
sessoin state */
uint8_t client_content_type; /**< Client content type storage field */
uint16_t client_version; /**< Client SSL version storage field */
uint16_t server_version; /**< Server SSL version storage field */
uint8_t server_content_type; /**< Server content type storage field */
} SslState;
typedef struct SslClient_ {
uint16_t length; /**< Length of the received message */
uint8_t msg_type;
uint8_t minor_ver;
uint8_t major_ver;
uint16_t cipher_spec_len;
uint16_t session_id_len;
} SslClient;
typedef struct SslServer_ {
uint16_t lentgth;
uint8_t msg_type;
uint8_t session_id;
uint8_t cert;
uint8_t minor_ver;
uint8_t major_ver;
} SslServer;
int SSLParseClientRecord(Flow *, void *, AppLayerParserState *, uint8_t *,
uint32_t , AppLayerParserResult *);
int SSLParseServerRecord(Flow *, void *, AppLayerParserState *, uint8_t *,
uint32_t , AppLayerParserResult *);
void SSLParserRegisterTests(void);
#endif /* _APP_LAYER_SSL_H */
///**
// * \file
// *
// * \author Gurvinder Singh <gurvindersinghdahiya@gmail.com>
// */
//
//#ifndef _APP_LAYER_SSL_H
//#define _APP_LAYER_SSL_H
//
//#define SSL_CLIENT_VERSION 0x0002
//#define SSL_SERVER_VERSION 0x0002
//
///* SSL message types */
//#define SSL_ERROR 0
//#define SSL_CLIENT_HELLO 1
//#define SSL_CLIENT_MASTER_KEY 2
//#define SSL_CLIENT_FINISHED 3
//#define SSL_SERVER_HELLO 4
//#define SSL_SERVER_VERIFY 5
//#define SSL_SERVER_FINISHED 6
//#define SSL_REQUEST_CERTIFICATE 7
//#define SSL_CLIENT_CERTIFICATE 8
//
///* structure to store the SSL state values */
//typedef struct SslState_ {
// uint8_t flags; /**< Flags to indicate the current SSL
// sessoin state */
// uint8_t client_content_type; /**< Client content type storage field */
// uint16_t client_version; /**< Client SSL version storage field */
//
// uint16_t server_version; /**< Server SSL version storage field */
// uint8_t server_content_type; /**< Server content type storage field */
//} SslState;
//
//typedef struct SslClient_ {
// uint16_t length; /**< Length of the received message */
// uint8_t msg_type;
// uint8_t minor_ver;
// uint8_t major_ver;
// uint16_t cipher_spec_len;
// uint16_t session_id_len;
//} SslClient;
//
//typedef struct SslServer_ {
// uint16_t lentgth;
// uint8_t msg_type;
// uint8_t session_id;
// uint8_t cert;
// uint8_t minor_ver;
// uint8_t major_ver;
//} SslServer;
//
//int SSLParseClientRecord(Flow *, void *, AppLayerParserState *, uint8_t *,
// uint32_t , AppLayerParserResult *);
//
//int SSLParseServerRecord(Flow *, void *, AppLayerParserState *, uint8_t *,
// uint32_t , AppLayerParserResult *);
//
//void SSLParserRegisterTests(void);
//
//#endif /* _APP_LAYER_SSL_H */

File diff suppressed because it is too large Load Diff

@ -15,66 +15,79 @@
* 02110-1301, USA.
*/
/**
* \file
*
* \author Victor Julien <victor@inliniac.net>
* \author Gurvinder Singh <gurvindersinghdahiya@gmail.com>
*/
#ifndef __APP_LAYER_SSL_H__
#define __APP_LAYER_SSL_H__
#ifndef __APP_LAYER_TLS_H__
#define __APP_LAYER_TLS_H__
/* Flag to indicate that server will now on send encrypted msgs */
#define SSL_AL_FLAG_SERVER_CHANGE_CIPHER_SPEC 0x0001
/* Flag to indicate that client will now on send encrypted msgs */
#define SSL_AL_FLAG_CLIENT_CHANGE_CIPHER_SPEC 0x0002
#define SSL_AL_FLAG_CHANGE_CIPHER_SPEC 0x0004
#define TLS_FLAG_SERVER_CHANGE_CIPHER_SPEC 0x01 /**< Flag to indicate that
server will now on sends
encrypted msgs. */
#define TLS_FLAG_CLIENT_CHANGE_CIPHER_SPEC 0x02 /**< Flag to indicate that
client will now on sends
encrypted msgs. */
/* SSL related flags */
#define SSL_AL_FLAG_SSL_CLIENT_HS 0x0008
#define SSL_AL_FLAG_SSL_SERVER_HS 0x0010
#define SSL_AL_FLAG_SSL_CLIENT_MASTER_KEY 0x0020
#define SSL_AL_FLAG_SSL_CLIENT_SSN_ENCRYPTED 0x0040
#define SSL_AL_FLAG_SSL_SERVER_SSN_ENCRYPTED 0x0080
#define SSL_AL_FLAG_SSL_NO_SESSION_ID 0x0100
#define TLS_FLAG_SSL_CLIENT_HS 0x04 /**< SSL state flags */
#define TLS_FLAG_SSL_SERVER_HS 0x08
#define TLS_FLAG_SSL_CLIENT_MASTER_KEY 0x10
#define TLS_FLAG_SSL_CLIENT_SSN_ENCRYPTED 0x20
#define TLS_FLAG_SSL_SERVER_SSN_ENCRYPTED 0x40
#define TLS_FLAG_SSL_NO_SESSION_ID 0x80
enum {
TLS_FIELD_NONE = 0,
TLS_FIELD_CLIENT_CONTENT_TYPE, /* len 1 */
TLS_FIELD_CLIENT_VERSION, /* len 2 */
TLS_FIELD_SERVER_CONTENT_TYPE, /* len 1 */
TLS_FIELD_SERVER_VERSION, /* len 2 */
TLS_FIELD_LENGTH,
/* must be last */
TLS_FIELD_MAX,
};
/* structure to store the TLS state values */
typedef struct TlsState_ {
uint8_t flags; /**< Flags to indicate the current TLS
sessoin state */
uint8_t client_content_type; /**< Client content type storage field */
uint16_t client_version; /**< Client TLS version storage field */
/* flags specific to detect-ssl-state keyword */
#define SSL_AL_FLAG_STATE_CLIENT_HELLO 0x0200
#define SSL_AL_FLAG_STATE_SERVER_HELLO 0x0400
#define SSL_AL_FLAG_STATE_CLIENT_KEYX 0x0800
#define SSL_AL_FLAG_STATE_SERVER_KEYX 0x1000
#define SSL_AL_FLAG_STATE_UNKNOWN 0x2000
uint16_t server_version; /**< Server TLS version storage field */
uint8_t server_content_type; /**< Server content type storage field */
} TlsState;
/* SSL versions. We'll use a unified format for all, with the top byte
* holding the major version and the lower byte the minor version */
enum {
TLS_VERSION_INVALID = 0x0000,
TLS_VERSION_VALID = 0x0001,
SSL_VERSION_2 = 0x0002,
TLS_VERSION_UNKNOWN = 0x0000,
SSL_VERSION_2 = 0x0200,
SSL_VERSION_3 = 0x0300,
TLS_VERSION_10 = 0x0301,
TLS_VERSION_11 = 0x0302,
TLS_VERSION_12 = 0x0303,
};
void RegisterTLSParsers(void);
void TLSParserRegisterTests(void);
/**
* \brief SSLv[2.0|3.[0|1|2|3]] state structure.
*
* Structure to store the SSL state values.
*/
typedef struct SslState_ {
/* record length */
uint32_t record_length;
/* record length's length for SSLv2 */
uint32_t record_lengths_length;
/* Flags to indicate the current SSL session state */
uint32_t flags;
uint16_t client_version;
uint16_t server_version;
uint8_t client_content_type;
uint8_t server_content_type;
/* dummy var. You can replace this if you want to */
uint8_t pad0;
uint8_t cur_content_type;
uint32_t handshake_length;
uint16_t handshake_client_hello_ssl_version;
uint16_t handshake_server_hello_ssl_version;
/* the no of bytes processed in the currently parsed record */
uint16_t bytes_processed;
uint16_t cur_ssl_version;
uint8_t handshake_type;
/* sslv2 client hello session id length */
uint16_t session_id_length;
} SslState;
#endif /* __APP_LAYER_TLS_H__ */
void RegisterSslParsers(void);
void SslParserRegisterTests(void);
#endif /* __APP_LAYER_SSL_H__ */

@ -121,7 +121,7 @@ int DetectSslVersionMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
SCEnter();
DetectSslVersionData *ssl = (DetectSslVersionData *)m->ctx;
TlsState *app_state = (TlsState *)state;
SslState *app_state = (SslState *)state;
if (app_state == NULL) {
SCLogDebug("no app state, no match");
SCReturnInt(0);
@ -472,7 +472,7 @@ static int DetectSslVersionTestDetect01(void)
goto end;
}
TlsState *app_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
SslState *app_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
if (app_state == NULL) {
printf("no ssl state: ");
goto end;
@ -589,7 +589,7 @@ static int DetectSslVersionTestDetect02(void)
goto end;
}
TlsState *app_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
SslState *app_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
if (app_state == NULL) {
printf("no ssl state: ");
goto end;
@ -720,7 +720,7 @@ static int DetectSslVersionTestDetect03(void)
goto end;
}
TlsState *app_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
SslState *app_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
if (app_state == NULL) {
printf("no ssl state: ");
goto end;

@ -115,7 +115,7 @@ int DetectTlsVersionMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *
SCEnter();
DetectTlsVersionData *tls_data = (DetectTlsVersionData *)m->ctx;
TlsState *tls_state = (TlsState *)state;
SslState *tls_state = (SslState *)state;
if (tls_state == NULL) {
SCLogDebug("no tls state, no match");
SCReturnInt(0);
@ -382,7 +382,7 @@ static int DetectTlsVersionTestDetect01(void) {
goto end;
}
TlsState *tls_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
SslState *tls_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
if (tls_state == NULL) {
printf("no tls state: ");
goto end;
@ -497,7 +497,7 @@ static int DetectTlsVersionTestDetect02(void) {
goto end;
}
TlsState *tls_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
SslState *tls_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
if (tls_state == NULL) {
printf("no tls state: ");
goto end;
@ -629,7 +629,7 @@ static int DetectTlsVersionTestDetect03(void) {
goto end;
}
TlsState *tls_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
SslState *tls_state = f.aldata[AlpGetStateIdx(ALPROTO_TLS)];
if (tls_state == NULL) {
printf("no tls state: ");
goto end;

@ -1056,7 +1056,7 @@ int main(int argc, char **argv)
AppLayerDetectProtoThreadInit();
RegisterAppLayerParsers();
RegisterHTPParsers();
RegisterTLSParsers();
RegisterSslParsers();
RegisterSMBParsers();
RegisterDCERPCParsers();
RegisterDCERPCUDPParsers();
@ -1097,7 +1097,7 @@ int main(int argc, char **argv)
DecodePPPRegisterTests();
DecodeVLANRegisterTests();
HTPParserRegisterTests();
TLSParserRegisterTests();
SslParserRegisterTests();
SSHParserRegisterTests();
SMBParserRegisterTests();
DCERPCParserRegisterTests();

Loading…
Cancel
Save