| 1 | package Crypt::OpenSSL::Cloner::x509asn1; | ||
| 2 | 1 | our $ASN_DEF = <<ASN; | |
| 3 | -- ASN.1 from RFC2459 and X.509(2001) | ||
| 4 | -- Adapted for use with Convert::ASN1 | ||
| 5 | -- Id: x509decode,v 1.1 2002/02/10 16:41:28 gbarr Exp | ||
| 6 | |||
| 7 | -- attribute data types -- | ||
| 8 | |||
| 9 | Attribute ::= SEQUENCE { | ||
| 10 | type AttributeType, | ||
| 11 | values SET OF AttributeValue | ||
| 12 | -- at least one value is required -- | ||
| 13 | } | ||
| 14 | |||
| 15 | AttributeType ::= OBJECT IDENTIFIER | ||
| 16 | |||
| 17 | AttributeValue ::= DirectoryString --ANY | ||
| 18 | |||
| 19 | AttributeTypeAndValue ::= SEQUENCE { | ||
| 20 | type AttributeType, | ||
| 21 | value AttributeValue | ||
| 22 | } | ||
| 23 | |||
| 24 | |||
| 25 | -- naming data types -- | ||
| 26 | |||
| 27 | Name ::= CHOICE { -- only one possibility for now | ||
| 28 | rdnSequence RDNSequence | ||
| 29 | } | ||
| 30 | |||
| 31 | RDNSequence ::= SEQUENCE OF RelativeDistinguishedName | ||
| 32 | |||
| 33 | DistinguishedName ::= RDNSequence | ||
| 34 | |||
| 35 | RelativeDistinguishedName ::= | ||
| 36 | SET OF AttributeTypeAndValue --SET SIZE (1 .. MAX) OF | ||
| 37 | |||
| 38 | |||
| 39 | -- Directory string type -- | ||
| 40 | |||
| 41 | DirectoryString ::= CHOICE { | ||
| 42 | teletexString TeletexString, --(SIZE (1..MAX)), | ||
| 43 | printableString PrintableString, --(SIZE (1..MAX)), | ||
| 44 | bmpString BMPString, --(SIZE (1..MAX)), | ||
| 45 | universalString UniversalString, --(SIZE (1..MAX)), | ||
| 46 | utf8String UTF8String, --(SIZE (1..MAX)), | ||
| 47 | ia5String IA5String, --added for EmailAddress, | ||
| 48 | integer INTEGER | ||
| 49 | } | ||
| 50 | |||
| 51 | |||
| 52 | -- certificate and CRL specific structures begin here | ||
| 53 | |||
| 54 | Certificate ::= SEQUENCE { | ||
| 55 | tbsCertificate TBSCertificate, | ||
| 56 | signatureAlgorithm AlgorithmIdentifier, | ||
| 57 | signature BIT STRING | ||
| 58 | } | ||
| 59 | |||
| 60 | TBSCertificate ::= SEQUENCE { | ||
| 61 | version [0] EXPLICIT Version OPTIONAL, --DEFAULT v1 | ||
| 62 | serialNumber CertificateSerialNumber, | ||
| 63 | signature AlgorithmIdentifier, | ||
| 64 | issuer Name, | ||
| 65 | validity Validity, | ||
| 66 | subject Name, | ||
| 67 | subjectPublicKeyInfo SubjectPublicKeyInfo, | ||
| 68 | issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, | ||
| 69 | -- If present, version shall be v2 or v3 | ||
| 70 | subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, | ||
| 71 | -- If present, version shall be v2 or v3 | ||
| 72 | extensions [3] EXPLICIT Extensions OPTIONAL | ||
| 73 | -- If present, version shall be v3 | ||
| 74 | } | ||
| 75 | |||
| 76 | Version ::= INTEGER --{ v1(0), v2(1), v3(2) } | ||
| 77 | |||
| 78 | CertificateSerialNumber ::= INTEGER | ||
| 79 | |||
| 80 | Validity ::= SEQUENCE { | ||
| 81 | notBefore Time, | ||
| 82 | notAfter Time | ||
| 83 | } | ||
| 84 | |||
| 85 | Time ::= CHOICE { | ||
| 86 | utcTime UTCTime, | ||
| 87 | generalTime GeneralizedTime | ||
| 88 | } | ||
| 89 | |||
| 90 | UniqueIdentifier ::= BIT STRING | ||
| 91 | |||
| 92 | SubjectPublicKeyInfo ::= SEQUENCE { | ||
| 93 | algorithm AlgorithmIdentifier, | ||
| 94 | subjectPublicKey BIT STRING | ||
| 95 | } | ||
| 96 | |||
| 97 | |||
| 98 | RSAPubKeyInfo ::= SEQUENCE { | ||
| 99 | modulus INTEGER, | ||
| 100 | exponent INTEGER | ||
| 101 | } | ||
| 102 | |||
| 103 | Extensions ::= SEQUENCE OF Extension --SIZE (1..MAX) OF Extension | ||
| 104 | |||
| 105 | Extension ::= SEQUENCE { | ||
| 106 | extnID OBJECT IDENTIFIER, | ||
| 107 | critical BOOLEAN OPTIONAL, --DEFAULT FALSE, | ||
| 108 | extnValue OCTET STRING | ||
| 109 | } | ||
| 110 | |||
| 111 | AlgorithmIdentifier ::= SEQUENCE { | ||
| 112 | algorithm OBJECT IDENTIFIER, | ||
| 113 | parameters ANY OPTIONAL | ||
| 114 | } | ||
| 115 | |||
| 116 | |||
| 117 | --extensions | ||
| 118 | |||
| 119 | AuthorityKeyIdentifier ::= SEQUENCE { | ||
| 120 | keyIdentifier [0] KeyIdentifier OPTIONAL, | ||
| 121 | authorityCertIssuer [1] GeneralNames OPTIONAL, | ||
| 122 | authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL } | ||
| 123 | -- authorityCertIssuer and authorityCertSerialNumber shall both | ||
| 124 | -- be present or both be absent | ||
| 125 | |||
| 126 | KeyIdentifier ::= OCTET STRING | ||
| 127 | |||
| 128 | SubjectKeyIdentifier ::= KeyIdentifier | ||
| 129 | |||
| 130 | -- key usage extension OID and syntax | ||
| 131 | |||
| 132 | -- id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } | ||
| 133 | |||
| 134 | KeyUsage ::= BIT STRING --{ | ||
| 135 | -- digitalSignature (0), | ||
| 136 | -- nonRepudiation (1), | ||
| 137 | -- keyEncipherment (2), | ||
| 138 | -- dataEncipherment (3), | ||
| 139 | -- keyAgreement (4), | ||
| 140 | -- keyCertSign (5), | ||
| 141 | -- cRLSign (6), | ||
| 142 | -- encipherOnly (7), | ||
| 143 | -- decipherOnly (8) } | ||
| 144 | |||
| 145 | |||
| 146 | -- private key usage period extension OID and syntax | ||
| 147 | |||
| 148 | -- id-ce-privateKeyUsagePeriod OBJECT IDENTIFIER ::= { id-ce 16 } | ||
| 149 | |||
| 150 | PrivateKeyUsagePeriod ::= SEQUENCE { | ||
| 151 | notBefore [0] GeneralizedTime OPTIONAL, | ||
| 152 | notAfter [1] GeneralizedTime OPTIONAL } | ||
| 153 | -- either notBefore or notAfter shall be present | ||
| 154 | |||
| 155 | -- certificate policies extension OID and syntax | ||
| 156 | -- id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 } | ||
| 157 | |||
| 158 | CertificatePolicies ::= SEQUENCE OF PolicyInformation | ||
| 159 | |||
| 160 | PolicyInformation ::= SEQUENCE { | ||
| 161 | policyIdentifier CertPolicyId, | ||
| 162 | policyQualifiers SEQUENCE OF | ||
| 163 | PolicyQualifierInfo OPTIONAL } | ||
| 164 | |||
| 165 | CertPolicyId ::= OBJECT IDENTIFIER | ||
| 166 | |||
| 167 | PolicyQualifierInfo ::= SEQUENCE { | ||
| 168 | policyQualifierId PolicyQualifierId, | ||
| 169 | qualifier ANY } --DEFINED BY policyQualifierId } | ||
| 170 | |||
| 171 | -- Implementations that recognize additional policy qualifiers shall | ||
| 172 | -- augment the following definition for PolicyQualifierId | ||
| 173 | |||
| 174 | PolicyQualifierId ::= | ||
| 175 | OBJECT IDENTIFIER --( id-qt-cps | id-qt-unotice ) | ||
| 176 | |||
| 177 | -- CPS pointer qualifier | ||
| 178 | |||
| 179 | CPSuri ::= IA5String | ||
| 180 | |||
| 181 | -- user notice qualifier | ||
| 182 | |||
| 183 | UserNotice ::= SEQUENCE { | ||
| 184 | noticeRef NoticeReference OPTIONAL, | ||
| 185 | explicitText DisplayText OPTIONAL} | ||
| 186 | |||
| 187 | NoticeReference ::= SEQUENCE { | ||
| 188 | organization DisplayText, | ||
| 189 | noticeNumbers SEQUENCE OF INTEGER } | ||
| 190 | |||
| 191 | DisplayText ::= CHOICE { | ||
| 192 | visibleString VisibleString , | ||
| 193 | bmpString BMPString , | ||
| 194 | utf8String UTF8String } | ||
| 195 | |||
| 196 | |||
| 197 | -- policy mapping extension OID and syntax | ||
| 198 | -- id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 } | ||
| 199 | |||
| 200 | PolicyMappings ::= SEQUENCE OF SEQUENCE { | ||
| 201 | issuerDomainPolicy CertPolicyId, | ||
| 202 | subjectDomainPolicy CertPolicyId } | ||
| 203 | |||
| 204 | |||
| 205 | -- subject alternative name extension OID and syntax | ||
| 206 | -- id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } | ||
| 207 | |||
| 208 | SubjectAltName ::= GeneralNames | ||
| 209 | |||
| 210 | GeneralNames ::= SEQUENCE OF GeneralName | ||
| 211 | |||
| 212 | GeneralName ::= CHOICE { | ||
| 213 | otherName [0] AnotherName, | ||
| 214 | rfc822Name [1] IA5String, | ||
| 215 | dNSName [2] IA5String, | ||
| 216 | x400Address [3] ANY, --ORAddress, | ||
| 217 | directoryName [4] Name, | ||
| 218 | ediPartyName [5] EDIPartyName, | ||
| 219 | uniformResourceIdentifier [6] IA5String, | ||
| 220 | iPAddress [7] OCTET STRING, | ||
| 221 | registeredID [8] OBJECT IDENTIFIER } | ||
| 222 | |||
| 223 | EntrustVersionInfo ::= SEQUENCE { | ||
| 224 | entrustVers GeneralString, | ||
| 225 | entrustInfoFlags EntrustInfoFlags } | ||
| 226 | |||
| 227 | EntrustInfoFlags::= BIT STRING --{ | ||
| 228 | -- keyUpdateAllowed | ||
| 229 | -- newExtensions (1), -- not used | ||
| 230 | -- pKIXCertificate (2) } -- certificate created by pkix | ||
| 231 | |||
| 232 | -- AnotherName replaces OTHER-NAME ::= TYPE-IDENTIFIER, as | ||
| 233 | -- TYPE-IDENTIFIER is not supported in the 88 ASN.1 syntax | ||
| 234 | |||
| 235 | AnotherName ::= SEQUENCE { | ||
| 236 | type OBJECT IDENTIFIER, | ||
| 237 | value [0] EXPLICIT ANY } --DEFINED BY type-id } | ||
| 238 | |||
| 239 | EDIPartyName ::= SEQUENCE { | ||
| 240 | nameAssigner [0] DirectoryString OPTIONAL, | ||
| 241 | partyName [1] DirectoryString } | ||
| 242 | |||
| 243 | |||
| 244 | -- issuer alternative name extension OID and syntax | ||
| 245 | -- id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 } | ||
| 246 | |||
| 247 | IssuerAltName ::= GeneralNames | ||
| 248 | |||
| 249 | |||
| 250 | -- id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 } | ||
| 251 | |||
| 252 | SubjectDirectoryAttributes ::= SEQUENCE OF Attribute | ||
| 253 | |||
| 254 | |||
| 255 | -- basic constraints extension OID and syntax | ||
| 256 | -- id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } | ||
| 257 | |||
| 258 | BasicConstraints ::= SEQUENCE { | ||
| 259 | cA BOOLEAN OPTIONAL, --DEFAULT FALSE, | ||
| 260 | pathLenConstraint INTEGER OPTIONAL } | ||
| 261 | |||
| 262 | |||
| 263 | -- name constraints extension OID and syntax | ||
| 264 | -- id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 } | ||
| 265 | |||
| 266 | NameConstraints ::= SEQUENCE { | ||
| 267 | permittedSubtrees [0] GeneralSubtrees OPTIONAL, | ||
| 268 | excludedSubtrees [1] GeneralSubtrees OPTIONAL } | ||
| 269 | |||
| 270 | GeneralSubtrees ::= SEQUENCE OF GeneralSubtree | ||
| 271 | |||
| 272 | GeneralSubtree ::= SEQUENCE { | ||
| 273 | base GeneralName, | ||
| 274 | minimum [0] BaseDistance OPTIONAL, --DEFAULT 0, | ||
| 275 | maximum [1] BaseDistance OPTIONAL } | ||
| 276 | |||
| 277 | BaseDistance ::= INTEGER | ||
| 278 | |||
| 279 | |||
| 280 | -- policy constraints extension OID and syntax | ||
| 281 | -- id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 } | ||
| 282 | |||
| 283 | PolicyConstraints ::= SEQUENCE { | ||
| 284 | requireExplicitPolicy [0] SkipCerts OPTIONAL, | ||
| 285 | inhibitPolicyMapping [1] SkipCerts OPTIONAL } | ||
| 286 | |||
| 287 | SkipCerts ::= INTEGER | ||
| 288 | |||
| 289 | |||
| 290 | -- CRL distribution points extension OID and syntax | ||
| 291 | -- id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= {id-ce 31} | ||
| 292 | |||
| 293 | cRLDistributionPoints ::= SEQUENCE OF DistributionPoint | ||
| 294 | |||
| 295 | DistributionPoint ::= SEQUENCE { | ||
| 296 | distributionPoint [0] DistributionPointName OPTIONAL, | ||
| 297 | reasons [1] ReasonFlags OPTIONAL, | ||
| 298 | cRLIssuer [2] GeneralNames OPTIONAL } | ||
| 299 | |||
| 300 | DistributionPointName ::= CHOICE { | ||
| 301 | fullName [0] GeneralNames, | ||
| 302 | nameRelativeToCRLIssuer [1] RelativeDistinguishedName } | ||
| 303 | |||
| 304 | ReasonFlags ::= BIT STRING --{ | ||
| 305 | -- unused (0), | ||
| 306 | -- keyCompromise (1), | ||
| 307 | -- cACompromise (2), | ||
| 308 | -- affiliationChanged (3), | ||
| 309 | -- superseded (4), | ||
| 310 | -- cessationOfOperation (5), | ||
| 311 | -- certificateHold (6), | ||
| 312 | -- privilegeWithdrawn (7), | ||
| 313 | -- aACompromise (8) } | ||
| 314 | |||
| 315 | |||
| 316 | -- extended key usage extension OID and syntax | ||
| 317 | -- id-ce-extKeyUsage OBJECT IDENTIFIER ::= {id-ce 37} | ||
| 318 | |||
| 319 | ExtKeyUsageSyntax ::= SEQUENCE OF KeyPurposeId | ||
| 320 | |||
| 321 | KeyPurposeId ::= OBJECT IDENTIFIER | ||
| 322 | |||
| 323 | -- extended key purpose OIDs | ||
| 324 | -- id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } | ||
| 325 | -- id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } | ||
| 326 | -- id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 } | ||
| 327 | -- id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 } | ||
| 328 | -- id-kp-ipsecEndSystem OBJECT IDENTIFIER ::= { id-kp 5 } | ||
| 329 | -- id-kp-ipsecTunnel OBJECT IDENTIFIER ::= { id-kp 6 } | ||
| 330 | -- id-kp-ipsecUser OBJECT IDENTIFIER ::= { id-kp 7 } | ||
| 331 | -- id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 } | ||
| 332 | |||
| 333 | -- authority info access | ||
| 334 | |||
| 335 | -- id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 } | ||
| 336 | |||
| 337 | AuthorityInfoAccessSyntax ::= | ||
| 338 | SEQUENCE OF AccessDescription --SIZE (1..MAX) OF AccessDescription | ||
| 339 | |||
| 340 | AccessDescription ::= SEQUENCE { | ||
| 341 | accessMethod OBJECT IDENTIFIER, | ||
| 342 | accessLocation GeneralName } | ||
| 343 | |||
| 344 | -- subject info access | ||
| 345 | |||
| 346 | -- id-pe-subjectInfoAccess OBJECT IDENTIFIER ::= { id-pe 11 } | ||
| 347 | |||
| 348 | SubjectInfoAccessSyntax ::= | ||
| 349 | SEQUENCE OF AccessDescription --SIZE (1..MAX) OF AccessDescription | ||
| 350 | |||
| 351 | -- pgp creation time | ||
| 352 | |||
| 353 | PGPExtension ::= SEQUENCE { | ||
| 354 | version Version, -- DEFAULT v1(0) | ||
| 355 | keyCreation Time | ||
| 356 | } | ||
| 357 | ASN | ||
| 358 | 1 | 1; |