MCPcopy Create free account
hub / github.com/SecurityInnovation/PGPy / UserAttribute

Class UserAttribute

pgpy/packet/packets.py:1367–1427  ·  view source on GitHub ↗

5.12. User Attribute Packet (Tag 17) The User Attribute packet is a variation of the User ID packet. It is capable of storing more types of data than the User ID packet, which is limited to text. Like the User ID packet, a User Attribute packet may be certified by the key ow

Source from the content-addressed store, hash-verified

1365
1366
1367class UserAttribute(Packet):
1368 """
1369 5.12. User Attribute Packet (Tag 17)
1370
1371 The User Attribute packet is a variation of the User ID packet. It
1372 is capable of storing more types of data than the User ID packet,
1373 which is limited to text. Like the User ID packet, a User Attribute
1374 packet may be certified by the key owner ("self-signed") or any other
1375 key owner who cares to certify it. Except as noted, a User Attribute
1376 packet may be used anywhere that a User ID packet may be used.
1377
1378 While User Attribute packets are not a required part of the OpenPGP
1379 standard, implementations SHOULD provide at least enough
1380 compatibility to properly handle a certification signature on the
1381 User Attribute packet. A simple way to do this is by treating the
1382 User Attribute packet as a User ID packet with opaque contents, but
1383 an implementation may use any method desired.
1384
1385 The User Attribute packet is made up of one or more attribute
1386 subpackets. Each subpacket consists of a subpacket header and a
1387 body. The header consists of:
1388
1389 - the subpacket length (1, 2, or 5 octets)
1390
1391 - the subpacket type (1 octet)
1392
1393 and is followed by the subpacket specific data.
1394
1395 The only currently defined subpacket type is 1, signifying an image.
1396 An implementation SHOULD ignore any subpacket of a type that it does
1397 not recognize. Subpacket types 100 through 110 are reserved for
1398 private or experimental use.
1399 """
1400 __typeid__ = 0x11
1401
1402 @property
1403 def image(self):
1404 if 'Image' not in self.subpackets:
1405 self.subpackets.addnew('Image')
1406 return next(iter(self.subpackets['Image']))
1407
1408 def __init__(self):
1409 super(UserAttribute, self).__init__()
1410 self.subpackets = UserAttributeSubPackets()
1411
1412 def __bytearray__(self):
1413 _bytes = bytearray()
1414 _bytes += super(UserAttribute, self).__bytearray__()
1415 _bytes += self.subpackets.__bytearray__()
1416 return _bytes
1417
1418 def parse(self, packet):
1419 super(UserAttribute, self).parse(packet)
1420
1421 plen = len(packet)
1422 while self.header.length > (plen - len(packet)):
1423 self.subpackets.parse(packet)
1424

Callers 2

parseMethod · 0.70
newMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…