GithubHelp home page GithubHelp logo

Comments (5)

thaidn avatar thaidn commented on August 20, 2024

Can you tell me why you need to read a reader multiple times? In Tink's design, a reader is a temporary object that should be immediately discarded after it is used to obtain a KeysetHandle.

from tink.

spennymac avatar spennymac commented on August 20, 2024

Sure. I only brought this up since this was a change that broke my framework when I updated to the latest release. I am fine with your response, makes sense, readers generally are used only use. I just got bit by the fact that a reader instantiated with JSON is able to be reused. If anything, I am abusing this.

Anyways, this is why..

I am reading in a keyset from some source and need to differentiate between NoSecret and Secret containing keysets.

try {
    KeysetHandle keysetHandle = NoSecretKeysetHandle.read(reader); 
     return new TinkPublicKeyset(keysetHandle);
} catch (GeneralSecurityException ex) {
    KeysetHandle keysetHandle = CleartextKeysetHandle.read(reader);
    return new TinkKeyset(keysetHandle);
}

Thanks!

from tink.

thaidn avatar thaidn commented on August 20, 2024

Oh I see. This is an interesting usage. I guess at some point downstream you'd have to check whether you're dealing with TinkPublicKeyset or TinkKeyset, right? I'd rather separate them completely from the beginning.

How did you fix it?

from tink.

spennymac avatar spennymac commented on August 20, 2024

Im not sure yet if I can do this a different layer since this is reading a keyset from some source (disk, kms).

But as a temporary fix, I just instantiated my reader with JsonKeysetReader.withJsonObject(json..) instead of JsonKeysetReader.withString(string..)

from tink.

spennymac avatar spennymac commented on August 20, 2024

Anyways, I will close this as you have already given me a proper response.

Thanks!

from tink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.