ssl_tls: fix format warning in ssl_parse_certificate() on x86_64
[tropicssl.git] / include / tropicssl / padlock.h
blob1ab06eaac1801c30bb5a9ebf57616b3ce340c214
1 /**
2 * \file padlock.h
4 * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
6 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
8 * All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of PolarSSL or XySSL nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef TROPICSSL_PADLOCK_H
36 #define TROPICSSL_PADLOCK_H
38 #include "tropicssl/aes.h"
40 #if (defined(__GNUC__) && defined(__i386__))
42 #ifndef TROPICSSL_HAVE_X86
43 #define TROPICSSL_HAVE_X86
44 #endif
46 #define PADLOCK_RNG 0x000C
47 #define PADLOCK_ACE 0x00C0
48 #define PADLOCK_PHE 0x0C00
49 #define PADLOCK_PMM 0x3000
51 #define PADLOCK_ALIGN16(x) (unsigned long *) (16 + ((long) x & ~15))
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
57 /**
58 * \brief PadLock detection routine
60 * \return 1 if CPU has support for the feature, 0 otherwise
62 int padlock_supports(int feature);
64 /**
65 * \brief PadLock AES-ECB block en(de)cryption
67 * \param ctx AES context
68 * \param mode AES_ENCRYPT or AES_DECRYPT
69 * \param input 16-byte input block
70 * \param output 16-byte output block
72 * \return 0 if success, 1 if operation failed
74 int padlock_xcryptecb(aes_context * ctx,
75 int mode,
76 const unsigned char input[16],
77 unsigned char output[16]);
79 /**
80 * \brief PadLock AES-CBC buffer en(de)cryption
82 * \param ctx AES context
83 * \param mode AES_ENCRYPT or AES_DECRYPT
84 * \param length length of the input data
85 * \param iv initialization vector (updated after use)
86 * \param input buffer holding the input data
87 * \param output buffer holding the output data
89 * \return 0 if success, 1 if operation failed
91 int padlock_xcryptcbc(aes_context * ctx,
92 int mode,
93 int length,
94 unsigned char iv[16],
95 const unsigned char *input,
96 unsigned char *output);
98 #ifdef __cplusplus
100 #endif
101 #endif /* HAVE_X86 */
102 #endif /* padlock.h */