Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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, Brainspark B.V. 00007 * 00008 * This file is part of PolarSSL (http://www.polarssl.org) 00009 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> 00010 * 00011 * All rights reserved. 00012 * 00013 * This program is free software; you can redistribute it and/or modify 00014 * it under the terms of the GNU General Public License as published by 00015 * the Free Software Foundation; either version 2 of the License, or 00016 * (at your option) any later version. 00017 * 00018 * This program is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License along 00024 * with this program; if not, write to the Free Software Foundation, Inc., 00025 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00026 */ 00027 #ifndef POLARSSL_AESNI_H 00028 #define POLARSSL_AESNI_H 00029 00030 #include "aes.h" 00031 00032 #define POLARSSL_AESNI_AES 0x02000000u 00033 #define POLARSSL_AESNI_CLMUL 0x00000002u 00034 00035 #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && \ 00036 ( defined(__amd64__) || defined(__x86_64__) ) && \ 00037 ! defined(POLARSSL_HAVE_X86_64) 00038 #define POLARSSL_HAVE_X86_64 00039 #endif 00040 00041 #if defined(POLARSSL_HAVE_X86_64) 00042 00043 /** 00044 * \brief AES-NI features detection routine 00045 * 00046 * \param what The feature to detect 00047 * (POLARSSL_AESNI_AES or POLARSSL_AESNI_CLMUL) 00048 * 00049 * \return 1 if CPU has support for the feature, 0 otherwise 00050 */ 00051 int aesni_supports( unsigned int what ); 00052 00053 /** 00054 * \brief AES-NI AES-ECB block en(de)cryption 00055 * 00056 * \param ctx AES context 00057 * \param mode AES_ENCRYPT or AES_DECRYPT 00058 * \param input 16-byte input block 00059 * \param output 16-byte output block 00060 * 00061 * \return 0 on success (cannot fail) 00062 */ 00063 int aesni_crypt_ecb( aes_context *ctx, 00064 int mode, 00065 const unsigned char input[16], 00066 unsigned char output[16] ); 00067 00068 /** 00069 * \brief GCM multiplication: c = a * b in GF(2^128) 00070 * 00071 * \param c Result 00072 * \param a First operand 00073 * \param b Second operand 00074 * 00075 * \note Both operands and result are bit strings interpreted as 00076 * elements of GF(2^128) as per the GCM spec. 00077 */ 00078 void aesni_gcm_mult( unsigned char c[16], 00079 const unsigned char a[16], 00080 const unsigned char b[16] ); 00081 00082 /** 00083 * \brief Compute decryption round keys from encryption round keys 00084 * 00085 * \param invkey Round keys for the equivalent inverse cipher 00086 * \param fwdkey Original round keys (for encryption) 00087 * \param nr Number of rounds (that is, number of round keys minus one) 00088 */ 00089 void aesni_inverse_key( unsigned char *invkey, 00090 const unsigned char *fwdkey, int nr ); 00091 00092 /** 00093 * \brief Perform key expansion (for encryption) 00094 * 00095 * \param rk Destination buffer where the round keys are written 00096 * \param key Encryption key 00097 * \param bits Key size in bits (must be 128, 192 or 256) 00098 * 00099 * \return 0 if successful, or POLARSSL_ERR_AES_INVALID_KEY_LENGTH 00100 */ 00101 int aesni_setkey_enc( unsigned char *rk, 00102 const unsigned char *key, 00103 size_t bits ); 00104 00105 #endif /* POLARSSL_HAVE_X86_64 */ 00106 00107 #endif /* POLARSSL_AESNI_H */ 00108 00109
Generated on Tue Jul 12 2022 19:40:15 by
1.7.2