| OLD | NEW |
| (Empty) |
| 1 # | |
| 2 # Certificate Management Protocol structures as per RFC4210 | |
| 3 # | |
| 4 # Based on Alex Railean's work | |
| 5 # | |
| 6 from pyasn1.type import tag,namedtype,namedval,univ,constraint,char,useful | |
| 7 from pyasn1_modules import rfc2459, rfc2511, rfc2314 | |
| 8 | |
| 9 MAX = 64 | |
| 10 | |
| 11 class KeyIdentifier(univ.OctetString): pass | |
| 12 | |
| 13 class CMPCertificate(rfc2459.Certificate): pass | |
| 14 | |
| 15 class OOBCert(CMPCertificate): pass | |
| 16 | |
| 17 class CertAnnContent(CMPCertificate): pass | |
| 18 | |
| 19 class PKIFreeText(univ.SequenceOf): | |
| 20 """ | |
| 21 PKIFreeText ::= SEQUENCE SIZE (1..MAX) OF UTF8String | |
| 22 """ | |
| 23 componentType = char.UTF8String() | |
| 24 subtypeSpec = univ.SequenceOf.subtypeSpec + constraint.ValueSizeConstraint(1
, MAX) | |
| 25 | |
| 26 class PollRepContent(univ.SequenceOf): | |
| 27 """ | |
| 28 PollRepContent ::= SEQUENCE OF SEQUENCE { | |
| 29 certReqId INTEGER, | |
| 30 checkAfter INTEGER, -- time in seconds | |
| 31 reason PKIFreeText OPTIONAL | |
| 32 } | |
| 33 """ | |
| 34 class CertReq(univ.Sequence): | |
| 35 componentType = namedtype.NamedTypes( | |
| 36 namedtype.NamedType('certReqId', univ.Integer()), | |
| 37 namedtype.NamedType('checkAfter', univ.Integer()), | |
| 38 namedtype.OptionalNamedType('reason', PKIFreeText()) | |
| 39 ) | |
| 40 componentType = CertReq() | |
| 41 | |
| 42 class PollReqContent(univ.SequenceOf): | |
| 43 """ | |
| 44 PollReqContent ::= SEQUENCE OF SEQUENCE { | |
| 45 certReqId INTEGER | |
| 46 } | |
| 47 | |
| 48 """ | |
| 49 class CertReq(univ.Sequence): | |
| 50 componentType = namedtype.NamedTypes( | |
| 51 namedtype.NamedType('certReqId', univ.Integer()) | |
| 52 ) | |
| 53 componentType = CertReq() | |
| 54 | |
| 55 class InfoTypeAndValue(univ.Sequence): | |
| 56 """ | |
| 57 InfoTypeAndValue ::= SEQUENCE { | |
| 58 infoType OBJECT IDENTIFIER, | |
| 59 infoValue ANY DEFINED BY infoType OPTIONAL | |
| 60 }""" | |
| 61 componentType = namedtype.NamedTypes( | |
| 62 namedtype.NamedType('infoType', univ.ObjectIdentifier()), | |
| 63 namedtype.OptionalNamedType('infoValue', univ.Any()) | |
| 64 ) | |
| 65 | |
| 66 class GenRepContent(univ.SequenceOf): | |
| 67 componentType = InfoTypeAndValue() | |
| 68 | |
| 69 class GenMsgContent(univ.SequenceOf): | |
| 70 componentType = InfoTypeAndValue() | |
| 71 | |
| 72 class PKIConfirmContent(univ.Null): pass | |
| 73 | |
| 74 class CRLAnnContent(univ.SequenceOf): | |
| 75 componentType = rfc2459.CertificateList() | |
| 76 | |
| 77 class CAKeyUpdAnnContent(univ.Sequence): | |
| 78 """ | |
| 79 CAKeyUpdAnnContent ::= SEQUENCE { | |
| 80 oldWithNew CMPCertificate, | |
| 81 newWithOld CMPCertificate, | |
| 82 newWithNew CMPCertificate | |
| 83 } | |
| 84 """ | |
| 85 componentType = namedtype.NamedTypes( | |
| 86 namedtype.NamedType('oldWithNew', CMPCertificate()), | |
| 87 namedtype.NamedType('newWithOld', CMPCertificate()), | |
| 88 namedtype.NamedType('newWithNew', CMPCertificate()) | |
| 89 ) | |
| 90 | |
| 91 class RevDetails(univ.Sequence): | |
| 92 """ | |
| 93 RevDetails ::= SEQUENCE { | |
| 94 certDetails CertTemplate, | |
| 95 crlEntryDetails Extensions OPTIONAL | |
| 96 } | |
| 97 """ | |
| 98 componentType = namedtype.NamedTypes( | |
| 99 namedtype.NamedType('certDetails', rfc2511.CertTemplate()), | |
| 100 namedtype.OptionalNamedType('crlEntryDetails', rfc2459.Extensions()) | |
| 101 ) | |
| 102 | |
| 103 class RevReqContent(univ.SequenceOf): | |
| 104 componentType = RevDetails() | |
| 105 | |
| 106 class CertOrEncCert(univ.Choice): | |
| 107 """ | |
| 108 CertOrEncCert ::= CHOICE { | |
| 109 certificate [0] CMPCertificate, | |
| 110 encryptedCert [1] EncryptedValue | |
| 111 } | |
| 112 """ | |
| 113 componentType = namedtype.NamedTypes( | |
| 114 namedtype.NamedType('certificate', CMPCertificate().subtype( | |
| 115 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0
) | |
| 116 ) | |
| 117 ), | |
| 118 namedtype.NamedType('encryptedCert', rfc2511.EncryptedValue().subtype( | |
| 119 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1
) | |
| 120 ) | |
| 121 ) | |
| 122 ) | |
| 123 | |
| 124 class CertifiedKeyPair(univ.Sequence): | |
| 125 """ | |
| 126 CertifiedKeyPair ::= SEQUENCE { | |
| 127 certOrEncCert CertOrEncCert, | |
| 128 privateKey [0] EncryptedValue OPTIONAL, | |
| 129 publicationInfo [1] PKIPublicationInfo OPTIONAL | |
| 130 } | |
| 131 """ | |
| 132 componentType = namedtype.NamedTypes( | |
| 133 namedtype.NamedType('certOrEncCert', CertOrEncCert()), | |
| 134 namedtype.OptionalNamedType('privateKey', rfc2511.EncryptedValue().subty
pe( | |
| 135 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructe
d, 0) | |
| 136 ) | |
| 137 ), | |
| 138 namedtype.OptionalNamedType('publicationInfo', rfc2511.PKIPublicationInf
o().subtype( | |
| 139 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructe
d, 1) | |
| 140 ) | |
| 141 ) | |
| 142 ) | |
| 143 | |
| 144 | |
| 145 class POPODecKeyRespContent(univ.SequenceOf): | |
| 146 componentType = univ.Integer() | |
| 147 | |
| 148 class Challenge(univ.Sequence): | |
| 149 """ | |
| 150 Challenge ::= SEQUENCE { | |
| 151 owf AlgorithmIdentifier OPTIONAL, | |
| 152 witness OCTET STRING, | |
| 153 challenge OCTET STRING | |
| 154 } | |
| 155 """ | |
| 156 componentType = namedtype.NamedTypes( | |
| 157 namedtype.OptionalNamedType('owf', rfc2459.AlgorithmIdentifier()), | |
| 158 namedtype.NamedType('witness', univ.OctetString()), | |
| 159 namedtype.NamedType('challenge', univ.OctetString()) | |
| 160 ) | |
| 161 | |
| 162 class PKIStatus(univ.Integer): | |
| 163 """ | |
| 164 PKIStatus ::= INTEGER { | |
| 165 accepted (0), | |
| 166 grantedWithMods (1), | |
| 167 rejection (2), | |
| 168 waiting (3), | |
| 169 revocationWarning (4), | |
| 170 revocationNotification (5), | |
| 171 keyUpdateWarning (6) | |
| 172 } | |
| 173 """ | |
| 174 namedValues = namedval.NamedValues( | |
| 175 ('accepted', 0), | |
| 176 ('grantedWithMods', 1), | |
| 177 ('rejection', 2), | |
| 178 ('waiting', 3), | |
| 179 ('revocationWarning', 4), | |
| 180 ('revocationNotification', 5), | |
| 181 ('keyUpdateWarning', 6) | |
| 182 ) | |
| 183 | |
| 184 class PKIFailureInfo(univ.BitString): | |
| 185 """ | |
| 186 PKIFailureInfo ::= BIT STRING { | |
| 187 badAlg (0), | |
| 188 badMessageCheck (1), | |
| 189 badRequest (2), | |
| 190 badTime (3), | |
| 191 badCertId (4), | |
| 192 badDataFormat (5), | |
| 193 wrongAuthority (6), | |
| 194 incorrectData (7), | |
| 195 missingTimeStamp (8), | |
| 196 badPOP (9), | |
| 197 certRevoked (10), | |
| 198 certConfirmed (11), | |
| 199 wrongIntegrity (12), | |
| 200 badRecipientNonce (13), | |
| 201 timeNotAvailable (14), | |
| 202 unacceptedPolicy (15), | |
| 203 unacceptedExtension (16), | |
| 204 addInfoNotAvailable (17), | |
| 205 badSenderNonce (18), | |
| 206 badCertTemplate (19), | |
| 207 signerNotTrusted (20), | |
| 208 transactionIdInUse (21), | |
| 209 unsupportedVersion (22), | |
| 210 notAuthorized (23), | |
| 211 systemUnavail (24), | |
| 212 systemFailure (25), | |
| 213 duplicateCertReq (26) | |
| 214 """ | |
| 215 namedValues = namedval.NamedValues( | |
| 216 ('badAlg', 0), | |
| 217 ('badMessageCheck', 1), | |
| 218 ('badRequest', 2), | |
| 219 ('badTime', 3), | |
| 220 ('badCertId', 4), | |
| 221 ('badDataFormat', 5), | |
| 222 ('wrongAuthority', 6), | |
| 223 ('incorrectData', 7), | |
| 224 ('missingTimeStamp', 8), | |
| 225 ('badPOP', 9), | |
| 226 ('certRevoked', 10), | |
| 227 ('certConfirmed', 11), | |
| 228 ('wrongIntegrity', 12), | |
| 229 ('badRecipientNonce', 13), | |
| 230 ('timeNotAvailable', 14), | |
| 231 ('unacceptedPolicy', 15), | |
| 232 ('unacceptedExtension', 16), | |
| 233 ('addInfoNotAvailable', 17), | |
| 234 ('badSenderNonce', 18), | |
| 235 ('badCertTemplate', 19), | |
| 236 ('signerNotTrusted', 20), | |
| 237 ('transactionIdInUse', 21), | |
| 238 ('unsupportedVersion', 22), | |
| 239 ('notAuthorized', 23), | |
| 240 ('systemUnavail', 24), | |
| 241 ('systemFailure', 25), | |
| 242 ('duplicateCertReq', 26) | |
| 243 ) | |
| 244 | |
| 245 class PKIStatusInfo(univ.Sequence): | |
| 246 """ | |
| 247 PKIStatusInfo ::= SEQUENCE { | |
| 248 status PKIStatus, | |
| 249 statusString PKIFreeText OPTIONAL, | |
| 250 failInfo PKIFailureInfo OPTIONAL | |
| 251 } | |
| 252 """ | |
| 253 componentType = namedtype.NamedTypes( | |
| 254 namedtype.NamedType('status', PKIStatus()), | |
| 255 namedtype.OptionalNamedType('statusString', PKIFreeText()), | |
| 256 namedtype.OptionalNamedType('failInfo', PKIFailureInfo()) | |
| 257 ) | |
| 258 | |
| 259 class ErrorMsgContent(univ.Sequence): | |
| 260 """ | |
| 261 ErrorMsgContent ::= SEQUENCE { | |
| 262 pKIStatusInfo PKIStatusInfo, | |
| 263 errorCode INTEGER OPTIONAL, | |
| 264 -- implementation-specific error codes | |
| 265 errorDetails PKIFreeText OPTIONAL | |
| 266 -- implementation-specific error details | |
| 267 } | |
| 268 """ | |
| 269 componentType = namedtype.NamedTypes( | |
| 270 namedtype.NamedType('pKIStatusInfo', PKIStatusInfo()), | |
| 271 namedtype.OptionalNamedType('errorCode', univ.Integer()), | |
| 272 namedtype.OptionalNamedType('errorDetails', PKIFreeText()) | |
| 273 ) | |
| 274 | |
| 275 class CertStatus(univ.Sequence): | |
| 276 """ | |
| 277 CertStatus ::= SEQUENCE { | |
| 278 certHash OCTET STRING, | |
| 279 certReqId INTEGER, | |
| 280 statusInfo PKIStatusInfo OPTIONAL | |
| 281 } | |
| 282 """ | |
| 283 componentType = namedtype.NamedTypes( | |
| 284 namedtype.NamedType('certHash', univ.OctetString()), | |
| 285 namedtype.NamedType('certReqId', univ.Integer()), | |
| 286 namedtype.OptionalNamedType('statusInfo', PKIStatusInfo()) | |
| 287 ) | |
| 288 | |
| 289 class CertConfirmContent(univ.SequenceOf): | |
| 290 componentType = CertStatus() | |
| 291 | |
| 292 class RevAnnContent(univ.Sequence): | |
| 293 """ | |
| 294 RevAnnContent ::= SEQUENCE { | |
| 295 status PKIStatus, | |
| 296 certId CertId, | |
| 297 willBeRevokedAt GeneralizedTime, | |
| 298 badSinceDate GeneralizedTime, | |
| 299 crlDetails Extensions OPTIONAL | |
| 300 } | |
| 301 """ | |
| 302 componentType = namedtype.NamedTypes( | |
| 303 namedtype.NamedType('status', PKIStatus()), | |
| 304 namedtype.NamedType('certId', rfc2511.CertId()), | |
| 305 namedtype.NamedType('willBeRevokedAt', useful.GeneralizedTime()), | |
| 306 namedtype.NamedType('badSinceDate', useful.GeneralizedTime()), | |
| 307 namedtype.OptionalNamedType('crlDetails', rfc2459.Extensions()) | |
| 308 ) | |
| 309 | |
| 310 class RevRepContent(univ.Sequence): | |
| 311 """ | |
| 312 RevRepContent ::= SEQUENCE { | |
| 313 status SEQUENCE SIZE (1..MAX) OF PKIStatusInfo, | |
| 314 revCerts [0] SEQUENCE SIZE (1..MAX) OF CertId | |
| 315 OPTIONAL, | |
| 316 crls [1] SEQUENCE SIZE (1..MAX) OF CertificateList | |
| 317 OPTIONAL | |
| 318 """ | |
| 319 componentType = namedtype.NamedTypes( | |
| 320 namedtype.NamedType('status', PKIStatusInfo()), | |
| 321 namedtype.OptionalNamedType('revCerts', univ.SequenceOf( | |
| 322 componentType=rfc2511.CertId() | |
| 323 ).subtype( | |
| 324 subtypeSpec=constraint.ValueSizeConstraint(1, MAX), | |
| 325 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructe
d, 0) | |
| 326 ) | |
| 327 ), | |
| 328 namedtype.OptionalNamedType('crls', univ.SequenceOf( | |
| 329 componentType=rfc2459.CertificateList() | |
| 330 ).subtype( | |
| 331 subtypeSpec=constraint.ValueSizeConstraint(1, MAX), | |
| 332 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructe
d, 1) | |
| 333 ) | |
| 334 ) | |
| 335 ) | |
| 336 | |
| 337 class KeyRecRepContent(univ.Sequence): | |
| 338 """ | |
| 339 KeyRecRepContent ::= SEQUENCE { | |
| 340 status PKIStatusInfo, | |
| 341 newSigCert [0] CMPCertificate OPTIONAL, | |
| 342 caCerts [1] SEQUENCE SIZE (1..MAX) OF | |
| 343 CMPCertificate OPTIONAL, | |
| 344 keyPairHist [2] SEQUENCE SIZE (1..MAX) OF | |
| 345 CertifiedKeyPair OPTIONAL | |
| 346 } | |
| 347 """ | |
| 348 componentType = namedtype.NamedTypes( | |
| 349 namedtype.NamedType('status', PKIStatusInfo()), | |
| 350 namedtype.OptionalNamedType('newSigCert', CMPCertificate().subtype( | |
| 351 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0
) | |
| 352 ) | |
| 353 ), | |
| 354 namedtype.OptionalNamedType('caCerts', univ.SequenceOf( | |
| 355 componentType=CMPCertificate() | |
| 356 ).subtype( | |
| 357 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructe
d, 1), | |
| 358 subtypeSpec=constraint.ValueSizeConstraint(1, MAX) | |
| 359 ) | |
| 360 ), | |
| 361 namedtype.OptionalNamedType('keyPairHist', univ.SequenceOf( | |
| 362 componentType=CertifiedKeyPair() | |
| 363 ).subtype( | |
| 364 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructe
d, 2), | |
| 365 subtypeSpec=constraint.ValueSizeConstraint(1, MAX) | |
| 366 ) | |
| 367 ) | |
| 368 ) | |
| 369 | |
| 370 class CertResponse(univ.Sequence): | |
| 371 """ | |
| 372 CertResponse ::= SEQUENCE { | |
| 373 certReqId INTEGER, | |
| 374 status PKIStatusInfo, | |
| 375 certifiedKeyPair CertifiedKeyPair OPTIONAL, | |
| 376 rspInfo OCTET STRING OPTIONAL | |
| 377 } | |
| 378 """ | |
| 379 componentType = namedtype.NamedTypes( | |
| 380 namedtype.NamedType('certReqId', univ.Integer()), | |
| 381 namedtype.NamedType('status', PKIStatusInfo()), | |
| 382 namedtype.OptionalNamedType('certifiedKeyPair', CertifiedKeyPair()), | |
| 383 namedtype.OptionalNamedType('rspInfo', univ.OctetString()) | |
| 384 ) | |
| 385 | |
| 386 class CertRepMessage(univ.Sequence): | |
| 387 """ | |
| 388 CertRepMessage ::= SEQUENCE { | |
| 389 caPubs [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate | |
| 390 OPTIONAL, | |
| 391 response SEQUENCE OF CertResponse | |
| 392 } | |
| 393 """ | |
| 394 componentType = namedtype.NamedTypes( | |
| 395 namedtype.OptionalNamedType('caPubs', univ.SequenceOf( | |
| 396 componentType=CMPCertificate() | |
| 397 ).subtype( | |
| 398 subtypeSpec=constraint.ValueSizeConstraint(1, MAX), | |
| 399 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed
,1) | |
| 400 ) | |
| 401 ), | |
| 402 namedtype.NamedType('response', univ.SequenceOf( | |
| 403 componentType=CertResponse()) | |
| 404 ) | |
| 405 ) | |
| 406 | |
| 407 class POPODecKeyChallContent(univ.SequenceOf): | |
| 408 componentType = Challenge() | |
| 409 | |
| 410 class OOBCertHash(univ.Sequence): | |
| 411 """ | |
| 412 OOBCertHash ::= SEQUENCE { | |
| 413 hashAlg [0] AlgorithmIdentifier OPTIONAL, | |
| 414 certId [1] CertId OPTIONAL, | |
| 415 hashVal BIT STRING | |
| 416 } | |
| 417 """ | |
| 418 componentType = namedtype.NamedTypes( | |
| 419 namedtype.OptionalNamedType('hashAlg', | |
| 420 rfc2459.AlgorithmIdentifier().subtype( | |
| 421 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,0) | |
| 422 ) | |
| 423 ), | |
| 424 namedtype.OptionalNamedType('certId', rfc2511.CertId().subtype( | |
| 425 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,1) | |
| 426 ) | |
| 427 ), | |
| 428 namedtype.NamedType('hashVal', univ.BitString()) | |
| 429 ) | |
| 430 | |
| 431 # pyasn1 does not naturally handle recursive definitions, thus this hack: | |
| 432 # NestedMessageContent ::= PKIMessages | |
| 433 class NestedMessageContent(univ.SequenceOf): | |
| 434 """ | |
| 435 NestedMessageContent ::= PKIMessages | |
| 436 """ | |
| 437 componentType = univ.Any() | |
| 438 | |
| 439 class DHBMParameter(univ.Sequence): | |
| 440 """ | |
| 441 DHBMParameter ::= SEQUENCE { | |
| 442 owf AlgorithmIdentifier, | |
| 443 -- AlgId for a One-Way Function (SHA-1 recommended) | |
| 444 mac AlgorithmIdentifier | |
| 445 -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11], | |
| 446 } -- or HMAC [RFC2104, RFC2202]) | |
| 447 """ | |
| 448 componentType = namedtype.NamedTypes( | |
| 449 namedtype.NamedType('owf', rfc2459.AlgorithmIdentifier()), | |
| 450 namedtype.NamedType('mac', rfc2459.AlgorithmIdentifier()) | |
| 451 ) | |
| 452 | |
| 453 id_DHBasedMac = univ.ObjectIdentifier('1.2.840.113533.7.66.30') | |
| 454 | |
| 455 class PBMParameter(univ.Sequence): | |
| 456 """ | |
| 457 PBMParameter ::= SEQUENCE { | |
| 458 salt OCTET STRING, | |
| 459 owf AlgorithmIdentifier, | |
| 460 iterationCount INTEGER, | |
| 461 mac AlgorithmIdentifier | |
| 462 } | |
| 463 """ | |
| 464 componentType = namedtype.NamedTypes( | |
| 465 namedtype.NamedType('salt', univ.OctetString().subtype( | |
| 466 subtypeSpec=constraint.ValueSizeConstraint(0, 128) | |
| 467 ) | |
| 468 ), | |
| 469 namedtype.NamedType('owf', rfc2459.AlgorithmIdentifier()), | |
| 470 namedtype.NamedType('iterationCount', univ.Integer()), | |
| 471 namedtype.NamedType('mac', rfc2459.AlgorithmIdentifier()) | |
| 472 ) | |
| 473 | |
| 474 id_PasswordBasedMac = univ.ObjectIdentifier('1.2.840.113533.7.66.13') | |
| 475 | |
| 476 class PKIProtection(univ.BitString): pass | |
| 477 | |
| 478 # pyasn1 does not naturally handle recursive definitions, thus this hack: | |
| 479 # NestedMessageContent ::= PKIMessages | |
| 480 nestedMessageContent = NestedMessageContent().subtype(explicitTag=tag.Tag(tag.ta
gClassContext,tag.tagFormatConstructed,20)) | |
| 481 | |
| 482 class PKIBody(univ.Choice): | |
| 483 """ | |
| 484 PKIBody ::= CHOICE { -- message-specific body elements | |
| 485 ir [0] CertReqMessages, --Initialization Request | |
| 486 ip [1] CertRepMessage, --Initialization Response | |
| 487 cr [2] CertReqMessages, --Certification Request | |
| 488 cp [3] CertRepMessage, --Certification Response | |
| 489 p10cr [4] CertificationRequest, --imported from [PKCS10] | |
| 490 popdecc [5] POPODecKeyChallContent, --pop Challenge | |
| 491 popdecr [6] POPODecKeyRespContent, --pop Response | |
| 492 kur [7] CertReqMessages, --Key Update Request | |
| 493 kup [8] CertRepMessage, --Key Update Response | |
| 494 krr [9] CertReqMessages, --Key Recovery Request | |
| 495 krp [10] KeyRecRepContent, --Key Recovery Response | |
| 496 rr [11] RevReqContent, --Revocation Request | |
| 497 rp [12] RevRepContent, --Revocation Response | |
| 498 ccr [13] CertReqMessages, --Cross-Cert. Request | |
| 499 ccp [14] CertRepMessage, --Cross-Cert. Response | |
| 500 ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann. | |
| 501 cann [16] CertAnnContent, --Certificate Ann. | |
| 502 rann [17] RevAnnContent, --Revocation Ann. | |
| 503 crlann [18] CRLAnnContent, --CRL Announcement | |
| 504 pkiconf [19] PKIConfirmContent, --Confirmation | |
| 505 nested [20] NestedMessageContent, --Nested Message | |
| 506 genm [21] GenMsgContent, --General Message | |
| 507 | |
| 508 """ | |
| 509 componentType = namedtype.NamedTypes( | |
| 510 namedtype.NamedType('ir', rfc2511.CertReqMessages().subtype( | |
| 511 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,0) | |
| 512 ) | |
| 513 ), | |
| 514 namedtype.NamedType('ip', CertRepMessage().subtype( | |
| 515 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,1) | |
| 516 ) | |
| 517 ), | |
| 518 namedtype.NamedType('cr', rfc2511.CertReqMessages().subtype( | |
| 519 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,2) | |
| 520 ) | |
| 521 ), | |
| 522 namedtype.NamedType('cp', CertRepMessage().subtype( | |
| 523 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,3) | |
| 524 ) | |
| 525 ), | |
| 526 namedtype.NamedType('p10cr', rfc2314.CertificationRequest().subtype( | |
| 527 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,4) | |
| 528 ) | |
| 529 ), | |
| 530 namedtype.NamedType('popdecc', POPODecKeyChallContent().subtype( | |
| 531 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,5) | |
| 532 ) | |
| 533 ), | |
| 534 namedtype.NamedType('popdecr', POPODecKeyRespContent().subtype( | |
| 535 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,6) | |
| 536 ) | |
| 537 ), | |
| 538 namedtype.NamedType('kur', rfc2511.CertReqMessages().subtype( | |
| 539 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,7) | |
| 540 ) | |
| 541 ), | |
| 542 namedtype.NamedType('kup', CertRepMessage().subtype( | |
| 543 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,8) | |
| 544 ) | |
| 545 ), | |
| 546 namedtype.NamedType('krr', rfc2511.CertReqMessages().subtype( | |
| 547 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,9) | |
| 548 ) | |
| 549 ), | |
| 550 namedtype.NamedType('krp', KeyRecRepContent().subtype( | |
| 551 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,10) | |
| 552 ) | |
| 553 ), | |
| 554 namedtype.NamedType('rr', RevReqContent().subtype( | |
| 555 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,11) | |
| 556 ) | |
| 557 ), | |
| 558 namedtype.NamedType('rp', RevRepContent().subtype( | |
| 559 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,12) | |
| 560 ) | |
| 561 ), | |
| 562 namedtype.NamedType('ccr', rfc2511.CertReqMessages().subtype( | |
| 563 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,13) | |
| 564 ) | |
| 565 ), | |
| 566 namedtype.NamedType('ccp', CertRepMessage().subtype( | |
| 567 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,14) | |
| 568 ) | |
| 569 ), | |
| 570 namedtype.NamedType('ckuann', CAKeyUpdAnnContent().subtype( | |
| 571 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,15) | |
| 572 ) | |
| 573 ), | |
| 574 namedtype.NamedType('cann', CertAnnContent().subtype( | |
| 575 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,16) | |
| 576 ) | |
| 577 ), | |
| 578 namedtype.NamedType('rann', RevAnnContent().subtype( | |
| 579 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,17) | |
| 580 ) | |
| 581 ), | |
| 582 namedtype.NamedType('crlann', CRLAnnContent().subtype( | |
| 583 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,18) | |
| 584 ) | |
| 585 ), | |
| 586 namedtype.NamedType('pkiconf', PKIConfirmContent().subtype( | |
| 587 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,19) | |
| 588 ) | |
| 589 ), | |
| 590 namedtype.NamedType('nested', nestedMessageContent), | |
| 591 # namedtype.NamedType('nested', NestedMessageContent().subtype( | |
| 592 # explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,20
) | |
| 593 # ) | |
| 594 # ), | |
| 595 namedtype.NamedType('genm', GenMsgContent().subtype( | |
| 596 explicitTag=tag.Tag(tag.tagClassContext,tag.tagFormatConstructed,21) | |
| 597 ) | |
| 598 ) | |
| 599 ) | |
| 600 | |
| 601 | |
| 602 class PKIHeader(univ.Sequence): | |
| 603 """ | |
| 604 PKIHeader ::= SEQUENCE { | |
| 605 pvno INTEGER { cmp1999(1), cmp2000(2) }, | |
| 606 sender GeneralName, | |
| 607 recipient GeneralName, | |
| 608 messageTime [0] GeneralizedTime OPTIONAL, | |
| 609 protectionAlg [1] AlgorithmIdentifier OPTIONAL, | |
| 610 senderKID [2] KeyIdentifier OPTIONAL, | |
| 611 recipKID [3] KeyIdentifier OPTIONAL, | |
| 612 transactionID [4] OCTET STRING OPTIONAL, | |
| 613 senderNonce [5] OCTET STRING OPTIONAL, | |
| 614 recipNonce [6] OCTET STRING OPTIONAL, | |
| 615 freeText [7] PKIFreeText OPTIONAL, | |
| 616 generalInfo [8] SEQUENCE SIZE (1..MAX) OF | |
| 617 InfoTypeAndValue OPTIONAL | |
| 618 } | |
| 619 | |
| 620 """ | |
| 621 componentType = namedtype.NamedTypes( | |
| 622 namedtype.NamedType('pvno', univ.Integer( | |
| 623 namedValues=namedval.NamedValues( | |
| 624 ('cmp1999', 1), | |
| 625 ('cmp2000', 2) | |
| 626 ) | |
| 627 ) | |
| 628 ), | |
| 629 namedtype.NamedType('sender', rfc2459.GeneralName()), | |
| 630 namedtype.NamedType('recipient', rfc2459.GeneralName()), | |
| 631 namedtype.OptionalNamedType('messageTime', useful.GeneralizedTime().subt
ype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), | |
| 632 namedtype.OptionalNamedType('protectionAlg', rfc2459.AlgorithmIdentifier
().subtype( | |
| 633 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1
))), | |
| 634 namedtype.OptionalNamedType('senderKID', rfc2459.KeyIdentifier().subtype
(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))), | |
| 635 namedtype.OptionalNamedType('recipKID', rfc2459.KeyIdentifier().subtype(
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))), | |
| 636 namedtype.OptionalNamedType('transactionID', univ.OctetString().subtype(
explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))), | |
| 637 namedtype.OptionalNamedType('senderNonce', univ.OctetString().subtype(ex
plicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5))), | |
| 638 namedtype.OptionalNamedType('recipNonce', univ.OctetString().subtype(exp
licitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))), | |
| 639 namedtype.OptionalNamedType('freeText', PKIFreeText().subtype(explicitTa
g=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 7))), | |
| 640 namedtype.OptionalNamedType('generalInfo', | |
| 641 univ.SequenceOf( | |
| 642 componentType=InfoTypeAndValue().subtype( | |
| 643 subtypeSpec=constraint.ValueSizeConstraint(1, MAX), | |
| 644 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple
, 8) | |
| 645 ) | |
| 646 ) | |
| 647 ) | |
| 648 ) | |
| 649 | |
| 650 class ProtectedPart(univ.Sequence): | |
| 651 """ | |
| 652 ProtectedPart ::= SEQUENCE { | |
| 653 header PKIHeader, | |
| 654 body PKIBody | |
| 655 } | |
| 656 """ | |
| 657 componentType = namedtype.NamedTypes( | |
| 658 namedtype.NamedType('header', PKIHeader()), | |
| 659 namedtype.NamedType('infoValue', PKIBody()) | |
| 660 ) | |
| 661 | |
| 662 class PKIMessage(univ.Sequence): | |
| 663 """ | |
| 664 PKIMessage ::= SEQUENCE { | |
| 665 header PKIHeader, | |
| 666 body PKIBody, | |
| 667 protection [0] PKIProtection OPTIONAL, | |
| 668 extraCerts [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate | |
| 669 OPTIONAL | |
| 670 }""" | |
| 671 componentType = namedtype.NamedTypes( | |
| 672 namedtype.NamedType('header', PKIHeader()), | |
| 673 namedtype.NamedType('body', PKIBody()), | |
| 674 namedtype.OptionalNamedType('protection', PKIProtection().subtype(explic
itTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), | |
| 675 namedtype.OptionalNamedType( 'extraCerts', | |
| 676 univ.SequenceOf( | |
| 677 componentType=CMPCertificate() | |
| 678 ).subtype( | |
| 679 subtypeSpec=constraint.ValueSizeConstraint(1, MAX), | |
| 680 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructe
d, 1) | |
| 681 ) | |
| 682 ) | |
| 683 ) | |
| 684 | |
| 685 class PKIMessages(univ.SequenceOf): | |
| 686 """ | |
| 687 PKIMessages ::= SEQUENCE SIZE (1..MAX) OF PKIMessage | |
| 688 """ | |
| 689 componentType = PKIMessage() | |
| 690 subtypeSpec = univ.SequenceOf.subtypeSpec + constraint.ValueSizeConstraint(1
, MAX) | |
| 691 | |
| 692 # pyasn1 does not naturally handle recursive definitions, thus this hack: | |
| 693 # NestedMessageContent ::= PKIMessages | |
| 694 NestedMessageContent.componentType = PKIMessages() | |
| 695 nestedMessageContent.componentType = PKIMessages() | |
| OLD | NEW |