From 54712c808171b39866e98acfbb72806eab26f38e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:17:13 +0800 Subject: [PATCH] Bump github.com/xtaci/qpp from 1.1.16 to 1.1.17 (#960) Bumps [github.com/xtaci/qpp](https://github.com/xtaci/qpp) from 1.1.16 to 1.1.17. - [Release notes](https://github.com/xtaci/qpp/releases) - [Commits](https://github.com/xtaci/qpp/compare/v1.1.16...v1.1.17) --- updated-dependencies: - dependency-name: github.com/xtaci/qpp dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 +-- go.sum | 40 ++------------------------- vendor/github.com/xtaci/qpp/README.md | 34 +++++++++++++---------- vendor/github.com/xtaci/qpp/qpp.go | 16 ++++++++++- vendor/modules.txt | 2 +- 5 files changed, 40 insertions(+), 56 deletions(-) diff --git a/go.mod b/go.mod index 346260246..fcd916726 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,12 @@ module github.com/xtaci/kcptun require ( + github.com/fatih/color v1.17.0 github.com/golang/snappy v0.0.4 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.1.16 + github.com/xtaci/qpp v1.1.17 github.com/xtaci/smux v1.5.24 github.com/xtaci/tcpraw v1.2.25 golang.org/x/crypto v0.25.0 @@ -14,7 +15,6 @@ require ( require ( github.com/coreos/go-iptables v0.7.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect - github.com/fatih/color v1.17.0 // indirect github.com/google/gopacket v1.1.19 // indirect github.com/klauspost/cpuid/v2 v2.2.8 // indirect github.com/klauspost/reedsolomon v1.12.2 // indirect diff --git a/go.sum b/go.sum index e2b79669a..30ac5ea8c 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,6 @@ github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/klauspost/reedsolomon v1.12.1 h1:NhWgum1efX1x58daOBGCFWcxtEhOhXKKl1HAPQUp03Q= -github.com/klauspost/reedsolomon v1.12.1/go.mod h1:nEi5Kjb6QqtbofI6s+cbG/j1da11c96IBYBSnVGtuBs= github.com/klauspost/reedsolomon v1.12.2 h1:TC0hlL/tTRxiMNnqHCzKsY11E0fIIKGCoZ2vQoPKIEM= github.com/klauspost/reedsolomon v1.12.2/go.mod h1:nEi5Kjb6QqtbofI6s+cbG/j1da11c96IBYBSnVGtuBs= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -74,36 +72,8 @@ github.com/xtaci/kcp-go/v5 v5.6.8 h1:jlI/0jAyjoOjT/SaGB58s4bQMJiNS41A2RKzR6TMWeI github.com/xtaci/kcp-go/v5 v5.6.8/go.mod h1:oE9j2NVqAkuKO5o8ByKGch3vgVX3BNf8zqP8JiGq0bM= github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM= github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE= -github.com/xtaci/qpp v1.0.2 h1:tJE3OOB5CgkjE7hd0he/9KQ9nvrFVSWXp02EltXQhTU= -github.com/xtaci/qpp v1.0.2/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -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/qpp v1.1.1 h1:UaZCbcwvKTx+pSXi/fQufXg2R82Gn4VBPs/zjGB9FwA= -github.com/xtaci/qpp v1.1.1/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.2 h1:QDJgYCtZdmKNKZ24uNPLq3cgHnp2irnJJBRtQ0gWZlU= -github.com/xtaci/qpp v1.1.2/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.3 h1:mYCWbvT4c9EItrVsSD8J3KIW83zBfEQ6dZDfFs0rHZs= -github.com/xtaci/qpp v1.1.3/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.4 h1:J4uUJy+7KVFWTduuIQr/MCiD9Ik8x7AblOtYbwMhC+s= -github.com/xtaci/qpp v1.1.4/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.5 h1:EpFDE3lpCkOtGVIQTxww0tjQEOOCohuBuISL+c7/iWw= -github.com/xtaci/qpp v1.1.5/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.6 h1:c0eVP1bbHQ+mDpPhT1FtKhKDGhikJGDw+tC/aVh9/pw= -github.com/xtaci/qpp v1.1.6/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.7 h1:KmqJRsXz84EnWfsI+hoPMNhJsbI4M717wFijEwI/q6w= -github.com/xtaci/qpp v1.1.7/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.10 h1:yCI7gS2GbOSFfGle4GmfQ6ToKHQbcxl1/buqmmXqZ8Q= -github.com/xtaci/qpp v1.1.10/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.12 h1:MNKmF0qiFwp4kjZAE07Ud2H0HLFVE+4Zs1HAlXGNHvQ= -github.com/xtaci/qpp v1.1.12/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.15 h1:/pP74+MR3RJuPhjMRId4CGAeJPkYWaVaeAVRrgOITtE= -github.com/xtaci/qpp v1.1.15/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= -github.com/xtaci/qpp v1.1.16 h1:iEpzzObrxl+4kEAS2fxm0W2/N6PdOStMt/gppK6rBak= -github.com/xtaci/qpp v1.1.16/go.mod h1:dJS3usaXNMbWxZSWCAdxz01UgJcz9wXDkd4BccDY/V0= +github.com/xtaci/qpp v1.1.17 h1:w35NYqF3wOBoAMs+2qA2XFjkNQ12mugw51CUJ7OcTzo= +github.com/xtaci/qpp v1.1.17/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= @@ -112,8 +82,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -129,8 +97,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -144,8 +110,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/vendor/github.com/xtaci/qpp/README.md b/vendor/github.com/xtaci/qpp/README.md index 7e1b64f78..ef48dc99d 100644 --- a/vendor/github.com/xtaci/qpp/README.md +++ b/vendor/github.com/xtaci/qpp/README.md @@ -16,8 +16,8 @@ The [Quantum Permutation Pad](https://link.springer.com/content/pdf/10.1140/epjq 2. **Quantum Bits (Qubits)**: Instead of classical bits (which are either 0 or 1), QPP uses qubits, which can be in a state of 0, 1, or any quantum superposition of these states. -3. **Permutation Operations**: Permutations in the context of QPP refer to rearranging the order of computational base. These permutations can be thought of as quantum gates that alter the qubit states in a manner that is hard to predict without the correct key. - +3. **Permutation Operations**: Permutations in the context of QPP refer to rearranging the ways to **transform/interpret** the plaintext comparing to rearranging the keys round and round in classical cryptography. These total permutations can be thought of as $P_n$. For a 8-bit byte, the permutations is $P_{256} = 256! = 857817775342842654119082271681232625157781520279485619859655650377269452553147589377440291360451408450375885342336584306157196834693696475322289288497426025679637332563368786442675207626794560187968867971521143307702077526646451464709187326100832876325702818980773671781454170250523018608495319068138257481070252817559459476987034665712738139286205234756808218860701203611083152093501947437109101726968262861606263662435022840944191408424615936000000000000000000000000000000000000000000000000000000000000000$ + ## Functionality of Quantum Permutation Pad 1. **Key Generation**: The QPP protocol involves generating a key based on quantum states. This key can be a set of quantum gates or permutation operations that will be applied to the qubits. @@ -32,12 +32,6 @@ The [Quantum Permutation Pad](https://link.springer.com/content/pdf/10.1140/epjq - **Reverse Permutations**: The receiver, who has the same key, applies the inverse of the permutation operations to the received qubits. This step decrypts the quantum state, returning it to its original form. - **Measurement**: The receiver then measures the qubits to obtain the classical data. -## Security Aspects - -- **Quantum No-Cloning Theorem**: One of the fundamental principles that enhance the security of QPP is the no-cloning theorem, which states that it is impossible to create an identical copy of an arbitrary unknown quantum state. This property prevents eavesdroppers from copying the qubits during transmission. -- **Quantum Key Distribution (QKD)**: QPP can be integrated with QKD protocols like BB84 to securely distribute the key used for the permutation operations. QKD ensures that any eavesdropping attempts can be detected. -- **Unpredictability of Quantum States**: The inherent unpredictability of quantum measurements adds an extra layer of security, making it extremely difficult for an attacker to gain useful information without the correct key. - ## Applications and Benefits - **High Security**: QPP offers higher security levels compared to classical cryptographic methods, leveraging the unique properties of quantum mechanics. @@ -52,19 +46,20 @@ The number of permutation matrices in an 8-qubit system is determined based on t Try directly from https://github.com/xtaci/kcptun/releases with the ```-QPP``` option enabled. +The permutation pad could be written in [Cycle notation](https://en.wikipedia.org/wiki/Permutation#Cycle_notation) as: $\sigma =(1\ 2\ 255)(3\ 36)(4\ 82\ 125)(....)$, which the elements are not reversible by encrypting twice simply. + ## Performance ![image](https://github.com/user-attachments/assets/4061d4a9-e7fa-43f5-89ef-f6ef6c00a2e7) ## Usage +Internal PRNG(NOT RECOMMENDED) ```golang -Internal PRNG: - func main() { seed := make([]byte, 32) io.ReadFull(rand.Reader, seed) - qpp := NewQPP(seed, 1024) + qpp := NewQPP(seed, 977) // a prime number of pads msg := make([]byte, 65536) io.ReadFull(rand.Reader, msg) @@ -74,14 +69,13 @@ func main() { } ``` +External PRNG(**RECOMMENDED**) ```golang -External PRNG: - func main() { seed := make([]byte, 32) io.ReadFull(rand.Reader, seed) - qpp := NewQPP(seed, 1024) + qpp := NewQPP(seed, 977) msg := make([]byte, 65536) io.ReadFull(rand.Reader, msg) @@ -94,7 +88,19 @@ func main() { } ``` +## Security consideration in setting PADs + +The number of pads is best to be coprime with 8. + +**Pads(64) GCD(64,8) == 8** + +![1721063372345](https://github.com/user-attachments/assets/4f6d5904-2663-46d7-870d-9fd7435df4d0) + +**Pads(15) GCD(15,8) == 1** + +![image](https://github.com/user-attachments/assets/accd3992-a56e-4059-a472-39ba5ad75660) +As you can tell the difference from the **[Chi square distribution](https://en.wikipedia.org/wiki/Chi-squared_distribution)**, randomness has been enhanced by setting to numbers that are coprimes to 8. ## Conclusion diff --git a/vendor/github.com/xtaci/qpp/qpp.go b/vendor/github.com/xtaci/qpp/qpp.go index 06c37a431..6d3a46bdc 100644 --- a/vendor/github.com/xtaci/qpp/qpp.go +++ b/vendor/github.com/xtaci/qpp/qpp.go @@ -1,3 +1,17 @@ +// Package qpp implements Quantum permutation pad +// +// Quantum permutation pad or QPP is a quantum-safe symmetric cryptographic +// algorithm proposed by Kuang and Bettenburg in 2020. The theoretical +// foundation of QPP leverages the linear algebraic representations of +// quantum gates which makes QPP realizable in both, quantum and classical +// systems. By applying the QPP with 64 of 8-bit permutation gates, holding +// respective entropy of over 100,000 bits, they accomplished quantum random +// number distributions digitally over today’s classical internet. The QPP has +// also been used to create pseudo quantum random numbers and served as a +// foundation for quantum-safe lightweight block and streaming ciphers. +// +// This file implements QPP in 8-qubits, which is compatible with the classical +// architecture. In 8-qubits, the overall permutation matrix reaches 256!. package qpp import ( @@ -42,7 +56,7 @@ type QuantumPermutationPad struct { pads []byte // Encryption pads, each pad is a permutation matrix for encryption rpads []byte // Decryption pads, each pad is a reverse permutation matrix for decryption padsPtr uintptr // raw pointer to encryption pads - rpadsPtr uintptr // raw pointer to encryption pads + rpadsPtr uintptr // raw pointer to decryption pads numPads uint16 // Number of pads (permutation matrices) encRand *Rand // Default random source for encryption pad selection diff --git a/vendor/modules.txt b/vendor/modules.txt index 25274b900..c392b8d20 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -47,7 +47,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.1.16 +# github.com/xtaci/qpp v1.1.17 ## explicit; go 1.22.3 github.com/xtaci/qpp # github.com/xtaci/smux v1.5.24