From 5d10dc4b1cfb9f63ff6f63337a1cd29844d08198 Mon Sep 17 00:00:00 2001 From: chubtub <43381989+chubtub@users.noreply.github.com> Date: Thu, 20 Jun 2024 08:45:32 -0400 Subject: [PATCH] Modify rimtool to properly namespace timestamp elements --- .../main/java/hirs/swid/SwidTagGateway.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/SwidTagGateway.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/SwidTagGateway.java index a0e9a4c3..3239a9d2 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/SwidTagGateway.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/SwidTagGateway.java @@ -718,11 +718,13 @@ public class SwidTagGateway { try { byte[] counterSignature = Base64.getEncoder().encode( Files.readAllBytes(Paths.get(timestampArgument))); - timeStampElement = doc.createElementNS(SwidTagConstants.RFC3852_NS, "TimeStamp"); + timeStampElement = doc.createElementNS(SwidTagConstants.RFC3852_NS, + SwidTagConstants.RFC3852_PFX + ":TimeStamp"); timeStampElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + SwidTagConstants.RFC3852_PFX, SwidTagConstants.RFC3852_NS); - timeStampElement.setAttribute(SwidTagConstants.DATETIME, + timeStampElement.setAttributeNS(SwidTagConstants.RFC3852_NS, + SwidTagConstants.RFC3852_PFX + ":" + SwidTagConstants.DATETIME, new String(counterSignature)); } catch (IOException e) { e.printStackTrace(); @@ -730,15 +732,17 @@ public class SwidTagGateway { } break; case "RFC3339": - timeStampElement = doc.createElementNS(SwidTagConstants.RFC3339_NS, "TimeStamp"); + timeStampElement = doc.createElementNS(SwidTagConstants.RFC3339_NS, + SwidTagConstants.RFC3339_PFX + ":TimeStamp"); timeStampElement.setAttributeNS("http://www.w3.org/2000/xmlns/", - "xmlns:" + SwidTagConstants.RFC3339_PFX, - SwidTagConstants.RFC3339_NS); + "xmlns:" + SwidTagConstants.RFC3339_PFX, SwidTagConstants.RFC3339_NS); if (timestampArgument.isEmpty()) { - timeStampElement.setAttribute(SwidTagConstants.DATETIME, + timeStampElement.setAttributeNS(SwidTagConstants.RFC3339_NS, + SwidTagConstants.RFC3339_PFX + ":" + SwidTagConstants.DATETIME, LocalDateTime.now().toString()); } else { - timeStampElement.setAttribute(SwidTagConstants.DATETIME, + timeStampElement.setAttributeNS(SwidTagConstants.RFC3339_NS, + SwidTagConstants.RFC3339_PFX + ":" + SwidTagConstants.DATETIME, timestampArgument); } break;