gnutls-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU gnutls branch, gnutls_2_12_x, updated. gnutls_2_12_5-11-gc0d9a


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, gnutls_2_12_x, updated. gnutls_2_12_5-11-gc0d9ae7
Date: Thu, 26 May 2011 06:11:20 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU gnutls".

http://git.savannah.gnu.org/cgit/gnutls.git/commit/?id=c0d9ae7f9444e828b17f68d34361ea9fe77fe6a0

The branch, gnutls_2_12_x has been updated
       via  c0d9ae7f9444e828b17f68d34361ea9fe77fe6a0 (commit)
      from  a027093ede7b22289350b5cba15956de7ea0ed8e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c0d9ae7f9444e828b17f68d34361ea9fe77fe6a0
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu May 26 07:59:40 2011 +0200

    Added gnutls_global_set_time_function() that allows overriding the
    default system time() function.

-----------------------------------------------------------------------

Summary of changes:
 lib/ext_session_ticket.c        |    3 ++-
 lib/gnutls_db.c                 |    2 +-
 lib/gnutls_global.c             |   17 +++++++++++++++++
 lib/gnutls_handshake.c          |    7 +++----
 lib/gnutls_int.h                |    1 +
 lib/gnutls_session_pack.c       |    2 +-
 lib/gnutls_v2_compat.c          |    2 +-
 lib/includes/gnutls/gnutls.h.in |    3 +++
 lib/libgnutls.map               |    1 +
 lib/nettle/rnd.c                |    6 +++---
 lib/opencdk/keydb.c             |    5 ++---
 lib/opencdk/literal.c           |    3 +--
 lib/opencdk/read-packet.c       |    2 +-
 lib/opencdk/sig-check.c         |    3 +--
 lib/openpgp/gnutls_openpgp.c    |    1 -
 lib/system.c                    |    1 +
 lib/system.h                    |    1 +
 lib/x509/common.c               |    1 -
 lib/x509/verify.c               |    2 +-
 19 files changed, 41 insertions(+), 22 deletions(-)

diff --git a/lib/ext_session_ticket.c b/lib/ext_session_ticket.c
index 3c77868..b2bf933 100644
--- a/lib/ext_session_ticket.c
+++ b/lib/ext_session_ticket.c
@@ -35,6 +35,7 @@
 #include <gnutls_mbuffers.h>
 #include <gnutls_extensions.h>
 #include <gnutls_constate.h>
+#include <system.h>
 
 #ifdef ENABLE_SESSION_TICKET
 
