blob: 1196c03a1739fb96040c5b35137b522aaac4e3d3 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file padlock.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
4 * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
5 *
6 * Copyright (C) 2009 Paul Bakker
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 Bakker5121ce52009-01-03 21:22:43 +000021 */
Paul Bakker40e46942009-01-03 21:51:57 +000022#ifndef POLARSSL_PADLOCK_H
23#define POLARSSL_PADLOCK_H
Paul Bakker5121ce52009-01-03 21:22:43 +000024
Paul Bakker8e831ed2009-01-03 21:24:11 +000025#include "polarssl/aes.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000026
27#if (defined(__GNUC__) && defined(__i386__))
28
Paul Bakker40e46942009-01-03 21:51:57 +000029#ifndef POLARSSL_HAVE_X86
30#define POLARSSL_HAVE_X86
Paul Bakker5121ce52009-01-03 21:22:43 +000031#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
41extern "C" {
42#endif
43
44/**
45 * \brief PadLock detection routine
46 *
47 * \return 1 if CPU has support for the feature, 0 otherwise
48 */
49int 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 */
61int 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 */
78int 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 */