pcompress.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Cryptographic API.
  3. *
  4. * Partial (de)compression operations.
  5. *
  6. * Copyright 2008 Sony Corporation
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program.
  19. * If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <linux/crypto.h>
  22. #include <linux/errno.h>
  23. #include <linux/module.h>
  24. #include <linux/seq_file.h>
  25. #include <linux/string.h>
  26. #include <crypto/compress.h>
  27. #include <crypto/internal/compress.h>
  28. #include "internal.h"
  29. static int crypto_pcomp_init(struct crypto_tfm *tfm, u32 type, u32 mask)
  30. {
  31. return 0;
  32. }
  33. static unsigned int crypto_pcomp_extsize(struct crypto_alg *alg,
  34. const struct crypto_type *frontend)
  35. {
  36. return alg->cra_ctxsize;
  37. }
  38. static int crypto_pcomp_init_tfm(struct crypto_tfm *tfm,
  39. const struct crypto_type *frontend)
  40. {
  41. return 0;
  42. }
  43. static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg)
  44. __attribute__ ((unused));
  45. static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg)
  46. {
  47. seq_printf(m, "type : pcomp\n");
  48. }
  49. static const struct crypto_type crypto_pcomp_type = {
  50. .extsize = crypto_pcomp_extsize,
  51. .init = crypto_pcomp_init,
  52. .init_tfm = crypto_pcomp_init_tfm,
  53. #ifdef CONFIG_PROC_FS
  54. .show = crypto_pcomp_show,
  55. #endif
  56. .maskclear = ~CRYPTO_ALG_TYPE_MASK,
  57. .maskset = CRYPTO_ALG_TYPE_MASK,
  58. .type = CRYPTO_ALG_TYPE_PCOMPRESS,
  59. .tfmsize = offsetof(struct crypto_pcomp, base),
  60. };
  61. struct crypto_pcomp *crypto_alloc_pcomp(const char *alg_name, u32 type,
  62. u32 mask)
  63. {
  64. return crypto_alloc_tfm(alg_name, &crypto_pcomp_type, type, mask);
  65. }
  66. EXPORT_SYMBOL_GPL(crypto_alloc_pcomp);
  67. int crypto_register_pcomp(struct pcomp_alg *alg)
  68. {
  69. struct crypto_alg *base = &alg->base;
  70. base->cra_type = &crypto_pcomp_type;
  71. base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
  72. base->cra_flags |= CRYPTO_ALG_TYPE_PCOMPRESS;
  73. return crypto_register_alg(base);
  74. }
  75. EXPORT_SYMBOL_GPL(crypto_register_pcomp);
  76. int crypto_unregister_pcomp(struct pcomp_alg *alg)
  77. {
  78. return crypto_unregister_alg(&alg->base);
  79. }
  80. EXPORT_SYMBOL_GPL(crypto_unregister_pcomp);
  81. MODULE_LICENSE("GPL");
  82. MODULE_DESCRIPTION("Partial (de)compression type");
  83. MODULE_AUTHOR("Sony Corporation");