Documentation ¶
Index ¶
Constants ¶
const ( Version0 = ProtocolVersion("v0") // see genKeyInfoV0 Version1 = ProtocolVersion("v1") // see genKeyInfoV1 Version = ProtocolVersion(Version1) // Current ProtocolVersion )
Variables ¶
var (
DefaultHash = sha512.New // DefaultHash is sha512
)
Functions ¶
func VersionFormat ¶
func VersionFormat(version ProtocolVersion, keyID KeyID) string
VersionFormat contruct Version from ProtocolVersion and KeyID see SecureID Version field
func VersionParse ¶
func VersionParse(str string) (ProtocolVersion, KeyID)
VersionParse return ProtocolVersion and KeyID from Version see SecureID Version field
Types ¶
type HashFunc ¶
HashFunc is used for extenal hash algorithm default is SHA512
func HashFromVersion ¶
func HashFromVersion(version ProtocolVersion) HashFunc
HashFromVersion return HashFunc from ProtocolVersion
type Keys ¶
type Keys struct { Version ProtocolVersion KeyID KeyID // contains filtered or unexported fields }
Keys struct holds state for encrypt/decrypt SecureID
func DefaultKeys ¶
func DefaultKeys(info SecureInfo, keyID KeyID) *Keys
DefaultKeys return Keys from current ProtocolVersion and KeyID, with SecureInfo
func NewKeys ¶
func NewKeys(info SecureInfo, version ProtocolVersion, keyID KeyID) *Keys
NewKeys return Key from SecureInfo, ProtocolVersion and KeyID
func NewKeysWithHashFunction ¶
func NewKeysWithHashFunction(info SecureInfo, version ProtocolVersion, keyID KeyID, hash HashFunc) *Keys
NewKeysWithHashFunction return Key from SecureInfo, ProtocolVersion, KeyID and HashFunc ProtocolVersion hash is used if nil
func (*Keys) SecureIDFromValue ¶
SecureIDFromValue return SecureID from Value using Keys state
type SecureID ¶
type SecureID struct { Version string `json:"ver"` Data string `json:"id"` Check string `json:"sig"` }
SecureID struct
func SecureIDFromValue ¶
func SecureIDFromValue(info SecureInfo, version ProtocolVersion, keyID KeyID, value Value) (SecureID, error)
SecureIDFromValue convert Value to SecureID using SecureInfo, ProtocolVersion and KeyID
type SecureInfo ¶
type SecureInfo struct { Seed Seed // seed used for keys derivation Context string // context used for hkdf }
SecureInfo struct used for SecureID function and Keys initialisation