diff --git a/go.mod b/go.mod index b66133a4..4bc3a965 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/urfave/cli v1.22.15 github.com/xtaci/kcp-go/v5 v5.6.8 - github.com/xtaci/qpp v1.0.4 + github.com/xtaci/qpp v1.1.0 github.com/xtaci/smux v1.5.24 github.com/xtaci/tcpraw v1.2.25 golang.org/x/crypto v0.24.0 diff --git a/go.sum b/go.sum index 776991ae..e683bbe0 100644 --- a/go.sum +++ b/go.sum @@ -71,6 +71,8 @@ github.com/xtaci/qpp v1.0.3 h1:dvbGTlxW2Dqx0TPJo2EIT/RRz0G/atETBks15LXPX24= github.com/xtaci/qpp v1.0.3/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= github.com/xtaci/qpp v1.0.4 h1:tIEul2yMdUv+Zk9w3ktZYJ2wOUeeOjmUnABA/zOt7C0= github.com/xtaci/qpp v1.0.4/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= +github.com/xtaci/qpp v1.1.0 h1:PsIxn2lE2MdbbfNmNeTm1iWKw/k8DI/XkU5brOno5H0= +github.com/xtaci/qpp v1.1.0/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= github.com/xtaci/smux v1.5.24 h1:77emW9dtnOxxOQ5ltR+8BbsX1kzcOxQ5gB+aaV9hXOY= github.com/xtaci/smux v1.5.24/go.mod h1:OMlQbT5vcgl2gb49mFkYo6SMf+zP3rcjcwQz7ZU7IGY= github.com/xtaci/tcpraw v1.2.25 h1:VDlqo0op17JeXBM6e2G9ocCNLOJcw9mZbobMbJjo0vk= diff --git a/vendor/github.com/xtaci/qpp/qpp.go b/vendor/github.com/xtaci/qpp/qpp.go index 2f9514d6..2c665d9d 100644 --- a/vendor/github.com/xtaci/qpp/qpp.go +++ b/vendor/github.com/xtaci/qpp/qpp.go @@ -56,9 +56,10 @@ func (qpp *QuantumPermutationPad) Encrypt(data []byte) { switch qpp.qubits { case NATIVE_BYTE_LENGTH: for i := 0; i < len(data); i++ { - index := qpp.encRand.Uint32() % uint32(qpp.numPads) + rand := qpp.encRand.Uint32() + index := rand % uint32(qpp.numPads) pad := qpp.pads[index] - data[i] = pad[data[i]] + data[i] = pad[data[i]^byte(rand&0xFF)] } default: } @@ -69,9 +70,10 @@ func (qpp *QuantumPermutationPad) Decrypt(data []byte) { switch qpp.qubits { case NATIVE_BYTE_LENGTH: for i := 0; i < len(data); i++ { - index := qpp.decRand.Uint32() % uint32(qpp.numPads) + rand := qpp.encRand.Uint32() + index := rand % uint32(qpp.numPads) rpad := qpp.rpads[index] - data[i] = rpad[data[i]] + data[i] = rpad[data[i]] ^ byte(rand&0xFF) } default: } @@ -95,9 +97,10 @@ func (qpp *QuantumPermutationPad) EncryptWithPRNG(data []byte, rand *rand.Rand) switch qpp.qubits { case NATIVE_BYTE_LENGTH: for i := 0; i < len(data); i++ { - index := rand.Uint32() % uint32(qpp.numPads) + rand := rand.Uint32() + index := rand % uint32(qpp.numPads) pad := qpp.pads[index] - data[i] = pad[data[i]] + data[i] = pad[data[i]^byte(rand&0xFF)] } default: } @@ -110,9 +113,10 @@ func (qpp *QuantumPermutationPad) DecryptWithPRNG(data []byte, rand *rand.Rand) switch qpp.qubits { case NATIVE_BYTE_LENGTH: for i := 0; i < len(data); i++ { - index := rand.Uint32() % uint32(qpp.numPads) + rand := rand.Uint32() + index := rand % uint32(qpp.numPads) rpad := qpp.rpads[index] - data[i] = rpad[data[i]] + data[i] = rpad[data[i]] ^ byte(rand&0xFF) } default: } diff --git a/vendor/modules.txt b/vendor/modules.txt index ea62977f..ccdda511 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -38,7 +38,7 @@ github.com/urfave/cli # github.com/xtaci/kcp-go/v5 v5.6.8 ## explicit; go 1.21 github.com/xtaci/kcp-go/v5 -# github.com/xtaci/qpp v1.0.4 +# github.com/xtaci/qpp v1.1.0 ## explicit; go 1.22.3 github.com/xtaci/qpp # github.com/xtaci/smux v1.5.24