package sm4

import (
	"fmt"
	"testing"
)

func l_prime(x uint32) uint32 {
	return x ^ rotl(x, 13) ^ rotl(x, 23)
}

func TestGenerateTable(t *testing.T) {
	sbox16 = make([]uint32, 65536)
	for i := 0; i < 65536; i++ {
		x := l_prime(uint32(sbox[i&0xff]) | (uint32(sbox[(i>>8)&0xff]) << 8))
		sbox16[i] = x
		// sbox16Rotl[i] = (x >> 16) | (x << 16)
	}

	for i := 0; i < 65536; i += 4 {
		fmt.Printf("0x%08x, 0x%08x, 0x%08x, 0x%08x,\n", sbox16[i], sbox16[i+1], sbox16[i+2], sbox16[i+3])
	}
}
