From 79b15475e4528a387a94af651738fafc94cd4d55 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 8 Jul 2007 17:29:58 +0000 Subject: [PATCH] Added SilcStack support. PKCS API was changed asynchronous. --- lib/silccore/silcpubkey.c | 27 ++++++++++++++------------- lib/silccore/silcpubkey.h | 12 +++++++++--- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/lib/silccore/silcpubkey.c b/lib/silccore/silcpubkey.c index f0e20e2e..8a880e70 100644 --- a/lib/silccore/silcpubkey.c +++ b/lib/silccore/silcpubkey.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 Pekka Riikonen + Copyright (C) 2005 - 2007 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 @@ -21,7 +21,8 @@ /* Encodes Public Key Payload for transmitting public keys and certificates. */ -SilcBuffer silc_public_key_payload_encode(SilcPublicKey public_key) +SilcBuffer silc_public_key_payload_encode(SilcStack stack, + SilcPublicKey public_key) { SilcBuffer buffer; unsigned char *pk; @@ -32,27 +33,27 @@ SilcBuffer silc_public_key_payload_encode(SilcPublicKey public_key) return NULL; type = silc_pkcs_get_type(public_key); - pk = silc_pkcs_public_key_encode(public_key, &pk_len); + pk = silc_pkcs_public_key_encode(stack, public_key, &pk_len); if (!pk) return NULL; - buffer = silc_buffer_alloc_size(4 + pk_len); + buffer = silc_buffer_salloc_size(stack, 4 + pk_len); if (!buffer) { - silc_free(pk); + silc_sfree(stack, pk); return NULL; } - if (silc_buffer_format(buffer, - SILC_STR_UI_SHORT(pk_len), - SILC_STR_UI_SHORT(type), - SILC_STR_DATA(pk, pk_len), - SILC_STR_END) < 0) { - silc_buffer_free(buffer); - silc_free(pk); + if (silc_buffer_sformat(stack, buffer, + SILC_STR_UI_SHORT(pk_len), + SILC_STR_UI_SHORT(type), + SILC_STR_DATA(pk, pk_len), + SILC_STR_END) < 0) { + silc_buffer_sfree(stack, buffer); + silc_sfree(stack, pk); return NULL; } - silc_free(pk); + silc_sfree(stack, pk); return buffer; } diff --git a/lib/silccore/silcpubkey.h b/lib/silccore/silcpubkey.h index 4bf004b9..510c0472 100644 --- a/lib/silccore/silcpubkey.h +++ b/lib/silccore/silcpubkey.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 Pekka Riikonen + Copyright (C) 2005 - 2007 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 @@ -34,7 +34,8 @@ * * SYNOPSIS * - * SilcBool silc_public_key_payload_encode(SilcPublicKey public_key); + * SilcBuffer silc_public_key_payload_encode(SilcStack stack, + * SilcPublicKey public_key); * * DESCRIPTION * @@ -42,8 +43,13 @@ * `public_key'. Returns the allocated and encoded payload buffer, * or NULL on error. * + * If `stack' is non-NULL the returned buffer is allocated from `stack'. + * This call will consume the `stack' so caller should push the stack + * before calling and then later pop it. + * ***/ -SilcBuffer silc_public_key_payload_encode(SilcPublicKey public_key); +SilcBuffer silc_public_key_payload_encode(SilcStack stack, + SilcPublicKey public_key); /****f* silccore/SilcPubKeyAPI/silc_public_key_payload_decode * -- 2.24.0