Key Interfaces
The Key interface is the top-level interface for
all opaque keys. It defines the functionality shared by all opaque
key objects.
An opaque key representation is one in which you have no direct access to the key
material that constitutes a key. In other words, an opaque key allows you limited access to the key
- just the three methods defined by the Key interface:
getAlgorithm, getFormat, and getEncoded. This is
in contrast to a transparent representation, in which you can access each key material
value individually, through one of the get methods defined in the corresponding
specification class.
- An Algorithm
- The key algorithm for that key. The key algorithm is usually an
encryption or asymmetric operation algorithm (such as DSA or RSA),
which will work with those algorithms and with related algorithms
(such as MD5 with RSA, SHA-1 with RSA, and so on.) The name of the
algorithm of a key is obtained using this method:
String getAlgorithm() - An Encoded Form
- The external encoded form for the key used when a standard representation of the key is needed
outside the Java™ Virtual Machine, as when transmitting the key
to some other party. The key is encoded according to a standard format (such as X.509 or PKCS #8), and is
returned using the method:
byte[] getEncoded() - A Format
- The name of the format of the encoded key. It is returned by the
method:
String getFormat()
KeyFactory),
or a KeyStore implementation
accessing a keystore database used to manage keys.It is possible to parse encoded keys, in an algorithm-dependent
manner, using a KeyFactory.
It is also possible to parse certificates, using a CertificateFactory.
Key interface in
the java.security and javax.crypto packages
are:
- The
PublicKeyandPrivateKeyInterfaces -
The
PublicKeyandPrivateKeyinterfaces (which both extend theKeyinterface) are methodless interfaces, used for type-safety and type-identification.