Add ARIA block cipher

This is the reference implementation, test data and test vectors from the ARIA.zip package on the KISA website. The website is located at http://seed.kisa.or.kr/iwt/ko/bbs/EgovReferenceList.do?bbsId=BBSMSTR_000000000002.

We have optimized routines that improve Key Setup and Bulk Encryption performance, but they are not being checked-in at the moment. The ARIA team is updating its implementation for contemporary hardware and we would like to use it as a starting point before we wander too far away from the KISA implementation.
pull/402/head
Jeffrey Walton 2017-04-10 10:52:40 -04:00
parent 8c7408bcd5
commit 8ca0f47939
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
18 changed files with 697 additions and 28 deletions

View File

@ -10,6 +10,8 @@ algparam.cpp
algparam.h
arc4.cpp
arc4.h
aria.cpp
aria.h
argnames.h
asn.cpp
asn.h
@ -318,6 +320,7 @@ Install.txt
Filelist.txt
TestData/3desval.dat
TestData/3wayval.dat
TestData/aria.dat
TestData/camellia.dat
TestData/cast128v.dat
TestData/cast256v.dat
@ -385,6 +388,7 @@ TestVectors/all.txt
TestVectors/blake2.txt
TestVectors/blake2b.txt
TestVectors/blake2s.txt
TestVectors/aria.txt
TestVectors/camellia.txt
TestVectors/ccm.txt
TestVectors/chacha.txt

45
TestData/aria.dat Normal file
View File

@ -0,0 +1,45 @@
0123456789ABCDEFFEDCBA9876543210 0123456789ABCDEFFEDCBA9876543210 7DC1917AE0D38FAE8D4A7D1959AEF27C
80000000000000000000000000000000 00000000000000000000000000000000 4ABA3055788204D82F4539D81BC9384B
00000000000000000000000000000001 00000000000000000000000000000000 5FA57C3B2E71144C3E5E1E9BE4F0FE7E
00000000000000000000000000000000 80000000000000000000000000000000 92E51E737DABB6BFD0EABC8D32224F77
00000000000000000000000000000000 00000000000000000000000000000001 B426E1A441F6DBFC2B2D2412D0066D20
00000000000000000000000000000000 00000000000000000000000000000000 4B40A63C7F0171EE3CDDA4363FBFAE75
01010101010101010101010101010101 01010101010101010101010101010101 CCE5D964A71D7A5E93986BCA572BB050
02020202020202020202020202020202 02020202020202020202020202020202 A04100328F459F6AAE8EBAB3B5FE90A8
04040404040404040404040404040404 04040404040404040404040404040404 BFE5C38FE204ADC614A321786CDCA08E
08080808080808080808080808080808 08080808080808080808080808080808 95A3371D4879057FAEB2E573CCE8A7F5
10101010101010101010101010101010 10101010101010101010101010101010 80AF7861CA5855FBED523345D36619EC
20202020202020202020202020202020 20202020202020202020202020202020 82E9D82550AECD0E0BB1B63E4B30CEC3
40404040404040404040404040404040 40404040404040404040404040404040 C80C04BA36ED0DA52B3E6CB430617FAC
80808080808080808080808080808080 80808080808080808080808080808080 41305D0632AC493419B04F3BCDBA6AE4
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF B99D80EF798362ACEB9E960AAE7EECC2
0123456789ABCDEFFEDCBA98765432100011223344556677 0123456789ABCDEFFEDCBA9876543210 6DC2DBDAC3C563E522F5A75942B8AFAC
800000000000000000000000000000000000000000000000 00000000000000000000000000000000 F9BA9C6E7E3C86FAE4BEB607F387548E
000000000000000000000000000000000000000000000001 00000000000000000000000000000000 5BC2C08F01C0CDC2F983073CBE9194D2
000000000000000000000000000000000000000000000000 80000000000000000000000000000000 AE56BF59874ED4DBD7B905878894ADEE
000000000000000000000000000000000000000000000000 00000000000000000000000000000001 D53236B0CDE20C26F57675A7405A9F98
000000000000000000000000000000000000000000000000 00000000000000000000000000000000 D5526B5E6A1E3DF23AD8ECAF20F281D0
010101010101010101010101010101010101010101010101 01010101010101010101010101010101 6E4C91AB71707075F375FFB7B3D27328
020202020202020202020202020202020202020202020202 02020202020202020202020202020202 D686D2A6F3BBBC5E703528FD4B1DBA8F
040404040404040404040404040404040404040404040404 04040404040404040404040404040404 ADE1730DA6F15693FD9F063DFC8EC4D1
080808080808080808080808080808080808080808080808 08080808080808080808080808080808 6A3FCA9070151FF14142B1700BE075EB
101010101010101010101010101010101010101010101010 10101010101010101010101010101010 773EC2820CCD29CA650DEA05E04CEB80
202020202020202020202020202020202020202020202020 20202020202020202020202020202020 531A8B8F5F1228E16B57E5365A1FB02B
404040404040404040404040404040404040404040404040 40404040404040404040404040404040 C0166DB2A70DF611921E7F0AB0E0F15D
808080808080808080808080808080808080808080808080 80808080808080808080808080808080 70F3361D505A220B1C2328EBE32ED731
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF F275975CCC163ED53AA0510443239638
0123456789ABCDEFFEDCBA987654321000112233445566778899AABBCCDDEEFF 0123456789ABCDEFFEDCBA9876543210 2F4792014AE2D9B812ADBAC663DC762B
8000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000 9250C9771F5A5A8612400AA917491263
0000000000000000000000000000000000000000000000000000000000000001 00000000000000000000000000000000 1A6AED07EC57E4373E988BFBB396406F
0000000000000000000000000000000000000000000000000000000000000000 80000000000000000000000000000000 209ACF63CE6DFB56B1F9821DDBFE86E3
0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000001 678FFFFDCE3177605F9320FEC4D30B5E
0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000 C20857DD9106DDDE286EC59FA98D77CC
0101010101010101010101010101010101010101010101010101010101010101 01010101010101010101010101010101 15C28D4EC27D8BEDDD8E6B3745A9A261
0202020202020202020202020202020202020202020202020202020202020202 02020202020202020202020202020202 5279DA1773C078835D506B25FED6513E
0404040404040404040404040404040404040404040404040404040404040404 04040404040404040404040404040404 7AED38F56F62FC75F7DB88F7E59D0B02
0808080808080808080808080808080808080808080808080808080808080808 08080808080808080808080808080808 6EB3C2BC1AC20926E860E688786DB872
1010101010101010101010101010101010101010101010101010101010101010 10101010101010101010101010101010 54A8718B4DD1A03B1A4ED06C30B9E6AB
2020202020202020202020202020202020202020202020202020202020202020 20202020202020202020202020202020 A876FA5538F926B373702DABF33025B6
4040404040404040404040404040404040404040404040404040404040404040 40404040404040404040404040404040 B71AB43F56E09592E69E315E7CD06E8A
8080808080808080808080808080808080808080808080808080808080808080 80808080808080808080808080808080 E975FB1435D92A0CF3E1A2487774D699
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 6C833E3962286C0DE0395446ED30F646

