본문 바로가기
내가만드는것_만든것/오픈소스

C LEA암호화 알고리즘 구현 소스

by Joseph.Lee 2015. 7. 31.

 국산 암호화 알고리즘 중에 LEA란 것이 있습니다.


한번 이 암호화 알고리즘을 소스로 구현해 봤습니다.


관련 기사

[정보보호]美 NSA 감청, 국산 암호 LEA로 막는다

http://www.etnews.com/20140425000083


"[2013-1164] 128비트 경량블록암호 LEA" 이 문서를 참고하여 소스를 만들었습니다.

http://committee.tta.or.kr/include/Download.jsp?filename=choan%2F%5B2013-1164%5D+128%BA%F1%C6%AE+%B0%E6%B7%AE%BA%ED%B7%CF%BE%CF%C8%A3+LEA.hwp



제가 만든 소스와 위 문서의 RoundKey, 암호화, 복호화 비교 테스트 모두 완료하였습니다.

예제 소스 포함합니다.



JsCrypto_LEA.zip





>main 128

Nk = 16

Nr = 24

K : 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1 f0

RK :

RoundKey[ 0] : 003a0fd4 02497010 194f7db1 02497010 090d0883 02497010

RoundKey[ 1] : 11fdcbb1 9e98e0c8 18b570cf 9e98e0c8 9dc53a79 9e98e0c8

RoundKey[ 2] : f30f7bb5 6d6628db b74e5dad 6d6628db a65e46d0 6d6628db

RoundKey[ 3] : 74120631 dac9bd17 cd1ecf34 dac9bd17 540f76f1 dac9bd17

RoundKey[ 4] : 662147db c637c47a 46518932 c637c47a 23269260 c637c47a

RoundKey[ 5] : e4dd5047 f694285e e1c2951d f694285e 8ca5242c f694285e

RoundKey[ 6] : baf8e5ca 3e936cd7 0fc7e5b1 3e936cd7 f1c8fa8c 3e936cd7

RoundKey[ 7] : 5522b80c ee22ca78 8a6fa8b3 ee22ca78 65637b74 ee22ca78

RoundKey[ 8] : 8a19279e 6fb40ffe 85c5f092 6fb40ffe 92cc9f25 6fb40ffe

RoundKey[ 9] : 9dde584c cb00c87f 4780ad66 cb00c87f e61b5dcb cb00c87f

RoundKey[10] : 4fa10466 f728e276 d255411b f728e276 656839ad f728e276

RoundKey[11] : 9250d058 51bd501f 1cb40dae 51bd501f 1abf218d 51bd501f

RoundKey[12] : 21dd192d 77c644e2 cabfaa45 77c644e2 681c207d 77c644e2

RoundKey[13] : de7ac372 9436afd0 10331d80 9436afd0 f326fe98 9436afd0

RoundKey[14] : fb3ac3d4 93df660e 2f65d8a3 93df660e df92e761 93df660e

RoundKey[15] : 27620087 265ef76e 4fb29864 265ef76e 2656ed1a 265ef76e

RoundKey[16] : 227b88ec d0b3fa6f c86a08fd d0b3fa6f a864cba9 d0b3fa6f

RoundKey[17] : f1002361 e5e85fc3 1f0b0408 e5e85fc3 488e7ac4 e5e85fc3

RoundKey[18] : c65415d5 51e176b6 eca88bf9 51e176b6 edb89ece 51e176b6

RoundKey[19] : 9b6fb99c 0548254b 8de9f7c2 0548254b b6b4d146 0548254b

RoundKey[20] : 7257f134 06051a42 36bcef01 06051a42 b649d524 06051a42

RoundKey[21] : a540fb03 34b196e6 f7c80dad 34b196e6 71bc7dc4 34b196e6

RoundKey[22] : 8fbee745 cf744123 907c0a60 cf744123 8215ec35 cf744123

RoundKey[23] : 0bf6adba df69029d 5b72305a df69029d cb47c19f df69029d


P : 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f

