Documentation ¶
Index ¶
- Constants
- func CalculateRFC2104HMAC(message []byte, key []byte) []byte
- func GenerateExtendedSecretKey() ([]byte, error)
- func GenerateMessage(timestamp int64, offsetType uint8) int64
- func GenerateMessageBytes(message int64) ([]byte, error)
- func GenerateStandardSecretKey() ([]byte, error)
- func GenerateValidToken(unixTimestamp int64, key []byte, offsetType, tokenlength uint8) (int, error)
- func ValidateToken(token int, key []byte, unixTimestamp int64, tokenlength uint8) (bool, error)
- type Validation
Constants ¶
const ( // Present can be used as an Offset Type Present uint8 = iota // Future can be used as an Offset Type Future // Past can be used as an Offset Type Past )
const ( // OffsetPresent is the offset to add when the OffsetTypePresent was used OffsetPresent int8 = 0 // OffsetFuture is the offset to add when the OffsetTypeFuture was used OffsetFuture int8 = 30 // OffsetPast is the offset to add when the OffsetTypePast was used OffsetPast int8 = -30 // KeySizeStandard is the default size of the SecretKey (128bit) KeySizeStandard int8 = 16 // KeySizeExtended is the extended size of the SecretKey (256bit) KeySizeExtended int8 = 32 )
Variables ¶
This section is empty.
Functions ¶
func CalculateRFC2104HMAC ¶
CalculateRFC2104HMAC calculates the hmac-sha1 value for a given message and key
func GenerateExtendedSecretKey ¶
GenerateExtendedSecretKey returns 32bytes to be used as a secret key
func GenerateMessage ¶
GenerateMessage takes in a Unix Timestamp and an offsetType of 0,1,2 offsetTypes: 0=No Offset; 1=Future Offset; 2=Past Offset
func GenerateMessageBytes ¶
GenerateMessageBytes takes in a int64 number and turns it to a BigEndian byte array
func GenerateStandardSecretKey ¶
GenerateStandardSecretKey returns 16bytes to be used as a secret key
Types ¶
type Validation ¶ added in v0.2.6
Validation is a struct used to return the result of a token validation
func ValidateTokenCurrentTimestamp ¶
func ValidateTokenCurrentTimestamp(token int, key []byte, tokenlength uint8) Validation
ValidateTokenCurrentTimestamp takes a submitted token and a secret key and validates against the current Unix Timestamp whether the token is valid
func ValidateTokenWithTimestamp ¶
func ValidateTokenWithTimestamp(token int, key []byte, timestamp int64, tokenlength uint8) Validation
ValidateTokenWithTimestamp takes a submitted token and a secret key and validates against the current Unix Timestamp whether the token is valid