@@ -128,7 +129,7 @@ decrypt_ticket (gnutls_session_t session, 
session_ticket_ext_st * priv,
   cipher_hd_st cipher_hd;
   gnutls_datum_t key, IV, mac_secret, state;
   opaque final[MAC_SECRET_SIZE];
-  time_t timestamp = time (0);
+  time_t timestamp = gnutls_time (0);
   int ret;
 
   /* Check the integrity of ticket using HMAC-SHA-256. */
diff --git a/lib/gnutls_db.c b/lib/gnutls_db.c
index 1c26ffb..9946c8e 100644
--- a/lib/gnutls_db.c
+++ b/lib/gnutls_db.c
@@ -153,7 +153,7 @@ gnutls_db_check_entry (gnutls_session_t session, 
gnutls_datum_t session_entry)
 {
   time_t timestamp;
 
-  timestamp = time (0);
+  timestamp = gnutls_time (0);
 
   if (session_entry.data != NULL)
     if (timestamp -
diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c
index 1a59bdf..60656d6 100644
--- a/lib/gnutls_global.c
+++ b/lib/gnutls_global.c
@@ -33,6 +33,7 @@
 #include <gnutls_extensions.h>  /* for _gnutls_ext_init */
 #include <gnutls_cryptodev.h>
 #include <locks.h>
+#include <system.h>
 
 #include "sockets.h"
 #include "gettext.h"
@@ -69,6 +70,22 @@ gnutls_global_set_log_function (gnutls_log_func log_func)
 }
 
 /**
+ * gnutls_global_set_time_function:
+ * @time_func: it's the system time function
+ *
+ * This is the function where you can override the default system
+ * time function.
+ *
+ * gnutls_time_func is of the form,
+ * time_t (*gnutls_time_func)( time*);
+ **/
+void
+gnutls_global_set_time_function (gnutls_time_func time_func)
+{
+  gnutls_time = time_func;
+}
+
+/**
  * gnutls_global_set_log_level:
  * @level: it's an integer from 0 to 9.
  *
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c
index a4a3aeb..986d11b 100644
--- a/lib/gnutls_handshake.c
+++ b/lib/gnutls_handshake.c
@@ -322,7 +322,7 @@ _gnutls_tls_create_random (opaque * dst)
    * system's time.
    */
 
-  tim = time (NULL);
+  tim = gnutls_time (NULL);
   /* generate server random value */
   _gnutls_write_uint32 (tim, dst);
 
@@ -442,7 +442,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque 
* data,
   _gnutls_tls_create_random (rnd);
   _gnutls_set_server_random (session, rnd);
 
-  session->security_parameters.timestamp = time (NULL);
+  session->security_parameters.timestamp = gnutls_time (NULL);
 
   DECR_LEN (len, 1);
   session_id_len = data[pos++];
@@ -2091,7 +2091,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int 
again)
 
       /* In order to know when this session was initiated.
        */
-      session->security_parameters.timestamp = time (NULL);
+      session->security_parameters.timestamp = gnutls_time (NULL);
 
       /* Generate random data 
        */
@@ -2855,7 +2855,6 @@ _gnutls_send_handshake_final (gnutls_session_t session, 
int init)
     case STATE20:
 
       STATE = STATE20;
-
       ret = _gnutls_handshake_io_write_flush (session);
       if (ret < 0)
         {
diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h
index f41f7cf..cafaa91 100644
--- a/lib/gnutls_int.h
+++ b/lib/gnutls_int.h
@@ -58,6 +58,7 @@ typedef struct
 } uint64;
 
 #include <gnutls/gnutls.h>
+#include <system.h>
 
 /*
  * They are not needed any more. You can simply enable
diff --git a/lib/gnutls_session_pack.c b/lib/gnutls_session_pack.c
index 1f4dec1..a305a8b 100644
--- a/lib/gnutls_session_pack.c
+++ b/lib/gnutls_session_pack.c
@@ -803,7 +803,7 @@ unpack_security_parameters (gnutls_session_t session, 
gnutls_buffer_st * ps)
 {
   size_t pack_size;
   int ret;
-  time_t timestamp = time (0);
+  time_t timestamp = gnutls_time (0);
 
   BUFFER_POP_NUM (ps, pack_size);
 
diff --git a/lib/gnutls_v2_compat.c b/lib/gnutls_v2_compat.c
index d92892b..64fd6d3 100644
--- a/lib/gnutls_v2_compat.c
+++ b/lib/gnutls_v2_compat.c
@@ -226,7 +226,7 @@ _gnutls_read_client_hello_v2 (gnutls_session_t session, 
opaque * data,
   _gnutls_tls_create_random (rnd);
   _gnutls_set_server_random (session, rnd);
 
-  session->security_parameters.timestamp = time (NULL);
+  session->security_parameters.timestamp = gnutls_time (NULL);
 
 
   /* RESUME SESSION */
diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in
index 20e5c50..9512ece 100644
--- a/lib/includes/gnutls/gnutls.h.in
+++ b/lib/includes/gnutls/gnutls.h.in
@@ -1106,6 +1106,7 @@ extern "C"
   int gnutls_global_init (void);
   void gnutls_global_deinit (void);
 
+  typedef time_t (*gnutls_time_func) (time_t *t);
   typedef int (*mutex_init_func) (void **mutex);
   typedef int (*mutex_lock_func) (void **mutex);
   typedef int (*mutex_unlock_func) (void **mutex);
@@ -1127,6 +1128,8 @@ extern "C"
                                      gnutls_realloc_function realloc_func,
                                      gnutls_free_function free_func);
 