View File

@ -2,6 +2,7 @@ AlgorithmType: FileList
Name: all.txt collection
Test: TestVectors/tea.txt
Test: TestVectors/wake.txt
Test: TestVectors/aria.txt
Test: TestVectors/camellia.txt
Test: TestVectors/shacal2.txt
Test: TestVectors/ttmac.txt

233
TestVectors/aria.txt Normal file
View File

@ -0,0 +1,233 @@
AlgorithmType: SymmetricCipher
Name: ARIA/ECB
Source: ARIA Test Vectors PDF (05.05.2004)
Comment: Tests using ECB mode
Comment: Section 1, 128-bit (p.3)
Key: 00112233445566778899aabbccddeeff
Plaintext: 11111111aaaaaaaa11111111bbbbbbbb \
11111111cccccccc11111111dddddddd \
22222222aaaaaaaa22222222bbbbbbbb \
22222222cccccccc22222222dddddddd \
33333333aaaaaaaa33333333bbbbbbbb \
33333333cccccccc33333333dddddddd \
44444444aaaaaaaa44444444bbbbbbbb \
44444444cccccccc44444444dddddddd \
55555555aaaaaaaa55555555bbbbbbbb \
55555555cccccccc55555555dddddddd
Ciphertext: c6ecd08e22c30abdb215cf74e2075e6e \
29ccaac63448708d331b2f816c51b17d \
9e133d1528dbf0af5787c7f3a3f5c2bf \
6b6f345907a3055612ce072ff54de7d7 \
88424da6e8ccfe8172b391be49935416 \
5665ba7864917000a6eeb2ecb4a698ed \
fc7887e7f556377614ab0a282293e6d8 \
84dbb84206cdb16ed1754e77a1f243fd \
086953f752cc1e46c7c794ae85537dca \
ec8dd721f55c93b6edfe2adea43873e8
Test: Encrypt
Comment: Section 2, 192-bit (p.6)
Key: 00112233445566778899aabbccddeeff \
0011223344556677
Plaintext: 11111111aaaaaaaa11111111bbbbbbbb \
11111111cccccccc11111111dddddddd \
22222222aaaaaaaa22222222bbbbbbbb \
22222222cccccccc22222222dddddddd \
33333333aaaaaaaa33333333bbbbbbbb \
33333333cccccccc33333333dddddddd \
44444444aaaaaaaa44444444bbbbbbbb \
44444444cccccccc44444444dddddddd \
55555555aaaaaaaa55555555bbbbbbbb \
55555555cccccccc55555555dddddddd
Ciphertext: 8d1470625f59ebacb0e55b534b3e462b \
5f23d33bff78f46c3c15911f4a21809a \
accad80b4bda915aa9dae6bcebe06a6c \
83f77fd5391acfe61de2f646b5d447ed \
bfd5bb49b12fbb9145b227895a757b2a \
f1f7188734863d7b8b6ede5a5b2f06a0 \
a233c8523d2db778fb31b0e311f32700 \
152f33861e9d040c83b5eb40cd88ea49 \
975709dc629365a189f78a3ec40345fc \
6a5a307a8f9a4413091e007eca5645a0
Test: Encrypt
Comment: Section 3, 256-bit (p.11)
Key: 00112233445566778899aabbccddeeff \
00112233445566778899aabbccddeeff
Plaintext: 11111111aaaaaaaa11111111bbbbbbbb \
11111111cccccccc11111111dddddddd \
22222222aaaaaaaa22222222bbbbbbbb \
22222222cccccccc22222222dddddddd \
33333333aaaaaaaa33333333bbbbbbbb \
33333333cccccccc33333333dddddddd \
44444444aaaaaaaa44444444bbbbbbbb \
44444444cccccccc44444444dddddddd \
55555555aaaaaaaa55555555bbbbbbbb \
55555555cccccccc55555555dddddddd
Ciphertext: 58a875e6044ad7fffa4f58420f7f442d \
8e191016f28e79aefc01e204773280d7 \
018e5f7a938ec30711719953bae86542 \
cd7ebc752474c1a5f6eaaace2a7e2946 \
2ee7dfa5afdb84177ead95ccd4b4bb6e \
1ed17b9534cff0a5fc2941429cfee2ee \
49c7adbeb7e9d1b0d2a8531d94207959 \
6a27ed79f5b1dd13ecd604b07a48885a \
3afa0627a0e4e60a3c703af292f1baa7 \
7b702f16c54aa74bc727ea95c7468b00
Test: Encrypt
AlgorithmType: SymmetricCipher
Name: ARIA/CBC
Source: ARIA Test Vectors PDF (05.05.2004)
Comment: Tests using CBC mode
Comment: Section 1, 128-bit (p.3)
Key: 00112233445566778899aabbccddeeff
IV: 0f1e2d3c4b5a69788796a5b4c3d2e1f0
Plaintext: 11111111aaaaaaaa11111111bbbbbbbb \
11111111cccccccc11111111dddddddd \
22222222aaaaaaaa22222222bbbbbbbb \
22222222cccccccc22222222dddddddd \
33333333aaaaaaaa33333333bbbbbbbb \
33333333cccccccc33333333dddddddd \
44444444aaaaaaaa44444444bbbbbbbb \
44444444cccccccc44444444dddddddd \
55555555aaaaaaaa55555555bbbbbbbb \
55555555cccccccc55555555dddddddd
Ciphertext: 49d61860b14909109cef0d22a9268134 \
fadf9fb23151e9645fba75018bdb1538 \
b53334634bbf7d4cd4b5377033060c15 \
5fe3948ca75de1031e1d85619e0ad61e \
b419a866b3c2dbfd10a4ed18b22149f7 \
5897f0b8668b0c1c542c687778835fb7 \
cd46e45f85eaa7072437dd9fa6793d6f \
8d4ccefc4eb1ac641ac1bd30b18c6d64 \
c49bca137eb21c2e04da62712ca2b4f5 \
40c57112c38791852cfac7a5d19ed83a
Test: Encrypt
Comment: Section 1, 192-bit (p.6)
Key: 00112233445566778899aabbccddeeff \
0011223344556677
IV: 0f1e2d3c4b5a69788796a5b4c3d2e1f0
Plaintext: 11111111aaaaaaaa11111111bbbbbbbb \
11111111cccccccc11111111dddddddd \
22222222aaaaaaaa22222222bbbbbbbb \
22222222cccccccc22222222dddddddd \
33333333aaaaaaaa33333333bbbbbbbb \
33333333cccccccc33333333dddddddd \
44444444aaaaaaaa44444444bbbbbbbb \
44444444cccccccc44444444dddddddd \
55555555aaaaaaaa55555555bbbbbbbb \
55555555cccccccc55555555dddddddd
Ciphertext: afe6cf23974b533c672a826264ea785f \
4e4f7f780dc7f3f1e0962b80902386d5 \
14e9c3e77259de92dd1102ffab086c1e \
a52a71260db5920a83295c25320e4211 \
47ca45d532f327b856ea947cd2196ae2 \
e040826548b4c891b0ed0ca6e714dbc4 \
631998d548110d666b3d54c2a091955c \
6f05beb4f62309368696c9791fc4c551 \
564a2637f194346ec45fbca6c72a5b46 \
12e208d531d6c34cc5c64eac6bd0cf8c
Test: Encrypt
Comment: Section 1, 256-bit (p.11)
Key: 00112233445566778899aabbccddeeff \
00112233445566778899aabbccddeeff
IV: 0f1e2d3c4b5a69788796a5b4c3d2e1f0
Plaintext: 11111111aaaaaaaa11111111bbbbbbbb \
11111111cccccccc11111111dddddddd \
22222222aaaaaaaa22222222bbbbbbbb \
22222222cccccccc22222222dddddddd \
33333333aaaaaaaa33333333bbbbbbbb \
33333333cccccccc33333333dddddddd \
44444444aaaaaaaa44444444bbbbbbbb \
44444444cccccccc44444444dddddddd \
55555555aaaaaaaa55555555bbbbbbbb \
55555555cccccccc55555555dddddddd
Ciphertext: 523a8a806ae621f155fdd28dbc34e1ab \
7b9b42432ad8b2efb96e23b13f0a6e52 \
f36185d50ad002c5f601bee5493f118b \
243ee2e313642bffc3902e7b2efd9a12 \
fa682edd2d23c8b9c5f043c18b17c1ec \
4b5867918270fbec1027c19ed6af833d \
a5d620994668ca22f599791d292dd627 \
3b2959082aafb7a996167cce1eec5f0c \
fd15f610d87e2dda9ba68ce1260ca54b \
222491418374294e7909b1e8551cd8de
Test: Encrypt
AlgorithmType: SymmetricCipher
Name: ARIA/CTR
Source: ARIA Test Vectors PDF (05.05.2004)
Comment: Tests using CTR mode
Comment: Section 1, 128-bit (p.3)
Key: 00112233445566778899aabbccddeeff
IV: 00000000000000000000000000000000
Plaintext: 11111111aaaaaaaa11111111bbbbbbbb \
11111111cccccccc11111111dddddddd \
22222222aaaaaaaa22222222bbbbbbbb \
22222222cccccccc22222222dddddddd \
33333333aaaaaaaa33333333bbbbbbbb \
33333333cccccccc33333333dddddddd \
44444444aaaaaaaa44444444bbbbbbbb \
44444444cccccccc44444444dddddddd \
55555555aaaaaaaa55555555bbbbbbbb \
55555555cccccccc55555555dddddddd
Ciphertext: ac5d7de805a0bf1c57c854501af60fa1 \
1497e2a34519dea1569e91e5b5ccae2f \
f3bfa1bf975f4571f48be191613546c3 \
911163c085f871f0e7ae5f2a085b8185 \
1c2a3ddf20ecb8fa51901aec8ee4ba32 \
a35dab67bb72cd9140ad188a967ac0fb \
bdfa94ea6cce47dcf8525ab5a814cfeb \
2bb60ee2b126e2d9d847c1a9e96f9019 \
e3e6a7fe40d3829afb73db1cc245646a \
ddb62d9b907baaafbe46a73dbc131d3d
Test: Encrypt
Comment: Section 2, 192-bit (p.6)
Key: 00112233445566778899aabbccddeeff \
0011223344556677
IV: 00000000000000000000000000000000
Plaintext: 11111111aaaaaaaa11111111bbbbbbbb \
11111111cccccccc11111111dddddddd \
22222222aaaaaaaa22222222bbbbbbbb \
22222222cccccccc22222222dddddddd \
33333333aaaaaaaa33333333bbbbbbbb \
33333333cccccccc33333333dddddddd \
44444444aaaaaaaa44444444bbbbbbbb \
44444444cccccccc44444444dddddddd \
55555555aaaaaaaa55555555bbbbbbbb \
55555555cccccccc55555555dddddddd
Ciphertext: 08625ca8fe569c19ba7af3760a6ed1ce \
f4d199263e999dde14082dbba7560b79 \
a4c6b456b8707dce751f9854f18893df \
db3f4e5afa539733e6f1e70b98ba3789 \
1f8f81e95df8efc26c7ce043504cb189 \
58b865e4e316cd2aa1c97f31bf23dc04 \
6ef326b95a692a191ba0f2a41c5fe9ae \
070f236ff7078e703b42666caafbdd20 \
bad74ac4c20c0f46c7ca24c151716575 \
c947da16c90cfe1bf217a41cfebe7531
Test: Encrypt
Comment: Section 3, 256-bit (p.11)
Key: 00112233445566778899aabbccddeeff \
00112233445566778899aabbccddeeff
IV: 00000000000000000000000000000000
Plaintext: 11111111aaaaaaaa11111111bbbbbbbb \
11111111cccccccc11111111dddddddd \
22222222aaaaaaaa22222222bbbbbbbb \
22222222cccccccc22222222dddddddd \
33333333aaaaaaaa33333333bbbbbbbb \
33333333cccccccc33333333dddddddd \
44444444aaaaaaaa44444444bbbbbbbb \
44444444cccccccc44444444dddddddd \
55555555aaaaaaaa55555555bbbbbbbb \
55555555cccccccc55555555dddddddd
Ciphertext: 30026c329666141721178b99c0a1f1b2 \
f06940253f7b3089e2a30ea86aa3c88f \
5940f05ad7ee41d71347bb7261e348f1 \
8360473fdf7d4e7723bffb4411cc13f6 \
cdd89f3bc7b9c768145022c7a74f14d7 \
c305cd012a10f16050c23f1ae5c23f45 \
998d13fbaa041e51619577e077276489 \
6a5d4516d8ffceb3bf7e05f613edd9a6 \
0cdcedaff9cfcaf4e00d445a54334f73 \
ab2cad944e51d266548e61c6eb0aa1cd
Test: Encrypt

