<commit_before>package dkrcrypt

// The HIGHT Block cipher from KISA
// Copyright (c) 2012 <NAME> <<EMAIL>>
// Licensed under the GPLv3 or, at your option, any later version.

/*

References:

http://tools.ietf.org/html/draft-kisa-hight-00
http://www.iacr.org/cryptodb/archive/2006/CHES/04/04.pdf
http://seed.kisa.or.kr/kor/hight/hightInfo.jsp

*/

import (
	"strconv"
)

// A HightCipher is an instance of HIGHT encryption using a particular key.
type HightCipher struct {
	wk [8]byte   // whitened keys
	sk [128]byte // subkeys
}

type KeySizeError int

func (k KeySizeError) Error() string {
	return "dkrcrypt/hight: invalid key size " + strconv.Itoa(int(k))
}

// NewHight creates and returns a new HightCipher.
// The key argument should be 16 bytes.
func NewHight(key []byte) (*HightCipher, error) {
	c := new(HightCipher)

	if klen := len(key); klen != 16 {
		return nil, KeySizeError(len(key))
	}

	whiten(key, c.wk[:])
	subkey(key, c.sk[:])
	return c, nil
}

// Reset zeros the key data so that it will no longer appear in the process' memory.
func (c *HightCipher) Reset() {
	for i := range wk {
		wk[i] = 0
	}

	for i := range sk {
		sk[i] = 0
	}

}

// BlockSize returns the Hight block size.  It is needed to satisfy the Block interface in crypto/cipher.
func (c *HightCipher) BlockSize() int { return 8 }

// rotate left
func rotl(x byte, r byte) byte {
	return (x << r) | (x >> (8 - r))
}

// F0, from the specification
func f0(x byte) byte {
	return rotl(x, 1) ^ rotl(x, 2) ^ rotl(x, 7)
}
<commit_msg>wk and sk belong to receiver<commit_after>package dkrcrypt

// The HIGHT Block cipher from KISA
// Copyright (c) 2012 <NAME> <<EMAIL>>
// Licensed under the GPLv3 or, at your option, any later version.

/*

References:

http://tools.ietf.org/html/draft-kisa-hight-00
http://www.iacr.org/cryptodb/archive/2006/CHES/04/04.pdf
http://seed.kisa.or.kr/kor/hight/hightInfo.jsp

*/

import (
	"strconv"
)

// A HightCipher is an instance of HIGHT encryption using a particular key.
type HightCipher struct {
	wk [8]byte   // whitened keys
	sk [128]byte // subkeys
}

type KeySizeError int

func (k KeySizeError) Error() string {
	return "dkrcrypt/hight: invalid key size " + strconv.Itoa(int(k))
}

// NewHight creates and returns a new HightCipher.
// The key argument should be 16 bytes.
func NewHight(key []byte) (*HightCipher, error) {
	c := new(HightCipher)

	if klen := len(key); klen != 16 {
		return nil, KeySizeError(len(key))
	}

	whiten(key, c.wk[:])
	subkey(key, c.sk[:])
	return c, nil
}

// Reset zeros the key data so that it will no longer appear in the process' memory.
func (c *HightCipher) Reset() {
	for i := range c.wk {
		c.wk[i] = 0
	}

	for i := range c.sk {
		c.sk[i] = 0
	}

}

// BlockSize returns the Hight block size.  It is needed to satisfy the Block interface in crypto/cipher.
func (c *HightCipher) BlockSize() int { return 8 }

// rotate left
func rotl(x byte, r byte) byte {
	return (x << r) | (x >> (8 - r))
}

// F0, from the specification
func f0(x byte) byte {
	return rotl(x, 1) ^ rotl(x, 2) ^ rotl(x, 7)
}

{'fraction_non_alphanumeric': 0.14066077854105333, 'fraction_numerical': 0.02093555773634282, 'mean_word_length': 3.331444759206799, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1574805', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1157, 'n_words': 377}