rustpq / pqcrypto Goto Github PK
View Code? Open in Web Editor NEWRust Post-Quantum cryptography
Rust Post-Quantum cryptography
When using several pqcrypto crates (for instance saber and classicmceliece),
it turns out both have their own copy of pqclean/common/
which leads to linker errors such as
/home/mrjb/.cargo/registry/src/github.com-1ecc6299db9ec823/pqcrypto-saber-0.1.5/pqclean/common/sp800-185.c:149:
multiple definition of `cshake256'; /tmp/rustc6Aet9z/libpqcrypto_classicmceliece-4c301a36d4b2b76b.rlib(sp800-185.o):
/home/mrjb/.cargo/registry/src/github.com-1ecc6299db9ec823/pqcrypto-classicmceliece-0.1.1/pqclean/common/sp800-185.c:149: first defined here
No doubt in practice pqclean/common/sp800-185.c
is identical for both crates but in theory they might not be.
Is there a version where the bindings to pqclean/common are split out to a separate package?
Hello,
I have compiled a list of reasons on why Zeroize Support would be good for this library. This is a continuation of #28 and #29
.zeroize()
method and ability to clear memory on dropMy personal reason is that I am developing two cryptography libraries that require Zeroize support. I would really appreciate it if Zeroize was implemented.
In the source code , it mentioned SharedSecret::new(), what type does SharedSecret::new() return? Can we customize the content?
https://docs.rs/pqcrypto/latest/pqcrypto/kem/kyber1024/index.html The example code says "use pqcrypto_kyber::kyber1024::;", but we should use pqcrypto::kem::kyber1024::; otherwise the compiler will not compile the code.
Hello,
It would be great if we could generate a keypair deterministically from a seed.
Would this be possible?
error: linking with link.exe
failed: exit code: 1181
LINK : fatal error LNK1181: cannot open input file 'pqcrypto_internals.lib'
Ran on Windows and Mac OS both with the same error.
Are you planning or would you be open to a SQIsign FFI implementation?
https://github.com/SQISign/the-sqisign
This issue tracks PQClean/PQClean#168
I'm not quite sure how to diagnose this. cargo test
builds everything, and almost everything succeeds. The only erroring build I'm getting is the following
cargo:rustc-link-lib=static=kyber512-90s_clean
cargo:rustc-link-search=native=/Users/micro/projects/pqcrypto-compat/target/debug/build/pqcrypto-kyber-ab7d6f1520cab3df/out
TARGET = Some("aarch64-apple-darwin")
HOST = Some("aarch64-apple-darwin")
AR_aarch64-apple-darwin = None
AR_aarch64_apple_darwin = None
HOST_AR = None
AR = None
running: "ar" "s" "/Users/micro/projects/pqcrypto-compat/target/debug/build/pqcrypto-kyber-ab7d6f1520cab3df/out/libkyber512-90s_aarch64.a"
cargo:warning=error: /Library/Developer/CommandLineTools/usr/bin/ranlib: can't open file: /Users/micro/projects/pqcrypto-compat/target/debug/build/pqcrypto-kyber-ab7d6f1520cab3df/out/libkyber512-90s_aarch64.a (No such file or directory)
cargo:warning=/Library/Developer/CommandLineTools/usr/bin/ar: internal ranlib command failed
exit status: 1
I can do more tests on my mac if you need more info
Hi, I've tried to execute cargo build
from a clean cloned master project and I've get this error:
error occurred: Command "ar" "s" "/home/pqcrypto/target/debug/build/pqcrypto-kyber-a3ed0b34ed342da2/out/libkyber512_clean.a" with args "ar" did not execute successfully (status code exit status: 1).
I've tried from a x86_64-unknown-linux-gnu target and also from a macOs m2 and still the same error. How can I fix this problem?
Thanks
Adding zeroize support for keypairs would be a good idea.
$ sudo -EH pip install pqcrypto
Enter PIN for 'Certificate For PIV Authentication':
Collecting pqcrypto
Downloading pqcrypto-0.1.3.tar.gz (1.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 19.8 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting cffi<2.0.0,>=1.14.2
Downloading cffi-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl (178 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 178.9/178.9 kB 7.6 MB/s eta 0:00:00
Requirement already satisfied: pycparser in /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from cffi<2.0.0,>=1.14.2->pqcrypto) (2.21)
Building wheels for collected packages: pqcrypto
Building wheel for pqcrypto (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pqcrypto (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
A setup.py file already exists. Using it.
Traceback (most recent call last):
File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-b2kuhf7r/pqcrypto_82dc7e3f926a4b61851d5ecee25e43f6/setup.py", line 2, in <module>
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 261, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-uxvwleqe/overlay/lib/python3.10/site-packages/poetry/core/masonry/api.py", line 68, in build_wheel
return unicode(WheelBuilder.make_in(poetry, Path(wheel_directory)))
File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-uxvwleqe/overlay/lib/python3.10/site-packages/poetry/core/masonry/builders/wheel.py", line 78, in make_in
wb.build()
File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-uxvwleqe/overlay/lib/python3.10/site-packages/poetry/core/masonry/builders/wheel.py", line 110, in build
self._build(zip_file)
File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-uxvwleqe/overlay/lib/python3.10/site-packages/poetry/core/masonry/builders/wheel.py", line 162, in _build
self._run_build_command(setup)
File "/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-build-env-uxvwleqe/overlay/lib/python3.10/site-packages/poetry/core/masonry/builders/wheel.py", line 190, in _run_build_command
subprocess.check_call(
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/local/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10', '/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-b2kuhf7r/pqcrypto_82dc7e3f926a4b61851d5ecee25e43f6/setup.py', 'build', '-b', '/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/pip-install-b2kuhf7r/pqcrypto_82dc7e3f926a4b61851d5ecee25e43f6/build']' returned non-zero exit status 1.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pqcrypto
Failed to build pqcrypto
ERROR: Could not build wheels for pqcrypto, which is required to install pyproject.toml-based projects
MacOS 12.4, Xcode-13.4.1, Python-3.10.
Must add that cloning this repo and building locally - succeeded, but the Wheel file is nowhere to be found:
$ poetry build
Creating virtualenv pqcrypto-l7v69cZ0-py3.10 in /Users/ur20980/Library/Caches/pypoetry/virtualenvs
Building pqcrypto (0.1.3)
- Building sdist
- Built pqcrypto-0.1.3.tar.gz
- Building wheel
/Users/ur20980/Library/Caches/pypoetry/virtualenvs/pqcrypto-l7v69cZ0-py3.10/lib/python3.10/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
warnings.warn(
running build
running build_py
creating /Users/ur20980/src/pqcrypto/build
creating /Users/ur20980/src/pqcrypto/build/lib.macosx-12.0-x86_64-cpython-310
creating /Users/ur20980/src/pqcrypto/build/lib.macosx-12.0-x86_64-cpython-310/pqcrypto
copying pqcrypto/__init__.py -> /Users/ur20980/src/pqcrypto/build/lib.macosx-12.0-x86_64-cpython-310/pqcrypto
copying pqcrypto/common.py -> /Users/ur20980/src/pqcrypto/build/lib.macosx-12.0-x86_64-cpython-310/pqcrypto
package init file 'pqcrypto/kem/__init__.py' not found (or not a regular file)
. . .
clang -bundle -undefined dynamic_lookup -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -O3 -std=gnu18 -march=native -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/pqcrypto._sign.sphincs_shake256_256s_simple.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/common/aes.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/common/fips202.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/common/randombytes.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/common/sha2.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/common/sp800-185.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/sphincs-shake256-256s-simple/ref/address.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/sphincs-shake256-256s-simple/ref/fors.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/sphincs-shake256-256s-simple/ref/hash_shake256.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/sphincs-shake256-256s-simple/ref/sign.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/sphincs-shake256-256s-simple/ref/thash_shake256_simple.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/sphincs-shake256-256s-simple/ref/utils.o /Users/ur20980/src/pqcrypto/build/temp.macosx-12.0-x86_64-cpython-310/Users/ur20980/src/pqcrypto/sources/sphincs-shake256-256s-simple/ref/wots.o -o /Users/ur20980/src/pqcrypto/build/lib.macosx-12.0-x86_64-cpython-310/pqcrypto/_sign/sphincs_shake256_256s_simple.abi3.so
- Built pqcrypto-0.1.3-cp310-cp310-macosx_12_0_x86_64.whl
$
But the tests cannot find pqcrypto
wheel:
$ python tests/test_kem.py
Traceback (most recent call last):
File "/Users/ur20980/src/pqcrypto/tests/test_kem.py", line 4, in <module>
import pqcrypto.kem
ModuleNotFoundError: No module named 'pqcrypto'
$
While building for Terminal emulator for Android:
error: failed to run custom build command for pqcrypto-internals v0.2.4
Caused by:
process didn't exit successfully: /data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-d4a85279fc3c99f5/build-script-build
(exit status: 1)
--- stdout
cargo:includepath=/data/data/com.termux/files/home/.cargo/registry/src/github.com-1ecc6299db9ec823/pqcrypto-internals-0.2.4/include
TARGET = Some("aarch64-linux-android")
OPT_LEVEL = Some("0")
HOST = Some("aarch64-linux-android")
cargo:rerun-if-env-changed=CC_aarch64-linux-android
CC_aarch64-linux-android = None
cargo:rerun-if-env-changed=CC_aarch64_linux_android
CC_aarch64_linux_android = None
cargo:rerun-if-env-changed=HOST_CC
HOST_CC = None
cargo:rerun-if-env-changed=CC
CC = None
cargo:rerun-if-env-changed=CFLAGS_aarch64-linux-android
CFLAGS_aarch64-linux-android = None
cargo:rerun-if-env-changed=CFLAGS_aarch64_linux_android
CFLAGS_aarch64_linux_android = None
cargo:rerun-if-env-changed=HOST_CFLAGS
HOST_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = Some("neon")
running: "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-I" "/data/data/com.termux/files/home/.cargo/registry/src/github.com-1ecc6299db9ec823/pqcrypto-internals-0.2.4/include" "-Wall" "-Wextra" "-o" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/fips202.o" "-c" "cfiles/fips202.c"
running: "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-I" "/data/data/com.termux/files/home/.cargo/registry/src/github.com-1ecc6299db9ec823/pqcrypto-internals-0.2.4/include" "-Wall" "-Wextra" "-o" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/aes.o" "-c" "cfiles/aes.c"
running: "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-I" "/data/data/com.termux/files/home/.cargo/registry/src/github.com-1ecc6299db9ec823/pqcrypto-internals-0.2.4/include" "-Wall" "-Wextra" "-o" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/sha2.o" "-c" "cfiles/sha2.c"
exit status: 0
exit status: 0
running: "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-I" "/data/data/com.termux/files/home/.cargo/registry/src/github.com-1ecc6299db9ec823/pqcrypto-internals-0.2.4/include" "-Wall" "-Wextra" "-o" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/nistseedexpander.o" "-c" "cfiles/nistseedexpander.c"
running: "aarch64-linux-android-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-I" "/data/data/com.termux/files/home/.cargo/registry/src/github.com-1ecc6299db9ec823/pqcrypto-internals-0.2.4/include" "-Wall" "-Wextra" "-o" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/sp800-185.o" "-c" "cfiles/sp800-185.c"
exit status: 0
exit status: 0
exit status: 0
cargo:rerun-if-env-changed=AR_aarch64-linux-android
AR_aarch64-linux-android = None
cargo:rerun-if-env-changed=AR_aarch64_linux_android
AR_aarch64_linux_android = None
cargo:rerun-if-env-changed=HOST_AR
HOST_AR = None
cargo:rerun-if-env-changed=AR
AR = None
running: "aarch64-linux-android-ar" "cq" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/libpqclean_common.a" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/fips202.o" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/aes.o" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/sha2.o" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/nistseedexpander.o" "/data/data/com.termux/files/home/pqproxy/target/debug/build/pqcrypto-internals-c51c990d4c0e78ae/out/cfiles/sp800-185.o"
--- stderr
error occurred: Failed to find tool. Is aarch64-linux-android-ar
installed?
FYI I just cut a new version of pcrypto-compat
which implements the RustCrypto KEM and signature traits over the pqcrypto
primitives. If it looks like a nice interface, I could make a PR here that implements it directly, and deprecate my crate. Let me know!
Originally posted by @rozbb in #39 (comment)
Example build log: https://travis-ci.org/mcginty/snow/jobs/619659365
Seems related to AVX2 variants not existing on the macOS build:
error[E0425]: cannot find function `PQCLEAN_KYBER1024_AVX2_crypto_kem_keypair` in module `ffi`
--> /Users/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/pqcrypto-kyber-0.6.1/src/kyber1024.rs:141:14
|
141 | ffi::PQCLEAN_KYBER1024_AVX2_crypto_kem_keypair(pk.0.as_mut_ptr(), sk.0.as_mut_ptr()),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `PQCLEAN_KYBER1024_CLEAN_crypto_kem_keypair`
Dependency: pqcryto-kyber v0.6.1
I'm getting errors building on Windows with:
rustc 1.62.0-nightly (8f36334ca 2022-04-06)
VS2022
I'm getting the errors:
cfiles\sp800-185.c(4): fatal error C1083: Cannot open include file: 'sp800-185.h': No such file or directory
cfiles\aes.c(32): fatal error C1083: Cannot open include file: 'aes.h': No such file or directory
cfiles\sha2.c(10): fatal error C1083: Cannot open include file: 'sha2.h': No such file or directory
cfiles\nistseedexpander.c(9): fatal error C1083: Cannot open include file: 'nistseedexpander.h': No such file or directory
Any help?
Hi,
I was wondering if you could make a second repository of Falcon with Zeroize support. I implemented it but cannot get it to work due to the confusing hierarchy used in the project. I need to be able to use the library for a project I am working on.
If you cannot do this or don't have the time, no worries. I can send a PR request for Falcon with Zeroize support as it was easy to implement but the only problem was that I could not get it to upload as a package.
Thank you for your hard work!
GPG is a program by GNU project, but it currently doesn't support post-quantum cryptos. I hope this project can replace GPG.
Requires PQClean/PQClean#561
Can we see the content of PublicKey?
Hi,
I cannot seem to access the structs PublicKey and SecretKey for SPHINCS+. Here has the documentation and I can access the two other structs but not the PublicKey / SecretKey.
I would like to be able to access it so I can save the keys someplace as a vector of bytes and then import them.
Any help would be appreciated.
When trying to compile a project that depends on pqcrypto-kyber to another architecture, like so:
cargo build --target armv7-unknown-linux-gnueabihf
I get the following warnings:
cargo:warning=armv7l-unknown-linux-gnueabihf-gcc: error: unrecognized command line option ‘-mavx2’
cargo:warning=armv7l-unknown-linux-gnueabihf-gcc: error: unrecognized command line option ‘-mbmi2’
cargo:warning=armv7l-unknown-linux-gnueabihf-gcc: error: unrecognized command line option ‘-mbmi’
cargo:warning=armv7l-unknown-linux-gnueabihf-gcc: error: unrecognized command line option ‘-maes’
cargo:warning=armv7l-unknown-linux-gnueabihf-gcc: error: unrecognized command line option ‘-mpopcnt’
after which the compilation fails.
I'm using version 0.6.5.
I'm not sure exactly why this happens, as for it to happen, this should be executed, but this is behind a target_arch = "x86_64" #cfg.
try adding this line as a dependency in cargo.toml
:
pqcrypto = { git = "https://github.com/rustpq/pqcrypto" }
When I compile one of my programs that has this dependency, I get this error:
cargo:warning=gcc.exe: error: pqclean/common\aes.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
exit code: 1
running: "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "pqclean/common" "-Wall" "-Wextra" "-std=c99" "-o" "C:\\hyxe_wave\\target\\debug\\build\\pqcrypto-qtesla-1a419fa1873d1b50\\out\\pqclean/common\\randombytes.o" "-c" "pqclean/common\\randombytes.c"
cargo:warning=gcc.exe: error: pqclean/common\sha2.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
exit code: 1
cargo:warning=gcc.exe: error: pqclean/common\fips202.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
cargo:warning=gcc.exe: error: pqclean/common\randombytes.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
The MinGW compilers are properly in the $PATH
, and further, I have attempted compilation on the MinGW under the Msys suite too. I am compiling using the latest version of cargo, and version 1.42.0 (nightly) of rust
We're currently simply checking cpuid
each time.
try adding this line as a dependency in cargo.toml
:
pqcrypto = { git = "https://github.com/rustpq/pqcrypto" }
When I compile one of my programs that has this dependency, I get this error:
`
cargo:warning=gcc.exe: error: pqclean/common\aes.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
exit code: 1
running: "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "pqclean/common" "-Wall" "-Wextra" "-std=c99" "-o" "C:\hyxe_wave\target\debug\build\pqcrypto-qtesla-1a419fa1873d1b50\out\pqclean/common\randombytes.o" "-c" "pqclean/common\randombytes.c"
cargo:warning=gcc.exe: error: pqclean/common\sha2.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
exit code: 1
cargo:warning=gcc.exe: error: pqclean/common\fips202.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
cargo:warning=gcc.exe: error: pqclean/common\randombytes.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
`
The MinGW compilers are properly in the $PATH, and further, I have attempted compilation on the MinGW under the Msys suite too. I am compiling using the latest version of cargo, and version 1.42.0 (nightly) of rust
Relevant (IMHO) error
$ cargo test
. . .
error: use of deprecated constant `ffi::PQCLEAN_RAINBOWVCIRCUMZENITHAL_CLEAN_CRYPTO_PUBLICKEYBYTES`: Insecure cryptography, do not use in production
--> pqcrypto-rainbow/src/ffi.rs:1183:40
|
1183 | let mut pk_alt = vec![0u8; PQCLEAN_RAINBOWVCIRCUMZENITHAL_CLEAN_CRYPTO_PUBLICKEYBYTES];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
. . .
warning: `pqcrypto-rainbow` (lib test) generated 234 warnings (171 duplicates)
error: could not compile `pqcrypto-rainbow` due to 153 previous errors; 234 warnings emitted
warning: build failed, waiting for other jobs to finish...
I've looking for a way to generate just the SK
(not the keypair
), and then generate a PK
using the previous SK
(like here).
pqcrypto
doesn't have a function to generate a PK
from a SK
(you can only generate keypair
(both at the same time)), so you can't recover the PK
from the SK
.
SK
SK
(maybe unsafe when used inproperly)3.Is this functionality already there and I haven't noticed?
Thanks!
There seems to be an issue with the McEliece crate.
When calling this as per the API documentation,
use pqcrypto_classicmceliece::mceliece460896::keypair as mckeypair;
use pqcrypto_classicmceliece::mceliece460896::encapsulate as mcencapsulate;
use pqcrypto_classicmceliece::mceliece460896::decapsulate as mcdecapsulate;
#[test]
pub fn test_generate_keypair() {
let (pk, sk) = mckeypair();
let (ss1, ct) = mcencapsulate(&pk);
let ss2 = mcdecapsulate(&ct, &sk);
assert!(ss1==ss2);
}
(names prefixed with mc
to avoid the possibility of namespace clashes)
the test crashes with
thread 'key::test::test_generate_keypair' has overflowed its stack
fatal runtime error: stack overflow
try adding this line as a dependency in cargo.toml
:
pqcrypto = { git = "https://github.com/rustpq/pqcrypto" }
When I compile one of my programs that has this dependency, I get this error:
cargo:warning=gcc.exe: error: pqclean/common\aes.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
exit code: 1
running: "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "pqclean/common" "-Wall" "-Wextra" "-std=c99" "-o" "C:\\hyxe_wave\\target\\debug\\build\\pqcrypto-qtesla-1a419fa1873d1b50\\out\\pqclean/common\\randombytes.o" "-c" "pqclean/common\\randombytes.c"
cargo:warning=gcc.exe: error: pqclean/common\sha2.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
exit code: 1
cargo:warning=gcc.exe: error: pqclean/common\fips202.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
cargo:warning=gcc.exe: error: pqclean/common\randombytes.c: No such file or directory
cargo:warning=gcc.exe: fatal error: no input files
cargo:warning=compilation terminated.
The MinGW compilers are properly in the $PATH
, and further, I have attempted compilation on the MinGW under the Msys suite too. I am compiling using the latest version of cargo, and version 1.42.0 (nightly) of rust
The Cargo.toml file indicates that it still uses 2018 Rust edition, could you please use the latest edition?
Note: This question is specific to pqcrypto-falcon
and I really would like it implemented in that if possible but it also goes for other pqcrypto crates
Hi,
I was wondering whether it is possible to add serde support for deriving serialization/deserialization to the Public Key, Private Key, and Signature structs so they can be serialized/deserialized by simply adding:
#[derive(Serialize,Deserialize)]
Specifically (if there is one you want to try it out on first), I am talking about pqcrypto-falcon
as I am trying to create structs that implement serde like below:
#[derive(Serialize,Deserialize)]
pub struct Keypair {
public: falcon512::PublicKey,
secret: falcon512::SecretKey
}
Due to the actual structs themselves not having serde support, to the best of my knowledge, it does not allow me to serialize/deserialize. If I am wrong about anything, feel free to correct me.
This is a heads-up about a compiler-introduced timing side-channel security issue in PQClean: PQClean/PQClean#556
Thanks to the help of Peter Schwabe, the pqcrystals/kyber upstream already has a fix available for this issue at pq-crystals/kyber@9b8d306
Hello,
Would it be possible to cut a new release of pqcrypto-internals
please ?
I came across #37 that was fixed in an associated PR, but I believe there was no release after that.
Thanks!
Update to the final ML-KEM version.
I've tried to compile pqcrypto to WASM using the instructions provided in WASM.md
, but it only led me to this error:
warning: In file included from cfiles/fips202.c:10:
warning: In file included from /opt/wasi/wasi-sysroot/include/stdlib.h:29:
warning: /opt/wasi/wasi-sysroot/include/bits/alltypes.h:72:24: error: typedef redefinition with different types ('unsigned long' vs 'unsigned int')
warning: typedef unsigned _Addr size_t;
warning: ^
warning: /usr/lib/llvm-6.0/lib/clang/6.0.0/include/stddef.h:62:23: note: previous definition is here
warning: typedef __SIZE_TYPE__ size_t;
warning: ^
warning: 1 error generated.
warning: In file included from cfiles/aes.c:30:
warning: In file included from /opt/wasi/wasi-sysroot/include/string.h:32:
warning: /opt/wasi/wasi-sysroot/include/bits/alltypes.h:72:24: error: typedef redefinition with different types ('unsigned long' vs 'unsigned int')
warning: typedef unsigned _Addr size_t;
warning: ^
warning: /usr/lib/llvm-6.0/lib/clang/6.0.0/include/stddef.h:62:23: note: previous definition is here
warning: typedef __SIZE_TYPE__ size_t;
warning: ^
warning: 1 error generated.
error: failed to run custom build command for `pqcrypto-internals v0.2.4 (/home/user/projects/pqcrypto/pqcrypto-internals)`
env:
cargo:includepath=/home/user/projects/pqcrypto/pqcrypto-internals/include
TARGET = Some("wasm32-wasi")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-unknown-linux-gnu")
cargo:rerun-if-env-changed=CC_wasm32-wasi
CC_wasm32-wasi = None
cargo:rerun-if-env-changed=CC_wasm32_wasi
CC_wasm32_wasi = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
cargo:rerun-if-env-changed=CFLAGS_wasm32-wasi
CFLAGS_wasm32-wasi = None
cargo:rerun-if-env-changed=CFLAGS_wasm32_wasi
CFLAGS_wasm32_wasi = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
There seems to be a clash between wasi-sysroot
and clang
and I'm not sure how to fix this. Any help is definitely appreciated!
Either this is an issue on my end or the instructions provided are wrong/outdated.
Requires PQClean/PQClean#562
There are a series of classes of weak keys which can be easily broken. Unfortunately it not viable to simply modify key generation to avoid the weak keys because they exist in multiple tranches and - so far - the only known way of detecting the weak keys is to perform the attack starting at ~2^18 effort for the weakest class. Even if you verify that a generated key is not in the weakest tranche of keys, it might then be breakable with slightly more than 2^18 effort. (And even if you verify that it not in the weakest 2 tranches, it might be in the 3rd, etc, etc)
It also seems that it is not really possible to modify Leda in a way that resolves the issue without a full redesign. I don't fully understand the argument here but the details are in https://eprint.iacr.org/2020/455 and one of the co-authors is also one of the Leda designers so I believe them.
Since there is no possibility that Leda is or can be made secure I would recommend you remove the crate and yank published versions.
Hello, I found that the output of the liboqs differs for decapsulating the shared secret.
The following tests
#[cfg(test)]
mod tests {
use pqcrypto_kyber::kyber768;
use pqcrypto_traits::kem::{Ciphertext, SecretKey,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CDGGB4XTG8muwBljndoiBuyp0xyCZ1IGl3siS13RXCJbkY7hFLVyOWExHZB2hQ6TX6a7wLP88YtbKcJK9viyixWz+Uky4CypYh7W55+RUabuIWybrPti3JJAazesHJXhefdnRTmd3nUWzpAI81pg5mEMGS42FyelfBOiXhTxaAJrsYH8ujmJc4rG88AK0jFdAP7J1HfJKC+fPvT44zyPnxrUuQ/f7rkPMOmX1uEliKzSnecHs0102Gmj0RFxkqjCZNgvAL/XX4Uy7+nbjCeQfKAG4AX7xIYm6gzcFb11CEeGPDFqEMHta+ocGmH8HYJ43K07fh0JaSfcqLrHeH/vZCib5cc8kddVqMVobOh9uFgpV8VUStozBPJL7z3nMiegI/P/QHzwEnKk5IHamyWJcMWRIodz6Fzh7ZC+JRsXITtKvvrxJ+tA=";
const EXPECTED_SHARED: &str = "T4KKTwQOEQ43G1UzPbBVzi219KXJ54qh6w24IMPEc0A=";
#[test]
fn decapsulate_kyber_ciphertext_pqcrypto() {
let shared = {
let secret_key =
kyber768::SecretKey::from_bytes(&BASE64.decode(SECRET_KEY).unwrap()).unwrap();
let ciphertext =
kyber768::Ciphertext::from_bytes(&BASE64.decode(CIPHERTEXT).unwrap()).unwrap();
let shared = kyber768::decapsulate(&ciphertext, &secret_key);
BASE64.encode(shared.as_bytes())
};
assert_eq!(shared, EXPECTED_SHARED);
}
#[test]
fn decapsulate_kyber_ciphertext_oqs() {
let shared = {
let kem = oqs::kem::Kem::new(oqs::kem::Algorithm::Kyber768).unwrap();
let sk_bytes = BASE64.decode(SECRET_KEY).unwrap();
let secret_key = kem.secret_key_from_bytes(&sk_bytes).unwrap();
let ct_bytes = BASE64.decode(CIPHERTEXT).unwrap();
let ciphertext = kem.ciphertext_from_bytes(&ct_bytes).unwrap();
let shared = kem.decapsulate(&secret_key, &ciphertext).unwrap();
BASE64.encode(&shared.into_vec())
};
assert_eq!(shared, EXPECTED_SHARED);
}
}
produce
running 2 tests
test tests::decapsulate_kyber_ciphertext_oqs ... ok
test tests::decapsulate_kyber_ciphertext_pqcrypto ... FAILED
failures:
---- tests::decapsulate_kyber_ciphertext_pqcrypto stdout ----
thread 'tests::decapsulate_kyber_ciphertext_pqcrypto' panicked at src/main.rs:52:9:
assertion `left == right` failed
left: "II2noqI0NF/VH60MQfgAcSuYOBDARokgh+aft2SCfXU="
right: "T4KKTwQOEQ43G1UzPbBVzi219KXJ54qh6w24IMPEc0A="
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The same shared secret as for liboqs is produced by the kyber
python package, thus suggesting the pqcrypto
kyber768 implementation is faulty.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.