270
aria.cpp Normal file
View File

@ -0,0 +1,270 @@
// aria.cpp - written and placed in the public domain by Jeffrey Walton
#include "pch.h"
#include "config.h"
#if CRYPTOPP_MSC_VERSION
# pragma warning(disable: 4456)
# if (CRYPTOPP_MSC_VERSION >= 1400)
# pragma warning(disable: 6246)
# endif
#endif
#include "aria.h"
#include "misc.h"
#include "cpu.h"
#include <iostream>
#include "files.h"
#include "hex.h"
NAMESPACE_BEGIN(CryptoPP)
// The ARIA s-boxes
CRYPTOPP_ALIGN_DATA(16)
const byte ARIA::Base::S[4][256] = {
// S-box type 1
{
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c,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, 0xb5, 0xe7, 0x42, 0xb3, 0xc7, 0xea, 0xf7, 0x4c, 0x11, 0x33, 0x03, 0xa2, 0xac, 0x60}
};
// constants used in the round key generation
CRYPTOPP_ALIGN_DATA(16)
const byte ARIA::Base::KRK[3][16] = {
{0x51, 0x7c, 0xc1, 0xb7, 0x27, 0x22, 0x0a, 0x94, 0xfe, 0x13, 0xab, 0xe8, 0xfa, 0x9a, 0x6e, 0xe0},
{0x6d, 0xb1, 0x4a, 0xcc, 0x9e, 0x21, 0xc8, 0x20, 0xff, 0x28, 0xb1, 0xd5, 0xef, 0x5d, 0xe2, 0xb0},
{0xdb, 0x92, 0x37, 0x1d, 0x21, 0x26, 0xe9, 0x70, 0x03, 0x24, 0x97, 0x75, 0x04, 0xe8, 0xc9, 0x0e}
};
// Diffusion Layer
inline void DL (const byte *i, byte *o)
{
byte T;
T = i[ 3] ^ i[ 4] ^ i[ 9] ^ i[14];
o[ 0] = i[ 6] ^ i[ 8] ^ i[13] ^ T;
o[ 5] = i[ 1] ^ i[10] ^ i[15] ^ T;
o[11] = i[ 2] ^ i[ 7] ^ i[12] ^ T;
o[14] = i[ 0] ^ i[ 5] ^ i[11] ^ T;
T = i[ 2] ^ i[ 5] ^ i[ 8] ^ i[15];
o[ 1] = i[ 7] ^ i[ 9] ^ i[12] ^ T;
o[ 4] = i[ 0] ^ i[11] ^ i[14] ^ T;
o[10] = i[ 3] ^ i[ 6] ^ i[13] ^ T;
o[15] = i[ 1] ^ i[ 4] ^ i[10] ^ T;
T = i[ 1] ^ i[ 6] ^ i[11] ^ i[12];
o[ 2] = i[ 4] ^ i[10] ^ i[15] ^ T;
o[ 7] = i[ 3] ^ i[ 8] ^ i[13] ^ T;
o[ 9] = i[ 0] ^ i[ 5] ^ i[14] ^ T;
o[12] = i[ 2] ^ i[ 7] ^ i[ 9] ^ T;
T = i[ 0] ^ i[ 7] ^ i[10] ^ i[13];
o[ 3] = i[ 5] ^ i[11] ^ i[14] ^ T;
o[ 6] = i[ 2] ^ i[ 9] ^ i[12] ^ T;
o[ 8] = i[ 1] ^ i[ 4] ^ i[15] ^ T;
o[13] = i[ 3] ^ i[ 6] ^ i[ 8] ^ T;
}
// Right-rotate 128 bit source string s by n bits and XOR it to target string t.
// Three implementations are provided. First is the CXX implementation. Second is the Intel
// implementations (one with MOVBE, one without MOVBE). Third is the ARM implementations.
// The specializations for 0 and non-0 rotate help save about 100 insns per subkey round.
template <unsigned int N>
inline void RotateAndXOR(const byte s[16], byte t[16])
{
// From the reference implementation
int i, n, q;
n = N; q = n/8; n %= 8;
for (i = 0; i < 16; i++) {
t[(q+i) % 16] ^= (s[i] >> n);
if (n != 0) t[(q+i+1) % 16] ^= (s[i] << (8-n));
}
}
template<>
inline void RotateAndXOR<0>(const byte s[16], byte t[16])
{
for (int i=0; i<16; ++i)
t[i] ^= s[i];
}
void ARIA::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs &params)
{
CRYPTOPP_ASSERT(key && keylen);
CRYPTOPP_UNUSED(params);
// w0 makes room for a 32-byte key. w1, w2 and w3 uses 16-byte blocks
int i, R = (keylen+32)/4, q = (keylen - 16) / 8;
byte *w0 = m_w.data(), *w1 = m_w.data()+32, *w2 = m_w.data()+48, *w3 = m_w.data()+64, *t = m_w.data()+80;
byte* rk = m_rkey.data();
m_rounds = R;
memcpy(w0, key, keylen);
for (i = 0; i < 16; i++)
t[i] = S[i % 4][KRK[q][i] ^ w0[i]];
DL (t, w1);
if (m_rounds == 14)
for (i = 0; i < 8; i++)
w1[i] ^= w0[16+i];
else if (m_rounds==16)
for (i = 0; i < 16; i++)
w1[i] ^= w0[16+i];
q = (q==2) ? 0 : (q+1);
for (i = 0; i < 16; i++)
t[i] = S[(2 + i) % 4][KRK[q][i] ^ w1[i]];
DL (t, w2);
for (i = 0; i < 16; i++)
w2[i] ^= w0[i];
q = (q==2) ? 0 : (q+1);
for (i = 0; i < 16; i++)
t[i] = S[i % 4][KRK[q][i] ^ w2[i]];
DL (t, w3);
for (i = 0; i < 16; i++)
w3[i] ^= w1[i];
for (i = 0; i < 16*(R+1); i++)
rk[i] = 0;
RotateAndXOR<0>(w0, rk + 0); RotateAndXOR<19>(w1, rk + 0);
RotateAndXOR<0>(w1, rk + 16); RotateAndXOR<19>(w2, rk + 16);
RotateAndXOR<0>(w2, rk + 32); RotateAndXOR<19>(w3, rk + 32);
RotateAndXOR<0>(w3, rk + 48); RotateAndXOR<19>(w0, rk + 48);
RotateAndXOR<0>(w0, rk + 64); RotateAndXOR<31>(w1, rk + 64);
RotateAndXOR<0>(w1, rk + 80); RotateAndXOR<31>(w2, rk + 80);
RotateAndXOR<0>(w2, rk + 96); RotateAndXOR<31>(w3, rk + 96);
RotateAndXOR<0>(w3, rk + 112); RotateAndXOR<31>(w0, rk + 112);
RotateAndXOR<0>(w0, rk + 128); RotateAndXOR<67>(w1, rk + 128);
RotateAndXOR<0>(w1, rk + 144); RotateAndXOR<67>(w2, rk + 144);
RotateAndXOR<0>(w2, rk + 160); RotateAndXOR<67>(w3, rk + 160);
RotateAndXOR<0>(w3, rk + 176); RotateAndXOR<67>(w0, rk + 176);
RotateAndXOR<0>(w0, rk + 192); RotateAndXOR<97>(w1, rk + 192);
if (m_rounds > 12) {
RotateAndXOR<0>(w1, rk + 208); RotateAndXOR<97>(w2, rk + 208);
RotateAndXOR<0>(w2, rk + 224); RotateAndXOR<97>(w3, rk + 224);
}
if (m_rounds > 14) {
RotateAndXOR<0>(w3, rk + 240); RotateAndXOR< 97>(w0, rk + 240);
RotateAndXOR<0>(w0, rk + 256); RotateAndXOR<109>(w1, rk + 256);
}
if (!IsForwardTransformation())
{
int i, j;
for (j = 0; j < 16; j++)
{
t[j] = rk[j];
rk[j] = rk[16*R + j];
rk[16*R + j] = t[j];
}
for (i = 1; i <= R/2; i++)
{
DL (rk + i*16, t);
DL (rk + (R-i)*16, rk + i*16);
for (j = 0; j < 16; j++)
rk[(R-i)*16 + j] = t[j];
}
}
}
void ARIA::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{
// t is a workspace; cast away const for this method
byte* t = const_cast<byte*>(m_w.data()+80);
int i, j, R = m_rounds;
const byte *p = inBlock;
const byte *e = m_rkey.data();
byte *c = outBlock;
for (j = 0; j < 16; j++) c[j] = p[j];
for (i = 0; i < R/2; i++)
{
for (j = 0; j < 16; j++) t[j] = S[ j % 4][e[j] ^ c[j]];
DL(t, c); e += 16;
for (j = 0; j < 16; j++) t[j] = S[(2 + j) % 4][e[j] ^ c[j]];
DL(t, c); e += 16;
}
DL(c, t);
for (j = 0; j < 16; j++) c[j] = e[j] ^ t[j];
if (xorBlock)
for (i = 0; i < 16; ++i)
outBlock[i] ^= xorBlock[i];
}
NAMESPACE_END

