azure-storage-blob 12.23.0__py3-none-any.whl → 12.23.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,6 +40,9 @@ if TYPE_CHECKING:
40
40
 
41
41
  _ENCRYPTION_PROTOCOL_V1 = '1.0'
42
42
  _ENCRYPTION_PROTOCOL_V2 = '2.0'
43
+ _ENCRYPTION_PROTOCOL_V2_1 = '2.1'
44
+ _VALID_ENCRYPTION_PROTOCOLS = [_ENCRYPTION_PROTOCOL_V1, _ENCRYPTION_PROTOCOL_V2, _ENCRYPTION_PROTOCOL_V2_1]
45
+ _ENCRYPTION_V2_PROTOCOLS = [_ENCRYPTION_PROTOCOL_V2, _ENCRYPTION_PROTOCOL_V2_1]
43
46
  _GCM_REGION_DATA_LENGTH = 4 * 1024 * 1024
44
47
  _GCM_NONCE_LENGTH = 12
45
48
  _GCM_TAG_LENGTH = 16
@@ -293,14 +296,14 @@ def encrypt_data_v2(data: bytes, nonce: int, key: bytes) -> bytes:
293
296
 
294
297
  def is_encryption_v2(encryption_data: Optional[_EncryptionData]) -> bool:
295
298
  """
296
- Determine whether the given encryption data signifies version 2.0.
299
+ Determine whether the given encryption data signifies version 2.0 or 2.1.
297
300
 
298
301
  :param Optional[_EncryptionData] encryption_data: The encryption data. Will return False if this is None.
299
302
  :return: True, if the encryption data indicates encryption V2, false otherwise.
300
303
  :rtype: bool
301
304
  """
302
305
  # If encryption_data is None, assume no encryption
303
- return bool(encryption_data and (encryption_data.encryption_agent.protocol == _ENCRYPTION_PROTOCOL_V2))
306
+ return bool(encryption_data and (encryption_data.encryption_agent.protocol in _ENCRYPTION_V2_PROTOCOLS))
304
307
 
305
308
 
