1 | 2 patches for repository http://tahoe-lafs.org/source/pycryptopp/trunk: |
---|
2 | |
---|
3 | Sat Jul 3 10:21:28 Öйú±ê׼ʱ¼ä 2010 xueyu7452@gmail.com |
---|
4 | * part1.dpatch |
---|
5 | |
---|
6 | Sun Jul 4 12:11:06 Öйú±ê׼ʱ¼ä 2010 xueyu7452@gmail.com |
---|
7 | * xsalsa20.dpatch |
---|
8 | |
---|
9 | New patches: |
---|
10 | |
---|
11 | [part1.dpatch |
---|
12 | xueyu7452@gmail.com**20100703022128 |
---|
13 | Ignore-this: e06eb0269745dc3eaf711891749dcbd0 |
---|
14 | ] { |
---|
15 | hunk ./pycryptopp/_pycryptoppmodule.cpp 8 |
---|
16 | #include "publickey/rsamodule.hpp" |
---|
17 | #include "hash/sha256module.hpp" |
---|
18 | #include "cipher/aesmodule.hpp" |
---|
19 | +#include "cipher/xsalsamodule.hpp" |
---|
20 | |
---|
21 | PyDoc_STRVAR(_pycryptopp__doc__, |
---|
22 | "_pycryptopp -- Python wrappers for a few algorithms from Crypto++\n\ |
---|
23 | hunk ./pycryptopp/_pycryptoppmodule.cpp 18 |
---|
24 | from pycryptopp.publickey import rsa\n\ |
---|
25 | from pycryptopp import cipher\n\ |
---|
26 | from pycryptopp.cipher import aes\n\ |
---|
27 | +from pycryptopp.cipher import xsalsa\n\ |
---|
28 | from pycryptopp import hash\n\ |
---|
29 | from pycryptopp.hash import sha256"); |
---|
30 | |
---|
31 | hunk ./pycryptopp/_pycryptoppmodule.cpp 44 |
---|
32 | init_rsa(module); |
---|
33 | init_sha256(module); |
---|
34 | init_aes(module); |
---|
35 | + init_xsalsa(module); |
---|
36 | } |
---|
37 | |
---|
38 | hunk ./pycryptopp/cipher/__init__.py 2 |
---|
39 | import aes |
---|
40 | +import xsalsa |
---|
41 | +#import ciphercombiner |
---|
42 | |
---|
43 | quiet_pyflakes=[aes] |
---|
44 | } |
---|
45 | [xsalsa20.dpatch |
---|
46 | xueyu7452@gmail.com**20100704041106 |
---|
47 | Ignore-this: bad22988183fb1ef8d387aaf0aecd8e5 |
---|
48 | ] { |
---|
49 | addfile ./cryptopp/salsa.cpp |
---|
50 | hunk ./cryptopp/salsa.cpp 1 |
---|
51 | +// salsa.cpp - written and placed in the public domain by Wei Dai |
---|
52 | + |
---|
53 | +// use "cl /EP /P /DCRYPTOPP_GENERATE_X64_MASM salsa.cpp" to generate MASM code |
---|
54 | + |
---|
55 | +#include "pch.h" |
---|
56 | + |
---|
57 | +#ifndef CRYPTOPP_GENERATE_X64_MASM |
---|
58 | + |
---|
59 | +#include "salsa.h" |
---|
60 | +#include "misc.h" |
---|
61 | +#include "argnames.h" |
---|
62 | +#include "cpu.h" |
---|
63 | + |
---|
64 | +NAMESPACE_BEGIN(CryptoPP) |
---|
65 | + |
---|
66 | +void Salsa20_TestInstantiations() |
---|
67 | +{ |
---|
68 | + Salsa20::Encryption x; |
---|
69 | +} |
---|
70 | + |
---|
71 | +void Salsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) |
---|
72 | +{ |
---|
73 | + m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20); |
---|
74 | + |
---|
75 | + if (!(m_rounds == 8 || m_rounds == 12 || m_rounds == 20)) |
---|
76 | + throw InvalidRounds(Salsa20::StaticAlgorithmName(), m_rounds); |
---|
77 | + |
---|
78 | + // m_state is reordered for SSE2 |
---|
79 | + GetBlock<word32, LittleEndian> get1(key); |
---|
80 | + get1(m_state[13])(m_state[10])(m_state[7])(m_state[4]); |
---|
81 | + GetBlock<word32, LittleEndian> get2(key + length - 16); |
---|
82 | + get2(m_state[15])(m_state[12])(m_state[9])(m_state[6]); |
---|
83 | + |
---|
84 | + // "expand 16-byte k" or "expand 32-byte k" |
---|
85 | + m_state[0] = 0x61707865; |
---|
86 | + m_state[1] = (length == 16) ? 0x3120646e : 0x3320646e; |
---|
87 | + m_state[2] = (length == 16) ? 0x79622d36 : 0x79622d32; |
---|
88 | + m_state[3] = 0x6b206574; |
---|
89 | +} |
---|
90 | + |
---|
91 | +void Salsa20_Policy::CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length) |
---|
92 | +{ |
---|
93 | + assert(length==8); |
---|
94 | + GetBlock<word32, LittleEndian> get(IV); |
---|
95 | + get(m_state[14])(m_state[11]); |
---|
96 | + m_state[8] = m_state[5] = 0; |
---|
97 | +} |
---|
98 | + |
---|
99 | +void Salsa20_Policy::SeekToIteration(lword iterationCount) |
---|
100 | +{ |
---|
101 | + m_state[8] = (word32)iterationCount; |
---|
102 | + m_state[5] = (word32)SafeRightShift<32>(iterationCount); |
---|
103 | +} |
---|
104 | + |
---|
105 | +#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64 |
---|
106 | +unsigned int Salsa20_Policy::GetAlignment() const |
---|
107 | +{ |
---|
108 | +#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE |
---|
109 | + if (HasSSE2()) |
---|
110 | + return 16; |
---|
111 | + else |
---|
112 | +#endif |
---|
113 | + return GetAlignmentOf<word32>(); |
---|
114 | +} |
---|
115 | + |
---|
116 | +unsigned int Salsa20_Policy::GetOptimalBlockSize() const |
---|
117 | +{ |
---|
118 | +#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE |
---|
119 | + if (HasSSE2()) |
---|
120 | + return 4*BYTES_PER_ITERATION; |
---|
121 | + else |
---|
122 | +#endif |
---|
123 | + return BYTES_PER_ITERATION; |
---|
124 | +} |
---|
125 | +#endif |
---|
126 | + |
---|
127 | +#ifdef CRYPTOPP_X64_MASM_AVAILABLE |
---|
128 | +extern "C" { |
---|
129 | +void Salsa20_OperateKeystream(byte *output, const byte *input, size_t iterationCount, int rounds, void *state); |
---|
130 | +} |
---|
131 | +#endif |
---|
132 | + |
---|
133 | +#pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code |
---|
134 | + |
---|
135 | +void Salsa20_Policy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) |
---|
136 | +{ |
---|
137 | +#endif // #ifdef CRYPTOPP_GENERATE_X64_MASM |
---|
138 | + |
---|
139 | +#ifdef CRYPTOPP_X64_MASM_AVAILABLE |
---|
140 | + Salsa20_OperateKeystream(output, input, iterationCount, m_rounds, m_state.data()); |
---|
141 | + return; |
---|
142 | +#endif |
---|
143 | + |
---|
144 | +#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE |
---|
145 | +#ifdef CRYPTOPP_GENERATE_X64_MASM |
---|
146 | + ALIGN 8 |
---|
147 | + Salsa20_OperateKeystream PROC FRAME |
---|
148 | + mov r10, [rsp + 5*8] ; state |
---|
149 | + alloc_stack(10*16 + 32*16 + 8) |
---|
150 | + save_xmm128 xmm6, 0200h |
---|
151 | + save_xmm128 xmm7, 0210h |
---|
152 | + save_xmm128 xmm8, 0220h |
---|
153 | + save_xmm128 xmm9, 0230h |
---|
154 | + save_xmm128 xmm10, 0240h |
---|
155 | + save_xmm128 xmm11, 0250h |
---|
156 | + save_xmm128 xmm12, 0260h |
---|
157 | + save_xmm128 xmm13, 0270h |
---|
158 | + save_xmm128 xmm14, 0280h |
---|
159 | + save_xmm128 xmm15, 0290h |
---|
160 | + .endprolog |
---|
161 | + |
---|
162 | + #define REG_output rcx |
---|
163 | + #define REG_input rdx |
---|
164 | + #define REG_iterationCount r8 |
---|
165 | + #define REG_state r10 |
---|
166 | + #define REG_rounds e9d |
---|
167 | + #define REG_roundsLeft eax |
---|
168 | + #define REG_temp32 r11d |
---|
169 | + #define REG_temp r11 |
---|
170 | + #define SSE2_WORKSPACE rsp |
---|
171 | +#else |
---|
172 | + if (HasSSE2()) |
---|
173 | + { |
---|
174 | + #if CRYPTOPP_BOOL_X64 |
---|
175 | + #define REG_output %4 |
---|
176 | + #define REG_input %1 |
---|
177 | + #define REG_iterationCount %2 |
---|
178 | + #define REG_state %3 |
---|
179 | + #define REG_rounds %0 |
---|
180 | + #define REG_roundsLeft eax |
---|
181 | + #define REG_temp32 edx |
---|
182 | + #define REG_temp rdx |
---|
183 | + #define SSE2_WORKSPACE %5 |
---|
184 | + |
---|
185 | + FixedSizeAlignedSecBlock<byte, 32*16> workspace; |
---|
186 | + #else |
---|
187 | + #define REG_output edi |
---|
188 | + #define REG_input eax |
---|
189 | + #define REG_iterationCount ecx |
---|
190 | + #define REG_state esi |
---|
191 | + #define REG_rounds edx |
---|
192 | + #define REG_roundsLeft ebx |
---|
193 | + #define REG_temp32 ebp |
---|
194 | + #define REG_temp ebp |
---|
195 | + #define SSE2_WORKSPACE esp + WORD_SZ |
---|
196 | + #endif |
---|
197 | + |
---|
198 | + #ifdef __GNUC__ |
---|
199 | + __asm__ __volatile__ |
---|
200 | + ( |
---|
201 | + ".intel_syntax noprefix;" |
---|
202 | + AS_PUSH_IF86( bx) |
---|
203 | + #else |
---|
204 | + void *s = m_state.data(); |
---|
205 | + word32 r = m_rounds; |
---|
206 | + |
---|
207 | + AS2( mov REG_iterationCount, iterationCount) |
---|
208 | + AS2( mov REG_input, input) |
---|
209 | + AS2( mov REG_output, output) |
---|
210 | + AS2( mov REG_state, s) |
---|
211 | + AS2( mov REG_rounds, r) |
---|
212 | + #endif |
---|
213 | +#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM |
---|
214 | + |
---|
215 | + AS_PUSH_IF86( bp) |
---|
216 | + AS2( cmp REG_iterationCount, 4) |
---|
217 | + ASJ( jl, 5, f) |
---|
218 | + |
---|
219 | +#if CRYPTOPP_BOOL_X86 |
---|
220 | + AS2( mov ebx, esp) |
---|
221 | + AS2( and esp, -16) |
---|
222 | + AS2( sub esp, 32*16) |
---|
223 | + AS1( push ebx) |
---|
224 | +#endif |
---|
225 | + |
---|
226 | +#define SSE2_EXPAND_S(i, j) \ |
---|
227 | + ASS( pshufd xmm4, xmm##i, j, j, j, j) \ |
---|
228 | + AS2( movdqa [SSE2_WORKSPACE + (i*4+j)*16 + 256], xmm4) |
---|
229 | + |
---|
230 | + AS2( movdqa xmm0, [REG_state + 0*16]) |
---|
231 | + AS2( movdqa xmm1, [REG_state + 1*16]) |
---|
232 | + AS2( movdqa xmm2, [REG_state + 2*16]) |
---|
233 | + AS2( movdqa xmm3, [REG_state + 3*16]) |
---|
234 | + SSE2_EXPAND_S(0, 0) |
---|
235 | + SSE2_EXPAND_S(0, 1) |
---|
236 | + SSE2_EXPAND_S(0, 2) |
---|
237 | + SSE2_EXPAND_S(0, 3) |
---|
238 | + SSE2_EXPAND_S(1, 0) |
---|
239 | + SSE2_EXPAND_S(1, 2) |
---|
240 | + SSE2_EXPAND_S(1, 3) |
---|
241 | + SSE2_EXPAND_S(2, 1) |
---|
242 | + SSE2_EXPAND_S(2, 2) |
---|
243 | + SSE2_EXPAND_S(2, 3) |
---|
244 | + SSE2_EXPAND_S(3, 0) |
---|
245 | + SSE2_EXPAND_S(3, 1) |
---|
246 | + SSE2_EXPAND_S(3, 2) |
---|
247 | + SSE2_EXPAND_S(3, 3) |
---|
248 | + |
---|
249 | +#define SSE2_EXPAND_S85(i) \ |
---|
250 | + AS2( mov dword ptr [SSE2_WORKSPACE + 8*16 + i*4 + 256], REG_roundsLeft) \ |
---|
251 | + AS2( mov dword ptr [SSE2_WORKSPACE + 5*16 + i*4 + 256], REG_temp32) \ |
---|
252 | + AS2( add REG_roundsLeft, 1) \ |
---|
253 | + AS2( adc REG_temp32, 0) |
---|
254 | + |
---|
255 | + ASL(1) |
---|
256 | + AS2( mov REG_roundsLeft, dword ptr [REG_state + 8*4]) |
---|
257 | + AS2( mov REG_temp32, dword ptr [REG_state + 5*4]) |
---|
258 | + SSE2_EXPAND_S85(0) |
---|
259 | + SSE2_EXPAND_S85(1) |
---|
260 | + SSE2_EXPAND_S85(2) |
---|
261 | + SSE2_EXPAND_S85(3) |
---|
262 | + AS2( mov dword ptr [REG_state + 8*4], REG_roundsLeft) |
---|
263 | + AS2( mov dword ptr [REG_state + 5*4], REG_temp32) |
---|
264 | + |
---|
265 | +#define SSE2_QUARTER_ROUND(a, b, d, i) \ |
---|
266 | + AS2( movdqa xmm4, xmm##d) \ |
---|
267 | + AS2( paddd xmm4, xmm##a) \ |
---|
268 | + AS2( movdqa xmm5, xmm4) \ |
---|
269 | + AS2( pslld xmm4, i) \ |
---|
270 | + AS2( psrld xmm5, 32-i) \ |
---|
271 | + AS2( pxor xmm##b, xmm4) \ |
---|
272 | + AS2( pxor xmm##b, xmm5) |
---|
273 | + |
---|
274 | +#define L01(A,B,C,D,a,b,c,d,i) AS2( movdqa xmm##A, [SSE2_WORKSPACE + d*16 + i*256]) /* y3 */ |
---|
275 | +#define L02(A,B,C,D,a,b,c,d,i) AS2( movdqa xmm##C, [SSE2_WORKSPACE + a*16 + i*256]) /* y0 */ |
---|
276 | +#define L03(A,B,C,D,a,b,c,d,i) AS2( paddd xmm##A, xmm##C) /* y0+y3 */ |
---|
277 | +#define L04(A,B,C,D,a,b,c,d,i) AS2( movdqa xmm##B, xmm##A) |
---|
278 | +#define L05(A,B,C,D,a,b,c,d,i) AS2( pslld xmm##A, 7) |
---|
279 | +#define L06(A,B,C,D,a,b,c,d,i) AS2( psrld xmm##B, 32-7) |
---|
280 | +#define L07(A,B,C,D,a,b,c,d,i) AS2( pxor xmm##A, [SSE2_WORKSPACE + b*16 + i*256]) |
---|
281 | +#define L08(A,B,C,D,a,b,c,d,i) AS2( pxor xmm##A, xmm##B) /* z1 */ |
---|
282 | +#define L09(A,B,C,D,a,b,c,d,i) AS2( movdqa [SSE2_WORKSPACE + b*16], xmm##A) |
---|
283 | +#define L10(A,B,C,D,a,b,c,d,i) AS2( movdqa xmm##B, xmm##A) |
---|
284 | +#define L11(A,B,C,D,a,b,c,d,i) AS2( paddd xmm##A, xmm##C) /* z1+y0 */ |
---|
285 | +#define L12(A,B,C,D,a,b,c,d,i) AS2( movdqa xmm##D, xmm##A) |
---|
286 | +#define L13(A,B,C,D,a,b,c,d,i) AS2( pslld xmm##A, 9) |
---|
287 | +#define L14(A,B,C,D,a,b,c,d,i) AS2( psrld xmm##D, 32-9) |
---|
288 | +#define L15(A,B,C,D,a,b,c,d,i) AS2( pxor xmm##A, [SSE2_WORKSPACE + c*16 + i*256]) |
---|
289 | +#define L16(A,B,C,D,a,b,c,d,i) AS2( pxor xmm##A, xmm##D) /* z2 */ |
---|
290 | +#define L17(A,B,C,D,a,b,c,d,i) AS2( movdqa [SSE2_WORKSPACE + c*16], xmm##A) |
---|
291 | +#define L18(A,B,C,D,a,b,c,d,i) AS2( movdqa xmm##D, xmm##A) |
---|
292 | +#define L19(A,B,C,D,a,b,c,d,i) AS2( paddd xmm##A, xmm##B) /* z2+z1 */ |
---|
293 | +#define L20(A,B,C,D,a,b,c,d,i) AS2( movdqa xmm##B, xmm##A) |
---|
294 | +#define L21(A,B,C,D,a,b,c,d,i) AS2( pslld xmm##A, 13) |
---|
295 | +#define L22(A,B,C,D,a,b,c,d,i) AS2( psrld xmm##B, 32-13) |
---|
296 | +#define L23(A,B,C,D,a,b,c,d,i) AS2( pxor xmm##A, [SSE2_WORKSPACE + d*16 + i*256]) |
---|
297 | +#define L24(A,B,C,D,a,b,c,d,i) AS2( pxor xmm##A, xmm##B) /* z3 */ |
---|
298 | +#define L25(A,B,C,D,a,b,c,d,i) AS2( movdqa [SSE2_WORKSPACE + d*16], xmm##A) |
---|
299 | +#define L26(A,B,C,D,a,b,c,d,i) AS2( paddd xmm##A, xmm##D) /* z3+z2 */ |
---|
300 | +#define L27(A,B,C,D,a,b,c,d,i) AS2( movdqa xmm##D, xmm##A) |
---|
301 | +#define L28(A,B,C,D,a,b,c,d,i) AS2( pslld xmm##A, 18) |
---|
302 | +#define L29(A,B,C,D,a,b,c,d,i) AS2( psrld xmm##D, 32-18) |
---|
303 | +#define L30(A,B,C,D,a,b,c,d,i) AS2( pxor xmm##A, xmm##C) /* xor y0 */ |
---|
304 | +#define L31(A,B,C,D,a,b,c,d,i) AS2( pxor xmm##A, xmm##D) /* z0 */ |
---|
305 | +#define L32(A,B,C,D,a,b,c,d,i) AS2( movdqa [SSE2_WORKSPACE + a*16], xmm##A) |
---|
306 | + |
---|
307 | +#define SSE2_QUARTER_ROUND_X8(i, a, b, c, d, e, f, g, h) \ |
---|
308 | + L01(0,1,2,3, a,b,c,d, i) L01(4,5,6,7, e,f,g,h, i) \ |
---|
309 | + L02(0,1,2,3, a,b,c,d, i) L02(4,5,6,7, e,f,g,h, i) \ |
---|
310 | + L03(0,1,2,3, a,b,c,d, i) L03(4,5,6,7, e,f,g,h, i) \ |
---|
311 | + L04(0,1,2,3, a,b,c,d, i) L04(4,5,6,7, e,f,g,h, i) \ |
---|
312 | + L05(0,1,2,3, a,b,c,d, i) L05(4,5,6,7, e,f,g,h, i) \ |
---|
313 | + L06(0,1,2,3, a,b,c,d, i) L06(4,5,6,7, e,f,g,h, i) \ |
---|
314 | + L07(0,1,2,3, a,b,c,d, i) L07(4,5,6,7, e,f,g,h, i) \ |
---|
315 | + L08(0,1,2,3, a,b,c,d, i) L08(4,5,6,7, e,f,g,h, i) \ |
---|
316 | + L09(0,1,2,3, a,b,c,d, i) L09(4,5,6,7, e,f,g,h, i) \ |
---|
317 | + L10(0,1,2,3, a,b,c,d, i) L10(4,5,6,7, e,f,g,h, i) \ |
---|
318 | + L11(0,1,2,3, a,b,c,d, i) L11(4,5,6,7, e,f,g,h, i) \ |
---|
319 | + L12(0,1,2,3, a,b,c,d, i) L12(4,5,6,7, e,f,g,h, i) \ |
---|
320 | + L13(0,1,2,3, a,b,c,d, i) L13(4,5,6,7, e,f,g,h, i) \ |
---|
321 | + L14(0,1,2,3, a,b,c,d, i) L14(4,5,6,7, e,f,g,h, i) \ |
---|
322 | + L15(0,1,2,3, a,b,c,d, i) L15(4,5,6,7, e,f,g,h, i) \ |
---|
323 | + L16(0,1,2,3, a,b,c,d, i) L16(4,5,6,7, e,f,g,h, i) \ |
---|
324 | + L17(0,1,2,3, a,b,c,d, i) L17(4,5,6,7, e,f,g,h, i) \ |
---|
325 | + L18(0,1,2,3, a,b,c,d, i) L18(4,5,6,7, e,f,g,h, i) \ |
---|
326 | + L19(0,1,2,3, a,b,c,d, i) L19(4,5,6,7, e,f,g,h, i) \ |
---|
327 | + L20(0,1,2,3, a,b,c,d, i) L20(4,5,6,7, e,f,g,h, i) \ |
---|
328 | + L21(0,1,2,3, a,b,c,d, i) L21(4,5,6,7, e,f,g,h, i) \ |
---|
329 | + L22(0,1,2,3, a,b,c,d, i) L22(4,5,6,7, e,f,g,h, i) \ |
---|
330 | + L23(0,1,2,3, a,b,c,d, i) L23(4,5,6,7, e,f,g,h, i) \ |
---|
331 | + L24(0,1,2,3, a,b,c,d, i) L24(4,5,6,7, e,f,g,h, i) \ |
---|
332 | + L25(0,1,2,3, a,b,c,d, i) L25(4,5,6,7, e,f,g,h, i) \ |
---|
333 | + L26(0,1,2,3, a,b,c,d, i) L26(4,5,6,7, e,f,g,h, i) \ |
---|
334 | + L27(0,1,2,3, a,b,c,d, i) L27(4,5,6,7, e,f,g,h, i) \ |
---|
335 | + L28(0,1,2,3, a,b,c,d, i) L28(4,5,6,7, e,f,g,h, i) \ |
---|
336 | + L29(0,1,2,3, a,b,c,d, i) L29(4,5,6,7, e,f,g,h, i) \ |
---|
337 | + L30(0,1,2,3, a,b,c,d, i) L30(4,5,6,7, e,f,g,h, i) \ |
---|
338 | + L31(0,1,2,3, a,b,c,d, i) L31(4,5,6,7, e,f,g,h, i) \ |
---|
339 | + L32(0,1,2,3, a,b,c,d, i) L32(4,5,6,7, e,f,g,h, i) |
---|
340 | + |
---|
341 | +#define SSE2_QUARTER_ROUND_X16(i, a, b, c, d, e, f, g, h, A, B, C, D, E, F, G, H) \ |
---|
342 | + L01(0,1,2,3, a,b,c,d, i) L01(4,5,6,7, e,f,g,h, i) L01(8,9,10,11, A,B,C,D, i) L01(12,13,14,15, E,F,G,H, i) \ |
---|
343 | + L02(0,1,2,3, a,b,c,d, i) L02(4,5,6,7, e,f,g,h, i) L02(8,9,10,11, A,B,C,D, i) L02(12,13,14,15, E,F,G,H, i) \ |
---|
344 | + L03(0,1,2,3, a,b,c,d, i) L03(4,5,6,7, e,f,g,h, i) L03(8,9,10,11, A,B,C,D, i) L03(12,13,14,15, E,F,G,H, i) \ |
---|
345 | + L04(0,1,2,3, a,b,c,d, i) L04(4,5,6,7, e,f,g,h, i) L04(8,9,10,11, A,B,C,D, i) L04(12,13,14,15, E,F,G,H, i) \ |
---|
346 | + L05(0,1,2,3, a,b,c,d, i) L05(4,5,6,7, e,f,g,h, i) L05(8,9,10,11, A,B,C,D, i) L05(12,13,14,15, E,F,G,H, i) \ |
---|
347 | + L06(0,1,2,3, a,b,c,d, i) L06(4,5,6,7, e,f,g,h, i) L06(8,9,10,11, A,B,C,D, i) L06(12,13,14,15, E,F,G,H, i) \ |
---|
348 | + L07(0,1,2,3, a,b,c,d, i) L07(4,5,6,7, e,f,g,h, i) L07(8,9,10,11, A,B,C,D, i) L07(12,13,14,15, E,F,G,H, i) \ |
---|
349 | + L08(0,1,2,3, a,b,c,d, i) L08(4,5,6,7, e,f,g,h, i) L08(8,9,10,11, A,B,C,D, i) L08(12,13,14,15, E,F,G,H, i) \ |
---|
350 | + L09(0,1,2,3, a,b,c,d, i) L09(4,5,6,7, e,f,g,h, i) L09(8,9,10,11, A,B,C,D, i) L09(12,13,14,15, E,F,G,H, i) \ |
---|
351 | + L10(0,1,2,3, a,b,c,d, i) L10(4,5,6,7, e,f,g,h, i) L10(8,9,10,11, A,B,C,D, i) L10(12,13,14,15, E,F,G,H, i) \ |
---|
352 | + L11(0,1,2,3, a,b,c,d, i) L11(4,5,6,7, e,f,g,h, i) L11(8,9,10,11, A,B,C,D, i) L11(12,13,14,15, E,F,G,H, i) \ |
---|
353 | + L12(0,1,2,3, a,b,c,d, i) L12(4,5,6,7, e,f,g,h, i) L12(8,9,10,11, A,B,C,D, i) L12(12,13,14,15, E,F,G,H, i) \ |
---|
354 | + L13(0,1,2,3, a,b,c,d, i) L13(4,5,6,7, e,f,g,h, i) L13(8,9,10,11, A,B,C,D, i) L13(12,13,14,15, E,F,G,H, i) \ |
---|
355 | + L14(0,1,2,3, a,b,c,d, i) L14(4,5,6,7, e,f,g,h, i) L14(8,9,10,11, A,B,C,D, i) L14(12,13,14,15, E,F,G,H, i) \ |
---|
356 | + L15(0,1,2,3, a,b,c,d, i) L15(4,5,6,7, e,f,g,h, i) L15(8,9,10,11, A,B,C,D, i) L15(12,13,14,15, E,F,G,H, i) \ |
---|
357 | + L16(0,1,2,3, a,b,c,d, i) L16(4,5,6,7, e,f,g,h, i) L16(8,9,10,11, A,B,C,D, i) L16(12,13,14,15, E,F,G,H, i) \ |
---|
358 | + L17(0,1,2,3, a,b,c,d, i) L17(4,5,6,7, e,f,g,h, i) L17(8,9,10,11, A,B,C,D, i) L17(12,13,14,15, E,F,G,H, i) \ |
---|
359 | + L18(0,1,2,3, a,b,c,d, i) L18(4,5,6,7, e,f,g,h, i) L18(8,9,10,11, A,B,C,D, i) L18(12,13,14,15, E,F,G,H, i) \ |
---|
360 | + L19(0,1,2,3, a,b,c,d, i) L19(4,5,6,7, e,f,g,h, i) L19(8,9,10,11, A,B,C,D, i) L19(12,13,14,15, E,F,G,H, i) \ |
---|
361 | + L20(0,1,2,3, a,b,c,d, i) L20(4,5,6,7, e,f,g,h, i) L20(8,9,10,11, A,B,C,D, i) L20(12,13,14,15, E,F,G,H, i) \ |
---|
362 | + L21(0,1,2,3, a,b,c,d, i) L21(4,5,6,7, e,f,g,h, i) L21(8,9,10,11, A,B,C,D, i) L21(12,13,14,15, E,F,G,H, i) \ |
---|
363 | + L22(0,1,2,3, a,b,c,d, i) L22(4,5,6,7, e,f,g,h, i) L22(8,9,10,11, A,B,C,D, i) L22(12,13,14,15, E,F,G,H, i) \ |
---|
364 | + L23(0,1,2,3, a,b,c,d, i) L23(4,5,6,7, e,f,g,h, i) L23(8,9,10,11, A,B,C,D, i) L23(12,13,14,15, E,F,G,H, i) \ |
---|
365 | + L24(0,1,2,3, a,b,c,d, i) L24(4,5,6,7, e,f,g,h, i) L24(8,9,10,11, A,B,C,D, i) L24(12,13,14,15, E,F,G,H, i) \ |
---|
366 | + L25(0,1,2,3, a,b,c,d, i) L25(4,5,6,7, e,f,g,h, i) L25(8,9,10,11, A,B,C,D, i) L25(12,13,14,15, E,F,G,H, i) \ |
---|
367 | + L26(0,1,2,3, a,b,c,d, i) L26(4,5,6,7, e,f,g,h, i) L26(8,9,10,11, A,B,C,D, i) L26(12,13,14,15, E,F,G,H, i) \ |
---|
368 | + L27(0,1,2,3, a,b,c,d, i) L27(4,5,6,7, e,f,g,h, i) L27(8,9,10,11, A,B,C,D, i) L27(12,13,14,15, E,F,G,H, i) \ |
---|
369 | + L28(0,1,2,3, a,b,c,d, i) L28(4,5,6,7, e,f,g,h, i) L28(8,9,10,11, A,B,C,D, i) L28(12,13,14,15, E,F,G,H, i) \ |
---|
370 | + L29(0,1,2,3, a,b,c,d, i) L29(4,5,6,7, e,f,g,h, i) L29(8,9,10,11, A,B,C,D, i) L29(12,13,14,15, E,F,G,H, i) \ |
---|
371 | + L30(0,1,2,3, a,b,c,d, i) L30(4,5,6,7, e,f,g,h, i) L30(8,9,10,11, A,B,C,D, i) L30(12,13,14,15, E,F,G,H, i) \ |
---|
372 | + L31(0,1,2,3, a,b,c,d, i) L31(4,5,6,7, e,f,g,h, i) L31(8,9,10,11, A,B,C,D, i) L31(12,13,14,15, E,F,G,H, i) \ |
---|
373 | + L32(0,1,2,3, a,b,c,d, i) L32(4,5,6,7, e,f,g,h, i) L32(8,9,10,11, A,B,C,D, i) L32(12,13,14,15, E,F,G,H, i) |
---|
374 | + |
---|
375 | +#if CRYPTOPP_BOOL_X64 |
---|
376 | + SSE2_QUARTER_ROUND_X16(1, 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15) |
---|
377 | +#else |
---|
378 | + SSE2_QUARTER_ROUND_X8(1, 2, 6, 10, 14, 3, 7, 11, 15) |
---|
379 | + SSE2_QUARTER_ROUND_X8(1, 0, 4, 8, 12, 1, 5, 9, 13) |
---|
380 | +#endif |
---|
381 | + AS2( mov REG_roundsLeft, REG_rounds) |
---|
382 | + ASJ( jmp, 2, f) |
---|
383 | + |
---|
384 | + ASL(SSE2_Salsa_Output) |
---|
385 | + AS2( movdqa xmm0, xmm4) |
---|
386 | + AS2( punpckldq xmm4, xmm5) |
---|
387 | + AS2( movdqa xmm1, xmm6) |
---|
388 | + AS2( punpckldq xmm6, xmm7) |
---|
389 | + AS2( movdqa xmm2, xmm4) |
---|
390 | + AS2( punpcklqdq xmm4, xmm6) // e |
---|
391 | + AS2( punpckhqdq xmm2, xmm6) // f |
---|
392 | + AS2( punpckhdq xmm0, xmm5) |
---|
393 | + AS2( punpckhdq xmm1, xmm7) |
---|
394 | + AS2( movdqa xmm6, xmm0) |
---|
395 | + AS2( punpcklqdq xmm0, xmm1) // g |
---|
396 | + AS2( punpckhqdq xmm6, xmm1) // h |
---|
397 | + AS_XMM_OUTPUT4(SSE2_Salsa_Output_A, REG_input, REG_output, 4, 2, 0, 6, 1, 0, 4, 8, 12, 1) |
---|
398 | + AS1( ret) |
---|
399 | + |
---|
400 | + ASL(6) |
---|
401 | +#if CRYPTOPP_BOOL_X64 |
---|
402 | + SSE2_QUARTER_ROUND_X16(0, 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15) |
---|
403 | + ASL(2) |
---|
404 | + SSE2_QUARTER_ROUND_X16(0, 0, 13, 10, 7, 1, 14, 11, 4, 2, 15, 8, 5, 3, 12, 9, 6) |
---|
405 | +#else |
---|
406 | + SSE2_QUARTER_ROUND_X8(0, 2, 6, 10, 14, 3, 7, 11, 15) |
---|
407 | + SSE2_QUARTER_ROUND_X8(0, 0, 4, 8, 12, 1, 5, 9, 13) |
---|
408 | + ASL(2) |
---|
409 | + SSE2_QUARTER_ROUND_X8(0, 2, 15, 8, 5, 3, 12, 9, 6) |
---|
410 | + SSE2_QUARTER_ROUND_X8(0, 0, 13, 10, 7, 1, 14, 11, 4) |
---|
411 | +#endif |
---|
412 | + AS2( sub REG_roundsLeft, 2) |
---|
413 | + ASJ( jnz, 6, b) |
---|
414 | + |
---|
415 | +#define SSE2_OUTPUT_4(a, b, c, d) \ |
---|
416 | + AS2( movdqa xmm4, [SSE2_WORKSPACE + a*16 + 256])\ |
---|
417 | + AS2( paddd xmm4, [SSE2_WORKSPACE + a*16])\ |
---|
418 | + AS2( movdqa xmm5, [SSE2_WORKSPACE + b*16 + 256])\ |
---|
419 | + AS2( paddd xmm5, [SSE2_WORKSPACE + b*16])\ |
---|
420 | + AS2( movdqa xmm6, [SSE2_WORKSPACE + c*16 + 256])\ |
---|
421 | + AS2( paddd xmm6, [SSE2_WORKSPACE + c*16])\ |
---|
422 | + AS2( movdqa xmm7, [SSE2_WORKSPACE + d*16 + 256])\ |
---|
423 | + AS2( paddd xmm7, [SSE2_WORKSPACE + d*16])\ |
---|
424 | + ASC( call, SSE2_Salsa_Output) |
---|
425 | + |
---|
426 | + SSE2_OUTPUT_4(0, 13, 10, 7) |
---|
427 | + SSE2_OUTPUT_4(4, 1, 14, 11) |
---|
428 | + SSE2_OUTPUT_4(8, 5, 2, 15) |
---|
429 | + SSE2_OUTPUT_4(12, 9, 6, 3) |
---|
430 | + AS2( test REG_input, REG_input) |
---|
431 | + ASJ( jz, 9, f) |
---|
432 | + AS2( add REG_input, 12*16) |
---|
433 | + ASL(9) |
---|
434 | + AS2( add REG_output, 12*16) |
---|
435 | + AS2( sub REG_iterationCount, 4) |
---|
436 | + AS2( cmp REG_iterationCount, 4) |
---|
437 | + ASJ( jge, 1, b) |
---|
438 | + AS_POP_IF86( sp) |
---|
439 | + |
---|
440 | + ASL(5) |
---|
441 | + AS2( sub REG_iterationCount, 1) |
---|
442 | + ASJ( jl, 4, f) |
---|
443 | + AS2( movdqa xmm0, [REG_state + 0*16]) |
---|
444 | + AS2( movdqa xmm1, [REG_state + 1*16]) |
---|
445 | + AS2( movdqa xmm2, [REG_state + 2*16]) |
---|
446 | + AS2( movdqa xmm3, [REG_state + 3*16]) |
---|
447 | + AS2( mov REG_roundsLeft, REG_rounds) |
---|
448 | + |
---|
449 | + ASL(0) |
---|
450 | + SSE2_QUARTER_ROUND(0, 1, 3, 7) |
---|
451 | + SSE2_QUARTER_ROUND(1, 2, 0, 9) |
---|
452 | + SSE2_QUARTER_ROUND(2, 3, 1, 13) |
---|
453 | + SSE2_QUARTER_ROUND(3, 0, 2, 18) |
---|
454 | + ASS( pshufd xmm1, xmm1, 2, 1, 0, 3) |
---|
455 | + ASS( pshufd xmm2, xmm2, 1, 0, 3, 2) |
---|
456 | + ASS( pshufd xmm3, xmm3, 0, 3, 2, 1) |
---|
457 | + SSE2_QUARTER_ROUND(0, 3, 1, 7) |
---|
458 | + SSE2_QUARTER_ROUND(3, 2, 0, 9) |
---|
459 | + SSE2_QUARTER_ROUND(2, 1, 3, 13) |
---|
460 | + SSE2_QUARTER_ROUND(1, 0, 2, 18) |
---|
461 | + ASS( pshufd xmm1, xmm1, 0, 3, 2, 1) |
---|
462 | + ASS( pshufd xmm2, xmm2, 1, 0, 3, 2) |
---|
463 | + ASS( pshufd xmm3, xmm3, 2, 1, 0, 3) |
---|
464 | + AS2( sub REG_roundsLeft, 2) |
---|
465 | + ASJ( jnz, 0, b) |
---|
466 | + |
---|
467 | + AS2( paddd xmm0, [REG_state + 0*16]) |
---|
468 | + AS2( paddd xmm1, [REG_state + 1*16]) |
---|
469 | + AS2( paddd xmm2, [REG_state + 2*16]) |
---|
470 | + AS2( paddd xmm3, [REG_state + 3*16]) |
---|
471 | + |
---|
472 | + AS2( add dword ptr [REG_state + 8*4], 1) |
---|
473 | + AS2( adc dword ptr [REG_state + 5*4], 0) |
---|
474 | + |
---|
475 | + AS2( pcmpeqb xmm6, xmm6) // all ones |
---|
476 | + AS2( psrlq xmm6, 32) // lo32 mask |
---|
477 | + ASS( pshufd xmm7, xmm6, 0, 1, 2, 3) // hi32 mask |
---|
478 | + AS2( movdqa xmm4, xmm0) |
---|
479 | + AS2( movdqa xmm5, xmm3) |
---|
480 | + AS2( pand xmm0, xmm7) |
---|
481 | + AS2( pand xmm4, xmm6) |
---|
482 | + AS2( pand xmm3, xmm6) |
---|
483 | + AS2( pand xmm5, xmm7) |
---|
484 | + AS2( por xmm4, xmm5) // 0,13,2,15 |
---|
485 | + AS2( movdqa xmm5, xmm1) |
---|
486 | + AS2( pand xmm1, xmm7) |
---|
487 | + AS2( pand xmm5, xmm6) |
---|
488 | + AS2( por xmm0, xmm5) // 4,1,6,3 |
---|
489 | + AS2( pand xmm6, xmm2) |
---|
490 | + AS2( pand xmm2, xmm7) |
---|
491 | + AS2( por xmm1, xmm6) // 8,5,10,7 |
---|
492 | + AS2( por xmm2, xmm3) // 12,9,14,11 |
---|
493 | + |
---|
494 | + AS2( movdqa xmm5, xmm4) |
---|
495 | + AS2( movdqa xmm6, xmm0) |
---|
496 | + AS3( shufpd xmm4, xmm1, 2) // 0,13,10,7 |
---|
497 | + AS3( shufpd xmm0, xmm2, 2) // 4,1,14,11 |
---|
498 | + AS3( shufpd xmm1, xmm5, 2) // 8,5,2,15 |
---|
499 | + AS3( shufpd xmm2, xmm6, 2) // 12,9,6,3 |
---|
500 | + |
---|
501 | + // output keystream |
---|
502 | + AS_XMM_OUTPUT4(SSE2_Salsa_Output_B, REG_input, REG_output, 4, 0, 1, 2, 3, 0, 1, 2, 3, 4) |
---|
503 | + ASJ( jmp, 5, b) |
---|
504 | + ASL(4) |
---|
505 | + |
---|
506 | + AS_POP_IF86( bp) |
---|
507 | +#ifdef __GNUC__ |
---|
508 | + AS_POP_IF86( bx) |
---|
509 | + ".att_syntax prefix;" |
---|
510 | + : |
---|
511 | + #if CRYPTOPP_BOOL_X64 |
---|
512 | + : "r" (m_rounds), "r" (input), "r" (iterationCount), "r" (m_state.data()), "r" (output), "r" (workspace.m_ptr) |
---|
513 | + : "%eax", "%edx", "memory", "cc", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11", "%xmm12", "%xmm13", "%xmm14", "%xmm15" |
---|
514 | + #else |
---|
515 | + : "d" (m_rounds), "a" (input), "c" (iterationCount), "S" (m_state.data()), "D" (output) |
---|
516 | + : "memory", "cc" |
---|
517 | + #endif |
---|
518 | + ); |
---|
519 | +#endif |
---|
520 | +#ifdef CRYPTOPP_GENERATE_X64_MASM |
---|
521 | + movdqa xmm6, [rsp + 0200h] |
---|
522 | + movdqa xmm7, [rsp + 0210h] |
---|
523 | + movdqa xmm8, [rsp + 0220h] |
---|
524 | + movdqa xmm9, [rsp + 0230h] |
---|
525 | + movdqa xmm10, [rsp + 0240h] |
---|
526 | + movdqa xmm11, [rsp + 0250h] |
---|
527 | + movdqa xmm12, [rsp + 0260h] |
---|
528 | + movdqa xmm13, [rsp + 0270h] |
---|
529 | + movdqa xmm14, [rsp + 0280h] |
---|
530 | + movdqa xmm15, [rsp + 0290h] |
---|
531 | + add rsp, 10*16 + 32*16 + 8 |
---|
532 | + ret |
---|
533 | +Salsa20_OperateKeystream ENDP |
---|
534 | +#else |
---|
535 | + } |
---|
536 | + else |
---|
537 | +#endif |
---|
538 | +#endif |
---|
539 | +#ifndef CRYPTOPP_GENERATE_X64_MASM |
---|
540 | + { |
---|
541 | + word32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; |
---|
542 | + |
---|
543 | + while (iterationCount--) |
---|
544 | + { |
---|
545 | + x0 = m_state[0]; x1 = m_state[1]; x2 = m_state[2]; x3 = m_state[3]; |
---|
546 | + x4 = m_state[4]; x5 = m_state[5]; x6 = m_state[6]; x7 = m_state[7]; |
---|
547 | + x8 = m_state[8]; x9 = m_state[9]; x10 = m_state[10]; x11 = m_state[11]; |
---|
548 | + x12 = m_state[12]; x13 = m_state[13]; x14 = m_state[14]; x15 = m_state[15]; |
---|
549 | + |
---|
550 | + for (int i=m_rounds; i>0; i-=2) |
---|
551 | + { |
---|
552 | + #define QUARTER_ROUND(a, b, c, d) \ |
---|
553 | + b = b ^ rotlFixed(a + d, 7); \ |
---|
554 | + c = c ^ rotlFixed(b + a, 9); \ |
---|
555 | + d = d ^ rotlFixed(c + b, 13); \ |
---|
556 | + a = a ^ rotlFixed(d + c, 18); |
---|
557 | + |
---|
558 | + QUARTER_ROUND(x0, x4, x8, x12) |
---|
559 | + QUARTER_ROUND(x1, x5, x9, x13) |
---|
560 | + QUARTER_ROUND(x2, x6, x10, x14) |
---|
561 | + QUARTER_ROUND(x3, x7, x11, x15) |
---|
562 | + |
---|
563 | + QUARTER_ROUND(x0, x13, x10, x7) |
---|
564 | + QUARTER_ROUND(x1, x14, x11, x4) |
---|
565 | + QUARTER_ROUND(x2, x15, x8, x5) |
---|
566 | + QUARTER_ROUND(x3, x12, x9, x6) |
---|
567 | + } |
---|
568 | + |
---|
569 | + #define SALSA_OUTPUT(x) {\ |
---|
570 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 0, x0 + m_state[0]);\ |
---|
571 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 1, x13 + m_state[13]);\ |
---|
572 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 2, x10 + m_state[10]);\ |
---|
573 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 3, x7 + m_state[7]);\ |
---|
574 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 4, x4 + m_state[4]);\ |
---|
575 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 5, x1 + m_state[1]);\ |
---|
576 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 6, x14 + m_state[14]);\ |
---|
577 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 7, x11 + m_state[11]);\ |
---|
578 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 8, x8 + m_state[8]);\ |
---|
579 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 9, x5 + m_state[5]);\ |
---|
580 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 10, x2 + m_state[2]);\ |
---|
581 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 11, x15 + m_state[15]);\ |
---|
582 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 12, x12 + m_state[12]);\ |
---|
583 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 13, x9 + m_state[9]);\ |
---|
584 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 14, x6 + m_state[6]);\ |
---|
585 | + CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, LITTLE_ENDIAN_ORDER, 15, x3 + m_state[3]);} |
---|
586 | + |
---|
587 | +#ifndef CRYPTOPP_DOXYGEN_PROCESSING |
---|
588 | + CRYPTOPP_KEYSTREAM_OUTPUT_SWITCH(SALSA_OUTPUT, BYTES_PER_ITERATION); |
---|
589 | +#endif |
---|
590 | + |
---|
591 | + if (++m_state[8] == 0) |
---|
592 | + ++m_state[5]; |
---|
593 | + } |
---|
594 | + } |
---|
595 | +} // see comment above if an internal compiler error occurs here |
---|
596 | + |
---|
597 | +void XSalsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) |
---|
598 | +{ |
---|
599 | + m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20); |
---|
600 | + |
---|
601 | + if (!(m_rounds == 8 || m_rounds == 12 || m_rounds == 20)) |
---|
602 | + throw InvalidRounds(XSalsa20::StaticAlgorithmName(), m_rounds); |
---|
603 | + |
---|
604 | + GetUserKey(LITTLE_ENDIAN_ORDER, m_key.begin(), m_key.size(), key, length); |
---|
605 | + if (length == 16) |
---|
606 | + memcpy(m_key.begin()+4, m_key.begin(), 16); |
---|
607 | + |
---|
608 | + // "expand 32-byte k" |
---|
609 | + m_state[0] = 0x61707865; |
---|
610 | + m_state[1] = 0x3320646e; |
---|
611 | + m_state[2] = 0x79622d32; |
---|
612 | + m_state[3] = 0x6b206574; |
---|
613 | +} |
---|
614 | + |
---|
615 | +void XSalsa20_Policy::CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length) |
---|
616 | +{ |
---|
617 | + assert(length==24); |
---|
618 | + |
---|
619 | + word32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; |
---|
620 | + |
---|
621 | + GetBlock<word32, LittleEndian> get(IV); |
---|
622 | + get(x14)(x11)(x8)(x5)(m_state[14])(m_state[11]); |
---|
623 | + |
---|
624 | + x13 = m_key[0]; x10 = m_key[1]; x7 = m_key[2]; x4 = m_key[3]; |
---|
625 | + x15 = m_key[4]; x12 = m_key[5]; x9 = m_key[6]; x6 = m_key[7]; |
---|
626 | + x0 = m_state[0]; x1 = m_state[1]; x2 = m_state[2]; x3 = m_state[3]; |
---|
627 | + |
---|
628 | + for (int i=m_rounds; i>0; i-=2) |
---|
629 | + { |
---|
630 | + QUARTER_ROUND(x0, x4, x8, x12) |
---|
631 | + QUARTER_ROUND(x1, x5, x9, x13) |
---|
632 | + QUARTER_ROUND(x2, x6, x10, x14) |
---|
633 | + QUARTER_ROUND(x3, x7, x11, x15) |
---|
634 | + |
---|
635 | + QUARTER_ROUND(x0, x13, x10, x7) |
---|
636 | + QUARTER_ROUND(x1, x14, x11, x4) |
---|
637 | + QUARTER_ROUND(x2, x15, x8, x5) |
---|
638 | + QUARTER_ROUND(x3, x12, x9, x6) |
---|
639 | + } |
---|
640 | + |
---|
641 | + m_state[13] = x0; m_state[10] = x1; m_state[7] = x2; m_state[4] = x3; |
---|
642 | + m_state[15] = x14; m_state[12] = x11; m_state[9] = x8; m_state[6] = x5; |
---|
643 | + m_state[8] = m_state[5] = 0; |
---|
644 | +} |
---|
645 | + |
---|
646 | +NAMESPACE_END |
---|
647 | + |
---|
648 | +#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM |
---|
649 | addfile ./cryptopp/salsa.h |
---|
650 | hunk ./cryptopp/salsa.h 1 |
---|
651 | +// salsa.h - written and placed in the public domain by Wei Dai |
---|
652 | + |
---|
653 | +#ifndef CRYPTOPP_SALSA_H |
---|
654 | +#define CRYPTOPP_SALSA_H |
---|
655 | + |
---|
656 | +#include "strciphr.h" |
---|
657 | + |
---|
658 | +NAMESPACE_BEGIN(CryptoPP) |
---|
659 | + |
---|
660 | +//! _ |
---|
661 | +struct Salsa20_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInterface::UNIQUE_IV, 8> |
---|
662 | +{ |
---|
663 | + static const char *StaticAlgorithmName() {return "Salsa20";} |
---|
664 | +}; |
---|
665 | + |
---|
666 | +class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy<word32, 16> |
---|
667 | +{ |
---|
668 | +protected: |
---|
669 | + void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); |
---|
670 | + void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); |
---|
671 | + void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length); |
---|
672 | + bool CipherIsRandomAccess() const {return true;} |
---|
673 | + void SeekToIteration(lword iterationCount); |
---|
674 | +#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64 |
---|
675 | + unsigned int GetAlignment() const; |
---|
676 | + unsigned int GetOptimalBlockSize() const; |
---|
677 | +#endif |
---|
678 | + |
---|
679 | + FixedSizeAlignedSecBlock<word32, 16> m_state; |
---|
680 | + int m_rounds; |
---|
681 | +}; |
---|
682 | + |
---|
683 | +/// <a href="http://www.cryptolounge.org/wiki/Salsa20">Salsa20</a>, variable rounds: 8, 12 or 20 (default 20) |
---|
684 | +struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation |
---|
685 | +{ |
---|
686 | + typedef SymmetricCipherFinal<ConcretePolicyHolder<Salsa20_Policy, AdditiveCipherTemplate<> >, Salsa20_Info> Encryption; |
---|
687 | + typedef Encryption Decryption; |
---|
688 | +}; |
---|
689 | + |
---|
690 | +//! _ |
---|
691 | +struct XSalsa20_Info : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_IV, 24> |
---|
692 | +{ |
---|
693 | + static const char *StaticAlgorithmName() {return "XSalsa20";} |
---|
694 | +}; |
---|
695 | + |
---|
696 | +class CRYPTOPP_NO_VTABLE XSalsa20_Policy : public Salsa20_Policy |
---|
697 | +{ |
---|
698 | +public: |
---|
699 | + void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); |
---|
700 | + void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length); |
---|
701 | + |
---|
702 | +protected: |
---|
703 | + FixedSizeSecBlock<word32, 8> m_key; |
---|
704 | +}; |
---|
705 | + |
---|
706 | +/// <a href="http://www.cryptolounge.org/wiki/XSalsa20">XSalsa20</a>, variable rounds: 8, 12 or 20 (default 20) |
---|
707 | +struct XSalsa20 : public XSalsa20_Info, public SymmetricCipherDocumentation |
---|
708 | +{ |
---|
709 | + typedef SymmetricCipherFinal<ConcretePolicyHolder<XSalsa20_Policy, AdditiveCipherTemplate<> >, XSalsa20_Info> Encryption; |
---|
710 | + typedef Encryption Decryption; |
---|
711 | +}; |
---|
712 | + |
---|
713 | +NAMESPACE_END |
---|
714 | + |
---|
715 | +#endif |
---|
716 | addfile ./pycryptopp/cipher/xsalsa.py |
---|
717 | hunk ./pycryptopp/cipher/xsalsa.py 1 |
---|
718 | +#!/usr/bin/env python |
---|
719 | +from pycryptopp import _import_my_names |
---|
720 | + |
---|
721 | +_import_my_names(globals(), "xsalsa_") |
---|
722 | + |
---|
723 | +del _import_my_names |
---|
724 | + |
---|
725 | addfile ./pycryptopp/cipher/xsalsamodule.cpp |
---|
726 | hunk ./pycryptopp/cipher/xsalsamodule.cpp 1 |
---|
727 | +/** |
---|
728 | + * xsalsamodule.cpp -- Python wrappers around Crypto++'s salsa |
---|
729 | + */ |
---|
730 | + |
---|
731 | +#define PY_SSIZE_T_CLEAN |
---|
732 | +#include <Python.h> |
---|
733 | +#if (PY_VERSION_HEX < 0x02050000) |
---|
734 | +typedef int Py_ssize_t; |
---|
735 | +#endif |
---|
736 | + |
---|
737 | +#include "xsalsamodule.hpp" |
---|
738 | + |
---|
739 | +#ifdef USE_NAME_CRYPTO_PLUS_PLUS |
---|
740 | +//#include <crypto++/modes.h> |
---|
741 | +#include <crypto++/salsa.h> |
---|
742 | +#else |
---|
743 | +//#include <cryptopp/modes.h> |
---|
744 | +#include <cryptopp/salsa.h> |
---|
745 | +#endif |
---|
746 | + |
---|
747 | +static const char* const xsalsa__doc__ = "_xsalsa cipher"; |
---|
748 | + |
---|
749 | +static PyObject *xsalsa_error; |
---|
750 | + |
---|
751 | +typedef struct { |
---|
752 | + PyObject_HEAD |
---|
753 | + |
---|
754 | + /* internal */ |
---|
755 | +// CryptoPP::CTR_Mode<CryptoPP::XSalsa20>::Encryption *e; |
---|
756 | + CryptoPP::XSalsa20::Encryption *e; |
---|
757 | +} XSalsa; |
---|
758 | + |
---|
759 | +PyDoc_STRVAR(XSalsa__doc__, |
---|
760 | +"An XSalsa20 cipher object.\n\ |
---|
761 | +\n\ |
---|
762 | +This object encrypts/decrypts in CTR mode, using a counter that is initialized\n\ |
---|
763 | +to zero when you instantiate the object. Successive calls to .process() will \n\ |
---|
764 | +use the current counter and increment it.\n\ |
---|
765 | +\n\ |
---|
766 | +"); |
---|
767 | + |
---|
768 | +static PyObject *XSalsa_process(XSalsa* self, PyObject* msgobj) { |
---|
769 | + if(!PyString_CheckExact(msgobj)) { |
---|
770 | + PyStringObject* typerepr = reinterpret_cast<PyStringObject*>(PyObject_Repr(reinterpret_cast<PyObject*>(msgobj->ob_type))); |
---|
771 | + if (typerepr) { |
---|
772 | + PyErr_Format(xsalsa_error, "Precondition violation: you are required to pass a Python string object (not a unicode, a subclass of string, or anything else), but you passed %s.", PyString_AS_STRING(reinterpret_cast<PyObject*>(typerepr))); |
---|
773 | + Py_DECREF(typerepr); |
---|
774 | + } else |
---|
775 | + PyErr_Format(xsalsa_error, "Precondition violation: you are required to pass a Python string object (not a unicode, a subclass of string, or anything else)."); |
---|
776 | + return NULL; |
---|
777 | + } |
---|
778 | + |
---|
779 | + const char* msg; |
---|
780 | + Py_ssize_t msgsize; |
---|
781 | + if (PyString_AsStringAndSize(msgobj, const_cast<char**>(&msg), &msgsize)) |
---|
782 | + return NULL; |
---|
783 | + assert (msgsize >= 0); |
---|
784 | + |
---|
785 | + PyStringObject* result = reinterpret_cast<PyStringObject*>(PyString_FromStringAndSize(NULL, msgsize)); |
---|
786 | + if (!result) |
---|
787 | + return NULL; |
---|
788 | + |
---|
789 | + self->e->ProcessString(reinterpret_cast<byte*>(PyString_AS_STRING(result)), reinterpret_cast<const byte*>(msg), msgsize); |
---|
790 | + return reinterpret_cast<PyObject*>(result); |
---|
791 | +} |
---|
792 | + |
---|
793 | +PyDoc_STRVAR(XSalsa_process__doc__, |
---|
794 | +"Encrypt or decrypt the next bytes, returning the result."); |
---|
795 | + |
---|
796 | +static PyMethodDef XSalsa_methods[] = { |
---|
797 | + {"process", reinterpret_cast<PyCFunction>(XSalsa_process), METH_O, XSalsa_process__doc__}, |
---|
798 | + {NULL}, |
---|
799 | +}; |
---|
800 | + |
---|
801 | +static PyObject* XSalsa_new(PyTypeObject* type, PyObject *args, PyObject *kwdict) { |
---|
802 | + XSalsa* self = reinterpret_cast<XSalsa*>(type->tp_alloc(type, 0)); |
---|
803 | + if (!self) |
---|
804 | + return NULL; |
---|
805 | + self->e = NULL; |
---|
806 | + return reinterpret_cast<PyObject*>(self); |
---|
807 | +} |
---|
808 | + |
---|
809 | +static void XSalsa_dealloc(PyObject* self) { |
---|
810 | + if (reinterpret_cast<XSalsa*>(self)->e) |
---|
811 | + delete reinterpret_cast<XSalsa*>(self)->e; |
---|
812 | + self->ob_type->tp_free(self); |
---|
813 | +} |
---|
814 | + |
---|
815 | +static int XSalsa_init(PyObject* self, PyObject *args, PyObject *kwdict) { |
---|
816 | + static const char *kwlist[] = { "key", "iv", NULL}; |
---|
817 | + const char *key = NULL; |
---|
818 | + Py_ssize_t keysize = 0; |
---|
819 | + const char *iv = NULL; |
---|
820 | + const char defaultiv[24] = {0}; |
---|
821 | + Py_ssize_t ivsize = 0; |
---|
822 | + if (!PyArg_ParseTupleAndKeywords(args, kwdict, "t#|t#:XSalsa.__init__", const_cast<char**>(kwlist), &key, &keysize, &iv, &ivsize)) |
---|
823 | + return -1; |
---|
824 | + assert (keysize >= 0); |
---|
825 | + assert (ivsize >= 0); |
---|
826 | + |
---|
827 | + if(!iv) |
---|
828 | + iv = defaultiv; |
---|
829 | + try { |
---|
830 | + reinterpret_cast<XSalsa*>(self)->e = new CryptoPP::XSalsa20::Encryption(reinterpret_cast<const byte*>(key), keysize, reinterpret_cast<const byte*>(iv)); |
---|
831 | + } |
---|
832 | + catch (CryptoPP::InvalidKeyLength le) |
---|
833 | + { |
---|
834 | + PyErr_Format(xsalsa_error, "Precondition violation: you are required to pass a valid key size. Crypto++ gave this exception: %s", le.what()); |
---|
835 | + return -1; |
---|
836 | + } |
---|
837 | + if (!reinterpret_cast<XSalsa*>(self)->e) |
---|
838 | + { |
---|
839 | + PyErr_NoMemory(); |
---|
840 | + return -1; |
---|
841 | + } |
---|
842 | + return 0; |
---|
843 | +} |
---|
844 | + |
---|
845 | + |
---|
846 | +static PyTypeObject XSalsa_type = { |
---|
847 | + PyObject_HEAD_INIT(NULL) |
---|
848 | + 0, /*ob_size*/ |
---|
849 | + "_xsalsa.XSalsa", /*tp_name*/ |
---|
850 | + sizeof(XSalsa), /*tp_basicsize*/ |
---|
851 | + 0, /*tp_itemsize*/ |
---|
852 | + XSalsa_dealloc, /*tp_dealloc*/ |
---|
853 | + 0, /*tp_print*/ |
---|
854 | + 0, /*tp_getattr*/ |
---|
855 | + 0, /*tp_setattr*/ |
---|
856 | + 0, /*tp_compare*/ |
---|
857 | + 0, /*tp_repr*/ |
---|
858 | + 0, /*tp_as_number*/ |
---|
859 | + 0, /*tp_as_sequence*/ |
---|
860 | + 0, /*tp_as_mapping*/ |
---|
861 | + 0, /*tp_hash*/ |
---|
862 | + 0, /*tp_call*/ |
---|
863 | + 0, /*tp_str*/ |
---|
864 | + 0, /*tp_getattro*/ |
---|
865 | + 0, /*tp_setattro*/ |
---|
866 | + 0, /*tp_as_buffer*/ |
---|
867 | + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ |
---|
868 | + XSalsa__doc__, /*tp_doc*/ |
---|
869 | + 0, /*tp_traverse*/ |
---|
870 | + 0, /*tp_clear*/ |
---|
871 | + 0, /*tp_richcompare*/ |
---|
872 | + 0, /*tp_weaklistoffset*/ |
---|
873 | + 0, /*tp_iter*/ |
---|
874 | + 0, /*tp_iternext*/ |
---|
875 | + XSalsa_methods, /*tp_methods*/ |
---|
876 | + 0, /*tp_members*/ |
---|
877 | + 0, /*tp_getset*/ |
---|
878 | + 0, /*tp_base*/ |
---|
879 | + 0, /*tp_dict*/ |
---|
880 | + 0, /*tp_descr_get*/ |
---|
881 | + 0, /*tp_descr_set*/ |
---|
882 | + 0, /*tp_dictoffset*/ |
---|
883 | + XSalsa_init, /*tp_init*/ |
---|
884 | + 0, /*tp_alloc*/ |
---|
885 | + XSalsa_new, /*tp_new*/ |
---|
886 | +}; |
---|
887 | + |
---|
888 | +void init_xsalsa(PyObject*const module) |
---|
889 | +{ |
---|
890 | + if (PyType_Ready(&XSalsa_type) < 0) |
---|
891 | + return; |
---|
892 | + Py_INCREF(&XSalsa_type); |
---|
893 | + PyModule_AddObject(module, "xsalsa_XSalsa", (PyObject *)&XSalsa_type); |
---|
894 | + |
---|
895 | + xsalsa_error = PyErr_NewException(const_cast<char*>("_xsalsa.Error"), NULL, NULL); |
---|
896 | + PyModule_AddObject(module, "xsalsa_Error", xsalsa_error); |
---|
897 | + |
---|
898 | + PyModule_AddStringConstant(module, "xsalsa__doc__", const_cast<char*>(xsalsa__doc__)); |
---|
899 | +} |
---|
900 | addfile ./pycryptopp/cipher/xsalsamodule.hpp |
---|
901 | hunk ./pycryptopp/cipher/xsalsamodule.hpp 1 |
---|
902 | +#ifndef __INCL_XSALSAMODULE_HPP |
---|
903 | +#define __INCL_XSALSAMODULE_HPP |
---|
904 | + |
---|
905 | +extern void init_xsalsa(PyObject* module); |
---|
906 | + |
---|
907 | +#endif; /*#ifndef __INCL_XSALSAMODULE_HPP*/ |
---|
908 | addfile ./pycryptopp/test/test_xsalsa.py |
---|
909 | hunk ./pycryptopp/test/test_xsalsa.py 1 |
---|
910 | +#!/usr/bin/env python |
---|
911 | + |
---|
912 | +import random, re |
---|
913 | +import unittest |
---|
914 | + |
---|
915 | +from binascii import a2b_hex, b2a_hex |
---|
916 | +from pkg_resources import resource_string |
---|
917 | + |
---|
918 | +from pycryptopp.cipher import xsalsa |
---|
919 | +TEST_XSALSA_RE=re.compile("\nCOUNT=([0-9]+)\nKEY=([0-9a-f]+)\nIV=([0-9a-f]+)\nPLAINTEXT=([0-9a-f]+)\nCIPHERTEXT=([0-9a-f]+)") |
---|
920 | + |
---|
921 | +class XSalsaTest(unittest.TestCase): |
---|
922 | + |
---|
923 | + enc0="eea6a7251c1e72916d11c2cb214d3c252539121d8e234e652d651fa4c8cff880309e645a74e9e0a60d8243acd9177ab51a1beb8d5a2f5d700c093c5e5585579625337bd3ab619d615760d8c5b224a85b1d0efe0eb8a7ee163abb0376529fcc09bab506c618e13ce777d82c3ae9d1a6f972d4160287cbfe60bf2130fc0a6ff6049d0a5c8a82f429231f0080" |
---|
924 | + |
---|
925 | + def test_zero_XSalsa(self): |
---|
926 | + key="1b27556473e985d462cd51197a9a46c76009549eac6474f206c4ee0844f68389" |
---|
927 | + iv="69696ee955b62b73cd62bda875fc73d68219e0036b7a0b37" |
---|
928 | + computedcipher=xsalsa.XSalsa(a2b_hex(key),a2b_hex(iv)).process('\x00'*139) |
---|
929 | + self.failUnlessEqual(a2b_hex(self.enc0), computedcipher, "enc0: %s, computedciper: %s" % (self.enc0, b2a_hex(computedcipher))) |
---|
930 | + |
---|
931 | + cryptor=xsalsa.XSalsa(a2b_hex(key),a2b_hex(iv)) |
---|
932 | + |
---|
933 | + computedcipher1=cryptor.process('\x00'*69) |
---|
934 | + computedcipher2=cryptor.process('\x00'*69) |
---|
935 | + computedcipher3=cryptor.process('\x00') |
---|
936 | + computedcipher12=b2a_hex(computedcipher1)+b2a_hex(computedcipher2)+b2a_hex(computedcipher3) |
---|
937 | + self.failUnlessEqual(self.enc0, computedcipher12) |
---|
938 | + |
---|
939 | + def test_XSalsa(self): |
---|
940 | + curfile = open( '../testvectors/testx1.txt', 'r') |
---|
941 | + s = curfile.read() |
---|
942 | + print s,"\n" |
---|
943 | + return self._test_XSalsa(s) |
---|
944 | + |
---|
945 | + def _test_XSalsa(self, vects_str): |
---|
946 | + for mo in TEST_XSALSA_RE.finditer(vects_str): |
---|
947 | + count = int(mo.group(1)) |
---|
948 | + key = a2b_hex(mo.group(2)) |
---|
949 | + iv = a2b_hex(mo.group(3)) |
---|
950 | +# plaintext = a2b_hex(mo.group(4)) |
---|
951 | +# ciphertext= a2b_hex(mo.group(5)) |
---|
952 | + plaintext = mo.group(4) |
---|
953 | + ciphertext = mo.group(5) |
---|
954 | + computedcipher=xsalsa.XSalsa(key,iv).process(a2b_hex(plaintext)) |
---|
955 | +# print "ciphertext", b2a_hex(computedcipher), '\n' |
---|
956 | +# print "computedtext", ciphertext, '\n' |
---|
957 | +# print count, ": \n" |
---|
958 | + self.failUnlessEqual(computedcipher,a2b_hex(ciphertext),"computedcipher: %s, ciphertext: %s" % (b2a_hex(computedcipher), ciphertext)) |
---|
959 | + |
---|
960 | + #the random decomposing |
---|
961 | + plaintext1 = "" |
---|
962 | + plaintext2 = "" |
---|
963 | + length = len(plaintext) |
---|
964 | + rccipher = "" |
---|
965 | + cryptor = xsalsa.XSalsa(key,iv) |
---|
966 | + if length > 2: |
---|
967 | + point = random.randint(0,length-3) |
---|
968 | + if (point%2) !=0: |
---|
969 | + point -= 1 |
---|
970 | + plaintext1 += plaintext[:point+2] |
---|
971 | + plaintext2 += plaintext[point+2:] |
---|
972 | + rccipher += b2a_hex(cryptor.process(a2b_hex(plaintext1))) |
---|
973 | + rccipher += b2a_hex(cryptor.process(a2b_hex(plaintext2))) |
---|
974 | + self.failUnlessEqual(rccipher, ciphertext, "random computed cipher: %s, ciphertext: %s" % (rccipher, ciphertext)) |
---|
975 | + |
---|
976 | + #every byte encrypted |
---|
977 | + cryptor = xsalsa.XSalsa(key,iv) |
---|
978 | + eccipher="" |
---|
979 | + l = 0 |
---|
980 | + while l<=(length-2): |
---|
981 | + eccipher += b2a_hex(cryptor.process(a2b_hex(plaintext[l:l+2]))) |
---|
982 | + l += 2 |
---|
983 | + self.failUnlessEqual(eccipher, ciphertext, "every byte computed cipher: %s, ciphertext: %s" % (eccipher, ciphertext)) |
---|
984 | + |
---|
985 | + |
---|
986 | + def test_init_type_check(self): |
---|
987 | + self.failUnlessRaises(TypeError, xsalsa.XSalsa, None) |
---|
988 | + self.failUnlessRaises(xsalsa.Error, xsalsa.XSalsa, "a"*1) |
---|
989 | + self.failUnlessRaises(xsalsa.Error, xsalsa.XSalsa, "a"*17) |
---|
990 | + self.failUnlessRaises(xsalsa.Error, xsalsa.XSalsa, "a"*18) |
---|
991 | +# self.failUnlessRaises(xsalsa.Error, xsalsa.XSalsa, "a"*32) |
---|
992 | + |
---|
993 | +if __name__ == "__main__": |
---|
994 | + unittest.main() |
---|
995 | addfile ./pycryptopp/testvectors/testx1.txt |
---|
996 | hunk ./pycryptopp/testvectors/testx1.txt 1 |
---|
997 | + |
---|
998 | +COUNT=1 |
---|
999 | +KEY=a6a7251c1e72916d11c2cb214d3c252539121d8e234e652d651fa4c8cff88030 |
---|
1000 | +IV=9e645a74e9e0a60d8243acd9177ab51a1beb8d5a2f5d700c |
---|
1001 | +PLAINTEXT=093c5e5585579625337bd3ab619d615760d8c5b224a85b1d0efe0eb8a7ee163abb0376529fcc09bab506c618e13ce777d82c3ae9d1a6f972d4160287cbfe60bf2130fc0a6ff6049d0a5c8a82f429231f008082e845d7e189d37f9ed2b464e6b919e6523a8c1210bd52a02a4c3fe406d3085f5068d1909eeeca6369abc981a42e87fe665583f0ab85ae71f6f84f528e6b397af86f6917d9754b7320dbdc2fea81496f2732f532ac78c4e9c6cfb18f8e9bdf74622eb126141416776971a84f94d156beaf67aecbf2ad412e76e66e8fad7633f5b6d7f3d64b5c6c69ce29003c6024465ae3b89be78e915d88b4b5621d |
---|
1002 | +CIPHERTEXT=b2af688e7d8fc4b508c05cc39dd583d6714322c64d7f3e63147aede2d9534934b04ff6f337b031815cd094bdbc6d7a92077dce709412286822ef0737ee47f6b7ffa22f9d53f11dd2b0a3bb9fc01d9a88f9d53c26e9365c2c3c063bc4840bfc812e4b80463e69d179530b25c158f543191cff993106511aa036043bbc75866ab7e34afc57e2cce4934a5faae6eabe4f221770183dd060467827c27a354159a081275a291f69d946d6fe28ed0b9ce08206cf484925a51b9498dbde178ddd3ae91a8581b91682d860f840782f6eea49dbb9bd721501d2c67122dea3b7283848c5f13e0c0de876bd227a856e4de593a3 |
---|
1003 | + |
---|
1004 | +COUNT=2 |
---|
1005 | +KEY=9e1da239d155f52ad37f75c7368a536668b051952923ad44f57e75ab588e475a |
---|
1006 | +IV=af06f17859dffa799891c4288f6635b5c5a45eee9017fd72 |
---|
1007 | +PLAINTEXT=feac9d54fc8c115ae247d9a7e919dd76cfcbc72d32cae4944860817cbdfb8c04e6b1df76a16517cd33ccf1acda9206389e9e318f5966c093cfb3ec2d9ee2de856437ed581f552f26ac2907609df8c613b9e33d44bfc21ff79153e9ef81a9d66cc317857f752cc175fd8891fefebb7d041e6517c3162d197e2112837d3bc4104312ad35b75ea686e7c70d4ec04746b52ff09c421451459fb59f |
---|
1008 | +CIPHERTEXT=2c261a2f4e61a62e1b27689916bf03453fcbc97bb2af6f329391ef063b5a219bf984d07d70f602d85f6db61474e9d9f5a2deecb4fcd90184d16f3b5b5e168ee03ea8c93f3933a22bc3d1a5ae8c2d8b02757c87c073409052a2a8a41e7f487e041f9a49a0997b540e18621cad3a24f0a56d9b19227929057ab3ba950f6274b121f193e32e06e5388781a1cb57317c0ba6305e910961d01002f0 |
---|
1009 | + |
---|
1010 | +COUNT=3 |
---|
1011 | +KEY=d5c7f6797b7e7e9c1d7fd2610b2abf2bc5a7885fb3ff78092fb3abe8986d35e2 |
---|
1012 | +IV=744e17312b27969d826444640e9c4a378ae334f185369c95 |
---|
1013 | +PLAINTEXT=7758298c628eb3a4b6963c5445ef66971222be5d1a4ad839715d1188071739b77cc6e05d5410f963a64167629757 |
---|
1014 | +CIPHERTEXT=27b8cfe81416a76301fd1eec6a4d99675069b2da2776c360db1bdfea7c0aa613913e10f7a60fec04d11e65f2d64e |
---|
1015 | + |
---|
1016 | +COUNT=4 |
---|
1017 | +KEY=737d7811ce96472efed12258b78122f11deaec8759ccbd71eac6bbefa627785c |
---|
1018 | +IV=6fb2ee3dda6dbd12f1274f126701ec75c35c86607adb3edd |
---|
1019 | +PLAINTEXT=501325fb2645264864df11faa17bbd58312b77cad3d94ac8fb8542f0eb653ad73d7fce932bb874cb89ac39fc47f8267cf0f0c209f204b2d8578a3bdf461cb6a271a468bebaccd9685014ccbc9a73618c6a5e778a21cc8416c60ad24ddc417a130d53eda6dfbfe47d09170a7be1a708b7b5f3ad464310be36d9a2a95dc39e83d38667e842eb6411e8a23712297b165f690c2d7ca1b1346e3c1fccf5cafd4f8be0 |
---|
1020 | +CIPHERTEXT=6724c372d2e9074da5e27a6c54b2d703dc1d4c9b1f8d90f00c122e692ace7700eadca942544507f1375b6581d5a8fb39981c1c0e6e1ff2140b082e9ec016fce141d5199647d43b0b68bfd0fea5e00f468962c7384dd6129aea6a3fdfe75abb210ed5607cef8fa0e152833d5ac37d52e557b91098a322e76a45bbbcf4899e790618aa3f4c2e5e0fc3de93269a577d77a5502e8ea02f717b1dd2df1ec69d8b61ca |
---|
1021 | + |
---|
1022 | +COUNT=5 |
---|
1023 | +KEY=760158da09f89bbab2c99e6997f9523a95fcef10239bcca2573b7105f6898d34 |
---|
1024 | +IV=43636b2cc346fc8b7c85a19bf507bdc3dafe953b88c69dba |
---|
1025 | +PLAINTEXT=d30a6d42dff49f0ed039a306bae9dec8d9e88366cc19e8c3642fd58fa0794ebf8029d949730339b0823a51f0f49f0d2c71f1051c1e0e2c86941f172789cdb1b0107413e70f982ff9761877bb526ef1c3eb1106a948d60ef21bd35d32cfd64f89b79ed63ecc5cca56246af736766f285d8e6b0da9cb1cd21020223ffacc5a32 |
---|
1026 | +CIPHERTEXT=c815b6b79b64f9369aec8dce8c753df8a50f2bc97c70ce2f014db33a65ac5816bac9e30ac08bdded308c65cb87e28e2e71b677dc25c5a6499c1553555daf1f55270a56959dffa0c66f24e0af00951ec4bb59ccc3a6c5f52e0981647e53e439313a52c40fa7004c855b6e6eb25b212a138e843a9ba46edb2a039ee82a263abe |
---|
1027 | + |
---|
1028 | +COUNT=6 |
---|
1029 | +KEY=27ba7e81e7edd4e71be53c07ce8e633138f287e155c7fa9e84c4ad804b7fa1b9 |
---|
1030 | +IV=ea05f4ebcd2fb6b000da0612861ba54ff5c176fb601391aa |
---|
1031 | +PLAINTEXT=e09ff5d2cb050d69b2d42494bde5825238c756d6991d99d7a20d1ef0b83c371c89872690b2fc11d5369f4fc4971b6d3d6c078aef9b0f05c0e61ab89c025168054defeb03fef633858700c58b1262ce011300012673e893e44901dc18eee3105699c44c805897bdaf776af1833162a21a |
---|
1032 | +CIPHERTEXT=a23e7ef93c5d0667c96d9e404dcbe6be62026fa98f7a3ff9ba5d458643a16a1cef7272dc6097a9b52f35983557c77a11b314b4f7d5dc2cca15ee47616f861873cbfed1d32372171a61e38e447f3cf362b3abbb2ed4170d89dcb28187b7bfd206a3e026f084a7e0ed63d319de6bc9afc0 |
---|
1033 | + |
---|
1034 | +COUNT=7 |
---|
1035 | +KEY=6799d76e5ffb5b4920bc2768bafd3f8c16554e65efcf9a16f4683a7a06927c11 |
---|
1036 | +IV=61ab951921e54ff06d9b77f313a4e49df7a057d5fd627989 |
---|
1037 | +PLAINTEXT=472766 |
---|
1038 | +CIPHERTEXT=8fd7df |
---|
1039 | + |
---|
1040 | +COUNT=8 |
---|
1041 | +KEY=f68238c08365bb293d26980a606488d09c2f109edafa0bbae9937b5cc219a49c |
---|
1042 | +IV=5190b51e9b708624820b5abdf4e40fad1fb950ad1adc2d26 |
---|
1043 | +PLAINTEXT=47ec6b1f73c4b7ff5274a0bfd7f45f864812c85a12fbcb3c2cf8a3e90cf66ccf2eacb521e748363c77f52eb426ae57a0c6c78f75af71284569e79d1a92f949a9d69c4efc0b69902f1e36d7562765543e2d3942d9f6ff5948d8a312cff72c1afd9ea3088aff7640bfd265f7a9946e606abc77bcedae6bddc75a0dba0bd917d73e3bd1268f727e0096345da1ed25cf553ea7a98fea6b6f285732de37431561ee1b3064887fbcbd71935e02 |
---|
1044 | +CIPHERTEXT=36160e88d3500529ba4edba17bc24d8cfaca9a0680b3b1fc97cf03f3675b7ac301c883a68c071bc54acdd3b63af4a2d72f985e51f9d60a4c7fd481af10b2fc75e252fdee7ea6b6453190617dcc6e2fe1cd56585fc2f0b0e97c5c3f8ad7eb4f31bc4890c03882aac24cc53acc1982296526690a220271c2f6e326750d3fbda5d5b63512c831f67830f59ac49aae330b3e0e02c9ea0091d19841f1b0e13d69c9fbfe8a12d6f30bb734d9d2 |
---|
1045 | + |
---|
1046 | +COUNT=9 |
---|
1047 | +KEY=45b2bd0de4ed9293ec3e26c4840faaf64b7d619d51e9d7a2c7e36c83d584c3df |
---|
1048 | +IV=546c8c5d6be8f90952cab3f36d7c1957baaa7a59abe3d7e5 |
---|
1049 | +PLAINTEXT=5007c8cd5b3c40e17d7fe423a87ae0ced86bec1c39dc07a25772f3e96dabd56cd3fd7319f6c9654925f2d87087a700e1b130da796895d1c9b9acd62b266144067d373ed51e787498b03c52faad16bb3826fa511b0ed2a19a8663f5ba2d6ea7c38e7212e9697d91486c49d8a000b9a1935d6a7ff7ef23e720a45855481440463b4ac8c4f6e7062adc1f1e1e25d3d65a31812f58a71160 |
---|
1050 | +CIPHERTEXT=8eacfba568898b10c0957a7d44100685e8763a71a69a8d16bc7b3f88085bb9a2f09642e4d09a9f0ad09d0aad66b22610c8bd02ff6679bb92c2c026a216bf425c6be35fb8dae7ff0c72b0efd6a18037c70eed0ca90062a49a3c97fdc90a8f9c2ea536bfdc41918a7582c9927fae47efaa3dc87967b7887dee1bf071734c7665901d9105dae2fdf66b4918e51d8f4a48c60d19fbfbbcba |
---|
1051 | + |
---|
1052 | +COUNT=10 |
---|
1053 | +KEY=fe559c9a282beb40814d016d6bfcb2c0c0d8bf077b1110b8703a3ce39d70e0e1 |
---|
1054 | +IV=b076200cc7011259805e18b304092754002723ebec5d6200 |
---|
1055 | +PLAINTEXT=6db65b9ec8b114a944137c821fd606be75478d928366d5284096cdef782fcff7e8f59cb8ffcda979757902c5ffa6bc477ceaa4cb5d5ea76f94d91e833f823a6bc78f1055dfa6a97bea8965c1cde67a668e001257334a585727d9e0f7c1a06e88d3d25a4e6d9096c968bf138e116a3ebeffd4bb4808adb1fd698164ba0a35c709a47f16f1f4435a2345a9194a00b95abd51851d505809a6077da9baca5831afff31578c487ee68f2767974a98a7e803aac788da98319c4ea8eaa3d394855651f484cef543f537e35158ee29 |
---|
1056 | +CIPHERTEXT=4dce9c8f97a028051b0727f34e1b9ef21f06f0760f36e71713204027902090ba2bb6b13436ee778d9f50530efbd7a32b0d41443f58ccaee781c7b716d3a96fdec0e3764ed7959f34c3941278591ea033b5cbadc0f1916032e9bebbd1a8395b83fb63b1454bd775bd20b3a2a96f951246ac14daf68166ba62f6cbff8bd121ac9498ff8852fd2be975df52b5daef3829d18eda42e715022dcbf930d0a789ee6a146c2c7088c35773c63c06b4af4559856ac199ced86863e4294707825337c5857970eb7fddeb263781309011 |
---|
1057 | + |
---|
1058 | +COUNT=11 |
---|
1059 | +KEY=0ae10012d7e56614b03dcc89b14bae9242ffe630f3d7e35ce8bbb97bbc2c92c3 |
---|
1060 | +IV=f96b025d6cf46a8a12ac2af1e2aef1fb83590adadaa5c5ea |
---|
1061 | +PLAINTEXT=ea0f354e96f12bc72bbaa3d12b4a8ed879b042f0689878f46b651cc4116d6f78409b11430b3aaa30b2076891e8e1fa528f2fd169ed93dc9f84e24409eec2101daf4d057be2492d11de640cbd7b355ad29fb70400fffd7cd6d425abeeb732a0eaa4330af4c656252c4173deab653eb85c58462d7ab0f35fd12b613d29d473d330310dc323d3c66348bbdbb68a326324657cae7b77a9e34358f2cec50c85609e73056856796e3be8d62b6e2fe9f953 |
---|
1062 | +CIPHERTEXT=e8abd48924b54e5b80866be7d4ebe5cf4274cafff08b39cb2d40a8f0b472398aedc776e0793812fbf1f60078635d2ed86b15efcdba60411ee23b07233592a44ec31b1013ce8964236675f8f183aef885e864f2a72edf4215b5338fa2b54653dfa1a8c55ce5d95cc605b9b311527f2e3463ffbec78a9d1d65dabad2f338769c9f43f133a791a11c7eca9af0b771a4ac32963dc8f631a2c11217ac6e1b9430c1aae1ceebe22703f429998a8fb8c641 |
---|
1063 | + |
---|
1064 | +COUNT=12 |
---|
1065 | +KEY=082c539bc5b20f97d767cd3f229eda80b2adc4fe49c86329b5cd6250a9877450 |
---|
1066 | +IV=845543502e8b64912d8f2c8d9fffb3c69365686587c08d0c |
---|
1067 | +PLAINTEXT=a96bb7e910281a6dfad7c8a9c370674f0ceec1ad8d4f0de32f9ae4a23ed329e3d6bc708f876640a229153ac0e7281a8188dd77695138f01cda5f41d5215fd5c6bdd46d982cb73b1efe2997970a9fdbdb1e768d7e5db712068d8ba1af6067b5753495e23e6e1963af012f9c7ce450bf2de619d3d59542fb55f3 |
---|
1068 | +CIPHERTEXT=835da74fc6de08cbda277a7966a07c8dcd627e7b17adde6d930b6581e3124b8baad096f693991fedb1572930601fc7709541839b8e3ffd5f033d2060d999c6c6e3048276613e648000acb5212cc632a916afce290e20ebdf612d08a6aa4c79a74b070d3f872a861f8dc6bb07614db515d363349d3a8e3336a3 |
---|
1069 | + |
---|
1070 | +COUNT=13 |
---|
1071 | +KEY=3d02bff3375d403027356b94f514203737ee9a85d2052db3e4e5a217c259d18a |
---|
1072 | +IV=74216c95031895f48c1dba651555ebfa3ca326a755237025 |
---|
1073 | +PLAINTEXT=0d4b0f54fd09ae39baa5fa4baccf2e6682e61b257e01f42b8f |
---|
1074 | +CIPHERTEXT=16c4006c28365190411eb1593814cf15e74c22238f210afc3d |
---|
1075 | + |
---|
1076 | +COUNT=14 |
---|
1077 | +KEY=ad1a5c47688874e6663a0f3fa16fa7efb7ecadc175c468e5432914bdb480ffc6 |
---|
1078 | +IV=e489eed440f1aae1fac8fb7a9825635454f8f8f1f52e2fcc |
---|
1079 | +PLAINTEXT=aa6c1e53580f03a9abb73bfdadedfecada4c6b0ebe020ef10db745e54ba861caf65f0e40dfc520203bb54d29e0a8f78f16b3f1aa525d6bfa33c54726e59988cfbec78056 |
---|
1080 | +CIPHERTEXT=02fe84ce81e178e7aabdd3ba925a766c3c24756eefae33942af75e8b464556b5997e616f3f2dfc7fce91848afd79912d9fb55201b5813a5a074d2c0d4292c1fd441807c5 |
---|
1081 | + |
---|
1082 | +COUNT=15 |
---|
1083 | +KEY=053a02bedd6368c1fb8afc7a1b199f7f7ea2220c9a4b642a6850091c9d20ab9c |
---|
1084 | +IV=c713eea5c26dad75ad3f52451e003a9cb0d649f917c89dde |
---|
1085 | +PLAINTEXT=8f0a8a164760426567e388840276de3f95cb5e3fadc6ed3f3e4fe8bc169d9388804dcb94b6587dbb66cb0bd5f87b8e98b52af37ba290629b858e0e2aa7378047a26602 |
---|
1086 | +CIPHERTEXT=516710e59843e6fbd4f25d0d8ca0ec0d47d39d125e9dad987e0518d49107014cb0ae405e30c2eb3794750bca142ce95e290cf95abe15e822823e2e7d3ab21bc8fbd445 |
---|
1087 | + |
---|
1088 | +COUNT=16 |
---|
1089 | +KEY=5b14ab0fbed4c58952548a6cb1e0000cf4481421f41288ea0aa84add9f7deb96 |
---|
1090 | +IV=54bf52b911231b952ba1a6af8e45b1c5a29d97e2abad7c83 |
---|
1091 | +PLAINTEXT=37fb44a675978b560ff9a4a87011d6f3ad2d37a2c3815b45a3c0e6d1b1d8b1784cd468927c2ee39e1dccd4765e1c3d676a335be1ccd6900a45f5d41a317648315d8a8c24adc64eb285f6aeba05b9029586353d303f17a807658b9ff790474e1737bd5fdc604aeff8dfcaf1427dcc3aacbb0256badcd183ed75a2dc52452f87d3c1ed2aa583472b0ab91cda20614e9b6fdbda3b49b098c95823cc72d8e5b717f2314b0324e9ce |
---|
1092 | +CIPHERTEXT=ae6deb5d6ce43d4b09d0e6b1c0e9f46157bcd8ab50eaa3197ff9fa2bf7af649eb52c68544fd3adfe6b1eb316f1f23538d470c30dbfec7e57b60cbcd096c782e7736b669199c8253e70214cf2a098fda8eac5da79a9496a3aae754d03b17c6d70d1027f42bf7f95ce3d1d9c338854e158fcc803e4d6262fb639521e47116ef78a7a437ca9427ba645cd646832feab822a208278e45e93e118d780b988d65397eddfd7a819526e |
---|
1093 | + |
---|
1094 | +COUNT=17 |
---|
1095 | +KEY=d74636e3413a88d85f322ca80fb0bd650bd0bf0134e2329160b69609cd58a4b0 |
---|
1096 | +IV=efb606aa1d9d9f0f465eaa7f8165f1ac09f5cb46fecf2a57 |
---|
1097 | +PLAINTEXT=f85471b75f6ec81abac2799ec09e98e280b2ffd64ca285e5a0109cfb31ffab2d617b2c2952a2a8a788fc0da2af7f530758f74f1ab56391ab5ff2adbcc5be2d6c7f49fbe8118104c6ff9a23c6dfe52f57954e6a69dcee5db06f514f4a0a572a9a8525d961dae72269b987189d465df6107119c7fa790853e063cba0fab7800ca932e258880fd74c33c784675bedad0e7c09e9cc4d63dd5e9713d5d4a0196e6b562226ac31b4f57c04f90a181973737ddc7e80f364112a9fbb435ebdbcabf7d490ce52 |
---|
1098 | +CIPHERTEXT=b2b795fe6c1d4c83c1327e015a67d4465fd8e32813575cbab263e20ef05864d2dc17e0e4eb81436adfe9f638dcc1c8d78f6b0306baf938e5d2ab0b3e05e735cc6fff2d6e02e3d60484bea7c7a8e13e23197fea7b04d47d48f4a4e5944174539492800d3ef51e2ee5e4c8a0bdf050c2dd3dd74fce5e7e5c37364f7547a11480a3063b9a0a157b15b10a5a954de2731ced055aa2e2767f0891d4329c426f3808ee867bed0dc75b5922b7cfb895700fda016105a4c7b7f0bb90f029f6bbcb04ac36ac16 |
---|
1099 | } |
---|
1100 | |
---|
1101 | Context: |
---|
1102 | |
---|
1103 | [setup: reorganize misc/ to match Tahoe-LAFS's misc/ so that the same buildmaster config can use pycryptopp's and Tahoe-LAFS's |
---|
1104 | zooko@zooko.com**20100607062909 |
---|
1105 | Ignore-this: 500b1eab3ac1983dd72d4d120b48ac64 |
---|
1106 | ] |
---|
1107 | [TAG pycryptopp-0.5.19 |
---|
1108 | zooko@zooko.com**20100604065231 |
---|
1109 | Ignore-this: 923894ad4dca6c77ed31e80c3e4b64e7 |
---|
1110 | ] |
---|
1111 | Patch bundle hash: |
---|
1112 | c7a0ae67a4a949158719430073ebfb5df3a0b517 |
---|