/* Our own convenience getopt. Public Domain. */
#include "silc.h"
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
#if !defined(HAVE_GETOPT) && !defined(HAVE_GETOPT_H)
int opterr = 1;
int optind = 1;
return c;
}
#endif /* !HAVE_GETOPT && !HAVE_GETOPT_H */
-#endif /* !SILC_EPOC */
+#endif /* !SILC_SYMBIAN */
#ifndef GETOPTI_H
#define GETOPTI_H
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
#if !defined(HAVE_GETOPT) && !defined(HAVE_GETOPT_H)
/* Our own convenience getopt. */
extern int opterr;
extern char *optarg;
int getopt(int argc, char * const *argv, const char *optstring);
#endif /* !HAVE_GETOPT && !HAVE_GETOPT_H */
-#endif /* !SILC_EPOC */
+#endif /* !SILC_SYMBIAN */
#endif /* GETOPTI_H */
}
#else
-#define RORc(x, y) ( ((((unsigned long)(x)&0xFFFFFFFFUL)>>(unsignedlong)((y)&31)) | ((unsigned long)(x)<<(unsigned long)(32-((y)&31)))) &0xFFFFFFFFUL)
+#define RORc(x, y) ( ((((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)((y)&31)) | ((unsigned long)(x)<<(unsigned long)(32-((y)&31)))) &0xFFFFFFFFUL)
#endif /* _MSC_VER */
/* Various logical functions */
#define Ch(x,y,z) (z ^ (x & (y ^ z)))
-#define Maj(x,y,z) (((x | y) & z) | (x & y))
+#define Maj(x,y,z) (((x | y) & z) | (x & y))
#define S(x, n) RORc((x),(n))
#define R(x, n) (((x)&0xFFFFFFFFUL)>>(n))
#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22))
/* fill W[16..63] */
for (i = 16; i < 64; i++) {
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
- }
+ }
/* Compress */
#define RND(a,b,c,d,e,f,g,h,i,ki) \
RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],61,0xa4506ceb);
RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],62,0xbef9a3f7);
RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],63,0xc67178f2);
-
-#undef RND
+
+#undef RND
/* feedback */
for (i = 0; i < 8; i++) {
if (md->curlen > block_size)
return FALSE;
- while (inlen > 0) {
+ while (inlen > 0) {
if (md->curlen == 0 && inlen >= block_size) {
if ((err = sha256_compress(md->state, (unsigned char *)in)) != TRUE)
return err;
in += block_size;
inlen -= block_size;
} else {
- n = MIN(inlen, (block_size - md->curlen));
+ n = MIN(inlen, (block_size - md->curlen));
memcpy(md->buf + md->curlen, in, (size_t)n);
md->curlen += n;
in += n;
unsigned char iv[SILC_CIPHER_MAX_IV_SIZE];
};
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
/* Dynamically registered list of ciphers. */
SilcDList silc_cipher_list = NULL;
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
/* Macro to define cipher to cipher list */
#define SILC_CIPHER_API_DEF(name, cipher, keylen, blocklen, ivlen, mode) \
SilcBool silc_cipher_register(const SilcCipherObject *cipher)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcCipherObject *new;
SILC_LOG_DEBUG(("Registering new cipher `%s'", cipher->name));
silc_cipher_list = silc_dlist_init();
silc_dlist_add(silc_cipher_list, new);
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SilcBool silc_cipher_unregister(SilcCipherObject *cipher)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcCipherObject *entry;
SILC_LOG_DEBUG(("Unregistering cipher"));
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return FALSE;
}
SilcBool silc_cipher_register_default(void)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
int i;
for (i = 0; silc_default_ciphers[i].name; i++)
silc_cipher_register(&(silc_default_ciphers[i]));
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SilcBool silc_cipher_unregister_all(void)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcCipherObject *entry;
if (!silc_cipher_list)
if (!silc_cipher_list)
break;
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SILC_LOG_DEBUG(("Allocating new cipher object"));
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
if (silc_cipher_list) {
silc_dlist_start(silc_cipher_list);
while ((entry = silc_dlist_get(silc_cipher_list)) != SILC_LIST_END) {
}
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
if (entry) {
*new_cipher = silc_calloc(1, sizeof(**new_cipher));
SilcBool silc_cipher_is_supported(const unsigned char *name)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcCipherObject *entry;
if (silc_cipher_list) {
if (!strcmp(silc_default_ciphers[i].name, name))
return TRUE;
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return FALSE;
}
char *list = NULL;
int len = 0;
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
if (silc_cipher_list) {
silc_dlist_start(silc_cipher_list);
while ((entry = silc_dlist_get(silc_cipher_list)) != SILC_LIST_END) {
len++;
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
list[len - 1] = 0;
void *context;
};
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
/* List of dynamically registered hash functions. */
SilcDList silc_hash_list = NULL;
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
/* Default hash functions for silc_hash_register_default(). */
const SilcHashObject silc_default_hash[] =
SilcBool silc_hash_register(const SilcHashObject *hash)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcHashObject *new;
SILC_LOG_DEBUG(("Registering new hash function `%s'", hash->name));
silc_hash_list = silc_dlist_init();
silc_dlist_add(silc_hash_list, new);
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SilcBool silc_hash_unregister(SilcHashObject *hash)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcHashObject *entry;
SILC_LOG_DEBUG(("Unregistering hash function"));
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return FALSE;
}
SilcBool silc_hash_register_default(void)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
int i;
for (i = 0; silc_default_hash[i].name; i++)
silc_hash_register(&(silc_default_hash[i]));
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SilcBool silc_hash_unregister_all(void)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcHashObject *entry;
if (!silc_hash_list)
if (!silc_hash_list)
break;
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SILC_LOG_DEBUG(("Allocating new hash object"));
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
if (silc_hash_list) {
silc_dlist_start(silc_hash_list);
while ((entry = silc_dlist_get(silc_hash_list)) != SILC_LIST_END) {
}
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
if (entry) {
*new_hash = silc_calloc(1, sizeof(**new_hash));
SilcBool silc_hash_is_supported(const unsigned char *name)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcHashObject *entry;
if (silc_hash_list) {
if (!strcmp(silc_default_hash[i].name, name))
return TRUE;
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return FALSE;
}
char *list = NULL;
int len = 0;
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
if (silc_hash_list) {
silc_dlist_start(silc_hash_list);
while ((entry = silc_dlist_get(silc_hash_list)) != SILC_LIST_END) {
len++;
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
list[len - 1] = 0;
unsigned int allocated_hash : 1; /* TRUE if the hash was allocated */
};
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
/* List of dynamically registered HMACs. */
SilcDList silc_hmac_list = NULL;
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
/* Default hmacs for silc_hmac_register_default(). */
const SilcHmacObject silc_default_hmacs[] =
SilcBool silc_hmac_register(const SilcHmacObject *hmac)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcHmacObject *new;
SILC_LOG_DEBUG(("Registering new HMAC `%s'", hmac->name));
silc_hmac_list = silc_dlist_init();
silc_dlist_add(silc_hmac_list, new);
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SilcBool silc_hmac_unregister(SilcHmacObject *hmac)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcHmacObject *entry;
SILC_LOG_DEBUG(("Unregistering HMAC"));
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return FALSE;
}
SilcBool silc_hmac_register_default(void)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
int i;
for (i = 0; silc_default_hmacs[i].name; i++)
silc_hmac_register(&(silc_default_hmacs[i]));
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SilcBool silc_hmac_unregister_all(void)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcHmacObject *entry;
if (!silc_hmac_list)
if (!silc_hmac_list)
break;
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
(*new_hmac)->hash = hash;
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
if (silc_hmac_list) {
SilcHmacObject *entry;
silc_dlist_start(silc_hmac_list);
}
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
silc_free(*new_hmac);
*new_hmac = NULL;
SilcBool silc_hmac_is_supported(const char *name)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcHmacObject *entry;
if (!name)
if (!strcmp(silc_default_hmacs[i].name, name))
return TRUE;
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return FALSE;
}
char *list = NULL;
int len = 0;
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
if (silc_hmac_list) {
silc_dlist_start(silc_hmac_list);
while ((entry = silc_dlist_get(silc_hmac_list)) != SILC_LIST_END) {
len++;
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
list[len - 1] = 0;
#include "silcpk_i.h"
#include "silcpkcs1_i.h"
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
/* Dynamically registered list of PKCS. */
SilcDList silc_pkcs_list = NULL;
SilcDList silc_pkcs_alg_list = NULL;
#else
#define SILC_PKCS_LIST TRUE
#define SILC_PKCS_ALG_LIST TRUE
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
/* Static list of PKCS for silc_pkcs_register_default(). */
const SilcPKCSObject silc_default_pkcs[] =
SilcBool silc_pkcs_register(const SilcPKCSObject *pkcs)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcPKCSObject *newpkcs;
SILC_LOG_DEBUG(("Registering new PKCS"));
silc_pkcs_list = silc_dlist_init();
silc_dlist_add(silc_pkcs_list, newpkcs);
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SilcBool silc_pkcs_unregister(SilcPKCSObject *pkcs)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcPKCSObject *entry;
SILC_LOG_DEBUG(("Unregistering PKCS"));
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return FALSE;
}
SilcBool silc_pkcs_algorithm_register(const SilcPKCSAlgorithm *pkcs)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcPKCSAlgorithm *newalg;
SILC_LOG_DEBUG(("Registering new PKCS algorithm %s",
silc_pkcs_alg_list = silc_dlist_init();
silc_dlist_add(silc_pkcs_alg_list, newalg);
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SilcBool silc_pkcs_algorithm_unregister(SilcPKCSAlgorithm *pkcs)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcPKCSAlgorithm*entry;
SILC_LOG_DEBUG(("Unregistering PKCS algorithm"));
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return FALSE;
}
SilcBool silc_pkcs_register_default(void)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
int i;
for (i = 0; silc_default_pkcs[i].type; i++)
for (i = 0; silc_default_pkcs_alg[i].name; i++)
silc_pkcs_algorithm_register(&(silc_default_pkcs_alg[i]));
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
SilcBool silc_pkcs_unregister_all(void)
{
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
SilcPKCSObject *entry;
SilcPKCSAlgorithm *alg;
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return TRUE;
}
char *list = NULL;
int len = 0;
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
if (silc_pkcs_alg_list) {
silc_dlist_start(silc_pkcs_alg_list);
while ((entry = silc_dlist_get(silc_pkcs_alg_list)) != SILC_LIST_END) {
len++;
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
list[len - 1] = 0;
{
SilcPKCSObject *entry;
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
if (silc_pkcs_list) {
silc_dlist_start(silc_pkcs_list);
while ((entry = silc_dlist_get(silc_pkcs_list)) != SILC_LIST_END) {
#else
{
int i;
- for (i = 0; silc_default_pkcs[i].name; i++) {
+ for (i = 0; silc_default_pkcs[i].type; i++) {
entry = (SilcPKCSObject *)&(silc_default_pkcs[i]);
if (entry->type == type)
return (const SilcPKCSObject *)entry;
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return NULL;
}
{
SilcPKCSAlgorithm *entry;
-#ifndef SILC_EPOC
+#ifndef SILC_SYMBIAN
if (silc_pkcs_alg_list) {
silc_dlist_start(silc_pkcs_alg_list);
while ((entry = silc_dlist_get(silc_pkcs_alg_list)) != SILC_LIST_END) {
return (const SilcPKCSAlgorithm *)entry;
}
}
-#endif /* SILC_EPOC */
+#endif /* SILC_SYMBIAN */
return NULL;
}
silc_rng_xor(rng, (r.ru_nsignals << 16), pos++);
silc_rng_xor(rng, (r.ru_nvcsw + r.ru_nivcsw), pos++);
silc_rng_xor(rng, (r.ru_nvcsw ^ r.ru_nivcsw), pos++);
-#endif /* SILC_SYMBIAN */
-#endif
+#endif /* SILC_SYMBIAN */
+#endif /* HAVE_GETRUSAGE */
#ifdef SILC_RNG_DEBUG
SILC_LOG_HEXDUMP(("pool"), rng->pool, sizeof(rng->pool));
}
return p1;
-};
+}
/* initialise the key schedule from the user supplied key */