Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK: GetTdfType does not reset the reader #1717

Closed
jrschumacher opened this issue Nov 5, 2024 · 0 comments · Fixed by #1718 or #1713
Closed

SDK: GetTdfType does not reset the reader #1717

jrschumacher opened this issue Nov 5, 2024 · 0 comments · Fixed by #1718 or #1713

Comments

@jrschumacher
Copy link
Member

jrschumacher commented Nov 5, 2024

I'm not sure if this is expected behavior, but when using the function sdk.GetTdfType(ec) I found that I needed to reset the *io.Reader to use it for decrypting data.

b := &bytes.Buffer{}
pt := io.Writer(b)
ec := bytes.NewReader(toDecrypt)
tdfType := sdk.GetTdfType(ec)
// reset the reader to the beginning
ec.Reset(toDecrypt)
if tdfType == sdk.Nano {
	err := h.sdk.ReadNanoTDF(pt, ec)
	return b, err
}
return nil, errors.New("unsupported TDF type")
github-merge-queue bot pushed a commit that referenced this issue Nov 6, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.3.18](sdk/v0.3.17...sdk/v0.3.18)
(2024-11-06)


### Bug Fixes

* **core:** Autobump sdk
([#1725](#1725))
([89e63de](89e63de))
* NanoTDF secure key from debug logging and iv conflict risk
([#1714](#1714))
([7ba2e12](7ba2e12))
* **sdk:** Error message improvements
([#1176](#1176))
([0ef65d4](0ef65d4))
* **sdk:** Fix handling of kas rewrap errors
([#1696](#1696))
([ce10f3f](ce10f3f))
* **sdk:** reset reader after checking if IsNanoTDF
([#1718](#1718))
([f9d6f26](f9d6f26)),
closes [#1717](#1717)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant