Skip to content

Commit

Permalink
fix(core): improve readability of TDF methods (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakedoublev authored Nov 12, 2024
1 parent 27682df commit a88d386
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/handlers/tdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
}),
Expand All @@ -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
Expand All @@ -74,15 +74,15 @@ 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
if ecdsaBinding {
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
Expand Down

0 comments on commit a88d386

Please sign in to comment.