Skip to content

Commit 9900995

Browse files
authored
[Key Vault] Prepare for strict-sphinx (#33969)
1 parent 65337c2 commit 9900995

File tree

4 files changed

+49
-17
lines changed

4 files changed

+49
-17
lines changed

sdk/keyvault/azure-keyvault-administration/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ A `KeyVaultSettingsClient` manages Managed HSM account settings.
124124
This section contains code snippets covering common tasks:
125125
* Access control
126126
* [List all role definitions](#list-all-role-definitions)
127-
* [Set, get, and delete a role definition](#set-get-and-delete-a-role-defintion)
127+
* [Set, get, and delete a role definition](#set-get-and-delete-a-role-definition)
128128
* [List all role assignments](#list-all-role-assignments)
129129
* [Create, get, and delete a role assignment](#create-get-and-delete-a-role-assignment)
130130
* Backup and restore
@@ -149,7 +149,6 @@ for definition in role_definitions:
149149
<!-- END SNIPPET -->
150150

151151
### Set, get, and delete a role definition
152-
153152
`set_role_definition` can be used by a `KeyVaultAccessControlClient` to either create a custom role definition or update
154153
an existing definition with the specified unique `name` (a UUID).
155154

sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/_models.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def verify(
222222
def recover_data_from_signature(
223223
self, signature: bytes, padding: AsymmetricPadding, algorithm: Optional[HashAlgorithm]
224224
) -> bytes:
225+
# pylint: disable=line-too-long
225226
"""Recovers the signed data from the signature. Only supported with `cryptography` version 3.3 and above.
226227
227228
This function uses the `cryptography` library's implementation.
@@ -236,11 +237,10 @@ def recover_data_from_signature(
236237
237238
Normally you should use the `verify()` function to validate the signature. But for some non-standard signature
238239
formats you may need to explicitly recover and validate the signed data. The following are some examples:
239-
* Some old Thawte and Verisign timestamp certificates without `DigestInfo`.
240-
* Signed MD5/SHA1 hashes in TLS 1.1 or earlier
241-
(`RFC 4346 <https://datatracker.ietf.org/doc/html/rfc4346.html>`_, section 4.7).
242-
* IKE version 1 signatures without `DigestInfo`
243-
(`RFC 2409 <https://datatracker.ietf.org/doc/html/rfc2409.html>`_, section 5.1).
240+
241+
* Some old Thawte and Verisign timestamp certificates without `DigestInfo`.
242+
* Signed MD5/SHA1 hashes in TLS 1.1 or earlier (`RFC 4346 <https://datatracker.ietf.org/doc/html/rfc4346.html>`_, section 4.7).
243+
* IKE version 1 signatures without `DigestInfo` (`RFC 2409 <https://datatracker.ietf.org/doc/html/rfc2409.html>`_, section 5.1).
244244
245245
:param bytes signature: The signature.
246246
:param padding: An instance of `AsymmetricPadding`. Recovery is only supported with some of the padding types.
@@ -254,7 +254,7 @@ def recover_data_from_signature(
254254
NotImplementedError if the local version of `cryptography` doesn't support this method.
255255
:class:`~cryptography.exceptions.InvalidSignature` if the signature is invalid.
256256
:class:`~cryptography.exceptions.UnsupportedAlgorithm` if the signature data recovery is not supported with
257-
the provided `padding` type.
257+
the provided `padding` type.
258258
"""
259259
public_key = self.public_numbers().public_key()
260260
try:

sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/aio/__init__.py

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,49 @@
22
# Copyright (c) Microsoft Corporation.
33
# Licensed under the MIT License.
44
# ------------------------------------
5+
from typing import Any, List, Optional
6+
57
from ._client import CryptographyClient
6-
from .. import EncryptionAlgorithm, KeyWrapAlgorithm, SignatureAlgorithm
7-
from .. import EncryptResult, SignResult, WrapResult
8+
89

910
__all__ = [
1011
"CryptographyClient",
11-
"EncryptionAlgorithm",
12-
"EncryptResult",
13-
"KeyWrapAlgorithm",
14-
"SignatureAlgorithm",
15-
"SignResult",
16-
"WrapResult",
1712
]
13+
14+
15+
def __dir__() -> List[str]:
16+
return __all__
17+
18+
19+
# Allow importing these types for backwards compatibility, but exclude indexing types that shouldn't be in aio namespace
20+
21+
22+
def __getattr__(name: str):
23+
requested: Optional[Any] = None
24+
if name == "EncryptionAlgorithm":
25+
from .. import EncryptionAlgorithm
26+
27+
requested = EncryptionAlgorithm
28+
if name == "KeyWrapAlgorithm":
29+
from .. import KeyWrapAlgorithm
30+
31+
requested = KeyWrapAlgorithm
32+
if name == "SignatureAlgorithm":
33+
from .. import SignatureAlgorithm
34+
35+
requested = SignatureAlgorithm
36+
if name == "EncryptResult":
37+
from .. import EncryptResult
38+
39+
requested = EncryptResult
40+
if name == "SignResult":
41+
from .. import SignResult
42+
43+
requested = SignResult
44+
if name == "WrapResult":
45+
from .. import WrapResult
46+
47+
requested = WrapResult
48+
if requested:
49+
return requested
50+
raise AttributeError(f"module 'azure.keyvault.keys.crypto.aio' has no attribute {name}")

sdk/keyvault/azure-keyvault-keys/tests/test_crypto_client_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from azure.keyvault.keys.crypto._providers import NoLocalCryptography, get_local_cryptography_provider
1818
from azure.keyvault.keys.crypto.aio import (
1919
CryptographyClient,
20-
EncryptionAlgorithm,
20+
EncryptionAlgorithm, # Shouldn't be imported from aio namespace, but do so to test backwards compatibility
2121
KeyWrapAlgorithm,
2222
SignatureAlgorithm,
2323
)

0 commit comments

Comments
 (0)