Class ProtoKey

  • All Implemented Interfaces:
    TinkKey

    @Immutable
    public final class ProtoKey
    extends java.lang.Object
    implements TinkKey
    Wraps the proto KeyData as an implementation of a TinkKey. The underlying KeyData determines whether this ProtoKey has a secret.

    ProtoKey is not intended for use outside of the Tink project.

    • Constructor Summary

      Constructors 
      Constructor Description
      ProtoKey​(com.google.crypto.tink.proto.KeyData keyData, KeyTemplate.OutputPrefixType opt)
      Constructs a ProtoKey with hasSecret() returning true if the input KeyData has key material of type UNKNOWN_KEYMATERIAL, SYMMETRIC, or ASYMMETRIC_PRIVATE.
    • Constructor Detail

      • ProtoKey

        public ProtoKey​(com.google.crypto.tink.proto.KeyData keyData,
                        KeyTemplate.OutputPrefixType opt)
        Constructs a ProtoKey with hasSecret() returning true if the input KeyData has key material of type UNKNOWN_KEYMATERIAL, SYMMETRIC, or ASYMMETRIC_PRIVATE.
    • Method Detail

      • getProtoKey

        public com.google.crypto.tink.proto.KeyData getProtoKey()
      • hasSecret

        public boolean hasSecret()
        Description copied from interface: TinkKey
        Returns true if the key contains secret key material, and false otherwise.
        Specified by:
        hasSecret in interface TinkKey
      • getKeyTemplate

        public KeyTemplate getKeyTemplate()
        Description copied from interface: TinkKey
        A TinkKey should know the KeyTemplate from which it was generated, which in turn specifies the cryptographic algorithm in which the TinkKey should be used. Throws UnsupportedOperationException to help ease rollout until it is possible to easily find the KeyTemplate associated to a key described in proto
        Specified by:
        getKeyTemplate in interface TinkKey
        Returns:
        the KeyTemplate used to generate the key.
        Throws:
        java.lang.UnsupportedOperationException - There is currently no direct way of getting a KeyTemplate from KeyData.