3 command -v fetch >/dev/null && DL="fetch -o" || DL="wget -O"
4 command -v sha256 >/dev/null && SHA256="sha256" || SHA256="sha256sum --binary"
7 TARBALL=gogost-5.13.0.tar.zst
9 $DL $TARBALL.tmp http://www.gogost.cypherpunks.ru/$TARBALL
10 mv $TARBALL.tmp $TARBALL
12 [ "`$SHA256 < $TARBALL | $PERL -lane 'print $F[0]'`" = "ee0deeb665aee4246c21c8c9f814860502468e37216f43d9acee8c309cc4843e" ]
14 mkdir -p src/crypto/go.cypherpunks.ru/gogost
15 mv ${TARBALL%.tar.zst} src/crypto/go.cypherpunks.ru/gogost/v5
16 crypto_version=$(sed -n 's#^.*golang.org/x/crypto \(.*\)$#\1#p' < src/go.mod)
17 cd src/crypto/go.cypherpunks.ru/gogost/v5
19 rm gost341194/pbkdf2_test.go
20 for len in 256 512 ; do
21 fn=gost34112012${len}/hash.go
22 echo "func init() { crypto.RegisterHash(crypto.GOSTR34112012${len}, New) }" >> $fn
23 $PERL -i -npe '/"hash"/ and print "\t\"crypto\"\n"' $fn
25 find . -name "*.go" -exec $PERL -i -npe "s#go.cypherpunks.ru#crypto/go.cypherpunks.ru#" {} \+
26 $PERL -i -ne "s#^(require golang.org/x/crypto) .*\$#\$1 $crypto_version#" go.mod