Mbed TLS v2.28.5
padlock.h
Go to the documentation of this file.
1 
10 /*
11  * Copyright The Mbed TLS Contributors
12  * SPDX-License-Identifier: Apache-2.0
13  *
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
17  *
18  * http://www.apache.org/licenses/LICENSE-2.0
19  *
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.
25  */
26 #ifndef MBEDTLS_PADLOCK_H
27 #define MBEDTLS_PADLOCK_H
28 
29 #if !defined(MBEDTLS_CONFIG_FILE)
30 #include "mbedtls/config.h"
31 #else
32 #include MBEDTLS_CONFIG_FILE
33 #endif
34 
35 #include "mbedtls/aes.h"
36 
38 #define MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -0x0030
39 
40 #if defined(__has_feature)
41 #if __has_feature(address_sanitizer)
42 #define MBEDTLS_HAVE_ASAN
43 #endif
44 #endif
45 
46 /* Some versions of ASan result in errors about not enough registers */
47 #if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_ASM) && \
48  defined(__GNUC__) && defined(__i386__) && \
49  !defined(MBEDTLS_HAVE_ASAN)
50 
51 #define MBEDTLS_VIA_PADLOCK_HAVE_CODE
52 
53 #ifndef MBEDTLS_HAVE_X86
54 #define MBEDTLS_HAVE_X86
55 #endif
56 
57 #include <stdint.h>
58 
59 #define MBEDTLS_PADLOCK_RNG 0x000C
60 #define MBEDTLS_PADLOCK_ACE 0x00C0
61 #define MBEDTLS_PADLOCK_PHE 0x0C00
62 #define MBEDTLS_PADLOCK_PMM 0x3000
63 
64 #define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) (x) & ~15))
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
80 int mbedtls_padlock_has_support(int feature);
81 
95 int mbedtls_padlock_xcryptecb(mbedtls_aes_context *ctx,
96  int mode,
97  const unsigned char input[16],
98  unsigned char output[16]);
99 
115 int mbedtls_padlock_xcryptcbc(mbedtls_aes_context *ctx,
116  int mode,
117  size_t length,
118  unsigned char iv[16],
119  const unsigned char *input,
120  unsigned char *output);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif /* MBEDTLS_PADLOCK_C && MBEDTLS_HAVE_ASM &&
127  __GNUC__ && __i386__ && !MBEDTLS_HAVE_ASAN */
128 
129 #endif /* padlock.h */
Configuration options (set of defines)
This file contains AES definitions and functions.
The AES context-type definition.
Definition: aes.h:91