summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects/obj_dat.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/objects/obj_dat.pl')
-rw-r--r--src/lib/libcrypto/objects/obj_dat.pl112
1 files changed, 73 insertions, 39 deletions
diff --git a/src/lib/libcrypto/objects/obj_dat.pl b/src/lib/libcrypto/objects/obj_dat.pl
index 4e7879d3f3..5dfb84ea00 100644
--- a/src/lib/libcrypto/objects/obj_dat.pl
+++ b/src/lib/libcrypto/objects/obj_dat.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2 2
3sub obj_cmp 3sub obj_cmp
4 { 4 {
@@ -38,15 +38,36 @@ sub expand_obj
38 return(%objn); 38 return(%objn);
39 } 39 }
40 40
41while (<>) 41open (IN,"$ARGV[0]") || die "Can't open input file $ARGV[0]";
42open (OUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]";
43
44while (<IN>)
42 { 45 {
43 next unless /^\#define\s+(\S+)\s+(.*)$/; 46 next unless /^\#define\s+(\S+)\s+(.*)$/;
44 $v=$1; 47 $v=$1;
45 $d=$2; 48 $d=$2;
49 $d =~ s/^\"//;
50 $d =~ s/\"$//;
46 if ($v =~ /^SN_(.*)$/) 51 if ($v =~ /^SN_(.*)$/)
47 { $sn{$1}=$d; } 52 {
53 if(defined $snames{$d})
54 {
55 print "WARNING: Duplicate short name \"$d\"\n";
56 }
57 else
58 { $snames{$d} = "X"; }
59 $sn{$1}=$d;
60 }
48 elsif ($v =~ /^LN_(.*)$/) 61 elsif ($v =~ /^LN_(.*)$/)
49 { $ln{$1}=$d; } 62 {
63 if(defined $lnames{$d})
64 {
65 print "WARNING: Duplicate long name \"$d\"\n";
66 }
67 else
68 { $lnames{$d} = "X"; }
69 $ln{$1}=$d;
70 }
50 elsif ($v =~ /^NID_(.*)$/) 71 elsif ($v =~ /^NID_(.*)$/)
51 { $nid{$d}=$1; } 72 { $nid{$d}=$1; }
52 elsif ($v =~ /^OBJ_(.*)$/) 73 elsif ($v =~ /^OBJ_(.*)$/)
@@ -55,6 +76,7 @@ while (<>)
55 $objd{$v}=$d; 76 $objd{$v}=$d;
56 } 77 }
57 } 78 }
79close IN;
58 80
59%ob=&expand_obj(*objd); 81%ob=&expand_obj(*objd);
60 82
@@ -74,11 +96,20 @@ for ($i=0; $i<$n; $i++)
74 { 96 {
75 $sn=defined($sn{$nid{$i}})?"$sn{$nid{$i}}":"NULL"; 97 $sn=defined($sn{$nid{$i}})?"$sn{$nid{$i}}":"NULL";
76 $ln=defined($ln{$nid{$i}})?"$ln{$nid{$i}}":"NULL"; 98 $ln=defined($ln{$nid{$i}})?"$ln{$nid{$i}}":"NULL";
77 $sn=$ln if ($sn eq "NULL"); 99
78 $ln=$sn if ($ln eq "NULL"); 100 if ($sn eq "NULL") {
101 $sn=$ln;
102 $sn{$nid{$i}} = $ln;
103 }
104
105 if ($ln eq "NULL") {
106 $ln=$sn;
107 $ln{$nid{$i}} = $sn;
108 }
109
79 $out ="{"; 110 $out ="{";
80 $out.=$sn; 111 $out.="\"$sn\"";
81 $out.=",".$ln; 112 $out.=","."\"$ln\"";
82 $out.=",NID_$nid{$i},"; 113 $out.=",NID_$nid{$i},";
83 if (defined($obj{$nid{$i}})) 114 if (defined($obj{$nid{$i}}))
84 { 115 {
@@ -113,13 +144,13 @@ for ($i=0; $i<$n; $i++)
113@a=grep(defined($sn{$nid{$_}}),0 .. $n); 144@a=grep(defined($sn{$nid{$_}}),0 .. $n);
114foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a) 145foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a)
115 { 146 {
116 push(@sn,sprintf("&(nid_objs[%2d]),/* $sn{$nid{$_}} */\n",$_)); 147 push(@sn,sprintf("&(nid_objs[%2d]),/* \"$sn{$nid{$_}}\" */\n",$_));
117 } 148 }
118 149
119@a=grep(defined($ln{$nid{$_}}),0 .. $n); 150@a=grep(defined($ln{$nid{$_}}),0 .. $n);
120foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a) 151foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a)
121 { 152 {
122 push(@ln,sprintf("&(nid_objs[%2d]),/* $ln{$nid{$_}} */\n",$_)); 153 push(@ln,sprintf("&(nid_objs[%2d]),/* \"$ln{$nid{$_}}\" */\n",$_));
123 } 154 }
124 155
125@a=grep(defined($obj{$nid{$_}}),0 .. $n); 156@a=grep(defined($obj{$nid{$_}}),0 .. $n);
@@ -132,8 +163,14 @@ foreach (sort obj_cmp @a)
132 push(@ob,sprintf("&(nid_objs[%2d]),/* %-32s %s */\n",$_,$m,$v)); 163 push(@ob,sprintf("&(nid_objs[%2d]),/* %-32s %s */\n",$_,$m,$v));
133 } 164 }
134 165
135print <<'EOF'; 166print OUT <<'EOF';
136/* lib/obj/obj_dat.h */ 167/* crypto/objects/obj_dat.h */
168
169/* THIS FILE IS GENERATED FROM objects.h by obj_dat.pl via the
170 * following command:
171 * perl obj_dat.pl obj_mac.h obj_dat.h
172 */
173
137/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 174/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
138 * All rights reserved. 175 * All rights reserved.
139 * 176 *
@@ -191,23 +228,18 @@ print <<'EOF';
191 * [including the GNU Public Licence.] 228 * [including the GNU Public Licence.]
192 */ 229 */
193 230
194/* THIS FILE IS GENERATED FROM Objects.h by obj_dat.pl via the
195 * following command:
196 * perl obj_dat.pl < objects.h > obj_dat.h
197 */
198
199EOF 231EOF
200 232
201printf "#define NUM_NID %d\n",$n; 233printf OUT "#define NUM_NID %d\n",$n;
202printf "#define NUM_SN %d\n",$#sn+1; 234printf OUT "#define NUM_SN %d\n",$#sn+1;
203printf "#define NUM_LN %d\n",$#ln+1; 235printf OUT "#define NUM_LN %d\n",$#ln+1;
204printf "#define NUM_OBJ %d\n\n",$#ob+1; 236printf OUT "#define NUM_OBJ %d\n\n",$#ob+1;
205 237
206printf "static unsigned char lvalues[%d]={\n",$lvalues+1; 238printf OUT "static unsigned char lvalues[%d]={\n",$lvalues+1;
207print @lvalues; 239print OUT @lvalues;
208print "};\n\n"; 240print OUT "};\n\n";
209 241
210printf "static ASN1_OBJECT nid_objs[NUM_NID]={\n"; 242printf OUT "static ASN1_OBJECT nid_objs[NUM_NID]={\n";
211foreach (@out) 243foreach (@out)
212 { 244 {
213 if (length($_) > 75) 245 if (length($_) > 75)
@@ -218,30 +250,32 @@ foreach (@out)
218 $t=$out.$_.","; 250 $t=$out.$_.",";
219 if (length($t) > 70) 251 if (length($t) > 70)
220 { 252 {
221 print "$out\n"; 253 print OUT "$out\n";
222 $t="\t$_,"; 254 $t="\t$_,";
223 } 255 }
224 $out=$t; 256 $out=$t;
225 } 257 }
226 chop $out; 258 chop $out;
227 print "$out"; 259 print OUT "$out";
228 } 260 }
229 else 261 else
230 { print $_; } 262 { print OUT $_; }
231 } 263 }
232print "};\n\n"; 264print OUT "};\n\n";
265
266printf OUT "static ASN1_OBJECT *sn_objs[NUM_SN]={\n";
267print OUT @sn;
268print OUT "};\n\n";
233 269
234printf "static ASN1_OBJECT *sn_objs[NUM_SN]={\n"; 270printf OUT "static ASN1_OBJECT *ln_objs[NUM_LN]={\n";
235print @sn; 271print OUT @ln;
236print "};\n\n"; 272print OUT "};\n\n";
237 273
238printf "static ASN1_OBJECT *ln_objs[NUM_LN]={\n"; 274printf OUT "static ASN1_OBJECT *obj_objs[NUM_OBJ]={\n";
239print @ln; 275print OUT @ob;
240print "};\n\n"; 276print OUT "};\n\n";
241 277
242printf "static ASN1_OBJECT *obj_objs[NUM_OBJ]={\n"; 278close OUT;
243print @ob;
244print "};\n\n";
245 279
246sub der_it 280sub der_it
247 { 281 {
@@ -252,7 +286,7 @@ sub der_it
252 $ret.=pack("C*",$a[0]*40+$a[1]); 286 $ret.=pack("C*",$a[0]*40+$a[1]);
253 shift @a; 287 shift @a;
254 shift @a; 288 shift @a;
255 while ($_=shift(@a)) 289 foreach (@a)
256 { 290 {
257 @r=(); 291 @r=();
258 $t=0; 292 $t=0;