C : 9f c8 4e 35 28 c6 c6 18 55 32 c7 a7 04 64 8b fd

D : 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f

>main 192

Nk = 24

Nr = 28

K : 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1 f0 f0 e1 d2 c3 b4 a5 96 87

RK :

RoundKey[ 0] : 003a0fd4 02497010 194f7db1 090d0883 2ff5805a c2580b27

RoundKey[ 1] : 11fdcbb1 9e98e0c8 18b570cf 9dc53a79 5c145788 9771b5e5

RoundKey[ 2] : f30f7bb5 6d6628db b74e5dad a65e46d0 6f44da96 f643115f

RoundKey[ 3] : 74120631 dac9bd17 cd1ecf34 540f76f1 aa1a5bdb fbafaae7

RoundKey[ 4] : 13f8a031 34f28728 31fdb409 0e31481b df498117 cf9371f1

RoundKey[ 5] : 0967c312 b3484ec8 3aae5b3d 5a9714a0 b2d4dd5f 3a1fcdf7

RoundKey[ 6] : 0ac47404 59e9e54d a60dc00a 566139d3 898dce4f 582d72dd

RoundKey[ 7] : 77f3ea4c e2a73c8d b8f1249a 6a172700 bc0e539c 2e46fdbb

RoundKey[ 8] : b4e0e98a 3d028c05 b8d3a050 dbd67bef df675c7a 99eefbb0

RoundKey[ 9] : e68584f6 ce31ef45 96c105ac 2a1be677 9d72b8b0 33cecc54

RoundKey[10] : c22ffd76 1ab7167e 42bb3060 7da517f5 4aa0e8d3 0a070c3c

RoundKey[11] : e200a765 c2be17b3 7f22543f 3e4eb7a1 c992a6f4 a783c823

RoundKey[12] : c13cc747 ffcc8185 66514e9e e4ccc199 cd5c766d a004f676

RoundKey[13] : 1d3a1fa6 d46894ec f49c33e6 782fda7e 1fe6346c 0ffe981c

RoundKey[14] : 78b97c3d 956e8ee8 49ab721c 2672138a 037ea242 ce5fe8a4

RoundKey[15] : 225f7158 32d83e3e e118f6aa 1fb83751 4d27715c ed2fba4e

RoundKey[16] : 8dfbc56d e0a907db e4af091c 5e123225 d0e8d2e1 cc4501fb

RoundKey[17] : 8422a8f0 46a12f92 415152ad f55417f5 38738248 c6e29ded

RoundKey[18] : 5723715e abfa788c c3646af7 64af9186 8fc855ec 2bc36989

RoundKey[19] : 5e6b28e3 e0f5f592 eb3dd108 0551012a 50e4221d 97e85c0f

RoundKey[20] : 4e258e14 92298f0b 771269c3 6f934254 c0933b6b 421159b8

RoundKey[21] : d76953f4 6a3e36be 53b656fb 610c22e0 9f399330 acf7e7e9

RoundKey[22] : fe0b573b cbb73085 89ed67fc 77014cef e1b8431f ba1b4105

RoundKey[23] : 06de3450 b3f5b2fe df1cec27 fb22bd10 8e3de6fe 3d4acd27

RoundKey[24] : c5444873 5bec968b 8b2af393 11e2f6ca 9cb3694f 94c56b91

RoundKey[25] : 939a1a93 27f101bb 5381bae7 48ebd1b1 f6d5fca7 0ca24bbc

RoundKey[26] : 7b03490b de00acfb c7f8abfe 410a14c1 d37932a9 14029327

RoundKey[27] : bd948525 2c75004d c52486d5 0f07e2fa 1963e1fd 882719c3


P : 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f

C : 6f b9 5e 32 5a ad 1b 87 8c dc f5 35 76 74 c6 f2

D : 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f

>main 256

Nk = 32

Nr = 32

K : 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1 f0 f0 e1 d2 c3 b4 a5 96 87 78 6

9 5a 4b 3c 2d 1e 0f

RK :