+  void gnutls_global_set_time_function (gnutls_time_func);
+
 /* For use in callbacks */
   extern gnutls_alloc_function gnutls_malloc;
   extern gnutls_alloc_function gnutls_secure_malloc;
diff --git a/lib/libgnutls.map b/lib/libgnutls.map
index 23a2d81..8ebbae4 100644
--- a/lib/libgnutls.map
+++ b/lib/libgnutls.map
@@ -691,6 +691,7 @@ GNUTLS_2_12
        gnutls_pubkey_verify_data;
        gnutls_certificate_get_issuer;
        gnutls_x509_crq_verify;
+       gnutls_global_set_time_function;
 } GNUTLS_2_10;
 
 GNUTLS_PRIVATE {
diff --git a/lib/nettle/rnd.c b/lib/nettle/rnd.c
index 8af0add..2278c7c 100644
--- a/lib/nettle/rnd.c
+++ b/lib/nettle/rnd.c
@@ -94,7 +94,7 @@ do_trivia_source (int init)
 static int
 do_device_source (int init)
 {
-  time_t now = time (NULL);
+  time_t now = gnutls_time (NULL);
   int read_size = DEVICE_READ_SIZE;
 
   if (init)
@@ -226,7 +226,7 @@ do_trivia_source (int init)
 static int
 do_device_source_urandom (int init)
 {
-  time_t now = time (NULL);
+  time_t now = gnutls_time (NULL);
   int read_size = DEVICE_READ_SIZE;
 
   if (init)
@@ -291,7 +291,7 @@ do_device_source_urandom (int init)
 static int
 do_device_source_egd (int init)
 {
-  time_t now = time (NULL);
+  time_t now = gnutls_time (NULL);
   int read_size = DEVICE_READ_SIZE;
 
   if (init)
diff --git a/lib/opencdk/keydb.c b/lib/opencdk/keydb.c
index 7ef91e4..5be3129 100644
--- a/lib/opencdk/keydb.c
+++ b/lib/opencdk/keydb.c
@@ -29,7 +29,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
 #include <ctype.h>
 
 #include "opencdk.h"
@@ -1677,7 +1676,7 @@ keydb_merge_selfsig (cdk_kbnode_t key, u32 * keyid)
       if (key_expire)
         {
           pk->expiredate = pk->timestamp + key_expire;
-          pk->has_expired = pk->expiredate > (u32) time (NULL) ? 0 : 1;
+          pk->has_expired = pk->expiredate > (u32) gnutls_time (NULL) ? 0 : 1;
         }
 
       pk->is_invalid = 0;
@@ -1694,7 +1693,7 @@ keydb_parse_allsigs (cdk_kbnode_t knode, cdk_keydb_hd_t 
hd, int check)
   cdk_pkt_signature_t sig;
   cdk_pkt_pubkey_t pk;
   cdk_subpkt_t s = NULL;
-  u32 expiredate = 0, curtime = (u32) time (NULL);
+  u32 expiredate = 0, curtime = (u32) gnutls_time (NULL);
   u32 keyid[2];
 
   if (!knode)
diff --git a/lib/opencdk/literal.c b/lib/opencdk/literal.c
index a36921c..3ad1c2b 100644
--- a/lib/opencdk/literal.c
+++ b/lib/opencdk/literal.c
@@ -26,7 +26,6 @@
 #include <config.h>
 #endif
 #include <stdio.h>
-#include <time.h>
 
 #include "opencdk.h"
 #include "main.h"
@@ -211,7 +210,7 @@ literal_encode (void *data, FILE * in, FILE * out)
   memcpy (pt->name, pfx->filename, filelen);
   pt->namelen = filelen;
   pt->name[pt->namelen] = '\0';
-  pt->timestamp = (u32) time (NULL);
+  pt->timestamp = (u32) gnutls_time (NULL);
   pt->mode = intmode_to_char (pfx->mode);
   pt->len = cdk_stream_get_length (si);
   pt->buf = si;
diff --git a/lib/opencdk/read-packet.c b/lib/opencdk/read-packet.c
index 03395b3..a49d4fe 100644
--- a/lib/opencdk/read-packet.c
+++ b/lib/opencdk/read-packet.c
@@ -676,7 +676,7 @@ parse_sig_subpackets (cdk_pkt_signature_t sig)
       else if (node->type == CDK_SIGSUBPKT_SIG_EXPIRE && node->size >= 4)
         {
           sig->expiredate = _cdk_buftou32 (node->d);
-          if (sig->expiredate > 0 && sig->expiredate < (u32) time (NULL))
+          if (sig->expiredate > 0 && sig->expiredate < (u32) gnutls_time 
(NULL))
             sig->flags.expired = 1;
         }
       else if (node->type == CDK_SIGSUBPKT_POLICY)
diff --git a/lib/opencdk/sig-check.c b/lib/opencdk/sig-check.c
index c1a9154..75f0d9b 100644
--- a/lib/opencdk/sig-check.c
+++ b/lib/opencdk/sig-check.c
@@ -26,7 +26,6 @@
 #include <config.h>
 #endif
 #include <stdio.h>
-#include <time.h>
 #include <assert.h>
 
 #include "opencdk.h"
@@ -236,7 +235,7 @@ _cdk_sig_check (cdk_pubkey_t pk, cdk_pkt_signature_t sig,
 {
   cdk_error_t rc;
   byte md[MAX_DIGEST_LEN];
-  time_t cur_time = (u32) time (NULL);
+  time_t cur_time = (u32) gnutls_time (NULL);
 
   if (!pk || !sig || !digest)
     {
diff --git a/lib/openpgp/gnutls_openpgp.c b/lib/openpgp/gnutls_openpgp.c
index 8175a9d..5e13fd4 100644
--- a/lib/openpgp/gnutls_openpgp.c
+++ b/lib/openpgp/gnutls_openpgp.c
@@ -35,7 +35,6 @@
 #include <gnutls_str.h>
 #include <gnutls_sig.h>
 #include <stdio.h>
-#include <time.h>
 #include <sys/stat.h>
 
 #define datum_append(x, y, z) _gnutls_datum_append_m (x, y, z, gnutls_realloc)
diff --git a/lib/system.c b/lib/system.c
index 81fe97b..9f32534 100644
--- a/lib/system.c
+++ b/lib/system.c
@@ -259,6 +259,7 @@ _gnutls_atfork (void (*prepare) (void), void (*parent) 
(void),
 
 #endif /* NO_LOCKS */
 
+gnutls_time_func gnutls_time = time;
 mutex_init_func gnutls_mutex_init = gnutls_system_mutex_init;
 mutex_deinit_func gnutls_mutex_deinit = gnutls_system_mutex_deinit;
 mutex_lock_func gnutls_mutex_lock = gnutls_system_mutex_lock;
diff --git a/lib/system.h b/lib/system.h
index 860bca8..0cedded 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -33,5 +33,6 @@ ssize_t system_read_peek (gnutls_transport_ptr ptr, void 
*data,
 
 int _gnutls_atfork (void (*prepare) (void), void (*parent) (void),
                     void (*child) (void));
+extern gnutls_time_func gnutls_time;
 
 #endif /* SYSTEM_H */
diff --git a/lib/x509/common.c b/lib/x509/common.c
index 80af4a0..1825261 100644
--- a/lib/x509/common.c
+++ b/lib/x509/common.c
@@ -34,7 +34,6 @@
 #include <x509_b64.h>
 #include "x509_int.h"
 #include <common.h>
-#include <time.h>
 
 struct oid2string
 {
diff --git a/lib/x509/verify.c b/lib/x509/verify.c
index ff732f8..86f7f76 100644
--- a/lib/x509/verify.c
+++ b/lib/x509/verify.c
@@ -471,7 +471,7 @@ _gnutls_x509_verify_certificate (const gnutls_x509_crt_t * 
certificate_list,
 {
   int i = 0, ret;
   unsigned int status = 0, output;
-  time_t now = time (0);
+  time_t now = gnutls_time (0);
   gnutls_x509_crt_t issuer = NULL;
 
   if (clist_size > 1)


hooks/post-receive
-- 
GNU gnutls



reply via email to

[Prev in Thread] Current Thread [Next in Thread]