• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1107
  • Last Modified:

AES is AES is AES, right? WRONG!

I've been trying to build two sets of two routines using AES encryption
Set #1 - .NET
A) Encrypt a file
B) Decrypt a file
Set #2 - Android/Java
A) Encrypt a file
B) Decrypt a file
BUT #1 and #2 must be inter-compatible!
e.g. Encrypt with .NET ... decrypt with Android/Java
e.g. Encrypt with Android/Java ... decrypt with .NET
In several articles, I've read that AES encrypt/decrypt is compatible between .NET and Android/Java ... with one caveat ... which was repeated over and over and over. All AES parameter/settings must be the SAME.

But, that's tough when MS and Android each use DIFFERENT PARAMETER NAMES to mean exactly the same thing and it's even more difficult when I'm a bonehead novice with encryption (much less AES encryption)


Microsoft's System.Security.Cryptography.AES ... uses parameters of
Blocksize, Feedbacksize, IV, Key, Keysize, LegalBlockSizes, LegalKeySizes, Mode, Padding
Javax.crypto.Cipher ... uses parameters of
Cipher, CipherInputStream, CipherOutputStream, CipherSpi, EncryptedPrivateKeyInfo, ExemptionMechanism, ExemptionMechanismSpi, KeyAgreement, KeyAgreementSpi, KeyGenerator, KeyGeneratorSpi, Mac, MacSpi, NullCipher, SealedObject, SecretKeyFactory, SecretKeyFactorySpi
Four routines
Two in C#
Two in Java
  • 2
1 Solution
Not much time now, but most important are keysize and padding (apart from algo of course)
Giovanni HewardCommented:
In many respects, Rijndael (AES) is a relatively simple cipher. It has a variable number of rounds. Other than an extra round performed at the end of encipherment with one step omitted, the number of rounds in Rijndael is:

9 if both the block and the key are 128 bits long
11 if either the block or the key is 192 bits long, and neither of them is longer
13 if either the block or the key is 256 bits long

The process for enciphering a block of data in Rijndael is to first perform an Add Round Key step (XORing a subkey with the block) by itself, the regular rounds noted above, and the final round with the Mix Column step, as described below, omitted.

The Rounds
There are four steps in each round. First is the Byte Sub step, where each byte of the block is replaced by its substitute in an S-box (substitution table).

Next is the Shift Row step. Considering the block to be made up of bytes 1 to 16, these bytes are arranged in a rectangle, and shifted according to the algorithm.

Next comes the Mix Column step. Matrix multiplication is performed: each column, in the arrangement described above, is multiplied by the following matrix:

2 3 1 1
1 2 3 1
1 1 2 3
3 1 1 2

The final step is Add Round Key. This simply XORs in the subkey for the current round.

Rijndael (AES)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now