tolerate broken CMS/PKCS7 implementations using signature OID instead of digest
[openssl.git] / crypto / pariscid.pl
1 #!/usr/bin/env perl
2
3 $flavour = shift;
4 $output = shift;
5 open STDOUT,">$output";
6
7 if ($flavour =~ /64/) {
8         $LEVEL          ="2.0W";
9         $SIZE_T         =8;
10         $ST             ="std";
11 } else {
12         $LEVEL          ="1.1";
13         $SIZE_T         =4;
14         $ST             ="stw";
15 }
16
17 $rp="%r2";
18 $sp="%r30";
19 $rv="%r28";
20
21 $code=<<___;
22         .LEVEL  $LEVEL
23         .SPACE  \$TEXT\$
24         .SUBSPA \$CODE\$,QUAD=0,ALIGN=8,ACCESS=0x2C,CODE_ONLY
25
26         .EXPORT OPENSSL_cpuid_setup,ENTRY
27         .ALIGN  8
28 OPENSSL_cpuid_setup
29         .PROC
30         .CALLINFO       NO_CALLS
31         .ENTRY
32         bv      ($rp)
33         .EXIT
34         nop
35         .PROCEND
36
37         .EXPORT OPENSSL_rdtsc,ENTRY
38         .ALIGN  8
39 OPENSSL_rdtsc
40         .PROC
41         .CALLINFO       NO_CALLS
42         .ENTRY
43         mfctl   %cr16,$rv
44         bv      ($rp)
45         .EXIT
46         nop
47         .PROCEND
48
49         .EXPORT OPENSSL_wipe_cpu,ENTRY
50         .ALIGN  8
51 OPENSSL_wipe_cpu
52         .PROC
53         .CALLINFO       NO_CALLS
54         .ENTRY
55         xor             %r0,%r0,%r1
56         fcpy,dbl        %fr0,%fr4
57         xor             %r0,%r0,%r19
58         fcpy,dbl        %fr0,%fr5
59         xor             %r0,%r0,%r20
60         fcpy,dbl        %fr0,%fr6
61         xor             %r0,%r0,%r21
62         fcpy,dbl        %fr0,%fr7
63         xor             %r0,%r0,%r22
64         fcpy,dbl        %fr0,%fr8
65         xor             %r0,%r0,%r23
66         fcpy,dbl        %fr0,%fr9
67         xor             %r0,%r0,%r24
68         fcpy,dbl        %fr0,%fr10
69         xor             %r0,%r0,%r25
70         fcpy,dbl        %fr0,%fr11
71         xor             %r0,%r0,%r26
72         fcpy,dbl        %fr0,%fr22
73         xor             %r0,%r0,%r29
74         fcpy,dbl        %fr0,%fr23
75         xor             %r0,%r0,%r31
76         fcpy,dbl        %fr0,%fr24
77         fcpy,dbl        %fr0,%fr25
78         fcpy,dbl        %fr0,%fr26
79         fcpy,dbl        %fr0,%fr27
80         fcpy,dbl        %fr0,%fr28
81         fcpy,dbl        %fr0,%fr29
82         fcpy,dbl        %fr0,%fr30
83         fcpy,dbl        %fr0,%fr31
84         bv              ($rp)
85         .EXIT
86         ldo             0($sp),$rv
87         .PROCEND
88 ___
89 {
90 $inp="%r26";
91 $len="%r25";
92
93 $code.=<<___;
94         .EXPORT OPENSSL_cleanse,ENTRY,ARGW0=GR,ARGW1=GR
95         .ALIGN  8
96 OPENSSL_cleanse
97         .PROC
98         .CALLINFO       NO_CALLS
99         .ENTRY
100         cmpib,*=        0,$len,Ldone
101         nop
102         cmpib,*>>=      15,$len,Little
103         ldi             $SIZE_T-1,%r1
104
105 Lalign
106         and,*<>         $inp,%r1,%r28
107         b,n             Laligned
108         stb             %r0,0($inp)
109         ldo             -1($len),$len
110         b               Lalign
111         ldo             1($inp),$inp
112
113 Laligned
114         andcm           $len,%r1,%r28
115 Loop
116         $ST             %r0,0($inp)
117         addib,*<>       -$SIZE_T,%r28,Loop
118         ldo             $SIZE_T($inp),$inp
119
120         and,*<>         $len,%r1,$len
121         b,n             Ldone
122 Little
123         stb             %r0,0($inp)
124         addib,*<>       -1,$len,Little
125         ldo             1($inp),$inp
126 Ldone
127         bv              ($rp)
128         .EXIT
129         nop
130         .PROCEND
131 ___
132 }
133
134 $code =~ s/cmpib,\*/comib,/gm if ($SIZE_T==4);
135 $code =~ s/,\*/,/gm if ($SIZE_T==4);
136 print $code;
137 close STDOUT;
138