mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
markrad
Date:
Thu Jan 05 00:18:44 2017 +0000
Revision:
0:cdf462088d13
Initial commit

Who changed what in which revision?

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