}
}
- /* Short integer is actually big integer, so handle it correctly */
+ /* Short integer is actually big integer in the BER data, so handle
+ it correctly */
if (type == SILC_ASN1_TAG_SHORT_INTEGER && type == tag)
tag = SILC_ASN1_TAG_INTEGER;
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2003 - 2005 Pekka Riikonen
+ Copyright (C) 2003 - 2006 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
#ifndef SILCBER_H
#define SILCBER_H
+/****d* silcasn1/SilcBerAPI/SilcBerClass
+ *
+ * NAME
+ *
+ * typedef enum { ... } SilcBerClass;
+ *
+ * DESCRIPTION
+ *
+ * Defines the BER classes.
+ *
+ */
typedef enum {
SILC_BER_CLASS_UNIVERSAL = 0x00, /* Universal */
SILC_BER_CLASS_APPLICATION = 0x01, /* Application */
SILC_BER_CLASS_CONTEXT = 0x02, /* Context-specific */
SILC_BER_CLASS_PRIVATE = 0x03, /* Private */
} SilcBerClass;
+/***/
+/****d* silcasn1/SilcBerAPI/SilcBerEncoding
+ *
+ * NAME
+ *
+ * typedef enum { ... } SilcBerEncoding;
+ *
+ * DESCRIPTION
+ *
+ * Defines the BER encoding type.
+ *
+ */
typedef enum {
SILC_BER_ENC_PRIMITIVE = 0x00,
SILC_BER_ENC_CONSTRUCTED = 0x01,
} SilcBerEncoding;
+/***/
/****f* silcasn1/SilcBerAPI/silc_ber_encode
*
* SYNOPSIS
*
- * SilcBool silc_ber_encode(SilcBuffer ber, SilcBerClass ber_class,
- * SilcBerEncoding encoding, SilcUInt32 tag,
- * const unsigned char *data, SilcUInt32 data_len,
- * SilcBool indefinite);
+ * SilcBool
+ * silc_ber_encode(SilcBuffer ber, SilcBerClass ber_class,
+ * SilcBerEncoding encoding, SilcUInt32 tag,
+ * const unsigned char *data, SilcUInt32 data_len,
+ * SilcBool indefinite);
*
* DESCRIPTION
*
*
***/
SilcBool silc_ber_encode(SilcBuffer ber, SilcBerClass ber_class,
- SilcBerEncoding encoding, SilcUInt32 tag,
- const unsigned char *data, SilcUInt32 data_len,
- SilcBool indefinite);
+ SilcBerEncoding encoding, SilcUInt32 tag,
+ const unsigned char *data, SilcUInt32 data_len,
+ SilcBool indefinite);
/****f* silcasn1/SilcBerAPI/silc_ber_decode
*
* SYNOPSIS
*
- * SilcBool silc_ber_decode(SilcBuffer ber, SilcBerClass *ber_class,
- * SilcBerEncoding *encoding, SilcUInt32 *tag,
- * const unsigned char **data, SilcUInt32 *data_len,
- * SilcBool *indefinite, SilcUInt32 *identifier_len);
+ * SilcBool
+ * silc_ber_decode(SilcBuffer ber, SilcBerClass *ber_class,
+ * SilcBerEncoding *encoding, SilcUInt32 *tag,
+ * const unsigned char **data, SilcUInt32 *data_len,
+ * SilcBool *indefinite, SilcUInt32 *identifier_len);
*
* DESCRIPTION
*
*
***/
SilcBool silc_ber_decode(SilcBuffer ber, SilcBerClass *ber_class,
- SilcBerEncoding *encoding, SilcUInt32 *tag,
- const unsigned char **data, SilcUInt32 *data_len,
- SilcBool *indefinite, SilcUInt32 *identifier_len);
+ SilcBerEncoding *encoding, SilcUInt32 *tag,
+ const unsigned char **data, SilcUInt32 *data_len,
+ SilcBool *indefinite, SilcUInt32 *identifier_len);
/****f* silcasn1/SilcBerAPI/silc_ber_encoded_len
*
/* Decrypts the Message Payload. The `data' is the actual Message Payload */
SilcBool silc_message_payload_decrypt(unsigned char *data,
- size_t data_len,
- SilcBool private_message,
- SilcBool static_key,
- SilcCipher cipher,
- SilcHmac hmac,
- SilcBool check_mac)
+ size_t data_len,
+ SilcBool private_message,
+ SilcBool static_key,
+ SilcCipher cipher,
+ SilcHmac hmac,
+ SilcBool check_mac)
{
SilcUInt32 mac_len, iv_len = 0, block_len;
SilcUInt16 len, totlen, dlen;
The `true_len' is the data length which is used to create MAC out of. */
SilcBool silc_message_payload_encrypt(unsigned char *data,
- SilcUInt32 data_len,
- SilcUInt32 true_len,
- unsigned char *iv,
- SilcUInt32 iv_len,
- SilcCipher cipher,
- SilcHmac hmac)
+ SilcUInt32 data_len,
+ SilcUInt32 true_len,
+ unsigned char *iv,
+ SilcUInt32 iv_len,
+ SilcCipher cipher,
+ SilcHmac hmac)
{
unsigned char mac[32];
SilcUInt32 mac_len;
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2005 Pekka Riikonen
+ Copyright (C) 1997 - 2006 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
* SYNOPSIS
*
* SilcBool silc_message_payload_decrypt(unsigned char *data,
- * size_t data_len,
- * SilcBool private_message,
- * SilcBool static_key,
- * SilcCipher cipher,
- * SilcHmac hmac,
- * SilcBool check_mac);
+ * size_t data_len,
+ * SilcBool private_message,
+ * SilcBool static_key,
+ * SilcCipher cipher,
+ * SilcHmac hmac,
+ * SilcBool check_mac);
*
* DESCRIPTION
*
*
***/
SilcBool silc_message_payload_decrypt(unsigned char *data,
- size_t data_len,
- SilcBool private_message,
- SilcBool static_key,
- SilcCipher cipher,
- SilcHmac hmac,
- SilcBool check_mac);
+ size_t data_len,
+ SilcBool private_message,
+ SilcBool static_key,
+ SilcCipher cipher,
+ SilcHmac hmac,
+ SilcBool check_mac);
/****f* silccore/SilcMessageAPI/silc_message_payload_parse
*
* SYNOPSIS
*
* SilcBool silc_message_payload_encrypt(unsigned char *data,
- * SilcUInt32 data_len,
- * SilcUInt32 true_len,
- * unsigned char *iv,
- * SilcUInt32 iv_len,
- * SilcCipher cipher,
- * SilcHmac hmac);
+ * SilcUInt32 data_len,
+ * SilcUInt32 true_len,
+ * unsigned char *iv,
+ * SilcUInt32 iv_len,
+ * SilcCipher cipher,
+ * SilcHmac hmac);
*
* DESCRIPTION
*
*
***/
SilcBool silc_message_payload_encrypt(unsigned char *data,
- SilcUInt32 data_len,
- SilcUInt32 true_len,
- unsigned char *iv,
- SilcUInt32 iv_len,
- SilcCipher cipher,
- SilcHmac hmac);
+ SilcUInt32 data_len,
+ SilcUInt32 true_len,
+ unsigned char *iv,
+ SilcUInt32 iv_len,
+ SilcCipher cipher,
+ SilcHmac hmac);
/****f* silccore/SilcMessageAPI/silc_message_payload_encode
*
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2005 Pekka Riikonen
+ Copyright (C) 1997 - 2006 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
/* Encrypts */
SilcBool silc_cipher_encrypt(SilcCipher cipher, const unsigned char *src,
- unsigned char *dst, SilcUInt32 len,
- unsigned char *iv)
+ unsigned char *dst, SilcUInt32 len,
+ unsigned char *iv)
{
#ifdef SILC_DEBUG
assert((len & (cipher->cipher->block_len - 1)) == 0);
/* Decrypts */
SilcBool silc_cipher_decrypt(SilcCipher cipher, const unsigned char *src,
- unsigned char *dst, SilcUInt32 len,
- unsigned char *iv)
+ unsigned char *dst, SilcUInt32 len,
+ unsigned char *iv)
{
#ifdef SILC_DEBUG
/* assert((len & (cipher->cipher->block_len - 1)) == 0); */
/* Sets the key for the cipher */
SilcBool silc_cipher_set_key(SilcCipher cipher, const unsigned char *key,
- SilcUInt32 keylen)
+ SilcUInt32 keylen)
{
return cipher->cipher->set_key(cipher->context, key, keylen);
}
*
* DESCRIPTION
*
- * Returns the key length in bits from the public key.
+ * Returns the key length in bits from the private key.
*
***/
SilcUInt32 silc_pkcs_private_key_get_len(SilcPrivateKey private_key);
* SYNOPSIS
*
* SilcBool silc_pkcs1_encode(SilcPkcs1BlockType bt,
- * const unsigned char *data,
- * SilcUInt32 data_len,
- * unsigned char *dest_data,
- * SilcUInt32 dest_data_size,
- * SilcRng rng);
+ * const unsigned char *data,
+ * SilcUInt32 data_len,
+ * unsigned char *dest_data,
+ * SilcUInt32 dest_data_size,
+ * SilcRng rng);
*
* DESCRIPTION
*
* SYNOPSIS
*
* SilcBool silc_pkcs1_decode(SilcPkcs1BlockType bt,
- * const unsigned char *data,
- * SilcUInt32 data_len,
- * unsigned char *dest_data,
- * SilcUInt32 dest_data_size,
- * SilcUInt32 *dest_len);
+ * const unsigned char *data,
+ * SilcUInt32 data_len,
+ * unsigned char *dest_data,
+ * SilcUInt32 dest_data_size,
+ * SilcUInt32 *dest_len);
*
* DESCRIPTION
*
* if (ret < 0)
* error;
*
+ * // Free the allocated data
+ * silc_buffer_purge(&buffer);
+ *
***/
int silc_buffer_format(SilcBuffer dst, ...);
* returns SILC_FSM_FINISH. This function will be called through
* the scheduler; it will not be called immediately after the state
* function returns SILC_FSM_FINISH, but will be called later.
- * The `fsm' may be freed or uninitialized in this function.
+ * The `fsm' may be freed in this function.
*
***/
typedef void (*SilcFSMDestructor)(SilcFSM fsm, void *fsm_context,
* returns SILC_FSM_FINISH. This function will be called through
* the scheduler; it will not be called immediately after the state
* function returns SILC_FSM_FINISH, but will be called later. The
- * `thread' may be freed or uninitialized in this function.
+ * `thread' may be freed in this function.
*
* NOTES
*
* works with normal FSM threads, but especially with real system threads
* it does not guarantee that the FSM won't continue before the thread has
* actually terminated. Usually this is not a problem, but it can be a
- * problem if the FSM is waiting to be freed or uninitialized. In this
- * case using this macro is strongly recommended.
+ * problem if the FSM is waiting to be freed. In this case using this
+ * macro is strongly recommended.
*
***/
#define SILC_FSM_THREAD_WAIT(thread) \
* Initializes a pre-allocated SilcFSMThread context. This call is
* equivalent to silc_fsm_thread_alloc except that this takes the
* pre-allocated context as argument. The silc_fsm_free must not be
- * called if this was called. Returns TRUE if the initialization is Ok
- * or FALSE if error occurred. If the `real_thread' is TRUE then the
+ * called if this was called. If the `real_thread' is TRUE then the
* thread will actually be executed in real thread, if platform supports
* them.
*
* EXAMPLE
*
* // Signalling example
- * ctx->sema = silc_fsm_sema_alloc(fsm, 0);
+ * ctx->async_sema = silc_fsm_sema_alloc(fsm, 0);
* ...
*
* SILC_FSM_STATE(silc_foo_state)
* SilcBool timedout;
* ...
*
- *
* // Wait here for async call to complete, or 10 seconds for timeout
* SILC_FSM_SEMA_TIMEDWAIT(ctx->async_sema, 10, 0, &timedout);
*