Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bim-msft committed Jan 22, 2020
1 parent ff01618 commit 788ca69
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/keyvault/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,13 +752,15 @@ def _jwk_to_dict(jwk):


def _extract_rsa_public_key_from_jwk(jwk_dict):
# Please refer to: https://github.com/mpdavis/python-jose/blob/eed086d7650ccbd4ea8b555157aff3b1b99f14b9/jose/backends/cryptography_backend.py#L249-L254
e = jwk_dict.get('e', 256)
n = jwk_dict.get('n')
public = rsa.RSAPublicNumbers(e, n)
return public.public_key(default_backend())


def _extract_ec_public_key_from_jwk(jwk_dict):
# Please refer to: https://github.com/mpdavis/python-jose/blob/eed086d7650ccbd4ea8b555157aff3b1b99f14b9/jose/backends/cryptography_backend.py#L81-L100
if not all(k in jwk_dict for k in ['x', 'y', 'crv']):
raise CLIError('Invalid EC key: missing properties(x, y, crv)')

Expand Down Expand Up @@ -801,6 +803,7 @@ def _to_der(k):
)

def _to_pem(k):
# Please refer to: https://github.com/mpdavis/python-jose/blob/eed086d7650ccbd4ea8b555157aff3b1b99f14b9/jose/backends/cryptography_backend.py#L329-L332
return k.public_bytes(
encoding=Encoding.PEM,
format=PublicFormat.SubjectPublicKeyInfo
Expand Down

0 comments on commit 788ca69

Please sign in to comment.