interface encapsulates a cryptographic key. It defines only
- public String getAlgorithm()
This method returns the name of the cryptographic algorithm for which this key is used. An example is DSA, the Digital Signature Algorithm.
- public byte getEncoded()
You can retrieve the encoded value of the key by calling this method. Encoding is a process of mapping the key’s value into an array of bytes. The
getFormat()method will return the name of the format used to encode the key.
- public String getFormat()
This method returns the name of the format used to encode the key. An example is X.509.
Several interfaces extend the
Key interface. These
child interfaces define different flavors of keys, but none of them
defines any additional methods; they are used for clarity and type
safety. As we saw in Chapter 2, keys are used
differently for symmetric ciphers, asymmetric ciphers, and
signatures. Semantic extensions to the
interfaces keep the concepts clear. In the JDK, there are two such interfaces:
This interface represents the public key of a key pair, suitable for use with a signature or an asymmetric cipher (see Chapter 6, and Chapter 7, respectively). When used with a signature, a
PublicKeyis used to verify a signature (see
This interface represents the other half of a key pair. Just like a public key, a private key can be used with a signature or an ...