Ejemplo n.º 1
0
 def KDC_REQ_create(self,
                    msg_type,
                    padata,
                    kdc_options,
                    cname,
                    realm,
                    sname,
                    from_time,
                    till_time,
                    renew_time,
                    nonce,
                    etypes,
                    addresses,
                    EncAuthorizationData,
                    EncAuthorizationData_key,
                    additional_tickets,
                    asn1Spec=None,
                    asn1_print=None,
                    hexdump=None):
     # KDC-REQ         ::= SEQUENCE {
     #        -- NOTE: first tag is [1], not [0]
     #        pvno            [1] INTEGER (5) ,
     #        msg-type        [2] INTEGER (10 -- AS -- | 12 -- TGS --),
     #        padata          [3] SEQUENCE OF PA-DATA OPTIONAL
     #                            -- NOTE: not empty --,
     #        req-body        [4] KDC-REQ-BODY
     # }
     #
     KDC_REQ_BODY_obj = self.KDC_REQ_BODY_create(kdc_options,
                                                 cname,
                                                 realm,
                                                 sname,
                                                 from_time,
                                                 till_time,
                                                 renew_time,
                                                 nonce,
                                                 etypes,
                                                 addresses,
                                                 EncAuthorizationData,
                                                 EncAuthorizationData_key,
                                                 additional_tickets,
                                                 asn1_print=asn1_print,
                                                 hexdump=hexdump)
     KDC_REQ_obj = {
         'pvno': 5,
         'msg-type': msg_type,
         'req-body': KDC_REQ_BODY_obj,
     }
     if padata is not None:
         KDC_REQ_obj['padata'] = padata
     if asn1Spec is not None:
         KDC_REQ_decoded = pyasn1_native_decode(KDC_REQ_obj,
                                                asn1Spec=asn1Spec)
     else:
         KDC_REQ_decoded = None
     return KDC_REQ_obj, KDC_REQ_decoded
Ejemplo n.º 2
0
 def der_encode(self, obj, asn1Spec=None, native_decode=True, asn1_print=None, hexdump=None):
     if native_decode:
         obj = pyasn1_native_decode(obj, asn1Spec=asn1Spec)
     class_name = type(obj).__name__.split(':')[0]
     if class_name is not None:
         self.asn1_dump(None, obj, asn1_print=asn1_print)
     blob = pyasn1_der_encode(obj)
     if class_name is not None:
         self.hex_dump(class_name, blob, hexdump=hexdump)
     return blob