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

njns #21

Open
wants to merge 346 commits into
base: Nalendra
Choose a base branch
from
Open

njns #21

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
346 commits
Select commit Hold shift + click to select a range
d26bb04
update pembangkit kunci
erinadwy Mar 17, 2024
503ce5d
update main
erinadwy Mar 17, 2024
fc87352
update expandkey
erinadwy Mar 17, 2024
233cfda
Update main.c
daffalghi Mar 17, 2024
27dd39e
update expandkey.h
erinadwy Mar 17, 2024
381f1fa
Merge branch 'main' of https://github.com/Cobalttt2311/Kelompok-B6
erinadwy Mar 17, 2024
390d83c
Update AES_Encryption.c
daffalghi Mar 17, 2024
774f8db
Update AES_Encryption.c
daffalghi Mar 17, 2024
99e656a
Update AES_Encryption.c
daffalghi Mar 17, 2024
29fa073
Update AES_Encryption.c
daffalghi Mar 17, 2024
5e350c9
update pembangkit_kunci
erinadwy Mar 17, 2024
4e2dd31
Update enum.h
alannatnsyaa Mar 17, 2024
ee1fd90
Update shiftrows.h
alannatnsyaa Mar 17, 2024
64c0401
Update shiftrows.h
alannatnsyaa Mar 17, 2024
00cfb61
Update shiftrows.h
alannatnsyaa Mar 17, 2024
f14097b
Update enum.h
alannatnsyaa Mar 17, 2024
c5e2687
mixcolumn
Cobalttt2311 Mar 17, 2024
ee6c418
Update README.md
Cobalttt2311 Mar 17, 2024
3f06b1e
update expandkey.h
erinadwy Mar 17, 2024
774fbad
Update AES_Encryption.c
Radja-Restu-A Mar 17, 2024
cabc7a4
Update subbytes.h
Radja-Restu-A Mar 17, 2024
b78eeea
Merge branch 'main' into Radja
Radja-Restu-A Mar 17, 2024
ae9ffca
Merge pull request #18 from Cobalttt2311/Radja
Radja-Restu-A Mar 17, 2024
b90ca06
perubahan sbox
Radja-Restu-A Mar 17, 2024
bc5c0fb
update pemanggilan modul subbytes.c
Radja-Restu-A Mar 17, 2024
f82290e
Update AES_Encryption.c
daffalghi Mar 17, 2024
74eed70
Update AES_Encryption.c
alannatnsyaa Mar 17, 2024
031724b
Update shiftrows.h
alannatnsyaa Mar 17, 2024
7bfa1d5
Update AES_Encryption.c
daffalghi Mar 17, 2024
c0672b1
update readme
erinadwy Mar 17, 2024
1c793fe
Merge branch 'main' of https://github.com/Cobalttt2311/Kelompok-B6
erinadwy Mar 17, 2024
892d4e4
Update AES_Encryption.c
Cobalttt2311 Mar 17, 2024
6e4b5a4
Update mixcolumn.h
Cobalttt2311 Mar 17, 2024
92fb709
Update AES_Encryption.c
daffalghi Mar 17, 2024
98c1b93
Update addroundkey.h
daffalghi Mar 17, 2024
d95cde7
Update aesmain.h
daffalghi Mar 17, 2024
bc59f45
Update AES_Encryption.c
Cobalttt2311 Mar 17, 2024
cf69a2a
update expandKey
erinadwy Mar 17, 2024
961d526
Merge branch 'main' of https://github.com/Cobalttt2311/Kelompok-B6
erinadwy Mar 17, 2024
4cea00f
Update aesencrypt.h
Cobalttt2311 Mar 17, 2024
935b299
Update mixcolumn.h
Cobalttt2311 Mar 17, 2024
09cdea8
Update aesencrypt.h
Cobalttt2311 Mar 17, 2024
aa60e13
Update AES_Encryption.c
daffalghi Mar 17, 2024
315da48
fix error
daffalghi Mar 17, 2024
8459a34
perbaikan
Radja-Restu-A Mar 17, 2024
50073c1
Revisi akhir
Radja-Restu-A Mar 18, 2024
728e982
Update aesencrypt.h
daffalghi Apr 15, 2024
1c574e4
Update main.c
daffalghi Apr 15, 2024
f943688
Update shiftrows.h
daffalghi Apr 15, 2024
2c6df57
Create AES_Encryption.h
daffalghi Apr 15, 2024
e976ddf
Update AES_Encryption.c
daffalghi Apr 15, 2024
538fd3e
Update addroundkey.h
daffalghi Apr 15, 2024
175f7f9
Update aesmain.h
daffalghi Apr 15, 2024
f53510f
Update main.c
daffalghi Apr 15, 2024
9f803b9
Update AES_Encryption.c
daffalghi Apr 15, 2024
71d988e
delete enum.h
Apr 15, 2024
0cceade
Update AES_Encryption.c
Radja-Restu-A Apr 22, 2024
b2505bc
Update AES_Encryption.c
Radja-Restu-A Apr 22, 2024
bfc7d69
Update AES_Decryption.h
Radja-Restu-A Apr 22, 2024
9a38517
Update AES_Decryption.c
Radja-Restu-A Apr 22, 2024
2dfc808
inverseSbox
Radja-Restu-A Apr 22, 2024
24e6013
Update main.c
daffalghi Apr 25, 2024
dd56836
Update AES_Decryption.c
daffalghi Apr 25, 2024
e0fea16
Update AES_Decryption.h
daffalghi Apr 25, 2024
099f5fd
inverse sub byte
Radja-Restu-A Apr 27, 2024
02b092f
SubByte enchancement
Radja-Restu-A Apr 27, 2024
5e3cfc0
Update AES_Decryption.h
Radja-Restu-A Apr 27, 2024
d669681
enchancement subbyte
Radja-Restu-A Apr 27, 2024
bf0340f
Update enchancement modul subbyte di dalam file algoritma
Radja-Restu-A Apr 27, 2024
0cc03bf
Update AES_Encryption.c
Radja-Restu-A Apr 27, 2024
74b564a
Update subbytes.h
Radja-Restu-A Apr 27, 2024
1ca2b81
Update AES_Decryption.c
Cobalttt2311 Apr 28, 2024
ca1fb83
Update AES_Decryption.c
Cobalttt2311 Apr 28, 2024
c3e2c91
Update AES_Decryption.c
Cobalttt2311 Apr 28, 2024
e2bbf33
Update AES_Decryption.c
erinadwy Apr 28, 2024
f6d4b5a
Update AES_Decryption.c
erinadwy Apr 28, 2024
c9f7875
Update AES_Decryption.c
erinadwy Apr 28, 2024
d99b72a
Update AES_Decryption.c
Cobalttt2311 Apr 28, 2024
787e905
Update AES_Decryption.c
Cobalttt2311 Apr 28, 2024
aead4b2
Update AES_Decryption.c
Cobalttt2311 Apr 28, 2024
502b4c7
Create invMixColumn.h
Cobalttt2311 Apr 29, 2024
d984164
Update AES_Decryption.c
alannatnsyaa Apr 29, 2024
b67037e
Update invMixColumn.h
Cobalttt2311 Apr 29, 2024
845f549
Update invMixColumn.h
Cobalttt2311 Apr 29, 2024
9e02700
Create invShiftrows
alannatnsyaa Apr 29, 2024
90ab421
Update invShiftrows
alannatnsyaa Apr 29, 2024
d3dadce
Create invExpandedkey.h
erinadwy Apr 29, 2024
dd1d3ae
Update invShiftrows
alannatnsyaa Apr 29, 2024
318aa0c
Update invExpandedkey.h
erinadwy Apr 29, 2024
14a88cb
Update invShiftrows
alannatnsyaa Apr 29, 2024
e74638d
Update invShiftrows
alannatnsyaa Apr 29, 2024
8bf54e1
Update invShiftrows
alannatnsyaa Apr 29, 2024
7144862
Update AES_Decryption.c
erinadwy Apr 29, 2024
bc17719
Update enum KeySize AES_Decryption.c
erinadwy Apr 29, 2024
e03a7a7
Update enum errorCode AES_Decryption.c
erinadwy Apr 29, 2024
1168efd
Update AES_Decryption.c
alannatnsyaa Apr 29, 2024
50ac9c7
pindah header
Radja-Restu-A Apr 29, 2024
2550caa
Update AES_Decryption.c
alannatnsyaa Apr 29, 2024
b82553d
Update AES_Decryption.c
alannatnsyaa Apr 29, 2024
bfe03cd
header inverese sbox kesini
Radja-Restu-A Apr 29, 2024
1ed6e0d
Update AES_Decryption.c
alannatnsyaa Apr 29, 2024
4b8d272
Merge branch 'main' into Radja
Radja-Restu-A Apr 29, 2024
c3faf92
delete aes_decrypt AES_Decryption.c
erinadwy Apr 29, 2024
6d04943
Merge branch 'main' into Radja
Radja-Restu-A Apr 29, 2024
1d64b36
Delete invShiftrows
Cobalttt2311 Apr 29, 2024
0f54b4a
Update invExpandedkey.h
erinadwy Apr 29, 2024
ac19a82
Merge pull request #19 from Cobalttt2311/Radja
Radja-Restu-A Apr 29, 2024
c096763
Create invShiftrows.h
alannatnsyaa Apr 29, 2024
c840a7a
Update and rename invShiftrows.h to invShiftRows.h
alannatnsyaa Apr 29, 2024
f67e563
Create invaesmain.h
daffalghi Apr 29, 2024
f57d191
Update AES_Decryption.c
alannatnsyaa Apr 29, 2024
36d32b2
Delete inverseSbox.h
Cobalttt2311 Apr 29, 2024
4e5d658
Create invSubByte.h
Radja-Restu-A Apr 29, 2024
9682361
fixing kesalahan penulisan
Radja-Restu-A Apr 29, 2024
0ad1f58
Update AES_Decryption.c
daffalghi Apr 29, 2024
057428c
fixing penulisan
Radja-Restu-A Apr 29, 2024
14a378d
Update main.c
daffalghi Apr 29, 2024
31c35b0
Update invSubByte.h
daffalghi Apr 29, 2024
bf2af8d
Update AES_Decryption.c
daffalghi Apr 29, 2024
99e574e
Update AES_Encryption.c
daffalghi Apr 29, 2024
3d260bb
SEMICOLON ADUHAI
daffalghi Apr 29, 2024
b276662
Update AES_Decryption.h
daffalghi Apr 29, 2024
ba00769
Update invExpandedkey.h
daffalghi Apr 29, 2024
52efd1f
Update AES_Decryption.c
alannatnsyaa Apr 29, 2024
b07861e
library external buat lsb
daffalghi May 6, 2024
1a33fc3
Membuat LSB_Decrypt.h
alannatnsyaa May 6, 2024
4d54d16
Create LSB.c
daffalghi May 6, 2024
02941e9
Update LSB.c
alannatnsyaa May 7, 2024
12578ca
Update LSB.c
erinadwy May 7, 2024
c1805e0
Update comment in decrypt_message
erinadwy May 7, 2024
d3690ac
Update LSB_Decrypt.h
erinadwy May 7, 2024
1094dd5
Update LSB.c
Cobalttt2311 May 12, 2024
31b8c14
Update LSB.c
Cobalttt2311 May 12, 2024
ab911d6
Create LSB_Encryption.h
Cobalttt2311 May 12, 2024
a4d08ed
Update LSB_Encryption.h
Cobalttt2311 May 12, 2024
010fc19
Update LSB.c
Cobalttt2311 May 12, 2024
e18f946
Update LSB.c
Cobalttt2311 May 12, 2024
9350dd2
Merge branch 'main' into Radja
Radja-Restu-A May 12, 2024
338a20a
Merge pull request #22 from Cobalttt2311/Radja
Radja-Restu-A May 12, 2024
56c615e
Merge pull request #23 from Cobalttt2311/main
Radja-Restu-A May 12, 2024
e735cf6
Delete LSB_Decrypt.h
daffalghi May 13, 2024
e6b65a4
Create LSB_Decryption.h
daffalghi May 13, 2024
a323133
Create ReadLSB.h
Cobalttt2311 May 13, 2024
dbddde6
pembuatan file header
Radja-Restu-A May 13, 2024
81ed661
penerapan linked list modul menyisipkan tipuan
Radja-Restu-A May 13, 2024
afb2b47
add modul hapus node tipuan
Radja-Restu-A May 13, 2024
409e603
header dari modul penerapan sisipkan tipuan
Radja-Restu-A May 13, 2024
64fa2cf
Update radja.h
Radja-Restu-A May 13, 2024
702798c
Buat algoritmaLL.c
daffalghi May 14, 2024
4c84dba
buat header daffa.h
daffalghi May 14, 2024
9746458
Create linkedlist.h
daffalghi May 14, 2024
0eb2119
Update algoritmaLL.c
daffalghi May 20, 2024
4a34da0
Update algoritmaLL.c
Cobalttt2311 May 20, 2024
03311d5
modul putar linked list
Radja-Restu-A May 20, 2024
0c2b0e0
Create nalen.h
Cobalttt2311 May 20, 2024
1a2da2e
Update nalen.h
Cobalttt2311 May 20, 2024
9cf076f
Update modul pada header
Radja-Restu-A May 20, 2024
921421b
Update nalen.h
Cobalttt2311 May 20, 2024
1796e30
Create alanna.h
alannatnsyaa May 20, 2024
77f8f4e
Update alanna.h
alannatnsyaa May 20, 2024
d93c620
Create erina.h
erinadwy May 20, 2024
a7b7049
Update algoritmaLL.c
alannatnsyaa May 20, 2024
58f206b
Update erina.h
erinadwy May 20, 2024
ecdd74d
Update UI main.c
erinadwy May 20, 2024
9752d5a
Update main.c
alannatnsyaa May 20, 2024
725ca43
Update main.c
alannatnsyaa May 20, 2024
dbf6db6
Update main.c
alannatnsyaa May 20, 2024
f2ceeaf
Update main.c
erinadwy May 20, 2024
e5436e9
Error Handling main.c
erinadwy May 20, 2024
e5312d6
Update main.c
alannatnsyaa May 20, 2024
a1797c5
Update main.c
alannatnsyaa May 20, 2024
d92c2a6
Update case 4 main.c
erinadwy May 20, 2024
1928e17
Update modul putar jadi bisa dua arah
Radja-Restu-A May 20, 2024
2938f28
update parameter modul putar
Radja-Restu-A May 20, 2024
77f8f1c
Merge branch 'main' into Radja
Radja-Restu-A May 20, 2024
0dd6bd5
Merge pull request #24 from Cobalttt2311/Radja
Radja-Restu-A May 20, 2024
1c393c9
Update insert algoritmaLL.c
erinadwy May 20, 2024
a6a06be
Update pindahkearray algoritmaLL.c
erinadwy May 20, 2024
8da12be
Memperbaiki kesalahan penulisan algoritmaLL.
erinadwy May 20, 2024
02b0ac1
Update isian erina.h
erinadwy May 20, 2024
31d7bc4
Update main.c
daffalghi May 21, 2024
fc4b977
Update Urutan algoritmaLL.c
daffalghi May 21, 2024
e5acaaa
Update erina.h
daffalghi May 21, 2024
d616a4b
Update nalen.h
daffalghi May 21, 2024
80b1c5c
Update radja.h
daffalghi May 21, 2024
2f70c28
Update AES_Decryption.c
daffalghi May 21, 2024
5f129b2
Update AES_Decryption.h
daffalghi May 21, 2024
d14c136
Update LSB.c
daffalghi May 21, 2024
b8f79ca
Update AES_Encryption.h
daffalghi May 21, 2024
65c2d1f
Update LSB.c
daffalghi May 21, 2024
01fde4e
Update main.c
daffalghi May 21, 2024
40f4756
Update main.c
daffalghi May 21, 2024
6e53157
Update main.c
daffalghi May 21, 2024
f7cc0af
Update AES_Decryption.c
Cobalttt2311 May 22, 2024
279e242
Update main.c
daffalghi May 23, 2024
2b5b492
Update main.c
daffalghi May 23, 2024
42cd220
Update LSB_Decryption.h
daffalghi May 25, 2024
7a5b5a3
Update LSB_Decryption.h
daffalghi May 25, 2024
22b7269
Add files via upload
daffalghi May 25, 2024
f12b649
Update main.c
Cobalttt2311 May 25, 2024
783eb17
Update main.c
Cobalttt2311 May 25, 2024
0deb54c
Update main.c
Cobalttt2311 May 25, 2024
9e95d98
Update main.c
Cobalttt2311 May 25, 2024
da4eb4a
Update main.c
Cobalttt2311 May 25, 2024
0c7401c
Update main.c
Cobalttt2311 May 25, 2024
66d2477
Update main.c
Cobalttt2311 May 25, 2024
a4ddff6
Update main.c
Cobalttt2311 May 25, 2024
c3bbabc
Update main.c
Cobalttt2311 May 25, 2024
c2220da
Update main.c
Cobalttt2311 May 25, 2024
ae98571
Update main.c
Cobalttt2311 May 25, 2024
3824c2b
Update main.c
Cobalttt2311 May 25, 2024
3419990
Update main.c
Cobalttt2311 May 25, 2024
3efbfae
Update main.c
Cobalttt2311 May 25, 2024
29943fb
Update main.c
Cobalttt2311 May 25, 2024
c750acc
Update README.md
daffalghi May 25, 2024
f547c47
Add files via upload
daffalghi May 25, 2024
b44a788
Update README.md
daffalghi May 25, 2024
100519d
Update README.md
daffalghi May 25, 2024
3017b6c
Update README.md
daffalghi May 25, 2024
0f36bfe
Update main.c
Radja-Restu-A May 25, 2024
1b69bde
Update main.c
alannatnsyaa May 25, 2024
79d384e
Update main.c
alannatnsyaa May 25, 2024
90f766e
Update main.c
alannatnsyaa May 25, 2024
688fab5
Update main.c
alannatnsyaa May 25, 2024
b79380f
Update main.c
alannatnsyaa May 25, 2024
7869407
Update main.c
alannatnsyaa May 25, 2024
dd36ae8
Update main.c
erinadwy May 25, 2024
df674fa
Update main.c
erinadwy May 25, 2024
dc5fc9b
Update UI main.c
erinadwy May 25, 2024
c1ff038
Update UI case 3 main.c
erinadwy May 25, 2024
4a2bbdb
remove clear_list main.c
erinadwy May 25, 2024
fa889a6
Update main.c
alannatnsyaa May 25, 2024
1fc7a17
Update main.c
Radja-Restu-A May 25, 2024
d873178
Update README.md
erinadwy May 25, 2024
9d42b0f
Update README.md
erinadwy May 25, 2024
1f4046c
Update alanna.h
alannatnsyaa May 25, 2024
6d02ba3
Update README.md
erinadwy May 25, 2024
4b5d64b
Merge branch 'main' of https://github.com/Cobalttt2311/Kelompok-B6
erinadwy May 25, 2024
3b2eef0
Update comment erina.h
erinadwy May 25, 2024
6204adc
merapihkan struktrur penulisan README.md
erinadwy May 25, 2024
f2b48bc
Update README.md
erinadwy May 25, 2024
d63a9fc
coba tampilan README.md
erinadwy May 25, 2024
347b501
Update README.md
erinadwy May 25, 2024
473ecd5
Update README.md
erinadwy May 25, 2024
69a9b87
Update penempatan README.md
erinadwy May 25, 2024
46deefd
menghapus kesalahan penulisan README.md
erinadwy May 25, 2024
36a3d43
Update main.c
erinadwy May 25, 2024
41ee636
Update README.md
daffalghi May 25, 2024
6f62398
Update main.c
Radja-Restu-A May 25, 2024
a039967
Update README.md
daffalghi May 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 177 additions & 1 deletion AES_Decryption.c
Original file line number Diff line number Diff line change
@@ -1 +1,177 @@

