mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 11:cada08fc8a70 1 /**
mbedAustin 11:cada08fc8a70 2 * \file aesni.h
mbedAustin 11:cada08fc8a70 3 *
mbedAustin 11:cada08fc8a70 4 * \brief AES-NI for hardware AES acceleration on some Intel processors
mbedAustin 11:cada08fc8a70 5 *
mbedAustin 11:cada08fc8a70 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
mbedAustin 11:cada08fc8a70 7 * SPDX-License-Identifier: Apache-2.0
mbedAustin 11:cada08fc8a70 8 *
mbedAustin 11:cada08fc8a70 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
mbedAustin 11:cada08fc8a70 10 * not use this file except in compliance with the License.
mbedAustin 11:cada08fc8a70 11 * You may obtain a copy of the License at
mbedAustin 11:cada08fc8a70 12 *
mbedAustin 11:cada08fc8a70 13 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 11:cada08fc8a70 14 *
mbedAustin 11:cada08fc8a70 15 * Unless required by applicable law or agreed to in writing, software
mbedAustin 11:cada08fc8a70 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
mbedAustin 11:cada08fc8a70 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 11:cada08fc8a70 18 * See the License for the specific language governing permissions and
mbedAustin 11:cada08fc8a70 19 * limitations under the License.
mbedAustin 11:cada08fc8a70 20 *
mbedAustin 11:cada08fc8a70 21 * This file is part of mbed TLS (https://tls.mbed.org)
mbedAustin 11:cada08fc8a70 22 */
mbedAustin 11:cada08fc8a70 23 #ifndef MBEDTLS_AESNI_H
mbedAustin 11:cada08fc8a70 24 #define MBEDTLS_AESNI_H
mbedAustin 11:cada08fc8a70 25
mbedAustin 11:cada08fc8a70 26 #include "aes.h"
mbedAustin 11:cada08fc8a70 27
mbedAustin 11:cada08fc8a70 28 #define MBEDTLS_AESNI_AES 0x02000000u
mbedAustin 11:cada08fc8a70 29 #define MBEDTLS_AESNI_CLMUL 0x00000002u
mbedAustin 11:cada08fc8a70 30
mbedAustin 11:cada08fc8a70 31 #if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && \
mbedAustin 11:cada08fc8a70 32 ( defined(__amd64__) || defined(__x86_64__) ) && \
mbedAustin 11:cada08fc8a70 33 ! defined(MBEDTLS_HAVE_X86_64)
mbedAustin 11:cada08fc8a70 34 #define MBEDTLS_HAVE_X86_64
mbedAustin 11:cada08fc8a70 35 #endif
mbedAustin 11:cada08fc8a70 36
mbedAustin 11:cada08fc8a70 37 #if defined(MBEDTLS_HAVE_X86_64)
mbedAustin 11:cada08fc8a70 38
mbedAustin 11:cada08fc8a70 39 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 40 extern "C" {
mbedAustin 11:cada08fc8a70 41 #endif
mbedAustin 11:cada08fc8a70 42
mbedAustin 11:cada08fc8a70 43 /**
mbedAustin 11:cada08fc8a70 44 * \brief AES-NI features detection routine
mbedAustin 11:cada08fc8a70 45 *
mbedAustin 11:cada08fc8a70 46 * \param what The feature to detect
mbedAustin 11:cada08fc8a70 47 * (MBEDTLS_AESNI_AES or MBEDTLS_AESNI_CLMUL)
mbedAustin 11:cada08fc8a70 48 *
mbedAustin 11:cada08fc8a70 49 * \return 1 if CPU has support for the feature, 0 otherwise
mbedAustin 11:cada08fc8a70 50 */
mbedAustin 11:cada08fc8a70 51 int mbedtls_aesni_has_support( unsigned int what );
mbedAustin 11:cada08fc8a70 52
mbedAustin 11:cada08fc8a70 53 /**
mbedAustin 11:cada08fc8a70 54 * \brief AES-NI AES-ECB block en(de)cryption
mbedAustin 11:cada08fc8a70 55 *
mbedAustin 11:cada08fc8a70 56 * \param ctx AES context
mbedAustin 11:cada08fc8a70 57 * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
mbedAustin 11:cada08fc8a70 58 * \param input 16-byte input block
mbedAustin 11:cada08fc8a70 59 * \param output 16-byte output block
mbedAustin 11:cada08fc8a70 60 *
mbedAustin 11:cada08fc8a70 61 * \return 0 on success (cannot fail)
mbedAustin 11:cada08fc8a70 62 */
mbedAustin 11:cada08fc8a70 63 int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx,
mbedAustin 11:cada08fc8a70 64 int mode,
mbedAustin 11:cada08fc8a70 65 const unsigned char input[16],
mbedAustin 11:cada08fc8a70 66 unsigned char output[16] );
mbedAustin 11:cada08fc8a70 67
mbedAustin 11:cada08fc8a70 68 /**
mbedAustin 11:cada08fc8a70 69 * \brief GCM multiplication: c = a * b in GF(2^128)
mbedAustin 11:cada08fc8a70 70 *
mbedAustin 11:cada08fc8a70 71 * \param c Result
mbedAustin 11:cada08fc8a70 72 * \param a First operand
mbedAustin 11:cada08fc8a70 73 * \param b Second operand
mbedAustin 11:cada08fc8a70 74 *
mbedAustin 11:cada08fc8a70 75 * \note Both operands and result are bit strings interpreted as
mbedAustin 11:cada08fc8a70 76 * elements of GF(2^128) as per the GCM spec.
mbedAustin 11:cada08fc8a70 77 */
mbedAustin 11:cada08fc8a70 78 void mbedtls_aesni_gcm_mult( unsigned char c[16],
mbedAustin 11:cada08fc8a70 79 const unsigned char a[16],
mbedAustin 11:cada08fc8a70 80 const unsigned char b[16] );
mbedAustin 11:cada08fc8a70 81
mbedAustin 11:cada08fc8a70 82 /**
mbedAustin 11:cada08fc8a70 83 * \brief Compute decryption round keys from encryption round keys
mbedAustin 11:cada08fc8a70 84 *
mbedAustin 11:cada08fc8a70 85 * \param invkey Round keys for the equivalent inverse cipher
mbedAustin 11:cada08fc8a70 86 * \param fwdkey Original round keys (for encryption)
mbedAustin 11:cada08fc8a70 87 * \param nr Number of rounds (that is, number of round keys minus one)
mbedAustin 11:cada08fc8a70 88 */
mbedAustin 11:cada08fc8a70 89 void mbedtls_aesni_inverse_key( unsigned char *invkey,
mbedAustin 11:cada08fc8a70 90 const unsigned char *fwdkey, int nr );
mbedAustin 11:cada08fc8a70 91
mbedAustin 11:cada08fc8a70 92 /**
mbedAustin 11:cada08fc8a70 93 * \brief Perform key expansion (for encryption)
mbedAustin 11:cada08fc8a70 94 *
mbedAustin 11:cada08fc8a70 95 * \param rk Destination buffer where the round keys are written
mbedAustin 11:cada08fc8a70 96 * \param key Encryption key
mbedAustin 11:cada08fc8a70 97 * \param bits Key size in bits (must be 128, 192 or 256)
mbedAustin 11:cada08fc8a70 98 *
mbedAustin 11:cada08fc8a70 99 * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
mbedAustin 11:cada08fc8a70 100 */
mbedAustin 11:cada08fc8a70 101 int mbedtls_aesni_setkey_enc( unsigned char *rk,
mbedAustin 11:cada08fc8a70 102 const unsigned char *key,
mbedAustin 11:cada08fc8a70 103 size_t bits );
mbedAustin 11:cada08fc8a70 104
mbedAustin 11:cada08fc8a70 105 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 106 }
mbedAustin 11:cada08fc8a70 107 #endif
mbedAustin 11:cada08fc8a70 108
mbedAustin 11:cada08fc8a70 109 #endif /* MBEDTLS_HAVE_X86_64 */
mbedAustin 11:cada08fc8a70 110
mbedAustin 11:cada08fc8a70 111 #endif /* MBEDTLS_AESNI_H */