~andersk/ubuntu/oneiric/openssl/spurious-reboot

« back to all changes in this revision

Viewing changes to .pc/perl-path.diff/crypto/perlasm/cbc.pl

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-05-01 23:51:53 UTC
  • mfrom: (11.1.20 sid)
  • Revision ID: james.westby@ubuntu.com-20110501235153-bjcxitndquaezb68
Tags: 1.0.0d-2ubuntu1
* Resynchronise with Debian (LP: #675566).  Remaining changes:
  - debian/libssl1.0.0.postinst:
    + Display a system restart required notification bubble on libssl1.0.0
      upgrade.
    + Use a different priority for libssl1.0.0/restart-services depending
      on whether a desktop, or server dist-upgrade is being performed.
  - debian/{libssl1.0.0-udeb.dirs, control, rules}: Create
    libssl1.0.0-udeb, for the benefit of wget-udeb (no wget-udeb package
    in Debian).
  - debian/{libcrypto1.0.0-udeb.dirs, libssl1.0.0.dirs, libssl1.0.0.files,
    rules}: Move runtime libraries to /lib, for the benefit of
    wpasupplicant.
  - debian/patches/aesni.patch: Backport Intel AES-NI support, now from
    http://rt.openssl.org/Ticket/Display.html?id=2065 rather than the
    0.9.8 variant.
  - debian/patches/Bsymbolic-functions.patch: Link using
    -Bsymbolic-functions.
  - debian/patches/perlpath-quilt.patch: Don't change perl #! paths under
    .pc.
  - debian/rules:
    + Don't run 'make test' when cross-building.
    + Use host compiler when cross-building.  Patch from Neil Williams.
    + Don't build for processors no longer supported: i486, i586 (on
      i386), v8 (on sparc).
    + Fix Makefile to properly clean up libs/ dirs in clean target.
    + Replace duplicate files in the doc directory with symlinks.
* Update architectures affected by Bsymbolic-functions.patch.
* Drop debian/patches/no-sslv2.patch; Debian now adds the 'no-ssl2'
  configure option, which compiles out SSLv2 support entirely, so this is
  no longer needed.
* Drop openssl-doc in favour of the libssl-doc package introduced by
  Debian.  Add Conflicts/Replaces until the next LTS release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/local/bin/perl
2
 
 
3
 
# void des_ncbc_encrypt(input, output, length, schedule, ivec, enc)
4
 
# des_cblock (*input);
5
 
# des_cblock (*output);
6
 
# long length;
7
 
# des_key_schedule schedule;
8
 
# des_cblock (*ivec);
9
 
# int enc;
10
 
#
11
 
# calls 
12
 
# des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
13
 
#
14
 
 
15
 
#&cbc("des_ncbc_encrypt","des_encrypt",0);
16
 
#&cbc("BF_cbc_encrypt","BF_encrypt","BF_encrypt",
17
 
#       1,4,5,3,5,-1);
18
 
#&cbc("des_ncbc_encrypt","des_encrypt","des_encrypt",
19
 
#       0,4,5,3,5,-1);
20
 
#&cbc("des_ede3_cbc_encrypt","des_encrypt3","des_decrypt3",
21
 
#       0,6,7,3,4,5);
22
 
#
23
 
# When doing a cipher that needs bigendian order,
24
 
# for encrypt, the iv is kept in bigendian form,
25
 
# while for decrypt, it is kept in little endian.
26
 
