mbed TLS library

Dependents:   HTTPClient-SSL WS_SERVER

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers padlock.h Source File

padlock.h

Go to the documentation of this file.
00001 /**
00002  * \file padlock.h
00003  *
00004  * \brief VIA PadLock ACE for HW encryption/decryption supported by some
00005  *        processors
00006  *
00007  *  Copyright (C) 2006-2014, ARM Limited, All Rights Reserved
00008  *
00009  *  This file is part of mbed TLS (https://tls.mbed.org)
00010  *
00011  *  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version.
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public License along
00022  *  with this program; if not, write to the Free Software Foundation, Inc.,
00023  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00024  */
00025 #ifndef POLARSSL_PADLOCK_H
00026 #define POLARSSL_PADLOCK_H
00027 
00028 #include "aes.h"
00029 
00030 #define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED               -0x0030  /**< Input data should be aligned. */
00031 
00032 #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__i386__)
00033 
00034 #ifndef POLARSSL_HAVE_X86
00035 #define POLARSSL_HAVE_X86
00036 #endif
00037 
00038 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
00039 #include <basetsd.h>
00040 typedef INT32 int32_t;
00041 #else
00042 #include <inttypes.h>
00043 #endif
00044 
00045 #define PADLOCK_RNG 0x000C
00046 #define PADLOCK_ACE 0x00C0
00047 #define PADLOCK_PHE 0x0C00
00048 #define PADLOCK_PMM 0x3000
00049 
00050 #define PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) x & ~15))
00051 
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055 
00056 /**
00057  * \brief          PadLock detection routine
00058  *
00059  * \param feature  The feature to detect
00060  *
00061  * \return         1 if CPU has support for the feature, 0 otherwise
00062  */
00063 int padlock_supports( int feature );
00064 
00065 /**
00066  * \brief          PadLock AES-ECB block en(de)cryption
00067  *
00068  * \param ctx      AES context
00069  * \param mode     AES_ENCRYPT or AES_DECRYPT
00070  * \param input    16-byte input block
00071  * \param output   16-byte output block
00072  *
00073  * \return         0 if success, 1 if operation failed
00074  */
00075 int padlock_xcryptecb( aes_context *ctx,
00076                        int mode,
00077                        const unsigned char input[16],
00078                        unsigned char output[16] );
00079 
00080 /**
00081  * \brief          PadLock AES-CBC buffer en(de)cryption
00082  *
00083  * \param ctx      AES context
00084  * \param mode     AES_ENCRYPT or AES_DECRYPT
00085  * \param length   length of the input data
00086  * \param iv       initialization vector (updated after use)
00087  * \param input    buffer holding the input data
00088  * \param output   buffer holding the output data
00089  *
00090  * \return         0 if success, 1 if operation failed
00091  */
00092 int padlock_xcryptcbc( aes_context *ctx,
00093                        int mode,
00094                        size_t length,
00095                        unsigned char iv[16],
00096                        const unsigned char *input,
00097                        unsigned char *output );
00098 
00099 #ifdef __cplusplus
00100 }
00101 #endif
00102 
00103 #endif /* HAVE_X86  */
00104 
00105 #endif /* padlock.h */
00106