-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
4,065 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
import array | ||
import base64 | ||
import hashlib | ||
import secrets | ||
|
||
from cryptography.hazmat.primitives.serialization import Encoding | ||
|
||
|
||
class Utils: | ||
@staticmethod | ||
def is_little_endian(): | ||
a = array.array('H', [1]).tobytes() | ||
# little endian: b'\x01\x00' | ||
# big endian: b'\x00\x01' | ||
return a[0] == 1 | ||
|
||
@staticmethod | ||
def convert_to_uint16(b: bytearray): | ||
ret = [0 for _ in range(len(b) // 2)] | ||
for i in range(0, len(b), 2): | ||
byte_order = 'little' if Utils.is_little_endian() else 'big' | ||
ret[i // 2] = int.from_bytes(bytearray([b[i], b[i + 1]]), byteorder=byte_order, signed=False) | ||
return ret | ||
|
||
@staticmethod | ||
def get_random(cb): | ||
ret = bytearray() | ||
for _ in range(cb): | ||
ret.append(secrets.randbits(8)) | ||
return ret | ||
|
||
@staticmethod | ||
def get_SHA256_thumbprint(cert): | ||
public_bytes = cert.public_bytes(Encoding.DER) | ||
return hashlib.sha256(public_bytes).digest() | ||
|
||
@staticmethod | ||
def security_domain_b64_url_encode_for_x5c(s): | ||
return base64.b64encode(s).decode('ascii') | ||
|
||
@staticmethod | ||
def security_domain_b64_url_encode(s): | ||
return base64.b64encode(s).decode('ascii').strip('=').replace('+', '-').replace('/', '_') | ||
|
||
|
||
if __name__ == '__main__': | ||
print(Utils.convert_to_uint16(bytearray([40, 30, 20, 10]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
# pylint: skip-file | ||
# flake8: noqa |
47 changes: 47 additions & 0 deletions
47
plugins/module_utils/vendored_sdks/azure_keyvault_t1/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
# pylint: skip-file | ||
# flake8: noqa | ||
from . import http_bearer_challenge_cache as HttpBearerChallengeCache | ||
from .http_challenge import HttpChallenge | ||
from .http_bearer_challenge import HttpBearerChallenge | ||
from .key_vault_authentication import KeyVaultAuthentication, KeyVaultAuthBase, AccessToken | ||
from .http_message_security import generate_pop_key | ||
from .key_vault_id import (KeyVaultId, | ||
KeyId, | ||
SecretId, | ||
CertificateId, | ||
CertificateIssuerId, | ||
CertificateOperationId, | ||
StorageAccountId, | ||
StorageSasDefinitionId) | ||
from .key_vault_client import KeyVaultClient | ||
from .version import VERSION | ||
|
||
__all__ = ['KeyVaultClient', | ||
'KeyVaultId', | ||
'KeyId', | ||
'SecretId', | ||
'CertificateId', | ||
'CertificateIssuerId', | ||
'CertificateOperationId', | ||
'StorageAccountId', | ||
'StorageSasDefinitionId', | ||
'HttpBearerChallengeCache', | ||
'HttpBearerChallenge', | ||
'HttpChallenge', | ||
'KeyVaultAuthentication', | ||
'KeyVaultAuthBase', | ||
'generate_pop_key', | ||
'AccessToken'] | ||
|
||
__version__ = VERSION | ||
|
Oops, something went wrong.