First time user of tink (and overall cryptography noob, but I'm learning)
I'm able to create a private key using
tinkey create-keyset --key-template [MY TEMPLATE] --out-format json --out foo.json
then once I have that file I try to create the public keyset via
tinkey create-public-keyset --in-format=json --in=foo.json
The output is
{"primaryKeyId":3104918340,"key":[{"keyData":{"typeUrl":"type.googleapis.com/google.crypto.tink.HpkePublicKey","value":"EgYIAxACGAIaYQTKiU+xhistDls5CMGMC311ZRfELnUGdfLXBx++SHiMOMOzsaFryaKljLlHHKegOeC6vbG8AXXpoPrvaouxtU5CgHCXGEczYwo9p/PHN4gKnJFfJJWCerzC5lEtV4SJUVo=","keyMaterialType":"ASYMMETRIC_PUBLIC"},"status":"ENABLED","keyId":3104918340,"outputPrefixType":"TINK"}]}
So now I need to send pem across the wire to a server, but my server team keeps telling me that I'm giving them an invalid pem document. I was under the understanding that the valud in the json above is pem format. Any tips?
As noted by President James K. Polk, you are not dealing with PEM in the first place.
The output you have shown is a JSON representation of a keyset, which is Tink's own format for storing keys. The value inside the
valuefield is base64-encoded binary data, not PEM or DER formatted data.Tink key objects are structured in a way that encapsulates all necessary information for cryptographic operations, including the key material itself and metadata like the key type, status, and key ID. The
keyDatafield within a Tink key object contains the actual key material, encoded in a type-specific format and usually base64-encoded in JSON outputs.So you would have to:
typeUrlfield to understand the cryptographic algorithm and key type (e.g., RSA, ECDSA, AES).valuefield from thekeyDataobject to get the raw key material.As a generic pseudo-code: