1
0
Fork 0
mirror of https://github.com/Luzifer/wasm-openssl.git synced 2024-11-09 23:30:06 +00:00

Upgrade to go-openssl v4

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-06-13 15:44:15 +02:00
parent df07d2b8ea
commit e0199f23d7
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
4 changed files with 16 additions and 15 deletions

View file

@ -1,5 +1,4 @@
GO_VERSION=1.12.9 GO_VERSION=1.14.3
TINYGO_VERSION=0.7.1
default: build_golang default: build_golang
@ -8,11 +7,3 @@ build_golang:
GOOS=js GOARCH=wasm go build \ GOOS=js GOARCH=wasm go build \
-o example/openssl.wasm \ -o example/openssl.wasm \
main.go main.go
build_tinygo:
curl -fLo ./example/wasm_exec.js "https://github.com/tinygo-org/tinygo/blob/v${TINYGO_VERSION}/targets/wasm_exec.js"
tinygo build \
-o example/openssl.wasm \
-target wasm \
--no-debug \
main.go

2
go.mod
View file

@ -2,4 +2,4 @@ module github.com/Luzifer/wasm-openssl
go 1.12 go 1.12
require github.com/Luzifer/go-openssl/v3 v3.1.0 require github.com/Luzifer/go-openssl/v4 v4.0.0

10
go.sum
View file

@ -1,2 +1,12 @@
github.com/Luzifer/go-openssl v1.2.0 h1:vuvSxN845hEpMbNO0oGezXuxVxV6oemQgQ5QETKmOZk=
github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw=
github.com/Luzifer/go-openssl/v3 v3.1.0/go.mod h1:liy3FXuuS8hfDlYh1T+l78AwQ/NjZflJz0NDvjKhwDs= github.com/Luzifer/go-openssl/v3 v3.1.0/go.mod h1:liy3FXuuS8hfDlYh1T+l78AwQ/NjZflJz0NDvjKhwDs=
github.com/Luzifer/go-openssl/v4 v4.0.0 h1:52GaSYOd5Dz5tkwoDfh+XU70fxDcksxjyBj9+d43arY=
github.com/Luzifer/go-openssl/v4 v4.0.0/go.mod h1:3i1T3Pe6eQK19d86WhuQzjLyMwBaNmGmt3ZceWpWVa4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View file

@ -4,10 +4,10 @@ import (
"fmt" "fmt"
"syscall/js" "syscall/js"
openssl "github.com/Luzifer/go-openssl/v3" openssl "github.com/Luzifer/go-openssl/v4"
) )
var defaultKDF = openssl.DigestSHA256Sum var defaultCG = openssl.PBKDF2SHA256
func main() { func main() {
js.Global().Set("opensslDecrypt", js.FuncOf(decrypt)) js.Global().Set("opensslDecrypt", js.FuncOf(decrypt))
@ -34,7 +34,7 @@ func decrypt(this js.Value, i []js.Value) interface{} {
) )
o := openssl.New() o := openssl.New()
plaintext, err := o.DecryptBytes(password, []byte(ciphertext), defaultKDF) plaintext, err := o.DecryptBytes(password, []byte(ciphertext), defaultCG)
if err != nil { if err != nil {
callback.Invoke(nil, fmt.Sprintf("decrypt failed: %s", err)) callback.Invoke(nil, fmt.Sprintf("decrypt failed: %s", err))
return nil return nil
@ -57,7 +57,7 @@ func encrypt(this js.Value, i []js.Value) interface{} {
) )
o := openssl.New() o := openssl.New()
ciphertext, err := o.EncryptBytes(password, []byte(plaintext), defaultKDF) ciphertext, err := o.EncryptBytes(password, []byte(plaintext), defaultCG)
if err != nil { if err != nil {
callback.Invoke(nil, fmt.Sprintf("encrypt failed: %s", err)) callback.Invoke(nil, fmt.Sprintf("encrypt failed: %s", err))
return nil return nil