aws / aws-encryption-sdk-python

AWS Encryption SDK
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/introduction.html
Apache License 2.0
234 stars 83 forks source link

Encrypting large ML model files #624

Closed aditya1709 closed 10 months ago

aditya1709 commented 10 months ago

Hi Team, I was trying to encrypt a relatively large pytorch model file (.pth) and upload it to s3. Unfortunately I am not able to do it, it doesn't fail/throw any errors, but the decrypted file is not the same as the original .pth file. Wanted to understand if this is because of the 4kb limit on file size? These are the steps I used to encrypt the file -

import aws_encryption_sdk
from aws_encryption_sdk.identifiers import CommitmentPolicy
client = aws_encryption_sdk.EncryptionSDKClient(
    commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT
)
kms_key_provider = aws_encryption_sdk.StrictAwsKmsMasterKeyProvider(key_ids=[KMS_access_key])
shufflenet_cipher, encryptor_header = client.encrypt(
    source='./shufflenetv2_x1-5666bf0f80.pth',
    key_provider=kms_key_provider
)

and then I proceeded to upload shufflenet_cipher but could not decrypt it.

aditya1709 commented 10 months ago

Nvm found the problem. I was passing the location as the source. I converted to bytes using io and it works fine now.