mac

package
v1.3.0-rc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2020 License: Apache-2.0 Imports: 13 Imported by: 21

Documentation

Overview

Package mac provides implementations of the MAC primitive.

MAC computes a tag for a given message that can be used to authenticate a message. MAC protects data integrity as well as provides for authenticity of the message.

Example:

package main

import (
    "fmt"

    "github.com/google/tink/go/mac"
    "github.com/google/tink/go/keyset"
)

func main() {

    kh, err := keyset.NewHandle(mac.HMACSHA256Tag256KeyTemplate())
    if err != nil {
        // handle the error
    }

    m := mac.New(kh)

    mac , err := m.ComputeMac([]byte("this data needs to be MACed"))
    if err != nil {
        // handle error
    }

    if m.VerifyMAC(mac, []byte("this data needs to be MACed")); err != nil {
        //handle error
    }

}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HMACSHA256Tag128KeyTemplate added in v1.3.0

func HMACSHA256Tag128KeyTemplate() *tinkpb.KeyTemplate

HMACSHA256Tag128KeyTemplate is a KeyTemplate that generates a HMAC key with the following parameters:

  • Key size: 32 bytes
  • Tag size: 16 bytes
  • Hash function: SHA256

func HMACSHA256Tag256KeyTemplate added in v1.3.0

func HMACSHA256Tag256KeyTemplate() *tinkpb.KeyTemplate

HMACSHA256Tag256KeyTemplate is a KeyTemplate that generates a HMAC key with the following parameters:

  • Key size: 32 bytes
  • Tag size: 32 bytes
  • Hash function: SHA256

func HMACSHA512Tag256KeyTemplate added in v1.3.0

func HMACSHA512Tag256KeyTemplate() *tinkpb.KeyTemplate

HMACSHA512Tag256KeyTemplate is a KeyTemplate that generates a HMAC key with the following parameters:

  • Key size: 64 bytes
  • Tag size: 32 bytes
  • Hash function: SHA512

func HMACSHA512Tag512KeyTemplate added in v1.3.0

func HMACSHA512Tag512KeyTemplate() *tinkpb.KeyTemplate

HMACSHA512Tag512KeyTemplate is a KeyTemplate that generates a HMAC key with the following parameters:

  • Key size: 64 bytes
  • Tag size: 64 bytes
  • Hash function: SHA512

func New added in v1.3.0

func New(h *keyset.Handle) (tink.MAC, error)

New creates a MAC primitive from the given keyset handle.

func NewWithKeyManager added in v1.3.0

func NewWithKeyManager(h *keyset.Handle, km registry.KeyManager) (tink.MAC, error)

NewWithKeyManager creates a MAC primitive from the given keyset handle and a custom key manager.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL