Module jcifs

Class DES

java.lang.Object
org.codelibs.jcifs.smb1.util.DES

public class DES extends Object
This code is derived from the above source JCIFS API Norbert Hranitzky

and modified again by Michael B. Allen

  • Constructor Summary

    Constructors
    Constructor
    Description
    DES()
    Creates a DES cipher instance without a key
    DES(byte[] key)
    Creates a DES cipher instance with the specified key
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    decrypt(byte[] cipherText)
    Decrypts an 8-byte block using DES
    void
    decrypt(byte[] cipherText, byte[] clearText)
    Decrypts an 8-byte block using DES
    byte[]
    encrypt(byte[] clearText)
    Encrypts an 8-byte block using DES
    void
    encrypt(byte[] clearText, byte[] cipherText)
    Encrypts an 8-byte block using DES
    static void
    makeSMBKey(byte[] key7, byte[] key8)
    Converts a 7-byte SMB key to an 8-byte DES key with parity bits
    void
    setKey(byte[] key)
    Sets the DES encryption key
    static void
    spreadIntsToBytes(int[] inInts, int inOff, byte[] outBytes, int outOff, int intLen)
    Converts integers to bytes after internal DES processing
    static void
    squashBytesToInts(byte[] inBytes, int inOff, int[] outInts, int outOff, int intLen)
    Converts bytes to integers for internal DES processing

    Methods inherited from class java.lang.Object

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

    • DES

      public DES()
      Creates a DES cipher instance without a key
    • DES

      public DES(byte[] key)
      Creates a DES cipher instance with the specified key
      Parameters:
      key - the DES key (7 or 8 bytes)
  • Method Details

    • makeSMBKey

      public static void makeSMBKey(byte[] key7, byte[] key8)
      Converts a 7-byte SMB key to an 8-byte DES key with parity bits
      Parameters:
      key7 - the 7-byte SMB key
      key8 - the output 8-byte DES key
    • setKey

      public void setKey(byte[] key)
      Sets the DES encryption key
      Parameters:
      key - the 8-byte DES key
    • encrypt

      public void encrypt(byte[] clearText, byte[] cipherText)
      Encrypts an 8-byte block using DES
      Parameters:
      clearText - the 8-byte plaintext block
      cipherText - the output 8-byte ciphertext block
    • decrypt

      public void decrypt(byte[] cipherText, byte[] clearText)
      Decrypts an 8-byte block using DES
      Parameters:
      cipherText - the 8-byte ciphertext block
      clearText - the output 8-byte plaintext block
    • encrypt

      public byte[] encrypt(byte[] clearText)
      Encrypts an 8-byte block using DES
      Parameters:
      clearText - the 8-byte plaintext block
      Returns:
      the 8-byte ciphertext block
    • decrypt

      public byte[] decrypt(byte[] cipherText)
      Decrypts an 8-byte block using DES
      Parameters:
      cipherText - the 8-byte ciphertext block
      Returns:
      the 8-byte plaintext block
    • squashBytesToInts

      public static void squashBytesToInts(byte[] inBytes, int inOff, int[] outInts, int outOff, int intLen)
      Converts bytes to integers for internal DES processing
      Parameters:
      inBytes - the input byte array
      inOff - the offset into the input array
      outInts - the output integer array
      outOff - the offset into the output array
      intLen - the number of integers to convert
    • spreadIntsToBytes

      public static void spreadIntsToBytes(int[] inInts, int inOff, byte[] outBytes, int outOff, int intLen)
      Converts integers to bytes after internal DES processing
      Parameters:
      inInts - the input integer array
      inOff - the offset into the input array
      outBytes - the output byte array
      outOff - the offset into the output array
      intLen - the number of integers to convert