46 for (i = 0; i < 4; i++)
54 for (i = 0; i < 4; i++)
63 uint32_t k0 = ctx->
key[0];
64 uint32_t k1 = ctx->
key[1];
65 uint32_t k2 = ctx->
key[2];
66 uint32_t k3 = ctx->
key[3];
75 uint32_t
delta = 0x9E3779B9
U, sum = delta * 32;
77 for (i = 0; i < 32; i++) {
80 v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + ctx->
key[sum & 3]);
83 #define DSTEP(SUM, K0, K1) \
84 v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (SUM + K0); \
85 v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (SUM - 0x9E3779B9U + K1)
87 DSTEP(0xC6EF3720U, k2, k3);
88 DSTEP(0x28B7BD67U, k3, k2);
89 DSTEP(0x8A8043AEU, k0, k1);
90 DSTEP(0xEC48C9F5U, k1, k0);
91 DSTEP(0x4E11503CU, k2, k3);
92 DSTEP(0xAFD9D683U, k2, k2);
93 DSTEP(0x11A25CCAU, k3, k1);
94 DSTEP(0x736AE311U, k0, k0);
95 DSTEP(0xD5336958U, k1, k3);
96 DSTEP(0x36FBEF9FU, k1, k2);
97 DSTEP(0x98C475E6U, k2, k1);
98 DSTEP(0xFA8CFC2DU, k3, k0);
99 DSTEP(0x5C558274U, k0, k3);
100 DSTEP(0xBE1E08BBU, k1, k2);
101 DSTEP(0x1FE68F02U, k1, k1);
102 DSTEP(0x81AF1549U, k2, k0);
103 DSTEP(0xE3779B90U, k3, k3);
104 DSTEP(0x454021D7U, k0, k2);
105 DSTEP(0xA708A81EU, k1, k1);
106 DSTEP(0x08D12E65U, k1, k0);
107 DSTEP(0x6A99B4ACU, k2, k3);
108 DSTEP(0xCC623AF3U, k3, k2);
109 DSTEP(0x2E2AC13AU, k0, k1);
110 DSTEP(0x8FF34781U, k0, k0);
111 DSTEP(0xF1BBCDC8U, k1, k3);
112 DSTEP(0x5384540FU, k2, k2);
113 DSTEP(0xB54CDA56U, k3, k1);
114 DSTEP(0x1715609DU, k0, k0);
115 DSTEP(0x78DDE6E4U, k0, k3);
116 DSTEP(0xDAA66D2BU, k1, k2);
117 DSTEP(0x3C6EF372U, k2, k1);
118 DSTEP(0x9E3779B9U, k3, k0);
128 uint32_t sum = 0,
delta = 0x9E3779B9
U;
130 for (i = 0; i < 32; i++) {
131 v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + ctx->
key[sum & 3]);
136 #define ESTEP(SUM, K0, K1) \
137 v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (SUM + K0);\
138 v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (SUM + 0x9E3779B9U + K1)
139 ESTEP(0x00000000U, k0, k3);
140 ESTEP(0x9E3779B9U, k1, k2);
141 ESTEP(0x3C6EF372U, k2, k1);
142 ESTEP(0xDAA66D2BU, k3, k0);
143 ESTEP(0x78DDE6E4U, k0, k0);
144 ESTEP(0x1715609DU, k1, k3);
145 ESTEP(0xB54CDA56U, k2, k2);
146 ESTEP(0x5384540FU, k3, k1);
147 ESTEP(0xF1BBCDC8U, k0, k0);
148 ESTEP(0x8FF34781U, k1, k0);
149 ESTEP(0x2E2AC13AU, k2, k3);
150 ESTEP(0xCC623AF3U, k3, k2);
151 ESTEP(0x6A99B4ACU, k0, k1);
152 ESTEP(0x08D12E65U, k1, k1);
153 ESTEP(0xA708A81EU, k2, k0);
154 ESTEP(0x454021D7U, k3, k3);
155 ESTEP(0xE3779B90U, k0, k2);
156 ESTEP(0x81AF1549U, k1, k1);
157 ESTEP(0x1FE68F02U, k2, k1);
158 ESTEP(0xBE1E08BBU, k3, k0);
159 ESTEP(0x5C558274U, k0, k3);
160 ESTEP(0xFA8CFC2DU, k1, k2);
161 ESTEP(0x98C475E6U, k2, k1);
162 ESTEP(0x36FBEF9FU, k3, k1);
163 ESTEP(0xD5336958U, k0, k0);
164 ESTEP(0x736AE311U, k1, k3);
165 ESTEP(0x11A25CCAU, k2, k2);
166 ESTEP(0xAFD9D683U, k3, k2);
167 ESTEP(0x4E11503CU, k0, k1);
168 ESTEP(0xEC48C9F5U, k1, k0);
169 ESTEP(0x8A8043AEU, k2, k3);
170 ESTEP(0x28B7BD67U, k3, k2);
188 uint32_t
delta = 0x9E3779B9, sum = delta * 32;
190 for (i = 0; i < 32; i++) {
193 v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + ctx->
key[sum & 3]);
201 uint32_t sum = 0,
delta = 0x9E3779B9;
203 for (i = 0; i < 32; i++) {
204 v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + ctx->
key[sum & 3]);
222 crypt(ctx, dst, src, decrypt, iv);
230 for (i = 0; i < 8; i++)
231 dst[i] = src[i] ^ iv[i];
memory handling functions
#define ESTEP(SUM, K0, K1)
static const uint8_t crypt[]
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context, in big endian format...
static void xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt, void(*crypt)(AVXTEA *, uint8_t *, const uint8_t *, int, uint8_t *))
static void xtea_crypt_ecb(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int decrypt, uint8_t *iv)
void av_xtea_init(AVXTEA *ctx, const uint8_t key[16])
Initialize an AVXTEA context.
Public header for libavutil XTEA algorithm.
static void xtea_le_crypt_ecb(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int decrypt, uint8_t *iv)
#define DSTEP(SUM, K0, K1)
void av_xtea_le_init(AVXTEA *ctx, const uint8_t key[16])
Initialize an AVXTEA context.
common internal and external API header
void av_xtea_le_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context, in little endian format...
AVXTEA * av_xtea_alloc(void)
Allocate an AVXTEA context.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...