2 # Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
9 # fixes bug in floating point emulation on sparc64 when
10 # this script produces off-by-one output on sparc64
18 $A=$obj_len{$obj{$nid{$a}}};
19 $B=$obj_len{$obj{$nid{$b}}};
22 return($r) if $r != 0;
24 $A=$obj_der{$obj{$nid{$a}}};
25 $B=$obj_der{$obj{$nid{$b}}};
40 if (($v{$k} =~ s/(OBJ_[^,]+),/$v{$1},/))
52 open (IN,"$ARGV[0]") || die "Can't open input file $ARGV[0]";
53 open (OUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]";
57 next unless /^\#define\s+(\S+)\s+(.*)$/;
62 if ($v =~ /^SN_(.*)$/)
64 if(defined $snames{$d})
66 print "WARNING: Duplicate short name \"$d\"\n";
69 { $snames{$d} = "X"; }
72 elsif ($v =~ /^LN_(.*)$/)
74 if(defined $lnames{$d})
76 print "WARNING: Duplicate long name \"$d\"\n";
79 { $lnames{$d} = "X"; }
82 elsif ($v =~ /^NID_(.*)$/)
84 elsif ($v =~ /^OBJ_(.*)$/)
92 %ob=&expand_obj(*objd);
94 @a=sort { $a <=> $b } keys %nid;
100 for ($i=0; $i<$n; $i++)
102 if (!defined($nid{$i}))
104 push(@out,"{NULL,NULL,NID_undef,0,NULL,0},\n");
108 $sn=defined($sn{$nid{$i}})?"$sn{$nid{$i}}":"NULL";
109 $ln=defined($ln{$nid{$i}})?"$ln{$nid{$i}}":"NULL";
124 $out.=",NID_$nid{$i},";
125 if (defined($obj{$nid{$i}}) && $objd{$obj{$nid{$i}}} =~ /,/)
127 $v=$objd{$obj{$nid{$i}}};
133 foreach (unpack("C*",$r))
135 $z.=sprintf("0x%02X,",$_);
138 $obj_der{$obj{$nid{$i}}}=$z;
139 $obj_len{$obj{$nid{$i}}}=$length;
141 push(@lvalues,sprintf("%-45s/* [%3d] %s */\n",
142 $z,$lvalues,$obj{$nid{$i}}));
143 $out.="$length,&(lvalues[$lvalues]),0";
155 @a=grep(defined($sn{$nid{$_}}),0 .. $n);
156 foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a)
158 push(@sn,sprintf("%2d,\t/* \"$sn{$nid{$_}}\" */\n",$_));
161 @a=grep(defined($ln{$nid{$_}}),0 .. $n);
162 foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a)
164 push(@ln,sprintf("%2d,\t/* \"$ln{$nid{$_}}\" */\n",$_));
167 @a=grep(defined($obj{$nid{$_}}),0 .. $n);
168 foreach (sort obj_cmp @a)
174 push(@ob,sprintf("%2d,\t/* %-32s %s */\n",$_,$m,$v));
179 * WARNING: do not edit!
180 * Generated by crypto/objects/obj_dat.pl
182 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
183 * Licensed under the OpenSSL license (the "License"). You may not use
184 * this file except in compliance with the License. You can obtain a copy
185 * in the file LICENSE in the source distribution or at
186 * https://www.openssl.org/source/license.html
191 printf OUT "#define NUM_NID %d\n",$n;
192 printf OUT "#define NUM_SN %d\n",$#sn+1;
193 printf OUT "#define NUM_LN %d\n",$#ln+1;
194 printf OUT "#define NUM_OBJ %d\n\n",$#ob+1;
196 printf OUT "static const unsigned char lvalues[%d]={\n",$lvalues+1;
200 printf OUT "static const ASN1_OBJECT nid_objs[NUM_NID]={\n";
216 chop $out; # Get rid of the last comma
224 printf OUT "static const unsigned int sn_objs[NUM_SN]={\n";
228 printf OUT "static const unsigned int ln_objs[NUM_LN]={\n";
232 printf OUT "static const unsigned int obj_objs[NUM_OBJ]={\n";
241 local(@a,$i,$ret,@r);
244 $ret.=pack("C*",$a[0]*40+$a[1]);
255 push(@r,((($t++)?0x80:0)|$x));
257 push(@r,((($t++)?0x80:0)|$_));
258 $ret.=pack("C*",reverse(@r));