from Crypto.Cipher import AES # Key and IV (Initialization Vector) from your STM32 code key = bytes([0x00] * 32) # 256-bit key iv = bytes([0x00] * 12 ) # 96-bit IV (12 bytes + 4 bytes counter) # Header (AAD - Additional Authenticated Data) header = bytes([0x00] * 4) # Data to encrypt 981e09865ee3f41ea3d5fc7981166d94 plaintext = b'\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61' # 16 bytes of 'a' #plaintext = b'\x98\x1e\x09\x86\x5e\xe3\xf4\x1e\xa3\xd5\xfc\x79\x81\x16\x6d\x94' # 16 bytes of 'a' # Create AES-GCM cipher object cipher = AES.new(key, AES.MODE_GCM, nonce=iv) # Add AAD if used cipher.update(header) # Encrypt the data ciphertext, tag = cipher.encrypt_and_digest(plaintext) print(f'key: {key.hex()}') print(f'iv: {iv.hex()}') print(f'Ciphertext: {ciphertext.hex()}') print(f'Tag: {tag.hex()}')