| ... | @@ -15,6 +15,8 @@ pub const Algorithm = enum { | ... | @@ -15,6 +15,8 @@ pub const Algorithm = enum { |
| 15 | ecdsa_with_SHA256, | 15 | ecdsa_with_SHA256, |
| 16 | ecdsa_with_SHA384, | 16 | ecdsa_with_SHA384, |
| 17 | ecdsa_with_SHA512, | 17 | ecdsa_with_SHA512, |
| | 18 | md2WithRSAEncryption, |
| | 19 | md5WithRSAEncryption, |
| 18 | | 20 | |
| 19 | pub const map = std.ComptimeStringMap(Algorithm, .{ | 21 | pub const map = std.ComptimeStringMap(Algorithm, .{ |
| 20 | .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05 }, .sha1WithRSAEncryption }, | 22 | .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05 }, .sha1WithRSAEncryption }, |
| ... | @@ -26,6 +28,8 @@ pub const Algorithm = enum { | ... | @@ -26,6 +28,8 @@ pub const Algorithm = enum { |
| 26 | .{ &[_]u8{ 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02 }, .ecdsa_with_SHA256 }, | 28 | .{ &[_]u8{ 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02 }, .ecdsa_with_SHA256 }, |
| 27 | .{ &[_]u8{ 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x03 }, .ecdsa_with_SHA384 }, | 29 | .{ &[_]u8{ 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x03 }, .ecdsa_with_SHA384 }, |
| 28 | .{ &[_]u8{ 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x04 }, .ecdsa_with_SHA512 }, | 30 | .{ &[_]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 }, |
| 29 | }); | 33 | }); |
| 30 | | 34 | |
| 31 | pub fn Hash(comptime algorithm: Algorithm) type { | 35 | pub fn Hash(comptime algorithm: Algorithm) type { |
| ... | @@ -35,6 +39,8 @@ pub const Algorithm = enum { | ... | @@ -35,6 +39,8 @@ pub const Algorithm = enum { |
| 35 | .ecdsa_with_SHA256, .sha256WithRSAEncryption => crypto.hash.sha2.Sha256, | 39 | .ecdsa_with_SHA256, .sha256WithRSAEncryption => crypto.hash.sha2.Sha256, |
| 36 | .ecdsa_with_SHA384, .sha384WithRSAEncryption => crypto.hash.sha2.Sha384, | 40 | .ecdsa_with_SHA384, .sha384WithRSAEncryption => crypto.hash.sha2.Sha384, |
| 37 | .ecdsa_with_SHA512, .sha512WithRSAEncryption => crypto.hash.sha2.Sha512, | 41 | .ecdsa_with_SHA512, .sha512WithRSAEncryption => crypto.hash.sha2.Sha512, |
| | 42 | .md2WithRSAEncryption => @compileError("unimplemented"), |
| | 43 | .md5WithRSAEncryption => crypto.hash.Md5, |
| 38 | }; | 44 | }; |
| 39 | } | 45 | } |
| 40 | }; | 46 | }; |
| ... | @@ -59,6 +65,7 @@ pub const Attribute = enum { | ... | @@ -59,6 +65,7 @@ pub const Attribute = enum { |
| 59 | organizationalUnitName, | 65 | organizationalUnitName, |
| 60 | organizationIdentifier, | 66 | organizationIdentifier, |
| 61 | pkcs9_emailAddress, | 67 | pkcs9_emailAddress, |
| | 68 | domainComponent, |
| 62 | | 69 | |
| 63 | pub const map = std.ComptimeStringMap(Attribute, .{ | 70 | pub const map = std.ComptimeStringMap(Attribute, .{ |
| 64 | .{ &[_]u8{ 0x55, 0x04, 0x03 }, .commonName }, | 71 | .{ &[_]u8{ 0x55, 0x04, 0x03 }, .commonName }, |
| ... | @@ -70,6 +77,7 @@ pub const Attribute = enum { | ... | @@ -70,6 +77,7 @@ pub const Attribute = enum { |
| 70 | .{ &[_]u8{ 0x55, 0x04, 0x0B }, .organizationalUnitName }, | 77 | .{ &[_]u8{ 0x55, 0x04, 0x0B }, .organizationalUnitName }, |
| 71 | .{ &[_]u8{ 0x55, 0x04, 0x61 }, .organizationIdentifier }, | 78 | .{ &[_]u8{ 0x55, 0x04, 0x61 }, .organizationIdentifier }, |
| 72 | .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01 }, .pkcs9_emailAddress }, | 79 | .{ &[_]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 }, |
| 73 | }); | 81 | }); |
| 74 | }; | 82 | }; |
| 75 | | 83 | |
| ... | @@ -93,17 +101,40 @@ pub const ExtensionId = enum { | ... | @@ -93,17 +101,40 @@ pub const ExtensionId = enum { |
| 93 | crl_number, | 101 | crl_number, |
| 94 | certificate_policies, | 102 | certificate_policies, |
| 95 | authority_key_identifier, | 103 | 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, |
| 96 | | 114 | |
| 97 | pub const map = std.ComptimeStringMap(ExtensionId, .{ | 115 | 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 }, |
| 98 | .{ &[_]u8{ 0x55, 0x1D, 0x0E }, .subject_key_identifier }, | 119 | .{ &[_]u8{ 0x55, 0x1D, 0x0E }, .subject_key_identifier }, |
| 99 | .{ &[_]u8{ 0x55, 0x1D, 0x0F }, .key_usage }, | 120 | .{ &[_]u8{ 0x55, 0x1D, 0x0F }, .key_usage }, |
| | 121 | .{ &[_]u8{ 0x55, 0x1D, 0x0A }, .basic_constraints }, |
| 100 | .{ &[_]u8{ 0x55, 0x1D, 0x10 }, .private_key_usage_period }, | 122 | .{ &[_]u8{ 0x55, 0x1D, 0x10 }, .private_key_usage_period }, |
| 101 | .{ &[_]u8{ 0x55, 0x1D, 0x11 }, .subject_alt_name }, | 123 | .{ &[_]u8{ 0x55, 0x1D, 0x11 }, .subject_alt_name }, |
| 102 | .{ &[_]u8{ 0x55, 0x1D, 0x12 }, .issuer_alt_name }, | 124 | .{ &[_]u8{ 0x55, 0x1D, 0x12 }, .issuer_alt_name }, |
| 103 | .{ &[_]u8{ 0x55, 0x1D, 0x13 }, .basic_constraints }, | 125 | .{ &[_]u8{ 0x55, 0x1D, 0x13 }, .basic_constraints }, |
| 104 | .{ &[_]u8{ 0x55, 0x1D, 0x14 }, .crl_number }, | 126 | .{ &[_]u8{ 0x55, 0x1D, 0x14 }, .crl_number }, |
| | 127 | .{ &[_]u8{ 0x55, 0x1D, 0x1F }, .crl_distribution_points }, |
| 105 | .{ &[_]u8{ 0x55, 0x1D, 0x20 }, .certificate_policies }, | 128 | .{ &[_]u8{ 0x55, 0x1D, 0x20 }, .certificate_policies }, |
| 106 | .{ &[_]u8{ 0x55, 0x1D, 0x23 }, .authority_key_identifier }, | 129 | .{ &[_]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 }, |
| 107 | }); | 138 | }); |
| 108 | }; | 139 | }; |
| 109 | | 140 | |
| ... | @@ -238,6 +269,10 @@ pub const Parsed = struct { | ... | @@ -238,6 +269,10 @@ pub const Parsed = struct { |
| 238 | parsed_issuer.pub_key_algo, | 269 | parsed_issuer.pub_key_algo, |
| 239 | parsed_issuer.pubKey(), | 270 | parsed_issuer.pubKey(), |
| 240 | ), | 271 | ), |
| | 272 | |
| | 273 | .md2WithRSAEncryption, .md5WithRSAEncryption => { |
| | 274 | return error.CertificateSignatureAlgorithmUnsupported; |
| | 275 | }, |
| 241 | } | 276 | } |
| 242 | } | 277 | } |
| 243 | | 278 | |