summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2003-03-04 07:46:43 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2003-03-04 07:46:43 +0000
commitf16232205e2e20120d80f8d9019908b2d0d94fcf (patch)
tree0db538aeba308ba86e9eaa6288f02a41b0d3edee
parent38af72b3d68ab4c3fe0ae27332af37c9d71771cd (diff)
downloadgnutls-f16232205e2e20120d80f8d9019908b2d0d94fcf.tar.gz
Corrected a bug in 64 bit architectures, which affected the
serial number calculation in the record layer.
-rw-r--r--NEWS4
-rw-r--r--configure.in2
-rw-r--r--lib/defines.h7
-rw-r--r--lib/gnutls_cipher.c9
-rw-r--r--lib/gnutls_constate.c4
-rw-r--r--lib/gnutls_num.c39
-rw-r--r--lib/gnutls_num.h41
7 files changed, 27 insertions, 79 deletions
diff --git a/NEWS b/NEWS
index db9a8de951..17c8f84975 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+Version 0.8.3
+- Corrected a bug in 64 bit architectures, which affected the
+ serial number calculation in the record layer.
+
Version 0.8.2 (03/03/2003)
- Added protection against the new TLS 1.0 record layer timing attack.
diff --git a/configure.in b/configure.in
index 78f2d8aab3..45e221ea51 100644
--- a/configure.in
+++ b/configure.in
@@ -12,7 +12,7 @@ AC_DEFINE_UNQUOTED(T_OS, "$target_os", [OS name])
dnl Gnutls Version
GNUTLS_MAJOR_VERSION=0
GNUTLS_MINOR_VERSION=8
-GNUTLS_MICRO_VERSION=2
+GNUTLS_MICRO_VERSION=3
GNUTLS_VERSION=$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION.$GNUTLS_MICRO_VERSION
AC_DEFINE_UNQUOTED(GNUTLS_VERSION, "$GNUTLS_VERSION", [version of gnutls])
diff --git a/lib/defines.h b/lib/defines.h
index 17b3add903..8afb31450f 100644
--- a/lib/defines.h
+++ b/lib/defines.h
@@ -96,19 +96,12 @@ typedef signed int sint;
#define SIZEOF_UNSIGNED_LONG_INT SIZEOF_UNSIGNED_LONG
-#if SIZEOF_UNSIGNED_LONG == 8
-# define HAVE_UINT64
-/* only used native uint64 in 64 bit machines */
-typedef unsigned long int uint64;
-#else
/* some systems had problems with long long int, thus,
* it is not used.
*/
typedef struct {
unsigned char i[8];
} uint64;
-#endif
-
#if SIZEOF_UNSIGNED_LONG == 4
typedef unsigned long int uint32;
diff --git a/lib/gnutls_cipher.c b/lib/gnutls_cipher.c
index c31ac04da5..120bbfff71 100644
--- a/lib/gnutls_cipher.c
+++ b/lib/gnutls_cipher.c
@@ -241,7 +241,6 @@ int _gnutls_compressed2ciphertext(gnutls_session session,
uint8 MAC[MAX_HASH_SIZE];
uint16 c_length;
uint8 pad;
- uint64 seq_num;
int length,ret;
GNUTLS_MAC_HANDLE td;
uint8 type = _type;
@@ -271,11 +270,9 @@ int _gnutls_compressed2ciphertext(gnutls_session session,
}
c_length = _gnutls_conv_uint16(compressed.size);
- seq_num =
- _gnutls_conv_uint64(&session->connection_state.write_sequence_number);
if (td != GNUTLS_MAC_FAILED) { /* actually when the algorithm in not the NULL one */
- _gnutls_hmac(td, UINT64DATA(seq_num), 8);
+ _gnutls_hmac(td, UINT64DATA(session->connection_state.write_sequence_number), 8);
_gnutls_hmac(td, &type, 1);
if ( ver != GNUTLS_SSL3) { /* TLS 1.0 only */
@@ -332,7 +329,6 @@ int _gnutls_ciphertext2compressed(gnutls_session session,
uint8 MAC[MAX_HASH_SIZE];
uint16 c_length;
uint8 pad;
- uint64 seq_num;
uint16 length;
GNUTLS_MAC_HANDLE td;
uint16 blocksize;
@@ -431,13 +427,12 @@ int _gnutls_ciphertext2compressed(gnutls_session session,
c_length = _gnutls_conv_uint16((uint16) length);
- seq_num = _gnutls_conv_uint64( &session->connection_state.read_sequence_number);
/* Pass the type, version, length and compressed through
* MAC.
*/
if (td != GNUTLS_MAC_FAILED) {
- _gnutls_hmac(td, UINT64DATA(seq_num), 8);
+ _gnutls_hmac(td, UINT64DATA(session->connection_state.read_sequence_number), 8);
_gnutls_hmac(td, &type, 1);
if ( ver != GNUTLS_SSL3) { /* TLS 1.0 only */
diff --git a/lib/gnutls_constate.c b/lib/gnutls_constate.c
index 4d49af2440..fc75d27832 100644
--- a/lib/gnutls_constate.c
+++ b/lib/gnutls_constate.c
@@ -450,7 +450,7 @@ int _gnutls_read_connection_state_init(gnutls_session session)
int mac_size;
int rc;
- _gnutls_uint64zero(&session->connection_state.read_sequence_number);
+ _gnutls_uint64zero(session->connection_state.read_sequence_number);
/* Update internals from CipherSuite selected.
* If we are resuming just copy the connection session
@@ -632,7 +632,7 @@ int _gnutls_write_connection_state_init(gnutls_session session)
int mac_size;
int rc;
- _gnutls_uint64zero(&session->connection_state.write_sequence_number);
+ _gnutls_uint64zero(session->connection_state.write_sequence_number);
/* Update internals from CipherSuite selected.
* If we are resuming just copy the connection session
diff --git a/lib/gnutls_num.c b/lib/gnutls_num.c
index f747d4454e..8e078bb098 100644
--- a/lib/gnutls_num.c
+++ b/lib/gnutls_num.c
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2000,2001,2002 Nikos Mavroyanopoulos
+ * Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
*
- * This file is part of GNUTLS.
+ * This file is part of GNUTLS.
*
* The GNUTLS library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -27,16 +27,8 @@
#include <gnutls_num.h>
#include <gnutls_errors.h>
-
-#ifndef HAVE_UINT64
-
/* This function will set the uint64 x to zero
*/
-int _gnutls_uint64zero( uint64 *x) {
-
- memset( x->i, 0, 8);
- return 0;
-}
/* This function will add one to uint64 x.
* Returns 0 on success, or -1 if the uint64 max limit
@@ -59,8 +51,6 @@ register int i, y=0;
return 0;
}
-#endif /* HAVE_UINT64 */
-
uint32 _gnutls_uint24touint32( uint24 num) {
uint32 ret=0;
@@ -163,34 +153,13 @@ uint16 _gnutls_conv_uint16( uint16 data) {
#endif
}
-uint64 _gnutls_conv_uint64( const uint64* data) {
-#ifdef HAVE_UINT64
-# ifndef WORDS_BIGENDIAN
- return byteswap64(*data);
-# else
- return *data;
-# endif /* WORDS_BIGENDIAN */
-#else
- uint64 ret;
-
- memcpy( ret.i, data->i, 8);
- return ret;
-#endif /* HAVE_UINT64 */
-}
-
uint32 _gnutls_uint64touint32( const uint64* num) {
uint32 ret;
-#ifdef HAVE_UINT64
- ret = (uint32) *num;
-
-#else /* no native uint64 */
-
memcpy( &ret, &num->i[4], 4);
-# ifndef WORDS_BIGENDIAN
+#ifndef WORDS_BIGENDIAN
ret = byteswap32(ret);
-# endif
-#endif /* HAVE_UINT64 */
+#endif
return ret;
}
diff --git a/lib/gnutls_num.h b/lib/gnutls_num.h
index a8f0ebae48..91a54a4073 100644
--- a/lib/gnutls_num.h
+++ b/lib/gnutls_num.h
@@ -1,21 +1,21 @@
/*
- * Copyright (C) 2000 Nikos Mavroyanopoulos
+ * Copyright (C) 2000,2003 Nikos Mavroyanopoulos
*
- * This file is part of GNUTLS.
+ * This file is part of GNUTLS.
*
- * GNUTLS is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * GNUTLS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * GNUTLS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * GNUTLS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include <gnutls_int.h>
@@ -37,25 +37,12 @@ uint32 _gnutls_read_uint32( const opaque* data);
uint16 _gnutls_read_uint16( const opaque* data);
uint32 _gnutls_conv_uint32( uint32 data);
uint16 _gnutls_conv_uint16( uint16 data);
-uint64 _gnutls_conv_uint64( const uint64 *data);
uint32 _gnutls_read_uint24( const opaque* data);
void _gnutls_write_uint24( uint32 num, opaque* data);
void _gnutls_write_uint32( uint32 num, opaque* data);
void _gnutls_write_uint16( uint16 num, opaque* data);
uint32 _gnutls_uint64touint32( const uint64*);
-#ifndef HAVE_UINT64
-int _gnutls_uint64zero( uint64 *);
int _gnutls_uint64pp( uint64 *);
+# define _gnutls_uint64zero(x) x.i[0] = x.i[1] = x.i[2] = x.i[3] = x.i[4] = x.i[5] = x.i[6] = x.i[7] = 0
# define UINT64DATA(x) x.i
-
-#else
-# define UINT64DATA(x) &x
-# define rotl64(x,n) (((x) << ((uint16)(n))) | ((x) >> (64 - (uint16)(n))))
-# define rotr64(x,n) (((x) >> ((uint16)(n))) | ((x) << (64 - (uint16)(n))))
-# define byteswap64(x) ((rotl64(x, 8) & 0x00ff00ff00ff00ffUL) | (rotr64(x, 8) & 0xff00ff00ff00ff00UL))
-
-# define _gnutls_uint64pp(x) ((++(*x)==0) ? -1 : 0)
-# define _gnutls_uint64zero(x) (*x) = 0
-
-#endif