Changeset 040e092 for core


Ignore:
Timestamp:
May 29, 2019 7:08:33 PM (12 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
16ac93c
Parents:
098bde2
Message:

Blinding:

  • Fix bugs with lookup password
  • Log tweaks
Location:
core/java/src/net/i2p
Files:
4 edited

Legend:

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

    r098bde2 r040e092  
    131131                leaseSet = new LeaseSet2();
    132132            } else if (_ls2Type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
    133                 EncryptedLeaseSet encls2 = new EncryptedLeaseSet();
    134                 String secret = session.getOptions().getProperty(PROP_SECRET);
    135                 if (secret != null) {
    136                     secret = DataHelper.getUTF8(Base64.decode(secret));
    137                     encls2.setSecret(secret);
    138                 }
    139                 leaseSet = encls2;
     133                leaseSet = new EncryptedLeaseSet();
    140134            } else if (_ls2Type == DatabaseEntry.KEY_TYPE_META_LS2) {
    141135                leaseSet = new MetaLeaseSet();
     
    175169     */
    176170    protected synchronized void signLeaseSet(LeaseSet leaseSet, boolean isLS2, I2PSessionImpl session) {
     171        // must be before setDestination()
     172        if (isLS2 && _ls2Type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     173            String secret = session.getOptions().getProperty(PROP_SECRET);
     174            if (secret != null) {
     175                EncryptedLeaseSet encls2 = (EncryptedLeaseSet) leaseSet;
     176                secret = DataHelper.getUTF8(Base64.decode(secret));
     177                encls2.setSecret(secret);
     178            }
     179        }
    177180        Destination dest = session.getMyDestination();
    178181        // also, if this session is connected to multiple routers, include other leases here
  • core/java/src/net/i2p/client/impl/RequestVariableLeaseSetMessageHandler.java

    r098bde2 r040e092  
    5959            leaseSet = new LeaseSet();
    6060        }
    61         // Full Meta and Encrypted support TODO
     61        // Full Meta support TODO
    6262        for (int i = 0; i < msg.getEndpoints(); i++) {
    6363            Lease lease;
  • core/java/src/net/i2p/crypto/Blinding.java

    r098bde2 r040e092  
    328328        I2PAppContext ctx = I2PAppContext.getGlobalContext();
    329329        //String b32 = encode(pub, null);
    330         String b32 = encode(pub, "foobarbaz");
     330        String b32 = encode(pub, true, false);
    331331        System.out.println("pub b32 is " + b32);
    332332        BlindData bd = decode(ctx, b32);
  • core/java/src/net/i2p/data/EncryptedLeaseSet.java

    r098bde2 r040e092  
    4343    private PrivateKey _clientPrivateKey;
    4444    private final Log _log;
     45    // debug
     46    private int _authType, _numKeys;
    4547
    4648    private static final int MIN_ENCRYPTED_SIZE = 8 + 16;
     
    7577    /**
    7678     *  Must be set before sign or verify.
     79     *  Must be called before setDestination() or setSigningKey(), or alpha will be wrong.
    7780     *
    7881     *  @param secret null or "" for none (default)
     
    8083     */
    8184    public void setSecret(String secret) {
     85        if (_signingKey != null && !DataHelper.eq(secret, _secret)) {
     86            if (_log.shouldWarn())
     87                _log.warn("setSecret() after setSigningKey()" +
     88                          " was: " + _secret + " now: " + secret);
     89        }
    8290        _secret = secret;
    8391    }
     
    129137
    130138    /**
    131      * Overridden to set the blinded key
     139     * Overridden to set the blinded key.
     140     * setSecret() MUST be called before this for non-null secret, or alpha will be wrong.
    132141     *
    133142     * @param dest non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
     
    148157
    149158    /**
    150      * Overridden to set the blinded key
     159     * Overridden to set the blinded key.
     160     * setSecret() MUST be called before this for non-null secret, or alpha will be wrong.
    151161     *
    152162     * @param spk unblinded key non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
     
    157167    @Override
    158168    public void setSigningKey(SigningPublicKey spk) {
    159         // TODO already-set checks
    160169        SigType type = spk.getType();
    161170        if (type != SigType.EdDSA_SHA512_Ed25519 &&
     
    193202            _log.debug("Blind:" +
    194203                       "\norig:    " + spk +
     204                       "\nsecret:  " + _secret +
    195205                       "\nalpha:   " + _alpha +
    196206                       "\nblinded: " + rv);
     
    416426        byte[] iv = new byte[32];
    417427        int authLen;
     428        _authType = authType;  // debug
    418429        if (authType == BlindData.AUTH_NONE) {
    419430            authLen = 1;
     
    422433            if (clientKeys == null || clientKeys.isEmpty())
    423434                throw new IllegalArgumentException("No client keys provided");
     435            _numKeys = clientKeys.size();  // debug
    424436            authLen = 1 + SALT_LEN + 2 + (clientKeys.size() * CLIENT_LEN);
    425437        } else {
     
    610622
    611623        int authType = plaintext[0] & 0x0f;
     624        _authType = authType;  // debug
    612625        int authLen;
    613626        if (authType == BlindData.AUTH_NONE) {
     
    623636            System.arraycopy(plaintext, 1, seed, 0, 32);
    624637            int count = (int) DataHelper.fromLong(plaintext, 33, 2);
     638            _numKeys = count;  // debug
    625639            if (count == 0)
    626640                throw new DataFormatException("No client entries");
     
    949963        buf.append("\n\tPublished: ").append(new java.util.Date(_published));
    950964        buf.append("\n\tExpires: ").append(new java.util.Date(_expires));
     965        buf.append("\n\tAuth Type: ").append(_authType);
     966        buf.append("\n\tClient Keys: ").append(_numKeys);
    951967        if (_decryptedLS2 != null) {
     968            if (_secret != null)
     969                buf.append("\n\tSecret: ").append(_secret);
     970            if (_clientPrivateKey != null)
     971                buf.append("\n\tClient Private Key: ").append(_clientPrivateKey.toBase64());
    952972            buf.append("\n\tDecrypted LS:\n").append(_decryptedLS2);
    953973        } else if (_destination != null) {
Note: See TracChangeset for help on using the changeset viewer.