Changed SILC code to use new SRT and SCT APIs.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 14 Mar 2008 11:44:27 +0000 (13:44 +0200)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 14 Mar 2008 11:44:27 +0000 (13:44 +0200)
13 files changed:
lib/silcapputil/silcapputil.c
lib/silcclient/client.c
lib/silcclient/client_attrs.c
lib/silcclient/client_ftp.c
lib/silcclient/client_listener.c
lib/silccore/silcauth.c
lib/silccore/silcauth.h
lib/silccore/silcmessage.c
lib/silcsftp/sftp_fs_memory.c
lib/silcsftp/sftp_util.c
lib/silcsftp/sftp_util.h
lib/silcske/silcconnauth.c
lib/silcske/silcske.c

index 157cce57b3ed3261c0b795bdf850a3f987f2fa43..573d4585e17a9f0ba439658351165effe749702f 100644 (file)
@@ -984,33 +984,19 @@ char *silc_id_render(void *id, SilcIdType id_type)
 {
   char tmp[100];
   unsigned char tmps[2];
 {
   char tmp[100];
   unsigned char tmps[2];
-  char *cp;
 
   memset(rid, 0, sizeof(rid));
   switch(id_type) {
   case SILC_ID_SERVER:
     {
       SilcServerID *server_id = (SilcServerID *)id;
 
   memset(rid, 0, sizeof(rid));
   switch(id_type) {
   case SILC_ID_SERVER:
     {
       SilcServerID *server_id = (SilcServerID *)id;
-      if (server_id->ip.data_len > 4) {
-#ifdef HAVE_IPV6
-       struct sockaddr_in6 ipv6;
-       memset(&ipv6, 0, sizeof(ipv6));
-       ipv6.sin6_family = AF_INET6;
-       memmove(&ipv6.sin6_addr, server_id->ip.data, sizeof(ipv6.sin6_addr));
-       if (!getnameinfo((struct sockaddr *)&ipv6, sizeof(ipv6),
-                        tmp, sizeof(tmp) - 1, NULL, 0, NI_NUMERICHOST))
-         _PUT_STRING(rid, tmp);
-#endif
-      } else {
-       struct in_addr ipv4;
-       memmove(&ipv4.s_addr, server_id->ip.data, 4);
-       cp = inet_ntoa(ipv4);
-       if (cp)
-         _PUT_STRING(rid, cp);
-      }
+
+      if (!silc_net_bin2addr(server_id->ip.data, server_id->ip.data_len,
+                            tmp, sizeof(tmp)))
+       return NULL;
 
       memset(tmp, 0, sizeof(tmp));
 
       memset(tmp, 0, sizeof(tmp));
-      silc_snprintf(tmp, sizeof(tmp) - 1, ",%d,", ntohs(server_id->port));
+      silc_snprintf(tmp, sizeof(tmp) - 1, ",%d,", silc_ntohs(server_id->port));
       _PUT_STRING(rid, tmp);
       SILC_PUT16_MSB(server_id->rnd, tmps);
       memset(tmp, 0, sizeof(tmp));
       _PUT_STRING(rid, tmp);
       SILC_PUT16_MSB(server_id->rnd, tmps);
       memset(tmp, 0, sizeof(tmp));
@@ -1021,23 +1007,10 @@ char *silc_id_render(void *id, SilcIdType id_type)
   case SILC_ID_CLIENT:
     {
       SilcClientID *client_id = (SilcClientID *)id;
   case SILC_ID_CLIENT:
     {
       SilcClientID *client_id = (SilcClientID *)id;
-      if (client_id->ip.data_len > 4) {
-#ifdef HAVE_IPV6
-       struct sockaddr_in6 ipv6;
-       memset(&ipv6, 0, sizeof(ipv6));
-       ipv6.sin6_family = AF_INET6;
-       memmove(&ipv6.sin6_addr, client_id->ip.data, sizeof(ipv6.sin6_addr));
-       if (!getnameinfo((struct sockaddr *)&ipv6, sizeof(ipv6),
-                        tmp, sizeof(tmp) - 1, NULL, 0, NI_NUMERICHOST))
-         _PUT_STRING(rid, tmp);
-#endif
-      } else {
-       struct in_addr ipv4;
-       memmove(&ipv4.s_addr, client_id->ip.data, 4);
-       cp = inet_ntoa(ipv4);
-       if (cp)
-         _PUT_STRING(rid, cp);
-      }
+
+      if (!silc_net_bin2addr(client_id->ip.data, client_id->ip.data_len,
+                            tmp, sizeof(tmp)))
+       return NULL;
 
       memset(tmp, 0, sizeof(tmp));
       silc_snprintf(tmp, sizeof(tmp) - 1, ",%02x,", client_id->rnd);
 
       memset(tmp, 0, sizeof(tmp));
       silc_snprintf(tmp, sizeof(tmp) - 1, ",%02x,", client_id->rnd);
@@ -1052,26 +1025,14 @@ char *silc_id_render(void *id, SilcIdType id_type)
   case SILC_ID_CHANNEL:
     {
       SilcChannelID *channel_id = (SilcChannelID *)id;
   case SILC_ID_CHANNEL:
     {
       SilcChannelID *channel_id = (SilcChannelID *)id;
-      if (channel_id->ip.data_len > 4) {
-#ifdef HAVE_IPV6
-       struct sockaddr_in6 ipv6;
-       memset(&ipv6, 0, sizeof(ipv6));
-       ipv6.sin6_family = AF_INET6;
-       memmove(&ipv6.sin6_addr, channel_id->ip.data, sizeof(ipv6.sin6_addr));
-       if (!getnameinfo((struct sockaddr *)&ipv6, sizeof(ipv6),
-                        tmp, sizeof(tmp) - 1, NULL, 0, NI_NUMERICHOST))
-         _PUT_STRING(rid, tmp);
-#endif
-      } else {
-       struct in_addr ipv4;
-       memmove(&ipv4.s_addr, channel_id->ip.data, 4);
-       cp = inet_ntoa(ipv4);
-       if (cp)
-         _PUT_STRING(rid, cp);
-      }
+
+      if (!silc_net_bin2addr(channel_id->ip.data, channel_id->ip.data_len,
+                            tmp, sizeof(tmp)))
+       return NULL;
 
       memset(tmp, 0, sizeof(tmp));
 
       memset(tmp, 0, sizeof(tmp));
-      silc_snprintf(tmp, sizeof(tmp) - 1, ",%d,", ntohs(channel_id->port));
+      silc_snprintf(tmp, sizeof(tmp) - 1, ",%d,",
+                   silc_ntohs(channel_id->port));
       _PUT_STRING(rid, tmp);
       SILC_PUT16_MSB(channel_id->rnd, tmps);
       memset(tmp, 0, sizeof(tmp));
       _PUT_STRING(rid, tmp);
       SILC_PUT16_MSB(channel_id->rnd, tmps);
       memset(tmp, 0, sizeof(tmp));
index c27d055e1e3e230ac2a65ae7bd54d5094761fd15..fa139d2e31461155f6507c5e2982ed61de42a4f6 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2007 Pekka Riikonen
+  Copyright (C) 1997 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -16,7 +16,6 @@
   GNU General Public License for more details.
 
 */
   GNU General Public License for more details.
 
 */
-/* $Id$ */
 
 #include "silc.h"
 #include "silcclient.h"
 
 #include "silc.h"
 #include "silcclient.h"
index b7d0dbde94c14738c6b9bb6ec7ef6424b10dab8d..1947c1fb3e5d7592f892ef40f6953a88f0d64400 100644 (file)
@@ -170,9 +170,9 @@ void silc_client_attributes_process(SilcClient client,
   s->buffer = buffer;
 
   /* Finally compute the digital signature of all the data we provided. */
   s->buffer = buffer;
 
   /* Finally compute the digital signature of all the data we provided. */
-  silc_pkcs_sign(conn->private_key, silc_buffer_data(buffer),
-                silc_buffer_len(buffer), TRUE, conn->internal->sha1hash,
-                client->rng, silc_client_attributes_process_signed, s);
+  silc_pkcs_sign_async(conn->private_key, silc_buffer_data(buffer),
+                      silc_buffer_len(buffer), TRUE, NULL,
+                      client->rng, silc_client_attributes_process_signed, s);
 }
 
 static void silc_client_attribute_destruct(void *key, void *context,
 }
 
 static void silc_client_attribute_destruct(void *key, void *context,
index a38d03c009873b315aea103310d6d94e9335213b..b4e8d46ec2724c77da6af638777fb44f5820fc55 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 - 2007 Pekka Riikonen
+  Copyright (C) 2001 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -16,7 +16,6 @@
   GNU General Public License for more details.
 
 */
   GNU General Public License for more details.
 
 */
-/* $Id$ */
 
 #include "silc.h"
 #include "silcclient.h"
 
 #include "silc.h"
 #include "silcclient.h"
@@ -193,7 +192,7 @@ static void silc_client_ftp_open_handle(SilcSFTP sftp,
                                        SILC_CLIENT_MESSAGE_ERROR,
                                        "File `%s' open failed: %s",
                                        session->filepath,
                                        SILC_CLIENT_MESSAGE_ERROR,
                                        "File `%s' open failed: %s",
                                        session->filepath,
-                                       strerror(errno));
+                                       silc_errno_string(silc_errno));
 
     if (session->monitor)
       (*session->monitor)(session->client, session->conn,
 
     if (session->monitor)
       (*session->monitor)(session->client, session->conn,
@@ -738,7 +737,8 @@ silc_client_file_send(SilcClient client,
     if (!session->listener) {
       client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
                                 "Cannot create listener for file transfer: "
     if (!session->listener) {
       client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
                                 "Cannot create listener for file transfer: "
-                                "%s", strerror(errno));
+                                "%s", silc_errno_string(silc_errno));
+
       silc_free(session);
       return SILC_CLIENT_FILE_NO_MEMORY;
     }
       silc_free(session);
       return SILC_CLIENT_FILE_NO_MEMORY;
     }
@@ -871,7 +871,8 @@ silc_client_file_receive(SilcClient client,
     if (!session->listener) {
       client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
                                 "Cannot create listener for file transfer: "
     if (!session->listener) {
       client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
                                 "Cannot create listener for file transfer: "
-                                "%s", strerror(errno));
+                                "%s", silc_errno_string(silc_errno));
+
       silc_free(session);
       return SILC_CLIENT_FILE_NO_MEMORY;
     }
       silc_free(session);
       return SILC_CLIENT_FILE_NO_MEMORY;
     }
index 24ae0c74104b2cf62e14ed42a0b8b4e272c6d14b..3735877cc9368fbf42ae59e003bc52cbfb4f35dd 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2007 Pekka Riikonen
+  Copyright (C) 2007 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -334,7 +334,8 @@ silc_client_listener_add(SilcClient client,
                     client, NULL, SILC_CLIENT_MESSAGE_ERROR,
                     "Cannot create UDP listener on %s on port %d: %s",
                     params->bind_ip ? params->bind_ip :
                     client, NULL, SILC_CLIENT_MESSAGE_ERROR,
                     "Cannot create UDP listener on %s on port %d: %s",
                     params->bind_ip ? params->bind_ip :
-                    params->local_ip, params->local_port, strerror(errno));
+                    params->local_ip, params->local_port,
+                    silc_errno_string(silc_errno));
       silc_client_listener_free(listener);
       if (stream)
        silc_stream_destroy(stream);
       silc_client_listener_free(listener);
       if (stream)
        silc_stream_destroy(stream);
@@ -364,7 +365,8 @@ silc_client_listener_add(SilcClient client,
                     client, NULL, SILC_CLIENT_MESSAGE_ERROR,
                     "Cannot create listener on %s on port %d: %s",
                     params->bind_ip ? params->bind_ip :
                     client, NULL, SILC_CLIENT_MESSAGE_ERROR,
                     "Cannot create listener on %s on port %d: %s",
                     params->bind_ip ? params->bind_ip :
-                    params->local_ip, params->local_port, strerror(errno));
+                    params->local_ip, params->local_port,
+                    silc_errno_string(silc_errno));
 
       silc_client_listener_free(listener);
       return NULL;
 
       silc_client_listener_free(listener);
       return NULL;
index 72cce5aad9492891f625afb0202368eb6173c8f6..f2c73f0ece9fad49a5081d464595d561760068db 100644 (file)
@@ -370,8 +370,8 @@ silc_auth_public_key_auth_generate_wpub(SilcPublicKey public_key,
   }
 
   /* Compute the hash and the signature. */
   }
 
   /* Compute the hash and the signature. */
-  op = silc_pkcs_sign(private_key, tmp, tmp_len, TRUE, hash, rng,
-                     silc_auth_public_key_auth_generate_cb, a);
+  op = silc_pkcs_sign_async(private_key, tmp, tmp_len, TRUE, hash, rng,
+                           silc_auth_public_key_auth_generate_cb, a);
 
   memset(tmp, 0, tmp_len);
   silc_sfree(stack, tmp);
 
   memset(tmp, 0, tmp_len);
   silc_sfree(stack, tmp);
@@ -408,9 +408,9 @@ silc_auth_public_key_auth_verify(SilcAuthPayload payload,
   }
 
   /* Verify the authentication data */
   }
 
   /* Verify the authentication data */
-  op = silc_pkcs_verify(public_key, payload->auth_data,
-                       payload->auth_len, tmp, tmp_len, hash,
-                       result, context);
+  op = silc_pkcs_verify_async(public_key, payload->auth_data,
+                             payload->auth_len, tmp, tmp_len, TRUE, hash,
+                             result, context);
 
   memset(tmp, 0, tmp_len);
   silc_sfree(payload->stack, tmp);
 
   memset(tmp, 0, tmp_len);
   silc_sfree(payload->stack, tmp);
index 5a61c9b3f06bab1c9068491e70ed626807bb816a..a8d4512a04d1d6710219ac2da7f83fd26048ba8d 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 - 2007 Pekka Riikonen
+  Copyright (C) 2001 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 #ifndef SILCAUTH_H
 #define SILCAUTH_H
 
 #ifndef SILCAUTH_H
 #define SILCAUTH_H
 
+#define SILC_DEFAULT_HMAC "hmac-sha1-96"
+#define SILC_DEFAULT_HASH "sha1"
+#define SILC_DEFAULT_PKCS "rsa"
+#define SILC_DEFAULT_CIPHER "aes-256-cbc"
+
 /****d* silccore/SilcAuthAPI/SilcAuthMethod
  *
  * NAME
 /****d* silccore/SilcAuthAPI/SilcAuthMethod
  *
  * NAME
index ec0dbf9c032e4f463878d948f68569795a503939..b1e3894d9179ac104e253f0c1851803eb8dd78e4 100644 (file)
@@ -335,9 +335,9 @@ silc_message_signed_payload_encode(SilcBuffer payload,
   }
 
   /* Compute signature */
   }
 
   /* Compute signature */
-  op = silc_pkcs_sign(private_key, sign->data, silc_buffer_len(sign),
-                     TRUE, hash, rng,
-                     silc_message_signed_payload_encode_cb, e);
+  op = silc_pkcs_sign_async(private_key, sign->data, silc_buffer_len(sign),
+                           TRUE, hash, rng,
+                           silc_message_signed_payload_encode_cb, e);
 
   return op;
 }
 
   return op;
 }
@@ -876,9 +876,10 @@ silc_message_signed_verify(SilcMessagePayload message,
   }
 
   /* Verify the authentication data */
   }
 
   /* Verify the authentication data */
-  op = silc_pkcs_verify(remote_public_key, sig->sign_data, sig->sign_len,
-                       silc_buffer_data(sign), silc_buffer_len(sign),
-                       hash, result, context);
+  op = silc_pkcs_verify_async(remote_public_key, sig->sign_data,
+                             sig->sign_len,
+                             silc_buffer_data(sign), silc_buffer_len(sign),
+                             TRUE, hash, result, context);
 
   silc_buffer_clear(sign);
   silc_buffer_sfree(stack, sign);
 
   silc_buffer_clear(sign);
   silc_buffer_sfree(stack, sign);
index c111c9da8848b127379f10e61d1a9bc07a802901..afa2d2291c36d259dd55b081445e6649d24b9b26 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 - 2007 Pekka Riikonen
+  Copyright (C) 2001 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -575,7 +575,7 @@ void memfs_open(void *context, SilcSFTP sftp,
                           (attrs->flags & SILC_SFTP_ATTR_PERMISSIONS ?
                            attrs->permissions : 0600));
   if (fd == -1) {
                           (attrs->flags & SILC_SFTP_ATTR_PERMISSIONS ?
                            attrs->permissions : 0600));
   if (fd == -1) {
-    (*callback)(sftp, silc_sftp_map_errno(errno), NULL, callback_context);
+    (*callback)(sftp, silc_sftp_map_errno(silc_errno), NULL, callback_context);
     return;
   }
 
     return;
   }
 
@@ -601,7 +601,7 @@ void memfs_close(void *context, SilcSFTP sftp,
   if (h->fd != -1) {
     ret = silc_file_close(h->fd);
     if (ret == -1) {
   if (h->fd != -1) {
     ret = silc_file_close(h->fd);
     if (ret == -1) {
-      (*callback)(sftp, silc_sftp_map_errno(errno), NULL, NULL,
+      (*callback)(sftp, silc_sftp_map_errno(silc_errno), NULL, NULL,
                  callback_context);
       return;
     }
                  callback_context);
       return;
     }
@@ -630,7 +630,8 @@ void memfs_read(void *context, SilcSFTP sftp,
     if (!ret)
       (*callback)(sftp, SILC_SFTP_STATUS_EOF, NULL, 0, callback_context);
     else
     if (!ret)
       (*callback)(sftp, SILC_SFTP_STATUS_EOF, NULL, 0, callback_context);
     else
-      (*callback)(sftp, silc_sftp_map_errno(errno), NULL, 0, callback_context);
+      (*callback)(sftp, silc_sftp_map_errno(silc_errno),
+                 NULL, 0, callback_context);
     return;
   }
 
     return;
   }
 
@@ -640,7 +641,8 @@ void memfs_read(void *context, SilcSFTP sftp,
     if (!ret)
       (*callback)(sftp, SILC_SFTP_STATUS_EOF, NULL, 0, callback_context);
     else
     if (!ret)
       (*callback)(sftp, SILC_SFTP_STATUS_EOF, NULL, 0, callback_context);
     else
-      (*callback)(sftp, silc_sftp_map_errno(errno), NULL, 0, callback_context);
+      (*callback)(sftp, silc_sftp_map_errno(silc_errno),
+                 NULL, 0, callback_context);
     return;
   }
 
     return;
   }
 
@@ -665,7 +667,7 @@ void memfs_write(void *context, SilcSFTP sftp,
   /* Attempt to write */
   ret = silc_file_write(h->fd, data, data_len);
   if (ret <= 0) {
   /* Attempt to write */
   ret = silc_file_write(h->fd, data, data_len);
   if (ret <= 0) {
-    (*callback)(sftp, silc_sftp_map_errno(errno), NULL, NULL,
+    (*callback)(sftp, silc_sftp_map_errno(silc_errno), NULL, NULL,
                callback_context);
     return;
   }
                callback_context);
     return;
   }
@@ -769,7 +771,7 @@ void memfs_readdir(void *context, SilcSFTP sftp,
   char long_name[256];
   SilcUInt64 filesize = 0;
   char *date;
   char long_name[256];
   SilcUInt64 filesize = 0;
   char *date;
-  struct stat stats;
+  SilcFileStatStruct stats;
 
   if (!h->entry->directory) {
     (*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
 
   if (!h->entry->directory) {
     (*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
@@ -803,8 +805,7 @@ void memfs_readdir(void *context, SilcSFTP sftp,
 
     if (!entry->directory) {
       filesize = silc_file_size(entry->data + 7);
 
     if (!entry->directory) {
       filesize = silc_file_size(entry->data + 7);
-      memset(&stats, 0, sizeof(stats));
-      stat(entry->data + 7, &stats);
+      silc_file_stat(entry->data + 7, TRUE, &stats);
     }
 
     /* Long name format is:
     }
 
     /* Long name format is:
@@ -839,8 +840,8 @@ void memfs_readdir(void *context, SilcSFTP sftp,
     attrs->gid = 0;
     if (!entry->directory) {
       attrs->flags |= SILC_SFTP_ATTR_ACMODTIME;
     attrs->gid = 0;
     if (!entry->directory) {
       attrs->flags |= SILC_SFTP_ATTR_ACMODTIME;
-      attrs->atime = stats.st_atime;
-      attrs->mtime = stats.st_mtime;
+      attrs->atime = silc_time_epoch(&stats.last_access);
+      attrs->mtime = silc_time_epoch(&stats.last_mod);
     }
 
     /* Add the name */
     }
 
     /* Add the name */
@@ -875,8 +876,7 @@ void memfs_stat(void *context, SilcSFTP sftp,
   MemFS fs = (MemFS)context;
   MemFSEntry entry;
   SilcSFTPAttributes attrs;
   MemFS fs = (MemFS)context;
   MemFSEntry entry;
   SilcSFTPAttributes attrs;
-  int ret;
-  struct stat stats;
+  SilcFileStatStruct stats;
 
   if (!path || !strlen(path))
     path = (const char *)DIR_SEPARATOR;
 
   if (!path || !strlen(path))
     path = (const char *)DIR_SEPARATOR;
@@ -894,9 +894,8 @@ void memfs_stat(void *context, SilcSFTP sftp,
   }
 
   /* Get real stat */
   }
 
   /* Get real stat */
-  ret = stat(entry->data + 7, &stats);
-  if (ret == -1) {
-    (*callback)(sftp, silc_sftp_map_errno(errno), NULL, callback_context);
+  if (!silc_file_stat(entry->data + 7, TRUE, &stats)) {
+    (*callback)(sftp, silc_sftp_map_errno(silc_errno), NULL, callback_context);
     return;
   }
 
     return;
   }
 
@@ -908,11 +907,11 @@ void memfs_stat(void *context, SilcSFTP sftp,
   attrs->flags = (SILC_SFTP_ATTR_SIZE |
                  SILC_SFTP_ATTR_UIDGID |
                  SILC_SFTP_ATTR_ACMODTIME);
   attrs->flags = (SILC_SFTP_ATTR_SIZE |
                  SILC_SFTP_ATTR_UIDGID |
                  SILC_SFTP_ATTR_ACMODTIME);
-  attrs->size = stats.st_size;
+  attrs->size = stats.size;
   attrs->uid = 0;                  /* We use always 0 UID and GID */
   attrs->gid = 0;
   attrs->uid = 0;                  /* We use always 0 UID and GID */
   attrs->gid = 0;
-  attrs->atime = stats.st_atime;
-  attrs->mtime = stats.st_mtime;
+  attrs->atime = silc_time_epoch(&stats.last_access);
+  attrs->mtime = silc_time_epoch(&stats.last_mod);
 
   /* Return attributes */
   (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
 
   /* Return attributes */
   (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
@@ -929,8 +928,7 @@ void memfs_lstat(void *context, SilcSFTP sftp,
   MemFS fs = (MemFS)context;
   MemFSEntry entry;
   SilcSFTPAttributes attrs;
   MemFS fs = (MemFS)context;
   MemFSEntry entry;
   SilcSFTPAttributes attrs;
-  int ret;
-  struct stat stats;
+  SilcFileStatStruct stats;
 
   if (!path || !strlen(path))
     path = (const char *)DIR_SEPARATOR;
 
   if (!path || !strlen(path))
     path = (const char *)DIR_SEPARATOR;
@@ -948,17 +946,8 @@ void memfs_lstat(void *context, SilcSFTP sftp,
   }
 
   /* Get real stat */
   }
 
   /* Get real stat */
-#ifdef SILC_WIN32
-  ret = stat(entry->data + 7, &stats);
-#endif /* SILC_WIN32 */
-#ifdef SILC_UNIX
-  ret = lstat(entry->data + 7, &stats);
-#endif /* SILC_UNIX */
-#ifdef SILC_SYMBIAN
-  ret = stat(entry->data + 7, &stats);
-#endif /* SILC_SYMBIAN */
-  if (ret == -1) {
-    (*callback)(sftp, silc_sftp_map_errno(errno), NULL, callback_context);
+  if (!silc_file_stat(entry->data + 7, FALSE, &stats)) {
+    (*callback)(sftp, silc_sftp_map_errno(silc_errno), NULL, callback_context);
     return;
   }
 
     return;
   }
 
@@ -970,11 +959,11 @@ void memfs_lstat(void *context, SilcSFTP sftp,
   attrs->flags = (SILC_SFTP_ATTR_SIZE |
                  SILC_SFTP_ATTR_UIDGID |
                  SILC_SFTP_ATTR_ACMODTIME);
   attrs->flags = (SILC_SFTP_ATTR_SIZE |
                  SILC_SFTP_ATTR_UIDGID |
                  SILC_SFTP_ATTR_ACMODTIME);
-  attrs->size = stats.st_size;
+  attrs->size = stats.size;
   attrs->uid = 0;                  /* We use always 0 UID and GID */
   attrs->gid = 0;
   attrs->uid = 0;                  /* We use always 0 UID and GID */
   attrs->gid = 0;
-  attrs->atime = stats.st_atime;
-  attrs->mtime = stats.st_mtime;
+  attrs->atime = silc_time_epoch(&stats.last_access);
+  attrs->mtime = silc_time_epoch(&stats.last_mod);
 
   /* Return attributes */
   (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
 
   /* Return attributes */
   (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
@@ -990,8 +979,7 @@ void memfs_fstat(void *context, SilcSFTP sftp,
 {
   MemFSFileHandle h = (MemFSFileHandle)handle;
   SilcSFTPAttributes attrs;
 {
   MemFSFileHandle h = (MemFSFileHandle)handle;
   SilcSFTPAttributes attrs;
-  int ret;
-  struct stat stats;
+  SilcFileStatStruct stats;
 
   if (h->entry->directory || !h->entry->data) {
     (*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
 
   if (h->entry->directory || !h->entry->data) {
     (*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
@@ -999,9 +987,8 @@ void memfs_fstat(void *context, SilcSFTP sftp,
   }
 
   /* Get real stat */
   }
 
   /* Get real stat */
-  ret = fstat(h->fd, &stats);
-  if (ret == -1) {
-    (*callback)(sftp, silc_sftp_map_errno(errno), NULL, callback_context);
+  if (!silc_file_fstat(h->fd, &stats)) {
+    (*callback)(sftp, silc_sftp_map_errno(silc_errno), NULL, callback_context);
     return;
   }
 
     return;
   }
 
@@ -1013,11 +1000,11 @@ void memfs_fstat(void *context, SilcSFTP sftp,
   attrs->flags = (SILC_SFTP_ATTR_SIZE |
                  SILC_SFTP_ATTR_UIDGID |
                  SILC_SFTP_ATTR_ACMODTIME);
   attrs->flags = (SILC_SFTP_ATTR_SIZE |
                  SILC_SFTP_ATTR_UIDGID |
                  SILC_SFTP_ATTR_ACMODTIME);
-  attrs->size = stats.st_size;
+  attrs->size = stats.size;
   attrs->uid = 0;                  /* We use always 0 UID and GID */
   attrs->gid = 0;
   attrs->uid = 0;                  /* We use always 0 UID and GID */
   attrs->gid = 0;
-  attrs->atime = stats.st_atime;
-  attrs->mtime = stats.st_mtime;
+  attrs->atime = silc_time_epoch(&stats.last_access);
+  attrs->mtime = silc_time_epoch(&stats.last_mod);
 
   /* Return attributes */
   (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
 
   /* Return attributes */
   (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
index 826181856b24dd7ce839de8eee1b8a0700625d38..6ec07bba94c2aec6b414bde5dcaa5cdf8f7f0cfb 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 - 2007 Pekka Riikonen
+  Copyright (C) 2001 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -475,7 +475,7 @@ void silc_sftp_name_free(SilcSFTPName name)
 
 /* Maps errno to SFTP status message. */
 
 
 /* Maps errno to SFTP status message. */
 
-SilcSFTPStatus silc_sftp_map_errno(int err)
+SilcSFTPStatus silc_sftp_map_errno(SilcResult err)
 {
   SilcSFTPStatus ret;
 
 {
   SilcSFTPStatus ret;
 
@@ -483,18 +483,15 @@ SilcSFTPStatus silc_sftp_map_errno(int err)
   case 0:
     ret = SILC_SFTP_STATUS_OK;
     break;
   case 0:
     ret = SILC_SFTP_STATUS_OK;
     break;
-  case ENOENT:
-  case ENOTDIR:
-  case EBADF:
+  case SILC_ERR_NOT_DIRECTORY:
+  case SILC_ERR_NO_SUCH_FILE:
+  case SILC_ERR_BAD_FD:
     ret = SILC_SFTP_STATUS_NO_SUCH_FILE;
     break;
     ret = SILC_SFTP_STATUS_NO_SUCH_FILE;
     break;
-  case EPERM:
-  case EACCES:
-  case EFAULT:
+  case SILC_ERR_PERMISSION_DENIED:
     ret = SILC_SFTP_STATUS_PERMISSION_DENIED;
     break;
     ret = SILC_SFTP_STATUS_PERMISSION_DENIED;
     break;
-  case ENAMETOOLONG:
-  case EINVAL:
+  case SILC_ERR_INVALID_ARGUMENT:
     ret = SILC_SFTP_STATUS_BAD_MESSAGE;
     break;
   default:
     ret = SILC_SFTP_STATUS_BAD_MESSAGE;
     break;
   default:
index fef68ce4720419e5897a232bf9ac31cc4cfc6ccd..fe92bd5850154c9c9d400be881fa1fc325b2f8da 100644 (file)
@@ -1,6 +1,6 @@
 /*
 
 /*
 
-  sftp_util.h 
+  sftp_util.h
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
@@ -64,13 +64,13 @@ typedef SilcUInt32 SilcSFTPPacket;
    buffer. If `packet_buf' is non-NULL then the new packet data is put
    to that buffer instead of allocating new one.  If the new data cannot
    fit to `packet_buf' will be reallocated. */
    buffer. If `packet_buf' is non-NULL then the new packet data is put
    to that buffer instead of allocating new one.  If the new data cannot
    fit to `packet_buf' will be reallocated. */
-SilcBuffer silc_sftp_packet_encode(SilcSFTPPacket packet, 
+SilcBuffer silc_sftp_packet_encode(SilcSFTPPacket packet,
                                   SilcBuffer packet_buf, SilcUInt32 len, ...);
 
 /* Same as silc_sftp_packet_encode but takes the variable argument list
    pointer as argument. */
                                   SilcBuffer packet_buf, SilcUInt32 len, ...);
 
 /* Same as silc_sftp_packet_encode but takes the variable argument list
    pointer as argument. */
-SilcBuffer silc_sftp_packet_encode_vp(SilcSFTPPacket packet, 
-                                     SilcBuffer packet_buf, SilcUInt32 len, 
+SilcBuffer silc_sftp_packet_encode_vp(SilcSFTPPacket packet,
+                                     SilcBuffer packet_buf, SilcUInt32 len,
                                      va_list vp);
 
 /* Decodes the SFTP packet data `data' and return the SFTP packet type.
                                      va_list vp);
 
 /* Decodes the SFTP packet data `data' and return the SFTP packet type.
@@ -95,7 +95,7 @@ void silc_sftp_attr_free(SilcSFTPAttributes attr);
 void silc_sftp_name_add(SilcSFTPName name, const char *short_name,
                        const char *long_name, SilcSFTPAttributes attrs);
 
 void silc_sftp_name_add(SilcSFTPName name, const char *short_name,
                        const char *long_name, SilcSFTPAttributes attrs);
 
-/* Encodes the SilcSFTPName to a buffer and returns the allocated buffer. 
+/* Encodes the SilcSFTPName to a buffer and returns the allocated buffer.
    The caller must free the buffer. */
 SilcBuffer silc_sftp_name_encode(SilcSFTPName name);
 
    The caller must free the buffer. */
 SilcBuffer silc_sftp_name_encode(SilcSFTPName name);
 
@@ -108,6 +108,6 @@ SilcSFTPName silc_sftp_name_decode(SilcUInt32 count, SilcBuffer buffer);
 void silc_sftp_name_free(SilcSFTPName name);
 
 /* Maps errno to SFTP status message. */
 void silc_sftp_name_free(SilcSFTPName name);
 
 /* Maps errno to SFTP status message. */
-SilcSFTPStatus silc_sftp_map_errno(int err);
+SilcSFTPStatus silc_sftp_map_errno(SilcResult err);
 
 #endif /* SFTP_UTIL_H */
 
 #endif /* SFTP_UTIL_H */
index ea3528fa57603ec4cb9c5239b2f13a730733a85c..06161b3344f861a978db95727f1534547897d110 100644 (file)
@@ -146,9 +146,9 @@ silc_connauth_get_signature(SilcConnAuth connauth)
                     SILC_STR_END);
 
   /* Compute signature */
                     SILC_STR_END);
 
   /* Compute signature */
-  op = silc_pkcs_sign(private_key, auth->data, silc_buffer_len(auth),
-                     TRUE, ske->prop->hash, ske->rng,
-                     silc_connauth_get_signature_cb, connauth);
+  op = silc_pkcs_sign_async(private_key, auth->data, silc_buffer_len(auth),
+                           TRUE, ske->prop->hash, ske->rng,
+                           silc_connauth_get_signature_cb, connauth);
 
   silc_buffer_free(auth);
 
 
   silc_buffer_free(auth);
 
@@ -210,9 +210,9 @@ silc_connauth_verify_signature(SilcConnAuth connauth,
                     SILC_STR_END);
 
   /* Verify signature */
                     SILC_STR_END);
 
   /* Verify signature */
-  op = silc_pkcs_verify(pub_key, sign, sign_len, auth->data,
-                       silc_buffer_len(auth), ske->prop->hash,
-                       silc_connauth_verify_signature_cb, connauth);
+  op = silc_pkcs_verify_async(pub_key, sign, sign_len, auth->data,
+                             silc_buffer_len(auth), TRUE, ske->prop->hash,
+                             silc_connauth_verify_signature_cb, connauth);
 
   silc_buffer_free(auth);
 
 
   silc_buffer_free(auth);
 
index b3a151e6eaeb7f8f4a5b947cb3b4e11a731a2614..7331e23513c5c61d82c250bd35ab6bcb475b587d 100644 (file)
@@ -1506,9 +1506,9 @@ SILC_FSM_STATE(silc_ske_st_initiator_phase2)
 
     /* Sign the hash value */
     SILC_FSM_CALL(ske->key_op =
 
     /* Sign the hash value */
     SILC_FSM_CALL(ske->key_op =
-                 silc_pkcs_sign(ske->private_key, hash, hash_len, FALSE,
-                                ske->prop->hash, ske->rng,
-                                silc_ske_initiator_sign_cb, ske));
+                 silc_pkcs_sign_async(ske->private_key, hash, hash_len, FALSE,
+                                      ske->prop->hash, ske->rng,
+                                      silc_ske_initiator_sign_cb, ske));
     /* NOT REACHED */
   }
 
     /* NOT REACHED */
   }
 
@@ -1715,9 +1715,11 @@ SILC_FSM_STATE(silc_ske_st_initiator_phase4)
 
     /* Verify signature */
     SILC_FSM_CALL(ske->key_op =
 
     /* Verify signature */
     SILC_FSM_CALL(ske->key_op =
-                 silc_pkcs_verify(ske->prop->public_key, payload->sign_data,
-                                  payload->sign_len, hash, hash_len, NULL,
-                                  silc_ske_verify_cb, ske));
+                 silc_pkcs_verify_async(ske->prop->public_key,
+                                        payload->sign_data,
+                                        payload->sign_len, hash,
+                                        hash_len, FALSE, NULL,
+                                        silc_ske_verify_cb, ske));
     /* NOT REACHED */
   }
 
     /* NOT REACHED */
   }
 
@@ -2245,11 +2247,11 @@ SILC_FSM_STATE(silc_ske_st_responder_phase4)
 
     /* Verify signature */
     SILC_FSM_CALL(ske->key_op =
 
     /* Verify signature */
     SILC_FSM_CALL(ske->key_op =
-                 silc_pkcs_verify(ske->prop->public_key,
-                                  recv_payload->sign_data,
-                                  recv_payload->sign_len,
-                                  hash, hash_len, NULL,
-                                  silc_ske_verify_cb, ske));
+                 silc_pkcs_verify_async(ske->prop->public_key,
+                                        recv_payload->sign_data,
+                                        recv_payload->sign_len,
+                                        hash, hash_len, FALSE, NULL,
+                                        silc_ske_verify_cb, ske));
     /* NOT REACHED */
   }
 
     /* NOT REACHED */
   }
 
@@ -2343,9 +2345,9 @@ SILC_FSM_STATE(silc_ske_st_responder_phase5)
 
     /* Sign the hash value */
     SILC_FSM_CALL(ske->key_op =
 
     /* Sign the hash value */
     SILC_FSM_CALL(ske->key_op =
-                 silc_pkcs_sign(ske->private_key, hash, hash_len, FALSE,
-                                ske->prop->hash, ske->rng,
-                                silc_ske_responder_sign_cb, ske));
+                 silc_pkcs_sign_async(ske->private_key, hash, hash_len, FALSE,
+                                      ske->prop->hash, ske->rng,
+                                      silc_ske_responder_sign_cb, ske));
     /* NOT REACHED */
   }
 
     /* NOT REACHED */
   }