sm3

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2019 License: MIT Imports: 6 Imported by: 0

README

SM 3

规格

  • 长度: 固定256位

测试

从国家密码局给出的参考文 档 中的附录 A.2.2 的「填充」部分数据存在与 RFC 中的测试用例不一致,具体为

*** /var/folders/1f/b3qhndss0s3ggtsg9z29mty00000gn/T/ediff42218AJR	Fri Nov  1 00:52:32 2019
--- /var/folders/1f/b3qhndss0s3ggtsg9z29mty00000gn/T/ediff42218NTX	Fri Nov  1 00:52:32 2019
***************
*** 1,4 ****
  61626364 61626364 61626364 61626364 61626364 61626364 61626364 61626364
  61626364 61626364 61626364 61626364 61626364 61626364 61626364 61626364
  80000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
! 80000000 00000000 00000000 00000000 00000000 00000000 00000000 00000200
\ No newline at end of file
--- 1,4 ----
  61626364 61626364 61626364 61626364 61626364 61626364 61626364 61626364
  61626364 61626364 61626364 61626364 61626364 61626364 61626364 61626364
  80000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
! 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000200
\ No newline at end of file

相关参考和引用

Documentation

Index

Constants

View Source
const (
	BlockSizeInByte  = 16
	DigestSizeInByte = 32
)

Variables

This section is empty.

Functions

func New

func New() hash.Hash

New 生成杂凑上下文实例

func Padding

func Padding(message []byte) []byte

Padding 5.2 填充

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context 杂凑过程上下文

func NewContext

func NewContext() *Context

NewContext 5.1

func (*Context) BlockSize

func (ctx *Context) BlockSize() int

BlockSize 实现 Hash 接口中的 BlockSize 函数

func (*Context) CompressFunction

func (ctx *Context) CompressFunction(w *[68]uint32, wp *[64]uint32)

CompressFunction 5.3.3 压缩函数

func (*Context) ComputeFromBytes

func (ctx *Context) ComputeFromBytes(message []byte) *Context

ComputeFromBytes 总过程

func (*Context) ComputeFromString

func (ctx *Context) ComputeFromString(s string) *Context

ComputeFromString 以 string 输入

func (*Context) ComputeFromWords

func (ctx *Context) ComputeFromWords(words []uint32) *Context

ComputeFromWords 以 Word 输入

func (*Context) Init

func (ctx *Context) Init() *Context

Init 5.1

func (*Context) MessageExpansion

func (ctx *Context) MessageExpansion(w *[68]uint32, wp *[64]uint32)

MessageExpansion 5.3.2 消息扩展

func (*Context) Reset

func (ctx *Context) Reset()

Reset 实现 Hash 接口中的 Reset 函数,初始化杂凑上下文

func (*Context) Size

func (ctx *Context) Size() int

Size 实现 Hash 接口中的 Size 函数

func (*Context) Sum

func (ctx *Context) Sum(inputStream []byte) []byte

Sum 实现 Hash 接口中的 Sum 函数

func (*Context) ToBytes

func (ctx *Context) ToBytes() []byte

ToBytes 以 Bytes 输出

func (*Context) ToHexString

func (ctx *Context) ToHexString() string

ToHexString 以 string 输出

func (*Context) ToWords

func (ctx *Context) ToWords() []uint32

ToWords 以 [8]uint32 输出

func (*Context) Update

func (ctx *Context) Update(payload []byte) (n int, err error)

func (*Context) Write

func (ctx *Context) Write(newChunk []byte) (int, error)

Write 实现 Hash 接口中的 Write 方法(来自 io.Writer)

Jump to

Keyboard shortcuts

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