Source file src/crypto/internal/fips140/hash.go

     1  // Copyright 2024 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package fips140
     6  
     7  import "io"
     8  
     9  // Hash is the common interface implemented by all hash functions. It is a copy
    10  // of [hash.Hash] from the standard library, to avoid depending on security
    11  // definitions from outside of the module.
    12  type Hash interface {
    13  	// Write (via the embedded io.Writer interface) adds more data to the
    14  	// running hash. It never returns an error.
    15  	io.Writer
    16  
    17  	// Sum appends the current hash to b and returns the resulting slice.
    18  	// It does not change the underlying hash state.
    19  	Sum(b []byte) []byte
    20  
    21  	// Reset resets the Hash to its initial state.
    22  	Reset()
    23  
    24  	// Size returns the number of bytes Sum will return.
    25  	Size() int
    26  
    27  	// BlockSize returns the hash's underlying block size.
    28  	// The Write method must be able to accept any amount
    29  	// of data, but it may operate more efficiently if all writes
    30  	// are a multiple of the block size.
    31  	BlockSize() int
    32  }
    33  

View as plain text