authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-16 16:30:28-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-17 00:08:42-07:00
log62e3fdcf4faf6bdfdfd468d54b540eec74a8bdae
tree3bf332076d081a75040fcf069516729587da6d6d
parent09560bc69a87f0540bd7a5a5c5e9e2a44db3a0cc

std.crypto.Certificate: add more object ids


1 files changed, 35 insertions(+), 0 deletions(-)

lib/std/crypto/Certificate.zig+35
......@@ -15,6 +15,8 @@ pub const Algorithm = enum {
1515 ecdsa_with_SHA256,
1616 ecdsa_with_SHA384,
1717 ecdsa_with_SHA512,
18 md2WithRSAEncryption,
19 md5WithRSAEncryption,
1820
1921 pub const map = std.ComptimeStringMap(Algorithm, .{
2022 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05 }, .sha1WithRSAEncryption },
......@@ -26,6 +28,8 @@ pub const Algorithm = enum {
2628 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02 }, .ecdsa_with_SHA256 },
2729 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x03 }, .ecdsa_with_SHA384 },
2830 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x04 }, .ecdsa_with_SHA512 },
31 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x02 }, .md2WithRSAEncryption },
32 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04 }, .md5WithRSAEncryption },
2933 });
3034
3135 pub fn Hash(comptime algorithm: Algorithm) type {
......@@ -35,6 +39,8 @@ pub const Algorithm = enum {
3539 .ecdsa_with_SHA256, .sha256WithRSAEncryption => crypto.hash.sha2.Sha256,
3640 .ecdsa_with_SHA384, .sha384WithRSAEncryption => crypto.hash.sha2.Sha384,
3741 .ecdsa_with_SHA512, .sha512WithRSAEncryption => crypto.hash.sha2.Sha512,
42 .md2WithRSAEncryption => @compileError("unimplemented"),
43 .md5WithRSAEncryption => crypto.hash.Md5,
3844 };
3945 }
4046};
......@@ -59,6 +65,7 @@ pub const Attribute = enum {
5965 organizationalUnitName,
6066 organizationIdentifier,
6167 pkcs9_emailAddress,
68 domainComponent,
6269
6370 pub const map = std.ComptimeStringMap(Attribute, .{
6471 .{ &[_]u8{ 0x55, 0x04, 0x03 }, .commonName },
......@@ -70,6 +77,7 @@ pub const Attribute = enum {
7077 .{ &[_]u8{ 0x55, 0x04, 0x0B }, .organizationalUnitName },
7178 .{ &[_]u8{ 0x55, 0x04, 0x61 }, .organizationIdentifier },
7279 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01 }, .pkcs9_emailAddress },
80 .{ &[_]u8{ 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19 }, .domainComponent },
7381 });
7482};
7583
......@@ -93,17 +101,40 @@ pub const ExtensionId = enum {
93101 crl_number,
94102 certificate_policies,
95103 authority_key_identifier,
104 msCertsrvCAVersion,
105 commonName,
106 ext_key_usage,
107 crl_distribution_points,
108 info_access,
109 entrustVersInfo,
110 enroll_certtype,
111 pe_logotype,
112 netscape_cert_type,
113 netscape_comment,
96114
97115 pub const map = std.ComptimeStringMap(ExtensionId, .{
116 .{ &[_]u8{ 0x55, 0x04, 0x03 }, .commonName },
117 .{ &[_]u8{ 0x55, 0x1D, 0x01 }, .authority_key_identifier },
118 .{ &[_]u8{ 0x55, 0x1D, 0x07 }, .subject_alt_name },
98119 .{ &[_]u8{ 0x55, 0x1D, 0x0E }, .subject_key_identifier },
99120 .{ &[_]u8{ 0x55, 0x1D, 0x0F }, .key_usage },
121 .{ &[_]u8{ 0x55, 0x1D, 0x0A }, .basic_constraints },
100122 .{ &[_]u8{ 0x55, 0x1D, 0x10 }, .private_key_usage_period },
101123 .{ &[_]u8{ 0x55, 0x1D, 0x11 }, .subject_alt_name },
102124 .{ &[_]u8{ 0x55, 0x1D, 0x12 }, .issuer_alt_name },
103125 .{ &[_]u8{ 0x55, 0x1D, 0x13 }, .basic_constraints },
104126 .{ &[_]u8{ 0x55, 0x1D, 0x14 }, .crl_number },
127 .{ &[_]u8{ 0x55, 0x1D, 0x1F }, .crl_distribution_points },
105128 .{ &[_]u8{ 0x55, 0x1D, 0x20 }, .certificate_policies },
106129 .{ &[_]u8{ 0x55, 0x1D, 0x23 }, .authority_key_identifier },
130 .{ &[_]u8{ 0x55, 0x1D, 0x25 }, .ext_key_usage },
131 .{ &[_]u8{ 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x15, 0x01 }, .msCertsrvCAVersion },
132 .{ &[_]u8{ 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x01, 0x01 }, .info_access },
133 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF6, 0x7D, 0x07, 0x41, 0x00 }, .entrustVersInfo },
134 .{ &[_]u8{ 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x14, 0x02 }, .enroll_certtype },
135 .{ &[_]u8{ 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x01, 0x0c }, .pe_logotype },
136 .{ &[_]u8{ 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x01 }, .netscape_cert_type },
137 .{ &[_]u8{ 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x0d }, .netscape_comment },
107138 });
108139};
109140
......@@ -238,6 +269,10 @@ pub const Parsed = struct {
238269 parsed_issuer.pub_key_algo,
239270 parsed_issuer.pubKey(),
240271 ),
272
273 .md2WithRSAEncryption, .md5WithRSAEncryption => {
274 return error.CertificateSignatureAlgorithmUnsupported;
275 },
241276 }
242277 }
243278