ssl_tls: fix format warning in ssl_parse_certificate() on x86_64
[tropicssl.git] / include / tropicssl / xtea.h
blob7996b49695ff5739a81237afa093fd439e2490ff
1 /**
2 * \file xtea.h
4 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the names of PolarSSL or XySSL nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef TROPICSSL_XTEA_H
34 #define TROPICSSL_XTEA_H
36 #define XTEA_ENCRYPT 1
37 #define XTEA_DECRYPT 0
39 /**
40 * \brief XTEA context structure
42 typedef struct {
43 unsigned long k[4]; /*!< key */
44 } xtea_context;
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
50 /**
51 * \brief XTEA key schedule
53 * \param ctx XTEA context to be initialized
54 * \param key the secret key
56 void xtea_setup(xtea_context * ctx, const unsigned char key[16]);
58 /**
59 * \brief XTEA cipher function
61 * \param ctx XTEA context
62 * \param mode XTEA_ENCRYPT or XTEA_DECRYPT
63 * \param input 8-byte input block
64 * \param output 8-byte output block
66 void xtea_crypt(xtea_context * ctx,
67 int mode,
68 const unsigned char input[8],
69 unsigned char output[8]);
71 /**
72 * \brief XTEA cipher function
74 * \param ctx XTEA context
75 * \param mode XTEA_ENCRYPT or XTEA_DECRYPT
76 * \param input 8-byte input block
77 * \param output 8-byte output block
79 void xtea_crypt_ecb(xtea_context * ctx, int mode,
80 const unsigned char input[8],
81 unsigned char output[8]);
83 /**
84 * \brief Checkup routine
86 * \return 0 if successful, or 1 if the test failed
88 int xtea_self_test(int verbose);
90 #ifdef __cplusplus
92 #endif
93 #endif /* xtea.h */