Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Restrictions TokenLength = 32 PublicIDMaxLength = 16 OTPMinLength = TokenLength OTPMaxLength = TokenLength + PublicIDMaxLength NonceMinLength = 16 NonceMaxLength = 40 )
Variables ¶
View Source
var ( ErrStorageNoKey = errors.New("client key not found") ErrStorageKeyInactive = errors.New("client key is not active") ErrStorageDecryptFail = errors.New("otp request decryption failed") )
View Source
var TestVectors = map[string]TestVector{ "dvgtiblfkbgturecfllberrvkinnctnn": { AESKey: []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, OTP: OTP{ PrivateID: [6]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}, UsageCounter: 1, TimestampCounter: [3]byte{0x01, 0x00, 0x01}, SessionCounter: 1, CRC: 0xfe36, }, }, "rnibcnfhdninbrdebccrndfhjgnhftee": { AESKey: []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, OTP: OTP{ PrivateID: [6]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}, UsageCounter: 1, TimestampCounter: [3]byte{0x01, 0x00, 0x01}, SessionCounter: 2, CRC: 0x1152, }, }, "iikkijbdknrrdhfdrjltvgrbkkjblcbh": { AESKey: []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, OTP: OTP{ PrivateID: [6]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}, UsageCounter: 0x0fff, TimestampCounter: [3]byte{0x01, 0x00, 0x01}, SessionCounter: 1, CRC: 0x9454, }, }, "dcihgvrhjeucvrinhdfddbjhfjftjdei": { AESKey: []byte{0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88}, OTP: OTP{ PrivateID: [6]byte{0x88, 0x88, 0x88, 0x88, 0x88, 0x88}, UsageCounter: 0x8888, TimestampCounter: [3]byte{0x88, 0x88, 0x88}, SessionCounter: 0x88, Random: 0x8888, CRC: 0xd3b6, }, }, "kkkncjnvcnenkjvjgncjihljiibgbhbh": { AESKey: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, OTP: OTP{ PrivateID: [6]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, TimestampCounter: [3]byte{0x00, 0x00, 0x00}, CRC: 0xa96a, }, }, "iucvrkjiegbhidrcicvlgrcgkgurhjnj": { AESKey: []byte{0xc4, 0x42, 0x28, 0x90, 0x65, 0x30, 0x76, 0xcd, 0xe7, 0x3d, 0x44, 0x9b, 0x19, 0x1b, 0x41, 0x6a}, OTP: OTP{ PrivateID: [6]byte{0x33, 0xc6, 0x9e, 0x7f, 0x24, 0x9e}, UsageCounter: 0x01, TimestampCounter: [3]byte{0x24, 0x13, 0xa7}, Random: 0xc63c, CRC: 0x1c86, }, }, }
Functions ¶
func SignMap ¶
* SignMap - signs specified strings slice with given apiKey @return []byte Raw HMAC signature
func SignMapToBase64 ¶
* SignMapToBase64 - signs specified strings slice with given apiKey @return []byte Base64-encoded HMAC signature
Types ¶
type OTP ¶
type OTP struct { PrivateID [6]byte UsageCounter uint16 TimestampCounter [3]byte SessionCounter uint8 Random uint16 CRC uint16 }
func (*OTP) MarshalBinary ¶
func (*OTP) UnmarshalBinary ¶
type StorageInterface ¶
type StorageInterface interface { // DecryptOTP using stored private AES for specified public identifier DecryptOTP(publicID, token string) (*OTP, error) }
StorageInterface for implementing keys storage
type TestVector ¶
Click to show internal directories.
Click to hide internal directories.