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 /* 00007 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00008 * SPDX-License-Identifier: Apache-2.0 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00011 * not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00018 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 * 00022 * This file is part of mbed TLS (https://tls.mbed.org) 00023 */ 00024 #ifndef MBEDTLS_AESNI_H 00025 #define MBEDTLS_AESNI_H 00026 00027 #include "aes.h" 00028 00029 #define MBEDTLS_AESNI_AES 0x02000000u 00030 #define MBEDTLS_AESNI_CLMUL 0x00000002u 00031 00032 #if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && \ 00033 ( defined(__amd64__) || defined(__x86_64__) ) && \ 00034 ! defined(MBEDTLS_HAVE_X86_64) 00035 #define MBEDTLS_HAVE_X86_64 00036 #endif 00037 00038 #if defined(MBEDTLS_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 * (MBEDTLS_AESNI_AES or MBEDTLS_AESNI_CLMUL) 00049 * 00050 * \return 1 if CPU has support for the feature, 0 otherwise 00051 */ 00052 int mbedtls_aesni_has_support( unsigned int what ); 00053 00054 /** 00055 * \brief AES-NI AES-ECB block en(de)cryption 00056 * 00057 * \param ctx AES context 00058 * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_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 mbedtls_aesni_crypt_ecb( mbedtls_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 mbedtls_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 mbedtls_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 MBEDTLS_ERR_AES_INVALID_KEY_LENGTH 00101 */ 00102 int mbedtls_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 /* MBEDTLS_HAVE_X86_64 */ 00111 00112 #endif /* MBEDTLS_AESNI_H */
Generated on Tue Jul 12 2022 18:18:24 by
