Skip to content

Commit 2d93de4

Browse files
authored
Merge pull request #271 from pusher/dev-fix-lazysodium-5
swap lazsysodium for tweetnacl
2 parents 15cdaa4 + 159b09f commit 2d93de4

File tree

4 files changed

+3417
-35
lines changed

4 files changed

+3417
-35
lines changed

build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ dependencies {
4747
compile "com.google.code.gson:gson:2.2.2"
4848
compile "org.java-websocket:Java-WebSocket:1.4.0"
4949

50-
implementation "com.goterl.lazycode:lazysodium-java:4.2.6"
51-
implementation "net.java.dev.jna:jna:5.5.0"
52-
5350
testCompile "org.mockito:mockito-all:1.8.5"
5451
testCompile "org.powermock:powermock-module-junit4:1.4.11"
5552
testCompile "org.powermock:powermock-api-mockito:1.4.11"

src/main/java/com/pusher/client/crypto/nacl/SecretBoxOpener.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ a copy of this software and associated documentation files (the "Software"),
2424

2525
package com.pusher.client.crypto.nacl;
2626

27-
import com.goterl.lazycode.lazysodium.LazySodiumJava;
28-
import com.goterl.lazycode.lazysodium.SodiumJava;
29-
import com.goterl.lazycode.lazysodium.exceptions.SodiumException;
30-
import com.goterl.lazycode.lazysodium.interfaces.Helpers;
31-
import com.goterl.lazycode.lazysodium.interfaces.SecretBox;
32-
import com.goterl.lazycode.lazysodium.utils.Key;
33-
3427
import static com.pusher.client.util.internal.Preconditions.checkArgument;
3528
import static com.pusher.client.util.internal.Preconditions.checkNotNull;
3629
import static java.util.Arrays.fill;
@@ -52,14 +45,11 @@ public String open(byte[] cypher, byte[] nonce) throws AuthenticityException {
5245
checkNotNull(key, "key has been cleared, create new instance");
5346
checkArgument(nonce.length == 24, "nonce length must be 24 bytes, but is " +
5447
key.length + " bytes");
55-
56-
57-
SecretBox.Lazy secretBoxLazy = (SecretBox.Lazy) Sodium.getInstance();
58-
5948
try {
60-
return secretBoxLazy.cryptoSecretBoxOpenEasy(
61-
Sodium.getInstance().sodiumBin2Hex(cypher), nonce, Key.fromBytes(key));
62-
} catch (SodiumException e) {
49+
TweetNaclFast.SecretBox secretBox = new TweetNaclFast.SecretBox(key);
50+
byte[] result = secretBox.open(cypher, nonce);
51+
return new String(result);
52+
} catch (Exception e) {
6353
throw new AuthenticityException();
6454
}
6555
}

src/main/java/com/pusher/client/crypto/nacl/Sodium.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)