Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file padlock.h |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 3 | * |
| 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine |
| 5 | * |
Paul Bakker | 785a9ee | 2009-01-25 14:15:10 +0000 | [diff] [blame^] | 6 | * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org> |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 21 | */ |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 22 | #ifndef POLARSSL_PADLOCK_H |
| 23 | #define POLARSSL_PADLOCK_H |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 24 | |
Paul Bakker | 8e831ed | 2009-01-03 21:24:11 +0000 | [diff] [blame] | 25 | #include "polarssl/aes.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 26 | |
| 27 | #if (defined(__GNUC__) && defined(__i386__)) |
| 28 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 29 | #ifndef POLARSSL_HAVE_X86 |
| 30 | #define POLARSSL_HAVE_X86 |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 31 | #endif |
| 32 | |
| 33 | #define PADLOCK_RNG 0x000C |
| 34 | #define PADLOCK_ACE 0x00C0 |
| 35 | #define PADLOCK_PHE 0x0C00 |
| 36 | #define PADLOCK_PMM 0x3000 |
| 37 | |
| 38 | #define PADLOCK_ALIGN16(x) (unsigned long *) (16 + ((long) x & ~15)) |
| 39 | |
| 40 | #ifdef __cplusplus |
| 41 | extern "C" { |
| 42 | #endif |
| 43 | |
| 44 | /** |
| 45 | * \brief PadLock detection routine |
| 46 | * |
| 47 | * \return 1 if CPU has support for the feature, 0 otherwise |
| 48 | */ |
| 49 | int padlock_supports( int feature ); |
| 50 | |
| 51 | /** |
| 52 | * \brief PadLock AES-ECB block en(de)cryption |
| 53 | * |
| 54 | * \param ctx AES context |
| 55 | * \param mode AES_ENCRYPT or AES_DECRYPT |
| 56 | * \param input 16-byte input block |
| 57 | * \param output 16-byte output block |
| 58 | * |
| 59 | * \return 0 if success, 1 if operation failed |
| 60 | */ |
| 61 | int padlock_xcryptecb( aes_context *ctx, |
| 62 | int mode, |
| 63 | unsigned char input[16], |
| 64 | unsigned char output[16] ); |
| 65 | |
| 66 | /** |
| 67 | * \brief PadLock AES-CBC buffer en(de)cryption |
| 68 | * |
| 69 | * \param ctx AES context |
| 70 | * \param mode AES_ENCRYPT or AES_DECRYPT |
| 71 | * \param length length of the input data |
| 72 | * \param iv initialization vector (updated after use) |
| 73 | * \param input buffer holding the input data |
| 74 | * \param output buffer holding the output data |
| 75 | * |
| 76 | * \return 0 if success, 1 if operation failed |
| 77 | */ |
| 78 | int padlock_xcryptcbc( aes_context *ctx, |
| 79 | int mode, |
| 80 | int length, |
| 81 | unsigned char iv[16], |
| 82 | unsigned char *input, |
| 83 | unsigned char *output ); |
| 84 | |
| 85 | #ifdef __cplusplus |
| 86 | } |
| 87 | #endif |
| 88 | |
| 89 | #endif /* HAVE_X86 */ |
| 90 | |
| 91 | #endif /* padlock.h */ |