gmac

package module
v0.0.0-...-9eb35b8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: ISC Imports: 1 Imported by: 1

README

GMAC

ISC License GoDoc Go Report Card

RFC 4543 Galois Message Authentication Code (GMAC) (NIST SP800-38D)

"GMAC" stands for "Galois Message Authentication Code." It is a cryptographic authentication code that provides integrity and authenticity assurances for a given message or data. GMAC is specifically associated with the GCM (Galois/Counter Mode) mode of operation for block ciphers. It's used in authenticated encryption, ensuring that the data remains unaltered and authentic while providing confidentiality through encryption.

Usage

package main

import (
	"crypto/aes"
	"encoding/hex"
	"fmt"
	"log"

	"github.com/pedroalbanese/gmac"
)

func main() {
	// Example using AES block cipher
	key, _ := hex.DecodeString("00000000000000000000000000000000")
	nonce, _ := hex.DecodeString("00000000000000000000000000000000")
	message := []byte("Yoda said, do or do not. There is no try.")

	block, _ := aes.NewCipher(key)
	gmac, err := gmac.New(block, nonce, message)
	if err != nil {
		log.Fatal(err)
	}

	// Print out GMAC
	fmt.Printf("GMAC: %x\n", gmac)
}

Result: GMAC: e7ee2c63b4dc328eed4a86b3fb3490af

Reference

https://www.cryptopp.com/wiki/GMAC

License

This project is licensed under the ISC License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(block cipher.Block, nonce, data []byte) ([]byte, error)

CalculateGMAC calculates the Galois Message Authentication Code (GMAC)

Types

This section is empty.

Jump to

Keyboard shortcuts

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