I'm trying to understand the difference in output of AES decrypt (GCM mode) using Webcrypto and Cryptodome.Cipher.AES in python.
from Cryptodome.Cipher import AES
from binascii import hexlify, unhexlify
key = 'E52BC6CEDC2E096584B1F57D3AE6A60724C7B301EECB975813819673E6D23126'
iv = 'B5DDEDB80480A649D1763BE7'
encrypted_data = '37631B44E6B7DB7C404F2947F40FC629BB537BF303B728A674280C23528C3B09815BA2CD39B3844A38C4527464353A66'
cipher_item_key = AES.new(unhexlify(key), AES.MODE_GCM, nonce=unhexlify(iv))
res = cipher_item_key.decrypt(unhexlify(encrypted_data))
print hexlify(res).upper()
prints EEE72939E910F74104846B5BADBDDAD007A46E3392ADE713F6EE33900299C250C83D25005D7D7E27211B2BBFF48E62AC
vs
https://gist.github.com/syst3mw0rm/9b22a1eadd6cbf38474573d54cd54f0c
prints EEE72939E910F74104846B5BADBDDAD007A46E3392ADE713F6EE33900299C250
I noticed that the first 64 characters as exactly same and that makes me think that the issue is probably with unpadding of output in python but I'm not sure what's the right way to go about doing it or is that is the root cause in the first place.
Similarly, I'm noticing a difference in output when encrypting data.
from Cryptodome.Cipher import AES
from binascii import hexlify, unhexlify
key = 'EEE72939E910F74104846B5BADBDDAD007A46E3392ADE713F6EE33900299C250'
iv = '523AEBE425EA83DCE42F9512'
data = '{"username":"test","password":"test"}'
cipher_data = AES.new(unhexlify(key), AES.MODE_GCM, nonce=unhexlify(iv))
cipher_data.update('')
encrypted_data, mac = cipher_data.encrypt_and_digest(bytearray(data))
print (hexlify(encrypted_data) + hexlify(mac)).upper()
prints C7D1A799120CBDD6539378509AFC4D0C3F78BA8D42C9F3546E15DFBD94CBE789350DD3554AF092A39AF0345623E117D28F493CD7DE
vs
https://gist.github.com/syst3mw0rm/22bb4a8c7c51516b358b482b3336d927
prints C7F3F0EA027EA0B75BF6286AD688497F265AF3AF10A8BA273B7AD9D9D3F1B6FD247E85771BAE4447F81447389A84A3145155E7DE387D6B3E181516707731EC2DC3CEF847FCA949EE484B3FC0A6C66853D42C956BA0735642D29E
I'm not sure why the output of above two would be any different. I'm using exact same key, iv, additionalData (defaults to '' according to subtle crypto spec), data. Can someone please tell me if I'm missing something obvious?