sub cbc
27
 
        {
28
 
        local($name,$enc_func,$dec_func,$swap,$iv_off,$enc_off,$p1,$p2,$p3)=@_;
29
 
        # name is the function name
30
 
        # enc_func and dec_func and the functions to call for encrypt/decrypt
31
 
        # swap is true if byte order needs to be reversed
32
 
        # iv_off is parameter number for the iv 
33
 
        # enc_off is parameter number for the encrypt/decrypt flag
34
 
        # p1,p2,p3 are the offsets for parameters to be passed to the
35
 
        # underlying calls.
36
 
 
37
 
        &function_begin_B($name,"");
38
 
        &comment("");
39
 
 
40
 
        $in="esi";
41
 
        $out="edi";
42
 
        $count="ebp";
43
 
 
44
 
        &push("ebp");
45
 
        &push("ebx");
46
 
        &push("esi");
47
 
        &push("edi");
48
 
 
49
 
        $data_off=4;
50
 
        $data_off+=4 if ($p1 > 0);
51
 
        $data_off+=4 if ($p2 > 0);
52
 
        $data_off+=4 if ($p3 > 0);
53
 
 
54
 
        &mov($count,    &wparam(2));    # length
55
 
 
56
 
        &comment("getting iv ptr from parameter $iv_off");
57
 
        &mov("ebx",     &wparam($iv_off));      # Get iv ptr
58
 
 
59
 
        &mov($in,       &DWP(0,"ebx","",0));#   iv[0]
60
 
        &mov($out,      &DWP(4,"ebx","",0));#   iv[1]
61
 
 
62
 
        &push($out);
63
 
        &push($in);
64
 
        &push($out);    # used in decrypt for iv[1]
65
 
        &push($in);     # used in decrypt for iv[0]
66
 
 
67
 
        &mov("ebx",     "esp");         # This is the address of tin[2]
68
 
 
69
 
        &mov($in,       &wparam(0));    # in
70
 
        &mov($out,      &wparam(1));    # out
71
 
 
72
 
        # We have loaded them all, how lets push things
73
 
        &comment("getting encrypt flag from parameter $enc_off");
74
 
        &mov("ecx",     &wparam($enc_off));     # Get enc flag
75
 
        if ($p3 > 0)
76
 
                {
77
 
                &comment("get and push parameter $p3");
78
 
                if ($enc_off != $p3)
79
 
                        { &mov("eax",   &wparam($p3)); &push("eax"); }
80
 
                else    { &push("ecx"); }
81
 
                }
82
 
        if ($p2 > 0)
83
 
                {
84
 
                &comment("get and push parameter $p2");
85
 
                if ($enc_off != $p2)
86
 
                        { &mov("eax",   &wparam($p2)); &push("eax"); }
87
 
                else    { &push("ecx"); }
88
 
                }
89
 
        if ($p1 > 0)
90
 
                {
91
 
                &comment("get and push parameter $p1");
92
 
                if ($enc_off != $p1)
93
 
                        { &mov("eax",   &wparam($p1)); &push("eax"); }
94
 
                else    { &push("ecx"); }
95
 
                }
96
 
        &push("ebx");           # push data/iv
97
 
 
98
 
        &cmp("ecx",0);
99
 
        &jz(&label("decrypt"));
100
 
 
101
 
        &and($count,0xfffffff8);
102
 
        &mov("eax",     &DWP($data_off,"esp","",0));    # load iv[0]
103
 
        &mov("ebx",     &DWP($data_off+4,"esp","",0));  # load iv[1]
104
 
 
105
 
        &jz(&label("encrypt_finish"));
106
 
 
107
 
        #############################################################
108
 
 
109
 
        &set_label("encrypt_loop");
110
 
        # encrypt start 
111
 
        # "eax" and "ebx" hold iv (or the last cipher text)
112
 
 
113
 
        &mov("ecx",     &DWP(0,$in,"",0));      # load first 4 bytes
114
 
        &mov("edx",     &DWP(4,$in,"",0));      # second 4 bytes
115
 
 
116
 
        &xor("eax",     "ecx");
117
 
        &xor("ebx",     "edx");
118
 
 
119
 
        &bswap("eax")   if $swap;
120
 
        &bswap("ebx")   if $swap;
121
 
 
122
 
        &mov(&DWP($data_off,"esp","",0),        "eax"); # put in array for call
123
 
        &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
124
 
 
125
 
        &call   (&label("pic_point0"));
126
 
        &set_label("pic_point0");
127
 
        &blindpop("ebx");
128
 
        &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point0") . "]");
