Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encryption.decrypt() should throw exception if decryption fails #3545

Open
itlancer opened this issue Oct 27, 2024 · 0 comments
Open

Encryption.decrypt() should throw exception if decryption fails #3545

itlancer opened this issue Oct 27, 2024 · 0 comments
Labels

Comments

@itlancer
Copy link

Problem Description

Encryption.decrypt() should throw exception if decryption fails. If data corrupted or incorrect key/IV.
Right now there is no way to check if decryption failed.

Tested with multiple AIR 51 versions, even with latest AIR 51.1.2.1 with different applications, different corrupted data, wrong key/IV.
AIR anyway return some ByteArray as a decrypted data result.

You can check what expected with https://anycript.com/crypto or other libs.

Related issues:
#3544
#3543
#229

Steps to Reproduce

Launch application with code below.
It just try to decrypt some random base64 bytes.

Application sample with sources attached.
encryption_decrypt_bug.zip

package {
	import flash.display.Sprite;
	import flash.utils.ByteArray;
	import air.security.Encryption;
	
	public class EncryptionDecryptBug extends Sprite {
		
		public function EncryptionDecryptBug() {
			var data:ByteArray = new ByteArray();
			data.writeBase64("emhou9O241wJuhQAVBEB+Q==");//Some random base64 bytes
			
			var key:ByteArray = new ByteArray();
			key.writeUTFBytes("testtesttesttest");//Any bytes as a key
			
			var iv:ByteArray = new ByteArray();
			iv.writeUTFBytes("testtesttesttest");//Any bytes as an IV
			
			trace(Encryption.decrypt(data, key, iv));//Here exception should be throwed
		}
	}
}

Actual Result:
AIR "decrypt" data and return some bytes: }%�è7�pàÛlҫ"ι�

Expected Result:
Exception should be throwed cause decryption process should be failed.

Known Workarounds

none

  1. Use third-party libs for that.
  2. Write your own native extension for that.
@itlancer itlancer added the Bug label Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant