pkcs12_plugin.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2012 Tobias Brunner
  3. * HSR Hochschule fuer Technik Rapperswil
  4. *
  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>.
  9. *
  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
  13. * for more details.
  14. */
  15. #include "pkcs12_plugin.h"
  16. #include <library.h>
  17. #include "pkcs12_decode.h"
  18. typedef struct private_pkcs12_plugin_t private_pkcs12_plugin_t;
  19. /**
  20. * private data of pkcs12_plugin
  21. */
  22. struct private_pkcs12_plugin_t {
  23. /**
  24. * public functions
  25. */
  26. pkcs12_plugin_t public;
  27. };
  28. METHOD(plugin_t, get_name, char*,
  29. private_pkcs12_plugin_t *this)
  30. {
  31. return "pkcs12";
  32. }
  33. METHOD(plugin_t, get_features, int,
  34. private_pkcs12_plugin_t *this, plugin_feature_t *features[])
  35. {
  36. static plugin_feature_t f[] = {
  37. PLUGIN_REGISTER(CONTAINER_DECODE, pkcs12_decode, FALSE),
  38. PLUGIN_PROVIDE(CONTAINER_DECODE, CONTAINER_PKCS12),
  39. PLUGIN_DEPENDS(CONTAINER_DECODE, CONTAINER_PKCS7),
  40. PLUGIN_SDEPEND(CERT_DECODE, CERT_X509),
  41. PLUGIN_SDEPEND(PRIVKEY, KEY_ANY),
  42. PLUGIN_SDEPEND(HASHER, HASH_SHA1),
  43. PLUGIN_SDEPEND(CRYPTER, ENCR_3DES, 24),
  44. PLUGIN_SDEPEND(CRYPTER, ENCR_RC2_CBC, 0),
  45. };
  46. *features = f;
  47. return countof(f);
  48. }
  49. METHOD(plugin_t, destroy, void,
  50. private_pkcs12_plugin_t *this)
  51. {
  52. free(this);
  53. }
  54. /*
  55. * see header file
  56. */
  57. plugin_t *pkcs12_plugin_create()
  58. {
  59. private_pkcs12_plugin_t *this;
  60. INIT(this,
  61. .public = {
  62. .plugin = {
  63. .get_name = _get_name,
  64. .get_features = _get_features,
  65. .destroy = _destroy,
  66. },
  67. },
  68. );
  69. return &this->public.plugin;
  70. }