aes-encblock.c 923 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * AES encrypt_block
  3. *
  4. * Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
  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.
  9. *
  10. * Alternatively, this software may be distributed under the terms of BSD
  11. * license.
  12. *
  13. * See README and COPYING for more details.
  14. */
  15. #include "includes.h"
  16. #include "common.h"
  17. #include "aes.h"
  18. #include "aes_wrap.h"
  19. /**
  20. * aes_128_encrypt_block - Perform one AES 128-bit block operation
  21. * @key: Key for AES
  22. * @in: Input data (16 bytes)
  23. * @out: Output of the AES block operation (16 bytes)
  24. * Returns: 0 on success, -1 on failure
  25. */
  26. int aes_128_encrypt_block(const u8 *key, const u8 *in, u8 *out)
  27. {
  28. void *ctx;
  29. ctx = aes_encrypt_init(key, 16);
  30. if (ctx == NULL)
  31. return -1;
  32. aes_encrypt(ctx, in, out);
  33. aes_encrypt_deinit(ctx);
  34. return 0;
  35. }