From 054699d14dee579c2b4c1424bd1ddc531a2d8e5a Mon Sep 17 00:00:00 2001 From: chubtub <43381989+chubtub@users.noreply.github.com> Date: Wed, 7 Dec 2022 19:47:30 -0500 Subject: [PATCH] Add commandline support for passing in a countersignature file for RFC3852 timestamps --- tools/tcg_rim_tool/src/main/java/hirs/swid/Main.java | 7 +++++-- .../src/main/java/hirs/swid/utils/Commander.java | 10 +++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/Main.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/Main.java index 8e56dcdb..1f91e088 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/Main.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/Main.java @@ -79,8 +79,11 @@ public class Main { } else { gateway.setRimEventLog(rimEventLog); } - if (commander.isRfc3852()) { - gateway.setTimestampFormat("RFC3852"); + if (!commander.getRfc3852Filename().isEmpty() && commander.isRfc3339()) { + System.out.println("Only one timestamp format can be specified"); + System.exit(1); + } else if (!commander.getRfc3852Filename().isEmpty()) { + //pass file to gateway } else if (commander.isRfc3339()) { gateway.setTimestampFormat("RFC3339"); } diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/Commander.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/Commander.java index d4ce8a78..77ea96cf 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/Commander.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/Commander.java @@ -47,7 +47,7 @@ public class Commander { private String rimEventLog = ""; @Parameter(names = {"--rfc3852"}, order = 10, description = "Add a placeholder for a base 64-encoded RFC3852 countersignature.") - private boolean rfc3852 = false; + private String rfc3852Filename = ""; @Parameter(names = {"--rfc3339"}, order = 11, description = "Add a timestamp to the signature that is compliant with RFC3339.") private boolean rfc3339 = false; @@ -88,7 +88,7 @@ public class Commander { public String getRimEventLog() { return rimEventLog; } - public boolean isRfc3852() { return rfc3852; } + public String getRfc3852Filename() { return rfc3852Filename; } public boolean isRfc3339() { return rfc3339; } @@ -133,12 +133,12 @@ public class Commander { sb.append("Signing credential: (none given)" + System.lineSeparator()); } sb.append("Event log support RIM: " + this.getRimEventLog() + System.lineSeparator()); - if (isRfc3852()) { + if (!this.getRfc3852Filename().isEmpty()) { sb.append("Timestamp format: RFC3852"); - } else if (isRfc3339()) { + } else if (this.isRfc3339()) { sb.append("Timestamp format: RFC3339"); } else { - sb.append("No timestamp included"); + sb.append("No timestamp specified"); } return sb.toString(); }