示例#1
0
 def content(cls: Type['stem.descriptor.extrainfo_descriptor.BridgeExtraInfoDescriptor'], attr: Optional[Mapping[str, str]] = None, exclude: Sequence[str] = ()) -> bytes:
   return _descriptor_content(attr, exclude, (
     ('extra-info', 'ec2bridgereaac65a3 %s' % _random_fingerprint()),
     ('published', _random_date()),
   ), (
     ('router-digest', _random_fingerprint()),
   ))
示例#2
0
    def content(cls, attr=None, exclude=(), sign=False):
        if sign:
            raise NotImplementedError('Signing of %s not implemented' %
                                      cls.__name__)

        return _descriptor_content(attr, exclude, (
            ('extra-info', 'ec2bridgereaac65a3 %s' % _random_fingerprint()),
            ('published', _random_date()),
        ), (('router-digest', _random_fingerprint()), ))
示例#3
0
  def content(cls, attr = None, exclude = (), sign = False):
    if sign:
      raise NotImplementedError('Signing of %s not implemented' % cls.__name__)

    return _descriptor_content(attr, exclude, (
      ('extra-info', 'ec2bridgereaac65a3 %s' % _random_fingerprint()),
      ('published', _random_date()),
    ), (
      ('router-digest', _random_fingerprint()),
    ))
示例#4
0
    def content(cls, attr=None, exclude=(), sign=False, signing_key=None):
        base_header = (
            ('extra-info',
             '%s %s' % (_random_nickname(), _random_fingerprint())),
            ('published', _random_date()),
        )

        if signing_key:
            sign = True

        if sign:
            if attr and 'router-signature' in attr:
                raise ValueError(
                    'Cannot sign the descriptor if a router-signature has been provided'
                )

            if signing_key is None:
                signing_key = create_signing_key()

            content = _descriptor_content(
                attr, exclude, base_header) + b'\nrouter-signature\n'
            return _append_router_signature(content, signing_key.private)
        else:
            return _descriptor_content(
                attr, exclude, base_header,
                (('router-signature', _random_crypto_blob('SIGNATURE')), ))
示例#5
0
  def content(cls: Type['stem.descriptor.extrainfo_descriptor.RelayExtraInfoDescriptor'], attr: Optional[Mapping[str, str]] = None, exclude: Sequence[str] = (), sign: bool = False, signing_key: Optional['stem.descriptor.SigningKey'] = None) -> bytes:
    base_header = (
      ('extra-info', '%s %s' % (_random_nickname(), _random_fingerprint())),
      ('published', _random_date()),
    )

    if sign or signing_key:
      if attr and 'router-signature' in attr:
        raise ValueError('Cannot sign the descriptor if a router-signature has been provided')

      if signing_key is None:
        signing_key = create_signing_key()

      content = _descriptor_content(attr, exclude, base_header) + b'\nrouter-signature\n'
      return _append_router_signature(content, signing_key.private)
    else:
      return _descriptor_content(attr, exclude, base_header, (
        ('router-signature', _random_crypto_blob('SIGNATURE')),
      ))
示例#6
0
  def content(cls, attr = None, exclude = (), sign = False, signing_key = None):
    base_header = (
      ('extra-info', '%s %s' % (_random_nickname(), _random_fingerprint())),
      ('published', _random_date()),
    )

    if signing_key:
      sign = True

    if sign:
      if attr and 'router-signature' in attr:
        raise ValueError('Cannot sign the descriptor if a router-signature has been provided')

      if signing_key is None:
        signing_key = create_signing_key()

      content = _descriptor_content(attr, exclude, base_header) + b'\nrouter-signature\n'
      return _append_router_signature(content, signing_key.private)
    else:
      return _descriptor_content(attr, exclude, base_header, (
        ('router-signature', _random_crypto_blob('SIGNATURE')),
      ))
示例#7
0
 def content(cls, attr=None, exclude=()):
     return _descriptor_content(attr, exclude, (
         ('extra-info', 'ec2bridgereaac65a3 %s' % _random_fingerprint()),
         ('published', _random_date()),
     ), (('router-digest', _random_fingerprint()), ))