+Tue Jul 17 16:53:30 EEST 2001 Pekka Riikonen <priikone@silcnet.org>
+
+ * Found a bug in the SKE implementation. The HASH value,
+ specified by the protocol, was not computed correctly. The
+ public key of the responder was not added to the computation
+ even though it is mandatory. Affected file lib/silcske/silcske.c.
+ This unfortunately causes incompatibilities with older
+ clients and servers.
+
+ * Added WIN32 specific network init and uninit functions:
+ silc_net_win32_init and silc_net_win32_uninit to init and uninit
+ the Winsock2. Affected file lib/silcutil/silcnet.h and
+ lib/silcutil/win32/silcwin32net.c.
+
+ * Set the socket always to nonblocking mode on WIN32 after
+ reading data or writing data. Affected file is
+ lib/silcutil/win32/silcwin32sockconn.c.
+
Mon Jul 16 22:55:26 EEST 2001 Pekka Riikonen <priikone@silcnet.org>
* Fixed various compilation problems under WIN32. Affected
in separately.
+TODO/Bugs in native WIN32 support (libraries)
+=============================================
+
+ o silc_net_create_connection_async does not work the same way than on
+ Unix. Do it with threads on WIN32.
+
+
TODO In SILC Protocol
=====================
}
if (ske->start_payload_copy)
silc_buffer_free(ske->start_payload_copy);
- if (ske->pk)
- silc_free(ske->pk);
if (ske->x) {
silc_mp_uninit(ske->x);
silc_free(ske->x);
/* Send the packet. */
if (ske->callbacks->send_packet)
(*ske->callbacks->send_packet)(ske, payload_buf,
- SILC_PACKET_KEY_EXCHANGE_1,
- ske->callbacks->context);
+ SILC_PACKET_KEY_EXCHANGE_1,
+ ske->callbacks->context);
silc_buffer_free(payload_buf);
ske->users++;
(*ske->callbacks->verify_key)(ske, recv_payload->pk_data,
- recv_payload->pk_len,
- recv_payload->pk_type,
- ske->callbacks->context,
- silc_ske_responder_phase2_final, NULL);
+ recv_payload->pk_len,
+ recv_payload->pk_type,
+ ske->callbacks->context,
+ silc_ske_responder_phase2_final, NULL);
/* We will continue to the final state after the public key has
been verified by the caller. */
KEY = silc_mp_mp2bin(ske->KEY, 0, &KEY_len);
buf = silc_buffer_alloc(ske->start_payload_copy->len +
- ske->pk_len + e_len + f_len + KEY_len);
+ ske->ke2_payload->pk_len + e_len +
+ f_len + KEY_len);
silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
-
+
/* Format the buffer used to compute the hash value */
ret =
silc_buffer_format(buf,
SILC_STR_UI_XNSTRING(ske->start_payload_copy->data,
ske->start_payload_copy->len),
- SILC_STR_UI_XNSTRING(ske->pk, ske->pk_len),
+ SILC_STR_UI_XNSTRING(ske->ke2_payload->pk_data,
+ ske->ke2_payload->pk_len),
SILC_STR_UI_XNSTRING(e, e_len),
SILC_STR_UI_XNSTRING(f, f_len),
SILC_STR_UI_XNSTRING(KEY, KEY_len),
e = silc_mp_mp2bin(&ske->ke1_payload->x, 0, &e_len);
buf = silc_buffer_alloc(ske->start_payload_copy->len +
- ske->pk_len + e_len);
+ ske->ke1_payload->pk_len + e_len);
silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
/* Format the buffer used to compute the hash value */
silc_buffer_format(buf,
SILC_STR_UI_XNSTRING(ske->start_payload_copy->data,
ske->start_payload_copy->len),
- SILC_STR_UI_XNSTRING(ske->pk, ske->pk_len),
+ SILC_STR_UI_XNSTRING(ske->ke1_payload->pk_data,
+ ske->ke1_payload->pk_len),
SILC_STR_UI_XNSTRING(e, e_len),
SILC_STR_END);
if (ret == -1) {
HASH computation. */
SilcBuffer start_payload_copy;
- /* If initiator, this is responders public key. If responder this
- is our own public key. */
- unsigned char *pk;
- uint32 pk_len;
-
/* Random number x, 1 < x < q. This is the secret exponent
used in Diffie Hellman computations. */
SilcMPInt *x;
***/
char *silc_net_localhost();
+#ifdef WIN32
+
+/****f* silcutil/SilcNetAPI/silc_net_win32_init
+ *
+ * SYNOPSIS
+ *
+ * bool silc_net_win32_init(void);
+ *
+ * DESCRIPTION
+ *
+ * This is WIN32 system specific function and is used to initialize
+ * the network. This must be called by all WIN32 applications. It
+ * is usually called at the application's main() or WinMain() before
+ * calling any other SILC routine. The application must also call
+ * the silc_net_win32_uninit when exiting the application. Returns
+ * FALSE on error. The network will not work if this function returns
+ * FALSE.
+ *
+ ***/
+bool silc_net_win32_init(void);
+
+/****f* silcutil/SilcNetAPI/silc_net_win32_uninit
+ *
+ * SYNOPSIS
+ *
+ * void silc_net_win32_init(void);
+ *
+ * DESCRIPTION
+ *
+ * This is WIN32 system specific function and is used to uninitialize
+ * the network. This must be called by all WIN32 applications. It
+ * is usually called when the application is exiting. After calling
+ * this function the SILC Net API routines will not work anymore.
+ *
+ ***/
+void silc_net_win32_init(void);
+
+#endif
+
#endif
return -1;
}
- /* Set socket to nonblocking mode */
- silc_net_set_socket_nonblock(sock);
-
/* Connect to the host */
rval = connect(sock, (struct sockaddr *)&desthost, sizeof(desthost));
err = WSAGetLastError();
return -1;
}
+ /* Set socket to nonblocking mode */
+ silc_net_set_socket_nonblock(sock);
+
/* Set appropriate options */
silc_net_set_socket_opt(sock, IPPROTO_TCP, TCP_NODELAY, 1);
silc_net_set_socket_opt(sock, SOL_SOCKET, SO_KEEPALIVE, 1);
unsigned long on = 1;
return ioctlsocket(sock, FIONBIO, &on);
}
+
+/* Init Winsock2. */
+
+bool silc_net_win32_init(void)
+{
+ int ret, sopt = SO_SYNCHRONOUS_NONALERT;
+ WSADATA wdata;
+ WORD ver = MAKEWORD(1, 1);
+
+ ret = WSAStartup(ver, &wdata);
+ if (ret)
+ return FALSE;
+
+ /* Allow using the SOCKET's as file descriptors so that we can poll
+ them with SILC Scheduler. */
+ ret = setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&sopt,
+ sizeof(sopt));
+ if (ret)
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Uninit Winsock2 */
+
+void silc_net_win32_uninit(void)
+{
+ WSACleanup();
+}
err = WSAGetLastError();
if (err == WSAEWOULDBLOCK) {
SILC_LOG_DEBUG(("Could not write immediately, will do it later"));
+ silc_net_set_socket_nonblock(fd);
return -2;
}
SILC_LOG_ERROR(("Cannot write to socket: %d", (int)fd));
+ silc_net_set_socket_nonblock(fd);
return -1;
}
SILC_LOG_DEBUG(("Wrote data %d bytes", ret));
+ silc_net_set_socket_nonblock(fd);
return ret;
}
err = WSAGetLastError();
if (err == WSAEWOULDBLOCK || err == WSAEINTR) {
SILC_LOG_DEBUG(("Could not read immediately, will do it later"));
+ silc_net_set_socket_nonblock(fd);
return -2;
}
SILC_LOG_ERROR(("Cannot read from socket: %d", (int)fd));
+ silc_net_set_socket_nonblock(fd);
return -1;
}
+ silc_net_set_socket_nonblock(fd);
+
if (!len)
return 0;