Skip to content

Commit 12505f1

Browse files
committed
Add 128-EEA3, 128-EIA3, ZUC-MAC, ZUC256, ZUC256-MAC and EVP_zuc256
1 parent c4455c9 commit 12505f1

18 files changed

Lines changed: 6184 additions & 5508 deletions

File tree

crypto/evp/c_allc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,5 +293,6 @@ void openssl_add_all_ciphers_int(void)
293293
#endif
294294
#ifndef OPENSSL_NO_ZUC
295295
EVP_add_cipher(EVP_zuc());
296+
EVP_add_cipher(EVP_zuc256());
296297
#endif
297298
}

crypto/evp/e_zuc.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,31 @@ const EVP_CIPHER *EVP_zuc(void)
109109
{
110110
return &zuc_cipher;
111111
}
112+
113+
static int zuc256_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
114+
const unsigned char *iv, int enc)
115+
{
116+
EVP_ZUC_KEY *dctx = EVP_C_DATA(EVP_ZUC_KEY, ctx);
117+
ZUC256_set_key(&dctx->ks, key, iv);
118+
return 1;
119+
}
120+
121+
const EVP_CIPHER zuc256_cipher = {
122+
NID_zuc256,
123+
1,
124+
ZUC256_KEY_LENGTH,
125+
ZUC256_IV_LENGTH,
126+
0,
127+
zuc256_init_key,
128+
zuc_do_cipher,
129+
NULL,
130+
sizeof(EVP_ZUC_KEY),
131+
NULL,NULL,NULL,NULL,
132+
};
133+
134+
const EVP_CIPHER *EVP_zuc256(void)
135+
{
136+
return &zuc256_cipher;
137+
}
138+
112139
#endif /* OPENSSL_NO_ZUC */

crypto/objects/obj_dat.h

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
/* Serialized OID's */
13-
static const unsigned char so[7915] = {
13+
static const unsigned char so[7972] = {
1414
0x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 0] OBJ_rsadsi */
1515
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 6] OBJ_pkcs */
1616
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 13] OBJ_md2 */
@@ -1104,9 +1104,15 @@ static const unsigned char so[7915] = {
11041104
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x82,0x2F,0x07, /* [ 7885] OBJ_sm9hash2 */
11051105
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x82,0x2F,0x07,0x01, /* [ 7894] OBJ_sm9hash2_with_sm3 */
11061106
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x82,0x2F,0x07,0x02, /* [ 7904] OBJ_sm9hash2_with_sha256 */
1107+
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x86,0x20,0x04, /* [ 7914] OBJ_zuc256 */
1108+
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x86,0x20,0x03, /* [ 7923] OBJ_zuc_mac */
1109+
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x86,0x20,0x05, /* [ 7932] OBJ_zuc256_mac */
1110+
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x86,0x20,0x05,0x01, /* [ 7941] OBJ_zuc256_mac32 */
1111+
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x86,0x20,0x05,0x02, /* [ 7951] OBJ_zuc256_mac64 */
1112+
0x2A,0x81,0x1C,0xCF,0x55,0x01,0x86,0x20,0x05,0x03, /* [ 7961] OBJ_zuc256_mac128 */
11071113
};
11081114

