1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
12 @file crypt_register_cipher.c
13 Register a cipher, Tom St Denis
17 Register a cipher with the descriptor table
18 @param cipher The cipher you wish to register
19 @return value >= 0 if successfully added (or already present), -1 if unsuccessful
21 int register_cipher(const struct ltc_cipher_descriptor *cipher)
25 LTC_ARGCHK(cipher != NULL);
27 /* is it already registered? */
28 LTC_MUTEX_LOCK(<c_cipher_mutex);
29 for (x = 0; x < TAB_SIZE; x++) {
30 if (cipher_descriptor[x].name != NULL && cipher_descriptor[x].ID == cipher->ID) {
31 LTC_MUTEX_UNLOCK(<c_cipher_mutex);
36 /* find a blank spot */
37 for (x = 0; x < TAB_SIZE; x++) {
38 if (cipher_descriptor[x].name == NULL) {
39 XMEMCPY(&cipher_descriptor[x], cipher, sizeof(struct ltc_cipher_descriptor));
40 LTC_MUTEX_UNLOCK(<c_cipher_mutex);
46 LTC_MUTEX_UNLOCK(<c_cipher_mutex);
50 /* ref: $Format:%D$ */
51 /* git commit: $Format:%H$ */
52 /* commit time: $Format:%ai$ */