2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #include "gcrypt_plugin.h"
18 #include "gcrypt_hasher.h"
27 typedef struct private_gcrypt_plugin_t private_gcrypt_plugin_t
;
30 * private data of gcrypt_plugin
32 struct private_gcrypt_plugin_t
{
37 gcrypt_plugin_t
public;
41 * Thread callback implementations for pthread
43 GCRY_THREAD_OPTION_PTHREAD_IMPL
;
46 * Implementation of gcrypt_plugin_t.destroy
48 static void destroy(private_gcrypt_plugin_t
*this)
50 lib
->crypto
->remove_hasher(lib
->crypto
,
51 (hasher_constructor_t
)gcrypt_hasher_create
);
58 plugin_t
*plugin_create()
60 private_gcrypt_plugin_t
*this;
62 gcry_control(GCRYCTL_SET_THREAD_CBS
, &gcry_threads_pthread
);
64 if (!gcry_check_version(GCRYPT_VERSION
))
66 DBG1("libgcrypt version mismatch");
70 /* we currently do not use secure memory */
71 gcry_control(GCRYCTL_DISABLE_SECMEM
, 0);
72 gcry_control(GCRYCTL_INITIALIZATION_FINISHED
, 0);
74 this = malloc_thing(private_gcrypt_plugin_t
);
76 this->public.plugin
.destroy
= (void(*)(plugin_t
*))destroy
;
79 lib
->crypto
->add_hasher(lib
->crypto
, HASH_SHA1
,
80 (hasher_constructor_t
)gcrypt_hasher_create
);
81 lib
->crypto
->add_hasher(lib
->crypto
, HASH_MD2
,
82 (hasher_constructor_t
)gcrypt_hasher_create
);
83 lib
->crypto
->add_hasher(lib
->crypto
, HASH_MD4
,
84 (hasher_constructor_t
)gcrypt_hasher_create
);
85 lib
->crypto
->add_hasher(lib
->crypto
, HASH_MD5
,
86 (hasher_constructor_t
)gcrypt_hasher_create
);
87 lib
->crypto
->add_hasher(lib
->crypto
, HASH_SHA256
,
88 (hasher_constructor_t
)gcrypt_hasher_create
);
89 lib
->crypto
->add_hasher(lib
->crypto
, HASH_SHA384
,
90 (hasher_constructor_t
)gcrypt_hasher_create
);
91 lib
->crypto
->add_hasher(lib
->crypto
, HASH_SHA512
,
92 (hasher_constructor_t
)gcrypt_hasher_create
);
94 return &this->public.plugin
;