Skip to content

Commit

Permalink
missed policybinding
Browse files Browse the repository at this point in the history
  • Loading branch information
mkleene committed Nov 26, 2024
1 parent 66e1b4f commit b2f8e54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 0 additions & 4 deletions sdk/src/main/java/io/opentdf/platform/sdk/HexString.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,5 @@ public HexString(byte[] value) {
this.value = value;
}

String hexValue() {
return Hex.encodeHexString(value);
}

byte[] byteValue() { return value; }
}
7 changes: 4 additions & 3 deletions sdk/src/main/java/io/opentdf/platform/sdk/TDF.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ private void prepareManifest(Config.TDFConfig tdfConfig, SDK.KAS kas) {
var hexBinding = new HexString(CryptoUtils.CalculateSHA256Hmac(symKey, base64PolicyObject.getBytes(StandardCharsets.UTF_8)));
var policyBinding = new Manifest.PolicyBinding();
policyBinding.alg = kHmacIntegrityAlgorithm;
policyBinding.hash = encoder.encodeToString(hexBinding.hexValue().getBytes(StandardCharsets.UTF_8));
policyBinding.hash = encoder.encodeToString(hexBinding.byteValue());

// Add meta data
var encryptedMetadata = new String();
var encryptedMetadata = "";
if (tdfConfig.metaData != null && !tdfConfig.metaData.trim().isEmpty()) {
AesGcm aesGcm = new AesGcm(symKey);
var encrypted = aesGcm.encrypt(tdfConfig.metaData.getBytes(StandardCharsets.UTF_8));
Expand Down Expand Up @@ -388,7 +388,8 @@ public void readPayload(OutputStream outputStream) throws TDFReadFailed,

} else {
var segmentSig = new HexString(digest.digest(readBuf));
if (segment.hash.compareTo(segmentSig.hexValue()) != 0) {
byte[] hash = Base64.getDecoder().decode(segment.hash);
if (!Arrays.equals(hash, segmentSig.byteValue())) {
throw new SegmentSignatureMismatch("segment signature miss match");
}

Expand Down

0 comments on commit b2f8e54

Please sign in to comment.