Refactoring: renamed 'security' to 'cryptography'

This commit is contained in:
Christian Basler 2016-01-10 13:38:32 +01:00
parent de0100e14f
commit 549c8854ed
30 changed files with 72 additions and 74 deletions

View File

@ -53,6 +53,7 @@ BitmessageContext ctx = new BitmessageContext.Builder()
.messageRepo(new JdbcMessageRepository(jdbcConfig)) .messageRepo(new JdbcMessageRepository(jdbcConfig))
.nodeRegistry(new MemoryNodeRegistry()) .nodeRegistry(new MemoryNodeRegistry())
.networkHandler(new NetworkNode()) .networkHandler(new NetworkNode())
.cryptography(new BouncyCryptography())
.build(); .build();
``` ```
This creates a simple context using a H2 database that will be created in the user's home directory. Next you'll need to This creates a simple context using a H2 database that will be created in the user's home directory. Next you'll need to

View File

@ -2,9 +2,9 @@ uploadArchives {
repositories { repositories {
mavenDeployer { mavenDeployer {
pom.project { pom.project {
name 'Jabit Bouncy Security' name 'Jabit Bouncy Cryptography'
artifactId = 'jabit-security-bouncy' artifactId = 'jabit-cryptography-bouncy'
description 'The Security implementation using bouncy castle' description 'The Cryptography implementation using bouncy castle'
} }
} }
} }

View File

@ -14,11 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
package ch.dissem.bitmessage.security.bc; package ch.dissem.bitmessage.cryptography.bc;
import ch.dissem.bitmessage.entity.payload.Pubkey; import ch.dissem.bitmessage.entity.payload.Pubkey;
import ch.dissem.bitmessage.entity.valueobject.PrivateKey; import ch.dissem.bitmessage.entity.valueobject.PrivateKey;
import ch.dissem.bitmessage.ports.AbstractSecurity; import ch.dissem.bitmessage.ports.AbstractCryptography;
import org.bouncycastle.asn1.x9.X9ECParameters; import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.BufferedBlockCipher; import org.bouncycastle.crypto.BufferedBlockCipher;
import org.bouncycastle.crypto.CipherParameters; import org.bouncycastle.crypto.CipherParameters;
@ -47,14 +47,14 @@ import java.util.Arrays;
* As Spongycastle can't be used on the Oracle JVM, and Bouncycastle doesn't work properly on Android (thanks, Google), * As Spongycastle can't be used on the Oracle JVM, and Bouncycastle doesn't work properly on Android (thanks, Google),
* this is the Bouncycastle implementation. * this is the Bouncycastle implementation.
*/ */
public class BouncySecurity extends AbstractSecurity { public class BouncyCryptography extends AbstractCryptography {
private static final X9ECParameters EC_CURVE_PARAMETERS = CustomNamedCurves.getByName("secp256k1"); private static final X9ECParameters EC_CURVE_PARAMETERS = CustomNamedCurves.getByName("secp256k1");
static { static {
java.security.Security.addProvider(new BouncyCastleProvider()); java.security.Security.addProvider(new BouncyCastleProvider());
} }
public BouncySecurity() { public BouncyCryptography() {
super("BC"); super("BC");
} }

View File

@ -5,7 +5,7 @@ import ch.dissem.bitmessage.entity.ObjectMessage;
import ch.dissem.bitmessage.entity.payload.GenericPayload; import ch.dissem.bitmessage.entity.payload.GenericPayload;
import ch.dissem.bitmessage.ports.MultiThreadedPOWEngine; import ch.dissem.bitmessage.ports.MultiThreadedPOWEngine;
import ch.dissem.bitmessage.ports.ProofOfWorkEngine; import ch.dissem.bitmessage.ports.ProofOfWorkEngine;
import ch.dissem.bitmessage.security.bc.BouncySecurity; import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
import ch.dissem.bitmessage.utils.CallbackWaiter; import ch.dissem.bitmessage.utils.CallbackWaiter;
import ch.dissem.bitmessage.utils.Singleton; import ch.dissem.bitmessage.utils.Singleton;
import ch.dissem.bitmessage.utils.UnixTime; import ch.dissem.bitmessage.utils.UnixTime;
@ -23,7 +23,7 @@ import static org.mockito.Mockito.when;
/** /**
* Created by chris on 19.07.15. * Created by chris on 19.07.15.
*/ */
public class SecurityTest { public class CryptographyTest {
public static final byte[] TEST_VALUE = "teststring".getBytes(); public static final byte[] TEST_VALUE = "teststring".getBytes();
public static final byte[] TEST_SHA1 = DatatypeConverter.parseHexBinary("" public static final byte[] TEST_SHA1 = DatatypeConverter.parseHexBinary(""
+ "b8473b86d4c2072ca9b08bd28e373e8253e865c4"); + "b8473b86d4c2072ca9b08bd28e373e8253e865c4");
@ -33,10 +33,10 @@ public class SecurityTest {
public static final byte[] TEST_RIPEMD160 = DatatypeConverter.parseHexBinary("" public static final byte[] TEST_RIPEMD160 = DatatypeConverter.parseHexBinary(""
+ "cd566972b5e50104011a92b59fa8e0b1234851ae"); + "cd566972b5e50104011a92b59fa8e0b1234851ae");
private static BouncySecurity security; private static BouncyCryptography security;
public SecurityTest() { public CryptographyTest() {
security = new BouncySecurity(); security = new BouncyCryptography();
Singleton.initialize(security); Singleton.initialize(security);
InternalContext ctx = mock(InternalContext.class); InternalContext ctx = mock(InternalContext.class);
when(ctx.getProofOfWorkEngine()).thenReturn(new MultiThreadedPOWEngine()); when(ctx.getProofOfWorkEngine()).thenReturn(new MultiThreadedPOWEngine());

View File

@ -2,9 +2,9 @@ uploadArchives {
repositories { repositories {
mavenDeployer { mavenDeployer {
pom.project { pom.project {
name 'Jabit Spongy Security' name 'Jabit Spongy Cryptography'
artifactId = 'jabit-security-spongy' artifactId = 'jabit-cryptography-spongy'
description 'The Security implementation using spongy castle (needed for Android)' description 'The Cryptography implementation using spongy castle (needed for Android)'
} }
} }
} }

View File

@ -14,11 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
package ch.dissem.bitmessage.security.sc; package ch.dissem.bitmessage.cryptography.sc;
import ch.dissem.bitmessage.entity.payload.Pubkey; import ch.dissem.bitmessage.entity.payload.Pubkey;
import ch.dissem.bitmessage.entity.valueobject.PrivateKey; import ch.dissem.bitmessage.entity.valueobject.PrivateKey;
import ch.dissem.bitmessage.ports.AbstractSecurity; import ch.dissem.bitmessage.ports.AbstractCryptography;
import org.spongycastle.asn1.x9.X9ECParameters; import org.spongycastle.asn1.x9.X9ECParameters;
import org.spongycastle.crypto.BufferedBlockCipher; import org.spongycastle.crypto.BufferedBlockCipher;
import org.spongycastle.crypto.CipherParameters; import org.spongycastle.crypto.CipherParameters;
@ -47,14 +47,14 @@ import java.util.Arrays;
* As Spongycastle can't be used on the Oracle JVM, and Bouncycastle doesn't work properly on Android (thanks, Google), * As Spongycastle can't be used on the Oracle JVM, and Bouncycastle doesn't work properly on Android (thanks, Google),
* this is the Spongycastle implementation. * this is the Spongycastle implementation.
*/ */
public class SpongySecurity extends AbstractSecurity { public class SpongyCryptography extends AbstractCryptography {
private static final X9ECParameters EC_CURVE_PARAMETERS = CustomNamedCurves.getByName("secp256k1"); private static final X9ECParameters EC_CURVE_PARAMETERS = CustomNamedCurves.getByName("secp256k1");
static { static {
java.security.Security.addProvider(new BouncyCastleProvider()); java.security.Security.addProvider(new BouncyCastleProvider());
} }
public SpongySecurity() { public SpongyCryptography() {
super("SC"); super("SC");
} }

View File

@ -24,7 +24,7 @@ dependencies {
compile project(':domain') compile project(':domain')
compile project(':networking') compile project(':networking')
compile project(':repositories') compile project(':repositories')
compile project(':security-bc') compile project(':cryptography-bc')
compile project(':wif') compile project(':wif')
compile 'org.slf4j:slf4j-simple:1.7.12' compile 'org.slf4j:slf4j-simple:1.7.12'
compile 'args4j:args4j:2.32' compile 'args4j:args4j:2.32'

View File

@ -23,7 +23,7 @@ import ch.dissem.bitmessage.entity.payload.Pubkey;
import ch.dissem.bitmessage.networking.DefaultNetworkHandler; import ch.dissem.bitmessage.networking.DefaultNetworkHandler;
import ch.dissem.bitmessage.ports.MemoryNodeRegistry; import ch.dissem.bitmessage.ports.MemoryNodeRegistry;
import ch.dissem.bitmessage.repository.*; import ch.dissem.bitmessage.repository.*;
import ch.dissem.bitmessage.security.bc.BouncySecurity; import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -49,7 +49,7 @@ public class Application {
.messageRepo(new JdbcMessageRepository(jdbcConfig)) .messageRepo(new JdbcMessageRepository(jdbcConfig))
.powRepo(new JdbcProofOfWorkRepository(jdbcConfig)) .powRepo(new JdbcProofOfWorkRepository(jdbcConfig))
.networkHandler(new DefaultNetworkHandler()) .networkHandler(new DefaultNetworkHandler())
.security(new BouncySecurity()) .cryptography(new BouncyCryptography())
.port(48444) .port(48444)
.listener(new BitmessageContext.Listener() { .listener(new BitmessageContext.Listener() {
@Override @Override

View File

@ -20,7 +20,7 @@ import ch.dissem.bitmessage.BitmessageContext;
import ch.dissem.bitmessage.networking.DefaultNetworkHandler; import ch.dissem.bitmessage.networking.DefaultNetworkHandler;
import ch.dissem.bitmessage.ports.MemoryNodeRegistry; import ch.dissem.bitmessage.ports.MemoryNodeRegistry;
import ch.dissem.bitmessage.repository.*; import ch.dissem.bitmessage.repository.*;
import ch.dissem.bitmessage.security.bc.BouncySecurity; import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
import ch.dissem.bitmessage.wif.WifExporter; import ch.dissem.bitmessage.wif.WifExporter;
import ch.dissem.bitmessage.wif.WifImporter; import ch.dissem.bitmessage.wif.WifImporter;
import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineException;
@ -53,7 +53,7 @@ public class Main {
.messageRepo(new JdbcMessageRepository(jdbcConfig)) .messageRepo(new JdbcMessageRepository(jdbcConfig))
.powRepo(new JdbcProofOfWorkRepository(jdbcConfig)) .powRepo(new JdbcProofOfWorkRepository(jdbcConfig))
.networkHandler(new DefaultNetworkHandler()) .networkHandler(new DefaultNetworkHandler())
.security(new BouncySecurity()) .cryptography(new BouncyCryptography())
.port(48444) .port(48444)
.build(); .build();

View File

@ -27,5 +27,5 @@ dependencies {
compile 'org.slf4j:slf4j-api:1.7.12' compile 'org.slf4j:slf4j-api:1.7.12'
testCompile 'junit:junit:4.11' testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.mockito:mockito-core:1.10.19'
testCompile project(':security-bc') testCompile project(':cryptography-bc')
} }

View File

@ -325,7 +325,7 @@ public class BitmessageContext {
MessageRepository messageRepo; MessageRepository messageRepo;
ProofOfWorkRepository proofOfWorkRepository; ProofOfWorkRepository proofOfWorkRepository;
ProofOfWorkEngine proofOfWorkEngine; ProofOfWorkEngine proofOfWorkEngine;
Security security; Cryptography cryptography;
MessageCallback messageCallback; MessageCallback messageCallback;
CustomCommandHandler customCommandHandler; CustomCommandHandler customCommandHandler;
Listener listener; Listener listener;
@ -372,8 +372,8 @@ public class BitmessageContext {
return this; return this;
} }
public Builder security(Security security) { public Builder cryptography(Cryptography cryptography) {
this.security = security; this.cryptography = cryptography;
return this; return this;
} }

View File

@ -42,7 +42,7 @@ import java.util.TreeSet;
public class InternalContext { public class InternalContext {
private final static Logger LOG = LoggerFactory.getLogger(InternalContext.class); private final static Logger LOG = LoggerFactory.getLogger(InternalContext.class);
private final Security security; private final Cryptography cryptography;
private final Inventory inventory; private final Inventory inventory;
private final NodeRegistry nodeRegistry; private final NodeRegistry nodeRegistry;
private final NetworkHandler networkHandler; private final NetworkHandler networkHandler;
@ -64,7 +64,7 @@ public class InternalContext {
private int connectionLimit; private int connectionLimit;
public InternalContext(BitmessageContext.Builder builder) { public InternalContext(BitmessageContext.Builder builder) {
this.security = builder.security; this.cryptography = builder.cryptography;
this.inventory = builder.inventory; this.inventory = builder.inventory;
this.nodeRegistry = builder.nodeRegistry; this.nodeRegistry = builder.nodeRegistry;
this.networkHandler = builder.networkHandler; this.networkHandler = builder.networkHandler;
@ -73,7 +73,7 @@ public class InternalContext {
this.proofOfWorkRepository = builder.proofOfWorkRepository; this.proofOfWorkRepository = builder.proofOfWorkRepository;
this.proofOfWorkService = new ProofOfWorkService(); this.proofOfWorkService = new ProofOfWorkService();
this.proofOfWorkEngine = builder.proofOfWorkEngine; this.proofOfWorkEngine = builder.proofOfWorkEngine;
this.clientNonce = security.randomNonce(); this.clientNonce = cryptography.randomNonce();
this.messageCallback = builder.messageCallback; this.messageCallback = builder.messageCallback;
this.customCommandHandler = builder.customCommandHandler; this.customCommandHandler = builder.customCommandHandler;
this.port = builder.port; this.port = builder.port;
@ -81,7 +81,7 @@ public class InternalContext {
this.connectionTTL = builder.connectionTTL; this.connectionTTL = builder.connectionTTL;
this.pubkeyTTL = builder.pubkeyTTL; this.pubkeyTTL = builder.pubkeyTTL;
Singleton.initialize(security); Singleton.initialize(cryptography);
// TODO: streams of new identities and subscriptions should also be added. This works only after a restart. // TODO: streams of new identities and subscriptions should also be added. This works only after a restart.
for (BitmessageAddress address : addressRepository.getIdentities()) { for (BitmessageAddress address : addressRepository.getIdentities()) {
@ -94,7 +94,7 @@ public class InternalContext {
streams.add(1L); streams.add(1L);
} }
init(security, inventory, nodeRegistry, networkHandler, addressRepository, messageRepository, init(cryptography, inventory, nodeRegistry, networkHandler, addressRepository, messageRepository,
proofOfWorkRepository, proofOfWorkService, proofOfWorkEngine, proofOfWorkRepository, proofOfWorkService, proofOfWorkEngine,
messageCallback, customCommandHandler); messageCallback, customCommandHandler);
for (BitmessageAddress identity : addressRepository.getIdentities()) { for (BitmessageAddress identity : addressRepository.getIdentities()) {
@ -110,8 +110,8 @@ public class InternalContext {
} }
} }
public Security getSecurity() { public Cryptography getCryptography() {
return security; return cryptography;
} }
public Inventory getInventory() { public Inventory getInventory() {
@ -203,7 +203,7 @@ public class InternalContext {
.payload(identity.getPubkey()) .payload(identity.getPubkey())
.build(); .build();
response.sign(identity.getPrivateKey()); response.sign(identity.getPrivateKey());
response.encrypt(security.createPublicKey(identity.getPublicDecryptionKey())); response.encrypt(cryptography.createPublicKey(identity.getPublicDecryptionKey()));
messageCallback.proofOfWorkStarted(identity.getPubkey()); messageCallback.proofOfWorkStarted(identity.getPubkey());
// TODO: remember that the pubkey is just about to be sent, and on which stream! // TODO: remember that the pubkey is just about to be sent, and on which stream!
proofOfWorkService.doProofOfWork(response); proofOfWorkService.doProofOfWork(response);

View File

@ -7,7 +7,7 @@ import ch.dissem.bitmessage.entity.PlaintextHolder;
import ch.dissem.bitmessage.ports.MessageRepository; import ch.dissem.bitmessage.ports.MessageRepository;
import ch.dissem.bitmessage.ports.ProofOfWorkEngine; import ch.dissem.bitmessage.ports.ProofOfWorkEngine;
import ch.dissem.bitmessage.ports.ProofOfWorkRepository; import ch.dissem.bitmessage.ports.ProofOfWorkRepository;
import ch.dissem.bitmessage.ports.Security; import ch.dissem.bitmessage.ports.Cryptography;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -21,7 +21,7 @@ import static ch.dissem.bitmessage.utils.Singleton.security;
public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalContext.ContextHolder { public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalContext.ContextHolder {
private final static Logger LOG = LoggerFactory.getLogger(ProofOfWorkService.class); private final static Logger LOG = LoggerFactory.getLogger(ProofOfWorkService.class);
private Security security; private Cryptography cryptography;
private InternalContext ctx; private InternalContext ctx;
private ProofOfWorkRepository powRepo; private ProofOfWorkRepository powRepo;
private MessageRepository messageRepo; private MessageRepository messageRepo;
@ -33,7 +33,7 @@ public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalC
LOG.info("Doing POW for " + items.size() + " tasks."); LOG.info("Doing POW for " + items.size() + " tasks.");
for (byte[] initialHash : items) { for (byte[] initialHash : items) {
ProofOfWorkRepository.Item item = powRepo.getItem(initialHash); ProofOfWorkRepository.Item item = powRepo.getItem(initialHash);
security.doProofOfWork(item.object, item.nonceTrialsPerByte, item.extraBytes, this); cryptography.doProofOfWork(item.object, item.nonceTrialsPerByte, item.extraBytes, this);
} }
} }
@ -50,10 +50,10 @@ public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalC
powRepo.putObject(object, nonceTrialsPerByte, extraBytes); powRepo.putObject(object, nonceTrialsPerByte, extraBytes);
if (object.getPayload() instanceof PlaintextHolder) { if (object.getPayload() instanceof PlaintextHolder) {
Plaintext plaintext = ((PlaintextHolder) object.getPayload()).getPlaintext(); Plaintext plaintext = ((PlaintextHolder) object.getPayload()).getPlaintext();
plaintext.setInitialHash(security.getInitialHash(object)); plaintext.setInitialHash(cryptography.getInitialHash(object));
messageRepo.save(plaintext); messageRepo.save(plaintext);
} }
security.doProofOfWork(object, nonceTrialsPerByte, extraBytes, this); cryptography.doProofOfWork(object, nonceTrialsPerByte, extraBytes, this);
} }
@Override @Override
@ -75,7 +75,7 @@ public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalC
@Override @Override
public void setContext(InternalContext ctx) { public void setContext(InternalContext ctx) {
this.ctx = ctx; this.ctx = ctx;
this.security = security(); this.cryptography = security();
this.powRepo = ctx.getProofOfWorkRepository(); this.powRepo = ctx.getProofOfWorkRepository();
this.messageRepo = ctx.getMessageRepository(); this.messageRepo = ctx.getMessageRepository();
} }

View File

@ -17,7 +17,6 @@
package ch.dissem.bitmessage.entity; package ch.dissem.bitmessage.entity;
import ch.dissem.bitmessage.exception.DecryptionFailedException; import ch.dissem.bitmessage.exception.DecryptionFailedException;
import ch.dissem.bitmessage.ports.Security;
import java.io.IOException; import java.io.IOException;

View File

@ -22,7 +22,6 @@ import ch.dissem.bitmessage.entity.payload.Pubkey;
import ch.dissem.bitmessage.entity.valueobject.InventoryVector; import ch.dissem.bitmessage.entity.valueobject.InventoryVector;
import ch.dissem.bitmessage.entity.valueobject.PrivateKey; import ch.dissem.bitmessage.entity.valueobject.PrivateKey;
import ch.dissem.bitmessage.exception.DecryptionFailedException; import ch.dissem.bitmessage.exception.DecryptionFailedException;
import ch.dissem.bitmessage.ports.Security;
import ch.dissem.bitmessage.utils.Bytes; import ch.dissem.bitmessage.utils.Bytes;
import ch.dissem.bitmessage.utils.Encode; import ch.dissem.bitmessage.utils.Encode;

View File

@ -18,7 +18,6 @@ package ch.dissem.bitmessage.entity.payload;
import ch.dissem.bitmessage.entity.BitmessageAddress; import ch.dissem.bitmessage.entity.BitmessageAddress;
import ch.dissem.bitmessage.entity.Plaintext; import ch.dissem.bitmessage.entity.Plaintext;
import ch.dissem.bitmessage.ports.Security;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@ -39,8 +39,8 @@ import static ch.dissem.bitmessage.utils.Numbers.max;
/** /**
* Implements everything that isn't directly dependent on either Spongy- or Bouncycastle. * Implements everything that isn't directly dependent on either Spongy- or Bouncycastle.
*/ */
public abstract class AbstractSecurity implements Security, InternalContext.ContextHolder { public abstract class AbstractCryptography implements Cryptography, InternalContext.ContextHolder {
public static final Logger LOG = LoggerFactory.getLogger(Security.class); public static final Logger LOG = LoggerFactory.getLogger(Cryptography.class);
private static final SecureRandom RANDOM = new SecureRandom(); private static final SecureRandom RANDOM = new SecureRandom();
private static final BigInteger TWO = BigInteger.valueOf(2); private static final BigInteger TWO = BigInteger.valueOf(2);
private static final BigInteger TWO_POW_64 = TWO.pow(64); private static final BigInteger TWO_POW_64 = TWO.pow(64);
@ -49,7 +49,7 @@ public abstract class AbstractSecurity implements Security, InternalContext.Cont
private final String provider; private final String provider;
private InternalContext context; private InternalContext context;
protected AbstractSecurity(String provider) { protected AbstractCryptography(String provider) {
this.provider = provider; this.provider = provider;
} }

View File

@ -29,7 +29,7 @@ import java.security.SecureRandom;
* Provides some methods to help with hashing and encryption. All randoms are created using {@link SecureRandom}, * Provides some methods to help with hashing and encryption. All randoms are created using {@link SecureRandom},
* which should be secure enough. * which should be secure enough.
*/ */
public interface Security { public interface Cryptography {
/** /**
* A helper method to calculate SHA-512 hashes. Please note that a new {@link MessageDigest} object is created at * A helper method to calculate SHA-512 hashes. Please note that a new {@link MessageDigest} object is created at
* each call (to ensure thread safety), so you shouldn't use this if you need to do many hash calculations in * each call (to ensure thread safety), so you shouldn't use this if you need to do many hash calculations in

View File

@ -16,23 +16,23 @@
package ch.dissem.bitmessage.utils; package ch.dissem.bitmessage.utils;
import ch.dissem.bitmessage.ports.Security; import ch.dissem.bitmessage.ports.Cryptography;
/** /**
* Created by chris on 20.07.15. * Created by chris on 20.07.15.
*/ */
public class Singleton { public class Singleton {
private static Security security; private static Cryptography cryptography;
public static void initialize(Security security) { public static void initialize(Cryptography cryptography) {
synchronized (Singleton.class) { synchronized (Singleton.class) {
if (Singleton.security == null) { if (Singleton.cryptography == null) {
Singleton.security = security; Singleton.cryptography = cryptography;
} }
} }
} }
public static Security security() { public static Cryptography security() {
return security; return cryptography;
} }
} }

View File

@ -16,13 +16,13 @@
package ch.dissem.bitmessage.utils; package ch.dissem.bitmessage.utils;
import ch.dissem.bitmessage.security.bc.BouncySecurity; import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
/** /**
* Created by chris on 20.07.15. * Created by chris on 20.07.15.
*/ */
public class TestBase { public class TestBase {
static { static {
Singleton.initialize(new BouncySecurity()); Singleton.initialize(new BouncyCryptography());
} }
} }

View File

@ -32,5 +32,5 @@ dependencies {
testCompile 'org.slf4j:slf4j-simple:1.7.12' testCompile 'org.slf4j:slf4j-simple:1.7.12'
testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.mockito:mockito-core:1.10.19'
testCompile project(path: ':domain', configuration: 'testArtifacts') testCompile project(path: ':domain', configuration: 'testArtifacts')
testCompile project(':security-bc') testCompile project(':cryptography-bc')
} }

View File

@ -16,5 +16,5 @@ dependencies {
testCompile 'org.slf4j:slf4j-simple:1.7.12' testCompile 'org.slf4j:slf4j-simple:1.7.12'
testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.mockito:mockito-core:1.10.19'
testCompile project(path: ':domain', configuration: 'testArtifacts') testCompile project(path: ':domain', configuration: 'testArtifacts')
testCompile project(':security-bc') testCompile project(':cryptography-bc')
} }

View File

@ -22,7 +22,7 @@ import ch.dissem.bitmessage.ports.AddressRepository;
import ch.dissem.bitmessage.ports.MessageRepository; import ch.dissem.bitmessage.ports.MessageRepository;
import ch.dissem.bitmessage.ports.NetworkHandler; import ch.dissem.bitmessage.ports.NetworkHandler;
import ch.dissem.bitmessage.ports.ProofOfWorkRepository; import ch.dissem.bitmessage.ports.ProofOfWorkRepository;
import ch.dissem.bitmessage.security.bc.BouncySecurity; import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
import ch.dissem.bitmessage.utils.Property; import ch.dissem.bitmessage.utils.Property;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -59,7 +59,7 @@ public class NetworkHandlerTest {
.port(6001) .port(6001)
.nodeRegistry(new TestNodeRegistry()) .nodeRegistry(new TestNodeRegistry())
.networkHandler(new DefaultNetworkHandler()) .networkHandler(new DefaultNetworkHandler())
.security(new BouncySecurity()) .cryptography(new BouncyCryptography())
.listener(Mockito.mock(BitmessageContext.Listener.class)) .listener(Mockito.mock(BitmessageContext.Listener.class))
.build(); .build();
peer.startup(); peer.startup();
@ -74,7 +74,7 @@ public class NetworkHandlerTest {
.port(6002) .port(6002)
.nodeRegistry(new TestNodeRegistry(localhost)) .nodeRegistry(new TestNodeRegistry(localhost))
.networkHandler(networkHandler) .networkHandler(networkHandler)
.security(new BouncySecurity()) .cryptography(new BouncyCryptography())
.listener(Mockito.mock(BitmessageContext.Listener.class)) .listener(Mockito.mock(BitmessageContext.Listener.class))
.build(); .build();
} }

View File

@ -18,5 +18,5 @@ dependencies {
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
testCompile 'com.h2database:h2:1.4.190' testCompile 'com.h2database:h2:1.4.190'
testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.mockito:mockito-core:1.10.19'
testCompile project(':security-bc') testCompile project(':cryptography-bc')
} }

View File

@ -55,7 +55,7 @@ public class JdbcMessageRepositoryTest extends TestBase {
addressRepo = new JdbcAddressRepository(config); addressRepo = new JdbcAddressRepository(config);
repo = new JdbcMessageRepository(config); repo = new JdbcMessageRepository(config);
new InternalContext(new BitmessageContext.Builder() new InternalContext(new BitmessageContext.Builder()
.security(security()) .cryptography(security())
.addressRepo(addressRepo) .addressRepo(addressRepo)
.messageRepo(repo) .messageRepo(repo)
); );

View File

@ -18,7 +18,7 @@ package ch.dissem.bitmessage.repository;
import ch.dissem.bitmessage.InternalContext; import ch.dissem.bitmessage.InternalContext;
import ch.dissem.bitmessage.ports.MultiThreadedPOWEngine; import ch.dissem.bitmessage.ports.MultiThreadedPOWEngine;
import ch.dissem.bitmessage.security.bc.BouncySecurity; import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
import ch.dissem.bitmessage.utils.Singleton; import ch.dissem.bitmessage.utils.Singleton;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -29,7 +29,7 @@ import static org.mockito.Mockito.when;
*/ */
public class TestBase { public class TestBase {
static { static {
BouncySecurity security = new BouncySecurity(); BouncyCryptography security = new BouncyCryptography();
Singleton.initialize(security); Singleton.initialize(security);
InternalContext ctx = mock(InternalContext.class); InternalContext ctx = mock(InternalContext.class);
when(ctx.getProofOfWorkEngine()).thenReturn(new MultiThreadedPOWEngine()); when(ctx.getProofOfWorkEngine()).thenReturn(new MultiThreadedPOWEngine());

View File

@ -10,8 +10,8 @@ include 'demo'
include 'wif' include 'wif'
include 'security-sc' include 'cryptography-sc'
include 'security-bc' include 'cryptography-bc'
include 'extensions' include 'extensions'

View File

@ -15,5 +15,5 @@ dependencies {
compile 'org.ini4j:ini4j:0.5.4' compile 'org.ini4j:ini4j:0.5.4'
testCompile 'junit:junit:4.11' testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.mockito:mockito-core:1.10.19'
testCompile project(':security-bc') testCompile project(':cryptography-bc')
} }

View File

@ -18,7 +18,7 @@ package ch.dissem.bitmessage.wif;
import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.BitmessageContext;
import ch.dissem.bitmessage.ports.*; import ch.dissem.bitmessage.ports.*;
import ch.dissem.bitmessage.security.bc.BouncySecurity; import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -35,7 +35,7 @@ public class WifExporterTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
ctx = new BitmessageContext.Builder() ctx = new BitmessageContext.Builder()
.security(new BouncySecurity()) .cryptography(new BouncyCryptography())
.networkHandler(mock(NetworkHandler.class)) .networkHandler(mock(NetworkHandler.class))
.inventory(mock(Inventory.class)) .inventory(mock(Inventory.class))
.messageRepo(mock(MessageRepository.class)) .messageRepo(mock(MessageRepository.class))

View File

@ -19,7 +19,7 @@ package ch.dissem.bitmessage.wif;
import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.BitmessageContext;
import ch.dissem.bitmessage.entity.BitmessageAddress; import ch.dissem.bitmessage.entity.BitmessageAddress;
import ch.dissem.bitmessage.ports.*; import ch.dissem.bitmessage.ports.*;
import ch.dissem.bitmessage.security.bc.BouncySecurity; import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -38,7 +38,7 @@ public class WifImporterTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
ctx = new BitmessageContext.Builder() ctx = new BitmessageContext.Builder()
.security(new BouncySecurity()) .cryptography(new BouncyCryptography())
.networkHandler(mock(NetworkHandler.class)) .networkHandler(mock(NetworkHandler.class))
.inventory(mock(Inventory.class)) .inventory(mock(Inventory.class))
.messageRepo(mock(MessageRepository.class)) .messageRepo(mock(MessageRepository.class))