sun.security.mule.krb5.internal.crypto.dk
Class ArcFourCrypto

java.lang.Object
  extended by sun.security.mule.krb5.internal.crypto.dk.DkCrypto
      extended by sun.security.mule.krb5.internal.crypto.dk.ArcFourCrypto

public class ArcFourCrypto
extends DkCrypto

Support for ArcFour in Kerberos as defined in RFC 4757. http://www.ietf.org/rfc/rfc4757.txt

Author:
Seema Malkani

Constructor Summary
ArcFourCrypto(int length)
           
 
Method Summary
 byte[] calculateChecksum(byte[] baseKey, int usage, byte[] input, int start, int len)
          Calculate the checksum
 byte[] decrypt(byte[] baseKey, int usage, byte[] ivec, byte[] ciphertext, int start, int len)
           
 byte[] decryptRaw(byte[] baseKey, int usage, byte[] ivec, byte[] ciphertext, int start, int len, byte[] seqNum)
          Decrypts data using specified key and initial vector.
 byte[] decryptSeq(byte[] baseKey, int usage, byte[] checksum, byte[] ciphertext, int start, int len)
          Performs decryption of Sequence Number using derived key.
 byte[] encrypt(byte[] baseKey, int usage, byte[] ivec, byte[] new_ivec, byte[] plaintext, int start, int len)
          Performs encryption using derived key; adds confounder.
 byte[] encryptRaw(byte[] baseKey, int usage, byte[] seqNum, byte[] plaintext, int start, int len)
          Performs encryption using derived key; does not add confounder.
 byte[] encryptSeq(byte[] baseKey, int usage, byte[] checksum, byte[] plaintext, int start, int len)
          Performs encryption of Sequence Number using derived key.
 int getChecksumLength()
           
protected  Cipher getCipher(byte[] key, byte[] ivec, int mode)
           
protected  byte[] getHmac(byte[] key, byte[] msg)
          Get the HMAC-MD5
protected  int getKeySeedLength()
           
protected  byte[] randomToKey(byte[] in)
           
 byte[] stringToKey(char[] passwd)
           
 
Methods inherited from class sun.security.mule.krb5.internal.crypto.dk.DkCrypto
decryptRaw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArcFourCrypto

public ArcFourCrypto(int length)
Method Detail

getKeySeedLength

protected int getKeySeedLength()
Specified by:
getKeySeedLength in class DkCrypto

randomToKey

protected byte[] randomToKey(byte[] in)
Specified by:
randomToKey in class DkCrypto

stringToKey

public byte[] stringToKey(char[] passwd)
                   throws GeneralSecurityException
Throws:
GeneralSecurityException

getCipher

protected Cipher getCipher(byte[] key,
                           byte[] ivec,
                           int mode)
                    throws GeneralSecurityException
Specified by:
getCipher in class DkCrypto
Throws:
GeneralSecurityException

getChecksumLength

public int getChecksumLength()
Specified by:
getChecksumLength in class DkCrypto

getHmac

protected byte[] getHmac(byte[] key,
                         byte[] msg)
                  throws GeneralSecurityException
Get the HMAC-MD5

Specified by:
getHmac in class DkCrypto
Throws:
GeneralSecurityException

calculateChecksum

public byte[] calculateChecksum(byte[] baseKey,
                                int usage,
                                byte[] input,
                                int start,
                                int len)
                         throws GeneralSecurityException
Calculate the checksum

Overrides:
calculateChecksum in class DkCrypto
Throws:
GeneralSecurityException

encryptSeq

public byte[] encryptSeq(byte[] baseKey,
                         int usage,
                         byte[] checksum,
                         byte[] plaintext,
                         int start,
                         int len)
                  throws GeneralSecurityException,
                         KrbCryptoException
Performs encryption of Sequence Number using derived key.

Throws:
GeneralSecurityException
KrbCryptoException

decryptSeq

public byte[] decryptSeq(byte[] baseKey,
                         int usage,
                         byte[] checksum,
                         byte[] ciphertext,
                         int start,
                         int len)
                  throws GeneralSecurityException,
                         KrbCryptoException
Performs decryption of Sequence Number using derived key.

Throws:
GeneralSecurityException
KrbCryptoException

encrypt

public byte[] encrypt(byte[] baseKey,
                      int usage,
                      byte[] ivec,
                      byte[] new_ivec,
                      byte[] plaintext,
                      int start,
                      int len)
               throws GeneralSecurityException,
                      KrbCryptoException
Performs encryption using derived key; adds confounder.

Overrides:
encrypt in class DkCrypto
ivec - initial vector to use when initializing the cipher; if null, then blocksize number of zeros are used,
new_ivec - if non-null, it is updated upon return to be the new ivec to use when calling encrypt next time
Throws:
GeneralSecurityException
KrbCryptoException

encryptRaw

public byte[] encryptRaw(byte[] baseKey,
                         int usage,
                         byte[] seqNum,
                         byte[] plaintext,
                         int start,
                         int len)
                  throws GeneralSecurityException,
                         KrbCryptoException
Performs encryption using derived key; does not add confounder.

Overrides:
encryptRaw in class DkCrypto
Throws:
GeneralSecurityException
KrbCryptoException

decrypt

public byte[] decrypt(byte[] baseKey,
                      int usage,
                      byte[] ivec,
                      byte[] ciphertext,
                      int start,
                      int len)
               throws GeneralSecurityException
Overrides:
decrypt in class DkCrypto
Parameters:
baseKey - key from which keys are to be derived using usage
ciphertext - E(Ke, conf | plaintext | padding, ivec) | H1[1..h]
Throws:
GeneralSecurityException

decryptRaw

public byte[] decryptRaw(byte[] baseKey,
                         int usage,
                         byte[] ivec,
                         byte[] ciphertext,
                         int start,
                         int len,
                         byte[] seqNum)
                  throws GeneralSecurityException
Decrypts data using specified key and initial vector.

Parameters:
baseKey - encryption key to use
ciphertext - encrypted data to be decrypted
usage - ignored
Throws:
GeneralSecurityException


Copyright © 2013. All Rights Reserved.