129
 
        &call("$enc_func\@PLT");
130
 
 
131
 
        &mov("eax",     &DWP($data_off,"esp","",0));
132
 
        &mov("ebx",     &DWP($data_off+4,"esp","",0));
133
 
 
134
 
        &bswap("eax")   if $swap;
135
 
        &bswap("ebx")   if $swap;
136
 
 
137
 
        &mov(&DWP(0,$out,"",0),"eax");
138
 
        &mov(&DWP(4,$out,"",0),"ebx");
139
 
 
140
 
        # eax and ebx are the next iv.
141
 
 
142
 
        &add($in,       8);
143
 
        &add($out,      8);
144
 
 
145
 
        &sub($count,    8);
146
 
        &jnz(&label("encrypt_loop"));
147
 
 
148
 
###################################################################3
149
 
        &set_label("encrypt_finish");
150
 
        &mov($count,    &wparam(2));    # length
151
 
        &and($count,    7);
152
 
        &jz(&label("finish"));
153
 
        &call(&label("PIC_point"));
154
 
&set_label("PIC_point");
155
 
        &blindpop("edx");
156
 
        &lea("ecx",&DWP(&label("cbc_enc_jmp_table")."-".&label("PIC_point"),"edx"));
157
 
        &mov($count,&DWP(0,"ecx",$count,4))
158
 
        &add($count,"edx");
159
 
        &xor("ecx","ecx");
160
 
        &xor("edx","edx");
161
 
        #&mov($count,&DWP(&label("cbc_enc_jmp_table"),"",$count,4));
162
 
        &jmp_ptr($count);
163
 
 
164
 
&set_label("ej7");
165
 
        &xor("edx",             "edx") if $ppro; # ppro friendly
166
 
        &movb(&HB("edx"),       &BP(6,$in,"",0));
167
 
        &shl("edx",8);
168
 
&set_label("ej6");
169
 
        &movb(&HB("edx"),       &BP(5,$in,"",0));
170
 
&set_label("ej5");
171
 
        &movb(&LB("edx"),       &BP(4,$in,"",0));
172
 
&set_label("ej4");
173
 
        &mov("ecx",             &DWP(0,$in,"",0));
174
 
        &jmp(&label("ejend"));
175
 
&set_label("ej3");
176
 
        &movb(&HB("ecx"),       &BP(2,$in,"",0));
177
 
        &xor("ecx",             "ecx") if $ppro; # ppro friendly
178
 
        &shl("ecx",8);
179
 
&set_label("ej2");
180
 
        &movb(&HB("ecx"),       &BP(1,$in,"",0));
181
 
&set_label("ej1");
182
 
        &movb(&LB("ecx"),       &BP(0,$in,"",0));
183
 
&set_label("ejend");
184
 
 
185
 
        &xor("eax",     "ecx");
186
 
        &xor("ebx",     "edx");
187
 
 
188
 
        &bswap("eax")   if $swap;
189
 
        &bswap("ebx")   if $swap;
190
 
 
191
 
        &mov(&DWP($data_off,"esp","",0),        "eax"); # put in array for call
192
 
        &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
193
 
 
194
 
        &call   (&label("pic_point1"));
195
 
        &set_label("pic_point1");
196
 
        &blindpop("ebx");
197
 
        &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point1") . "]");
198
 
        &call("$enc_func\@PLT");
199
 
 
200
 
        &mov("eax",     &DWP($data_off,"esp","",0));
201
 
        &mov("ebx",     &DWP($data_off+4,"esp","",0));
202
 
 
203
 
        &bswap("eax")   if $swap;
204
 
        &bswap("ebx")   if $swap;
205
 
 
206
 
        &mov(&DWP(0,$out,"",0),"eax");
207
 
        &mov(&DWP(4,$out,"",0),"ebx");
208
 
 
209
 
        &jmp(&label("finish"));
