leekspin.generator

Main leekspin module for generating mocked Onion Relay (OR) and Hidden Service (HS) descriptors and writing them to disk.

nacl = True

If pynacl was found by leekspin.ntor.nacl.

generateDescriptors(bridge=True, withoutTAP=False, withoutNTOR=False)[source]

Create keys, certs, signatures, documents and descriptors for an OR.

Parameters:
  • bridge (bool) – If True, generate Bridge descriptors; otherwise, generate Relay descriptors.
  • withoutTAP (bool) – If True, generate descriptors without support for the TAP handshake, e.g. without RSA keys.
  • withoutTAP – If True, generate descriptors without support for the ntor handshake, e.g. without Ed25519 keys.
Returns:

A 3-tuple of strings:

  • a @type [bridge-]extra-info descriptor,
  • a @type [bridge-]server-descriptor, and
  • a @type network-status document

for a mock Tor relay/bridge.

generateHSDesc(replica)[source]

Generate a @type rendezvous-service-descriptor for an Hidden Service.

Todo

Make generation of permanent_ids deal with HS “stealth” authorisation.

Todo

Implement per-client session_keys and descriptor_cookies, see rend-spec.txt §2.1.

Parameters:replica (int) – The replica number for this particular descriptor. This influences the secret-id-part of the descriptor (see calculateSecretIDPart()).
Return type:str
Returns:A @type rendezvous-service-descriptor as a string.
createHiddenServiceDescriptors(count, replicas=2)[source]

Generate hidden service descriptors.

Parameters:
  • count (int) – How many sets of descriptors to generate. This essentially corresponds to the number of fake .onion s which should be mocked.
  • replicas (int) – The number of times which one particular mocked Hidden Service should “replicate” its descriptor in the Tor Network’s HSDir hashring. The default for real Hidden Services created with Tor is 2.
createRelayOrBridgeDescriptors(count, bridge=True, **kwargs)[source]

Generate all types of descriptors and write them to files.

Parameters:
  • count (int) – How many sets of descriptors to generate, i.e. how many mock bridges/relays to create.
  • bridge (bool) – If True, generate Bridge descriptors; otherwise, generate Relay descriptors.
create(count, descriptorType=None, withoutTAP=False, withoutNTOR=False)[source]

Create count descriptors of type descriptor_type.

Parameters:
  • count (int) – The number of descriptors to generate.
  • descriptorType (str or None) – One of "relay", "bridge", "hidden_service", or None.
  • withoutTAP (bool) – If True, generate descriptors without support for the TAP handshake, e.g. without RSA keys.
  • withoutTAP – If True, generate descriptors without support for the ntor handshake, e.g. without Ed25519 keys.