]> Cypherpunks.ru repositories - gostls13.git/blob - gogost-install
e85a0b57ae7014eadfe92323dbff7af0844c6a22
[gostls13.git] / gogost-install
1 #!/bin/sh -ex
2
3 command -v fetch >/dev/null && DL="fetch -o" || DL="wget -O"
4 command -v sha256 >/dev/null && SHA256="sha256" || SHA256="sha256sum --binary"
5 PERL=${PERL:-perl}
6
7 TARBALL=gogost-5.11.0.tar.zst
8 [ -r $TARBALL ] || {
9     $DL $TARBALL.tmp http://www.gogost.cypherpunks.ru/$TARBALL
10     mv $TARBALL.tmp $TARBALL
11 }
12 [ "`$SHA256 < $TARBALL | $PERL -lane 'print $F[0]'`" = "6c4abc20ebead10b99bff5601358a63301d4b0bea159e84e532cc3799537d8f4" ]
13 tar xf $TARBALL
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
18 rm -r cmd
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
24 done
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
27 rm go.sum