|
7 | 7 | import io.opentdf.platform.sdk.nanotdf.NanoTDFType;
|
8 | 8 | import org.apache.commons.codec.DecoderException;
|
9 | 9 | import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;
|
10 |
| -import org.bouncycastle.jce.interfaces.ECPrivateKey; |
11 | 10 | import org.junit.jupiter.api.BeforeAll;
|
12 | 11 | import org.junit.jupiter.api.Test;
|
13 | 12 |
|
@@ -519,6 +518,22 @@ public void legacyTDFRoundTrips() throws DecoderException, IOException, Executio
|
519 | 518 | var dataOutputStream = new ByteArrayOutputStream();
|
520 | 519 |
|
521 | 520 | var reader = tdf.loadTDF(new SeekableInMemoryByteChannel(tdfOutputStream.toByteArray()), kas);
|
| 521 | + var integrityInformation = reader.getManifest().encryptionInformation.integrityInformation; |
| 522 | + assertThat(reader.getManifest().tdfVersion).isNull(); |
| 523 | + var decodedSignature = Base64.getDecoder().decode(integrityInformation.rootSignature.signature); |
| 524 | + for (var b: decodedSignature) { |
| 525 | + assertThat(isHexChar(b)) |
| 526 | + .withFailMessage("non-hex byte in signature: " + b) |
| 527 | + .isTrue(); |
| 528 | + } |
| 529 | + for (var s: integrityInformation.segments) { |
| 530 | + var decodedSegmentSignature = Base64.getDecoder().decode(s.hash); |
| 531 | + for (var b: decodedSegmentSignature) { |
| 532 | + assertThat(isHexChar(b)) |
| 533 | + .withFailMessage("non-hex byte in segment signature: " + b) |
| 534 | + .isTrue(); |
| 535 | + } |
| 536 | + } |
522 | 537 | reader.readPayload(dataOutputStream);
|
523 | 538 | assertThat(reader.getManifest().payload.mimeType).isEqualTo(mimeType);
|
524 | 539 | assertArrayEquals(data, dataOutputStream.toByteArray(), "extracted data does not match");
|
@@ -547,4 +562,8 @@ private static Config.KASInfo[] getRSAKASInfos() {
|
547 | 562 | private static Config.KASInfo[] getECKASInfos() {
|
548 | 563 | return getKASInfos(i -> i % 2 != 0);
|
549 | 564 | }
|
| 565 | + |
| 566 | + private static boolean isHexChar(byte b) { |
| 567 | + return (b >= 'a' && b <= 'f') || (b >= '0' && b <= '9'); |
| 568 | + } |
550 | 569 | }
|
0 commit comments