Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/**
.gradle/**
.idea/**
.DS_Store
File renamed without changes.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ git_repository(
name = "boringssl",
branch = "master-with-bazel",
remote = "https://boringssl.googlesource.com/boringssl",
)
)
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand All @@ -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"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't build w cmake anymore, so this should probably be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning to support only bazel for the c++ library and gradle for java?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, since this is built as part of https://github.com/google/nearby, so that's why a lot of this stuff wasn't updated correctly (my bad!)

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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down