Class DESedeKeySpec

java.lang.Object
javax.crypto.spec.DESedeKeySpec
All Implemented Interfaces:
KeySpec

public class DESedeKeySpec
extends Object
implements KeySpec
The key specification for a triple-DES (DES-EDE) key.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int DES_EDE_KEY_LEN
    The length of a DES-EDE key in bytes.
  • Constructor Summary

    Constructors
    Constructor Description
    DESedeKeySpec​(byte[] key)
    Creates a new DESedeKeySpec instance from the first 24 ( DES_EDE_KEY_LEN) bytes of the specified key data.
    DESedeKeySpec​(byte[] key, int offset)
    Creates a new DESedeKeySpec instance from the first 24 ( DES_EDE_KEY_LEN ) bytes of the specified key data starting at offset.
  • Method Summary

    Modifier and Type Method Description
    byte[] getKey()
    Returns a copy of the key.
    static boolean isParityAdjusted​(byte[] key, int offset)
    Returns whether the specified key data starting at offset is parity-adjusted.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DES_EDE_KEY_LEN

      public static final int DES_EDE_KEY_LEN
      The length of a DES-EDE key in bytes.
      See Also:
      Constant Field Values
  • Constructor Details

    • DESedeKeySpec

      public DESedeKeySpec​(byte[] key) throws InvalidKeyException
      Creates a new DESedeKeySpec instance from the first 24 ( DES_EDE_KEY_LEN) bytes of the specified key data.
      Parameters:
      key - the key data.
      Throws:
      InvalidKeyException - if the length of the key data is less than 24.
      NullPointerException - if the key data is null.
    • DESedeKeySpec

      public DESedeKeySpec​(byte[] key, int offset) throws InvalidKeyException
      Creates a new DESedeKeySpec instance from the first 24 ( DES_EDE_KEY_LEN ) bytes of the specified key data starting at offset.
      Parameters:
      key - the key data
      offset - the offset to start at.
      Throws:
      InvalidKeyException - if the length of the key data starting at offset is less than 24.
      NullPointerException - if the key data is null.
  • Method Details

    • getKey

      public byte[] getKey()
      Returns a copy of the key.
      Returns:
      a copy of the key.
    • isParityAdjusted

      public static boolean isParityAdjusted​(byte[] key, int offset) throws InvalidKeyException
      Returns whether the specified key data starting at offset is parity-adjusted.
      Parameters:
      key - the key data.
      offset - the offset to start checking at.
      Returns:
      true if the specified key data is parity-adjusted, false otherwise.
      Throws:
      InvalidKeyException - if the length of the key data starting at offset is less than 24.