1109-
#define NUM_NID 1212
1115+
#define NUM_NID 1218
11101116
static const ASN1_OBJECT nid_objs[NUM_NID] = {
11111117
{"UNDEF", "undefined", NID_undef},
11121118
{"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]},
@@ -2320,9 +2326,15 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = {
23202326
{"sm9hash2", "sm9hash2", NID_sm9hash2, 9, &so[7885]},
23212327
{"sm9hash2-with-sm3", "sm9hash2-with-sm3", NID_sm9hash2_with_sm3, 10, &so[7894]},
23222328
{"sm9hash2-with-sha256", "sm9hash2-with-sha256", NID_sm9hash2_with_sha256, 10, &so[7904]},
2329+
{"ZUC256", "zuc256", NID_zuc256, 9, &so[7914]},
2330+
{"ZUC-MAC", "zuc-mac", NID_zuc_mac, 9, &so[7923]},
2331+
{"ZUC256-MAC", "zuc256-mac", NID_zuc256_mac, 9, &so[7932]},
2332+
{"ZUC256-MAC32", "zuc256-mac32", NID_zuc256_mac32, 10, &so[7941]},
2333+
{"ZUC256-MAC64", "zuc256-mac64", NID_zuc256_mac64, 10, &so[7951]},
2334+
{"ZUC256-MAC128", "zuc256-mac128", NID_zuc256_mac128, 10, &so[7961]},
23232335
};
23242336

2325-
#define NUM_SN 1202
2337+
#define NUM_SN 1208
23262338
static const unsigned int sn_objs[NUM_SN] = {
23272339
364, /* "AD_DVCS" */
23282340
419, /* "AES-128-CBC" */
@@ -2613,6 +2625,12 @@ static const unsigned int sn_objs[NUM_SN] = {
26132625
185, /* "X9cm" */
26142626
125, /* "ZLIB" */
26152627
1185, /* "ZUC" */
2628+
1213, /* "ZUC-MAC" */
2629+
1212, /* "ZUC256" */
2630+
1214, /* "ZUC256-MAC" */
2631+
1217, /* "ZUC256-MAC128" */
2632+
1215, /* "ZUC256-MAC32" */
2633+
1216, /* "ZUC256-MAC64" */
26162634
478, /* "aRecord" */
26172635
289, /* "aaControls" */
26182636
287, /* "ac-auditEntity" */
@@ -3528,7 +3546,7 @@ static const unsigned int sn_objs[NUM_SN] = {
35283546
1187, /* "zuc-128eia3" */
35293547
};
35303548

3531-
#define NUM_LN 1202
3549+
#define NUM_LN 1208
35323550
static const unsigned int ln_objs[NUM_LN] = {
35333551
363, /* "AD Time Stamping" */
35343552
405, /* "ANSI X9.62" */
@@ -4732,9 +4750,15 @@ static const unsigned int ln_objs[NUM_LN] = {
47324750
1185, /* "zuc" */
47334751
1186, /* "zuc-128eea3" */
47344752
1187, /* "zuc-128eia3" */
4753+
1213, /* "zuc-mac" */
4754+
1212, /* "zuc256" */
4755+
1214, /* "zuc256-mac" */
4756+
1217, /* "zuc256-mac128" */
4757+
1215, /* "zuc256-mac32" */
4758+
1216, /* "zuc256-mac64" */
47354759
};
47364760

4737-
#define NUM_OBJ 1099
4761+
#define NUM_OBJ 1105
47384762
static const unsigned int obj_objs[NUM_OBJ] = {
47394763
0, /* OBJ_undef 0 */
47404764
181, /* OBJ_iso 1 */
@@ -5483,6 +5507,9 @@ static const unsigned int obj_objs[NUM_OBJ] = {
54835507
1149, /* OBJ_hmac_sm3 1 2 156 10197 1 401 2 */
54845508
1186, /* OBJ_zuc_128eea3 1 2 156 10197 1 800 1 */
54855509
1187, /* OBJ_zuc_128eia3 1 2 156 10197 1 800 2 */
5510+
1213, /* OBJ_zuc_mac 1 2 156 10197 1 800 3 */
5511+
1212, /* OBJ_zuc256 1 2 156 10197 1 800 4 */
5512+
1214, /* OBJ_zuc256_mac 1 2 156 10197 1 800 5 */
54865513
1192, /* OBJ_wapip192v1 1 2 156 11235 1 1 2 1 */
54875514
997, /* OBJ_id_tc26_gost_3410_2012_512_paramSetTest 1 2 643 7 1 2 1 2 0 */
54885515
998, /* OBJ_id_tc26_gost_3410_2012_512_paramSetA 1 2 643 7 1 2 1 2 1 */
@@ -5700,6 +5727,9 @@ static const unsigned int obj_objs[NUM_OBJ] = {
57005727
1175, /* OBJ_sm9bn256v1 1 2 156 10197 1 302 6 1 */
57015728
1210, /* OBJ_sm9hash2_with_sm3 1 2 156 10197 1 303 7 1 */
57025729
1211, /* OBJ_sm9hash2_with_sha256 1 2 156 10197 1 303 7 2 */
5730+
1215, /* OBJ_zuc256_mac32 1 2 156 10197 1 800 5 1 */
5731+
1216, /* OBJ_zuc256_mac64 1 2 156 10197 1 800 5 2 */
5732+
1217, /* OBJ_zuc256_mac128 1 2 156 10197 1 800 5 3 */
57035733
189, /* OBJ_id_smime_mod 1 2 840 113549 1 9 16 0 */
57045734
190, /* OBJ_id_smime_ct 1 2 840 113549 1 9 16 1 */
57055735
191, /* OBJ_id_smime_aa 1 2 840 113549 1 9 16 2 */

crypto/objects/obj_mac.num

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,3 +1209,9 @@ paillier 1208
12091209
sm9hash2 1209
12101210
sm9hash2_with_sm3 1210
12111211
sm9hash2_with_sha256 1211
1212+
zuc256 1212
1213+
zuc_mac 1213
1214+
zuc256_mac 1214
1215+
zuc256_mac32 1215
1216+
zuc256_mac64 1216
1217+
zuc256_mac128 1217

crypto/objects/objects.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,13 @@ sm9kdf 2 : sm9kdf-with-sha256
16501650
sm-scheme 800 : ZUC : zuc
16511651
zuc 1 : zuc-128eea3
16521652
zuc 2 : zuc-128eia3
1653+
zuc 3 : ZUC-MAC : zuc-mac
1654+
zuc 4 : ZUC256 : zuc256
1655+
zuc 5 : ZUC256-MAC : zuc256-mac
1656+
zuc256-mac 1 : ZUC256-MAC32 : zuc256-mac32
1657+
zuc256-mac 2 : ZUC256-MAC64 : zuc256-mac64
1658+
zuc256-mac 3 : ZUC256-MAC128 : zuc256-mac128
1659+
16531660

16541661
# WAPI (GB 15629.11-2003-XG1-2006)
16551662
ISO-CN 11235 : bwips

crypto/zuc/build.info

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
LIBS=../../libcrypto
2-
SOURCE[../../libcrypto]=zuc_core.c
2+
SOURCE[../../libcrypto]=zuc_core.c zuc_eea.c zuc_eia.c
3+
INCLUDE[zuc_core.o]=../modes
4+
INCLUDE[zuc_eia.o]=../modes

crypto/zuc/zuc256.c

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)