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 padlock.h
mbedAustin 11:cada08fc8a70 3 *
mbedAustin 11:cada08fc8a70 4 * \brief VIA PadLock ACE for HW encryption/decryption supported by some
mbedAustin 11:cada08fc8a70 5 * processors
mbedAustin 11:cada08fc8a70 6 *
mbedAustin 11:cada08fc8a70 7 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
mbedAustin 11:cada08fc8a70 8 * SPDX-License-Identifier: Apache-2.0
mbedAustin 11:cada08fc8a70 9 *
mbedAustin 11:cada08fc8a70 10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
mbedAustin 11:cada08fc8a70 11 * not use this file except in compliance with the License.
mbedAustin 11:cada08fc8a70 12 * You may obtain a copy of the License at
mbedAustin 11:cada08fc8a70 13 *
mbedAustin 11:cada08fc8a70 14 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 11:cada08fc8a70 15 *
mbedAustin 11:cada08fc8a70 16 * Unless required by applicable law or agreed to in writing, software
mbedAustin 11:cada08fc8a70 17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
mbedAustin 11:cada08fc8a70 18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 11:cada08fc8a70 19 * See the License for the specific language governing permissions and
mbedAustin 11:cada08fc8a70 20 * limitations under the License.
mbedAustin 11:cada08fc8a70 21 *
mbedAustin 11:cada08fc8a70 22 * This file is part of mbed TLS (https://tls.mbed.org)
mbedAustin 11:cada08fc8a70 23 */
mbedAustin 11:cada08fc8a70 24 #ifndef MBEDTLS_PADLOCK_H
mbedAustin 11:cada08fc8a70 25 #define MBEDTLS_PADLOCK_H
mbedAustin 11:cada08fc8a70 26
mbedAustin 11:cada08fc8a70 27 #include "aes.h"
mbedAustin 11:cada08fc8a70 28
mbedAustin 11:cada08fc8a70 29 #define MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */
mbedAustin 11:cada08fc8a70 30
mbedAustin 11:cada08fc8a70 31 #if defined(__has_feature)
mbedAustin 11:cada08fc8a70 32 #if __has_feature(address_sanitizer)
mbedAustin 11:cada08fc8a70 33 #define MBEDTLS_HAVE_ASAN
mbedAustin 11:cada08fc8a70 34 #endif
mbedAustin 11:cada08fc8a70 35 #endif
mbedAustin 11:cada08fc8a70 36
mbedAustin 11:cada08fc8a70 37 /* Some versions of ASan result in errors about not enough registers */
mbedAustin 11:cada08fc8a70 38 #if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) && \
mbedAustin 11:cada08fc8a70 39 !defined(MBEDTLS_HAVE_ASAN)
mbedAustin 11:cada08fc8a70 40
mbedAustin 11:cada08fc8a70 41 #ifndef MBEDTLS_HAVE_X86
mbedAustin 11:cada08fc8a70 42 #define MBEDTLS_HAVE_X86
mbedAustin 11:cada08fc8a70 43 #endif
mbedAustin 11:cada08fc8a70 44
mbedAustin 11:cada08fc8a70 45 #include <stdint.h>
mbedAustin 11:cada08fc8a70 46
mbedAustin 11:cada08fc8a70 47 #define MBEDTLS_PADLOCK_RNG 0x000C
mbedAustin 11:cada08fc8a70 48 #define MBEDTLS_PADLOCK_ACE 0x00C0
mbedAustin 11:cada08fc8a70 49 #define MBEDTLS_PADLOCK_PHE 0x0C00
mbedAustin 11:cada08fc8a70 50 #define MBEDTLS_PADLOCK_PMM 0x3000
mbedAustin 11:cada08fc8a70 51
mbedAustin 11:cada08fc8a70 52 #define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) x & ~15))
mbedAustin 11:cada08fc8a70 53
mbedAustin 11:cada08fc8a70 54 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 55 extern "C" {
mbedAustin 11:cada08fc8a70 56 #endif
mbedAustin 11:cada08fc8a70 57
mbedAustin 11:cada08fc8a70 58 /**
mbedAustin 11:cada08fc8a70 59 * \brief PadLock detection routine
mbedAustin 11:cada08fc8a70 60 *
mbedAustin 11:cada08fc8a70 61 * \param feature The feature to detect
mbedAustin 11:cada08fc8a70 62 *
mbedAustin 11:cada08fc8a70 63 * \return 1 if CPU has support for the feature, 0 otherwise
mbedAustin 11:cada08fc8a70 64 */
mbedAustin 11:cada08fc8a70 65 int mbedtls_padlock_has_support( int feature );
mbedAustin 11:cada08fc8a70 66
mbedAustin 11:cada08fc8a70 67 /**
mbedAustin 11:cada08fc8a70 68 * \brief PadLock AES-ECB block en(de)cryption
mbedAustin 11:cada08fc8a70 69 *
mbedAustin 11:cada08fc8a70 70 * \param ctx AES context
mbedAustin 11:cada08fc8a70 71 * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
mbedAustin 11:cada08fc8a70 72 * \param input 16-byte input block
mbedAustin 11:cada08fc8a70 73 * \param output 16-byte output block
mbedAustin 11:cada08fc8a70 74 *
mbedAustin 11:cada08fc8a70 75 * \return 0 if success, 1 if operation failed
mbedAustin 11:cada08fc8a70 76 */
mbedAustin 11:cada08fc8a70 77 int mbedtls_padlock_xcryptecb( mbedtls_aes_context *ctx,
mbedAustin 11:cada08fc8a70 78 int mode,
mbedAustin 11:cada08fc8a70 79 const unsigned char input[16],
mbedAustin 11:cada08fc8a70 80 unsigned char output[16] );
mbedAustin 11:cada08fc8a70 81
mbedAustin 11:cada08fc8a70 82 /**
mbedAustin 11:cada08fc8a70 83 * \brief PadLock AES-CBC buffer en(de)cryption
mbedAustin 11:cada08fc8a70 84 *
mbedAustin 11:cada08fc8a70 85 * \param ctx AES context
mbedAustin 11:cada08fc8a70 86 * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
mbedAustin 11:cada08fc8a70 87 * \param length length of the input data
mbedAustin 11:cada08fc8a70 88 * \param iv initialization vector (updated after use)
mbedAustin 11:cada08fc8a70 89 * \param input buffer holding the input data
mbedAustin 11:cada08fc8a70 90 * \param output buffer holding the output data
mbedAustin 11:cada08fc8a70 91 *
mbedAustin 11:cada08fc8a70 92 * \return 0 if success, 1 if operation failed
mbedAustin 11:cada08fc8a70 93 */
mbedAustin 11:cada08fc8a70 94 int mbedtls_padlock_xcryptcbc( mbedtls_aes_context *ctx,
mbedAustin 11:cada08fc8a70 95 int mode,
mbedAustin 11:cada08fc8a70 96 size_t length,
mbedAustin 11:cada08fc8a70 97 unsigned char iv[16],
mbedAustin 11:cada08fc8a70 98 const unsigned char *input,
mbedAustin 11:cada08fc8a70 99 unsigned char *output );
mbedAustin 11:cada08fc8a70 100
mbedAustin 11:cada08fc8a70 101 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 102 }
mbedAustin 11:cada08fc8a70 103 #endif
mbedAustin 11:cada08fc8a70 104
mbedAustin 11:cada08fc8a70 105 #endif /* HAVE_X86 */
mbedAustin 11:cada08fc8a70 106
mbedAustin 11:cada08fc8a70 107 #endif /* padlock.h */