X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccrypt%2Fsilccipher.c;h=35155c5103379a048a8063340d4aba7892129a0c;hb=a818c5b5411bbc4436d1c5f011236985c96bb787;hp=785cec1f5e07a99e26bc968871c4bae89269d456;hpb=2dc218143c7859f7529396dc121ae08e2fd78da0;p=silc.git diff --git a/lib/silccrypt/silccipher.c b/lib/silccrypt/silccipher.c index 785cec1f..35155c51 100644 --- a/lib/silccrypt/silccipher.c +++ b/lib/silccrypt/silccipher.c @@ -95,6 +95,16 @@ bool silc_cipher_register(SilcCipherObject *cipher) SILC_LOG_DEBUG(("Registering new cipher `%s'", cipher->name)); + /* Check if exists already */ + if (silc_cipher_list) { + SilcCipherObject *entry; + silc_dlist_start(silc_cipher_list); + while ((entry = silc_dlist_get(silc_cipher_list)) != SILC_LIST_END) { + if (!strcmp(entry->name, cipher->name)) + return FALSE; + } + } + new = silc_calloc(1, sizeof(*new)); new->name = strdup(cipher->name); new->block_len = cipher->block_len; @@ -128,6 +138,8 @@ bool silc_cipher_unregister(SilcCipherObject *cipher) while ((entry = silc_dlist_get(silc_cipher_list)) != SILC_LIST_END) { if (cipher == SILC_ALL_CIPHERS || entry == cipher) { silc_dlist_del(silc_cipher_list, entry); + silc_free(entry->name); + silc_free(entry); if (silc_dlist_count(silc_cipher_list) == 0) { silc_dlist_uninit(silc_cipher_list); @@ -241,7 +253,7 @@ char *silc_cipher_get_supported(void) /* Encrypts */ bool silc_cipher_encrypt(SilcCipher cipher, const unsigned char *src, - unsigned char *dst, uint32 len, + unsigned char *dst, SilcUInt32 len, unsigned char *iv) { return cipher->cipher->encrypt(cipher->context, src, dst, len, iv); @@ -250,7 +262,7 @@ bool silc_cipher_encrypt(SilcCipher cipher, const unsigned char *src, /* Decrypts */ bool silc_cipher_decrypt(SilcCipher cipher, const unsigned char *src, - unsigned char *dst, uint32 len, + unsigned char *dst, SilcUInt32 len, unsigned char *iv) { return cipher->cipher->decrypt(cipher->context, src, dst, len, iv); @@ -259,7 +271,7 @@ bool silc_cipher_decrypt(SilcCipher cipher, const unsigned char *src, /* Sets the key for the cipher */ bool silc_cipher_set_key(SilcCipher cipher, const unsigned char *key, - uint32 keylen) + SilcUInt32 keylen) { return cipher->cipher->set_key(cipher->context, key, keylen); } @@ -282,14 +294,14 @@ void silc_cipher_get_iv(SilcCipher cipher, unsigned char *iv) /* Returns the key length of the cipher. */ -uint32 silc_cipher_get_key_len(SilcCipher cipher) +SilcUInt32 silc_cipher_get_key_len(SilcCipher cipher) { return cipher->cipher->key_len; } /* Returns the block size of the cipher. */ -uint32 silc_cipher_get_block_len(SilcCipher cipher) +SilcUInt32 silc_cipher_get_block_len(SilcCipher cipher) { return cipher->cipher->block_len; }