VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.0g/crypto/objects/objxref.pl@ 69881

Last change on this file since 69881 was 69881, checked in by vboxsync, 7 years ago

Update OpenSSL to 1.1.0g.
bugref:8070: src/libs maintenance

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#! /usr/bin/env perl
2# Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved.
3#
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
8
9
10use strict;
11
12my %xref_tbl;
13my %oid_tbl;
14
15my ($mac_file, $xref_file) = @ARGV;
16
17open(IN, $mac_file) || die "Can't open $mac_file, $!\n";
18
19# Read in OID nid values for a lookup table.
20
21while (<IN>)
22 {
23 s|\R$||; # Better chomp
24 my ($name, $num) = /^(\S+)\s+(\S+)$/;
25 $oid_tbl{$name} = $num;
26 }
27close IN;
28
29open(IN, $xref_file) || die "Can't open $xref_file, $!\n";
30
31my $ln = 1;
32
33while (<IN>)
34 {
35 s|\R$||; # Better chomp
36 s/#.*$//;
37 next if (/^\S*$/);
38 my ($xr, $p1, $p2) = /^(\S+)\s+(\S+)\s+(\S+)/;
39 check_oid($xr);
40 check_oid($p1);
41 check_oid($p2);
42 $xref_tbl{$xr} = [$p1, $p2, $ln];
43 }
44
45my @xrkeys = keys %xref_tbl;
46
47my @srt1 = sort { $oid_tbl{$a} <=> $oid_tbl{$b}} @xrkeys;
48
49my $i;
50for($i = 0; $i <= $#srt1; $i++)
51 {
52 $xref_tbl{$srt1[$i]}[2] = $i;
53 }
54
55my @srt2 = sort
56 {
57 my$ap1 = $oid_tbl{$xref_tbl{$a}[0]};
58 my$bp1 = $oid_tbl{$xref_tbl{$b}[0]};
59 return $ap1 - $bp1 if ($ap1 != $bp1);
60 my$ap2 = $oid_tbl{$xref_tbl{$a}[1]};
61 my$bp2 = $oid_tbl{$xref_tbl{$b}[1]};
62
63 return $ap2 - $bp2;
64 } @xrkeys;
65
66my $pname = $0;
67$pname =~ s|.*/||;
68
69print <<EOF;
70/*
71 * WARNING: do not edit!
72 * Generated by $pname
73 *
74 * Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved.
75 *
76 * Licensed under the OpenSSL license (the "License"). You may not use
77 * this file except in compliance with the License. You can obtain a copy
78 * in the file LICENSE in the source distribution or at
79 * https://www.openssl.org/source/license.html
80 */
81
82
83typedef struct {
84 int sign_id;
85 int hash_id;
86 int pkey_id;
87} nid_triple;
88
89DEFINE_STACK_OF(nid_triple)
90
91static const nid_triple sigoid_srt[] = {
92EOF
93
94foreach (@srt1)
95 {
96 my $xr = $_;
97 my ($p1, $p2) = @{$xref_tbl{$_}};
98 my $o1 = " {NID_$xr, NID_$p1,";
99 my $o2 = "NID_$p2},";
100 if (length("$o1 $o2") < 78)
101 {
102 print "$o1 $o2\n";
103 }
104 else
105 {
106 print "$o1\n $o2\n";
107 }
108 }
109
110print "};";
111print <<EOF;
112
113
114static const nid_triple *const sigoid_srt_xref[] = {
115EOF
116
117foreach (@srt2)
118 {
119 my ($p1, $p2, $x) = @{$xref_tbl{$_}};
120 # If digest or signature algorithm is "undef" then the algorithm
121 # needs special handling and is excluded from the cross reference table.
122 next if $p1 eq "undef" || $p2 eq "undef";
123 print " \&sigoid_srt\[$x\],\n";
124 }
125
126print "};\n";
127
128sub check_oid
129 {
130 my ($chk) = @_;
131 if (!exists $oid_tbl{$chk})
132 {
133 die "Can't find \"$chk\"\n";
134 }
135 }
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette