def __init__(self, plain_key): RawMasterKeyProvider.__init__(self) self.wrapping_key = WrappingKey( wrapping_algorithm=WrappingAlgorithm. AES_256_GCM_IV12_TAG16_NO_PADDING, wrapping_key=plain_key, wrapping_key_type=EncryptionKeyType.SYMMETRIC)
def __init__(self, private_key_id, private_key_text): RawMasterKeyProvider.__init__(self) private_key = RSA.importKey(private_key_text) self._key = private_key.exportKey() RawMasterKeyProvider.add_master_key(self, private_key_id)
def __init__(self, wrapping_key): RawMasterKeyProvider.__init__(self) self.wrapping_key = wrapping_key
# rawAmount = event["Details"]["Parameters"]["Amount"] # print(float(rawAmount)) # amountFloat = int(round(float(rawAmount), 2) * 100) # print(amountFloat) import boto3 import aws_encryption_sdk from aws_encryption_sdk.key_providers.raw import RawMasterKeyProvider session = boto3.Session(region_name='ap-southeast-2') client = session.client('ssm') priv_response = client.get_parameter(Name='CONNECT_INPUT_DECRYPTION_KEY', WithDecryption=True) pub_response = client.get_parameter(Name='CONNECT_ENCRYPTION_KEY', WithDecryption=True) privateKey = priv_response['Parameter']['Value'] print(privateKey) publicKey = pub_response['Parameter']['Value'] print(publicKey) key_provider = RawMasterKeyProvider(publicKey) my_plaintext = b'This is some super secret data! Yup, sure is!' my_ciphertext, encryptor_header = aws_encryption_sdk.encrypt( source=my_plaintext, key_provider=key_provider)