AES is AES is AES, right? WRONG!

Posted on 2012-08-31
Last Modified: 2013-12-02
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
Question by:volking
    LVL 86

    Accepted Solution

    Not much time now, but most important are keysize and padding (apart from algo of course)
    LVL 86

    Expert Comment

    LVL 14

    Expert Comment

    by:Giovanni Heward
    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)

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    This video teaches viewers about errors in exception handling.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now