RoundKey[ 0] : 003a0fd4 02497010 194f7db1 090d0883 2ff5805a c2580b27

RoundKey[ 1] : 11fdcbb1 9e98e0c8 18b570cf 9dc53a79 5c145788 9771b5e5

RoundKey[ 2] : 007ec5f0 66c8f663 8f080bfe 0a39a69e bd11cf23 773eb00e

RoundKey[ 3] : 0816ad0d 298df6a8 ff32a708 d18e330a 63a88dd9 3f05617e

RoundKey[ 4] : a5f83215 189a1ee5 eff52a57 022f06c7 e8af2bba dfd91dae

RoundKey[ 5] : 2d66e6db d0850cb7 b88beeac 488c7440 68293e8c 9199ee82

RoundKey[ 6] : 9890f2c9 802c4d83 c6da5b2d f222117b 33c95a8b 490bef7b

RoundKey[ 7] : 2b9c0cfa 68aa3b00 ebaf316c 7cd4bbc6 3e13417f 74457ad4

RoundKey[ 8] : 47666c9c 46fd3811 d0df027a c8c8ff3f 9db55d49 6886f420

RoundKey[ 9] : 1878e248 854a0916 0dc52779 c91c2f7b b4babd62 0a70068f

RoundKey[10] : 2f6ea2c1 e8041a56 20d94037 0aae5ad0 282739d2 ae8e4c92

RoundKey[11] : 435d3b30 0ce8a0fd 5eb292ca 1df9a6c9 19e73ee5 3f509dcc

RoundKey[12] : 24e241ce 1910d5ec 2135e1fb becd62f9 2085006a 130cce6d

RoundKey[13] : c047357d 7c9c3e6c 8ed16f43 c153f4c6 51eeba93 d908f66f

RoundKey[14] : 96b84eac d34b2769 0666b851 f5b865ea 79fcebec 53c0c944

RoundKey[15] : fd51bd9c e8c57842 00624904 287a9071 2ee48964 d9637bf1

RoundKey[16] : c7b15fb6 3bc28919 303356e9 1cbe09bd d10053c3 1cdcc7e6

RoundKey[17] : 3b6bd0f5 3e5cd517 115e7f22 127f1e67 1c020629 c101badb

RoundKey[18] : 0710cd56 b6976bd7 2a691439 87b95292 e8bea535 ba2bf7a8

RoundKey[19] : e044d85c 479c2cde 74fd10bf d3255415 300afd67 668b7f3c

RoundKey[20] : 654b763e 6fd11be2 f84c0141 a6e184b6 cdec626d 22bc2010

RoundKey[21] : 4d48cdf3 9417eac7 6bf10bbf 4854858d 6dc43c6f 6ef09bb4

RoundKey[22] : ed523ef7 ee256832 2922d866 89ccc625 6f57f31a bf868a4f

RoundKey[23] : 3695aa3c bb6272c0 984c93b9 cc1728d7 56806aef d2d894e6

RoundKey[24] : 9637c606 b8735113 695a78e9 0f9074cc 724aca91 4c24892a

RoundKey[25] : 358115b9 0c26d5fe df63105e b4dbe19e e2fe375a 47d5ba7a

RoundKey[26] : 129534a0 4557ac10 a717c8a2 90505cb8 ba785621 d4ab0491

RoundKey[27] : 3c7e9f50 e1c7bcfc e6a15b72 fc49bfff 1e7d0462 e1d6ea51

RoundKey[28] : 431c80d5 16b6c925 35921df6 b87a58d3 00020b00 1277be0e

RoundKey[29] : 381a782d 44c1fd3e 5542bee6 0196ec00 b7e2b1e1 4c72611e

RoundKey[30] : 1aacf6e0 8df328ab 0c6902e6 822b9868 17f1737d 740520d5

RoundKey[31] : 15a6f050 ce495162 4bc0bff8 cbb60b2a 2156ef3c 41504fed


P : 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f

C : 8c 82 83 59 de ed a5 d3 3f c3 b0 78 55 d6 dd bf

D : 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f





반응형

댓글