Exemple #1
0
 def to_dict(self):
     result = super(PayloadNOTIFY, self).to_dict()
     result.update(
         OrderedDict([
             ('protocol_id', Proposal.Protocol.safe_name(self.protocol_id)),
             ('spi', hexstring(self.spi)),
             ('notification_type',
              PayloadNOTIFY.Type.safe_name(self.notification_type)),
             ('notification_data', hexstring(self.notification_data))
         ]))
     return result
Exemple #2
0
 def to_dict(self):
     return OrderedDict([
         ('spi_i', hexstring(self.spi_i)), ('spi_r', hexstring(self.spi_r)),
         ('major', self.major), ('minor', self.minor),
         ('exchange_type', Message.Exchange.safe_name(self.exchange_type)),
         ('is_request', self.is_request), ('is_response', self.is_response),
         ('can_use_higher_version', self.can_use_higher_version),
         ('is_initiator', self.is_initiator),
         ('is_responder', self.is_responder),
         ('message_id', self.message_id),
         ('payloads', [x.to_dict() for x in self.payloads]),
         ('encrypted_payloads',
          [x.to_dict() for x in self.encrypted_payloads])
     ])
Exemple #3
0
 def to_dict(self):
     result = super(PayloadDELETE, self).to_dict()
     result.update(
         OrderedDict([('protocol_id',
                       Proposal.Protocol.safe_name(self.protocol_id)),
                      ('spis', [hexstring(x) for x in self.spis])]))
     return result
Exemple #4
0
 def to_dict(self):
     return OrderedDict([
         ('num', self.num),
         ('protocol_id', Proposal.Protocol.safe_name(self.protocol_id)),
         ('spi', hexstring(self.spi)),
         ('transforms', [x.to_dict() for x in self.transforms]),
     ])
Exemple #5
0
 def to_dict(self):
     result = super(PayloadAUTH, self).to_dict()
     result.update(
         OrderedDict([
             ('method', PayloadAUTH.Method.safe_name(self.method)),
             ('auth_data', hexstring(self.auth_data)),
         ]))
     return result
Exemple #6
0
 def _id_data_str(self):
     if self.id_type in (PayloadID.Type.ID_RFC822_ADDR,
                         PayloadID.Type.ID_FQDN):
         return self.id_data.decode()
     elif self.id_type in (PayloadID.Type.ID_IPV4_ADDR,
                           PayloadID.Type.ID_IPV6_ADDR):
         return str(ip_address(self.id_data.decode())),
     else:
         return hexstring(self.id_data)
Exemple #7
0
 def delete_sa(self, daddr, proto, spi):
     xfrm_id = XfrmUserSaId(daddr=XfrmAddress.from_ipaddr(daddr),
                            family=socket.AF_INET,
                            proto=socket.IPPROTO_ESP if proto
                            == Proposal.Protocol.ESP else socket.IPPROTO_AH,
                            spi=create_byte_array(spi))
     try:
         self.send_recv(XFRM_MSG_DELSA, (NLM_F_REQUEST | NLM_F_ACK),
                        xfrm_id)
     except NetlinkError as ex:
         logging.warning(
             'Could not delete IPsec SA with SPI: {}. {}'.format(
                 hexstring(spi), ex))
Exemple #8
0
 def to_dict(self):
     result = super(PayloadSK, self).to_dict()
     result.update(OrderedDict([('ciphertext', hexstring(self.ciphertext))
                                ]))
     return result
Exemple #9
0
 def to_dict(self):
     result = super(PayloadNONCE, self).to_dict()
     result.update(OrderedDict([('nonce', hexstring(self.nonce))]))
     return result
Exemple #10
0
 def to_dict(self):
     result = super(PayloadKE, self).to_dict()
     result.update(
         OrderedDict([('dh_group', self.dh_group),
                      ('ke_data', hexstring(self.ke_data))]))
     return result