package byteutil
import "github.com/ProtonMail/go-crypto/internal/byteutil"
Index ¶
- func GfnDouble(input []byte) []byte
- func RightXor(X, Y []byte) []byte
- func ShiftBytesLeft(x []byte) []byte
- func ShiftNBytesLeft(dst, x []byte, n int)
- func SliceForAppend(in []byte, n int) (head, tail []byte)
- func XorBytes(Z, X, Y []byte)
- func XorBytesMut(X, Y []byte)
Functions ¶
func GfnDouble ¶
GfnDouble computes 2 * input in the field of 2^n elements. The irreducible polynomial in the finite field for n=128 is x^128 + x^7 + x^2 + x + 1 (equals 0x87) Constant-time execution in order to avoid side-channel attacks
func RightXor ¶
RightXor XORs smaller input (assumed Y) at the right of the larger input (assumed X)
func ShiftBytesLeft ¶
ShiftBytesLeft outputs the byte array corresponding to x << 1 in binary.
func ShiftNBytesLeft ¶
ShiftNBytesLeft puts in dst the byte array corresponding to x << n in binary.
func SliceForAppend ¶
SliceForAppend takes a slice and a requested number of bytes. It returns a slice with the contents of the given slice followed by that many bytes and a second slice that aliases into it and contains only the extra bytes. If the original slice has sufficient capacity then no allocation is performed.
func XorBytes ¶
func XorBytes(Z, X, Y []byte)
XorBytes puts X XOR Y into Z. len(Z) and len(X) must be >= len(Y).
func XorBytesMut ¶
func XorBytesMut(X, Y []byte)
XorBytesMut replaces X with X XOR Y. len(X) must be >= len(Y).
Source Files ¶
- Version
- v1.3.0 (latest)
- Published
- May 22, 2025
- Platform
- linux/amd64
- Last checked
- 2 days ago –
Tools for package owners.