cryptotime

package module
v0.0.0-...-caacbb6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: MIT Imports: 10 Imported by: 0

README

Crypto Time

Go report card Build Status GoDoc Maintenance License GitHub release GitHub issues PRs Welcome

CryptoTime puts a end to client side time spoofing attacks. Time is checked from our servers which is signed using our PGP key. This ensures the traffic has not been tampered with. To prevent reply attacks we also implement a 40 character nonce/challenge which the client sends with each request. This will prevent a attack for just sending the response form a previous reply.

  • No longer trust client side time
  • Trust the time is correct and hasn't been tampered with
  • Ensure replay attacks can not occur
  • Perform secure client side time verification
  • Works just like the time package.
cryptotime.Now()

Cryptotime.Now() will return everything you would expect time.Now(), a time.Time. Its really simple, just a drop in replacement.

REST API

Rest API supports both JSON and protobufers. To use protobufers just append ?protobuf=1. https://api.syrinsecurity.net

GET /v1/common/cryptotime/:challenge
Host: api.syrinsecurity.net
{
        "unix": 1598819088,
        "unixNano": 1598819088784807000,
        "nano": 784806859,
        "UnixDate": "Sun Aug 30 21:24:48 BST 2020",
        "RFC850": "Sunday, 30-Aug-20 21:24:48 BST",
        "RFC1123": "Sun, 30 Aug 2020 21:24:48 BST",
        "stamp": "Aug 30 21:24:48",
        "stampMillisecond": "Aug 30 21:24:48.784",
        "stampMicrosecond": "Aug 30 21:24:48.784806",
        "stampNanoSecond": "Aug 30 21:24:48.784806859",
        "challenge": "asdgadfhnw5ysdrhgssgnsfgnhdfgndfgnfgnsfg",
        "hash": "86AA971ED2DB1A44BEF92BBA580CF93B1BB3DCC3CEF8ED5EBF4A77F67A09FB51",
        "signature": "-----BEGIN PGP SIGNATURE-----\n\nws8dA5xo-----END PGP SIGNATURE-----",
        "success": true
}

Documentation

Index

Constants

View Source
const Key = `` /* 2428-byte string literal not displayed */

Key is the PGP key used to sign the responses

View Source
const (
	//VERSION is using semantic versioning
	VERSION = "1.0.0"
)

Variables

View Source
var (
	//Client is the HTTP client used to fetch the datetime
	Client http.Client

	//Endpoint is queried for the current timestamp
	Endpoint = "https://api.syrinsecurity.net/v1/common/cryptotime/"

	//UserAgent is used in the request to the API
	UserAgent = "CryptoTime lib (https://github.com/syrinsecurity/cryptotime, v" + VERSION + ", " + runtime.GOOS + " " + runtime.GOARCH + ", " + runtime.Version() + ")"
	//ErrStatusCodeNotOk is returned when the API returns a statuscode that was not expected
	ErrStatusCodeNotOk = errors.New("cryptotime: status code not ok")
)
View Source
var (
	//DefaultTime is used as a fallback if the time can not be obtained from the server
	DefaultTime time.Time = time.Unix(500, 500)
)

Functions

func Now

func Now() time.Time

Now returns the current local time.

Types

This section is empty.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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