padlock-generic.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Cryptographic API.
  3. *
  4. * Support for VIA PadLock hardware crypto engine.
  5. *
  6. * Copyright (c) 2004 Michal Ludvig <michal@logix.cz>
  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; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/types.h>
  16. #include <linux/errno.h>
  17. #include <linux/crypto.h>
  18. #include <asm/byteorder.h>
  19. #include "padlock.h"
  20. static int __init
  21. padlock_init(void)
  22. {
  23. int ret = -ENOSYS;
  24. if (!cpu_has_xcrypt) {
  25. printk(KERN_ERR PFX "VIA PadLock not detected.\n");
  26. return -ENODEV;
  27. }
  28. if (!cpu_has_xcrypt_enabled) {
  29. printk(KERN_ERR PFX "VIA PadLock detected, but not enabled. Hmm, strange...\n");
  30. return -ENODEV;
  31. }
  32. #ifdef CONFIG_CRYPTO_DEV_PADLOCK_AES
  33. if ((ret = padlock_init_aes())) {
  34. printk(KERN_ERR PFX "VIA PadLock AES initialization failed.\n");
  35. return ret;
  36. }
  37. #endif
  38. if (ret == -ENOSYS)
  39. printk(KERN_ERR PFX "Hmm, VIA PadLock was compiled without any algorithm.\n");
  40. return ret;
  41. }
  42. static void __exit
  43. padlock_fini(void)
  44. {
  45. #ifdef CONFIG_CRYPTO_DEV_PADLOCK_AES
  46. padlock_fini_aes();
  47. #endif
  48. }
  49. module_init(padlock_init);
  50. module_exit(padlock_fini);
  51. MODULE_DESCRIPTION("VIA PadLock crypto engine support.");
  52. MODULE_LICENSE("Dual BSD/GPL");
  53. MODULE_AUTHOR("Michal Ludvig");