aes-encblock.c 704 B

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