kmac

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveKey

func DeriveKey(masterKey, context []byte, keyLen int) []byte

DeriveKey 使用 KMAC256 派生密钥

参数:

  • masterKey: 主密钥
  • context: 上下文/标签 (用于域分离)
  • keyLen: 输出密钥长度

返回:

  • 派生的密钥

func DeriveKeyWithLabel

func DeriveKeyWithLabel(masterKey []byte, label string, context []byte, keyLen int) []byte

DeriveKeyWithLabel 使用标签派生密钥

参数:

  • masterKey: 主密钥
  • label: 字符串标签
  • context: 二进制上下文
  • keyLen: 输出长度

func DeriveMultipleKeys

func DeriveMultipleKeys(masterKey []byte, labels []string, keyLen int) [][]byte

DeriveMultipleKeys 派生多个密钥

func KMAC128

func KMAC128(key, data []byte, customization string, outputLen int) []byte

KMAC128 使用 KMAC128 计算 MAC 或派生密钥

参数:

  • key: 密钥
  • data: 输入数据
  • customization: 自定义字符串 (用于域分离,可为空)
  • outputLen: 输出长度 (字节)

返回:

  • MAC/派生密钥

func KMAC256

func KMAC256(key, data []byte, customization string, outputLen int) []byte

KMAC256 使用 KMAC256 计算 MAC 或派生密钥

参数同 KMAC128,但使用更高安全级别

func KMACXOF128

func KMACXOF128(key, data []byte, customization string) *sha3.ShakeHash

KMACXOF128 可扩展输出函数模式 (无限输出) 返回一个 io.Reader,可按需读取任意长度的输出

func KMACXOF256

func KMACXOF256(key, data []byte, customization string) *sha3.ShakeHash

KMACXOF256 可扩展输出函数模式 (无限输出)

func MAC128

func MAC128(key, message []byte) []byte

MAC128 计算 128-bit MAC

func MAC256

func MAC256(key, message []byte) []byte

MAC256 计算 256-bit MAC

func PRF

func PRF(key []byte, counter uint64, outputLen int) []byte

PRF 伪随机函数 可用于生成确定性随机数

func Verify

func Verify(key, message, expectedMAC []byte) bool

Verify 验证 MAC

使用常量时间比较防止时序攻击

Types

This section is empty.

Jump to

Keyboard shortcuts

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