fix compilation without GNUTLS and libgcrypt

move from_hex_char() and from_hex() outside ifdef gnutls
add dummy ssl_generate_pre_master_secret()

this should fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9529

svn path=/trunk/; revision=53884
This commit is contained in:
Martin Kaiser 2013-12-09 17:51:48 +00:00
parent edce8204d1
commit 8aebe15965
1 changed files with 42 additions and 32 deletions

View File

@ -1351,6 +1351,40 @@ ssl_data_set(StringInfo* str, const guchar* data, guint len)
str->data_len = len;
}
static guint8
from_hex_char(gchar c) {
if ((c >= '0') && (c <= '9'))
return c - '0';
if ((c >= 'A') && (c <= 'F'))
return c - 'A' + 10;
if ((c >= 'a') && (c <= 'f'))
return c - 'a' + 10;
return 16;
}
/* from_hex converts |hex_len| bytes of hex data from |in| and sets |*out| to
* the result. |out->data| will be allocated using se_alloc. Returns TRUE on
* success. */
static gboolean from_hex(StringInfo* out, const char* in, gsize hex_len) {
gsize i;
if (hex_len & 1)
return FALSE;
out->data_len = (guint)hex_len/2;
out->data = (guchar *)wmem_alloc(wmem_file_scope(), out->data_len);
for (i = 0; i < out->data_len; i++) {
guint8 a = from_hex_char(in[i*2]);
guint8 b = from_hex_char(in[i*2 + 1]);
if (a == 16 || b == 16)
return FALSE;
out->data[i] = a << 4 | b;
}
return TRUE;
}
#if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
/* hmac abstraction layer */
@ -2307,38 +2341,6 @@ ssl_create_decoder(SslCipherSuite *cipher_suite, gint compression,
}
static guint8
from_hex_char(gchar c) {
if ((c >= '0') && (c <= '9'))
return c - '0';
if ((c >= 'A') && (c <= 'F'))
return c - 'A' + 10;
if ((c >= 'a') && (c <= 'f'))
return c - 'a' + 10;
return 16;
}
/* from_hex converts |hex_len| bytes of hex data from |in| and sets |*out| to
* the result. |out->data| will be allocated using se_alloc. Returns TRUE on
* success. */
static gboolean from_hex(StringInfo* out, const char* in, gsize hex_len) {
gsize i;
if (hex_len & 1)
return FALSE;
out->data_len = (guint)hex_len/2;
out->data = (guchar *)wmem_alloc(wmem_file_scope(), out->data_len);
for (i = 0; i < out->data_len; i++) {
guint8 a = from_hex_char(in[i*2]);
guint8 b = from_hex_char(in[i*2 + 1]);
if (a == 16 || b == 16)
return FALSE;
out->data[i] = a << 4 | b;
}
return TRUE;
}
int
ssl_generate_pre_master_secret(SslDecryptSession *ssl_session,
guint32 length, tvbuff_t *tvb, guint32 offset,
@ -3662,6 +3664,14 @@ ssl_find_cipher(int num,SslCipherSuite* cs)
return 0;
}
int
ssl_generate_pre_master_secret(SslDecryptSession *ssl_session _U_,
guint32 length _U_, tvbuff_t *tvb _U_, guint32 offset _U_,
const gchar *ssl_psk _U_, const gchar *keylog_filename _U_)
{
ssl_debug_printf("ssl_generate_pre_master_secret: impossible without gnutls.\n");
return 0;
}
int
ssl_generate_keyring_material(SslDecryptSession*ssl)
{
ssl_debug_printf("ssl_generate_keyring_material: impossible without gnutls. ssl %p\n",