blob: d6684fc6ca4eb022763cb6a000c1d8d91db4ee66 [file] [log] [blame]
Manuel Pégourié-Gonnard92ac76f2013-12-16 17:12:53 +01001/**
2 * \file aesni.h
3 *
4 * \brief AES-NI for hardware AES acceleration on some Intel processors
5 *
6 * Copyright (C) 2013, Brainspark B.V.
7 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
10 *
11 * All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27#ifndef POLARSSL_AESNI_H
28#define POLARSSL_AESNI_H
29
30#include "aes.h"
31
32#if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && \
33 ( defined(__amd64__) || defined(__x86_64__) ) && \
34 ! defined(POLARSSL_HAVE_X86_64)
35#define POLARSSL_HAVE_X86_64
36#endif
37
38#if defined(POLARSSL_HAVE_X86_64)
39
40/**
Manuel Pégourié-Gonnard5b685652013-12-18 11:45:21 +010041 * \brief AES-NI detection routine
Manuel Pégourié-Gonnard92ac76f2013-12-16 17:12:53 +010042 *
43 * \return 1 if CPU supports AES-NI, 0 otherwise
44 */
45int aesni_supported( void );
46
Manuel Pégourié-Gonnard5b685652013-12-18 11:45:21 +010047/**
48 * \brief AES-NI AES-ECB block en(de)cryption
49 *
50 * \param ctx AES context
51 * \param mode AES_ENCRYPT or AES_DECRYPT
52 * \param input 16-byte input block
53 * \param output 16-byte output block
54 *
55 * \return 0 if success, 1 if operation failed
56 */
57int aesni_crypt_ecb( aes_context *ctx,
58 int mode,
59 const unsigned char input[16],
60 unsigned char output[16] );
61
Manuel Pégourié-Gonnard92ac76f2013-12-16 17:12:53 +010062#endif /* POLARSSL_HAVE_X86_64 */
63
64#endif /* POLARSSL_AESNI_H */