Changeset 5d389c8


Ignore:
Timestamp:
Mar 9, 2019 4:40:15 PM (17 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e36a3b3
Parents:
d6a53cc
Message:

I2CP: Add support for blinding secret

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java

    rd6a53cc r5d389c8  
    6666    public static final String PROP_LS_TYPE = "i2cp.leaseSetType";
    6767    private static final String PROP_LS_ENCTYPE = "i2cp.leaseSetEncType";
     68    private static final String PROP_SECRET = "i2cp.leaseSetSecret";
    6869
    6970    public RequestLeaseSetMessageHandler(I2PAppContext context) {
     
    124125                leaseSet = new LeaseSet2();
    125126            } else if (_ls2Type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
    126                 leaseSet = new EncryptedLeaseSet();
     127                EncryptedLeaseSet encls2 = new EncryptedLeaseSet();
     128                String secret = session.getOptions().getProperty(PROP_SECRET);
     129                if (secret != null)
     130                    encls2.setSecret(secret);
     131                leaseSet = encls2;
    127132            } else if (_ls2Type == DatabaseEntry.KEY_TYPE_META_LS2) {
    128133                leaseSet = new MetaLeaseSet();
     
    137142            leaseSet = new LeaseSet();
    138143        }
    139         // Full Meta and Encrypted support TODO
     144        // Full Meta support TODO
    140145        for (int i = 0; i < msg.getEndpoints(); i++) {
    141146            Lease lease;
  • core/java/src/net/i2p/data/EncryptedLeaseSet.java

    rd6a53cc r5d389c8  
    2323 * PRELIMINARY - Subject to change - see proposal 123
    2424 *
     25 * Per-client auth TODO
     26 *
    2527 * @since 0.9.38
    2628 */
     
    3234    private Hash __calculatedHash;
    3335    private SigningPrivateKey _alpha;
     36    private String _secret;
    3437    private final Log _log;
    3538
     
    5760    }
    5861
     62    /**
     63     *  Must be set before sign or verify.
     64     *
     65     *  @param secret null or "" for none (default)
     66     *  @since 0.9.39
     67     */
     68    public void setSecret(String secret) {
     69        _secret = secret;
     70    }
     71
    5972    ///// overrides below here
    6073
     
    8598     *  @since 0.9.39
    8699     */
     100    @Override
    87101    public List<PublicKey> getEncryptionKeys() {
    88102        if (_decryptedLS2 != null)
     
    130144        I2PAppContext ctx = I2PAppContext.getGlobalContext();
    131145        if (_published <= 0)
    132             _alpha = Blinding.generateAlpha(ctx, _destination.getSigningPublicKey(), null);
     146            _alpha = Blinding.generateAlpha(ctx, _destination.getSigningPublicKey(), _secret);
    133147        else
    134             _alpha = Blinding.generateAlpha(ctx, _destination.getSigningPublicKey(), null, _published);
     148            _alpha = Blinding.generateAlpha(ctx, _destination.getSigningPublicKey(), _secret, _published);
    135149        SigningPublicKey rv = Blinding.blind(spk, _alpha);
    136150        if (_log.shouldDebug())
     
    681695        pubKey = encKeys2.getPublic();
    682696        ls2.addEncryptionKey(pubKey);
     697        ls2.setSecret("foobar");
    683698        SigningPrivateKey spk = pkf.getSigningPrivKey();
    684699        if (offline) {
     
    693708            ls2.sign(spk);
    694709        }
    695         System.out.println("Created: " + ls2);
     710        System.out.println("\nCreated: " + ls2);
    696711        if (!ls2.verifySignature()) {
    697712            System.out.println("Verify FAILED");
     
    704719        out2.close();
    705720        java.io.ByteArrayInputStream in = new java.io.ByteArrayInputStream(out.toByteArray());
    706         System.out.println("Size calculated: " + (ls2.size() + ls2.getSignature().length()));
    707         System.out.println("Size to read in: " + in.available());
     721        System.out.println("\nSize calculated: " + (ls2.size() + ls2.getSignature().length()));
     722        System.out.println("\nSize to read in: " + in.available());
    708723        EncryptedLeaseSet ls3 = new EncryptedLeaseSet();
    709724        ls3.readBytes(in);
    710         System.out.println("Read back: " + ls3);
     725        System.out.println("\nRead back: " + ls3);
    711726        // required to decrypt
    712727        ls3.setDestination(pkf.getDestination());
  • router/java/src/net/i2p/router/client/ClientMessageEventListener.java

    rd6a53cc r5d389c8  
    643643                    return;
    644644                }
     645                String secret = cfg.getOptions().getProperty("i2cp.leaseSetSecret");
     646                if (secret != null) {
     647                    EncryptedLeaseSet encls = (EncryptedLeaseSet) ls;
     648                    encls.setSecret(secret);
     649                }
    645650            }
    646651            if (_log.shouldDebug())
Note: See TracChangeset for help on using the changeset viewer.