| 364 | |
| 365 | |
| 366 | class EncryptedData(ASN1_Packet): |
| 367 | ASN1_codec = ASN1_Codecs.BER |
| 368 | ASN1_root = ASN1F_SEQUENCE( |
| 369 | ASN1F_enum_INTEGER("etype", 0x17, _KRB_E_TYPES, explicit_tag=0xA0), |
| 370 | ASN1F_optional(UInt32("kvno", None, explicit_tag=0xA1)), |
| 371 | ASN1F_STRING("cipher", "", explicit_tag=0xA2), |
| 372 | ) |
| 373 | |
| 374 | def get_usage(self): |
| 375 | """ |
| 376 | Get current key usage number and encrypted class |
| 377 | """ |
| 378 | # RFC 4120 sect 7.5.1 |
| 379 | if self.underlayer: |
| 380 | if isinstance(self.underlayer, PADATA): |
| 381 | patype = self.underlayer.padataType |
| 382 | if patype == 2: |
| 383 | # AS-REQ PA-ENC-TIMESTAMP padata timestamp |
| 384 | return 1, PA_ENC_TS_ENC |
| 385 | elif patype == 138: |
| 386 | # RFC6113 PA-ENC-TS-ENC |
| 387 | return 54, PA_ENC_TS_ENC |
| 388 | elif isinstance(self.underlayer, KRB_Ticket): |
| 389 | # AS-REP Ticket and TGS-REP Ticket |
| 390 | return 2, EncTicketPart |
| 391 | elif isinstance(self.underlayer, KRB_AS_REP): |
| 392 | # AS-REP encrypted part |
| 393 | return 3, EncASRepPart |
| 394 | elif isinstance(self.underlayer, KRB_KDC_REQ_BODY): |
| 395 | # KDC-REQ enc-authorization-data |
| 396 | return 4, AuthorizationData |
| 397 | elif isinstance(self.underlayer, KRB_AP_REQ) and isinstance( |
| 398 | self.underlayer.underlayer, PADATA |
| 399 | ): |
| 400 | # TGS-REQ PA-TGS-REQ Authenticator |
| 401 | return 7, KRB_Authenticator |
| 402 | elif isinstance(self.underlayer, KRB_TGS_REP): |
| 403 | # TGS-REP encrypted part |
| 404 | return 8, EncTGSRepPart |
| 405 | elif isinstance(self.underlayer, KRB_AP_REQ): |
| 406 | # AP-REQ Authenticator |
| 407 | return 11, KRB_Authenticator |
| 408 | elif isinstance(self.underlayer, KRB_AP_REP): |
| 409 | # AP-REP encrypted part |
| 410 | return 12, EncAPRepPart |
| 411 | elif isinstance(self.underlayer, KRB_PRIV): |
| 412 | # KRB-PRIV encrypted part |
| 413 | return 13, EncKrbPrivPart |
| 414 | elif isinstance(self.underlayer, KRB_CRED): |
| 415 | # KRB-CRED encrypted part |
| 416 | return 14, EncKrbCredPart |
| 417 | elif isinstance(self.underlayer, KrbFastArmoredReq): |
| 418 | # KEY_USAGE_FAST_ENC |
| 419 | return 51, KrbFastReq |
| 420 | elif isinstance(self.underlayer, KrbFastArmoredRep): |
| 421 | # KEY_USAGE_FAST_REP |
| 422 | return 52, KrbFastResponse |
| 423 | raise ValueError( |
no test coverage detected