Documentation ¶
Overview ¶
Package mac provides implementations of the Mac primitive.
Index ¶
- Constants
- func GetPrimitive(handle *tink.KeysetHandle) (tink.Mac, error)
- func GetPrimitiveWithCustomerManager(handle *tink.KeysetHandle, manager tink.KeyManager) (tink.Mac, error)
- func HmacSha256Tag128KeyTemplate() *tinkpb.KeyTemplate
- func HmacSha256Tag256KeyTemplate() *tinkpb.KeyTemplate
- func NewHmacKey(params *hmacpb.HmacParams, version uint32, keyValue []byte) *hmacpb.HmacKey
- func NewHmacKeyFormat(params *hmacpb.HmacParams, keySize uint32) *hmacpb.HmacKeyFormat
- func NewHmacParams(hashType commonpb.HashType, tagSize uint32) *hmacpb.HmacParams
- func RegisterKeyManager(keyManager tink.KeyManager) (bool, error)
- func RegisterStandardKeyTypes() (bool, error)
- type HmacKeyManager
- func (km *HmacKeyManager) DoesSupport(typeURL string) bool
- func (km *HmacKeyManager) GetKeyType() string
- func (km *HmacKeyManager) GetPrimitiveFromKey(m proto.Message) (interface{}, error)
- func (km *HmacKeyManager) GetPrimitiveFromSerializedKey(serializedKey []byte) (interface{}, error)
- func (km *HmacKeyManager) NewKeyData(serializedKeyFormat []byte) (*tinkpb.KeyData, error)
- func (km *HmacKeyManager) NewKeyFromKeyFormat(m proto.Message) (proto.Message, error)
- func (km *HmacKeyManager) NewKeyFromSerializedKeyFormat(serializedKeyFormat []byte) (proto.Message, error)
Constants ¶
const ( // HmacTypeURL is the only type URL that this manager supports. HmacTypeURL = "type.googleapis.com/google.crypto.tink.HmacKey" // HmacKeyVersion is the maxmimal version of keys that this key manager supports. HmacKeyVersion = uint32(0) )
Variables ¶
This section is empty.
Functions ¶
func GetPrimitive ¶ added in v1.1.1
func GetPrimitive(handle *tink.KeysetHandle) (tink.Mac, error)
GetPrimitive creates a Mac primitive from the given keyset handle.
func GetPrimitiveWithCustomerManager ¶ added in v1.1.1
func GetPrimitiveWithCustomerManager( handle *tink.KeysetHandle, manager tink.KeyManager) (tink.Mac, error)
GetPrimitiveWithCustomerManager creates a Mac primitive from the given keyset handle and a custom key manager.
func HmacSha256Tag128KeyTemplate ¶
func HmacSha256Tag128KeyTemplate() *tinkpb.KeyTemplate
HmacSha256Tag128KeyTemplate is a KeyTemplate for HmacKey with the following parameters:
- Key size: 32 bytes
- Tag size: 16 bytes
- Hash function: SHA256
func HmacSha256Tag256KeyTemplate ¶
func HmacSha256Tag256KeyTemplate() *tinkpb.KeyTemplate
HmacSha256Tag256KeyTemplate is a KeyTemplate for HmacKey with the following parameters:
- Key size: 32 bytes
- Tag size: 32 bytes
- Hash function: SHA256
func NewHmacKey ¶ added in v1.1.0
NewHmacKey returns a new HmacKey.
func NewHmacKeyFormat ¶ added in v1.1.0
func NewHmacKeyFormat(params *hmacpb.HmacParams, keySize uint32) *hmacpb.HmacKeyFormat
NewHmacKeyFormat returns a new HmacKeyFormat.
func NewHmacParams ¶ added in v1.1.0
func NewHmacParams(hashType commonpb.HashType, tagSize uint32) *hmacpb.HmacParams
NewHmacParams returns a new HmacParams.
func RegisterKeyManager ¶ added in v1.1.1
func RegisterKeyManager(keyManager tink.KeyManager) (bool, error)
RegisterKeyManager registers the given keyManager for the key type given in keyManager.KeyType(). It returns true if registration was successful, false if there already exisits a key manager for the key type.
func RegisterStandardKeyTypes ¶ added in v1.1.1
RegisterStandardKeyTypes registers standard Mac key types and their managers with the Registry.
Types ¶
type HmacKeyManager ¶
type HmacKeyManager struct{}
HmacKeyManager generates new HmacKeys and produces new instances of Hmac.
func NewHmacKeyManager ¶
func NewHmacKeyManager() *HmacKeyManager
NewHmacKeyManager returns a new HmacKeyManager.
func (*HmacKeyManager) DoesSupport ¶
func (km *HmacKeyManager) DoesSupport(typeURL string) bool
DoesSupport checks whether this KeyManager supports the given key type.
func (*HmacKeyManager) GetKeyType ¶
func (km *HmacKeyManager) GetKeyType() string
GetKeyType returns the type URL of keys managed by this KeyManager.
func (*HmacKeyManager) GetPrimitiveFromKey ¶
func (km *HmacKeyManager) GetPrimitiveFromKey(m proto.Message) (interface{}, error)
GetPrimitiveFromKey constructs a HMAC instance for the given HmacKey.
func (*HmacKeyManager) GetPrimitiveFromSerializedKey ¶
func (km *HmacKeyManager) GetPrimitiveFromSerializedKey(serializedKey []byte) (interface{}, error)
GetPrimitiveFromSerializedKey constructs a Hmac instance for the given serialized HmacKey.
func (*HmacKeyManager) NewKeyData ¶
func (km *HmacKeyManager) NewKeyData(serializedKeyFormat []byte) (*tinkpb.KeyData, error)
NewKeyData generates a new KeyData according to specification in the given serialized HmacKeyFormat. This should be used solely by the key management API.
func (*HmacKeyManager) NewKeyFromKeyFormat ¶
NewKeyFromKeyFormat generates a new HmacKey according to specification in the given HmacKeyFormat.
func (*HmacKeyManager) NewKeyFromSerializedKeyFormat ¶
func (km *HmacKeyManager) NewKeyFromSerializedKeyFormat(serializedKeyFormat []byte) (proto.Message, error)
NewKeyFromSerializedKeyFormat generates a new HmacKey according to specification in the given serialized HmacKeyFormat.