Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame^] | 1 | /** |
| 2 | * \file padlock.h |
| 3 | */ |
| 4 | #ifndef XYSSL_PADLOCK_H |
| 5 | #define XYSSL_PADLOCK_H |
| 6 | |
| 7 | #include "xyssl/aes.h" |
| 8 | |
| 9 | #if (defined(__GNUC__) && defined(__i386__)) |
| 10 | |
| 11 | #ifndef XYSSL_HAVE_X86 |
| 12 | #define XYSSL_HAVE_X86 |
| 13 | #endif |
| 14 | |
| 15 | #define PADLOCK_RNG 0x000C |
| 16 | #define PADLOCK_ACE 0x00C0 |
| 17 | #define PADLOCK_PHE 0x0C00 |
| 18 | #define PADLOCK_PMM 0x3000 |
| 19 | |
| 20 | #define PADLOCK_ALIGN16(x) (unsigned long *) (16 + ((long) x & ~15)) |
| 21 | |
| 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
| 26 | /** |
| 27 | * \brief PadLock detection routine |
| 28 | * |
| 29 | * \return 1 if CPU has support for the feature, 0 otherwise |
| 30 | */ |
| 31 | int padlock_supports( int feature ); |
| 32 | |
| 33 | /** |
| 34 | * \brief PadLock AES-ECB block en(de)cryption |
| 35 | * |
| 36 | * \param ctx AES context |
| 37 | * \param mode AES_ENCRYPT or AES_DECRYPT |
| 38 | * \param input 16-byte input block |
| 39 | * \param output 16-byte output block |
| 40 | * |
| 41 | * \return 0 if success, 1 if operation failed |
| 42 | */ |
| 43 | int padlock_xcryptecb( aes_context *ctx, |
| 44 | int mode, |
| 45 | unsigned char input[16], |
| 46 | unsigned char output[16] ); |
| 47 | |
| 48 | /** |
| 49 | * \brief PadLock AES-CBC buffer en(de)cryption |
| 50 | * |
| 51 | * \param ctx AES context |
| 52 | * \param mode AES_ENCRYPT or AES_DECRYPT |
| 53 | * \param length length of the input data |
| 54 | * \param iv initialization vector (updated after use) |
| 55 | * \param input buffer holding the input data |
| 56 | * \param output buffer holding the output data |
| 57 | * |
| 58 | * \return 0 if success, 1 if operation failed |
| 59 | */ |
| 60 | int padlock_xcryptcbc( aes_context *ctx, |
| 61 | int mode, |
| 62 | int length, |
| 63 | unsigned char iv[16], |
| 64 | unsigned char *input, |
| 65 | unsigned char *output ); |
| 66 | |
| 67 | #ifdef __cplusplus |
| 68 | } |
| 69 | #endif |
| 70 | |
| 71 | #endif /* HAVE_X86 */ |
| 72 | |
| 73 | #endif /* padlock.h */ |