mbed TLS library
Dependents: HTTPClient-SSL WS_SERVER
include/polarssl/padlock.h@0:137634ff4186, 2015-06-11 (annotated)
- Committer:
- ansond
- Date:
- Thu Jun 11 03:27:03 2015 +0000
- Revision:
- 0:137634ff4186
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:137634ff4186 | 1 | /** |
ansond | 0:137634ff4186 | 2 | * \file padlock.h |
ansond | 0:137634ff4186 | 3 | * |
ansond | 0:137634ff4186 | 4 | * \brief VIA PadLock ACE for HW encryption/decryption supported by some |
ansond | 0:137634ff4186 | 5 | * processors |
ansond | 0:137634ff4186 | 6 | * |
ansond | 0:137634ff4186 | 7 | * Copyright (C) 2006-2014, ARM Limited, All Rights Reserved |
ansond | 0:137634ff4186 | 8 | * |
ansond | 0:137634ff4186 | 9 | * This file is part of mbed TLS (https://tls.mbed.org) |
ansond | 0:137634ff4186 | 10 | * |
ansond | 0:137634ff4186 | 11 | * This program is free software; you can redistribute it and/or modify |
ansond | 0:137634ff4186 | 12 | * it under the terms of the GNU General Public License as published by |
ansond | 0:137634ff4186 | 13 | * the Free Software Foundation; either version 2 of the License, or |
ansond | 0:137634ff4186 | 14 | * (at your option) any later version. |
ansond | 0:137634ff4186 | 15 | * |
ansond | 0:137634ff4186 | 16 | * This program is distributed in the hope that it will be useful, |
ansond | 0:137634ff4186 | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ansond | 0:137634ff4186 | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ansond | 0:137634ff4186 | 19 | * GNU General Public License for more details. |
ansond | 0:137634ff4186 | 20 | * |
ansond | 0:137634ff4186 | 21 | * You should have received a copy of the GNU General Public License along |
ansond | 0:137634ff4186 | 22 | * with this program; if not, write to the Free Software Foundation, Inc., |
ansond | 0:137634ff4186 | 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
ansond | 0:137634ff4186 | 24 | */ |
ansond | 0:137634ff4186 | 25 | #ifndef POLARSSL_PADLOCK_H |
ansond | 0:137634ff4186 | 26 | #define POLARSSL_PADLOCK_H |
ansond | 0:137634ff4186 | 27 | |
ansond | 0:137634ff4186 | 28 | #include "aes.h" |
ansond | 0:137634ff4186 | 29 | |
ansond | 0:137634ff4186 | 30 | #define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */ |
ansond | 0:137634ff4186 | 31 | |
ansond | 0:137634ff4186 | 32 | #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) |
ansond | 0:137634ff4186 | 33 | |
ansond | 0:137634ff4186 | 34 | #ifndef POLARSSL_HAVE_X86 |
ansond | 0:137634ff4186 | 35 | #define POLARSSL_HAVE_X86 |
ansond | 0:137634ff4186 | 36 | #endif |
ansond | 0:137634ff4186 | 37 | |
ansond | 0:137634ff4186 | 38 | #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32) |
ansond | 0:137634ff4186 | 39 | #include <basetsd.h> |
ansond | 0:137634ff4186 | 40 | typedef INT32 int32_t; |
ansond | 0:137634ff4186 | 41 | #else |
ansond | 0:137634ff4186 | 42 | #include <inttypes.h> |
ansond | 0:137634ff4186 | 43 | #endif |
ansond | 0:137634ff4186 | 44 | |
ansond | 0:137634ff4186 | 45 | #define PADLOCK_RNG 0x000C |
ansond | 0:137634ff4186 | 46 | #define PADLOCK_ACE 0x00C0 |
ansond | 0:137634ff4186 | 47 | #define PADLOCK_PHE 0x0C00 |
ansond | 0:137634ff4186 | 48 | #define PADLOCK_PMM 0x3000 |
ansond | 0:137634ff4186 | 49 | |
ansond | 0:137634ff4186 | 50 | #define PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) x & ~15)) |
ansond | 0:137634ff4186 | 51 | |
ansond | 0:137634ff4186 | 52 | #ifdef __cplusplus |
ansond | 0:137634ff4186 | 53 | extern "C" { |
ansond | 0:137634ff4186 | 54 | #endif |
ansond | 0:137634ff4186 | 55 | |
ansond | 0:137634ff4186 | 56 | /** |
ansond | 0:137634ff4186 | 57 | * \brief PadLock detection routine |
ansond | 0:137634ff4186 | 58 | * |
ansond | 0:137634ff4186 | 59 | * \param feature The feature to detect |
ansond | 0:137634ff4186 | 60 | * |
ansond | 0:137634ff4186 | 61 | * \return 1 if CPU has support for the feature, 0 otherwise |
ansond | 0:137634ff4186 | 62 | */ |
ansond | 0:137634ff4186 | 63 | int padlock_supports( int feature ); |
ansond | 0:137634ff4186 | 64 | |
ansond | 0:137634ff4186 | 65 | /** |
ansond | 0:137634ff4186 | 66 | * \brief PadLock AES-ECB block en(de)cryption |
ansond | 0:137634ff4186 | 67 | * |
ansond | 0:137634ff4186 | 68 | * \param ctx AES context |
ansond | 0:137634ff4186 | 69 | * \param mode AES_ENCRYPT or AES_DECRYPT |
ansond | 0:137634ff4186 | 70 | * \param input 16-byte input block |
ansond | 0:137634ff4186 | 71 | * \param output 16-byte output block |
ansond | 0:137634ff4186 | 72 | * |
ansond | 0:137634ff4186 | 73 | * \return 0 if success, 1 if operation failed |
ansond | 0:137634ff4186 | 74 | */ |
ansond | 0:137634ff4186 | 75 | int padlock_xcryptecb( aes_context *ctx, |
ansond | 0:137634ff4186 | 76 | int mode, |
ansond | 0:137634ff4186 | 77 | const unsigned char input[16], |
ansond | 0:137634ff4186 | 78 | unsigned char output[16] ); |
ansond | 0:137634ff4186 | 79 | |
ansond | 0:137634ff4186 | 80 | /** |
ansond | 0:137634ff4186 | 81 | * \brief PadLock AES-CBC buffer en(de)cryption |
ansond | 0:137634ff4186 | 82 | * |
ansond | 0:137634ff4186 | 83 | * \param ctx AES context |
ansond | 0:137634ff4186 | 84 | * \param mode AES_ENCRYPT or AES_DECRYPT |
ansond | 0:137634ff4186 | 85 | * \param length length of the input data |
ansond | 0:137634ff4186 | 86 | * \param iv initialization vector (updated after use) |
ansond | 0:137634ff4186 | 87 | * \param input buffer holding the input data |
ansond | 0:137634ff4186 | 88 | * \param output buffer holding the output data |
ansond | 0:137634ff4186 | 89 | * |
ansond | 0:137634ff4186 | 90 | * \return 0 if success, 1 if operation failed |
ansond | 0:137634ff4186 | 91 | */ |
ansond | 0:137634ff4186 | 92 | int padlock_xcryptcbc( aes_context *ctx, |
ansond | 0:137634ff4186 | 93 | int mode, |
ansond | 0:137634ff4186 | 94 | size_t length, |
ansond | 0:137634ff4186 | 95 | unsigned char iv[16], |
ansond | 0:137634ff4186 | 96 | const unsigned char *input, |
ansond | 0:137634ff4186 | 97 | unsigned char *output ); |
ansond | 0:137634ff4186 | 98 | |
ansond | 0:137634ff4186 | 99 | #ifdef __cplusplus |
ansond | 0:137634ff4186 | 100 | } |
ansond | 0:137634ff4186 | 101 | #endif |
ansond | 0:137634ff4186 | 102 | |
ansond | 0:137634ff4186 | 103 | #endif /* HAVE_X86 */ |
ansond | 0:137634ff4186 | 104 | |
ansond | 0:137634ff4186 | 105 | #endif /* padlock.h */ |
ansond | 0:137634ff4186 | 106 |