* feat: [OCISDEV-732] acceptance test (#12143) * feat: acceptance test - graph * feat: acceptance test - graph * feat: acceptance test - graph * fix: remove drone * feat: run each behat suite as a separate worker * feat: rename feat: [OCISDEV-740] acceptance test, coverage P0 feat: [OCISDEV-743] build and unit test ci: [ocisdev-730] code quality feat: [OCISDEV-741] local-api-test part 2 feat: [OCISDEV-741] local-api-test, apiSpaces feat: [OCISDEV-744] cli-test feat: [OCISDEV-741] local-api-test, apiCollaboration # Conflicts: # .github/workflows/acceptance-tests.yml # tests/acceptance/run-github.py feat: [OCISDEV-741] integration feat: [OCISDEV-744] build-and-test, lint feat: [OCISDEV-744] e2e-test # Conflicts: # .github/workflows/acceptance-tests.yml feat: [OCISDEV-744] fix apiSearch2 test suite * test [OCISDEV-744]: Run apiSearch2 test suite * Added php8.4-gd to all 4 PHP install lines * test [OCISDEV-744]: Enable all commented tests * test [OCISDEV-744]: Fixed failings * test [OCISDEV-744]: Fixed failings feat: [OCISDEV-744] fix apiOcm test suite * test [OCISDEV-744]: fix apiOcm tests * test [OCISDEV-744]: remove redundant .sh files * test [OCISDEV-744]: remove run-e2e.sh. Fix DRY vialation in run-github.py * test [OCISDEV-744]: documentation fixes --------- Co-authored-by: Deyan Zhekov <deyan.zhekov@kiteworks.com> fix: [OCISDEV-730] actions compliance (#12187) feat: [OCISDEV-786] Split coreApiSharees and coreApiSharePublicLink2 (#12196) feat: [OCISDEV-779] reduce ci duration, libcurl (#12193) * feat: [OCISDEV-779] reduce ci duration, libcurl * feat: [OCISDEV-779] reduce ci duration, libcurl * feat: [OCISDEV-779] reduce ci duration, libcurl * feat: [OCISDEV-779] reduce ci duration, libcurl feat: [OCISDEV-792] reduce ci duration, build-and-run (#12204) * feat: [OCISDEV-792] reduce ci duration, build-and-run * feat: [OCISDEV-792] reduce ci duration, build-and-run * feat: [OCISDEV-792] reduce ci duration, pre-check * feat: [OCISDEV-792] reduce ci duration, pre-check * feat: [OCISDEV-792] reduce ci duration, pre-check * feat: [OCISDEV-792] reduce ci duration, pre-check * feat: [OCISDEV-792] reduce ci duration, pre-check fix: ci, govulncheck stderr (#12219) * fix: ci, govulncheck stderr * fix: ci, litmus flakines feat: [OCISDEV-779] reduce CI duration, PHP-version (#12217) * feat: [OCISDEV-779] reduce CI duration, php-version * feat: [OCISDEV-779] fix flaky test in apiSharingNgShares * feat: [OCISDEV-779] fix flaky preview comparison * feat: [OCISDEV-779] fix flaky preview comparison * feat: [OCISDEV-779] replace manual PHP installation with shivammathur/setup-php action * feat: [OCISDEV-779] fix Pre-checks and generate step * feat: [OCISDEV-779] fix flaky preview comparison * feat: [OCISDEV-779] fix failing test --------- Co-authored-by: Michal Klos <michal.klos@kiteworks.com> * feat: post rebase fix * feat: post rebase fix * feat: post rebase fix
91 lines
2.6 KiB
Go
91 lines
2.6 KiB
Go
// Copyright (C) 2019 ProtonTech AG
|
|
// This file contains necessary tools for the aex and ocb packages.
|
|
//
|
|
// These functions SHOULD NOT be used elsewhere, since they are optimized for
|
|
// specific input nature in the EAX and OCB modes of operation.
|
|
|
|
package byteutil
|
|
|
|
// 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 GfnDouble(input []byte) []byte {
|
|
if len(input) != 16 {
|
|
panic("Doubling in GFn only implemented for n = 128")
|
|
}
|
|
// If the first bit is zero, return 2L = L << 1
|
|
// Else return (L << 1) xor 0^120 10000111
|
|
shifted := ShiftBytesLeft(input)
|
|
shifted[15] ^= ((input[0] >> 7) * 0x87)
|
|
return shifted
|
|
}
|
|
|
|
// ShiftBytesLeft outputs the byte array corresponding to x << 1 in binary.
|
|
func ShiftBytesLeft(x []byte) []byte {
|
|
l := len(x)
|
|
dst := make([]byte, l)
|
|
for i := 0; i < l-1; i++ {
|
|
dst[i] = (x[i] << 1) | (x[i+1] >> 7)
|
|
}
|
|
dst[l-1] = x[l-1] << 1
|
|
return dst
|
|
}
|
|
|
|
// ShiftNBytesLeft puts in dst the byte array corresponding to x << n in binary.
|
|
func ShiftNBytesLeft(dst, x []byte, n int) {
|
|
// Erase first n / 8 bytes
|
|
copy(dst, x[n/8:])
|
|
|
|
// Shift the remaining n % 8 bits
|
|
bits := uint(n % 8)
|
|
l := len(dst)
|
|
for i := 0; i < l-1; i++ {
|
|
dst[i] = (dst[i] << bits) | (dst[i+1] >> uint(8-bits))
|
|
}
|
|
dst[l-1] = dst[l-1] << bits
|
|
|
|
// Append trailing zeroes
|
|
dst = append(dst, make([]byte, n/8)...)
|
|
}
|
|
|
|
// XorBytesMut replaces X with X XOR Y. len(X) must be >= len(Y).
|
|
func XorBytesMut(X, Y []byte) {
|
|
for i := 0; i < len(Y); i++ {
|
|
X[i] ^= Y[i]
|
|
}
|
|
}
|
|
|
|
// XorBytes puts X XOR Y into Z. len(Z) and len(X) must be >= len(Y).
|
|
func XorBytes(Z, X, Y []byte) {
|
|
for i := 0; i < len(Y); i++ {
|
|
Z[i] = X[i] ^ Y[i]
|
|
}
|
|
}
|
|
|
|
// RightXor XORs smaller input (assumed Y) at the right of the larger input (assumed X)
|
|
func RightXor(X, Y []byte) []byte {
|
|
offset := len(X) - len(Y)
|
|
xored := make([]byte, len(X))
|
|
copy(xored, X)
|
|
for i := 0; i < len(Y); i++ {
|
|
xored[offset+i] ^= Y[i]
|
|
}
|
|
return xored
|
|
}
|
|
|
|
// 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 SliceForAppend(in []byte, n int) (head, tail []byte) {
|
|
if total := len(in) + n; cap(in) >= total {
|
|
head = in[:total]
|
|
} else {
|
|
head = make([]byte, total)
|
|
copy(head, in)
|
|
}
|
|
tail = head[len(in):]
|
|
return
|
|
}
|