MCPcopy Create free account
hub / github.com/secdev/scapy / _AttributeValue_Field

Class _AttributeValue_Field

scapy/layers/x509.py:298–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296
297
298class _AttributeValue_Field(ASN1F_field):
299 def m2i(self, pkt, s):
300 # Some types have special structures
301 if pkt.underlayer:
302 attrType = pkt.underlayer.type.val
303 if attrType in _X509_ATTRIBUTE_TYPE:
304 return self.extract_packet(
305 _X509_ATTRIBUTE_TYPE[attrType],
306 s,
307 _underlayer=pkt,
308 )
309 try:
310 return super(_AttributeValue_Field, self).m2i(pkt, s)
311 except BER_Decoding_Error:
312 # Do not fail on special attributes
313 return s, b""
314
315 def i2m(self, pkt, x):
316 # The special structures should be just bytes()
317 if pkt.underlayer and pkt.underlayer.type.val in _X509_ATTRIBUTE_TYPE:
318 return bytes(x)
319 return super(_AttributeValue_Field, self).i2m(pkt, x)
320
321
322class X509_AttributeValue(ASN1_Packet):

Callers 1

X509_AttributeValueClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…