From a596d38a8cddca4af3416b2664e120028d96e6a9 Mon Sep 17 00:00:00 2001 From: Tianjia Zhang Date: Sun, 3 Oct 2021 11:07:24 +0800 Subject: obj: Add SM4 GCM/CCM OID Add the following OID: SM4-GCM: 1.2.156.10197.1.104.8 SM4-CCM: 1.2.156.10197.1.104.9 Signed-off-by: Tianjia Zhang Reviewed-by: Paul Dale Reviewed-by: Dmitry Belyavskiy Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/16731) --- crypto/objects/obj_dat.h | 20 +++++++++++++++----- crypto/objects/obj_mac.num | 2 ++ crypto/objects/objects.txt | 2 ++ fuzz/oids.txt | 2 ++ include/openssl/obj_mac.h | 10 ++++++++++ 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/crypto/objects/obj_dat.h b/crypto/objects/obj_dat.h index 5d638fb05d..ed9debf890 100644 --- a/crypto/objects/obj_dat.h +++ b/crypto/objects/obj_dat.h @@ -10,7 +10,7 @@ */ /* Serialized OID's */ -static const unsigned char so[8076] = { +static const unsigned char so[8092] = { 0x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 0] OBJ_rsadsi */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 6] OBJ_pkcs */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 13] OBJ_md2 */ @@ -1115,9 +1115,11 @@ static const unsigned char so[8076] = { 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x0D, /* [ 8045] OBJ_rpkiNotify */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x2F, /* [ 8053] OBJ_id_ct_geofeedCSVwithCRLF */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x30, /* [ 8064] OBJ_id_ct_signedChecklist */ + 0x2A,0x81,0x1C,0xCF,0x55,0x01,0x68,0x08, /* [ 8075] OBJ_sm4_gcm */ + 0x2A,0x81,0x1C,0xCF,0x55,0x01,0x68,0x09, /* [ 8083] OBJ_sm4_ccm */ }; -#define NUM_NID 1248 +#define NUM_NID 1250 static const ASN1_OBJECT nid_objs[NUM_NID] = { {"UNDEF", "undefined", NID_undef}, {"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]}, @@ -2367,9 +2369,11 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = { {"rpkiNotify", "RPKI Notify", NID_rpkiNotify, 8, &so[8045]}, {"id-ct-geofeedCSVwithCRLF", "id-ct-geofeedCSVwithCRLF", NID_id_ct_geofeedCSVwithCRLF, 11, &so[8053]}, {"id-ct-signedChecklist", "id-ct-signedChecklist", NID_id_ct_signedChecklist, 11, &so[8064]}, + {"SM4-GCM", "sm4-gcm", NID_sm4_gcm, 8, &so[8075]}, + {"SM4-CCM", "sm4-ccm", NID_sm4_ccm, 8, &so[8083]}, }; -#define NUM_SN 1239 +#define NUM_SN 1241 static const unsigned int sn_objs[NUM_SN] = { 364, /* "AD_DVCS" */ 419, /* "AES-128-CBC" */ @@ -2648,11 +2652,13 @@ static const unsigned int sn_objs[NUM_SN] = { 1204, /* "SM2-SM3" */ 1143, /* "SM3" */ 1134, /* "SM4-CBC" */ + 1249, /* "SM4-CCM" */ 1137, /* "SM4-CFB" */ 1136, /* "SM4-CFB1" */ 1138, /* "SM4-CFB8" */ 1139, /* "SM4-CTR" */ 1133, /* "SM4-ECB" */ + 1248, /* "SM4-GCM" */ 1135, /* "SM4-OFB" */ 188, /* "SMIME" */ 167, /* "SMIME-CAPS" */ @@ -3612,7 +3618,7 @@ static const unsigned int sn_objs[NUM_SN] = { 1093, /* "x509ExtAdmission" */ }; -#define NUM_LN 1239 +#define NUM_LN 1241 static const unsigned int ln_objs[NUM_LN] = { 363, /* "AD Time Stamping" */ 405, /* "ANSI X9.62" */ @@ -4797,11 +4803,13 @@ static const unsigned int ln_objs[NUM_LN] = { 1143, /* "sm3" */ 1144, /* "sm3WithRSAEncryption" */ 1134, /* "sm4-cbc" */ + 1249, /* "sm4-ccm" */ 1137, /* "sm4-cfb" */ 1136, /* "sm4-cfb1" */ 1138, /* "sm4-cfb8" */ 1139, /* "sm4-ctr" */ 1133, /* "sm4-ecb" */ + 1248, /* "sm4-gcm" */ 1135, /* "sm4-ofb" */ 1203, /* "sshkdf" */ 1205, /* "sskdf" */ @@ -4855,7 +4863,7 @@ static const unsigned int ln_objs[NUM_LN] = { 125, /* "zlib compression" */ }; -#define NUM_OBJ 1110 +#define NUM_OBJ 1112 static const unsigned int obj_objs[NUM_OBJ] = { 0, /* OBJ_undef 0 */ 181, /* OBJ_iso 1 */ @@ -5332,6 +5340,8 @@ static const unsigned int obj_objs[NUM_OBJ] = { 1136, /* OBJ_sm4_cfb1 1 2 156 10197 1 104 5 */ 1138, /* OBJ_sm4_cfb8 1 2 156 10197 1 104 6 */ 1139, /* OBJ_sm4_ctr 1 2 156 10197 1 104 7 */ + 1248, /* OBJ_sm4_gcm 1 2 156 10197 1 104 8 */ + 1249, /* OBJ_sm4_ccm 1 2 156 10197 1 104 9 */ 1172, /* OBJ_sm2 1 2 156 10197 1 301 */ 1143, /* OBJ_sm3 1 2 156 10197 1 401 */ 1204, /* OBJ_SM2_with_SM3 1 2 156 10197 1 501 */ diff --git a/crypto/objects/obj_mac.num b/crypto/objects/obj_mac.num index c626558ad5..f20dbba312 100644 --- a/crypto/objects/obj_mac.num +++ b/crypto/objects/obj_mac.num @@ -1245,3 +1245,5 @@ signedObject 1244 rpkiNotify 1245 id_ct_geofeedCSVwithCRLF 1246 id_ct_signedChecklist 1247 +sm4_gcm 1248 +sm4_ccm 1249 diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt index 51dba7dcf3..b71a8eae2c 100644 --- a/crypto/objects/objects.txt +++ b/crypto/objects/objects.txt @@ -1565,6 +1565,8 @@ sm-scheme 104 4 : SM4-CFB : sm4-cfb sm-scheme 104 5 : SM4-CFB1 : sm4-cfb1 sm-scheme 104 6 : SM4-CFB8 : sm4-cfb8 sm-scheme 104 7 : SM4-CTR : sm4-ctr +sm-scheme 104 8 : SM4-GCM : sm4-gcm +sm-scheme 104 9 : SM4-CCM : sm4-ccm # There is no OID that just denotes "HMAC" oddly enough... diff --git a/fuzz/oids.txt b/fuzz/oids.txt index f0dbc30fc3..0fb14839f9 100644 --- a/fuzz/oids.txt +++ b/fuzz/oids.txt @@ -1111,3 +1111,5 @@ OBJ_signedObject="\x2B\x06\x01\x05\x05\x07\x30\x0B" OBJ_rpkiNotify="\x2B\x06\x01\x05\x05\x07\x30\x0D" OBJ_id_ct_geofeedCSVwithCRLF="\x2A\x86\x48\x86\xF7\x0D\x01\x09\x10\x01\x2F" OBJ_id_ct_signedChecklist="\x2A\x86\x48\x86\xF7\x0D\x01\x09\x10\x01\x30" +OBJ_sm4_gcm="\x2A\x81\x1C\xCF\x55\x01\x68\x08" +OBJ_sm4_ccm="\x2A\x81\x1C\xCF\x55\x01\x68\x09" diff --git a/include/openssl/obj_mac.h b/include/openssl/obj_mac.h index 0e86027667..c70bf172ba 100644 --- a/include/openssl/obj_mac.h +++ b/include/openssl/obj_mac.h @@ -4952,6 +4952,16 @@ #define NID_sm4_ctr 1139 #define OBJ_sm4_ctr OBJ_sm_scheme,104L,7L +#define SN_sm4_gcm "SM4-GCM" +#define LN_sm4_gcm "sm4-gcm" +#define NID_sm4_gcm 1248 +#define OBJ_sm4_gcm OBJ_sm_scheme,104L,8L + +#define SN_sm4_ccm "SM4-CCM" +#define LN_sm4_ccm "sm4-ccm" +#define NID_sm4_ccm 1249 +#define OBJ_sm4_ccm OBJ_sm_scheme,104L,9L + #define SN_hmac "HMAC" #define LN_hmac "hmac" #define NID_hmac 855 -- cgit v1.2.3