4 * \brief VIA PadLock ACE for HW encryption/decryption supported by some
7 * \warning These functions are only for internal use by other library
8 * functions; you must not call them directly.
11 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
12 * SPDX-License-Identifier: Apache-2.0
14 * Licensed under the Apache License, Version 2.0 (the "License"); you may
15 * not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
18 * http://www.apache.org/licenses/LICENSE-2.0
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
26 * This file is part of mbed TLS (https://tls.mbed.org)
28 #ifndef MBEDTLS_PADLOCK_H
29 #define MBEDTLS_PADLOCK_H
31 #if !defined(MBEDTLS_CONFIG_FILE)
34 #include MBEDTLS_CONFIG_FILE
39 #define MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */
41 #if defined(__has_feature)
42 #if __has_feature(address_sanitizer)
43 #define MBEDTLS_HAVE_ASAN
47 /* Some versions of ASan result in errors about not enough registers */
48 #if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) && \
49 !defined(MBEDTLS_HAVE_ASAN)
51 #ifndef MBEDTLS_HAVE_X86
52 #define MBEDTLS_HAVE_X86
57 #define MBEDTLS_PADLOCK_RNG 0x000C
58 #define MBEDTLS_PADLOCK_ACE 0x00C0
59 #define MBEDTLS_PADLOCK_PHE 0x0C00
60 #define MBEDTLS_PADLOCK_PMM 0x3000
62 #define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) (x) & ~15))
69 * \brief Internal PadLock detection routine
71 * \note This function is only for internal use by other library
72 * functions; you must not call it directly.
74 * \param feature The feature to detect
76 * \return 1 if CPU has support for the feature, 0 otherwise
78 int mbedtls_padlock_has_support( int feature );
81 * \brief Internal PadLock AES-ECB block en(de)cryption
83 * \note This function is only for internal use by other library
84 * functions; you must not call it directly.
86 * \param ctx AES context
87 * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
88 * \param input 16-byte input block
89 * \param output 16-byte output block
91 * \return 0 if success, 1 if operation failed
93 int mbedtls_padlock_xcryptecb( mbedtls_aes_context *ctx,
95 const unsigned char input[16],
96 unsigned char output[16] );
99 * \brief Internal PadLock AES-CBC buffer en(de)cryption
101 * \note This function is only for internal use by other library
102 * functions; you must not call it directly.
104 * \param ctx AES context
105 * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
106 * \param length length of the input data
107 * \param iv initialization vector (updated after use)
108 * \param input buffer holding the input data
109 * \param output buffer holding the output data
111 * \return 0 if success, 1 if operation failed
113 int mbedtls_padlock_xcryptcbc( mbedtls_aes_context *ctx,
116 unsigned char iv[16],
117 const unsigned char *input,
118 unsigned char *output );
124 #endif /* HAVE_X86 */
126 #endif /* padlock.h */