/** @since 0.8.9 */ public PrivateKeyFile(File file, I2PSession session) { this(file, session.getMyDestination(), session.getDecryptionKey(), session.getPrivateKey()); }
/** * Can't be used for writing * @since 0.9.26 */ public PrivateKeyFile(InputStream in) throws I2PSessionException { this("/dev/null"); I2PSession s = this.client.createSession(in, new Properties()); this.dest = s.getMyDestination(); this.privKey = s.getDecryptionKey(); this.signingPrivKey = s.getPrivateKey(); }
/** * If the destination is not set, read it in from the file. * Also sets the local privKey and signingPrivKey. */ public Destination getDestination() throws I2PSessionException, IOException, DataFormatException { if (dest == null) { I2PSession s = open(); if (s != null) { this.dest = new VerifiedDestination(s.getMyDestination()); this.privKey = s.getDecryptionKey(); this.signingPrivKey = s.getPrivateKey(); if (s.isOffline()) { _offlineExpiration = s.getOfflineExpiration(); _transientSigningPubKey = s.getTransientSigningPublicKey(); _offlineSignature = s.getOfflineSignature(); _transientSigningPrivKey = signingPrivKey; // set dummy SPK SigType type = dest.getSigningPublicKey().getType(); byte[] dbytes = new byte[type.getPrivkeyLen()]; signingPrivKey = new SigningPrivateKey(type, dbytes); } } } return this.dest; }
PrivateKey priv = _session.getDecryptionKey(); SimpleDataStructure[] keys = _context.keyGenerator().generateSigningKeys(type); pub.writeBytes(keyStream);
/** * Decrypts the <code>CommunicationPacket</code> inside this packet. * @throws DataFormatException * @throws MalformedPacketException */ private CommunicationPacket decrypt(I2PSession i2pSession) throws DataFormatException, MalformedPacketException { PrivateKey privateKey = i2pSession.getDecryptionKey(); byte[] decryptedData = Util.decrypt(payload, privateKey); return CommunicationPacket.createPacket(decryptedData); } }
@Override public KeyPair generateEncryptionKeyPair() throws KeyException { I2PSession i2pSession = createI2PSession(); net.i2p.data.PublicKey i2pPublicKey = i2pSession.getMyDestination().getPublicKey(); net.i2p.data.PrivateKey i2pPrivateKey = i2pSession.getDecryptionKey(); PublicKey publicKey = new ElGamalPublicKey(i2pPublicKey); PrivateKey privateKey = new ElGamalPrivateKey(i2pPrivateKey); return new KeyPair(publicKey, privateKey); }
PrivateKey priv = _session.getDecryptionKey(); SimpleDataStructure[] keys = _context.keyGenerator().generateSigningKeys(type); pub.writeBytes(keyStream);