59
aria.h Normal file
View File

@ -0,0 +1,59 @@
// aria.h - written and placed in the public domain by Jeffrey Walton
//! \file aria.h
//! \brief Classes for the ARIA block cipher
//! \sa <A HREF="http://tools.ietf.org/html/rfc5794">RFC 5794, A Description of the ARIA Encryption Algorithm</A>,
//! <A HREF="http://seed.kisa.or.kr/iwt/ko/bbs/EgovReferenceList.do?bbsId=BBSMSTR_000000000002">Korea
//! Internet & Security Agency homepage</A>
#ifndef CRYPTOPP_ARIA_H
#define CRYPTOPP_ARIA_H
#include "config.h"
#include "seckey.h"
#include "secblock.h"
NAMESPACE_BEGIN(CryptoPP)
//! \class ARIA_Info
//! \brief ARIA block cipher information
struct ARIA_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
{
CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "ARIA";}
};
//! \class ARIA
//! \brief ARIA block cipher
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#ARIA">ARIA</a>
class ARIA : public ARIA_Info, public BlockCipherDocumentation
{
public:
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<ARIA_Info>
{
public:
void UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs &params);
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
protected:
CRYPTOPP_ALIGN_DATA(16)
static const byte S[4][256];
CRYPTOPP_ALIGN_DATA(16)
static const byte KRK[3][16];
FixedSizeAlignedSecBlock<byte, 16*17> m_rkey; // round keys
FixedSizeAlignedSecBlock<byte, 16*6> m_w; // scratch, w0, w1, w2, w3 and t
unsigned int m_rounds;
};
public:
typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
};
typedef ARIA::Encryption ARIAEncryption;
typedef ARIA::Decryption ARIADecryption;
NAMESPACE_END
#endif

