nfold
import "github.com/TheManticoreProject/Manticore/crypto/nfold"
Package nfold implements the N-FOLD function from RFC 3961 Section 5.1. N-FOLD is used by Kerberos to generate key derivation constants.
Index
func NFold
func NFold(in []byte, n int) []byte
NFold folds the input byte string into n bits (n must be a multiple of 8).
The algorithm (RFC 3961 Section 5.1):
- Let k = len(in)*8 and l = lcm(n, k).
- Build a buffer of l/8 bytes by concatenating l/k copies of the input, each copy rotated right by 13*i bits relative to the original.
- XOR (with end-around carry / ones’ complement addition) all n-bit blocks of the buffer together to produce the n-bit output.