xref: /freebsd/crypto/openssl/fuzz/mkfuzzoids.pl (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert#! /usr/bin/env perl
2*e0c4386eSCy Schubert# Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert#
4*e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License").  You may not use
5*e0c4386eSCy Schubert# this file except in compliance with the License.  You can obtain a copy
6*e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at
7*e0c4386eSCy Schubert# https://www.openssl.org/source/license.html
8*e0c4386eSCy Schubertuse FindBin;
9*e0c4386eSCy Schubertuse lib "$FindBin::Bin/../util/perl";
10*e0c4386eSCy Schubertuse OpenSSL::copyright;
11*e0c4386eSCy Schubert
12*e0c4386eSCy Schubertmy $obj_dat_h = $ARGV[0];
13*e0c4386eSCy Schubertmy $YEAR = OpenSSL::copyright::latest(($0, $obj_dat_h));
14*e0c4386eSCy Schubertprint <<"EOF";
15*e0c4386eSCy Schubert# WARNING: do not edit!
16*e0c4386eSCy Schubert# Generated by fuzz/mkfuzzoids.pl
17*e0c4386eSCy Schubert#
18*e0c4386eSCy Schubert# Copyright 2020-$YEAR The OpenSSL Project Authors. All Rights Reserved.
19*e0c4386eSCy Schubert#
20*e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License").  You may not use
21*e0c4386eSCy Schubert# this file except in compliance with the License.  You can obtain a copy
22*e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at
23*e0c4386eSCy Schubert# https://www.openssl.org/source/license.html
24*e0c4386eSCy SchubertEOF
25*e0c4386eSCy Schubert
26*e0c4386eSCy Schubertopen IN, '<', $obj_dat_h
27*e0c4386eSCy Schubert    || die "Couldn't open $obj_dat_h : $!\n";
28*e0c4386eSCy Schubert
29*e0c4386eSCy Schubertwhile(<IN>) {
30*e0c4386eSCy Schubert    s|\R$||;                    # Better chomp
31*e0c4386eSCy Schubert
32*e0c4386eSCy Schubert    next unless m|^\s+((0x[0-9A-F][0-9A-F],)*)\s+/\*\s\[\s*\d+\]\s(OBJ_\w+)\s\*/$|;
33*e0c4386eSCy Schubert
34*e0c4386eSCy Schubert    my $OID = $1;
35*e0c4386eSCy Schubert    my $OBJname = $3;
36*e0c4386eSCy Schubert
37*e0c4386eSCy Schubert    $OID =~ s|0x|\\x|g;
38*e0c4386eSCy Schubert    $OID =~ s|,||g;
39*e0c4386eSCy Schubert
40*e0c4386eSCy Schubert    print "$OBJname=\"$OID\"\n";
41*e0c4386eSCy Schubert}
42*e0c4386eSCy Schubertclose IN;
43