/drivers/staging/rtl8192u/ieee80211/crypto_compat.h

https://bitbucket.org/wisechild/galaxy-nexus · C++ Header · 60 lines · 38 code · 10 blank · 12 comment · 7 complexity · dbc86f226320a6d4d51621c5b0d23dbf MD5 · raw file

  1. /*
  2. * Header file to maintain compatibility among different kernel versions.
  3. *
  4. * Copyright (c) 2004-2006 <lawrence_wang@realsil.com.cn>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation. See README and COPYING for
  9. * more details.
  10. */
  11. #include <linux/crypto.h>
  12. static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
  13. struct scatterlist *dst,
  14. struct scatterlist *src,
  15. unsigned int nbytes)
  16. {
  17. BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
  18. return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
  19. }
  20. static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
  21. struct scatterlist *dst,
  22. struct scatterlist *src,
  23. unsigned int nbytes)
  24. {
  25. BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
  26. return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
  27. }
  28. struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
  29. {
  30. struct crypto_tfm *tfm = NULL;
  31. int err;
  32. printk("call crypto_alloc_tfm!!!\n");
  33. do {
  34. struct crypto_alg *alg;
  35. alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
  36. err = PTR_ERR(alg);
  37. if (IS_ERR(alg))
  38. continue;
  39. tfm = __crypto_alloc_tfm(alg, flags);
  40. err = 0;
  41. if (IS_ERR(tfm)) {
  42. crypto_mod_put(alg);
  43. err = PTR_ERR(tfm);
  44. tfm = NULL;
  45. }
  46. } while (err == -EAGAIN && !signal_pending(current));
  47. return tfm;
  48. }
  49. //EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
  50. //EXPORT_SYMBOL_GPL(crypto_free_tfm);