Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sdk/tdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const (
kAssertionSignature = "assertionSig"
kAssertionHash = "assertionHash"
hexSemverThreshold = "4.3.0"
readActionName = "read"

// maxPayloadSegments caps the segment count a declared input size may imply.
// The archive writer counts segments with an int, so the count has to fit one
Expand Down
14 changes: 6 additions & 8 deletions sdk/tdf_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ const (
inputSizeUnknown = -1
)

// TDFFormat once selected a manifest serialization. Only JSON was ever
// implemented, and nothing reads this.
//
// Deprecated: unused; the manifest is always JSON.
type TDFFormat = int

const (
// Deprecated: unused; the manifest is always JSON.
JSONFormat = iota
// Deprecated: never implemented.
XMLFormat
)

Expand Down Expand Up @@ -138,12 +144,8 @@ type TDFConfig struct {
autoconfigure bool
defaultSegmentSize int64
inputSize int64
enableEncryption bool
tdfFormat TDFFormat
metaData string
mimeType string
rootIntegrityAlg RootIntegrityAlg
segmentIntegrityAlg SegmentIntegrityAlg
assertions []AssertionConfig
attributes []AttributeValueFQN
attributeValues []*policy.Value
Expand All @@ -161,10 +163,6 @@ func newTDFConfig(opt ...TDFOption) (*TDFConfig, error) {
autoconfigure: true,
defaultSegmentSize: defaultSegmentSize,
inputSize: inputSizeUnknown,
enableEncryption: true,
tdfFormat: JSONFormat,
rootIntegrityAlg: RootHS256,
segmentIntegrityAlg: SegmentGMAC,
addDefaultAssertion: false,
}

Expand Down
9 changes: 0 additions & 9 deletions sdk/tdf_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,6 @@ func TestRootIntegrityRejectsNonHS256(t *testing.T) {
assert.Equal(t, hex.EncodeToString(ocrypto.CalculateSHA256Hmac(key, aggregate)), legacySig)
}

// Closing the root off to GMAC must not move the defaults: HS256 root, GMAC
// segments, which is what every writer has been emitting all along.
func TestIntegrityAlgDefaults(t *testing.T) {
def, err := newTDFConfig()
require.NoError(t, err)
assert.Equal(t, RootHS256, def.rootIntegrityAlg)
assert.Equal(t, SegmentGMAC, def.segmentIntegrityAlg)
}

// The deprecated constants stay numerically where they were, so an existing
// caller that converts one into the new types lands on the same algorithm.
func TestDeprecatedIntegrityAlgorithmConstants(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions sdk/tdf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2912,6 +2912,12 @@ func (s *TDFSuite) testEncrypt(sdk *SDK, encryptOpts []TDFOption, plainTextFilen
tdfObj, err := sdk.CreateTDF(fileWriter, readSeeker, encryptOpts...)
s.Require().NoError(err)

// Every TDF this SDK writes carries an HS256 root over the aggregate hash
// and GMAC segment hashes. Nothing configures either, so assert it here
// rather than in one test: this runs on every encrypt case there is.
s.Equal(hmacIntegrityAlgorithm, tdfObj.manifest.Algorithm)
s.Equal(gmacIntegrityAlgorithm, tdfObj.manifest.SegmentHashAlgorithm)

s.InDelta(float64(test.tdfFileSize), float64(tdfObj.size), .04*float64(test.tdfFileSize))
return tdfObj
}
Expand Down
Loading