tink icon indicating copy to clipboard operation
tink copied to clipboard

Go issue

Open gitHusband opened this issue 4 years ago • 5 comments

Help us help you

Please tell us more about your Tink deployment.

Describe the bug

I am trying to get go for tesing following Tink for Go HOW-TO

To install Tink locally run:

go get github.com/google/tink/go/...

to run all the tests locally:

cd $GOPATH/go/src/github.com/google/tink/go
go test ./...
  1. I only get one directory called pkg in $GOPATH
  2. SO I cann't cd $GOPATH/go/src/github.com/google/tink/go
  3. I tried
cd pkg/mod/github.com/google/tink/[email protected]
go test ./...

But I get some bug:

aead/subtle/chacha20poly1305.go:21:2: missing go.sum entry for module providing package golang.org/x/crypto/chacha20poly1305 (imported by github.com/google/tink/go/aead); to add:
        go get github.com/google/tink/go/aead
subtle/hkdf.go:22:2: missing go.sum entry for module providing package golang.org/x/crypto/hkdf (imported by github.com/google/tink/go/prf/subtle); to add:
        go get github.com/google/tink/go/prf/subtle
integration/awskms/aws_kms_aead.go:25:2: missing go.sum entry for module providing package github.com/aws/aws-sdk-go/aws (imported by github.com/google/tink/go/integration/awskms); to add:
        go get github.com/google/tink/go/integration/awskms
integration/awskms/aws_kms_client.go:28:2: missing go.sum entry for module providing package github.com/aws/aws-sdk-go/aws/credentials (imported by github.com/google/tink/go/integration/awskms); to add:
        go get github.com/google/tink/go/integration/awskms
integration/awskms/aws_kms_client.go:29:2: missing go.sum entry for module providing package github.com/aws/aws-sdk-go/aws/session (imported by github.com/google/tink/go/integration/awskms); to add:
        go get github.com/google/tink/go/integration/awskms
integration/awskms/aws_kms_aead.go:26:2: missing go.sum entry for module providing package github.com/aws/aws-sdk-go/service/kms (imported by github.com/google/tink/go/integration/awskms); to add:
        go get github.com/google/tink/go/integration/awskms
integration/awskms/aws_kms_aead.go:27:2: missing go.sum entry for module providing package github.com/aws/aws-sdk-go/service/kms/kmsiface (imported by github.com/google/tink/go/integration/awskms); to add:
        go get github.com/google/tink/go/integration/awskms
integration/gcpkms/gcp_kms_client.go:31:2: missing go.sum entry for module providing package golang.org/x/oauth2 (imported by github.com/google/tink/go/integration/gcpkms); to add:
        go get github.com/google/tink/go/integration/gcpkms
integration/gcpkms/gcp_kms_client.go:30:2: missing go.sum entry for module providing package golang.org/x/oauth2/google (imported by github.com/google/tink/go/integration/gcpkms); to add:
        go get github.com/google/tink/go/integration/gcpkms
integration/gcpkms/gcp_kms_aead.go:22:2: missing go.sum entry for module providing package google.golang.org/api/cloudkms/v1 (imported by github.com/google/tink/go/integration/gcpkms); to add:
        go get github.com/google/tink/go/integration/gcpkms
integration/hcvault/hcvault_aead.go:27:2: missing go.sum entry for module providing package github.com/hashicorp/vault/api (imported by github.com/google/tink/go/integration/hcvault); to add:
        go get github.com/google/tink/go/integration/hcvault
signature/subtle/ed25519_signer.go:18:2: missing go.sum entry for module providing package golang.org/x/crypto/ed25519 (imported by github.com/google/tink/go/signature); to add:
        go get github.com/google/tink/go/signature
  1. My Go version:
go version
go version go1.16.1 darwin/amd64
  1. My platform is MACOS

To Reproduce

See Describe the bug

Expected behavior

Please tell me how to do it successfully, thanks!

Error messages, stack traces, etc.

See Describe the bug

Version information

  • Language: (GO)
  • Version: (go1.16.1 darwin/amd64)
  • Environment: (MACOS)

Additional context

gitHusband avatar Mar 12 '21 02:03 gitHusband

I know why now, it's because GO Modules feature. See https://medium.com/@fonseka.live/getting-started-with-go-modules-b3dac652066d

gitHusband avatar Mar 12 '21 08:03 gitHusband

I want to use PHP to call GO to decrypt PaymentToken of Google Pay But I just start learning GO. Sorry, Could you please give me a demo about 1-6 steps below, thanks!

The following steps outline what an integrator must do to consume the Google Pay API ECv2 PaymentMethodToken payload:

  1. Fetch the Google root signing keys.
  2. Verify that the signature of the intermediate signing key is valid by any of the non-expired root signing keys.
  3. Verify that the intermediate signing key of the payload hasn't expired.
  4. Verify that the signature of the payload is valid by the intermediate signing key.
  5. Decrypt the contents of the payload after you verify the signature.
  6. Verify that the message isn't expired. This requires you to check that the current time is less than the messageExpiration field in the decrypted contents.
  7. Use the payment method in the decrypted contents and charge it.

The sample code in our Tink library performs steps 1–6.

gitHusband avatar Mar 12 '21 08:03 gitHusband

Does https://github.com/google-pay/tink-jni-examples work for you?

thaidn avatar Mar 17 '21 18:03 thaidn

Does https://github.com/google-pay/tink-jni-examples work for you?

It should help. Thanks!

I use php to call JAVA but it can not verify signature. See

[[o:Exception]:"java.lang.Exception: Invoke failed: [[o:PaymentMethodTokenRecipient]]->unseal((o:String)[o:String]). Cause: java.security.GeneralSecurityException: cannot verify signature VM: 1.8.0_261@http://java.oracle.com/" at:
#-18 com.google.crypto.tink.apps.paymentmethodtoken.PaymentMethodTokenRecipient.verify(PaymentMethodTokenRecipient.java:458)
#-17 com.google.crypto.tink.apps.paymentmethodtoken.PaymentMethodTokenRecipient.verifyIntermediateSigningKey(PaymentMethodTokenRecipient.java:531)

The TInk version is 1.2.2, is that too old so it cannot verify?

gitHusband avatar Mar 20 '21 08:03 gitHusband

Does https://github.com/google-pay/tink-jni-examples work for you?

It should help. Thanks!

I use php to call JAVA but it can not verify signature. See

[[o:Exception]:"java.lang.Exception: Invoke failed: [[o:PaymentMethodTokenRecipient]]->unseal((o:String)[o:String]). Cause: java.security.GeneralSecurityException: cannot verify signature VM: 1.8.0_261@http://java.oracle.com/" at:
#-18 com.google.crypto.tink.apps.paymentmethodtoken.PaymentMethodTokenRecipient.verify(PaymentMethodTokenRecipient.java:458)
#-17 com.google.crypto.tink.apps.paymentmethodtoken.PaymentMethodTokenRecipient.verifyIntermediateSigningKey(PaymentMethodTokenRecipient.java:531)

The TInk version is 1.2.2, is that too old so it cannot verify?

gitHusband avatar Mar 20 '21 08:03 gitHusband

I'm sorry, we cannot help you with this besides the above link.

tholenst avatar Jan 26 '23 15:01 tholenst