1f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project/* LibTomCrypt, modular cryptographic library -- Tom St Denis
2f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project *
3f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * LibTomCrypt is a library that provides various cryptographic
4f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * algorithms in a highly modular and flexible manner.
5f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project *
6f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * The library is free for all purposes without any express
7f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * guarantee it works.
8f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project *
9f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
10f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project */
11f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project#include "tomcrypt.h"
12f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
13f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project/**
14f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project  @file crypt_unregister_cipher.c
15f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project  Unregister a cipher, Tom St Denis
16f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project*/
17f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
18f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project/**
19f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project  Unregister a cipher from the descriptor table
20f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project  @param cipher   The cipher descriptor to remove
21f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project  @return CRYPT_OK on success
22f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project*/
23f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectint unregister_cipher(const struct ltc_cipher_descriptor *cipher)
24f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project{
25f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project   int x;
26f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
27f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project   LTC_ARGCHK(cipher != NULL);
28f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
29f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project   /* is it already registered? */
30f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project   LTC_MUTEX_LOCK(&ltc_cipher_mutex);
31f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project   for (x = 0; x < TAB_SIZE; x++) {
32f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project       if (XMEMCMP(&cipher_descriptor[x], cipher, sizeof(struct ltc_cipher_descriptor)) == 0) {
33f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project          cipher_descriptor[x].name = NULL;
34f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project          cipher_descriptor[x].ID   = 255;
35f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project          LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
36f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project          return CRYPT_OK;
37f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project       }
38f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project   }
39f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project   LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
40f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project   return CRYPT_ERROR;
41f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project}
42f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project
43f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_unregister_cipher.c,v $ */
44f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project/* $Revision: 1.6 $ */
45f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project/* $Date: 2006/11/01 09:28:17 $ */
46