Name

SecretKey

Synopsis

This interface represents a secret key used for symmetric cryptographic algorithms that depend on both the sender and receiver knowing the same secret. SecretKey extends the java.security.Key interface, but does not add any new methods. The interface exists in order to keep secret keys distinct from the public and private keys used in public-key, or asymmetric, cryptography. See also java.security.PublicKey and java.security.PrivateKey.

A secret key is nothing more than arrays of bytes and does not require a specialized encoding format. Therefore, an implementation of this interface should return the format name “RAW” from getFormat( ) and should return the bytes of the key from getEncoded( ). (These two methods are defined by the java.security.Key interface that SecretKey extends.)

javax.crypto.SecretKey

Figure 17-10. javax.crypto.SecretKey

public interface SecretKey extends java.security.Key {
// Public Constants
                  5.0  public static final long serialVersionUID;                      =-4795878709595146952
}

Implementations

javax.crypto.interfaces.PBEKey, javax.crypto.spec.SecretKeySpec, javax.security.auth.kerberos.KerberosKey

Passed To

java.security.KeyStore.SecretKeyEntry.SecretKeyEntry( ), SecretKeyFactory.{getKeySpec( ), translateKey( )}, SecretKeyFactorySpi.{engineGetKeySpec( ), engineTranslateKey( )}

Returned By

java.security.KeyStore.SecretKeyEntry.getSecretKey( ), KeyAgreement.generateSecret( )

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.