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

java.lang.Object
  extended by sun.security.mule.krb5.internal.crypto.dk.DkCrypto
Direct Known Subclasses:
AesDkCrypto, ArcFourCrypto, Des3DkCrypto

public abstract class DkCrypto
extends Object

Implements Derive Key cryptography functionality as defined in RFC 3961. http://www.ietf.org/rfc/rfc3961.txt This is an abstract class. Concrete subclasses need to implement the abstract methods.


Field Summary
protected static boolean debug
           
 
Constructor Summary
DkCrypto()
           
 
Method Summary
 byte[] calculateChecksum(byte[] baseKey, int usage, byte[] input, int start, int len)
           
 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)
          Decrypts data using specified key and initial vector.
 byte[] encrypt(byte[] baseKey, int usage, byte[] ivec, byte[] new_ivec, byte[] plaintext, int start, int len)
          From RFC 3961.
 byte[] encryptRaw(byte[] baseKey, int usage, byte[] ivec, byte[] plaintext, int start, int len)
          Performs encryption using given key only; does not add confounder, padding, or checksum.
abstract  int getChecksumLength()
           
protected abstract  Cipher getCipher(byte[] key, byte[] ivec, int mode)
           
protected abstract  byte[] getHmac(byte[] key, byte[] plaintext)
           
protected abstract  int getKeySeedLength()
           
protected abstract  byte[] randomToKey(byte[] in)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected static final boolean debug
See Also:
Constant Field Values
Constructor Detail

DkCrypto

public DkCrypto()
Method Detail

getKeySeedLength

protected abstract int getKeySeedLength()

randomToKey

protected abstract byte[] randomToKey(byte[] in)

getCipher

protected abstract Cipher getCipher(byte[] key,
                                    byte[] ivec,
                                    int mode)
                             throws GeneralSecurityException
Throws:
GeneralSecurityException

getChecksumLength

public abstract int getChecksumLength()

getHmac

protected abstract byte[] getHmac(byte[] key,
                                  byte[] plaintext)
                           throws GeneralSecurityException
Throws:
GeneralSecurityException

encrypt

public byte[] encrypt(byte[] baseKey,
                      int usage,
                      byte[] ivec,
                      byte[] new_ivec,
                      byte[] plaintext,
                      int start,
                      int len)
               throws GeneralSecurityException,
                      KrbCryptoException
From RFC 3961. encryption function conf = random string of length c pad = shortest string to bring confounder and plaintext to a length that's a multiple of m (C1, newIV) = E(Ke, conf | plaintext | pad, oldstate.ivec) H1 = HMAC(Ki, conf | plaintext | pad) ciphertext = C1 | H1[1..h] newstate.ivec = newIV

Parameters:
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[] ivec,
                         byte[] plaintext,
                         int start,
                         int len)
                  throws GeneralSecurityException,
                         KrbCryptoException
Performs encryption using given key only; does not add confounder, padding, or checksum. Incoming data to be encrypted assumed to have the correct blocksize. Ignore key usage.

Throws:
GeneralSecurityException
KrbCryptoException

decryptRaw

public byte[] decryptRaw(byte[] baseKey,
                         int usage,
                         byte[] ivec,
                         byte[] ciphertext,
                         int start,
                         int len)
                  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

decrypt

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

calculateChecksum

public byte[] calculateChecksum(byte[] baseKey,
                                int usage,
                                byte[] input,
                                int start,
                                int len)
                         throws GeneralSecurityException
Throws:
GeneralSecurityException


Copyright © 2013. All Rights Reserved.