Data size limits to 4GB in AES-GCM

20 views
Skip to first unread message

msent...@gmail.com

unread,
Oct 24, 2018, 9:42:45 AM10/24/18
to PyCryptodome

Hi Team,

 

We have implemented a utility by using pycryptodome for encryption and decryption the data. It is working till 4GB of data size in AES-GCM algorithm.

 

If the data exceeds 4GB, encryption process itself  hangs forever. I got some references from web portal, AES-GCM could support till 64GiB (2^39 - 256).  

 

PFB, snippet of encryption. We feed the data converted as a tar achieve to encryption. Kindly let me know, is there any limitation in pycryptodome or any changes required in below snippet to support beyond 4GB of data? Please advise me.

 

I appreciate the earliest response. Thank you.

 

 

PUBLIC_KEY  = 'bkup.pub'

PRIVATE_KEY = 'bkup.enc'

ENCRYPT_DIR = '/.enc/'

BLOCK_SIZE  = 16

 

symmetric_key = get_random_bytes(BLOCK_SIZE * 2)

pub_key = RSA.import_key(open("/root/.enc/bkup.pub").read())

cipher_rsa = PKCS1_OAEP.new(pub_key)

enc_symmetric_key = cipher_rsa.encrypt(symmetric_key)

cipher = AES.new(symmetric_key, AES.MODE_GCM)

ciphertext, tag = cipher.encrypt_and_digest(< output of tar archive >)

[sys.stdout.write(x) for x in (enc_symmetric_key, cipher.nonce, tag, ciphertext)

 

 

--

Best Regards,

Senthil M

Reply all
Reply to author
Forward
0 new messages