diff --git a/.gitignore b/.gitignore index f53951a..b7841cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/** .gradle/** .idea/** +.DS_Store diff --git a/BUILD b/BUILD.bazel similarity index 100% rename from BUILD rename to BUILD.bazel diff --git a/WORKSPACE b/WORKSPACE index 101fc3d..88f2522 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -34,4 +34,4 @@ git_repository( name = "boringssl", branch = "master-with-bazel", remote = "https://boringssl.googlesource.com/boringssl", -) \ No newline at end of file +) diff --git a/build.gradle b/build.gradle index b9fca13..a43d1b9 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.0' + classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.3' } } @@ -33,7 +33,7 @@ dependencies { testImplementation group: 'com.google.guava', name: 'guava-testlib', version: '29.0-jre' testImplementation 'junit:junit:4.13' implementation "com.google.code.findbugs:jsr305:3.0.0" - implementation "com.google.protobuf:protobuf-java:3.19.3" + implementation 'com.google.protobuf:protobuf-java:3.19.6' implementation "com.google.guava:guava:19.0" } diff --git a/src/main/javatest/com/google/security/cryptauth/lib/securegcm/Ukey2ShellCppWrapper.java b/src/main/javatest/com/google/security/cryptauth/lib/securegcm/Ukey2ShellCppWrapper.java index 2b73653..da0c70e 100644 --- a/src/main/javatest/com/google/security/cryptauth/lib/securegcm/Ukey2ShellCppWrapper.java +++ b/src/main/javatest/com/google/security/cryptauth/lib/securegcm/Ukey2ShellCppWrapper.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.File; import java.lang.ProcessBuilder.Redirect; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -50,6 +51,7 @@ public class Ukey2ShellCppWrapper { // The path the the ukey2_shell binary. private static final String BINARY_PATH = "build/src/main/cpp/src/securegcm/ukey2_shell"; + private static final String BINARY_PATH_BAZEL = "bazel-bin/src/main/cpp/ukey2_shell"; // The time to wait before timing out a read or write operation to the shell. @SuppressWarnings("GoodTime") // TODO(b/147378611): store a java.time.Duration instead @@ -90,8 +92,18 @@ public void startShell() throws IOException { String modeArg = "--mode=" + getModeString(); String verificationStringLengthArg = "--verification_string_length=" + verificationStringLength; - final ProcessBuilder builder = - new ProcessBuilder(BINARY_PATH, modeArg, verificationStringLengthArg); + String binaryPath; + if (new File(BINARY_PATH).exists()){ + binaryPath = BINARY_PATH; + } else if (new File(BINARY_PATH_BAZEL).exists()) { + binaryPath = BINARY_PATH_BAZEL; + } else { + throw new IllegalStateException("Unable to find ukey2_shell binary in "+BINARY_PATH); + } + + + ProcessBuilder builder = + new ProcessBuilder(binaryPath, modeArg, verificationStringLengthArg); // Merge the shell's stderr with the stderr of the current process. builder.redirectError(Redirect.INHERIT); @@ -316,7 +328,7 @@ private void writeFrame(byte[] contents) throws IOException { * @param command The command to send. * @param argument The argument of the command. Can be null. * @return the expression that can be sent to the shell. - * @throws IOException. + * @throws IOException */ private byte[] createExpression(String command, @Nullable byte[] argument) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream();