Documentation ¶
Index ¶
- func CheckRSATimeSignature(b *SignedRSABlock, k *rsa.PublicKey, w time.Duration) error
- func SignTime(key []byte) string
- type RSATimeSigner
- type Sessions
- func (s *Sessions) Check(session string) ([]byte, time.Duration, bool)
- func (s *Sessions) CheckJSON(session string, dat interface{}) bool
- func (s *Sessions) CheckState(session string) bool
- func (s *Sessions) New(data []byte, ttl time.Duration) (string, time.Time)
- func (s *Sessions) NewJSON(data interface{}) (string, time.Time, error)
- func (s *Sessions) NewState() string
- type SignedRSABlock
- type Signer
- func (s *Signer) Check(bs []byte) (bool, []byte)
- func (s *Signer) CheckChallenge(bs []byte, mustAfter time.Time) (*timeutil.Challenge, error)
- func (s *Signer) CheckHex(str string) (bool, []byte)
- func (s *Signer) CheckHexJSON(str string, dat interface{}) (bool, error)
- func (s *Signer) CheckJSON(bs []byte, dat interface{}) (bool, error)
- func (s *Signer) NewSignedChallenge(t time.Time, rand io.Reader) ([]byte, *timeutil.Challenge, error)
- func (s *Signer) Sign(dat []byte) []byte
- func (s *Signer) SignHex(dat []byte) string
- func (s *Signer) SignHexJSON(dat interface{}) (string, error)
- func (s *Signer) SignJSON(dat interface{}) ([]byte, error)
- type TimeSigner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRSATimeSignature ¶
CheckRSATimeSignature checks if the signed RSA block is signed with the given key, and with in the time window.
Types ¶
type RSATimeSigner ¶
RSATimeSigner signes the current time, or checks if a signed time is within a time window of the current time reading.
func NewRSATimeSigner ¶
func NewRSATimeSigner(k *rsa.PublicKey, w time.Duration) *RSATimeSigner
NewRSATimeSigner creates a new time signer that uses an RSA key.
func (*RSATimeSigner) Check ¶
func (s *RSATimeSigner) Check(b *SignedRSABlock) error
Check checks if the timestamp is with in the time window.
type Sessions ¶
type Sessions struct { // TimeFunc is an optional function for reading the current timestamp. // When it is nil, the Sessions object uses time.Now(). TimeFunc func() time.Time // contains filtered or unexported fields }
Sessions signs a session data so that the server can run statelessly.
func NewSessions ¶
NewSessions creates a new session store.
func (*Sessions) CheckJSON ¶
CheckJSON checks if the session is valid and unmarshals if it is. It will return false if it is fails to unmarshal.
func (*Sessions) CheckState ¶
CheckState checks if it is a signed session with no data.
type SignedRSABlock ¶
SignedRSABlock is a signed RSA block.
func RSASignTime ¶
func RSASignTime(k *rsa.PrivateKey) (*SignedRSABlock, error)
RSASignTime signes the current time with the given RSA key.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer is a signer that contains a secrect key.
func (*Signer) Check ¶
Check verifies if the signed blob is valid. If it is valid, it returns the original data that is protected by the signature.
func (*Signer) CheckChallenge ¶
CheckChallenge checks if a challenge is properly signed and if the time is after mustAfter.
func (*Signer) CheckHex ¶
CheckHex verifies if the signed blob is valid, and if it is, returns the original data that is protected by the signature.
func (*Signer) CheckHexJSON ¶
CheckHexJSON verifies if the signed blob is valid, and if it is, unmarshals the original data into dat.
func (*Signer) CheckJSON ¶
CheckJSON verifies if the signed blob is valid, and if it is, unmarshals the original data into dat.
func (*Signer) NewSignedChallenge ¶
func (s *Signer) NewSignedChallenge(t time.Time, rand io.Reader) ( []byte, *timeutil.Challenge, error, )
NewSignedChallenge creates a new signed challenge.
func (*Signer) SignHex ¶
SignHex signs a blob and returns the data along with the signature in a hex string.
func (*Signer) SignHexJSON ¶
SignHexJSON signs a JSON marshalable blob and returns the data along with the signature in a hex string.
type TimeSigner ¶
type TimeSigner struct { // TimeFunc is an optional function for reading teh current timestamp. // When it is nil, the TimeSinger uses time.Now() TimeFunc func() time.Time // contains filtered or unexported fields }
TimeSigner signs the current time, or checks if a signed time is within a time window of the current time reading.
func NewTimeSigner ¶
func NewTimeSigner(key []byte, window time.Duration) *TimeSigner
NewTimeSigner creates a new time singer.
func (*TimeSigner) Check ¶
func (s *TimeSigner) Check(token string) bool
Check checks if the timestamp is with in the time window.
func (*TimeSigner) Token ¶
func (s *TimeSigner) Token() string
Token generates a signed token that has the current time reading.