From: Pekka Riikonen Date: Fri, 14 Mar 2008 11:44:27 +0000 (+0200) Subject: Changed SILC code to use new SRT and SCT APIs. X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=1ea936cbf1bb3b19bd55839b904ef59ada84b8b5 Changed SILC code to use new SRT and SCT APIs. --- diff --git a/lib/silcapputil/silcapputil.c b/lib/silcapputil/silcapputil.c index 157cce57..573d4585 100644 --- a/lib/silcapputil/silcapputil.c +++ b/lib/silcapputil/silcapputil.c @@ -984,33 +984,19 @@ char *silc_id_render(void *id, SilcIdType id_type) { 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; - 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)); - 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)); @@ -1021,23 +1007,10 @@ char *silc_id_render(void *id, SilcIdType id_type) 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); @@ -1052,26 +1025,14 @@ char *silc_id_render(void *id, SilcIdType id_type) 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)); - 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)); diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index c27d055e..fa139d2e 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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 @@ -16,7 +16,6 @@ GNU General Public License for more details. */ -/* $Id$ */ #include "silc.h" #include "silcclient.h" diff --git a/lib/silcclient/client_attrs.c b/lib/silcclient/client_attrs.c index b7d0dbde..1947c1fb 100644 --- a/lib/silcclient/client_attrs.c +++ b/lib/silcclient/client_attrs.c @@ -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. */ - 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, diff --git a/lib/silcclient/client_ftp.c b/lib/silcclient/client_ftp.c index a38d03c0..b4e8d46e 100644 --- a/lib/silcclient/client_ftp.c +++ b/lib/silcclient/client_ftp.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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 @@ -16,7 +16,6 @@ GNU General Public License for more details. */ -/* $Id$ */ #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, - strerror(errno)); + silc_errno_string(silc_errno)); 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: " - "%s", strerror(errno)); + "%s", silc_errno_string(silc_errno)); + 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: " - "%s", strerror(errno)); + "%s", silc_errno_string(silc_errno)); + silc_free(session); return SILC_CLIENT_FILE_NO_MEMORY; } diff --git a/lib/silcclient/client_listener.c b/lib/silcclient/client_listener.c index 24ae0c74..3735877c 100644 --- a/lib/silcclient/client_listener.c +++ b/lib/silcclient/client_listener.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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 @@ -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 : - 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); @@ -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 : - 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; diff --git a/lib/silccore/silcauth.c b/lib/silccore/silcauth.c index 72cce5aa..f2c73f0e 100644 --- a/lib/silccore/silcauth.c +++ b/lib/silccore/silcauth.c @@ -370,8 +370,8 @@ silc_auth_public_key_auth_generate_wpub(SilcPublicKey public_key, } /* 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); @@ -408,9 +408,9 @@ silc_auth_public_key_auth_verify(SilcAuthPayload payload, } /* 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); diff --git a/lib/silccore/silcauth.h b/lib/silccore/silcauth.h index 5a61c9b3..a8d4512a 100644 --- a/lib/silccore/silcauth.h +++ b/lib/silccore/silcauth.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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 @@ -37,6 +37,11 @@ #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 diff --git a/lib/silccore/silcmessage.c b/lib/silccore/silcmessage.c index ec0dbf9c..b1e3894d 100644 --- a/lib/silccore/silcmessage.c +++ b/lib/silccore/silcmessage.c @@ -335,9 +335,9 @@ silc_message_signed_payload_encode(SilcBuffer payload, } /* 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; } @@ -876,9 +876,10 @@ silc_message_signed_verify(SilcMessagePayload message, } /* 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); diff --git a/lib/silcsftp/sftp_fs_memory.c b/lib/silcsftp/sftp_fs_memory.c index c111c9da..afa2d229 100644 --- a/lib/silcsftp/sftp_fs_memory.c +++ b/lib/silcsftp/sftp_fs_memory.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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 @@ -575,7 +575,7 @@ void memfs_open(void *context, SilcSFTP sftp, (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; } @@ -601,7 +601,7 @@ void memfs_close(void *context, SilcSFTP sftp, 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; } @@ -630,7 +630,8 @@ void memfs_read(void *context, SilcSFTP sftp, 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; } @@ -640,7 +641,8 @@ void memfs_read(void *context, SilcSFTP sftp, 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; } @@ -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) { - (*callback)(sftp, silc_sftp_map_errno(errno), NULL, NULL, + (*callback)(sftp, silc_sftp_map_errno(silc_errno), NULL, NULL, callback_context); return; } @@ -769,7 +771,7 @@ void memfs_readdir(void *context, SilcSFTP sftp, 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); @@ -803,8 +805,7 @@ void memfs_readdir(void *context, SilcSFTP sftp, 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: @@ -839,8 +840,8 @@ void memfs_readdir(void *context, SilcSFTP sftp, 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 */ @@ -875,8 +876,7 @@ void memfs_stat(void *context, SilcSFTP sftp, MemFS fs = (MemFS)context; MemFSEntry entry; SilcSFTPAttributes attrs; - int ret; - struct stat stats; + SilcFileStatStruct stats; if (!path || !strlen(path)) path = (const char *)DIR_SEPARATOR; @@ -894,9 +894,8 @@ void memfs_stat(void *context, SilcSFTP sftp, } /* 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; } @@ -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->size = stats.st_size; + attrs->size = stats.size; 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, @@ -929,8 +928,7 @@ void memfs_lstat(void *context, SilcSFTP sftp, MemFS fs = (MemFS)context; MemFSEntry entry; SilcSFTPAttributes attrs; - int ret; - struct stat stats; + SilcFileStatStruct stats; if (!path || !strlen(path)) path = (const char *)DIR_SEPARATOR; @@ -948,17 +946,8 @@ void memfs_lstat(void *context, SilcSFTP sftp, } /* 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; } @@ -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->size = stats.st_size; + attrs->size = stats.size; 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, @@ -990,8 +979,7 @@ void memfs_fstat(void *context, SilcSFTP sftp, { 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); @@ -999,9 +987,8 @@ void memfs_fstat(void *context, SilcSFTP sftp, } /* 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; } @@ -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->size = stats.st_size; + attrs->size = stats.size; 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, diff --git a/lib/silcsftp/sftp_util.c b/lib/silcsftp/sftp_util.c index 82618185..6ec07bba 100644 --- a/lib/silcsftp/sftp_util.c +++ b/lib/silcsftp/sftp_util.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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 @@ -475,7 +475,7 @@ 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) { SilcSFTPStatus ret; @@ -483,18 +483,15 @@ SilcSFTPStatus silc_sftp_map_errno(int err) 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; - case EPERM: - case EACCES: - case EFAULT: + case SILC_ERR_PERMISSION_DENIED: ret = SILC_SFTP_STATUS_PERMISSION_DENIED; break; - case ENAMETOOLONG: - case EINVAL: + case SILC_ERR_INVALID_ARGUMENT: ret = SILC_SFTP_STATUS_BAD_MESSAGE; break; default: diff --git a/lib/silcsftp/sftp_util.h b/lib/silcsftp/sftp_util.h index fef68ce4..fe92bd58 100644 --- a/lib/silcsftp/sftp_util.h +++ b/lib/silcsftp/sftp_util.h @@ -1,6 +1,6 @@ /* - sftp_util.h + sftp_util.h Author: Pekka Riikonen @@ -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. */ -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 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. @@ -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); -/* 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); @@ -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. */ -SilcSFTPStatus silc_sftp_map_errno(int err); +SilcSFTPStatus silc_sftp_map_errno(SilcResult err); #endif /* SFTP_UTIL_H */ diff --git a/lib/silcske/silcconnauth.c b/lib/silcske/silcconnauth.c index ea3528fa..06161b33 100644 --- a/lib/silcske/silcconnauth.c +++ b/lib/silcske/silcconnauth.c @@ -146,9 +146,9 @@ silc_connauth_get_signature(SilcConnAuth connauth) 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); @@ -210,9 +210,9 @@ silc_connauth_verify_signature(SilcConnAuth connauth, 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); diff --git a/lib/silcske/silcske.c b/lib/silcske/silcske.c index b3a151e6..7331e235 100644 --- a/lib/silcske/silcske.c +++ b/lib/silcske/silcske.c @@ -1506,9 +1506,9 @@ SILC_FSM_STATE(silc_ske_st_initiator_phase2) /* 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 */ } @@ -1715,9 +1715,11 @@ SILC_FSM_STATE(silc_ske_st_initiator_phase4) /* 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 */ } @@ -2245,11 +2247,11 @@ SILC_FSM_STATE(silc_ske_st_responder_phase4) /* 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 */ } @@ -2343,9 +2345,9 @@ SILC_FSM_STATE(silc_ske_st_responder_phase5) /* 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 */ }