37
37
*/
38
38
public class TDF {
39
39
40
+ private static final String EMPTY_SPLIT_ID = "" ;
40
41
private static final String TDF_VERSION = "4.3.0" ;
41
42
private static final String KEY_ACCESS_SECHMA_VERSION = "4.3.0" ;
42
43
private final long maximumSize ;
@@ -607,29 +608,22 @@ public Reader loadTDF(SeekableByteChannel tdf, SDK.KAS kas,
607
608
Set <String > foundSplits = new HashSet <>();
608
609
609
610
Map <Autoconfigure .KeySplitStep , Exception > skippedSplits = new HashMap <>();
610
- boolean mixedSplits = manifest .encryptionInformation .keyAccessObj .size () > 1 &&
611
- (manifest .encryptionInformation .keyAccessObj .get (0 ).sid != null ) &&
612
- !manifest .encryptionInformation .keyAccessObj .get (0 ).sid .isEmpty ();
613
-
614
611
MessageDigest digest = MessageDigest .getInstance ("SHA-256" );
615
612
616
613
if (manifest .payload .isEncrypted ) {
617
614
for (Manifest .KeyAccess keyAccess : manifest .encryptionInformation .keyAccessObj ) {
618
- Autoconfigure .KeySplitStep ss = new Autoconfigure .KeySplitStep (keyAccess .url , keyAccess .sid );
615
+ String splitId = keyAccess .sid == null || keyAccess .sid .isEmpty () ? EMPTY_SPLIT_ID : keyAccess .sid ;
616
+ Autoconfigure .KeySplitStep ss = new Autoconfigure .KeySplitStep (keyAccess .url , splitId );
619
617
byte [] unwrappedKey ;
620
- if (!mixedSplits ) {
618
+ if (foundSplits .contains (ss .splitID )) {
619
+ continue ;
620
+ }
621
+ knownSplits .add (ss .splitID );
622
+ try {
621
623
unwrappedKey = kas .unwrap (keyAccess , manifest .encryptionInformation .policy );
622
- } else {
623
- if (foundSplits .contains (ss .splitID )) {
624
- continue ;
625
- }
626
- knownSplits .add (ss .splitID );
627
- try {
628
- unwrappedKey = kas .unwrap (keyAccess , manifest .encryptionInformation .policy );
629
- } catch (Exception e ) {
630
- skippedSplits .put (ss , e );
631
- continue ;
632
- }
624
+ } catch (Exception e ) {
625
+ skippedSplits .put (ss , e );
626
+ continue ;
633
627
}
634
628
635
629
for (int index = 0 ; index < unwrappedKey .length ; index ++) {
@@ -656,7 +650,7 @@ public Reader loadTDF(SeekableByteChannel tdf, SDK.KAS kas,
656
650
}
657
651
}
658
652
659
- if (mixedSplits && knownSplits .size () > foundSplits .size ()) {
653
+ if (knownSplits .size () > foundSplits .size ()) {
660
654
List <Exception > exceptionList = new ArrayList <>(skippedSplits .size () + 1 );
661
655
exceptionList .add (new Exception ("splitKey.unable to reconstruct split key: " + skippedSplits ));
662
656
0 commit comments