aes.c 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * \file aes.c
  3. *
  4. * AES Interface file for the Open AES-CCM block.
  5. *
  6. */
  7. /*
  8. * Copyright (C) 2013. Mindtree Limited.
  9. * All rights reserved.
  10. */
  11. /* --------------------------------------------- Header File Inclusion */
  12. #include "aes.h"
  13. #include "cry.h"
  14. /* --------------------------------------------- External Global Variables */
  15. /* --------------------------------------------- Exported Global Variables */
  16. /* --------------------------------------------- Static Global Variables */
  17. /* --------------------------------------------- Functions */
  18. void * aes_encrypt_init(const u8 *key, size_t len)
  19. {
  20. u8 *ctx;
  21. ctx = EM_alloc_mem (len);
  22. if (NULL != ctx)
  23. {
  24. memcpy (ctx, key, len);
  25. }
  26. return (void *)ctx;
  27. }
  28. void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt)
  29. {
  30. INT32 ret;
  31. cry_aes_128_encrypt_be ((UCHAR *)plain, (UCHAR *)ctx, (UCHAR *)crypt, ret);
  32. VOID ret; // resolve warning
  33. }
  34. void aes_encrypt_deinit(void *ctx)
  35. {
  36. EM_free_mem (ctx);
  37. }