updates.
[silc.git] / lib / silcclient / client_prvmsg.c
index d0695efdf7d4d40af6caec0f16281a6c08be4035..a5c6d7d171c1bf442bf737636d2faa8e247d0bb2 100644 (file)
@@ -45,6 +45,7 @@ void silc_client_send_private_message(SilcClient client,
   SilcPacketContext packetdata;
   SilcCipher cipher;
   SilcHmac hmac;
+  int block_len;
 
   SILC_LOG_DEBUG(("Sending private message"));
 
@@ -69,6 +70,7 @@ void silc_client_send_private_message(SilcClient client,
   /* Get data used in the encryption */
   cipher = client_entry->send_key;
   hmac = conn->hmac_send;
+  block_len = silc_cipher_get_block_len(cipher);
 
   /* Set the packet context pointers. */
   packetdata.flags = SILC_PACKET_FLAG_PRIVMSG_KEY;
@@ -83,7 +85,7 @@ void silc_client_send_private_message(SilcClient client,
     packetdata.src_id_len + packetdata.dst_id_len;
   packetdata.padlen = SILC_PACKET_PADLEN((SILC_PACKET_HEADER_LEN +
                                          packetdata.src_id_len +
-                                         packetdata.dst_id_len));
+                                         packetdata.dst_id_len), block_len);
 
   /* Prepare outgoing data buffer for packet sending */
   silc_packet_send_prepare(sock, 
@@ -99,11 +101,12 @@ void silc_client_send_private_message(SilcClient client,
   silc_buffer_put(sock->outbuf, buffer->data, buffer->len);
 
   /* Create the outgoing packet */
-  silc_packet_assemble(&packetdata);
+  silc_packet_assemble(&packetdata, cipher);
 
   /* Encrypt the header and padding of the packet. */
   cipher = conn->send_key;
-  silc_packet_encrypt(cipher, hmac, sock->outbuf, SILC_PACKET_HEADER_LEN + 
+  silc_packet_encrypt(cipher, hmac, conn->psn_send++,
+                     sock->outbuf, SILC_PACKET_HEADER_LEN + 
                      packetdata.src_id_len + packetdata.dst_id_len +
                      packetdata.padlen);
 
@@ -111,7 +114,7 @@ void silc_client_send_private_message(SilcClient client,
                   sock->outbuf->data, sock->outbuf->len);
 
   /* Now actually send the packet */
-  silc_client_packet_send_real(client, sock, force_send, FALSE);
+  silc_client_packet_send_real(client, sock, force_send);
   silc_free(packetdata.dst_id);
 
  out:
@@ -161,7 +164,8 @@ void silc_client_private_message(SilcClient client,
   if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)remote_id, 
                                       NULL, NULL, 
                                       silc_hash_client_id_compare, NULL,
-                                      &id_cache)) {
+                                      &id_cache) || 
+      ((SilcClientEntry)id_cache->context)->nickname == NULL) {
     /* Resolve the client info */
     silc_client_get_client_by_id_resolve(client, conn, remote_id,
                                         silc_client_private_message_cb,
@@ -320,7 +324,7 @@ int silc_client_add_private_message_key(SilcClient client,
     return FALSE;
 
   if (!cipher)
-    cipher = "aes-256-cbc";
+    cipher = SILC_DEFAULT_CIPHER;
 
   /* Check the requested cipher */
   if (!silc_cipher_is_supported(cipher))
@@ -394,7 +398,7 @@ int silc_client_add_private_message_key_ske(SilcClient client,
     return FALSE;
 
   if (!cipher)
-    cipher = "aes-256-cbc";
+    cipher = SILC_DEFAULT_CIPHER;
 
   /* Check the requested cipher */
   if (!silc_cipher_is_supported(cipher))