use of sun.security.krb5.KrbCryptoException in project jdk8u_jdk by JetBrains.
the class DesCbcEType method decrypt.
/**
* Decrypts the data using DES in CBC mode.
* @param cipher the input buffer.
* @param key the key to decrypt the data.
* @param ivec initialization vector.
*
* @modified by Yanni Zhang, Dec 6 99.
*/
public byte[] decrypt(byte[] cipher, byte[] key, byte[] ivec, int usage) throws KrbApErrException, KrbCryptoException {
/*
* To meet export control requirements, double check that the
* key being used is no longer than 64 bits.
*
* Note that from a protocol point of view, an
* algorithm that is not DES will be rejected before this
* point. Also, a DES key that is not 64 bits will be
* rejected by a good JCE provider.
*/
if (key.length > 8)
throw new KrbCryptoException("Invalid DES Key!");
byte[] data = new byte[cipher.length];
Des.cbc_encrypt(cipher, data, key, ivec, false);
if (!isChecksumValid(data))
throw new KrbApErrException(Krb5.KRB_AP_ERR_BAD_INTEGRITY);
return data;
}
use of sun.security.krb5.KrbCryptoException in project jdk8u_jdk by JetBrains.
the class RsaMd5DesCksumType method calculateChecksum.
/**
* Calculates checksum using MD5.
* @param data the data used to generate the checksum.
* @param size length of the data.
* @return the checksum.
*
* @modified by Yanni Zhang, 12/08/99.
*/
public byte[] calculateChecksum(byte[] data, int size) throws KrbCryptoException {
MessageDigest md5;
byte[] result = null;
try {
md5 = MessageDigest.getInstance("MD5");
} catch (Exception e) {
throw new KrbCryptoException("JCE provider may not be installed. " + e.getMessage());
}
try {
md5.update(data);
result = md5.digest();
} catch (Exception e) {
throw new KrbCryptoException(e.getMessage());
}
return result;
}
Aggregations