From a88d386b3dfe6e7bf210c632c92eb54069c1c5b8 Mon Sep 17 00:00:00 2001 From: Jake Van Vorhis <83739412+jakedoublev@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:52:25 -0800 Subject: [PATCH] fix(core): improve readability of TDF methods (#424) --- pkg/handlers/tdf.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/handlers/tdf.go b/pkg/handlers/tdf.go index f6250f72..b789c1e4 100644 --- a/pkg/handlers/tdf.go +++ b/pkg/handlers/tdf.go @@ -32,7 +32,7 @@ type TDFInspect struct { UnencryptedMetadata []byte } -func (h Handler) EncryptBytes(tdfType string, b []byte, values []string, mimeType string, kasUrlPath string, ecdsaBinding bool, assertions string) (*bytes.Buffer, error) { +func (h Handler) EncryptBytes(tdfType string, unencrypted []byte, attrValues []string, mimeType string, kasUrlPath string, ecdsaBinding bool, assertions string) (*bytes.Buffer, error) { var encrypted []byte enc := bytes.NewBuffer(encrypted) @@ -44,7 +44,7 @@ func (h Handler) EncryptBytes(tdfType string, b []byte, values []string, mimeTyp } opts := []sdk.TDFOption{ - sdk.WithDataAttributes(values...), + sdk.WithDataAttributes(attrValues...), sdk.WithKasInformation(sdk.KASInfo{ URL: h.platformEndpoint + kasUrlPath, }), @@ -60,7 +60,7 @@ func (h Handler) EncryptBytes(tdfType string, b []byte, values []string, mimeTyp opts = append(opts, sdk.WithAssertions(assertionConfigs...)) } - _, err := h.sdk.CreateTDF(enc, bytes.NewReader(b), opts...) + _, err := h.sdk.CreateTDF(enc, bytes.NewReader(unencrypted), opts...) return enc, err // Encrypt the data as a Nano TDF @@ -74,7 +74,7 @@ func (h Handler) EncryptBytes(tdfType string, b []byte, values []string, mimeTyp return nil, err } // set the attributes - if err = nanoTDFConfig.SetAttributes(values); err != nil { + if err = nanoTDFConfig.SetAttributes(attrValues); err != nil { return nil, err } // enable ECDSA policy binding @@ -82,7 +82,7 @@ func (h Handler) EncryptBytes(tdfType string, b []byte, values []string, mimeTyp nanoTDFConfig.EnableECDSAPolicyBinding() } // create the nano TDF - if _, err = h.sdk.CreateNanoTDF(enc, bytes.NewReader(b), *nanoTDFConfig); err != nil { + if _, err = h.sdk.CreateNanoTDF(enc, bytes.NewReader(unencrypted), *nanoTDFConfig); err != nil { return nil, err } return enc, nil