Search in sources :

Example 6 with KrbCryptoException

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;
}
Also used : KrbCryptoException(sun.security.krb5.KrbCryptoException)

Example 7 with KrbCryptoException

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;
}
Also used : KrbCryptoException(sun.security.krb5.KrbCryptoException) MessageDigest(java.security.MessageDigest) KrbCryptoException(sun.security.krb5.KrbCryptoException) InvalidKeyException(java.security.InvalidKeyException)

Aggregations

KrbCryptoException (sun.security.krb5.KrbCryptoException)7 GeneralSecurityException (java.security.GeneralSecurityException)3 MessageDigest (java.security.MessageDigest)2 Cipher (javax.crypto.Cipher)2 SecretKey (javax.crypto.SecretKey)2 SecretKeyFactory (javax.crypto.SecretKeyFactory)2 IvParameterSpec (javax.crypto.spec.IvParameterSpec)2 SecretKeySpec (javax.crypto.spec.SecretKeySpec)2 InvalidKeyException (java.security.InvalidKeyException)1