App crashes on CreateDecryptor (android)

Godot Version

4.2.2 Godot .NET (.net 8)

Question

Hello everybody,

calling .NET Aes.CreateDecryptor for creating a ICryptoTransform, crashes the Android app. And error seems not to bubble up, since I am not able to get it in a try…catch.

This is the .NET source code of the method I called:
public sealed override ICryptoTransform CreateDecryptor(byte rgbKey, byte? rgbIV)
{
return CreateTransform(rgbKey, rgbIV.CloneByteArray(), encrypting: false);
}

Following the MS .NET source code I cannot figure out what can possibly cause the issue in Android.

Key and IV are correct and verified., same for Padding and Cipher mode.

Exactly same code is working on the same app for Android compiled with Unity…

Perhaps something during Godot compilation may strip some code?

Please, any hint is appreciated.

Thanks

1 Like

I would like to add that using Godot AESContext decrypting works correctly.

This is the code used with Godot AESContext:
AesContext _aes = new AesContext();
// Decrypt CBC
_aes.Start(AesContext.Mode.CbcDecrypt, key, iv);
byte decrypted = _aes.Update(encrypted);
_aes.Finish();

Should I use (or it is recommended) the Godot AESContext?

Moreover, I just tested (in isolation so to say) these few lines of code from .NET System.Security.Cryptography Aes class:

var aes = Aes.Create(); // this is always working in Android

aes.GenerateKey(); // at this line Android crashes

Please, why is not working with .NET System.Security.Cryptography Aes class?

1 Like