2019-05-14 19:15:12 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package macaroon
|
|
|
|
|
|
|
|
import (
|
2019-05-14 22:08:52 +01:00
|
|
|
"crypto/rand"
|
2019-05-14 19:15:12 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewCaveat returns a Caveat with a nonce initialized to the current timestamp
|
|
|
|
// in nanoseconds.
|
2019-05-14 22:08:52 +01:00
|
|
|
func NewCaveat() (Caveat, error) {
|
2019-05-14 19:15:12 +01:00
|
|
|
var buf [8]byte
|
2019-05-14 22:08:52 +01:00
|
|
|
_, err := rand.Read(buf[:])
|
|
|
|
return Caveat{Nonce: buf[:]}, err
|
2019-05-14 19:15:12 +01:00
|
|
|
}
|