blob: e154214a127324a3b618647aad498b9a4f06e167 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file padlock.h
3 */
Paul Bakker40e46942009-01-03 21:51:57 +00004#ifndef POLARSSL_PADLOCK_H
5#define POLARSSL_PADLOCK_H
Paul Bakker5121ce52009-01-03 21:22:43 +00006
Paul Bakker8e831ed2009-01-03 21:24:11 +00007#include "polarssl/aes.h"
Paul Bakker5121ce52009-01-03 21:22:43 +00008
9#if (defined(__GNUC__) && defined(__i386__))
10
Paul Bakker40e46942009-01-03 21:51:57 +000011#ifndef POLARSSL_HAVE_X86
12#define POLARSSL_HAVE_X86
Paul Bakker5121ce52009-01-03 21:22:43 +000013#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
23extern "C" {
24#endif
25
26/**
27 * \brief PadLock detection routine
28 *
29 * \return 1 if CPU has support for the feature, 0 otherwise
30 */
31int 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 */
43int 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 */
60int 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 */