View File

@ -531,6 +531,8 @@ void Benchmark2(double t, double hertz)
BenchMarkByName<SymmetricCipher>("AES/OFB", 16);
BenchMarkByName<SymmetricCipher>("AES/CFB", 16);
BenchMarkByName<SymmetricCipher>("AES/ECB", 16);
BenchMarkByName<SymmetricCipher>("ARIA/CTR", 16);
BenchMarkByName<SymmetricCipher>("ARIA/CTR", 32);
BenchMarkByName<SymmetricCipher>("Camellia/CTR", 16);
BenchMarkByName<SymmetricCipher>("Camellia/CTR", 32);
BenchMarkByName<SymmetricCipher>("Twofish/CTR");

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">

View File

@ -180,7 +180,7 @@
<!-- FIPS Validated Warning -->
<ItemDefinitionGroup Label="FIPS Warning">
<PreBuildEvent Condition="'$(Configuration)'=='DLL-Import Debug' Or '$(Configuration)'=='DLL-Import Release'">
<Command>
<Command>
echo *************************************************************************
echo This configuration requires cryptopp.dll. You can build it yourself using
echo the cryptdll project, or obtain a pre-built, FIPS 140-2 validated DLL. If
@ -221,6 +221,7 @@
<None Include="TestVectors\blake2.txt" />
<None Include="TestVectors\blake2b.txt" />
<None Include="TestVectors\blake2s.txt" />
<None Include="TestVectors\aria.txt" />
<None Include="TestVectors\camellia.txt" />
<None Include="TestVectors\ccm.txt" />
<None Include="TestVectors\chacha.txt" />
@ -257,6 +258,7 @@
<None Include="TestVectors\whrlpool.txt" />
<None Include="TestData\3desval.dat" />
<None Include="TestData\3wayval.dat" />
<None Include="TestData\aria.dat" />
<None Include="TestData\camellia.dat" />
<None Include="TestData\cast128v.dat" />
<None Include="TestData\cast256v.dat" />

