2009-01-03 22:22:43 +01:00
|
|
|
/**
|
|
|
|
* \file padlock.h
|
2009-01-04 17:27:10 +01:00
|
|
|
*
|
2014-05-01 14:18:25 +02:00
|
|
|
* \brief VIA PadLock ACE for HW encryption/decryption supported by some
|
|
|
|
* processors
|
2018-12-13 11:15:26 +01:00
|
|
|
*
|
2018-12-18 09:57:18 +01:00
|
|
|
* \warning These functions are only for internal use by other library
|
|
|
|
* functions; you must not call them directly.
|
2018-01-05 16:33:17 +01:00
|
|
|
*/
|
|
|
|
/*
|
2020-08-07 13:07:28 +02:00
|
|
|
* Copyright The Mbed TLS Contributors
|
2015-09-04 14:21:07 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2010-07-18 22:36:00 +02:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2010-07-18 22:36:00 +02:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-01-04 17:27:10 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-01-03 22:22:43 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#ifndef MBEDTLS_PADLOCK_H
|
|
|
|
#define MBEDTLS_PADLOCK_H
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2021-05-27 11:25:03 +02:00
|
|
|
#include "mbedtls/build_info.h"
|
2018-02-14 15:02:41 +01:00
|
|
|
|
2019-07-04 21:01:14 +02:00
|
|
|
#include "mbedtls/aes.h"
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */
|
2011-05-23 12:19:31 +02:00
|
|
|
|
2015-08-04 22:19:05 +02:00
|
|
|
#if defined(__has_feature)
|
|
|
|
#if __has_feature(address_sanitizer)
|
|
|
|
#define MBEDTLS_HAVE_ASAN
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Some versions of ASan result in errors about not enough registers */
|
|
|
|
#if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) && \
|
2015-08-04 22:49:07 +02:00
|
|
|
!defined(MBEDTLS_HAVE_ASAN)
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#ifndef MBEDTLS_HAVE_X86
|
|
|
|
#define MBEDTLS_HAVE_X86
|
2009-01-03 22:22:43 +01:00
|
|
|
#endif
|
|
|
|
|
2015-04-15 11:53:16 +02:00
|
|
|
#include <stdint.h>
|
2012-10-01 16:41:15 +02:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_PADLOCK_RNG 0x000C
|
|
|
|
#define MBEDTLS_PADLOCK_ACE 0x00C0
|
|
|
|
#define MBEDTLS_PADLOCK_PHE 0x0C00
|
|
|
|
#define MBEDTLS_PADLOCK_PMM 0x3000
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2018-10-15 13:01:35 +02:00
|
|
|
#define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) (x) & ~15))
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2018-12-13 11:15:26 +01:00
|
|
|
* \brief Internal PadLock detection routine
|
|
|
|
*
|
|
|
|
* \note This function is only for internal use by other library
|
|
|
|
* functions; you must not call it directly.
|
2009-01-03 22:22:43 +01:00
|
|
|
*
|
2013-12-30 17:57:27 +01:00
|
|
|
* \param feature The feature to detect
|
2009-07-28 09:18:38 +02:00
|
|
|
*
|
2021-05-18 19:59:37 +02:00
|
|
|
* \return non-zero if CPU has support for the feature, 0 otherwise
|
2009-01-03 22:22:43 +01:00
|
|
|
*/
|
2015-06-02 11:38:50 +02:00
|
|
|
int mbedtls_padlock_has_support( int feature );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
/**
|
2018-12-13 11:15:26 +01:00
|
|
|
* \brief Internal PadLock AES-ECB block en(de)cryption
|
|
|
|
*
|
|
|
|
* \note This function is only for internal use by other library
|
|
|
|
* functions; you must not call it directly.
|
2009-01-03 22:22:43 +01:00
|
|
|
*
|
|
|
|
* \param ctx AES context
|
2015-04-08 12:49:31 +02:00
|
|
|
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
|
2009-01-03 22:22:43 +01:00
|
|
|
* \param input 16-byte input block
|
|
|
|
* \param output 16-byte output block
|
|
|
|
*
|
|
|
|
* \return 0 if success, 1 if operation failed
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_padlock_xcryptecb( mbedtls_aes_context *ctx,
|
2018-12-13 11:15:26 +01:00
|
|
|
int mode,
|
|
|
|
const unsigned char input[16],
|
|
|
|
unsigned char output[16] );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
/**
|
2018-12-13 11:15:26 +01:00
|
|
|
* \brief Internal PadLock AES-CBC buffer en(de)cryption
|
|
|
|
*
|
|
|
|
* \note This function is only for internal use by other library
|
|
|
|
* functions; you must not call it directly.
|
2009-01-03 22:22:43 +01:00
|
|
|
*
|
|
|
|
* \param ctx AES context
|
2015-04-08 12:49:31 +02:00
|
|
|
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
|
2009-01-03 22:22:43 +01:00
|
|
|
* \param length length of the input data
|
|
|
|
* \param iv initialization vector (updated after use)
|
|
|
|
* \param input buffer holding the input data
|
|
|
|
* \param output buffer holding the output data
|
|
|
|
*
|
|
|
|
* \return 0 if success, 1 if operation failed
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_padlock_xcryptcbc( mbedtls_aes_context *ctx,
|
2018-12-13 11:15:26 +01:00
|
|
|
int mode,
|
|
|
|
size_t length,
|
|
|
|
unsigned char iv[16],
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned char *output );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* HAVE_X86 */
|
|
|
|
|
|
|
|
#endif /* padlock.h */
|