Paranoid 项目用于检查密码学产物(如公钥、数字签名和一般伪随机数)中已知的弱点。该库包含文献中已有工作的实现与优化。已有工作表明,这些产物的生成在某些情况下存在缺陷。以下是该库所基于的部分出版物示例。
目标是提升 Google 内外密码学用例的可信度。
在处理非对称加密时,密码学产物通常:
借助 Paranoid,任何密码学产物都可以被测试,但其主要动机是检测弱第三方硬件或软件黑盒的使用。因此,即使我们无法检查源代码(上述情况 3),也可以使用 Paranoid。
该项目旨在检测已知漏洞以及未知漏洞。例如,它尝试识别由编程错误或使用弱专有随机数生成器导致的漏洞。检测新漏洞当然比检测已知漏洞困难得多。此类检测可能需要大量产物集合,或者只能以较低概率发现弱产物。
因此,我们非常希望收到反馈,并了解生成弱密码学产物的密码学库(参见征集贡献)。该项目持续进行中。在了解弱实现后,计划分析并添加针对它们的检测。
当前已实现检查的文档位于 docs。文档将随时间补充更多内容。
要了解如何使用这些检查,可以查看 examples 文件夹或单元测试(*test.py 文件)。示例演示了测试不同的密码学产物。
克隆仓库:
$ git clone https://github.com/google/paranoid_crypto.git && cd paranoid_crypto
NOTE: The commands below have been tested on Debian stable version
(bookworm). Make sure you will be using python3.11 or newer.
Install dependencies:
$ sudo apt update && sudo apt install python3 python3-full python3-pip \
python3-pybind11 python3-fpylll python3-gmpy2 libgmp-dev protobuf-compiler
Create and activate a virtual environment:
$ python3 -m venv --system-site-packages ~/paranoid-venv
$ source ~/paranoid-venv/bin/activate
NOTE: If you know what you are doing, you can instead skip to the next step
and use --break-system-packages switch for pip.
Install paranoid_crypto python package:
$ python3 -m pip install .
要检查安装是否成功,可以运行单元测试。 例如:
$ cd paranoid_crypto && python3 -m unittest discover -b -p "*test.py"
.................................................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 305 tests in 314.660s
OK
或者,如果你想在容器中运行它,可以使用我们提供的 Dockerfile,如下所示。
注意:请确保已安装 docker。
克隆仓库后,构建 docker 镜像:
$ docker build -t paranoid-img .
Create and start the container:
$ docker run --name paranoid-container -it paranoid-img
paranoid-user@6191368b26b8:~$
To check whether the installation was successful, you can run the unit tests. For example:
paranoid-user@6191368b26b8:~$ cd paranoid_crypto && python3 -m unittest discover -b -p "*test.py"
.................................................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 305 tests in 307.555s
OK
Similar to other published works, we have been analyzing the crypto artifacts from Certificate Transparency (CT), which logs issued website certificates since 2013 with the goal of making them transparent and verifiable. Its database contains more than 7 billion certificates as of September 2022. For the Paranoid checks of EC public keys and ECDSA signatures, so far, we have not found any weak artifacts in CT. For the RSA public key checks with severities high or critical, we have the following results:
| TestName | Potentially Related CVEs | Severity | Number of Weak Artifacts |
|---|---|---|---|
| CheckOpensslDenylist | CVE-2008-0166 | SEVERITY_CRITICAL | 3989 |
| CheckROCA | CVE-2017-15361 | SEVERITY_HIGH | 2875 |
| CheckGCD | - | SEVERITY_CRITICAL | 1860 |
| CheckFermat | CVE-2022-26320 | SEVERITY_CRITICAL | 36 |
| CheckContinuedFractions | - | SEVERITY_CRITICAL | 16 |
| CheckBitPatterns | - | SEVERITY_CRITICAL | 6 |
| CheckPermutedBitPatterns | - | SEVERITY_CRITICAL | 6 |
| CheckKeypairDenylist | CVE-2021-41117 | SEVERITY_CRITICAL | 4 |
| CheckPollardpm1 | - | SEVERITY_CRITICAL | 1 |
Some of these certificates were already expired or revoked. For the ones that were still active (most of the CheckGCD ones), we immediately reported them to the Certificate Authorities to be revoked.
This library is developed and maintained by members of Google Security Team, but this is not an officially supported Google product. If you want to contribute, please read CONTRIBUTING and send us pull requests. You can also report bugs or file feature requests.
If you use Paranoid in your research, you can cite it using the following BibTeX:
@software{Barbosa_Bleichenbacher_Paranoid_Crypto_2022,
author = {Barbosa, Pedro and Bleichenbacher, Daniel},
license = {Apache-2.0},
month = {8},
title = {{Paranoid Crypto}},
url = {https://github.com/google/paranoid_crypto},
year = {2022}
}