Skip to content

Commit

Permalink
Base64 encoding added to tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lomilar committed Oct 30, 2019
1 parent a71feb3 commit 925d9bf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public String getImageUrl() {
*/
public EbacContact toEncryptedContact(String secret) {
EbacContact c = new EbacContact();
c.iv = EcAes.newIv(32);
c.iv = EcAes.newIv(16);
c.pk = EcAesCtr.encrypt(pk.toPem(), secret, c.iv);
c.displayNameIv = EcAes.newIv(16);
c.displayName = EcAesCtr.encrypt(displayName, secret, c.iv);
Expand Down
26 changes: 13 additions & 13 deletions ec.crypto/src/test/java/com/eduworks/ec/crypto/EcAesAsyncTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import static org.stjs.javascript.Global.console;

@RunWith(STJSTestDriverRunner.class)
@ScriptsBefore({"pem-jwk.js", "require.js", "/forge/forge.bundle.js", "ec.base.js"})
@ScriptsBefore({"pem-jwk.js", "require.js", "/forge/forge.bundle.js", "ec.base.js", "base64toArrayBuffer.js"})
public class EcAesAsyncTest {
@Test
public void aesTest() {
Expand Down Expand Up @@ -54,9 +54,9 @@ public void aesCrossTest1() {
console.log("-----aesCrossTest1-----");
final String randomString = EcAes.newIv(1024);
console.log("Random string: " + randomString);
final String secret = EcAes.newIv(32);
final String secret = EcAes.newIv(16);
console.log("Random secret: " + secret);
final String iv = EcAes.newIv(32);
final String iv = EcAes.newIv(16);
console.log("Random iv:" + iv);
EcAesCtrAsync.encrypt(randomString, secret, iv, new Callback1<String>() {
@Override
Expand All @@ -81,9 +81,9 @@ public void aesCrossTest1Utf8() {
console.log("-----aesCrossTest1Utf8-----");
final String randomString = "ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ";
console.log("Random string: " + randomString);
final String secret = EcAes.newIv(32);
final String secret = EcAes.newIv(16);
console.log("Random secret: " + secret);
final String iv = EcAes.newIv(32);
final String iv = EcAes.newIv(16);
console.log("Random iv:" + iv);
EcAesCtrAsync.encrypt(randomString, secret, iv, new Callback1<String>() {
@Override
Expand All @@ -108,9 +108,9 @@ public void aesCrossTest2Utf8() {
console.log("-----aesCrossTest2Utf8-----");
final String randomString = "ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ";
console.log("Random string: " + randomString);
final String secret = EcAes.newIv(32);
final String secret = EcAes.newIv(16);
console.log("Random secret: " + secret);
final String iv = EcAes.newIv(32);
final String iv = EcAes.newIv(16);
console.log("Random iv:" + iv);
String encrypted = EcAesCtr.encrypt(randomString, secret, iv);
console.log("Encrypted String: " + encrypted);
Expand Down Expand Up @@ -171,9 +171,9 @@ public void aesCrossTest1Worker() {
console.log("-----aesCrossTest1Worker-----");
final String randomString = EcAes.newIv(1024);
console.log("Random string: " + randomString);
final String secret = EcAes.newIv(32);
final String secret = EcAes.newIv(16);
console.log("Random secret: " + secret);
final String iv = EcAes.newIv(32);
final String iv = EcAes.newIv(16);
console.log("Random iv:" + iv);
EcAesCtrAsyncWorker.encrypt(randomString, secret, iv, new Callback1<String>() {
@Override
Expand All @@ -198,9 +198,9 @@ public void aesCrossTest1Utf8Worker() {
console.log("-----aesCrossTest1Utf8Worker-----");
final String randomString = "ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ";
console.log("Random string: " + randomString);
final String secret = EcAes.newIv(32);
final String secret = EcAes.newIv(16);
console.log("Random secret: " + secret);
final String iv = EcAes.newIv(32);
final String iv = EcAes.newIv(16);
console.log("Random iv:" + iv);
EcAesCtrAsyncWorker.encrypt(randomString, secret, iv, new Callback1<String>() {
@Override
Expand All @@ -225,9 +225,9 @@ public void aesCrossTest2Utf8Worker() {
console.log("-----aesCrossTest2Utf8Worker-----");
final String randomString = "ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ";
console.log("Random string: " + randomString);
final String secret = EcAes.newIv(32);
final String secret = EcAes.newIv(16);
console.log("Random secret: " + secret);
final String iv = EcAes.newIv(32);
final String iv = EcAes.newIv(16);
console.log("Random iv:" + iv);
String encrypted = EcAesCtr.encrypt(randomString, secret, iv);
console.log("Encrypted String: " + encrypted);
Expand Down
10 changes: 5 additions & 5 deletions ec.crypto/src/test/java/com/eduworks/ec/crypto/EcAesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
import static org.stjs.javascript.Global.console;

@RunWith(STJSTestDriverRunner.class)
@ScriptsBefore({"pem-jwk.js", "require.js", "/forge/forge.bundle.js", "ec.base.js"})
@ScriptsBefore({"pem-jwk.js", "require.js", "/forge/forge.bundle.js", "ec.base.js", "base64toArrayBuffer.js"})
public class EcAesTest {
@Test
public void aesTest() {
console.log("-----aesTest-----");
String randomString = EcAes.newIv(1024);
console.log("Random string: " + randomString);
String secret = EcAes.newIv(32);
String secret = EcAes.newIv(16);
console.log("Random secret: " + secret);
String iv = EcAes.newIv(32);
String iv = EcAes.newIv(16);
console.log("Random iv:" + iv);
String encrypted = EcAesCtr.encrypt(randomString, secret, iv);
console.log("Encrypted String: " + encrypted);
Expand All @@ -33,9 +33,9 @@ public void aesUtf8Test() {
console.log("-----aesUtf8Test-----");
String randomString = "abcᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ";
console.log("Random string: " + randomString);
String secret = EcAes.newIv(32);
String secret = EcAes.newIv(16);
console.log("Random secret: " + secret);
String iv = EcAes.newIv(32);
String iv = EcAes.newIv(16);
console.log("Random iv:" + iv);
String encrypted = EcAesCtr.encrypt(randomString, secret, iv);
console.log("Encrypted String: " + encrypted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import static org.stjs.javascript.Global.console;

@RunWith(STJSTestDriverRunner.class)
@ScriptsBefore({"pem-jwk.js", "require.js", "/forge/forge.bundle.js", "ec.base.js"})
@ScriptsBefore({"pem-jwk.js", "require.js", "/forge/forge.bundle.js", "ec.base.js", "base64toArrayBuffer.js"})
public class EcPpkTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import static org.stjs.javascript.Global.console;

@RunWith(STJSTestDriverRunner.class)
@ScriptsBefore({"pem-jwk.js", "require.js", "/forge/forge.bundle.js", "ec.base.js"})
@ScriptsBefore({"pem-jwk.js", "require.js", "/forge/forge.bundle.js", "ec.base.js", "base64toArrayBuffer.js"})
public class EcRsaTest {
@Test
public void rsaOaepTest() {
Expand Down

0 comments on commit 925d9bf

Please sign in to comment.