View File

@ -33,6 +33,9 @@
<None Include="TestVectors\blake2s.txt">
<Filter>TestVectors</Filter>
</None>
<None Include="TestVectors\aria.txt">
<Filter>TestVectors</Filter>
</None>
<None Include="TestVectors\camellia.txt">
<Filter>TestVectors</Filter>
</None>
@ -141,6 +144,9 @@
<None Include="TestData\3wayval.dat">
<Filter>TestData</Filter>
</None>
<None Include="TestData\aria.dat">
<Filter>TestData</Filter>
</None>
<None Include="TestData\camellia.dat">
<Filter>TestData</Filter>
</None>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -34,17 +34,14 @@
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{c39f4b46-6e89-4074-902e-ca57073044d2}</ProjectGuid>
<RootNamespace>cryptlib</RootNamespace>
<PlatformToolset>v100</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup>
@ -173,6 +170,7 @@
<ClCompile Include="algebra.cpp" />
<ClCompile Include="algparam.cpp" />
<ClCompile Include="arc4.cpp" />
<ClCompile Include="aria.cpp" />
<ClCompile Include="asn.cpp" />
<ClCompile Include="authenc.cpp" />
<ClCompile Include="base32.cpp" />
@ -345,6 +343,7 @@
<ClInclude Include="algebra.h" />
<ClInclude Include="algparam.h" />
<ClInclude Include="arc4.h" />
<ClInclude Include="aria.h" />
<ClInclude Include="argnames.h" />
<ClInclude Include="asn.h" />
<ClInclude Include="authenc.h" />

