diff --git a/examples/protocols/mqtt/ssl_ds/configure_ds.py b/examples/protocols/mqtt/ssl_ds/configure_ds.py index 374309a365..b718052301 100644 --- a/examples/protocols/mqtt/ssl_ds/configure_ds.py +++ b/examples/protocols/mqtt/ssl_ds/configure_ds.py @@ -29,14 +29,14 @@ from cryptography.utils import int_to_bytes try: import nvs_partition_gen as nvs_gen except ImportError: - idf_path = os.getenv("IDF_PATH") + idf_path = os.getenv('IDF_PATH') if not idf_path or not os.path.exists(idf_path): - raise Exception("IDF_PATH not found") - sys.path.insert(0, os.path.join(idf_path, "components", "nvs_flash", "nvs_partition_generator")) + raise Exception('IDF_PATH not found') + sys.path.insert(0, os.path.join(idf_path, 'components', 'nvs_flash', 'nvs_partition_generator')) import nvs_partition_gen as nvs_gen # Check python version is proper or not to avoid script failure -assert sys.version_info >= (3, 6, 0), "Python version too low." +assert sys.version_info >= (3, 6, 0), 'Python version too low.' esp_ds_data_dir = 'esp_ds_data' # hmac_key_file is generated when HMAC_KEY is calculated, it is used when burning HMAC_KEY to efuse @@ -59,7 +59,7 @@ def get_idf_target(): idf_target_read = sdkconfig['IDF_TARGET'] return idf_target_read else: - print("ERROR: IDF_TARGET has not been set for the supported targets," + print('ERROR: IDF_TARGET has not been set for the supported targets,' "\nplase execute command \"idf.py set-target {TARGET}\" in the example directory") return None @@ -96,10 +96,10 @@ def number_as_bytes(number, pad_bits=None): def calculate_ds_parameters(privkey, priv_key_pass, hmac_key, idf_target): private_key = load_privatekey(privkey, priv_key_pass) if not isinstance(private_key, rsa.RSAPrivateKey): - print("ERROR: Only RSA private keys are supported") + print('ERROR: Only RSA private keys are supported') sys.exit(-1) if hmac_key is None: - print("ERROR: hmac_key cannot be None") + print('ERROR: hmac_key cannot be None') sys.exit(-2) priv_numbers = private_key.private_numbers() @@ -108,7 +108,7 @@ def calculate_ds_parameters(privkey, priv_key_pass, hmac_key, idf_target): M = pub_numbers.n key_size = private_key.key_size if key_size not in supported_key_size[idf_target]: - print("ERROR: Private key size {0} not supported for the target {1},\nthe supported key sizes are {2}" + print('ERROR: Private key size {0} not supported for the target {1},\nthe supported key sizes are {2}' .format(key_size, idf_target, str(supported_key_size[idf_target]))) sys.exit(-1) @@ -122,12 +122,12 @@ def calculate_ds_parameters(privkey, priv_key_pass, hmac_key, idf_target): # get max supported key size for the respective target max_len = max(supported_key_size[idf_target]) - aes_key = hmac.HMAC(hmac_key, b"\xFF" * 32, hashlib.sha256).digest() + aes_key = hmac.HMAC(hmac_key, b'\xFF' * 32, hashlib.sha256).digest() md_in = number_as_bytes(Y, max_len) + \ number_as_bytes(M, max_len) + \ number_as_bytes(rinv, max_len) + \ - struct.pack("