mbed TLS library
Dependents: HTTPClient-SSL WS_SERVER
aesni.h
00001 /** 00002 * \file aesni.h 00003 * 00004 * \brief AES-NI for hardware AES acceleration on some Intel processors 00005 * 00006 * Copyright (C) 2013, ARM Limited, All Rights Reserved 00007 * 00008 * This file is part of mbed TLS (https://tls.mbed.org) 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License along 00021 * with this program; if not, write to the Free Software Foundation, Inc., 00022 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00023 */ 00024 #ifndef POLARSSL_AESNI_H 00025 #define POLARSSL_AESNI_H 00026 00027 #include "aes.h" 00028 00029 #define POLARSSL_AESNI_AES 0x02000000u 00030 #define POLARSSL_AESNI_CLMUL 0x00000002u 00031 00032 #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && \ 00033 ( defined(__amd64__) || defined(__x86_64__) ) && \ 00034 ! defined(POLARSSL_HAVE_X86_64) 00035 #define POLARSSL_HAVE_X86_64 00036 #endif 00037 00038 #if defined(POLARSSL_HAVE_X86_64) 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /** 00045 * \brief AES-NI features detection routine 00046 * 00047 * \param what The feature to detect 00048 * (POLARSSL_AESNI_AES or POLARSSL_AESNI_CLMUL) 00049 * 00050 * \return 1 if CPU has support for the feature, 0 otherwise 00051 */ 00052 int aesni_supports( unsigned int what ); 00053 00054 /** 00055 * \brief AES-NI AES-ECB block en(de)cryption 00056 * 00057 * \param ctx AES context 00058 * \param mode AES_ENCRYPT or AES_DECRYPT 00059 * \param input 16-byte input block 00060 * \param output 16-byte output block 00061 * 00062 * \return 0 on success (cannot fail) 00063 */ 00064 int aesni_crypt_ecb( aes_context *ctx, 00065 int mode, 00066 const unsigned char input[16], 00067 unsigned char output[16] ); 00068 00069 /** 00070 * \brief GCM multiplication: c = a * b in GF(2^128) 00071 * 00072 * \param c Result 00073 * \param a First operand 00074 * \param b Second operand 00075 * 00076 * \note Both operands and result are bit strings interpreted as 00077 * elements of GF(2^128) as per the GCM spec. 00078 */ 00079 void aesni_gcm_mult( unsigned char c[16], 00080 const unsigned char a[16], 00081 const unsigned char b[16] ); 00082 00083 /** 00084 * \brief Compute decryption round keys from encryption round keys 00085 * 00086 * \param invkey Round keys for the equivalent inverse cipher 00087 * \param fwdkey Original round keys (for encryption) 00088 * \param nr Number of rounds (that is, number of round keys minus one) 00089 */ 00090 void aesni_inverse_key( unsigned char *invkey, 00091 const unsigned char *fwdkey, int nr ); 00092 00093 /** 00094 * \brief Perform key expansion (for encryption) 00095 * 00096 * \param rk Destination buffer where the round keys are written 00097 * \param key Encryption key 00098 * \param bits Key size in bits (must be 128, 192 or 256) 00099 * 00100 * \return 0 if successful, or POLARSSL_ERR_AES_INVALID_KEY_LENGTH 00101 */ 00102 int aesni_setkey_enc( unsigned char *rk, 00103 const unsigned char *key, 00104 size_t bits ); 00105 00106 #ifdef __cplusplus 00107 } 00108 #endif 00109 00110 #endif /* POLARSSL_HAVE_X86_64 */ 00111 00112 #endif /* POLARSSL_AESNI_H */ 00113
Generated on Tue Jul 12 2022 13:50:36 by 1.7.2