306
309
  def modify_user_agent_for_encryption(
@@ -405,7 +408,7 @@ def get_adjusted_download_range_and_offset(
405
408
  end_offset = 15 - (end % 16)
406
409
  end += end_offset
407
410
 
408
- elif encryption_data.encryption_agent.protocol == _ENCRYPTION_PROTOCOL_V2:
411
+ elif encryption_data.encryption_agent.protocol in _ENCRYPTION_V2_PROTOCOLS:
409
412
  start_offset, end_offset = 0, end
410
413
 
411
414
  if encryption_data.encrypted_region_info is None:
@@ -550,7 +553,7 @@ def _dict_to_encryption_data(encryption_data_dict: Dict[str, Any]) -> _Encryptio
550
553
  """
551
554
  try:
552
555
  protocol = encryption_data_dict['EncryptionAgent']['Protocol']
553
- if protocol not in [_ENCRYPTION_PROTOCOL_V1, _ENCRYPTION_PROTOCOL_V2]:
556
+ if protocol not in _VALID_ENCRYPTION_PROTOCOLS:
554
557
  raise ValueError("Unsupported encryption version.")
555
558
  except KeyError as exc:
556
559
  raise ValueError("Unsupported encryption version.") from exc
@@ -636,7 +639,7 @@ def _validate_and_unwrap_cek(
636
639
  # Validate we have the right info for the specified version
637
640
  if encryption_data.encryption_agent.protocol == _ENCRYPTION_PROTOCOL_V1:
638
641
  _validate_not_none('content_encryption_IV', encryption_data.content_encryption_IV)
639
- elif encryption_data.encryption_agent.protocol == _ENCRYPTION_PROTOCOL_V2:
642
+ elif encryption_data.encryption_agent.protocol in _ENCRYPTION_V2_PROTOCOLS:
640
643
  _validate_not_none('encrypted_region_info', encryption_data.encrypted_region_info)
641
644
  else:
642
645
  raise ValueError('Specified encryption version is not supported.')
@@ -662,8 +665,8 @@ def _validate_and_unwrap_cek(
662
665
 
663
666
  # For V2, the version is included with the cek. We need to validate it
664
667
  # and remove it from the actual cek.
665
- if encryption_data.encryption_agent.protocol == _ENCRYPTION_PROTOCOL_V2:
666
- version_2_bytes = _ENCRYPTION_PROTOCOL_V2.encode().ljust(8, b'\0')
668
+ if encryption_data.encryption_agent.protocol in _ENCRYPTION_V2_PROTOCOLS:
669
+ version_2_bytes = encryption_data.encryption_agent.protocol.encode().ljust(8, b'\0')
667
670
  cek_version_bytes = content_encryption_key[:len(version_2_bytes)]
668
671
  if cek_version_bytes != version_2_bytes:
669
672
  raise ValueError('The encryption metadata is not valid and may have been modified.')
@@ -722,7 +725,7 @@ def _decrypt_message(
722
725
  unpadder = PKCS7(128).unpadder()
723
726
  decrypted_data = (unpadder.update(decrypted_data) + unpadder.finalize())
724
727
 
725
- elif encryption_data.encryption_agent.protocol == _ENCRYPTION_PROTOCOL_V2:
728
+ elif encryption_data.encryption_agent.protocol in _ENCRYPTION_V2_PROTOCOLS:
726
729
  block_info = encryption_data.encrypted_region_info
727
730
  if not block_info or not block_info.nonce_length:
728
731
  raise ValueError("Missing required metadata for decryption.")
@@ -894,7 +897,7 @@ def decrypt_blob( # pylint: disable=too-many-locals,too-many-statements
894
897
  raise ValueError('Specified encryption algorithm is not supported.')
895
898
 
896
899
  version = encryption_data.encryption_agent.protocol
897
- if version not in (_ENCRYPTION_PROTOCOL_V1, _ENCRYPTION_PROTOCOL_V2):
900
+ if version not in _VALID_ENCRYPTION_PROTOCOLS:
898
901
  raise ValueError('Specified encryption version is not supported.')
899
902
 
900
903
  content_encryption_key = _validate_and_unwrap_cek(encryption_data, key_encryption_key, key_resolver)
@@ -945,7 +948,7 @@ def decrypt_blob( # pylint: disable=too-many-locals,too-many-statements
945
948
 
946
949
  return content[start_offset: len(content) - end_offset]
947
950
 
948
- if version == _ENCRYPTION_PROTOCOL_V2:
951
+ if version in _ENCRYPTION_V2_PROTOCOLS:
949
952
  # We assume the content contains only full encryption regions
950
953
  total_size = len(content)
951
954
  offset = 0
@@ -4,4 +4,4 @@
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
6
 
7
- VERSION = "12.23.0"
7
+ VERSION = "12.23.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: azure-storage-blob
3
- Version: 12.23.0
3
+ Version: 12.23.1
4
4
  Summary: Microsoft Azure Blob Storage Client Library for Python
5
5
  Home-page: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
6
6
  Author: Microsoft Corporation
@@ -7,7 +7,7 @@ azure/storage/blob/_container_client.py,sha256=piG3Jv1lciW3FifKp_K1trQOtCorm4TTE
7
7
  azure/storage/blob/_container_client_helpers.py,sha256=7H8-506B1iDoCvvwnx3masFjiFSzL1jt5gzIhPmnafA,12596
8
8
  azure/storage/blob/_deserialize.py,sha256=VisgOi6WtpfkeOZ9lMcEAiZyg3A6AqR7oZO52WUXaWU,9937
9
9
  azure/storage/blob/_download.py,sha256=nvj_IBZuSQWV1fO2iB0n_LAndv95SRhbscuGmxu9hHE,40069
10
- azure/storage/blob/_encryption.py,sha256=yw1T7bw7WWSxi4utqCvbpcDTwiMBdsjw0-Eqvud_Ulc,47238
10
+ azure/storage/blob/_encryption.py,sha256=hRSsODop-NFAwO5HHu8sT5zQ1NuN4Absnr_NMhlCL44,47445
11
11
  azure/storage/blob/_lease.py,sha256=ReF0nVfZE8p_clUGpebZPprBdXJ7lOGEqXmJUhvsX5U,18336
12
12
  azure/storage/blob/_list_blobs_helper.py,sha256=smnTcpGSVkk93G0RI7YczhkIM0s0gx4bSGWj_DB8t_s,13160
13
13
  azure/storage/blob/_models.py,sha256=c01JsL1fCAWecXfUUD6Dn50qpjV9r5ZiViXXCwNZVN4,66018
@@ -15,7 +15,7 @@ azure/storage/blob/_quick_query_helper.py,sha256=HO6ufvSEWQSaFJ4CanujE4IN7FYB6y1
15
15
  azure/storage/blob/_serialize.py,sha256=5_MsQx2hVJnhNqlxP6_O7rksxEoGJXXSJSG3WIUd-iw,8146
16
16
  azure/storage/blob/_shared_access_signature.py,sha256=VkoKyo5apDnKQ8wuEBp1C6MaKlqDHAZOf5wlqRcqdOA,35354
17
17
  azure/storage/blob/_upload_helpers.py,sha256=-ZpqzST-wFdWqCm_I4oWGLTMQ5N0aYb3RHxaMvmf9Q4,14688
18
- azure/storage/blob/_version.py,sha256=qk_3SN9FXGO65fpW7ymqmUkdNnMNAuvdI-ea-NvmFzw,331
18
+ azure/storage/blob/_version.py,sha256=UJeQ8inMo-t88amR6znjwTdSjvmma6OAm0OZr0xls6Q,331
19
19
  azure/storage/blob/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  azure/storage/blob/_generated/__init__.py,sha256=J2H2yiFhRSsMCNKUI7gaYFIQ4_AAbWjPtzXdOsHFQFI,835
21
21
  azure/storage/blob/_generated/_azure_blob_storage.py,sha256=VKK-9xxlF9DfNHuxlOxG6LB0XOZDLFdviW8O4W2AqeI,5737
@@ -77,8 +77,8 @@ azure/storage/blob/aio/_lease_async.py,sha256=dy4_KZYuIhlxEvYO4GLTKdZz4UzFkpxcm7
77
77
  azure/storage/blob/aio/_list_blobs_helper.py,sha256=cbrJcaGVfOvVCcLYd5dGx-jV3JjSvKfDIi2AQjf79qs,9920
78
78
  azure/storage/blob/aio/_models.py,sha256=fdv7OQc6utrGBIS8FSNuBhYK5Q65o1TbKvdeeQaeUOc,8143
79
79
  azure/storage/blob/aio/_upload_helpers.py,sha256=zROsVN6PK2Cn59Ysq08Ide5T1IGG2yH7oK9ZCn5uQXs,14038
80
- azure_storage_blob-12.23.0.dist-info/LICENSE,sha256=_VMkgdgo4ToLE8y1mOAjOKNhd0BnWoYu5r3BVBto6T0,1073
81
- azure_storage_blob-12.23.0.dist-info/METADATA,sha256=xuw3F1eB7EGqb8Wjkm8v99XZp1_3LvtdOHYJM4oObJs,26252
82
- azure_storage_blob-12.23.0.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
83
- azure_storage_blob-12.23.0.dist-info/top_level.txt,sha256=S7DhWV9m80TBzAhOFjxDUiNbKszzoThbnrSz5MpbHSQ,6
84
- azure_storage_blob-12.23.0.dist-info/RECORD,,
80
+ azure_storage_blob-12.23.1.dist-info/LICENSE,sha256=_VMkgdgo4ToLE8y1mOAjOKNhd0BnWoYu5r3BVBto6T0,1073
81
+ azure_storage_blob-12.23.1.dist-info/METADATA,sha256=MsP96yVjSewFFWu2tOQgUL0AiNG1-MlHxML8LCReiyY,26252
82
+ azure_storage_blob-12.23.1.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
83
+ azure_storage_blob-12.23.1.dist-info/top_level.txt,sha256=S7DhWV9m80TBzAhOFjxDUiNbKszzoThbnrSz5MpbHSQ,6
84
+ azure_storage_blob-12.23.1.dist-info/RECORD,,