Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/keyvault/azure-keyvault-certificates/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 4.0.0b4
### Breaking changes
- Enums 'JsonWebKeyCurveName' and 'JsonWebKeyType' have been renamed to 'KeyCurveName' and 'KeyType', respectively.

## 4.0.0b3 (2019-09-11)
Version 4.0.0b3 is the first preview of our efforts to create a user-friendly and Pythonic client library for Azure Key Vault.
For more information about preview releases of other Azure SDK libraries, please visit https://aka.ms/azure-sdk-preview1-python.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License.
# ------------------------------------
from .client import CertificateClient
from .enums import ActionType, JsonWebKeyCurveName, JsonWebKeyType, SecretContentType, KeyUsageType
from .enums import ActionType, KeyCurveName, KeyType, SecretContentType, KeyUsageType
from .models import (
AdministratorDetails,
CertificatePolicy,
Expand All @@ -18,8 +18,8 @@
"CertificateClient",
"CertificatePolicy",
"Contact",
"JsonWebKeyCurveName",
"JsonWebKeyType",
"KeyCurveName",
"KeyType",
"KeyProperties",
"KeyUsageType",
"LifetimeAction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------

from .client import CertificateClient
from ..enums import ActionType, JsonWebKeyCurveName, JsonWebKeyType, SecretContentType, KeyUsageType
from ..enums import ActionType, KeyCurveName, KeyType, SecretContentType, KeyUsageType
from ..models import AdministratorDetails, CertificatePolicy, Contact, KeyProperties, LifetimeAction

__all__ = [
Expand All @@ -13,8 +13,8 @@
"CertificateClient",
"CertificatePolicy",
"Contact",
"JsonWebKeyCurveName",
"JsonWebKeyType",
"KeyCurveName",
"KeyType",
"KeyProperties",
"KeyUsageType",
"LifetimeAction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class KeyUsageType(str, Enum):
decipher_only = "decipherOnly"


class JsonWebKeyType(str, Enum):
class KeyType(str, Enum):
"""Supported key types"""

ec = "EC" #: Elliptic Curve
Expand All @@ -43,7 +43,7 @@ class JsonWebKeyType(str, Enum):
oct = "oct" #: Octet sequence (used to represent symmetric keys)


class JsonWebKeyCurveName(str, Enum):
class KeyCurveName(str, Enum):
"""Supported elliptic curves"""

p_256 = "P-256" #: The NIST P-256 elliptic curve, AKA SECG curve SECP256R1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from ._shared import parse_vault_id
from ._shared._generated.v7_0 import models
from .enums import ActionType, KeyUsageType, JsonWebKeyCurveName, JsonWebKeyType, SecretContentType
from .enums import ActionType, KeyUsageType, KeyCurveName, KeyType, SecretContentType

try:
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -703,11 +703,11 @@ def _from_certificate_policy_bundle(cls, certificate_policy_bundle):

key_properties = KeyProperties(
exportable=certificate_policy_bundle.key_properties.exportable,
key_type=(JsonWebKeyType(certificate_policy_bundle.key_properties.key_type)
key_type=(KeyType(certificate_policy_bundle.key_properties.key_type)
if certificate_policy_bundle.key_properties.key_type else None),
key_size=certificate_policy_bundle.key_properties.key_size,
reuse_key=certificate_policy_bundle.key_properties.reuse_key,
curve=(JsonWebKeyCurveName(certificate_policy_bundle.key_properties.curve)
curve=(KeyCurveName(certificate_policy_bundle.key_properties.curve)
if certificate_policy_bundle.key_properties.curve else None),
ekus=(certificate_policy_bundle.x509_certificate_properties.ekus
if certificate_policy_bundle.x509_certificate_properties else None),
Expand Down Expand Up @@ -1116,14 +1116,14 @@ class KeyProperties(object):
:param bool exportable: Indicates if the private key can be exported.
:param key_type: The type of key pair to be used for the certificate.
Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct'
:type key_type: str or ~azure.keyvault.certificates.enums.JsonWebKeyType
:type key_type: str or ~azure.keyvault.certificates.enums.KeyType
:param int key_size: The key size in bits. For example: 2048, 3072, or 4096
for RSA.
:param bool reuse_key: Indicates if the same key pair will be used on certificate
renewal.
:param curve: Elliptic curve name. For valid values, see JsonWebKeyCurveName.
:param curve: Elliptic curve name. For valid values, see KeyCurveName.
Possible values include: 'P-256', 'P-384', 'P-521', 'P-256K'
:type curve: str or ~azure.keyvault.certificates.enums.JsonWebKeyCurveName
:type curve: str or ~azure.keyvault.certificates.enums.KeyCurveName
:param ekus: The enhanced key usages.
:type ekus: list[str]
:param key_usage: List of key usages.
Expand All @@ -1132,10 +1132,10 @@ class KeyProperties(object):
def __init__(
self,
exportable=None, # type: Optional[bool]
key_type=None, # type: Optional[JsonWebKeyType]
key_type=None, # type: Optional[KeyType]
key_size=None, # type: Optional[str]
reuse_key=None, # type: Optional[bool]
curve=None, # type: Optional[JsonWebKeyCurveName]
curve=None, # type: Optional[KeyCurveName]
ekus=None, # type: Optional[list[str]]
key_usage=None # type: Optional[list[KeyUsageType]]
):
Expand All @@ -1159,10 +1159,10 @@ def exportable(self):

@property
def key_type(self):
# type: () -> JsonWebKeyType
# type: () -> KeyType
"""The type of key pair to be used for the certificate.

:rtype: ~azure.keyvault.certificates.enums.JsonWebKeyType
:rtype: ~azure.keyvault.certificates.enums.KeyType
"""
return self._key_type

Expand All @@ -1186,10 +1186,10 @@ def reuse_key(self):

@property
def curve(self):
# type: () -> JsonWebKeyCurveName
# type: () -> KeyCurveName
"""Elliptic curve name.

:rtype: ~azure.keyvault.certificates.enums.JsonWebKeyCurveName
:rtype: ~azure.keyvault.certificates.enums.KeyCurveName
"""
return self._curve

Expand Down
4 changes: 4 additions & 0 deletions sdk/keyvault/azure-keyvault-keys/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 4.0.0b4
- Enums 'JsonWebKeyCurveName', 'JsonWebKeyOperation', and 'JsonWebKeyType' have
been renamed to 'KeyCurveName', 'KeyOperation', and 'KeyType', respectively.

## 4.0.0b3 (2019-09-11)
### Breaking changes:
- `CryptographyClient` methods `wrap` and `unwrap` are renamed `wrap_key` and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Licensed under the MIT License.
# -------------------------------------
from .client import KeyClient
from .enums import JsonWebKeyCurveName, JsonWebKeyOperation, JsonWebKeyType
from .enums import KeyCurveName, KeyOperation, KeyType

__all__ = ["JsonWebKeyCurveName", "JsonWebKeyOperation", "JsonWebKeyType", "KeyClient"]
__all__ = ["KeyCurveName", "KeyOperation", "KeyType", "KeyClient"]
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ async def create_key(

:param str name: The name of the new key. Key Vault will generate the key's version.
:param key_type: The type of key to create
:type key_type: str or ~azure.keyvault.keys.enums.JsonWebKeyType
:type key_type: str or ~azure.keyvault.keys.enums.KeyType
:param int size: (optional) RSA key size in bits, for example 2048, 3072, or 4096.
:param key_operations: (optional) Allowed key operations
:type key_operations: list(str or ~azure.keyvault.keys.enums.JsonWebKeyOperation)
:type key_operations: list(str or ~azure.keyvault.keys.enums.KeyOperation)
:param bool enabled: (optional) Whether the key is enabled for use
:param expires: (optional) Expiry date of the key in UTC
:param datetime.datetime not_before: (optional) Not before date of the key in UTC
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:param curve: (optional) Elliptic curve name. Defaults to the NIST P-256 elliptic curve.
:type curve: ~azure.keyvault.keys.enums.JsonWebKeyCurveName or str
:type curve: ~azure.keyvault.keys.enums.KeyCurveName or str
:returns: The created key
:rtype: ~azure.keyvault.keys.models.Key

Expand Down Expand Up @@ -116,7 +116,7 @@ async def create_rsa_key(
:param bool hsm: Whether to create a hardware key (HSM) or software key
:param int size: (optional) Key size in bits, for example 2048, 3072, or 4096
:param key_operations: (optional) Allowed key operations
:type key_operations: list(str or ~azure.keyvault.keys.enums.JsonWebKeyOperation)
:type key_operations: list(str or ~azure.keyvault.keys.enums.KeyOperation)
:param bool enabled: (optional) Whether the key is enabled for use
:param expires: (optional) Expiry date of the key in UTC
:param datetime.datetime not_before: (optional) Not before date of the key in UTC
Expand Down Expand Up @@ -165,9 +165,9 @@ async def create_ec_key(
:param str name: The name for the new key. Key Vault will generate the key's version.
:param bool hsm: Whether to create as a hardware key (HSM) or software key.
:param curve: (optional) Elliptic curve name. Defaults to the NIST P-256 elliptic curve.
:type curve: ~azure.keyvault.keys.enums.JsonWebKeyCurveName or str
:type curve: ~azure.keyvault.keys.enums.KeyCurveName or str
:param key_operations: (optional) Allowed key operations
:type key_operations: list(~azure.keyvault.keys.enums.JsonWebKeyOperation)
:type key_operations: list(~azure.keyvault.keys.enums.KeyOperation)
:param bool enabled: (optional) Whether the key is enabled for use
:param datetime.datetime expires: (optional) Expiry date of the key in UTC
:param datetime.datetime not_before: (optional) Not before date of the key in UTC
Expand Down Expand Up @@ -398,7 +398,7 @@ async def update_key(
:param str name: The name of key to update
:param str version: (optional) The version of the key to update
:param key_operations: (optional) Allowed key operations
:type key_operations: list(str or ~azure.keyvault.keys.enums.JsonWebKeyOperation)
:type key_operations: list(str or ~azure.keyvault.keys.enums.KeyOperation)
:param bool enabled: (optional) Whether the key is enabled for use
:param datetime.datetime expires: (optional) Expiry date of the key in UTC
:param datetime.datetime not_before: (optional) Not before date of the key in UTC
Expand Down
14 changes: 7 additions & 7 deletions sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ def create_key(

:param str name: The name of the new key. Key Vault will generate the key's version.
:param key_type: The type of key to create
:type key_type: str or ~azure.keyvault.keys.enums.JsonWebKeyType
:type key_type: str or ~azure.keyvault.keys.enums.KeyType
:param int size: (optional) RSA key size in bits, for example 2048, 3072, or 4096.
:param key_operations: (optional) Allowed key operations
:type key_operations: list(str or ~azure.keyvault.keys.enums.JsonWebKeyOperation)
:type key_operations: list(str or ~azure.keyvault.keys.enums.KeyOperation)
:param bool enabled: (optional) Whether the key is enabled for use
:param expires: (optional) Expiry date of the key in UTC
:param datetime.datetime not_before: (optional) Not before date of the key in UTC
:param dict tags: (optional) Application specific metadata in the form of key-value pairs
:param curve: (optional) Elliptic curve name. Defaults to the NIST P-256 elliptic curve.
:type curve: ~azure.keyvault.keys.enums.JsonWebKeyCurveName or str
:type curve: ~azure.keyvault.keys.enums.KeyCurveName or str
:returns: The created key
:rtype: ~azure.keyvault.keys.models.Key

Expand Down Expand Up @@ -127,7 +127,7 @@ def create_rsa_key(
:param bool hsm: Whether to create a hardware key (HSM) or software key
:param int size: (optional) Key size in bits, for example 2048, 3072, or 4096
:param key_operations: (optional) Allowed key operations
:type key_operations: list(str or ~azure.keyvault.keys.enums.JsonWebKeyOperation)
:type key_operations: list(str or ~azure.keyvault.keys.enums.KeyOperation)
:param bool enabled: (optional) Whether the key is enabled for use
:param expires: (optional) Expiry date of the key in UTC
:param datetime.datetime not_before: (optional) Not before date of the key in UTC
Expand Down Expand Up @@ -177,9 +177,9 @@ def create_ec_key(
:param str name: The name for the new key. Key Vault will generate the key's version.
:param bool hsm: Whether to create as a hardware key (HSM) or software key.
:param curve: (optional) Elliptic curve name. Defaults to the NIST P-256 elliptic curve.
:type curve: ~azure.keyvault.keys.enums.JsonWebKeyCurveName or str
:type curve: ~azure.keyvault.keys.enums.KeyCurveName or str
:param key_operations: (optional) Allowed key operations
:type key_operations: list(~azure.keyvault.keys.enums.JsonWebKeyOperation)
:type key_operations: list(~azure.keyvault.keys.enums.KeyOperation)
:param bool enabled: (optional) Whether the key is enabled for use
:param datetime.datetime expires: (optional) Expiry date of the key in UTC
:param datetime.datetime not_before: (optional) Not before date of the key in UTC
Expand Down Expand Up @@ -424,7 +424,7 @@ def update_key(
:param str name: The name of key to update
:param str version: (optional) The version of the key to update
:param key_operations: (optional) Allowed key operations
:type key_operations: list(str or ~azure.keyvault.keys.enums.JsonWebKeyOperation)
:type key_operations: list(str or ~azure.keyvault.keys.enums.KeyOperation)
:param bool enabled: (optional) Whether the key is enabled for use
:param datetime.datetime expires: (optional) Expiry date of the key in UTC
:param datetime.datetime not_before: (optional) Not before date of the key in UTC
Expand Down
6 changes: 3 additions & 3 deletions sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from enum import Enum


class JsonWebKeyCurveName(str, Enum):
class KeyCurveName(str, Enum):
"""Supported elliptic curves"""

p_256 = "P-256" #: The NIST P-256 elliptic curve, AKA SECG curve SECP256R1.
Expand All @@ -14,7 +14,7 @@ class JsonWebKeyCurveName(str, Enum):
p_256_k = "P-256K" #: The SECG SECP256K1 elliptic curve.


class JsonWebKeyOperation(str, Enum):
class KeyOperation(str, Enum):
"""Supported key operations"""

encrypt = "encrypt"
Expand All @@ -25,7 +25,7 @@ class JsonWebKeyOperation(str, Enum):
unwrap_key = "unwrapKey"


class JsonWebKeyType(str, Enum):
class KeyType(str, Enum):
"""Supported key types"""

ec = "EC" #: Elliptic Curve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class JsonWebKey(object):

:param str kid: Key identifier.
:param kty: Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
:type kty: str or ~azure.keyvault.keys.enums.JsonWebKeyType
:type kty: str or ~azure.keyvault.keys.enums.KeyType
:param key_ops: Allowed operations for the key
:type key_ops: list(~azure.keyvault.keys.enums.JsonWebKeyOperation)
:type key_ops: list(~azure.keyvault.keys.enums.KeyOperation)
:param bytes n: RSA modulus.
:param bytes e: RSA public exponent.
:param bytes d: RSA private exponent, or the D component of an EC private key.
Expand All @@ -38,7 +38,7 @@ class JsonWebKey(object):
:param bytes k: Symmetric key.
:param bytes t: HSM Token, used with 'Bring Your Own Key'.
:param crv: Elliptic curve name.
:type crv: str or ~azure.keyvault.keys.enums.JsonWebKeyCurveName
:type crv: str or ~azure.keyvault.keys.enums.KeyCurveName
:param bytes x: X component of an EC public key.
:param bytes y: Y component of an EC public key.
"""
Expand Down
10 changes: 5 additions & 5 deletions sdk/keyvault/azure-keyvault-keys/tests/test_crypto_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import codecs
import hashlib

from azure.keyvault.keys import JsonWebKeyCurveName
from azure.keyvault.keys import KeyCurveName
from azure.keyvault.keys.crypto import EncryptionAlgorithm, KeyWrapAlgorithm, SignatureAlgorithm
from azure.keyvault.keys._shared._generated.v7_0.models import JsonWebKey
from azure.mgmt.keyvault.models import KeyPermissions, Permissions
Expand Down Expand Up @@ -189,10 +189,10 @@ def test_ec_verify_local(self, vault_client, **kwargs):
key_client = vault_client.keys

matrix = {
JsonWebKeyCurveName.p_256: (SignatureAlgorithm.es256, hashlib.sha256),
JsonWebKeyCurveName.p_256_k: (SignatureAlgorithm.es256_k, hashlib.sha256),
JsonWebKeyCurveName.p_384: (SignatureAlgorithm.es384, hashlib.sha384),
JsonWebKeyCurveName.p_521: (SignatureAlgorithm.es512, hashlib.sha512),
KeyCurveName.p_256: (SignatureAlgorithm.es256, hashlib.sha256),
KeyCurveName.p_256_k: (SignatureAlgorithm.es256_k, hashlib.sha256),
KeyCurveName.p_384: (SignatureAlgorithm.es384, hashlib.sha384),
KeyCurveName.p_521: (SignatureAlgorithm.es512, hashlib.sha512),
}

for curve, (signature_algorithm, hash_function) in matrix.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import codecs
import hashlib

from azure.keyvault.keys import JsonWebKeyCurveName
from azure.keyvault.keys import KeyCurveName
from azure.keyvault.keys.crypto import CryptographyClient, EncryptionAlgorithm, KeyWrapAlgorithm, SignatureAlgorithm
from azure.keyvault.keys._shared._generated.v7_0.models import JsonWebKey
from azure.mgmt.keyvault.models import KeyPermissions, Permissions
Expand Down Expand Up @@ -196,10 +196,10 @@ async def test_ec_verify_local(self, vault_client, **kwargs):
key_client = vault_client.keys

matrix = {
JsonWebKeyCurveName.p_256: (SignatureAlgorithm.es256, hashlib.sha256),
JsonWebKeyCurveName.p_256_k: (SignatureAlgorithm.es256_k, hashlib.sha256),
JsonWebKeyCurveName.p_384: (SignatureAlgorithm.es384, hashlib.sha384),
JsonWebKeyCurveName.p_521: (SignatureAlgorithm.es512, hashlib.sha512),
KeyCurveName.p_256: (SignatureAlgorithm.es256, hashlib.sha256),
KeyCurveName.p_256_k: (SignatureAlgorithm.es256_k, hashlib.sha256),
KeyCurveName.p_384: (SignatureAlgorithm.es384, hashlib.sha384),
KeyCurveName.p_521: (SignatureAlgorithm.es512, hashlib.sha512),
}

for curve, (signature_algorithm, hash_function) in matrix.items():
Expand Down