~ubuntu-branches/ubuntu/gutsy/openssl/gutsy-security

« back to all changes in this revision

Viewing changes to crypto/camellia/cmll_locl.h

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2007-03-10 17:11:46 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070310171146-ekahy2avht7qdc4f
Tags: 0.9.8e-4
openssl should depend on libssl0.9.8 0.9.8e-1 since it 
uses some of the defines that changed to functions.
Other things build against libssl or libcrypto shouldn't 
have this problem since they use the old headers.
(Closes: #414283)

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
#include <stdlib.h>
74
74
#include <string.h>
75
75
 
76
 
#if defined(_MSC_VER)
77
 
typedef unsigned char uint8_t;
78
 
typedef unsigned int uint32_t;
79
 
typedef unsigned __int64 uint64_t;
80
 
#else
81
 
#include <inttypes.h>
82
 
#endif
 
76
typedef unsigned char u8;
 
77
typedef unsigned int u32;
83
78
 
84
79
#ifdef __cplusplus
85
80
extern "C" {
86
81
#endif
87
82
 
88
 
#define ALIGN 4
89
 
#define UNITSIZE 4
90
 
 
91
83
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
92
84
# define SWAP(x) ( _lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00 )
93
 
# define GETU32(p) SWAP(*((uint32_t *)(p)))
94
 
# define PUTU32(ct, st) { *((uint32_t *)(ct)) = SWAP((st)); }
 
85
# define GETU32(p) SWAP(*((u32 *)(p)))
 
86
# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
95
87
# define CAMELLIA_SWAP4(x) (x = ( _lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) )
96
88
 
97
 
 
98
89
#else /* not windows */
99
 
# define GETU32(pt) (((uint32_t)(pt)[0] << 24) \
100
 
        ^ ((uint32_t)(pt)[1] << 16) \
101
 
        ^ ((uint32_t)(pt)[2] <<  8) \
102
 
        ^ ((uint32_t)(pt)[3]))
103
 
 
104
 
# define PUTU32(ct, st) { (ct)[0] = (uint8_t)((st) >> 24); \
105
 
        (ct)[1] = (uint8_t)((st) >> 16); \
106
 
        (ct)[2] = (uint8_t)((st) >>  8); \
107
 
        (ct)[3] = (uint8_t)(st); }
108
 
 
109
 
#ifdef L_ENDIAN
110
 
#if (defined (__GNUC__) && !defined(i386))
 
90
# define GETU32(pt) (((u32)(pt)[0] << 24) \
 
91
        ^ ((u32)(pt)[1] << 16) \
 
92
        ^ ((u32)(pt)[2] <<  8) \
 
93
        ^ ((u32)(pt)[3]))
 
94
 
 
95
# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); \
 
96
        (ct)[1] = (u8)((st) >> 16); \
 
97
        (ct)[2] = (u8)((st) >>  8); \
 
98
        (ct)[3] = (u8)(st); }
 
99
 
 
100
#if (defined (__GNUC__) && (defined(__x86_64__) || defined(__x86_64)))
111
101
#define CAMELLIA_SWAP4(x) \
112
102
  do{\
113
103
    asm("bswap %1" : "+r" (x));\
114
104
  }while(0)
115
 
#else /* not gcc */
 
105
#else
116
106
#define CAMELLIA_SWAP4(x) \
117
107
   do{\
118
 
     x = ((uint32_t)x << 16) + ((uint32_t)x >> 16);\
119
 
     x = (((uint32_t)x & 0xff00ff) << 8) + (((uint32_t)x >> 8) & 0xff00ff);\
 
108
     x = ((u32)x << 16) + ((u32)x >> 16);\
 
109
     x = (((u32)x & 0xff00ff) << 8) + (((u32)x >> 8) & 0xff00ff);\
120
110
   } while(0)
121
 
#endif /* not gcc */
122
 
#else /* big endian */
123
 
#define CAMELLIA_SWAP4(x)
124
 
#endif /* L_ENDIAN */
 
111
#endif
125
112
#endif
126
113
 
127
114
#define COPY4WORD(dst, src)      \
161
148
        }while(0)
162
149
 
163
150
 
164
 
void camellia_setup128(const unsigned char *key, uint32_t *subkey);
165
 
void camellia_setup192(const unsigned char *key, uint32_t *subkey);
166
 
void camellia_setup256(const unsigned char *key, uint32_t *subkey);
 
151
void camellia_setup128(const u8 *key, u32 *subkey);
 
152
void camellia_setup192(const u8 *key, u32 *subkey);
 
153
void camellia_setup256(const u8 *key, u32 *subkey);
167
154
 
168
 
void camellia_encrypt128(const uint32_t *subkey, uint32_t *io);
169
 
void camellia_decrypt128(const uint32_t *subkey, uint32_t *io);
170
 
void camellia_encrypt256(const uint32_t *subkey, uint32_t *io);
171
 
void camellia_decrypt256(const uint32_t *subkey, uint32_t *io);
 
155
void camellia_encrypt128(const u32 *subkey, u32 *io);
 
156
void camellia_decrypt128(const u32 *subkey, u32 *io);
 
157
void camellia_encrypt256(const u32 *subkey, u32 *io);
 
158
void camellia_decrypt256(const u32 *subkey, u32 *io);
172
159
 
173
160
#ifdef __cplusplus
174
161
}