This is a type in BirthdayCAKE. It describes a PublicKeyID. It's found in the cake.keystuff module.

For documentation purposes, here's the code for a version of the class. Notice how the KeyName is generated from a PublicKey or PrivateKey (aka AsymmetricKey) by serializing the PublicKey version of the key, then generating a hash digest of the serialized version:

   1 class KeyName(object):
   2     """KeyName(str) -> a keyname, str must be a 32 byte string.
   3 KeyName(AsymmetricKey) -> The name of the AsymmetricKey passed in."""
   4     __slots__ = ('_name', '__weakref__')
   5 
   6     def __init__(self, nameorkey):
   7         super(KeyName, self).__init__(self)
   8         if isinstance(nameorkey, KeyName):
   9             self._name = nameorkey._name
  10         elif isinstance(nameorkey, str):
  11             if len(nameorkey) != 32:  # 256 bits / 8 bits per byte = 32 bytes
  12                 raise TypeError('A string must be exactly 32 characters long '
  13                                 'to be converted to a %s' % KeyName)
  14             else:
  15                 self._name = intern(nameorkey)
  16         elif isinstance(nameorkey, _pubkey.AsymmetricKey):
  17             if isinstance(nameorkey, _pubkey.PrivateKey):
  18                 nameorkey = nameorkey.publicKey()
  19             if not isinstance(nameorkey, _pubkey.PublicKey):
  20                 raise TypeError("Passed in key appears to be neither a %s, "
  21                                 "nor a %s" % (_pubkey.PrivateKey,
  22                                               _pubkey.PublicKey))
  23             self._name = intern(_shad_256(serializeKey(nameorkey)).digest())
  24         else:
  25             raise TypeError("nameorkey must be a string or %s"
  26                             % _pubkey.AsymmetricKey)
  27     def __repr__(self):
  28         return '<%s.%s %s>' % \
               (KeyName.__module__, KeyName.__name__, self.printableName())
  29     def __hash__(self):
  30         return hash(self._name)
  31     def __cmp__(self, other):
  32         return cmp(self._name, other._name)
  33     def rawName(self):
  34         """The raw 32 byte string containing a key's name."""
  35         return self._name
  36     def printableName(self):
  37         """The human readable, base32 representation of a key's name."""
  38         return _b2a32(self._name)

CAKE: KeyName (last edited 2004-06-24 15:04:26 by EricHopper)