210
 
 
211
 
        #############################################################
212
 
        #############################################################
213
 
        &set_label("decrypt",1);
214
 
        # decrypt start 
215
 
        &and($count,0xfffffff8);
216
 
        # The next 2 instructions are only for if the jz is taken
217
 
        &mov("eax",     &DWP($data_off+8,"esp","",0));  # get iv[0]
218
 
        &mov("ebx",     &DWP($data_off+12,"esp","",0)); # get iv[1]
219
 
        &jz(&label("decrypt_finish"));
220
 
 
221
 
        &set_label("decrypt_loop");
222
 
        &mov("eax",     &DWP(0,$in,"",0));      # load first 4 bytes
223
 
        &mov("ebx",     &DWP(4,$in,"",0));      # second 4 bytes
224
 
 
225
 
        &bswap("eax")   if $swap;
226
 
        &bswap("ebx")   if $swap;
227
 
 
228
 
        &mov(&DWP($data_off,"esp","",0),        "eax"); # put back
229
 
        &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
230
 
 
231
 
        &call   (&label("pic_point2"));
232
 
        &set_label("pic_point2");
233
 
        &blindpop("ebx");
234
 
        &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point2") . "]");
235
 
        &call("$dec_func\@PLT");
236
 
 
237
 
        &mov("eax",     &DWP($data_off,"esp","",0));    # get return
238
 
        &mov("ebx",     &DWP($data_off+4,"esp","",0));  #
239
 
 
240
 
        &bswap("eax")   if $swap;
241
 
        &bswap("ebx")   if $swap;
242
 
 
243
 
        &mov("ecx",     &DWP($data_off+8,"esp","",0));  # get iv[0]
244
 
        &mov("edx",     &DWP($data_off+12,"esp","",0)); # get iv[1]
245
 
 
246
 
        &xor("ecx",     "eax");
247
 
        &xor("edx",     "ebx");
248
 
 
249
 
        &mov("eax",     &DWP(0,$in,"",0));      # get old cipher text,
250
 
        &mov("ebx",     &DWP(4,$in,"",0));      # next iv actually
251
 
 
252
 
        &mov(&DWP(0,$out,"",0),"ecx");
253
 
        &mov(&DWP(4,$out,"",0),"edx");
254
 
 
255
 
        &mov(&DWP($data_off+8,"esp","",0),      "eax"); # save iv
256
 
        &mov(&DWP($data_off+12,"esp","",0),     "ebx"); #
257
 
 
258
 
        &add($in,       8);
259
 
        &add($out,      8);
260
 
 
261
 
        &sub($count,    8);
262
 
        &jnz(&label("decrypt_loop"));
263
 
############################ ENDIT #######################3
264
 
        &set_label("decrypt_finish");
265
 
        &mov($count,    &wparam(2));    # length
266
 
        &and($count,    7);
267
 
        &jz(&label("finish"));
268
 
 
269
 
        &mov("eax",     &DWP(0,$in,"",0));      # load first 4 bytes
270
 
        &mov("ebx",     &DWP(4,$in,"",0));      # second 4 bytes
271
 
 
272
 
        &bswap("eax")   if $swap;
273
 
        &bswap("ebx")   if $swap;
274
 
 
275
 
        &mov(&DWP($data_off,"esp","",0),        "eax"); # put back
276
 
        &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
277
 
 
278
 
        &call   (&label("pic_point3"));
279
 
        &set_label("pic_point3");
280
 
        &blindpop("ebx");
281
 
        &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point3") . "]");
282
 
        &call("$dec_func\@PLT");
283
 
 
284
 
        &mov("eax",     &DWP($data_off,"esp","",0));    # get return
285
 
        &mov("ebx",     &DWP($data_off+4,"esp","",0));  #
286
 
 
287
 
        &bswap("eax")   if $swap;
288
 
        &bswap("ebx")   if $swap;
