|
Packit Service |
087331 |
#!/bin/sh
|
|
Packit Service |
087331 |
#
|
|
Packit Service |
087331 |
# Generate hash_info.h from kernel headers
|
|
Packit Service |
087331 |
#
|
|
Packit Service |
087331 |
# Copyright (C) 2018 <vt@altlinux.org>
|
|
Packit Service |
087331 |
#
|
|
Packit Service |
087331 |
# This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
087331 |
# it under the terms of the GNU General Public License as published by
|
|
Packit Service |
087331 |
# the Free Software Foundation; either version 2, or (at your option)
|
|
Packit Service |
087331 |
# any later version.
|
|
Packit Service |
087331 |
#
|
|
Packit Service |
087331 |
# This program is distributed in the hope that it will be useful,
|
|
Packit Service |
087331 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
087331 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
087331 |
# GNU General Public License for more details.
|
|
Packit Service |
087331 |
|
|
Packit Service |
087331 |
KERNEL_HEADERS=$1
|
|
Packit Service |
087331 |
HASH_INFO_H=uapi/linux/hash_info.h
|
|
Packit Service |
087331 |
HASH_INFO=$KERNEL_HEADERS/include/$HASH_INFO_H
|
|
Packit Service |
087331 |
|
|
Packit Service |
087331 |
TMPHASHINFO="./tmp_hash_info.h"
|
|
Packit Service |
087331 |
gen_hashinfo() {
|
|
Packit Service |
087331 |
cat << __EOF__ >$TMPHASHINFO
|
|
Packit Service |
087331 |
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
|
Packit Service |
087331 |
/*
|
|
Packit Service |
087331 |
* Hash Info: Hash algorithms information
|
|
Packit Service |
087331 |
*
|
|
Packit Service |
087331 |
* Copyright (c) 2013 Dmitry Kasatkin <d.kasatkin@samsung.com>
|
|
Packit Service |
087331 |
*
|
|
Packit Service |
087331 |
* This program is free software; you can redistribute it and/or modify it
|
|
Packit Service |
087331 |
* under the terms of the GNU General Public License as published by the Free
|
|
Packit Service |
087331 |
* Software Foundation; either version 2 of the License, or (at your option)
|
|
Packit Service |
087331 |
* any later version.
|
|
Packit Service |
087331 |
*
|
|
Packit Service |
087331 |
*/
|
|
Packit Service |
087331 |
|
|
Packit Service |
087331 |
enum hash_algo {
|
|
Packit Service |
087331 |
HASH_ALGO_MD4,
|
|
Packit Service |
087331 |
HASH_ALGO_MD5,
|
|
Packit Service |
087331 |
HASH_ALGO_SHA1,
|
|
Packit Service |
087331 |
HASH_ALGO_RIPE_MD_160,
|
|
Packit Service |
087331 |
HASH_ALGO_SHA256,
|
|
Packit Service |
087331 |
HASH_ALGO_SHA384,
|
|
Packit Service |
087331 |
HASH_ALGO_SHA512,
|
|
Packit Service |
087331 |
HASH_ALGO_SHA224,
|
|
Packit Service |
087331 |
HASH_ALGO_RIPE_MD_128,
|
|
Packit Service |
087331 |
HASH_ALGO_RIPE_MD_256,
|
|
Packit Service |
087331 |
HASH_ALGO_RIPE_MD_320,
|
|
Packit Service |
087331 |
HASH_ALGO_WP_256,
|
|
Packit Service |
087331 |
HASH_ALGO_WP_384,
|
|
Packit Service |
087331 |
HASH_ALGO_WP_512,
|
|
Packit Service |
087331 |
HASH_ALGO_TGR_128,
|
|
Packit Service |
087331 |
HASH_ALGO_TGR_160,
|
|
Packit Service |
087331 |
HASH_ALGO_TGR_192,
|
|
Packit Service |
087331 |
HASH_ALGO_SM3_256,
|
|
Packit Service |
087331 |
HASH_ALGO__LAST
|
|
Packit Service |
087331 |
};
|
|
Packit Service |
087331 |
__EOF__
|
|
Packit Service |
087331 |
}
|
|
Packit Service |
087331 |
|
|
Packit Service |
087331 |
# Allow to specify kernel-headers past include/
|
|
Packit Service |
087331 |
if [ ! -e $HASH_INFO ]; then
|
|
Packit Service |
087331 |
HASH_INFO2=$KERNEL_HEADERS/$HASH_INFO_H
|
|
Packit Service |
087331 |
if [ -e $HASH_INFO2 ]; then
|
|
Packit Service |
087331 |
HASH_INFO=$HASH_INFO2
|
|
Packit Service |
087331 |
else
|
|
Packit Service |
087331 |
gen_hashinfo
|
|
Packit Service |
087331 |
HASH_INFO="$TMPHASHINFO"
|
|
Packit Service |
087331 |
fi
|
|
Packit Service |
087331 |
fi
|
|
Packit Service |
087331 |
|
|
Packit Service |
087331 |
if [ ! -e $HASH_INFO ]; then
|
|
Packit Service |
087331 |
echo "/* $HASH_INFO is not found */"
|
|
Packit Service |
087331 |
HASH_INFO=/dev/null
|
|
Packit Service |
087331 |
else
|
|
Packit Service |
087331 |
echo "/* $HASH_INFO is found */"
|
|
Packit Service |
087331 |
fi
|
|
Packit Service |
087331 |
|
|
Packit Service |
087331 |
echo "enum hash_algo {"
|
|
Packit Service |
087331 |
grep HASH_ALGO_.*, $HASH_INFO
|
|
Packit Service |
087331 |
printf "\tHASH_ALGO__LAST\n"
|
|
Packit Service |
087331 |
echo "};"
|
|
Packit Service |
087331 |
|
|
Packit Service |
087331 |
echo "const char *const hash_algo_name[HASH_ALGO__LAST] = {"
|
|
Packit Service |
087331 |
sed -n 's/HASH_ALGO_\(.*\),/\1 \L\1\E/p' $HASH_INFO | \
|
|
Packit Service |
087331 |
while read a b; do
|
|
Packit Service |
087331 |
# Normalize text hash name: if it contains underscore between
|
|
Packit Service |
087331 |
# digits replace it with a dash, other underscores are removed.
|
|
Packit Service |
087331 |
b=$(echo "$b" | sed "s/\([0-9]\)_\([0-9]\)/\1-\2/g;s/_//g")
|
|
Packit Service |
087331 |
printf '\t%-26s = "%s",\n' "[HASH_ALGO_$a]" "$b"
|
|
Packit Service |
087331 |
done
|
|
Packit Service |
087331 |
echo "};"
|