blob: 9fd73f673f78e1f6a4bb9f22ea2d3d3692ea65ea [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file aes-encblock.c
2 * AES encrypt_block. */
Harald Welte781bd5d2011-12-06 22:23:52 +01003/*
Harald Welte781bd5d2011-12-06 22:23:52 +01004 * 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 Weltee08da972017-11-13 01:00:26 +090013 * SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
14 *
Harald Welte781bd5d2011-12-06 22:23:52 +010015 * 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 */
31int 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}