1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-17 18:21:00 +03:00

Update error generation

Adapt the `generate_errors.pl` to handle `PSA_WANT` macros and
update to handle SHA3 macros.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
Gabor Mezei
2025-04-24 12:11:26 +02:00
parent 4aa974f7c7
commit 588769cc65

View File

@ -96,8 +96,8 @@ foreach my $file (@files) {
}
}
my $ll_old_define = "";
my $hl_old_define = "";
my @ll_old_define = ("", "", "");
my @hl_old_define = ("", "", "");
my $ll_code_check = "";
my $hl_code_check = "";
@ -129,6 +129,14 @@ foreach my $match (@matches)
$define_name = "SSL_TLS" if ($define_name eq "SSL");
$define_name = "PEM_PARSE,PEM_WRITE" if ($define_name eq "PEM");
$define_name = "PKCS7" if ($define_name eq "PKCS7");
$define_name = "ALG_SHA3_224,ALG_SHA3_256,ALG_SHA3_384,ALG_SHA3_512"
if ($define_name eq "SHA3");
my $define_prefix = "MBEDTLS_";
$define_prefix = "PSA_WANT_" if ($module_name eq "SHA3");
my $define_suffix = "_C";
$define_suffix = "" if ($module_name eq "SHA3");
my $include_name = $module_name;
$include_name =~ tr/A-Z/a-z/;
@ -154,26 +162,30 @@ foreach my $match (@matches)
if ($found_ll)
{
$code_check = \$ll_code_check;
$old_define = \$ll_old_define;
$old_define = \@ll_old_define;
$white_space = ' ';
}
else
{
$code_check = \$hl_code_check;
$old_define = \$hl_old_define;
$old_define = \@hl_old_define;
$white_space = ' ';
}
if ($define_name ne ${$old_define})
my $old_define_name = \${$old_define}[0];
my $old_define_prefix = \${$old_define}[1];
my $old_define_suffix = \${$old_define}[2];
if ($define_name ne ${$old_define_name})
{
if (${$old_define} ne "")
if (${$old_define_name} ne "")
{
${$code_check} .= "#endif /* ";
$first = 0;
foreach my $dep (split(/,/, ${$old_define}))
foreach my $dep (split(/,/, ${$old_define_name}))
{
${$code_check} .= " || " if ($first++);
${$code_check} .= "MBEDTLS_${dep}_C";
${$code_check} .= " || \n " if ($first++);
${$code_check} .= "${$old_define_prefix}${dep}${$old_define_suffix}";
}
${$code_check} .= " */\n\n";
}
@ -183,42 +195,44 @@ foreach my $match (@matches)
$first = 0;
foreach my $dep (split(/,/, ${define_name}))
{
${$code_check} .= " || " if ($first);
$headers .= " || " if ($first++);
${$code_check} .= " || \\\n " if ($first);
$headers .= " || \\\n " if ($first++);
${$code_check} .= "defined(MBEDTLS_${dep}_C)";
$headers .= "defined(MBEDTLS_${dep}_C)" if
($include_name ne "");
${$code_check} .= "defined(${define_prefix}${dep}${define_suffix})";
$headers .= "defined(${define_prefix}${dep}${define_suffix})"
if ($include_name ne "");
}
${$code_check} .= "\n";
$headers .= "\n#include \"mbedtls/${include_name}.h\"\n".
"#endif\n\n" if ($include_name ne "");
${$old_define} = $define_name;
${$old_define_name} = $define_name;
${$old_define_prefix} = $define_prefix;
${$old_define_suffix} = $define_suffix;
}
${$code_check} .= "${white_space}case -($error_name):\n".
"${white_space} return( \"$module_name - $description\" );\n"
};
if ($ll_old_define ne "")
if ($ll_old_define[0] ne "")
{
$ll_code_check .= "#endif /* ";
my $first = 0;
foreach my $dep (split(/,/, $ll_old_define))
foreach my $dep (split(/,/, $ll_old_define[0]))
{
$ll_code_check .= " || " if ($first++);
$ll_code_check .= "MBEDTLS_${dep}_C";
$ll_code_check .= " || \n " if ($first++);
$ll_code_check .= "${ll_old_define[1]}${dep}${ll_old_define[2]}";
}
$ll_code_check .= " */\n";
}
if ($hl_old_define ne "")
if ($hl_old_define[0] ne "")
{
$hl_code_check .= "#endif /* ";
my $first = 0;
foreach my $dep (split(/,/, $hl_old_define))
foreach my $dep (split(/,/, $hl_old_define[0]))
{
$hl_code_check .= " || " if ($first++);
$hl_code_check .= "MBEDTLS_${dep}_C";
$hl_code_check .= " || \n " if ($first++);
$hl_code_check .= "${hl_old_define[1]}${dep}${hl_old_define[2]}";
}
$hl_code_check .= " */\n";
}