Fix intermittent sslapitest early data related failures
[openssl.git] / crypto / asn1 / charmap.pl
index 4ddbe0edca60361b1a3d363db51dc75b9149a5c0..78053dee15fb2437286b72f6797d298d157505e7 100644 (file)
@@ -1,12 +1,15 @@
 #! /usr/bin/env perl
-# Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
 #
-# Licensed under the OpenSSL license (the "License").  You may not use
+# Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
 # in the file LICENSE in the source distribution or at
 # https://www.openssl.org/source/license.html
 
 use strict;
+use FindBin;
+use lib "$FindBin::Bin/../../util/perl";
+use OpenSSL::copyright;
 
 my ($i, @arr);
 
@@ -21,6 +24,11 @@ my $NOESC_QUOTE      = 8;    # Not escaped if quoted
 my $PSTRING_CHAR = 0x10;       # Valid PrintableString character
 my $RFC2253_FIRST_ESC = 0x20; # Escaped with \ if first character
 my $RFC2253_LAST_ESC = 0x40;  # Escaped with \ if last character
+my $RFC2254_ESC = 0x400;       # Character escaped \XX
+my $HOST_ANY = 0x1000;      # Valid hostname character anywhere in label
+my $HOST_DOT = 0x2000;  # Dot: hostname label separator
+my $HOST_HYPHEN = 0x4000; # Hyphen: not valid at start or end.
+my $HOST_WILD = 0x8000; # Wildcard character
 
 for($i = 0; $i < 128; $i++) {
        # Set the RFC2253 escape characters (control)
@@ -33,7 +41,7 @@ for($i = 0; $i < 128; $i++) {
        if(                ( ( $i >= ord("a")) && ( $i <= ord("z")) )
                        || (  ( $i >= ord("A")) && ( $i <= ord("Z")) )
                        || (  ( $i >= ord("0")) && ( $i <= ord("9")) )  ) {
-               $arr[$i] |= $PSTRING_CHAR;
+               $arr[$i] |= $PSTRING_CHAR | $HOST_ANY;
        }
 }
 
@@ -52,6 +60,14 @@ $arr[ord("<")] |= $NOESC_QUOTE | $RFC2253_ESC;
 $arr[ord(">")] |= $NOESC_QUOTE | $RFC2253_ESC;
 $arr[ord(";")] |= $NOESC_QUOTE | $RFC2253_ESC;
 
+# Remaining RFC2254 characters
+
+$arr[0] |= $RFC2254_ESC;
+$arr[ord("(")] |= $RFC2254_ESC;
+$arr[ord(")")] |= $RFC2254_ESC;
+$arr[ord("*")] |= $RFC2254_ESC | $HOST_WILD;
+$arr[ord("\\")] |= $RFC2254_ESC;
+
 # Remaining PrintableString characters
 
 $arr[ord(" ")] |= $PSTRING_CHAR;
@@ -60,8 +76,8 @@ $arr[ord("(")] |= $PSTRING_CHAR;
 $arr[ord(")")] |= $PSTRING_CHAR;
 $arr[ord("+")] |= $PSTRING_CHAR;
 $arr[ord(",")] |= $PSTRING_CHAR;
-$arr[ord("-")] |= $PSTRING_CHAR;
-$arr[ord(".")] |= $PSTRING_CHAR;
+$arr[ord("-")] |= $PSTRING_CHAR | $HOST_HYPHEN;
+$arr[ord(".")] |= $PSTRING_CHAR | $HOST_DOT;
 $arr[ord("/")] |= $PSTRING_CHAR;
 $arr[ord(":")] |= $PSTRING_CHAR;
 $arr[ord("=")] |= $PSTRING_CHAR;
@@ -69,29 +85,38 @@ $arr[ord("?")] |= $PSTRING_CHAR;
 
 # Now generate the C code
 
+# Year the file was generated.
+my $YEAR = OpenSSL::copyright::year_of($0);
+
 print <<EOF;
 /*
  * WARNING: do not edit!
  * Generated by crypto/asn1/charmap.pl
  *
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Copyright 2000-$YEAR The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
 
+#define CHARTYPE_HOST_ANY $HOST_ANY
+#define CHARTYPE_HOST_DOT $HOST_DOT
+#define CHARTYPE_HOST_HYPHEN $HOST_HYPHEN
+#define CHARTYPE_HOST_WILD $HOST_WILD
+
 /*
  * Mask of various character properties
  */
 
-static const unsigned char char_type[] = {
+static const unsigned short char_type[] = {
 EOF
 
 print "   ";
 for($i = 0; $i < 128; $i++) {
-       print("\n   ") if($i && (($i % 16) == 0));
-       printf(" %2d", $arr[$i]);
+       print("\n   ") if($i && (($i % 12) == 0));
+       printf(" %4d", $arr[$i]);
        print(",") if ($i != 127);
 }
 print("\n};\n");