]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
added support for session resuming
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 9 Dec 2000 22:33:18 +0000 (22:33 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 9 Dec 2000 22:33:18 +0000 (22:33 +0000)
lib/gnutls_session.c [new file with mode: 0644]
lib/gnutls_session.h [new file with mode: 0644]

diff --git a/lib/gnutls_session.c b/lib/gnutls_session.c
new file mode 100644 (file)
index 0000000..129feec
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *      Copyright (C) 2000 Nikos Mavroyanopoulos
+ *
+ * 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 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
+ */
+#include <defines.h>
+#include "gnutls_int.h"
+#include "gnutls_errors.h"
+
+/* Returns all session parameters - in order to support resuming 
+ */
+int gnutls_get_current_session( GNUTLS_STATE state, void* session, int *session_size) {
+
+       ( *session_size = sizeof(SecurityParameters));
+       
+       if (state->gnutls_internals.resumable==RESUME_FALSE) return GNUTLS_E_INVALID_SESSION;
+       /* just return the session size */
+       if (session==NULL) {
+               return 0;
+       }
+       memcpy( session, &state->security_parameters, sizeof(SecurityParameters));
+       
+       return 0;
+}
+
+/* Sets all session parameters - in order to support resuming 
+ * session must be the one returned by get_current_session();
+ * This function should be called before gnutls_handshake_begin
+ */
+int gnutls_set_current_session( GNUTLS_STATE state, void* session, int session_size) {
+
+       if ( session_size != sizeof(SecurityParameters)) {
+               return GNUTLS_E_UNIMPLEMENTED_FEATURE;
+       }
+
+       memcpy( &state->gnutls_internals.resumed_security_parameters, session, sizeof(SecurityParameters));
+       
+       return 0;
+}
diff --git a/lib/gnutls_session.h b/lib/gnutls_session.h
new file mode 100644 (file)
index 0000000..93eca12
--- /dev/null
@@ -0,0 +1,2 @@
+int gnutls_set_current_session( GNUTLS_STATE state, void* session, int session_size);
+int gnutls_get_current_session( GNUTLS_STATE state, void* session, int *session_size);