View File

@ -29,6 +29,9 @@
<ClCompile Include="arc4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="aria.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="asn.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -429,6 +432,9 @@
<ClInclude Include="arc4.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="aria.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="argnames.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">

View File

@ -17,6 +17,7 @@
#include "seal.h"
#include "whrlpool.h"
#include "ttmac.h"
#include "aria.h"
#include "camellia.h"
#include "shacal2.h"
#include "tea.h"
@ -145,6 +146,7 @@ void RegisterFactories()
RegisterSignatureSchemeDefaultFactories<RSASS<PSS, SHA1> >("RSA/PSS-MGF1(SHA-1)");
RegisterSymmetricCipherDefaultFactories<SEAL<> >();
RegisterSymmetricCipherDefaultFactories<ECB_Mode<SHACAL2> >();
RegisterSymmetricCipherDefaultFactories<ECB_Mode<ARIA> >();
RegisterSymmetricCipherDefaultFactories<ECB_Mode<Camellia> >();
RegisterSymmetricCipherDefaultFactories<ECB_Mode<TEA> >();
RegisterSymmetricCipherDefaultFactories<ECB_Mode<XTEA> >();
@ -168,6 +170,8 @@ void RegisterFactories()
RegisterAuthenticatedSymmetricCipherDefaultFactories<CCM<AES> >();
RegisterAuthenticatedSymmetricCipherDefaultFactories<GCM<AES> >();
RegisterAuthenticatedSymmetricCipherDefaultFactories<EAX<AES> >();
RegisterSymmetricCipherDefaultFactories<CBC_Mode<ARIA> >(); // For test vectors
RegisterSymmetricCipherDefaultFactories<CTR_Mode<ARIA> >();
RegisterSymmetricCipherDefaultFactories<CTR_Mode<Camellia> >();
RegisterSymmetricCipherDefaultFactories<CTR_Mode<Twofish> >();
RegisterSymmetricCipherDefaultFactories<CTR_Mode<Serpent> >();