#include <stdio.h>
#include <stdlib.h>
#define BLOCK_SIZE 16

enum errorCode
{
SUCCESS = 0,
ERROR_AES_UNKNOWN_KEYSIZE,
ERROR_MEMORY_ALLOCATION_FAILED,
};

enum keySize
{
SIZE_16 = 16
};

char inverseSbox[16][16] = {
{0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb}, // 0
{0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb}, // 1
{0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e}, // 2
{0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25}, // 3
{0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92}, // 4
{0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84}, // 5
{0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06}, // 6
{0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b}, // 7
{0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73}, // 8
{0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e}, // 9
{0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b}, // A
{0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4}, // B
{0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f}, // C
{0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef}, // D
{0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61}, // E
{0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d} // F
};

void invsubBytes(int ukuran, unsigned char state[ukuran][ukuran]) {
int i, j;
for (i = 0; i < ukuran; i++) {
for (j = 0; j < ukuran; j++) {
int row = (state[i][j] >> 4) & 0x0F;
int col = state[i][j] & 0x0F;
state[i][j] = inverseSbox[row][col];
}
}
}

void invShiftRows(unsigned char state[4][4]) {
int i, j, k;
unsigned char tmp;

for (i = 0; i < 4; i++) {
// Number of cyclic shifts for this row (based on row index)
int shift = i;

// Perform cyclic shift to the right by `shift` positions
for (j = 0; j < shift; j++) {
tmp = state[i][3]; // Store the last element
for ( k = 2; k >= 0; k--) { // Shift elements to the right
state[i][k + 1] = state[i][k];
}
state[i][0] = tmp; // Move the stored element to the beginning
}
}
}


