From 704aed5472204cdde5a5d657c35e4601efc9dd98 Mon Sep 17 00:00:00 2001 From: Ryan Schumacher Date: Mon, 4 Nov 2024 21:53:57 -0600 Subject: [PATCH] fix reader --- pkg/handlers/tdf.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/handlers/tdf.go b/pkg/handlers/tdf.go index 6e4c1148..460d98d1 100644 --- a/pkg/handlers/tdf.go +++ b/pkg/handlers/tdf.go @@ -83,7 +83,10 @@ func (h Handler) DecryptBytes(toDecrypt []byte) (*bytes.Buffer, error) { out := &bytes.Buffer{} pt := io.Writer(out) ec := bytes.NewReader(toDecrypt) - switch sdk.GetTdfType(ec) { + tdfType := sdk.GetTdfType(ec) + // reset the reader to the beginning + ec.Reset(toDecrypt) + switch tdfType { case sdk.Nano: if _, err := h.sdk.ReadNanoTDF(pt, ec); err != nil { return nil, err