View File

@ -25,6 +25,7 @@
#include "stdcpp.h"
#include "ossig.h"
#include "trap.h"
#include "aria.h"
#include "validate.h"
#include "bench.h"
@ -971,22 +972,23 @@ bool Validate(int alg, bool thorough, const char *seedInput)
case 60: result = Test::ValidateDLIES(); break;
case 61: result = Test::ValidateBaseCode(); break;
case 62: result = Test::ValidateSHACAL2(); break;
case 63: result = Test::ValidateCamellia(); break;
case 64: result = Test::ValidateWhirlpool(); break;
case 65: result = Test::ValidateTTMAC(); break;
case 66: result = Test::ValidateSalsa(); break;
case 67: result = Test::ValidateSosemanuk(); break;
case 68: result = Test::ValidateVMAC(); break;
case 69: result = Test::ValidateCCM(); break;
case 70: result = Test::ValidateGCM(); break;
case 71: result = Test::ValidateCMAC(); break;
case 72: result = Test::ValidateHKDF(); break;
case 73: result = Test::ValidateBLAKE2s(); break;
case 74: result = Test::ValidateBLAKE2b(); break;
case 75: result = Test::ValidatePoly1305(); break;
case 76: result = Test::ValidateSipHash(); break;
case 77: result = Test::ValidateHashDRBG(); break;
case 78: result = Test::ValidateHmacDRBG(); break;
case 63: result = Test::ValidateARIA(); break;
case 64: result = Test::ValidateCamellia(); break;
case 65: result = Test::ValidateWhirlpool(); break;
case 66: result = Test::ValidateTTMAC(); break;
case 67: result = Test::ValidateSalsa(); break;
case 68: result = Test::ValidateSosemanuk(); break;
case 69: result = Test::ValidateVMAC(); break;
case 70: result = Test::ValidateCCM(); break;
case 71: result = Test::ValidateGCM(); break;
case 72: result = Test::ValidateCMAC(); break;
case 73: result = Test::ValidateHKDF(); break;
case 74: result = Test::ValidateBLAKE2s(); break;
case 75: result = Test::ValidateBLAKE2b(); break;
case 76: result = Test::ValidatePoly1305(); break;
case 77: result = Test::ValidateSipHash(); break;
case 78: result = Test::ValidateHashDRBG(); break;
case 79: result = Test::ValidateHmacDRBG(); break;
#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_IMPORTS)
// http://github.com/weidai11/cryptopp/issues/92

View File

@ -41,6 +41,7 @@
#include "skipjack.h"
#include "shacal2.h"
#include "camellia.h"
#include "aria.h"
#include "osrng.h"
#include "drbg.h"
#include "rdrand.h"
@ -144,6 +145,7 @@ bool ValidateAll(bool thorough)
pass=ValidateTwofish() && pass;
pass=ValidateSerpent() && pass;
pass=ValidateSHACAL2() && pass;
pass=ValidateARIA() && pass;
pass=ValidateCamellia() && pass;
pass=ValidateSalsa() && pass;
pass=ValidateSosemanuk() && pass;
@ -2545,6 +2547,39 @@ bool ValidateSHACAL2()
return pass1 && pass2 && pass3;
}
bool ValidateARIA()
{
std::cout << "\nARIA validation suite running...\n\n";
bool pass1 = true, pass2 = true, pass3 = true;
ARIAEncryption enc;
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1;
ARIADecryption dec;
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2;
std::cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/aria.dat", true, new HexDecoder);
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<ARIAEncryption, ARIADecryption>(16), valdata, 15) && pass3;
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<ARIAEncryption, ARIADecryption>(24), valdata, 15) && pass3;
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<ARIAEncryption, ARIADecryption>(32), valdata, 15) && pass3;
return pass1 && pass2 && pass3;
}
bool ValidateCamellia()
{
std::cout << "\nCamellia validation suite running...\n\n";

View File

@ -73,6 +73,7 @@ bool ValidateRijndael();
bool ValidateTwofish();
bool ValidateSerpent();
bool ValidateSHACAL2();
bool ValidateARIA();
bool ValidateCamellia();
bool ValidateSalsa();
bool ValidateSosemanuk();