void invMixColumns(unsigned char state[4][4]) {
// Define the inverse mix matrix


unsigned char invMixMatrix[4][4] = {
{0x0e, 0x0b, 0x0d, 0x09},
{0x09, 0x0e, 0x0b, 0x0d},
{0x0d, 0x09, 0x0e, 0x0b},
{0x0b, 0x0d, 0x09, 0x0e}
};

int i, j;
unsigned char column[4];
unsigned char result[4];

for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
column[j] = state[j][i];
}

for (j = 0; j < 4; j++) {
result[j] = galois_multiplication(invMixMatrix[j][0], column[0]) ^
galois_multiplication(invMixMatrix[j][1], column[1]) ^
galois_multiplication(invMixMatrix[j][2], column[2]) ^
galois_multiplication(invMixMatrix[j][3], column[3]);
}

for (j = 0; j < 4; j++) {
state[j][i] = result[j];
}
}
}


void aes_invRound(unsigned char state[4][4], unsigned char roundKey[4][4])
{
invShiftRows(state);
invsubBytes(4,state);
addRoundKey(state, roundKey);
invMixColumns(state);
}

void aes_invMain(unsigned char state[4][4], unsigned char *expandedKey, int nbrRounds)
{
int i = 0;

unsigned char roundKey[4][4];

createRoundKey(expandedKey + 16 * nbrRounds, roundKey);
addRoundKey(state, roundKey);

for (i = nbrRounds - 1; i > 0; i--)
{
createRoundKey(expandedKey + 16 * i, roundKey);
aes_invRound(state, roundKey);
}

createRoundKey(expandedKey, roundKey);
invShiftRows(state);
invsubBytes(4,state);
addRoundKey(state, roundKey);
}

