Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 983413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:51:12+00:00 2026-05-16T04:51:12+00:00

I’m going to make a long story short. It’s been a while that I

  • 0

I’m going to make a long story short. It’s been a while that I want to implement my own AES encryption/decryption program. The encryption program went well and encrypting without any error or strange output (Since I have compared my program’s output with a working commercial one and result was the same).

Wikipedia was (is) my guide in this implementation within which I read “A set of reverse rounds are applied to transform ciphertext back into the original plaintext using the same encryption key.”

There are couple of modules that I implemented:

  1. Add round key
  2. Shift rows
  3. Sub bytes
  4. Mix Column

I also implemented couple of reverse implementation of the above modules:

  1. Reverse shift rows
  2. Reverse Sub Byte
  3. Reverse Mix Column

NOTE: I didn’t implement reverse round key since, It’s XOR ing the plaintext with the encryption key, and reverse of XOR is XOR itself (correct me if I am wrong)

So I putted this modules in the reverse order that I did encryption, but never I got my plain-text back:

expandkey128(key);
rev_subbytes(data);  
rev_shiftrows(data);
addroundkey(data,key,10);

for(int i = 9; i>= 1; i--) { 
    rev_subbytes(data); 
    rev_shiftrows(data);
    rev_mixColum(data);
    addroundkey(data,key,i);
}

addroundkey(data,key,0);

// Please note that I also did from 0 to 10 ,
// instead of 10 to 0 and didn't workout

And also I thought , maybe I should not implement reverse model of the modules, maybe I have to use those modules that I did encryption with, only in reverse order; well guess what? didn’t work! :

expandkey128(key);
addroundkey(data,key,0);

for(int i = 1; i<= 9; i++) {
    subbytes(data); 
    shiftrows(data);
    mixColum(data);
    addroundkey(data,key,i);
}

subbytes(data);
shiftrows(data);
addroundkey(data,key,10);

So here is the question: what is wrong? || what is the correct sequence of applying these so called modules or functions if you will?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:51:13+00:00Added an answer on May 16, 2026 at 4:51 am

    Your order of operations seems wrong. I think you want this:

    expandkey128(key);
    
    addroundkey(data,key,10);
    rev_shiftrows(data);
    rev_subbytes(data); 
    
    for(int i = 9; i>= 1; i--) { 
        addroundkey(data,key,i);
        rev_mixColumn(data);
        rev_shiftrows(data);
        rev_subbytes(data); 
    }
    
    addroundkey(data,key,0);
    

    For more details, see my stick figure explanation of AES with its accompanying reference implementation.

    WARNING: As mentioned in Act 3, Scene 2, there be dragons in writing your own AES implementation for production use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.