aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-05-19 12:13:42 -0400
committerJack Lloyd <[email protected]>2017-05-19 12:13:42 -0400
commitb0fbcf8d24fb1c677aad3d2cfdd0c18274493f07 (patch)
treef3a64f226ef505df925dae82b8d376d418f8f9c7 /src
parentb517f47683a6aef6badd97374446ffb7797657d3 (diff)
Add SM3 OIDs and PKCSv1.5 hash prefix
Diffstat (limited to 'src')
-rw-r--r--src/build-data/oids.txt3
-rw-r--r--src/lib/asn1/oids.cpp6
-rw-r--r--src/lib/pk_pad/hash_id/hash_id.cpp8
3 files changed, 16 insertions, 1 deletions
diff --git a/src/build-data/oids.txt b/src/build-data/oids.txt
index 4a42ff9ca..0ebfcf8d6 100644
--- a/src/build-data/oids.txt
+++ b/src/build-data/oids.txt
@@ -59,6 +59,8 @@
1.2.840.113549.2.5 = MD5
1.3.6.1.4.1.11591.12.2 = Tiger(24,3)
+1.2.156.10197.1.401 = SM3
+
1.3.14.3.2.26 = SHA-160
# From NIST:
@@ -102,6 +104,7 @@
1.2.840.113549.1.1.12 = RSA/EMSA3(SHA-384)
1.2.840.113549.1.1.13 = RSA/EMSA3(SHA-512)
1.3.36.3.3.1.2 = RSA/EMSA3(RIPEMD-160)
+1.2.156.10197.1.504 = RSA/EMSA3(SM3)
1.2.840.10040.4.3 = DSA/EMSA1(SHA-160)
diff --git a/src/lib/asn1/oids.cpp b/src/lib/asn1/oids.cpp
index eb5101e85..17bfb9f1c 100644
--- a/src/lib/asn1/oids.cpp
+++ b/src/lib/asn1/oids.cpp
@@ -1,7 +1,7 @@
/*
* OID maps
*
-* This file was automatically generated by ./src/scripts/oids.py on 2016-11-21
+* This file was automatically generated by ./src/scripts/oids.py on 2017-05-19
*
* All manual edits to this file will be lost. Edit the script
* then regenerate this source file.
@@ -19,6 +19,8 @@ std::string lookup(const OID& oid)
{
const std::string oid_str = oid.as_string();
if(oid_str == "1.0.14888.3.0.5") return "ECKCDSA";
+ if(oid_str == "1.2.156.10197.1.401") return "SM3";
+ if(oid_str == "1.2.156.10197.1.504") return "RSA/EMSA3(SM3)";
if(oid_str == "1.2.250.1.223.101.256.1") return "frp256v1";
if(oid_str == "1.2.410.200004.1.100.4.3") return "ECKCDSA/EMSA1(SHA-1)";
if(oid_str == "1.2.410.200004.1.100.4.4") return "ECKCDSA/EMSA1(SHA-224)";
@@ -309,6 +311,7 @@ OID lookup(const std::string& name)
if(name == "RSA/EMSA3(SHA-3(512))") return OID("2.16.840.1.101.3.4.3.16");
if(name == "RSA/EMSA3(SHA-384)") return OID("1.2.840.113549.1.1.12");
if(name == "RSA/EMSA3(SHA-512)") return OID("1.2.840.113549.1.1.13");
+ if(name == "RSA/EMSA3(SM3)") return OID("1.2.156.10197.1.504");
if(name == "SEED/CBC") return OID("1.2.410.200004.1.4");
if(name == "SHA-160") return OID("1.3.14.3.2.26");
if(name == "SHA-224") return OID("2.16.840.1.101.3.4.2.4");
@@ -322,6 +325,7 @@ OID lookup(const std::string& name)
if(name == "SHA-512-256") return OID("2.16.840.1.101.3.4.2.6");
if(name == "SHAKE-128") return OID("2.16.840.1.101.3.4.2.11");
if(name == "SHAKE-256") return OID("2.16.840.1.101.3.4.2.12");
+ if(name == "SM3") return OID("1.2.156.10197.1.401");
if(name == "Serpent/CBC") return OID("1.3.6.1.4.1.25258.3.1");
if(name == "Serpent/GCM") return OID("1.3.6.1.4.1.25258.3.101");
if(name == "Serpent/OCB") return OID("1.3.6.1.4.1.25258.3.2.4");
diff --git a/src/lib/pk_pad/hash_id/hash_id.cpp b/src/lib/pk_pad/hash_id/hash_id.cpp
index 71a3dbe22..4cb613f76 100644
--- a/src/lib/pk_pad/hash_id/hash_id.cpp
+++ b/src/lib/pk_pad/hash_id/hash_id.cpp
@@ -44,6 +44,11 @@ const uint8_t SHA_512_256_PKCS_ID[] = {
0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x06, 0x05, 0x00, 0x04, 0x20 };
+const uint8_t SM3_PKCS_ID[] = {
+0x30, 0x30, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF,
+0x55, 0x01, 0x83, 0x11, 0x05, 0x00, 0x04, 0x20,
+};
+
const uint8_t TIGER_PKCS_ID[] = {
0x30, 0x29, 0x30, 0x0D, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04,
0x01, 0xDA, 0x47, 0x0C, 0x02, 0x05, 0x00, 0x04, 0x18 };
@@ -91,6 +96,9 @@ std::vector<uint8_t> pkcs_hash_id(const std::string& name)
return std::vector<uint8_t>(SHA_512_256_PKCS_ID,
SHA_512_256_PKCS_ID + sizeof(SHA_512_256_PKCS_ID));
+ if(name == "SM3")
+ return std::vector<uint8_t>(SM3_PKCS_ID, SM3_PKCS_ID + sizeof(SM3_PKCS_ID));
+
if(name == "Tiger(24,3)")
return std::vector<uint8_t>(TIGER_PKCS_ID,
TIGER_PKCS_ID + sizeof(TIGER_PKCS_ID));