2009-01-03 21:22:43 +00:00
|
|
|
/**
|
|
|
|
* \file padlock.h
|
2009-01-04 16:27:10 +00:00
|
|
|
*
|
2014-05-01 12:18:25 +00:00
|
|
|
* \brief VIA PadLock ACE for HW encryption/decryption supported by some
|
|
|
|
* processors
|
2018-12-13 10:15:26 +00:00
|
|
|
*
|
2018-12-18 08:57:18 +00:00
|
|
|
* \warning These functions are only for internal use by other library
|
|
|
|
* functions; you must not call them directly.
|
2018-01-05 15:33:17 +00:00
|
|
|
*/
|
|
|
|
/*
|
2020-08-07 11:07:28 +00:00
|
|
|
* Copyright The Mbed TLS Contributors
|
2015-09-04 12:21:07 +00:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2010-07-18 20:36:00 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00: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 20:36:00 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-01-04 16:27:10 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00: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 21:22:43 +00:00
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
#ifndef MBEDTLS_PADLOCK_H
|
|
|
|
#define MBEDTLS_PADLOCK_H
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2021-05-27 09:25:03 +00:00
|
|
|
#include "mbedtls/build_info.h"
|
2018-02-14 14:02:41 +00:00
|
|
|
|
2019-07-04 19:01:14 +00:00
|
|
|
#include "mbedtls/aes.h"
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
#define MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */
|
2011-05-23 10:19:31 +00:00
|
|
|
|
2015-08-04 20:19:05 +00: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 20:49:07 +00:00
|
|
|
!defined(MBEDTLS_HAVE_ASAN)
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
#ifndef MBEDTLS_HAVE_X86
|
|
|
|
#define MBEDTLS_HAVE_X86
|
2009-01-03 21:22:43 +00:00
|
|
|
#endif
|
|
|
|
|
2015-04-15 09:53:16 +00:00
|
|
|
#include <stdint.h>
|
2012-10-01 14:41:15 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
#define MBEDTLS_PADLOCK_RNG 0x000C
|
|
|
|
#define MBEDTLS_PADLOCK_ACE 0x00C0
|
|
|
|
#define MBEDTLS_PADLOCK_PHE 0x0C00
|
|
|
|
#define MBEDTLS_PADLOCK_PMM 0x3000
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2018-10-15 11:01:35 +00:00
|
|
|
#define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) (x) & ~15))
|
2009-01-03 21:22:43 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2018-12-13 10:15:26 +00: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 21:22:43 +00:00
|
|
|
*
|
2013-12-30 16:57:27 +00:00
|
|
|
* \param feature The feature to detect
|
2009-07-28 07:18:38 +00:00
|
|
|
*
|
2021-05-18 17:59:37 +00:00
|
|
|
* \return non-zero if CPU has support for the feature, 0 otherwise
|
2009-01-03 21:22:43 +00:00
|
|
|
*/
|
2015-06-02 09:38:50 +00:00
|
|
|
int mbedtls_padlock_has_support( int feature );
|
2009-01-03 21:22:43 +00:00
|
|
|
|
|
|
|
/**
|
2018-12-13 10:15:26 +00: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 21:22:43 +00:00
|
|
|
*
|
|
|
|
* \param ctx AES context
|
2015-04-08 10:49:31 +00:00
|
|
|
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
|
2009-01-03 21:22:43 +00:00
|
|
|
* \param input 16-byte input block
|
|
|
|
* \param output 16-byte output block
|
|
|
|
*
|
|
|
|
* \return 0 if success, 1 if operation failed
|
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
int mbedtls_padlock_xcryptecb( mbedtls_aes_context *ctx,
|
2018-12-13 10:15:26 +00:00
|
|
|
int mode,
|
|
|
|
const unsigned char input[16],
|
|
|
|
unsigned char output[16] );
|
2009-01-03 21:22:43 +00:00
|
|
|
|
|
|
|
/**
|
2018-12-13 10:15:26 +00: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 21:22:43 +00:00
|
|
|
*
|
|
|
|
* \param ctx AES context
|
2015-04-08 10:49:31 +00:00
|
|
|
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
|
2009-01-03 21:22:43 +00: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 10:49:31 +00:00
|
|
|
int mbedtls_padlock_xcryptcbc( mbedtls_aes_context *ctx,
|
2018-12-13 10:15:26 +00:00
|
|
|
int mode,
|
|
|
|
size_t length,
|
|
|
|
unsigned char iv[16],
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned char *output );
|
2009-01-03 21:22:43 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* HAVE_X86 */
|
|
|
|
|
|
|
|
#endif /* padlock.h */
|