openssl/util/fips-checksums.sh
Richard Levitte be22315235 FIPS module checksums: add scripts and Makefile rule
This adds the following scripts:

util/lang-compress.pl:

Compress source code, which language is determined by the first argument.
For the moment, we know 'perl' (perlasm source code), 'C' (C source code)
and 'S' (Assembler with C preprocessor directives).
This removes comments and empty lines, and compresses series of horizontal
spaces to one single space in the languages where that's appropriate.

util/fips-checksums.sh:

Takes source file names as arguments, pushes them through
util/lang-compress.pl and unifdef with FIPS_MODE defined, and calculates
the checksum on the result.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8871)
2021-05-04 11:32:16 +02:00

32 lines
956 B
Bash
Executable File

#! /bin/sh
HERE=`dirname $0`
for f in "$@"; do
# It's worth nothing that 'openssl sha256 -r' assumes that all input
# is binary. This isn't quite true, and we know better, so we convert
# the '*stdin' marker to the filename preceded by a space. See the
# sha1sum manual for a specification of the format.
case "$f" in
*.c | *.h )
cat "$f" \
| $HERE/lang-compress.pl 'C' \
| unifdef -DFIPS_MODE=1 \
| openssl sha256 -r \
| sed -e "s| \\*stdin| $f|"
;;
*.pl )
cat "$f" \
| $HERE/lang-compress.pl 'perl' \
| openssl sha256 -r \
| sed -e "s| \\*stdin| $f|"
;;
*.S )
cat "$f" \
| $HERE/lang-compress.pl 'S' \
| openssl sha256 -r \
| sed -e "s| \\*stdin| $f|"
;;
esac
done