Reorganised Guice modules. Contribute entropy to pool on Linux/Android.

This commit is contained in:
akwizgran
2014-01-14 19:33:17 +00:00
parent 46863b8c1b
commit 8886d954d7
45 changed files with 327 additions and 178 deletions

View File

@@ -30,8 +30,8 @@ import org.briarproject.api.crypto.PrivateKey;
import org.briarproject.api.crypto.PseudoRandom;
import org.briarproject.api.crypto.PublicKey;
import org.briarproject.api.crypto.SecretKey;
import org.briarproject.api.crypto.SeedProvider;
import org.briarproject.api.crypto.Signature;
import org.briarproject.api.system.SeedProvider;
import org.briarproject.util.ByteUtils;
import org.spongycastle.crypto.AsymmetricCipherKeyPair;
import org.spongycastle.crypto.BlockCipher;

View File

@@ -14,9 +14,7 @@ import javax.inject.Singleton;
import org.briarproject.api.crypto.CryptoComponent;
import org.briarproject.api.crypto.CryptoExecutor;
import org.briarproject.api.crypto.PasswordStrengthEstimator;
import org.briarproject.api.crypto.SeedProvider;
import org.briarproject.api.lifecycle.LifecycleManager;
import org.briarproject.util.OsUtils;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
@@ -41,9 +39,6 @@ public class CryptoModule extends AbstractModule {
}
protected void configure() {
if(OsUtils.isAndroid() || OsUtils.isLinux()) {
bind(SeedProvider.class).to(LinuxSeedProvider.class);
}
bind(CryptoComponent.class).to(
CryptoComponentImpl.class).in(Singleton.class);
bind(PasswordStrengthEstimator.class).to(

View File

@@ -1,23 +0,0 @@
package org.briarproject.crypto;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import org.briarproject.api.crypto.SeedProvider;
class LinuxSeedProvider implements SeedProvider {
public byte[] getSeed() {
byte[] seed = new byte[SEED_BYTES];
try {
DataInputStream in = new DataInputStream(
new FileInputStream("/dev/urandom"));
in.readFully(seed);
in.close();
} catch(IOException e) {
throw new RuntimeException(e);
}
return seed;
}
}