Package sun.security.krb5

Examples of sun.security.krb5.KrbCryptoException


    public byte[] encrypt(byte[] data, byte[] key, byte[] ivec, int usage)
        throws KrbCryptoException {
        try {
            return Des3.encrypt(key, usage, ivec, data, 0, data.length);
        } catch (GeneralSecurityException e) {
            KrbCryptoException ke = new KrbCryptoException(e.getMessage());
            ke.initCause(e);
            throw ke;
        }
    }
View Full Code Here


    public byte[] decrypt(byte[] cipher, byte[] key, byte[] ivec, int usage)
        throws KrbApErrException, KrbCryptoException {
        try {
            return Des3.decrypt(key, usage, ivec, cipher, 0, cipher.length);
        } catch (GeneralSecurityException e) {
            KrbCryptoException ke = new KrbCryptoException(e.getMessage());
            ke.initCause(e);
            throw ke;
        }
    }
View Full Code Here

        Cipher cipher = null;

        try {
            cipher = Cipher.getInstance("DES/CBC/NoPadding");
        } catch (GeneralSecurityException e) {
            KrbCryptoException ke = new KrbCryptoException("JCE provider may not be installed. "
                                                           + e.getMessage());
            ke.initCause(e);
            throw ke;
        }
        IvParameterSpec params = new IvParameterSpec(ivec);
        SecretKeySpec skSpec = new SecretKeySpec(key, "DES");
        try {
            SecretKeyFactory skf = SecretKeyFactory.getInstance("DES");
            //                  SecretKey sk = skf.generateSecret(skSpec);
            SecretKey sk = (SecretKey) skSpec;
            if (encrypt)
                cipher.init(Cipher.ENCRYPT_MODE, sk, params);
            else
                cipher.init(Cipher.DECRYPT_MODE, sk, params);
            byte[] result;
            result = cipher.doFinal(input);
            System.arraycopy(result, 0, output, 0, result.length);
        } catch (GeneralSecurityException e) {
            KrbCryptoException ke = new KrbCryptoException(e.getMessage());
            ke.initCause(e);
            throw ke;
        }
    }
View Full Code Here

        } catch (Exception e) {
            // clear-up sensitive information
            if (cbytes != null) {
                Arrays.fill(cbytes, 0, cbytes.length, (byte) 0);
            }
            KrbCryptoException ce =
                new KrbCryptoException("Unable to convert passwd, " + e);
            ce.initCause(e);
            throw ce;
        }

        // pad data
        byte[] passwdBytes = pad(cbytes);
View Full Code Here

        byte[] result = new byte[8];
        try{
            cipher = Cipher.getInstance("DES/CBC/NoPadding");
        } catch (Exception e) {
            KrbCryptoException ke = new KrbCryptoException("JCE provider may not be installed. "
                                                           + e.getMessage());
            ke.initCause(e);
            throw ke;
        }
        IvParameterSpec params = new IvParameterSpec(ivec);
        SecretKeySpec skSpec = new SecretKeySpec(key, "DES");
        try {
            SecretKeyFactory skf = SecretKeyFactory.getInstance("DES");
            // SecretKey sk = skf.generateSecret(skSpec);
            SecretKey sk = (SecretKey) skSpec;
            cipher.init(Cipher.ENCRYPT_MODE, sk, params);
            for (int i = 0; i < msg.length / 8; i++) {
                result = cipher.doFinal(msg, i * 8, 8);
                cipher.init(Cipher.ENCRYPT_MODE, sk, (new IvParameterSpec(result)));
            }
        }
        catch (GeneralSecurityException e) {
            KrbCryptoException ke = new KrbCryptoException(e.getMessage());
            ke.initCause(e);
            throw ke;
        }
        return result;
    }
View Full Code Here

    public byte[] encrypt(byte[] data, byte[] key, byte[] ivec, int usage)
        throws KrbCryptoException {
        try {
            return ArcFourHmac.encrypt(key, usage, ivec, data, 0, data.length);
        } catch (GeneralSecurityException e) {
            KrbCryptoException ke = new KrbCryptoException(e.getMessage());
            ke.initCause(e);
            throw ke;
        }
    }
View Full Code Here

    public byte[] decrypt(byte[] cipher, byte[] key, byte[] ivec, int usage)
        throws KrbApErrException, KrbCryptoException {
        try {
            return ArcFourHmac.decrypt(key, usage, ivec, cipher, 0, cipher.length);
        } catch (GeneralSecurityException e) {
            KrbCryptoException ke = new KrbCryptoException(e.getMessage());
            ke.initCause(e);
            throw ke;
        }
    }
View Full Code Here

    public byte[] encrypt(byte[] data, byte[] key, byte[] ivec, int usage)
        throws KrbCryptoException {
        try {
            return Aes256.encrypt(key, usage, ivec, data, 0, data.length);
        } catch (GeneralSecurityException e) {
            KrbCryptoException ke = new KrbCryptoException(e.getMessage());
            ke.initCause(e);
            throw ke;
        }
    }
View Full Code Here

    public byte[] decrypt(byte[] cipher, byte[] key, byte[] ivec, int usage)
        throws KrbApErrException, KrbCryptoException {
        try {
            return Aes256.decrypt(key, usage, ivec, cipher, 0, cipher.length);
        } catch (GeneralSecurityException e) {
            KrbCryptoException ke = new KrbCryptoException(e.getMessage());
            ke.initCause(e);
            throw ke;
        }
    }
View Full Code Here

         throws KrbCryptoException {
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (Exception e) {
            throw new KrbCryptoException("JCE provider may not be installed. " + e.getMessage());
        }
        try {
            md5.update(data);
            return(md5.digest());
        } catch (Exception e) {
            throw new KrbCryptoException(e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of sun.security.krb5.KrbCryptoException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.