289
 
 
290
 
        &mov("ecx",     &DWP($data_off+8,"esp","",0));  # get iv[0]
291
 
        &mov("edx",     &DWP($data_off+12,"esp","",0)); # get iv[1]
292
 
 
293
 
        &xor("ecx",     "eax");
294
 
        &xor("edx",     "ebx");
295
 
 
296
 
        # this is for when we exit
297
 
        &mov("eax",     &DWP(0,$in,"",0));      # get old cipher text,
298
 
        &mov("ebx",     &DWP(4,$in,"",0));      # next iv actually
299
 
 
300
 
&set_label("dj7");
301
 
        &rotr("edx",    16);
302
 
        &movb(&BP(6,$out,"",0), &LB("edx"));
303
 
        &shr("edx",16);
304
 
&set_label("dj6");
305
 
        &movb(&BP(5,$out,"",0), &HB("edx"));
306
 
&set_label("dj5");
307
 
        &movb(&BP(4,$out,"",0), &LB("edx"));
308
 
&set_label("dj4");
309
 
        &mov(&DWP(0,$out,"",0), "ecx");
310
 
        &jmp(&label("djend"));
311
 
&set_label("dj3");
312
 
        &rotr("ecx",    16);
313
 
        &movb(&BP(2,$out,"",0), &LB("ecx"));
314
 
        &shl("ecx",16);
315
 
&set_label("dj2");
316
 
        &movb(&BP(1,$in,"",0),  &HB("ecx"));
317
 
&set_label("dj1");
318
 
        &movb(&BP(0,$in,"",0),  &LB("ecx"));
319
 
&set_label("djend");
320
 
 
321
 
        # final iv is still in eax:ebx
322
 
        &jmp(&label("finish"));
323
 
 
324
 
 
325
 
############################ FINISH #######################3
326
 
        &set_label("finish",1);
327
 
        &mov("ecx",     &wparam($iv_off));      # Get iv ptr
328
 
 
329
 
        #################################################
330
 
        $total=16+4;
331
 
        $total+=4 if ($p1 > 0);
332
 
        $total+=4 if ($p2 > 0);
333
 
        $total+=4 if ($p3 > 0);
334
 
        &add("esp",$total);
335
 
 
336
 
        &mov(&DWP(0,"ecx","",0),        "eax"); # save iv
337
 
        &mov(&DWP(4,"ecx","",0),        "ebx"); # save iv
338
 
 
339
 
        &function_end_A($name);
340
 
 
341
 
        &align(64);
342
 
        &set_label("cbc_enc_jmp_table");
343
 
        &data_word("0");
344
 
        &data_word(&label("ej1")."-".&label("PIC_point"));
345
 
        &data_word(&label("ej2")."-".&label("PIC_point"));
346
 
        &data_word(&label("ej3")."-".&label("PIC_point"));
347
 
        &data_word(&label("ej4")."-".&label("PIC_point"));
348
 
        &data_word(&label("ej5")."-".&label("PIC_point"));
349
 
        &data_word(&label("ej6")."-".&label("PIC_point"));
350
 
        &data_word(&label("ej7")."-".&label("PIC_point"));
351
 
        # not used
352
 
        #&set_label("cbc_dec_jmp_table",1);
353
 
        #&data_word("0");
354
 
        #&data_word(&label("dj1")."-".&label("PIC_point"));
355
 
        #&data_word(&label("dj2")."-".&label("PIC_point"));
356
 
        #&data_word(&label("dj3")."-".&label("PIC_point"));
357
 
        #&data_word(&label("dj4")."-".&label("PIC_point"));
358
 
        #&data_word(&label("dj5")."-".&label("PIC_point"));
359
 
        #&data_word(&label("dj6")."-".&label("PIC_point"));
360
 
        #&data_word(&label("dj7")."-".&label("PIC_point"));
361
 
        &align(64);
362
 
 
363
 
        &function_end_B($name);
364
 
        
365
 
        }
366
 
 
367
 
1;