Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file aes-encblock.c |
| 2 | * AES encrypt_block. */ |
Harald Welte | 781bd5d | 2011-12-06 22:23:52 +0100 | [diff] [blame] | 3 | /* |
Harald Welte | 781bd5d | 2011-12-06 22:23:52 +0100 | [diff] [blame] | 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 | * |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 13 | * SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 14 | * |
Harald Welte | 781bd5d | 2011-12-06 22:23:52 +0100 | [diff] [blame] | 15 | * See README and COPYING for more details. |
| 16 | */ |
| 17 | |
| 18 | #include "includes.h" |
| 19 | |
| 20 | #include "common.h" |
| 21 | #include "aes.h" |
| 22 | #include "aes_wrap.h" |
| 23 | |
| 24 | /** |
| 25 | * aes_128_encrypt_block - Perform one AES 128-bit block operation |
| 26 | * @key: Key for AES |
| 27 | * @in: Input data (16 bytes) |
| 28 | * @out: Output of the AES block operation (16 bytes) |
| 29 | * Returns: 0 on success, -1 on failure |
| 30 | */ |
| 31 | int aes_128_encrypt_block(const u8 *key, const u8 *in, u8 *out) |
| 32 | { |
| 33 | void *ctx; |
| 34 | ctx = aes_encrypt_init(key, 16); |
| 35 | if (ctx == NULL) |
| 36 | return -1; |
| 37 | aes_encrypt(ctx, in, out); |
| 38 | aes_encrypt_deinit(ctx); |
| 39 | return 0; |
| 40 | } |