tink-crypto / tink

Tink is a multi-language, cross-platform, open source library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.
https://developers.google.com/tink
Apache License 2.0
13.47k stars 1.18k forks source link

tinkey: OutOptions.validate not called by CreatePublicKeysetCommand #546

Closed Matir closed 1 year ago

Matir commented 3 years ago

Describe the bug

When --out is not used with tinkey create-public-keyset a NullPointerException is raised.

To Reproduce

Generate a private key (of an asymmetric format) then try to create the public keyset without specifying --out.

/bazel-bin/tinkey/tinkey create-public-keyset --in ../../foo.json                                                                      ✘ 1  
Exception in thread "main" java.lang.NullPointerException                                                                                                                                     
        at com.google.crypto.tink.JsonKeysetWriter.write(JsonKeysetWriter.java:86)                                                                                                            
        at com.google.crypto.tink.CleartextKeysetHandle.write(CleartextKeysetHandle.java:79)                                                                                                  
        at com.google.crypto.tink.tinkey.CreatePublicKeysetCommand.create(CreatePublicKeysetCommand.java:47)                                                                                  
        at com.google.crypto.tink.tinkey.CreatePublicKeysetCommand.run(CreatePublicKeysetCommand.java:31)
        at com.google.crypto.tink.tinkey.Tinkey.main(Tinkey.java:55)

Expected behavior

Like other commands, it should print to stdout.

Error messages, stack traces, etc.

/bazel-bin/tinkey/tinkey create-public-keyset --in ../../foo.json                                                                      ✘ 1  
Exception in thread "main" java.lang.NullPointerException                                                                                                                                     
        at com.google.crypto.tink.JsonKeysetWriter.write(JsonKeysetWriter.java:86)                                                                                                            
        at com.google.crypto.tink.CleartextKeysetHandle.write(CleartextKeysetHandle.java:79)                                                                                                  
        at com.google.crypto.tink.tinkey.CreatePublicKeysetCommand.create(CreatePublicKeysetCommand.java:47)                                                                                  
        at com.google.crypto.tink.tinkey.CreatePublicKeysetCommand.run(CreatePublicKeysetCommand.java:31)
        at com.google.crypto.tink.tinkey.Tinkey.main(Tinkey.java:55)

Version information

Additional context

PR is on the way with a fix.

thaidn commented 3 years ago

Thanks! We'll fix this in 1.7.0.

morambro commented 1 year ago

This is now included in Tink 1.7.0