Changeset 491cd0a
- Timestamp:
- Apr 2, 2019 5:32:39 PM (2 years ago)
- Branches:
- master
- Children:
- b7d980d
- Parents:
- e380b26 (diff), 567bccb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 2 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java
re380b26 r491cd0a 1248 1248 } else if(ahelperPresent) { 1249 1249 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")) { 1251 1251 header = getErrorPage("nols", ERR_DESTINATION_UNKNOWN); 1252 1252 extraMessage = _t("Destination lease set not found"); -
apps/sam/java/src/net/i2p/sam/SAMUtils.java
re380b26 r491cd0a 172 172 if (s.length() >= 516) 173 173 msg = "Bad Base64 dest: "; 174 else if (s.length() == 60 && s.endsWith(".b32.i2p"))174 else if (s.length() >= 60 && s.endsWith(".b32.i2p")) 175 175 msg = "Lease set not found: "; 176 176 else -
core/java/src/net/i2p/crypto/Blinding.java
re380b26 r491cd0a 219 219 * 220 220 * @param b 35+ bytes 221 * @return BlindData structure, use getUnblindedPubKey() for the result 221 222 * @throws IllegalArgumentException on bad inputs 222 223 * @throws UnsupportedOperationException unless supported SigTypes … … 314 315 } 315 316 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 316 326 /****** 317 327 public static void main(String args[]) throws Exception { -
core/java/src/net/i2p/crypto/SelfSignedGenerator.java
re380b26 r491cd0a 250 250 if (!cpub.equals(jpub)) { 251 251 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")) { 253 254 // X509Certificate will sometimes contain an X509Key rather than the EdDSAPublicKey itself; the contained 254 255 // 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 116 116 byte decoded[] = decode(DataHelper.getUTF8(read(in))); 117 117 if (decoded == null) { 118 System. out.println("FAIL");118 System.err.println("FAIL"); 119 119 return; 120 120 } -
core/java/src/net/i2p/data/BlindData.java
re380b26 r491cd0a 26 26 27 27 /** 28 * @param secret may be null or zero-length 28 29 * @throws IllegalArgumentException on various errors 29 30 */ … … 34 35 35 36 /** 37 * @param secret may be null or zero-length 36 38 * @throws IllegalArgumentException on various errors 37 39 */ … … 41 43 _blindType = blindType; 42 44 _secret = secret; 43 _authType = 0;45 _authType = -1; 44 46 _authKey = null; 45 47 // defer until needed … … 48 50 49 51 /** 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 51 67 */ 52 68 public synchronized SigningPublicKey getBlindedPubKey() { 53 69 calculate(); 54 70 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; 55 78 } 56 79 … … 100 123 101 124 /** 102 * @return 0for no client auth125 * @return -1 for no client auth 103 126 */ 104 127 public int getAuthType() { 105 128 return _authType; 129 } 130 131 /** 132 * @return null for no client auth 133 */ 134 public PrivateKey getAuthPrivKey() { 135 return _authKey; 106 136 } 107 137 … … 128 158 _blindHash = _context.sha().calculateHash(hashData); 129 159 } 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 } 130 186 } -
core/java/src/net/i2p/data/DatabaseEntry.java
re380b26 r491cd0a 60 60 61 61 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; 64 65 65 66 /** … … 154 155 RoutingKeyGenerator gen = ctx.routingKeyGenerator(); 155 156 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; 159 163 } 160 return _currentRoutingKey;161 164 } 162 165 -
core/java/src/net/i2p/data/EncryptedLeaseSet.java
re380b26 r491cd0a 34 34 private Hash __calculatedHash; 35 35 private SigningPrivateKey _alpha; 36 // to decrypt with if we don't have full dest 37 private SigningPublicKey _unblindedSPK; 36 38 private String _secret; 37 39 private final Log _log; … … 121 123 } 122 124 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 123 139 SigType type = spk.getType(); 124 140 if (type != SigType.EdDSA_SHA512_Ed25519 && 125 141 type != SigType.RedDSA_SHA512_Ed25519) 126 142 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); 128 150 if (_signingKey == null) 129 151 _signingKey = bpk; … … 140 162 * @since 0.9.39 141 163 */ 142 private SigningPublicKey blind() { 143 SigningPublicKey spk = _destination.getSigningPublicKey(); 164 private SigningPublicKey blind(SigningPublicKey spk) { 144 165 I2PAppContext ctx = I2PAppContext.getGlobalContext(); 145 166 if (_published <= 0) 146 _alpha = Blinding.generateAlpha(ctx, _destination.getSigningPublicKey(), _secret);167 _alpha = Blinding.generateAlpha(ctx, spk, _secret); 147 168 else 148 _alpha = Blinding.generateAlpha(ctx, _destination.getSigningPublicKey(), _secret, _published);169 _alpha = Blinding.generateAlpha(ctx, spk, _secret, _published); 149 170 SigningPublicKey rv = Blinding.blind(spk, _alpha); 150 171 if (_log.shouldDebug()) … … 477 498 */ 478 499 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(); 483 503 byte[] in = new byte[spklen + 4]; 484 504 // 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()); 487 507 DataHelper.toLong(in, spklen + 2, 2, SigType.RedDSA_SHA512_Ed25519.getCode()); 488 508 byte[] credential = hash(ctx, CREDENTIAL, in); … … 573 593 } 574 594 _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")); 577 598 return true; 578 599 } -
core/java/src/net/i2p/data/PrivateKey.java
re380b26 r491cd0a 11 11 12 12 import java.util.Arrays; 13 import javax.security.auth.Destroyable; 13 14 14 15 import net.i2p.crypto.EncType; 15 16 import net.i2p.crypto.KeyGenerator; 17 import net.i2p.util.SimpleByteCache; 16 18 17 19 /** … … 25 27 * @author jrandom 26 28 */ 27 public class PrivateKey extends SimpleDataStructure {29 public class PrivateKey extends SimpleDataStructure implements Destroyable { 28 30 private static final EncType DEF_TYPE = EncType.ELGAMAL_2048; 29 31 public final static int KEYSIZE_BYTES = DEF_TYPE.getPrivkeyLen(); … … 91 93 92 94 /** 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 /** 93 118 * @since 0.9.38 94 119 */ … … 96 121 public String toString() { 97 122 StringBuilder buf = new StringBuilder(64); 98 buf.append("[PrivateKey ").append(_type).append( ": ");123 buf.append("[PrivateKey ").append(_type).append(' '); 99 124 int length = length(); 100 125 if (_data == null) { -
core/java/src/net/i2p/data/SigningPrivateKey.java
re380b26 r491cd0a 11 11 12 12 import java.util.Arrays; 13 import javax.security.auth.Destroyable; 13 14 14 15 import net.i2p.crypto.Blinding; 15 16 import net.i2p.crypto.KeyGenerator; 16 17 import net.i2p.crypto.SigType; 18 import net.i2p.util.SimpleByteCache; 17 19 18 20 /** … … 27 29 * @author jrandom 28 30 */ 29 public class SigningPrivateKey extends SimpleDataStructure {31 public class SigningPrivateKey extends SimpleDataStructure implements Destroyable { 30 32 private static final SigType DEF_TYPE = SigType.DSA_SHA1; 31 33 public final static int KEYSIZE_BYTES = DEF_TYPE.getPrivkeyLen(); … … 117 119 118 120 /** 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 /** 119 144 * @since 0.9.8 120 145 */ … … 122 147 public String toString() { 123 148 StringBuilder buf = new StringBuilder(64); 124 buf.append("[SigningPrivateKey ").append(_type).append( ": ");149 buf.append("[SigningPrivateKey ").append(_type).append(' '); 125 150 int length = length(); 126 151 if (_data == null) { -
debian-alt/jessie/control
re380b26 r491cd0a 10 10 ,debconf 11 11 ,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.jar14 ,openjdk-6-jdk15 12 ,libtomcat8-java 16 13 ,dh-apparmor 14 ,dh-systemd 15 ,bash-completion 17 16 ,gettext 18 17 ,libgetopt-java … … 34 33 lsb-base (>= 3.0-6), 35 34 service-wrapper 36 Description: Anonymous network (I2P)35 Description: Invisible Internet Project (I2P) - anonymous network 37 36 I2P is an anonymizing network, offering a simple layer that identity-sensitive 38 37 applications can use to securely communicate. All data is wrapped with several … … 49 48 Depends: ${shlibs:Depends}, i2p-router 50 49 Homepage: https://geti2p.net/ 51 Description: I 2Plibjbigi library50 Description: Invisible Internet Project (I2P) - libjbigi library 52 51 This Package contains the libjbigi JNI library (and on x86 platforms, jcpuid). 53 52 . … … 63 62 Depends: ${misc:Depends} 64 63 Suggests: i2p, default-jdk-doc 65 Description: I 2Pdeveloper documentation64 Description: Invisible Internet Project (I2P) - developer documentation 66 65 I2P is an anonymizing network, offering a simple layer that identity-sensitive 67 66 applications can use to securely communicate. All data is wrapped with several … … 89 88 ,privoxy 90 89 ,syndie 91 Description: Router for I2P90 Description: Invisible Internet Project (I2P) - Router 92 91 I2P is an anonymizing network, offering a simple layer that identity-sensitive 93 92 applications can use to securely communicate. All data is wrapped with several -
debian-alt/precise/control
re380b26 r491cd0a 10 10 ,debconf 11 11 ,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.jar14 ,openjdk-6-jdk15 12 ,glassfish-javaee 16 13 ,dh-apparmor 14 ,dh-systemd 17 15 ,bash-completion 18 16 ,gettext -
debian-alt/trusty/control
re380b26 r491cd0a 10 10 ,debconf 11 11 ,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.jar14 ,openjdk-6-jdk15 12 ,glassfish-javaee 16 13 ,dh-apparmor -
debian/po/sv.po
re380b26 r491cd0a 2 2 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 3 # This file is distributed under the same license as the PACKAGE package. 4 # 4 # 5 5 # Translators: 6 6 # Anders Nilsson <anders@devode.se>, 2015 … … 12 12 msgstr "" 13 13 "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" 19 21 "MIME-Version: 1.0\n" 20 22 "Content-Type: text/plain; charset=UTF-8\n" 21 23 "Content-Transfer-Encoding: 8bit\n" 22 "Language: sv_SE\n"23 24 "Plural-Forms: nplurals=2; plural=(n != 1);\n" 25 "X-Generator: Poedit 2.2.1\n" 24 26 25 27 #. Type: boolean … … 27 29 #: ../i2p.templates:2001 28 30 msgid "Should the I2P router be started at boot?" 29 msgstr "Ska I2P 31 msgstr "Ska I2P-routern startas vid systemstart?" 30 32 31 33 #. Type: boolean … … 35 37 "The I2P router can be run as a daemon that starts automatically when your " 36 38 "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. " 39 msgstr "" 40 "I2P-routern kan köras som en tjänst (demon) som automatiskt startas när " 41 "datorn startas. Detta är den rekommenderade konfigurationen." 38 42 39 43 #. Type: string … … 47 51 #: ../i2p.templates:3001 48 52 msgid "" 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." 57 msgstr "" 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." 54 62 55 63 #. Type: string … … 59 67 "Very important: If a user other than the default of 'i2psvc' is entered " 60 68 "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." 69 msgstr "" 70 "Mycket viktigt: om en annan användare än standard 'i2psvc' anges här, " 71 "*MÅSTE* det valda användarnamnet *redan finnas." 62 72 63 73 #. Type: string … … 71 81 #: ../i2p.templates:4001 72 82 msgid "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."83 msgstr "Som standard får I2P endast använda upp till 128 MB RAM." 74 84 75 85 #. Type: string … … 79 89 "High bandwidth routers, as well as routers with a lot of active torrents / " 80 90 "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" 91 msgstr "" 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." 82 94 83 95 #. Type: boolean 84 96 #. Description 85 97 #: ../i2p.templates:5001 86 msgid " Run I2P daemon confined with AppArmor"87 msgstr " Kör I2P begränsad av AppArmor"98 msgid "Should the I2P daemon be confined with AppArmor?" 99 msgstr "Ska I2P-demonen vara begränsad med AppArmor?" 88 100 89 101 #. Type: boolean … … 93 105 "With this option enabled I2P will be sandboxed with AppArmor, restricting " 94 106 "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." 107 msgstr "" 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 1 2019-03-27 zzz 2 * NetDB: Cache blinding data for lookups and decryption (proposal #123) 3 4 2019-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 1 11 2019-03-22 zzz 2 12 * i2ptunnel: Escape {} in URLs (ticket #2130) -
router/java/src/net/i2p/router/NetworkDatabaseFacade.java
re380b26 r491cd0a 14 14 import java.util.Set; 15 15 16 import net.i2p.data.BlindData; 16 17 import net.i2p.data.DatabaseEntry; 17 18 import net.i2p.data.Destination; 18 19 import net.i2p.data.Hash; 19 20 import net.i2p.data.LeaseSet; 21 import net.i2p.data.SigningPublicKey; 20 22 import net.i2p.data.router.RouterInfo; 21 23 import net.i2p.router.networkdb.reseed.ReseedChecker; … … 162 164 */ 163 165 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) {} 164 181 } -
router/java/src/net/i2p/router/RouterVersion.java
re380b26 r491cd0a 19 19 public final static String ID = "Monotone"; 20 20 public final static String VERSION = CoreVersion.VERSION; 21 public final static long BUILD = 1;21 public final static long BUILD = 2; 22 22 23 23 /** for example "-test" */ -
router/java/src/net/i2p/router/client/ClientConnectionRunner.java
re380b26 r491cd0a 609 609 * updated. This takes care of all the LeaseRequestState stuff (including firing any jobs) 610 610 * 611 * @param ls ,if encrypted, the encrypted LS, not the decrypted one611 * @param ls if encrypted, the encrypted LS, not the decrypted one 612 612 */ 613 613 void leaseSetCreated(LeaseSet ls) { -
router/java/src/net/i2p/router/client/LookupDestJob.java
re380b26 r491cd0a 10 10 import net.i2p.data.Base32; 11 11 import net.i2p.data.BlindData; 12 import net.i2p.data.DatabaseEntry; 12 13 import net.i2p.data.Destination; 14 import net.i2p.data.EncryptedLeaseSet; 13 15 import net.i2p.data.Hash; 14 16 import net.i2p.data.LeaseSet; 17 import net.i2p.data.SigningPublicKey; 15 18 import net.i2p.data.i2cp.DestReplyMessage; 16 19 import net.i2p.data.i2cp.HostReplyMessage; … … 35 38 private final SessionId _sessID; 36 39 private final Hash _fromLocalDest; 40 private final BlindData _blindData; 37 41 38 42 private static final long DEFAULT_TIMEOUT = 15*1000; … … 70 74 _sessID = sessID; 71 75 _fromLocalDest = fromLocalDest; 76 BlindData bd = null; 72 77 if (name != null && name.length() >= 60) { 73 78 // convert a b32 lookup to a hash lookup … … 83 88 } else if (b.length >= 35) { 84 89 // encrypted LS2 90 // lookup the blinded hash 85 91 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 } 87 100 h = bd.getBlindedHash(); 88 101 if (_log.shouldDebug()) … … 92 105 if (_log.shouldWarn()) 93 106 _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 95 110 } 96 111 } … … 100 115 _hash = h; 101 116 _name = name; 117 _blindData = bd; 102 118 } 103 119 … … 108 124 109 125 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 } 110 135 if (_name != null) { 111 136 // inline, ignore timeout … … 120 145 returnFail(); 121 146 } 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); 122 151 } else { 123 DoneJob done = new DoneJob(getContext());124 getContext().netDb().lookupDestination(_hash, done, _timeout, _fromLocalDest);152 // blinding decode fail 153 returnFail(); 125 154 } 126 155 } … … 133 162 public void runJob() { 134 163 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 } 135 176 if (dest != null) { 136 177 if (_log.shouldDebug()) … … 164 205 if (_reqID >= 0) 165 206 msg = new HostReplyMessage(_sessID, HostReplyMessage.RESULT_FAILURE, _reqID); 207 else if (_hash != null) 208 msg = new DestReplyMessage(_hash); 166 209 else 167 msg = new DestReplyMessage(_hash);210 return; // shouldn't happen 168 211 try { 169 212 _runner.doSend(msg); -
router/java/src/net/i2p/router/message/SendMessageDirectJob.java
re380b26 r491cd0a 77 77 if (timeoutMs < 10*1000) { 78 78 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!")); 80 80 _expiration = ctx.clock().now() + 10*1000; 81 81 } else { -
router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java
re380b26 r491cd0a 22 22 import net.i2p.crypto.SigAlgo; 23 23 import net.i2p.crypto.SigType; 24 import net.i2p.data.BlindData; 24 25 import net.i2p.data.Certificate; 25 26 import net.i2p.data.DatabaseEntry; … … 27 28 import net.i2p.data.DataHelper; 28 29 import net.i2p.data.Destination; 30 import net.i2p.data.EncryptedLeaseSet; 29 31 import net.i2p.data.Hash; 30 32 import net.i2p.data.KeyCertificate; 31 33 import net.i2p.data.LeaseSet; 32 34 import net.i2p.data.LeaseSet2; 35 import net.i2p.data.SigningPublicKey; 33 36 import net.i2p.data.i2np.DatabaseLookupMessage; 34 37 import net.i2p.data.i2np.DatabaseStoreMessage; … … 74 77 private NegativeLookupCache _negativeCache; 75 78 protected final int _networkID; 79 private final BlindCache _blindCache; 76 80 77 81 /** … … 172 176 _activeRequests = new HashMap<Hash, SearchJob>(8); 173 177 _reseedChecker = new ReseedChecker(context); 178 _blindCache = new BlindCache(context); 174 179 context.statManager().createRateStat("netDb.lookupDeferred", "how many lookups are deferred?", "NetworkDatabase", new long[] { 60*60*1000 }); 175 180 context.statManager().createRateStat("netDb.exploreKeySet", "how many keys are queued for exploration?", "NetworkDatabase", new long[] { 60*60*1000 }); … … 247 252 _exploreKeys.clear(); // hope this doesn't cause an explosion, it shouldn't. 248 253 // _exploreKeys = null; 249 _negativeCache.clear(); 254 if (_negativeCache != null) 255 _negativeCache.clear(); 256 _blindCache.shutdown(); 250 257 } 251 258 … … 258 265 _ds.restart(); 259 266 _exploreKeys.clear(); 267 _blindCache.startup(); 260 268 261 269 _initialized = true; … … 288 296 _dbDir = dbDir; 289 297 _negativeCache = new NegativeLookupCache(_context); 298 _blindCache.startup(); 290 299 291 300 createHandlers(); … … 465 474 466 475 /** 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 /** 467 497 * @return RouterInfo, LeaseSet, or null, validated 468 498 * @since 0.8.3 … … 477 507 if (DatabaseEntry.isLeaseSet(type)) { 478 508 LeaseSet ls = (LeaseSet)rv; 479 if (ls.isCurrent(Router.CLOCK_FUDGE_FACTOR)) 509 if (ls.isCurrent(Router.CLOCK_FUDGE_FACTOR)) { 480 510 return rv; 481 else 511 } else { 512 key = _blindCache.getHash(key); 482 513 fail(key); 514 } 483 515 } else if (type == DatabaseEntry.KEY_TYPE_ROUTERINFO) { 484 516 try { … … 534 566 //if (_log.shouldLog(Log.DEBUG)) 535 567 // _log.debug("leaseSet not found locally, running search"); 568 key = _blindCache.getHash(key); 536 569 search(key, onFindJob, onFailedLookupJob, timeoutMs, true, fromLocalDest); 537 570 } … … 550 583 public void lookupLeaseSetRemotely(Hash key, Hash fromLocalDest) { 551 584 if (!_initialized) return; 585 key = _blindCache.getHash(key); 552 586 search(key, null, null, 20*1000, true, fromLocalDest); 553 587 } … … 565 599 return ls; 566 600 } else { 601 key = _blindCache.getHash(key); 567 602 fail(key); 568 603 // this was an interesting key, so either refetch it or simply explore with it … … 600 635 _context.jobQueue().addJob(onFinishedJob); 601 636 } else { 637 key = _blindCache.getHash(key); 602 638 search(key, onFinishedJob, onFinishedJob, timeoutMs, true, fromLocalDest); 603 639 } … … 893 929 throw new IllegalArgumentException("LS Hash collision"); 894 930 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 895 953 String err = validate(key, leaseSet); 896 954 if (err != null) … … 899 957 _ds.put(key, leaseSet); 900 958 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 901 972 // Iterate through the old failure / success count, copying over the old 902 973 // values (if any tunnels overlap between leaseSets). no need to be
Note: See TracChangeset
for help on using the changeset viewer.