char aes_decrypt(unsigned char *input, unsigned char *output, unsigned char *key, enum keySize size)
{
// the number of rounds
int nbrRounds;

// the expanded key
unsigned char expandedKey[16][16]; // 15 rounds maximum

// the 128 bit block to decode
unsigned char block[BLOCK_SIZE];

int i, j;

// set the number of rounds
switch (size)
{
case SIZE_16:
nbrRounds = 10;
break;
default:
return ERROR_AES_UNKNOWN_KEYSIZE;
break;
}

// Set the block values
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
block[(i + (j * 4))] = input[(i * 4) + j];
}

// Expand the key into a 176 bytes key
expandKey(expandedKey[0], key, size, 16 * (nbrRounds + 1));

// Decrypt the block using the expandedKey
// Pass the address of block (which acts as 2D array)
aes_invMain(block, expandedKey[0], nbrRounds);

// Unmap the block again into the output
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
output[(i * 4) + j] = block[(i + (j * 4))];
}

return SUCCESS;
}

5 changes: 5 additions & 0 deletions AES_Decryption.h
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
#ifndef DECRYPTION_H
#define DECRYPTION_H

void aes_invRound(unsigned char state[4][4], unsigned char roundKey[4][4]); //inverse tahapan di round
char inverseSbox[16][16];
#endif
Loading