1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-07 06:42:56 +03:00

cert_audit: Check the version of cryptography

The script requires cryptography >= 35.0.0, we
need to check the version and provide meaningful
error message when the package version was too
old.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
This commit is contained in:
Pengyu Lv
2023-04-25 14:55:38 +08:00
parent c34b9ac18c
commit 1381598aa3
2 changed files with 15 additions and 3 deletions

View File

@@ -10,3 +10,8 @@ pylint == 2.4.4
# Use the earliest version of mypy that works with our code base. # Use the earliest version of mypy that works with our code base.
# See https://github.com/Mbed-TLS/mbedtls/pull/3953 . # See https://github.com/Mbed-TLS/mbedtls/pull/3953 .
mypy >= 0.780 mypy >= 0.780
# Install cryptography to avoid import-error reported by pylint.
# What we really need is cryptography >= 35.0.0, which is only
# available for Python >= 3.6.
cryptography # >= 35.0.0

View File

@@ -34,15 +34,21 @@ import logging
from enum import Enum from enum import Enum
# The script requires cryptography >= 35.0.0 which is only available # The script requires cryptography >= 35.0.0 which is only available
# for Python >= 3.6. Disable the pylint error here until we were # for Python >= 3.6.
# using modern system on our CI. import cryptography
from cryptography import x509 #pylint: disable=import-error from cryptography import x509
from generate_test_code import FileWrapper from generate_test_code import FileWrapper
import scripts_path # pylint: disable=unused-import import scripts_path # pylint: disable=unused-import
from mbedtls_dev import build_tree from mbedtls_dev import build_tree
def check_cryptography_version():
match = re.match(r'^[0-9]+', cryptography.__version__)
if match is None or int(match[0]) < 35:
raise Exception("audit-validity-dates requires cryptography >= 35.0.0"
+ "({} is too old)".format(cryptography.__version__))
class DataType(Enum): class DataType(Enum):
CRT = 1 # Certificate CRT = 1 # Certificate
CRL = 2 # Certificate Revocation List CRL = 2 # Certificate Revocation List
@@ -460,5 +466,6 @@ def main():
logger.debug("Done!") logger.debug("Done!")
check_cryptography_version()
if __name__ == "__main__": if __name__ == "__main__":
main() main()