Статья не для передачи заказчикам.
Создание случайной соли
Возможные варианты создания случайной соли (стандартно используется длина соли 16):
- openssl rand -base64 16 | head -c 16
- date | md5sum | head -c 16 | sed "s/\s*-\s*$//"
- date +%s | sha256sum | base64 | head -c 16
- tr -cd '[:alnum:]' < /dev/urandom | fold -w16 | head -n1
Получение чистого хеша пароля
sudo apt install libgost-astra
echo Пароль | openssl -md_gost12_512
Хеш пароля с солью по ГОСТ 2012.252 в формате /etc/shadow
sudo apt install -y libgost-astra
salt=`openssl rand -base64 16 | head -c 16` ; echo $salt
hash=`echo -n "${salt}q2w2e2r2" | openssl dgst -md_gost12_512 | awk '{print $2}'` ; echo $hash
shadow="\$gost12512hash\$$salt\$$hash" ; echo $shadow
hash=`echo -n "${salt}q2w2e2r2" | openssl dgst -sha512 | awk '{print $2}'` ; echo $hash
shadow="\$6\$$salt\$$hash" ; echo $shadow
sudo sed -i "s/^luser:[^:]*/luser:${shadow//\//\\/}/" /etc/shadow ; sudo grep luser /etc/shadow
salt="/Ew6fLFg4kxS5Ii."
- $1$ is Message Digest 5 (MD5)
- $2a$ is blowfish
- $5$ is 256-bit Secure Hash Algorithm (SHA-256)
- $6$ is 512-bit Secure Hash Algorithm (SHA-512)
- $y$ (or $7$) is yescrypt
echo -n "`openssl rand -base64 16 | head -c 16`Пароль" | openssl dgst -md_gost12_512 | sed "s/^.*= /\$gost12512hash\$/"
echo -n "`openssl rand -base64 16 | head -c 16`Пароль" | gostsum --gost-2012-512