Changes in / [e380b26:491cd0a]


Ignore:
Files:
2 added
21 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java

    re380b26 r491cd0a  
    12481248                } else if(ahelperPresent) {
    12491249                    header = getErrorPage("dnfb", ERR_DESTINATION_UNKNOWN);
    1250                 } else if(destination.length() == 60 && destination.toLowerCase(Locale.US).endsWith(".b32.i2p")) {
     1250                } else if(destination.length() >= 60 && destination.toLowerCase(Locale.US).endsWith(".b32.i2p")) {
    12511251                    header = getErrorPage("nols", ERR_DESTINATION_UNKNOWN);
    12521252                    extraMessage = _t("Destination lease set not found");
  • apps/sam/java/src/net/i2p/sam/SAMUtils.java

    re380b26 r491cd0a  
    172172            if (s.length() >= 516)
    173173                msg = "Bad Base64 dest: ";
    174             else if (s.length() == 60 && s.endsWith(".b32.i2p"))
     174            else if (s.length() >= 60 && s.endsWith(".b32.i2p"))
    175175                msg = "Lease set not found: ";
    176176            else
  • core/java/src/net/i2p/crypto/Blinding.java

    re380b26 r491cd0a  
    219219     *
    220220     *  @param b 35+ bytes
     221     *  @return BlindData structure, use getUnblindedPubKey() for the result
    221222     *  @throws IllegalArgumentException on bad inputs
    222223     *  @throws UnsupportedOperationException unless supported SigTypes
     
    314315    }
    315316
     317    public static void main(String args[]) throws Exception {
     318        if (args.length != 1) {
     319            System.out.println("Usage: blinding {56 chars}.b32.i2p");
     320            System.exit(1);
     321        }
     322        System.out.println("Blinded B32: " + args[0]);
     323        System.out.println(decode(I2PAppContext.getGlobalContext(), args[0]).toString());
     324    }
     325
    316326/******
    317327    public static void main(String args[]) throws Exception {
  • core/java/src/net/i2p/crypto/SelfSignedGenerator.java

    re380b26 r491cd0a  
    250250        if (!cpub.equals(jpub)) {
    251251            boolean ok = false;
    252             if (cpub.getClass().getName().equals("sun.security.x509.X509Key")) {
     252            if ((jpub instanceof EdDSAPublicKey) &&
     253                cpub.getClass().getName().equals("sun.security.x509.X509Key")) {
    253254                // X509Certificate will sometimes contain an X509Key rather than the EdDSAPublicKey itself; the contained
    254255                // key is valid but needs to be instanced as an EdDSAPublicKey before it can be used.
  • core/java/src/net/i2p/data/Base32.java

    re380b26 r491cd0a  
    116116        byte decoded[] = decode(DataHelper.getUTF8(read(in)));
    117117        if (decoded == null) {
    118             System.out.println("FAIL");
     118            System.err.println("FAIL");
    119119            return;
    120120        }
  • core/java/src/net/i2p/data/BlindData.java

    re380b26 r491cd0a  
    2626
    2727    /**
     28     *  @param secret may be null or zero-length
    2829     *  @throws IllegalArgumentException on various errors
    2930     */
     
    3435
    3536    /**
     37     *  @param secret may be null or zero-length
    3638     *  @throws IllegalArgumentException on various errors
    3739     */
     
    4143        _blindType = blindType;
    4244        _secret = secret;
    43         _authType = 0;
     45        _authType = -1;
    4446        _authKey = null;
    4547        // defer until needed
     
    4850
    4951    /**
    50      *  @return The blinded key for the current day
     52     *  @return The unblinded SPK, non-null
     53     */
     54    public SigningPublicKey getUnblindedPubKey() {
     55        return _clearSPK;
     56    }
     57
     58    /**
     59     *  @return The type of the blinded key
     60     */
     61    public SigType getBlindedSigType() {
     62        return _blindType;
     63    }
     64
     65    /**
     66     *  @return The blinded key for the current day, non-null
    5167     */
    5268    public synchronized SigningPublicKey getBlindedPubKey() {
    5369        calculate();
    5470        return _blindSPK;
     71    }
     72
     73    /**
     74     *  @return The hash of the destination if known, or null
     75     */
     76    public synchronized Hash getDestHash() {
     77        return _dest != null ? _dest.getHash() : null;
    5578    }
    5679
     
    100123
    101124    /**
    102      *  @return 0 for no client auth
     125     *  @return -1 for no client auth
    103126     */
    104127    public int getAuthType() {
    105128        return _authType;
     129    }
     130
     131    /**
     132     *  @return null for no client auth
     133     */
     134    public PrivateKey getAuthPrivKey() {
     135        return _authKey;
    106136    }
    107137
     
    128158        _blindHash = _context.sha().calculateHash(hashData);
    129159    }
     160   
     161    @Override
     162    public synchronized String toString() {
     163        calculate();
     164        StringBuilder buf = new StringBuilder(1024);
     165        buf.append("[BlindData: ");
     166        buf.append("\n\tSigningPublicKey: ").append(_clearSPK);
     167        buf.append("\n\tAlpha           : ").append(_alpha);
     168        buf.append("\n\tBlindedPublicKey: ").append(_blindSPK);
     169        buf.append("\n\tBlinded Hash    : ").append(_blindHash);
     170        if (_secret != null)
     171            buf.append("\n\tSecret          : \"").append(_secret).append('"');
     172        buf.append("\n\tAuth Type       : ");
     173        if (_authType >= 0)
     174            buf.append(_authType);
     175        else
     176            buf.append("none");
     177        if (_authKey != null)
     178            buf.append("\n\tAuth Key   : ").append(_authKey);
     179        if (_dest != null)
     180            buf.append("\n\tDestination: ").append(_dest);
     181        else
     182            buf.append("\n\tDestination: unknown");
     183        buf.append(']');
     184        return buf.toString();
     185    }
    130186}
  • core/java/src/net/i2p/data/DatabaseEntry.java

    re380b26 r491cd0a  
    6060
    6161    protected volatile Signature _signature;
    62     protected volatile Hash _currentRoutingKey;
    63     protected volatile long _routingKeyGenMod;
     62    // synch: this
     63    private Hash _currentRoutingKey;
     64    private long _routingKeyGenMod;
    6465
    6566    /**
     
    154155        RoutingKeyGenerator gen = ctx.routingKeyGenerator();
    155156        long mod = gen.getLastChanged();
    156         if (mod != _routingKeyGenMod) {
    157             _currentRoutingKey = gen.getRoutingKey(getHash());
    158             _routingKeyGenMod = mod;
     157        synchronized(this) {
     158            if (mod != _routingKeyGenMod) {
     159                _currentRoutingKey = gen.getRoutingKey(getHash());
     160                _routingKeyGenMod = mod;
     161            }
     162            return _currentRoutingKey;
    159163        }
    160         return _currentRoutingKey;
    161164    }
    162165
  • core/java/src/net/i2p/data/EncryptedLeaseSet.java

    re380b26 r491cd0a  
    3434    private Hash __calculatedHash;
    3535    private SigningPrivateKey _alpha;
     36    // to decrypt with if we don't have full dest
     37    private SigningPublicKey _unblindedSPK;
    3638    private String _secret;
    3739    private final Log _log;
     
    121123        }
    122124        SigningPublicKey spk = dest.getSigningPublicKey();
     125        setSigningKey(spk);
     126    }
     127
     128    /**
     129     * Overridden to set the blinded key
     130     *
     131     * @param spk unblinded key non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
     132     * @throws IllegalStateException if already signed
     133     * @throws IllegalArgumentException if not EdDSA
     134     * @since 0.9.40
     135     */
     136    @Override
     137    public void setSigningKey(SigningPublicKey spk) {
     138        // TODO already-set checks
    123139        SigType type = spk.getType();
    124140        if (type != SigType.EdDSA_SHA512_Ed25519 &&
    125141            type != SigType.RedDSA_SHA512_Ed25519)
    126142            throw new IllegalArgumentException();
    127         SigningPublicKey bpk = blind();
     143        if (_unblindedSPK != null) {
     144            if (!_unblindedSPK.equals(spk))
     145                throw new IllegalArgumentException("unblinded pubkey mismatch");
     146        } else {
     147            _unblindedSPK = spk;
     148        }
     149        SigningPublicKey bpk = blind(spk);
    128150        if (_signingKey == null)
    129151            _signingKey = bpk;
     
    140162     * @since 0.9.39
    141163     */
    142     private SigningPublicKey blind() {
    143         SigningPublicKey spk = _destination.getSigningPublicKey();
     164    private SigningPublicKey blind(SigningPublicKey spk) {
    144165        I2PAppContext ctx = I2PAppContext.getGlobalContext();
    145166        if (_published <= 0)
    146             _alpha = Blinding.generateAlpha(ctx, _destination.getSigningPublicKey(), _secret);
     167            _alpha = Blinding.generateAlpha(ctx, spk, _secret);
    147168        else
    148             _alpha = Blinding.generateAlpha(ctx, _destination.getSigningPublicKey(), _secret, _published);
     169            _alpha = Blinding.generateAlpha(ctx, spk, _secret, _published);
    149170        SigningPublicKey rv = Blinding.blind(spk, _alpha);
    150171        if (_log.shouldDebug())
     
    477498     */
    478499    private byte[] getSubcredential(I2PAppContext ctx) {
    479         if (_destination == null)
    480             throw new IllegalStateException("no known destination to decrypt with");
    481         SigningPublicKey destspk = _destination.getSigningPublicKey();
    482         int spklen = destspk.length();
     500        if (_unblindedSPK == null)
     501            throw new IllegalStateException("no known SPK to decrypt with");
     502        int spklen = _unblindedSPK.length();
    483503        byte[] in = new byte[spklen + 4];
    484504        // SHA256("credential" || spk || sigtypein || sigtypeout)
    485         System.arraycopy(destspk.getData(), 0, in, 0, spklen);
    486         DataHelper.toLong(in, spklen, 2, destspk.getType().getCode());
     505        System.arraycopy(_unblindedSPK.getData(), 0, in, 0, spklen);
     506        DataHelper.toLong(in, spklen, 2, _unblindedSPK.getType().getCode());
    487507        DataHelper.toLong(in, spklen + 2, 2, SigType.RedDSA_SHA512_Ed25519.getCode());
    488508        byte[] credential = hash(ctx, CREDENTIAL, in);
     
    573593        }
    574594        _log.info("ELS2 outer sig verify success");
    575         if (_destination == null) {
    576             _log.warn("ELS2 no dest to decrypt with");
     595        if (_unblindedSPK == null) {
     596            if (_log.shouldWarn())
     597                _log.warn("ELS2 no dest/SPK to decrypt with", new Exception("I did it"));
    577598            return true;
    578599        }
  • core/java/src/net/i2p/data/PrivateKey.java

    re380b26 r491cd0a  
    1111
    1212import java.util.Arrays;
     13import javax.security.auth.Destroyable;
    1314
    1415import net.i2p.crypto.EncType;
    1516import net.i2p.crypto.KeyGenerator;
     17import net.i2p.util.SimpleByteCache;
    1618
    1719/**
     
    2527 * @author jrandom
    2628 */
    27 public class PrivateKey extends SimpleDataStructure {
     29public class PrivateKey extends SimpleDataStructure implements Destroyable {
    2830    private static final EncType DEF_TYPE = EncType.ELGAMAL_2048;
    2931    public final static int KEYSIZE_BYTES = DEF_TYPE.getPrivkeyLen();
     
    9193
    9294    /**
     95     *  javax.security.auth.Destroyable interface
     96     *
     97     *  @since 0.9.40
     98     */
     99    public void destroy() {
     100        byte[] data = _data;
     101        if (data != null) {
     102            _data = null;
     103            Arrays.fill(data, (byte) 0);
     104            SimpleByteCache.release(data);
     105        }
     106    }
     107
     108    /**
     109     *  javax.security.auth.Destroyable interface
     110     *
     111     *  @since 0.9.40
     112     */
     113    public boolean isDestroyed() {
     114        return _data == null;
     115    }
     116
     117    /**
    93118     *  @since 0.9.38
    94119     */
     
    96121    public String toString() {
    97122        StringBuilder buf = new StringBuilder(64);
    98         buf.append("[PrivateKey ").append(_type).append(": ");
     123        buf.append("[PrivateKey ").append(_type).append(' ');
    99124        int length = length();
    100125        if (_data == null) {
  • core/java/src/net/i2p/data/SigningPrivateKey.java

    re380b26 r491cd0a  
    1111
    1212import java.util.Arrays;
     13import javax.security.auth.Destroyable;
    1314
    1415import net.i2p.crypto.Blinding;
    1516import net.i2p.crypto.KeyGenerator;
    1617import net.i2p.crypto.SigType;
     18import net.i2p.util.SimpleByteCache;
    1719
    1820/**
     
    2729 * @author jrandom
    2830 */
    29 public class SigningPrivateKey extends SimpleDataStructure {
     31public class SigningPrivateKey extends SimpleDataStructure implements Destroyable {
    3032    private static final SigType DEF_TYPE = SigType.DSA_SHA1;
    3133    public final static int KEYSIZE_BYTES = DEF_TYPE.getPrivkeyLen();
     
    117119
    118120    /**
     121     *  javax.security.auth.Destroyable interface
     122     *
     123     *  @since 0.9.40
     124     */
     125    public void destroy() {
     126        byte[] data = _data;
     127        if (data != null) {
     128            _data = null;
     129            Arrays.fill(data, (byte) 0);
     130            SimpleByteCache.release(data);
     131        }
     132    }
     133
     134    /**
     135     *  javax.security.auth.Destroyable interface
     136     *
     137     *  @since 0.9.40
     138     */
     139    public boolean isDestroyed() {
     140        return _data == null;
     141    }
     142
     143    /**
    119144     *  @since 0.9.8
    120145     */
     
    122147    public String toString() {
    123148        StringBuilder buf = new StringBuilder(64);
    124         buf.append("[SigningPrivateKey ").append(_type).append(": ");
     149        buf.append("[SigningPrivateKey ").append(_type).append(' ');
    125150        int length = length();
    126151        if (_data == null) {
  • debian-alt/jessie/control

    re380b26 r491cd0a  
    1010 ,debconf
    1111 ,openjdk-7-jdk
    12 # Ant requires java 6 tools.jar:
    13 # Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar
    14  ,openjdk-6-jdk
    1512 ,libtomcat8-java
    1613 ,dh-apparmor
     14 ,dh-systemd
     15 ,bash-completion
    1716 ,gettext
    1817 ,libgetopt-java
     
    3433 lsb-base (>= 3.0-6),
    3534 service-wrapper
    36 Description: Anonymous network (I2P)
     35Description: Invisible Internet Project (I2P) - anonymous network
    3736 I2P is an anonymizing network, offering a simple layer that identity-sensitive
    3837 applications can use to securely communicate. All data is wrapped with several
     
    4948Depends: ${shlibs:Depends}, i2p-router
    5049Homepage: https://geti2p.net/
    51 Description: I2P libjbigi library
     50Description: Invisible Internet Project (I2P) - libjbigi library
    5251 This Package contains the libjbigi JNI library (and on x86 platforms, jcpuid).
    5352 .
     
    6362Depends: ${misc:Depends}
    6463Suggests: i2p, default-jdk-doc
    65 Description: I2P developer documentation
     64Description: Invisible Internet Project (I2P) - developer documentation
    6665 I2P is an anonymizing network, offering a simple layer that identity-sensitive
    6766 applications can use to securely communicate. All data is wrapped with several
     
    8988 ,privoxy
    9089 ,syndie
    91 Description: Router for I2P
     90Description: Invisible Internet Project (I2P) - Router
    9291 I2P is an anonymizing network, offering a simple layer that identity-sensitive
    9392 applications can use to securely communicate. All data is wrapped with several
  • debian-alt/precise/control

    re380b26 r491cd0a  
    1010 ,debconf
    1111 ,openjdk-7-jdk
    12 # Ant requires java 6 tools.jar:
    13 # Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar
    14  ,openjdk-6-jdk
    1512 ,glassfish-javaee
    1613 ,dh-apparmor
     14 ,dh-systemd
    1715 ,bash-completion
    1816 ,gettext
  • debian-alt/trusty/control

    re380b26 r491cd0a  
    1010 ,debconf
    1111 ,openjdk-7-jdk
    12 # Ant requires java 6 tools.jar:
    13 # Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar
    14  ,openjdk-6-jdk
    1512 ,glassfish-javaee
    1613 ,dh-apparmor
  • debian/po/sv.po

    re380b26 r491cd0a  
    22# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
    33# This file is distributed under the same license as the PACKAGE package.
    4 # 
     4#
    55# Translators:
    66# Anders Nilsson <anders@devode.se>, 2015
     
    1212msgstr ""
    1313"Project-Id-Version: I2P\n"
    14 "Report-Msgid-Bugs-To: https://trac.i2p2.de/\n"
    15 "POT-Creation-Date: 2015-02-18 22:14+0000\n"
    16 "PO-Revision-Date: 2017-06-30 21:32+0000\n"
    17 "Last-Translator: Jony\n"
    18 "Language-Team: Swedish (Sweden) (http://www.transifex.com/otf/I2P/language/sv_SE/)\n"
     14"Report-Msgid-Bugs-To: i2p@packages.debian.org\n"
     15"POT-Creation-Date: 2017-11-12 14:01+0000\n"
     16"PO-Revision-Date: 2019-03-26 06:10+0100\n"
     17"Last-Translator: Jonatan Nyberg <jonatan.nyberg.karl@gmail.com>\n"
     18"Language-Team: Swedish (Sweden) (http://www.transifex.com/otf/I2P/language/"
     19"sv_SE/)\n"
     20"Language: sv_SE\n"
    1921"MIME-Version: 1.0\n"
    2022"Content-Type: text/plain; charset=UTF-8\n"
    2123"Content-Transfer-Encoding: 8bit\n"
    22 "Language: sv_SE\n"
    2324"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     25"X-Generator: Poedit 2.2.1\n"
    2426
    2527#. Type: boolean
     
    2729#: ../i2p.templates:2001
    2830msgid "Should the I2P router be started at boot?"
    29 msgstr "Ska I2P routern startas vid systemstart?"
     31msgstr "Ska I2P-routern startas vid systemstart?"
    3032
    3133#. Type: boolean
     
    3537"The I2P router can be run as a daemon that starts automatically when your "
    3638"computer boots up. This is the recommended configuration."
    37 msgstr "I2P routern kan köras som en tjänst (demon) som automatiskt startas när datorn startas. Detta är den rekommenderade konfigurationen. "
     39msgstr ""
     40"I2P-routern kan köras som en tjänst (demon) som automatiskt startas när "
     41"datorn startas. Detta är den rekommenderade konfigurationen."
    3842
    3943#. Type: string
     
    4751#: ../i2p.templates:3001
    4852msgid ""
    49 "By default I2P is configured to run under the account i2psvc when running as"
    50 " a daemon. To use an **existing** I2P profile you may enter a different "
    51 "account name here. For example, if your previous I2P installation is at "
    52 "/home/user/i2p, you may enter 'user' here."
    53 msgstr "Som standard är I2P inställt för att köras under användaren i2psvc när det körs som tjänst. För att använda ett **existerande** I2P profil, ange en annan användare här. Exempelvis, om din tidigare I2P installation är /home/user/i2p så ange 'user' här."
     53"By default I2P is configured to run under the account i2psvc when running as "
     54"a daemon. To use an **existing** I2P profile you may enter a different "
     55"account name here. For example, if your previous I2P installation is at /"
     56"home/user/i2p, you may enter 'user' here."
     57msgstr ""
     58"Som standard är I2P konfigurerad för att köras under användaren i2psvc när "
     59"det körs som tjänst. Om du vill använda en **befintlig** I2P-profil kan du "
     60"ange ett annat kontonamn här. Till exempel, om din tidigare I2P-installation "
     61"är på /home/user/I2P, kan du ange \"användare\" här."
    5462
    5563#. Type: string
     
    5967"Very important: If a user other than the default of 'i2psvc' is entered "
    6068"here, the chosen username *MUST* already exist."
    61 msgstr "OBS! Viktigt: Om en annan användare än standard 'i2psvc' skrivs in här. *MÅSTE* det användarnamnet redan existera."
     69msgstr ""
     70"Mycket viktigt: om en annan användare än standard 'i2psvc' anges här, "
     71"*MÅSTE* det valda användarnamnet *redan finnas."
    6272
    6373#. Type: string
     
    7181#: ../i2p.templates:4001
    7282msgid "By default, I2P will only be allowed to use up to 128MB of RAM."
    73 msgstr "Som standard kommer I2P bara att använda  up till 128MB RAM."
     83msgstr "Som standard får I2P endast använda upp till 128 MB RAM."
    7484
    7585#. Type: string
     
    7989"High bandwidth routers, as well as routers with a lot of active torrents / "
    8090"plugins, may need to have this value increased."
    81 msgstr "För routrar med hög bandbredd eller routrar med hög aktivitet kan detta behöva ökas"
     91msgstr ""
     92"För routrar med hög bandbredd samt routrar med en hel del aktiva torrenter / "
     93"insticksmoduler, kan detta värde behöva ökas."
    8294
    8395#. Type: boolean
    8496#. Description
    8597#: ../i2p.templates:5001
    86 msgid "Run I2P daemon confined with AppArmor"
    87 msgstr "Kör I2P begränsad av AppArmor"
     98msgid "Should the I2P daemon be confined with AppArmor?"
     99msgstr "Ska I2P-demonen vara begränsad med AppArmor?"
    88100
    89101#. Type: boolean
     
    93105"With this option enabled I2P will be sandboxed with AppArmor, restricting "
    94106"which files and directories may be accessed by I2P."
    95 msgstr "Med det här valet aktiverat kommer I2P att köras i sandlåda med AppArmor, som begränsar vilka filer och mappar som kan kommas åt av I2P."
     107msgstr ""
     108"Med det här alternativet aktiverat kommer I2P att köras i sandlåda med "
     109"AppArmor, som begränsar vilka filer och mappar som kan kommas åt av I2P."
  • history.txt

    re380b26 r491cd0a  
     12019-03-27 zzz
     2 * NetDB: Cache blinding data for lookups and decryption (proposal #123)
     3
     42019-03-23 zzz
     5 * Data: Preliminary work on new b32 format (proposal #149)
     6 * SelfSignedGenerator:
     7   - Fix generation with Ed25519ph keys (ticket #2465)
     8   - Increase serial number from 63 to 71 bits
     9 * SusiDNS: Add import feature (ticket #2447)
     10
    1112019-03-22 zzz
    212 * i2ptunnel: Escape {} in URLs (ticket #2130)
  • router/java/src/net/i2p/router/NetworkDatabaseFacade.java

    re380b26 r491cd0a  
    1414import java.util.Set;
    1515
     16import net.i2p.data.BlindData;
    1617import net.i2p.data.DatabaseEntry;
    1718import net.i2p.data.Destination;
    1819import net.i2p.data.Hash;
    1920import net.i2p.data.LeaseSet;
     21import net.i2p.data.SigningPublicKey;
    2022import net.i2p.data.router.RouterInfo;
    2123import net.i2p.router.networkdb.reseed.ReseedChecker;
     
    162164     */
    163165    public boolean isNegativeCachedForever(Hash key) { return false; }
     166   
     167    /**
     168     *  @param spk unblinded key
     169     *  @return BlindData or null
     170     *  @since 0.9.40
     171     */
     172    public BlindData getBlindData(SigningPublicKey spk) {
     173        return null;
     174    }
     175   
     176    /**
     177     *  @param bd new BlindData to put in the cache
     178     *  @since 0.9.40
     179     */
     180    public void setBlindData(BlindData bd) {}
    164181}
  • router/java/src/net/i2p/router/RouterVersion.java

    re380b26 r491cd0a  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 1;
     21    public final static long BUILD = 2;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/client/ClientConnectionRunner.java

    re380b26 r491cd0a  
    609609     * updated.  This takes care of all the LeaseRequestState stuff (including firing any jobs)
    610610     *
    611      * @param ls, if encrypted, the encrypted LS, not the decrypted one
     611     * @param ls if encrypted, the encrypted LS, not the decrypted one
    612612     */
    613613    void leaseSetCreated(LeaseSet ls) {
  • router/java/src/net/i2p/router/client/LookupDestJob.java

    re380b26 r491cd0a  
    1010import net.i2p.data.Base32;
    1111import net.i2p.data.BlindData;
     12import net.i2p.data.DatabaseEntry;
    1213import net.i2p.data.Destination;
     14import net.i2p.data.EncryptedLeaseSet;
    1315import net.i2p.data.Hash;
    1416import net.i2p.data.LeaseSet;
     17import net.i2p.data.SigningPublicKey;
    1518import net.i2p.data.i2cp.DestReplyMessage;
    1619import net.i2p.data.i2cp.HostReplyMessage;
     
    3538    private final SessionId _sessID;
    3639    private final Hash _fromLocalDest;
     40    private final BlindData _blindData;
    3741
    3842    private static final long DEFAULT_TIMEOUT = 15*1000;
     
    7074        _sessID = sessID;
    7175        _fromLocalDest = fromLocalDest;
     76        BlindData bd = null;
    7277        if (name != null && name.length() >= 60) {
    7378            // convert a b32 lookup to a hash lookup
     
    8388                    } else if (b.length >= 35) {
    8489                        // encrypted LS2
     90                        // lookup the blinded hash
    8591                        try {
    86                             BlindData bd = Blinding.decode(context, b);
     92                            bd = Blinding.decode(context, b);
     93                            SigningPublicKey spk = bd.getUnblindedPubKey();
     94                            BlindData bd2 = getContext().netDb().getBlindData(spk);
     95                            if (bd2 != null) {
     96                                bd = bd2;
     97                            } else {
     98                                getContext().netDb().setBlindData(bd);
     99                            }
    87100                            h = bd.getBlindedHash();
    88101                            if (_log.shouldDebug())
     
    92105                            if (_log.shouldWarn())
    93106                                _log.debug("Failed blinding conversion of " + name, re);
    94                             // lookup as a name, which will probably fail
     107                            // Do NOT lookup as a name, naming service will call us again and infinite loop
     108                            name = null;
     109                            // h and name both null, runJob will fail immediately
    95110                        }
    96111                    }
     
    100115        _hash = h;
    101116        _name = name;
     117        _blindData = bd;
    102118    }
    103119   
     
    108124
    109125    public void runJob() {
     126        if (_blindData != null) {
     127            Destination d = _blindData.getDestination();
     128            if (d != null) {
     129                if (_log.shouldDebug())
     130                    _log.debug("Found cached b33 lookup " + _name + " to " + d);
     131                returnDest(d);
     132                return;
     133            }
     134        }
    110135        if (_name != null) {
    111136            // inline, ignore timeout
     
    120145                returnFail();
    121146            }
     147        } else if (_hash != null) {
     148            DoneJob done = new DoneJob(getContext());
     149            // TODO tell router this is an encrypted lookup, skip 38 or earlier ffs?
     150            getContext().netDb().lookupDestination(_hash, done, _timeout, _fromLocalDest);
    122151        } else {
    123             DoneJob done = new DoneJob(getContext());
    124             getContext().netDb().lookupDestination(_hash, done, _timeout, _fromLocalDest);
     152            // blinding decode fail
     153            returnFail();
    125154        }
    126155    }
     
    133162        public void runJob() {
    134163            Destination dest = getContext().netDb().lookupDestinationLocally(_hash);
     164            if (dest == null && _blindData != null) {
     165                // TODO store and lookup original hash instead
     166                LeaseSet ls = getContext().netDb().lookupLeaseSetLocally(_hash);
     167                if (ls != null && ls.getType() == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     168                    // already decrypted
     169                    EncryptedLeaseSet encls = (EncryptedLeaseSet) ls;
     170                    LeaseSet decls = encls.getDecryptedLeaseSet();
     171                    if (decls != null) {
     172                        dest = decls.getDestination();
     173                    }
     174                }
     175            }
    135176            if (dest != null) {
    136177                if (_log.shouldDebug())
     
    164205        if (_reqID >= 0)
    165206            msg = new HostReplyMessage(_sessID, HostReplyMessage.RESULT_FAILURE, _reqID);
     207        else if (_hash != null)
     208            msg = new DestReplyMessage(_hash);
    166209        else
    167             msg = new DestReplyMessage(_hash);
     210            return; // shouldn't happen
    168211        try {
    169212            _runner.doSend(msg);
  • router/java/src/net/i2p/router/message/SendMessageDirectJob.java

    re380b26 r491cd0a  
    7777        if (timeoutMs < 10*1000) {
    7878            if (_log.shouldLog(Log.WARN))
    79                 _log.warn("Very little time given [" + timeoutMs + "], resetting to 5s", new Exception("stingy caller!"));
     79                _log.warn("Very little time given [" + timeoutMs + "], resetting to 10s", new Exception("stingy caller!"));
    8080            _expiration = ctx.clock().now() + 10*1000;
    8181        } else {
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    re380b26 r491cd0a  
    2222import net.i2p.crypto.SigAlgo;
    2323import net.i2p.crypto.SigType;
     24import net.i2p.data.BlindData;
    2425import net.i2p.data.Certificate;
    2526import net.i2p.data.DatabaseEntry;
     
    2728import net.i2p.data.DataHelper;
    2829import net.i2p.data.Destination;
     30import net.i2p.data.EncryptedLeaseSet;
    2931import net.i2p.data.Hash;
    3032import net.i2p.data.KeyCertificate;
    3133import net.i2p.data.LeaseSet;
    3234import net.i2p.data.LeaseSet2;
     35import net.i2p.data.SigningPublicKey;
    3336import net.i2p.data.i2np.DatabaseLookupMessage;
    3437import net.i2p.data.i2np.DatabaseStoreMessage;
     
    7477    private NegativeLookupCache _negativeCache;
    7578    protected final int _networkID;
     79    private final BlindCache _blindCache;
    7680
    7781    /**
     
    172176        _activeRequests = new HashMap<Hash, SearchJob>(8);
    173177        _reseedChecker = new ReseedChecker(context);
     178        _blindCache = new BlindCache(context);
    174179        context.statManager().createRateStat("netDb.lookupDeferred", "how many lookups are deferred?", "NetworkDatabase", new long[] { 60*60*1000 });
    175180        context.statManager().createRateStat("netDb.exploreKeySet", "how many keys are queued for exploration?", "NetworkDatabase", new long[] { 60*60*1000 });
     
    247252        _exploreKeys.clear(); // hope this doesn't cause an explosion, it shouldn't.
    248253        // _exploreKeys = null;
    249         _negativeCache.clear();
     254        if (_negativeCache != null)
     255            _negativeCache.clear();
     256        _blindCache.shutdown();
    250257    }
    251258   
     
    258265        _ds.restart();
    259266        _exploreKeys.clear();
     267        _blindCache.startup();
    260268
    261269        _initialized = true;
     
    288296        _dbDir = dbDir;
    289297        _negativeCache = new NegativeLookupCache(_context);
     298        _blindCache.startup();
    290299       
    291300        createHandlers();
     
    465474   
    466475    /**
     476     *  @param spk unblinded key
     477     *  @return BlindData or null
     478     *  @since 0.9.40
     479     */
     480    @Override
     481    public BlindData getBlindData(SigningPublicKey spk) {
     482        return _blindCache.getData(spk);
     483    }
     484   
     485    /**
     486     *  @param bd new BlindData to put in the cache
     487     *  @since 0.9.40
     488     */
     489    @Override
     490    public void setBlindData(BlindData bd) {
     491        if (_log.shouldWarn())
     492            _log.warn("Adding to blind cache: " + bd);
     493        _blindCache.addToCache(bd);
     494    }
     495   
     496    /**
    467497     *  @return RouterInfo, LeaseSet, or null, validated
    468498     *  @since 0.8.3
     
    477507        if (DatabaseEntry.isLeaseSet(type)) {
    478508            LeaseSet ls = (LeaseSet)rv;
    479             if (ls.isCurrent(Router.CLOCK_FUDGE_FACTOR))
     509            if (ls.isCurrent(Router.CLOCK_FUDGE_FACTOR)) {
    480510                return rv;
    481             else
     511            } else {
     512                key = _blindCache.getHash(key);
    482513                fail(key);
     514            }
    483515        } else if (type == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
    484516            try {
     
    534566            //if (_log.shouldLog(Log.DEBUG))
    535567            //    _log.debug("leaseSet not found locally, running search");
     568            key = _blindCache.getHash(key);
    536569            search(key, onFindJob, onFailedLookupJob, timeoutMs, true, fromLocalDest);
    537570        }
     
    550583    public void lookupLeaseSetRemotely(Hash key, Hash fromLocalDest) {
    551584        if (!_initialized) return;
     585        key = _blindCache.getHash(key);
    552586        search(key, null, null, 20*1000, true, fromLocalDest);
    553587    }
     
    565599                    return ls;
    566600                } else {
     601                    key = _blindCache.getHash(key);
    567602                    fail(key);
    568603                    // this was an interesting key, so either refetch it or simply explore with it
     
    600635            _context.jobQueue().addJob(onFinishedJob);
    601636        } else {
     637            key = _blindCache.getHash(key);
    602638            search(key, onFinishedJob, onFinishedJob, timeoutMs, true, fromLocalDest);
    603639        }
     
    893929            throw new IllegalArgumentException("LS Hash collision");
    894930
     931        EncryptedLeaseSet encls = null;
     932        if (leaseSet.getType() == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     933            // set dest or key before validate() calls verifySignature() which
     934            // will do the decryption
     935            BlindData bd = _blindCache.getReverseData(leaseSet.getSigningKey());
     936            if (bd != null) {
     937                if (_log.shouldWarn())
     938                    _log.warn("Found blind data for encls: " + bd);
     939                encls = (EncryptedLeaseSet) leaseSet;
     940                Destination dest = bd.getDestination();
     941                if (dest != null) {
     942                    encls.setDestination(dest);
     943                } else {
     944                    encls.setSigningKey(bd.getUnblindedPubKey());
     945                }
     946            } else {
     947                if (_log.shouldWarn())
     948                    _log.warn("No blind data found for encls: " + encls);
     949            }
     950        }
     951
     952
    895953        String err = validate(key, leaseSet);
    896954        if (err != null)
     
    899957        _ds.put(key, leaseSet);
    900958       
     959        if (encls != null) {
     960            // we now have decrypted it, store it as well
     961            LeaseSet decls = encls.getDecryptedLeaseSet();
     962            if (decls != null) {
     963                if (_log.shouldWarn())
     964                    _log.warn("Successfully decrypted encls: " + decls);
     965                // recursion
     966                Destination dest = decls.getDestination();
     967                store(dest.getHash(), decls);
     968                _blindCache.setBlinded(dest);
     969            }
     970        }
     971
    901972        // Iterate through the old failure / success count, copying over the old
    902973        // values (if any tunnels overlap between leaseSets).  no need to be
Note: See TracChangeset for help on using the changeset viewer.