safetynet

package module
v0.0.0-...-19c5646 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 4 Imported by: 0

README

SafetyNet validator

Usage

Given a SafetyNet Attestation

attestation, err := safetynet.Validate([]byte(safetynetJws))

The token is then validated and returned as attestation.

It is important that the nonce is validated to be used only once. This is not done by this library.

V1

V1 is available from go get github.com/wongnai/safetynet.

V1 only support Google SafetyNet.

V2

V2 package is available from go get github.com/wongnai/safetynet/v2. V2 is almost API-compatible with V1, but we accept string instead of []byte.

In V2, the returned attestation object contains attestation.Vendor field which can be:

Due to custom root required for HMS, V2 does not work on Windows

License

MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorBasicIntegrity = errors.New("basic integrity check fail")
View Source
var ErrorSafetyNetDecode = errors.New("cannot decode token")
View Source
var ErrorSafetyNetError = errors.New("safetyNet report error")
View Source
var TimeFunction = time.Now

for mocking

Functions

This section is empty.

Types

type Attestation

type Attestation struct {
	Timestamp                  int64    `json:"timestampMs"`
	Nonce                      string   `json:"nonce"`
	ApkPackageName             string   `json:"apkPackageName"`
	ApkDigestSHA256            string   `json:"apkDigestSha256"`
	ApkCertificateDigestSHA256 []string `json:"apkCertificateDigestSha256"`
	CTSProfileMatch            bool     `json:"ctsProfileMatch"`
	BasicIntegrity             bool     `json:"basicIntegrity"`
	Advice                     string   `json:"advice,omitempty"`
	Error                      string   `json:"error,omitempty"`
}

func Validate

func Validate(token []byte) (out Attestation, err error)

func (Attestation) GetTimestamp

func (s Attestation) GetTimestamp() time.Time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL