/** * Generate a random destination key. * Caller must close streams. Fails silently. * * @param priv Stream used to write the destination and private keys * @param pub Stream used to write the destination (may be null) * @param sigType what signature type * @since 0.9.14 */ public static void genRandomKey(OutputStream priv, OutputStream pub, SigType sigType) { //_log.debug("Generating random keys..."); try { I2PClient c = I2PClientFactory.createClient(); Destination d = c.createDestination(priv, sigType); priv.flush(); if (pub != null) { d.writeBytes(pub); pub.flush(); } } catch (I2PException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
/** * Read in the given destination, display it, and write it to the given location * Deprecated - only used by CLI * * @param readFrom stream to read the destination from * @param pubDest stream to write the destination to * @param l logger to send messages to */ private static void showKey(InputStream readFrom, OutputStream pubDest, Logging l) { try { Destination d = new Destination(); d.readBytes(readFrom); l.log("Destination: " + d.toBase32()); readFrom.close(); writePubKey(d, pubDest, l); } catch (I2PException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
/** * Create a new destination, storing the destination and its private keys where * instructed. * Does NOT support non-default sig types. * Deprecated - only used by CLI * * @param writeTo location to store the destination and private keys * @param pubDest location to store the destination * @param l logger to send messages to */ private static void makeKey(OutputStream writeTo, OutputStream pubDest, Logging l) { try { l.log("Generating new keys..."); I2PClient client = I2PClientFactory.createClient(); Destination d = client.createDestination(writeTo); l.log("New destination: " + d.toBase32()); writeTo.flush(); writeTo.close(); writePubKey(d, pubDest, l); } catch (I2PException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
e.printStackTrace(); System.exit(1); } catch (IOException e) {