Package javax.crypto.spec

Examples of javax.crypto.spec.RC2ParameterSpec


                ivParam = (ParametersWithIV)param;
            }
        }
        else if (params instanceof RC2ParameterSpec)
        {
            RC2ParameterSpec    rc2Param = (RC2ParameterSpec)params;

            param = new RC2Parameters(key.getEncoded(), ((RC2ParameterSpec)params).getEffectiveKeyBits());

            if (rc2Param.getIV() != null && ivLength != 0)
            {
                param = new ParametersWithIV(param, rc2Param.getIV());
                ivParam = (ParametersWithIV)param;
            }
        }
        else if (params instanceof RC5ParameterSpec)
        {
View Full Code Here


            LittleEndian.putInt(blockKey, 0, index);
            byte[] iv = generateIv(header.getHashAlgorithmEx(), header.getKeySalt(), blockKey, blockSize);
            try {
                AlgorithmParameterSpec aps;
                if (header.getCipherAlgorithm() == CipherAlgorithm.rc2) {
                    aps = new RC2ParameterSpec(getSecretKey().getEncoded().length*8, iv);
                } else {
                    aps = new IvParameterSpec(iv);
                }
               
                _cipher.init(Cipher.ENCRYPT_MODE, getSecretKey(), aps);
View Full Code Here

            if (vec == null) {
                cipher.init(cipherMode, key);
            } else {
                AlgorithmParameterSpec aps;
                if (cipherAlgorithm == CipherAlgorithm.rc2) {
                    aps = new RC2ParameterSpec(key.getEncoded().length*8, vec);
                } else {
                    aps = new IvParameterSpec(vec);
                }
                cipher.init(cipherMode, key, aps);
            }
View Full Code Here

            LittleEndian.putInt(blockKey, 0, index);
            byte[] iv = generateIv(header.getHashAlgorithmEx(), header.getKeySalt(), blockKey, blockSize);
            try {
                AlgorithmParameterSpec aps;
                if (header.getCipherAlgorithm() == CipherAlgorithm.rc2) {
                    aps = new RC2ParameterSpec(getSecretKey().getEncoded().length*8, iv);
                } else {
                    aps = new IvParameterSpec(iv);
                }
               
                _cipher.init(Cipher.ENCRYPT_MODE, getSecretKey(), aps);
View Full Code Here

            LittleEndian.putInt(blockKey, 0, index);
            EncryptionHeader header = info.getHeader();
            byte[] iv = generateIv(header.getHashAlgorithmEx(), header.getKeySalt(), blockKey, getBlockSizeInBytes());
            AlgorithmParameterSpec aps;
            if (header.getCipherAlgorithm() == CipherAlgorithm.rc2) {
                aps = new RC2ParameterSpec(getSecretKey().getEncoded().length*8, iv);
            } else {
                aps = new IvParameterSpec(iv);
            }
           
            _cipher.init(Cipher.DECRYPT_MODE, getSecretKey(), aps);
View Full Code Here

                ivParam = (ParametersWithIV)param;
            }
        }
        else if (params instanceof RC2ParameterSpec)
        {
            RC2ParameterSpec    rc2Param = (RC2ParameterSpec)params;

            param = new RC2Parameters(key.getEncoded(), ((RC2ParameterSpec)params).getEffectiveKeyBits());

            if (rc2Param.getIV() != null && ivLength != 0)
            {
                param = new ParametersWithIV(param, rc2Param.getIV());
                ivParam = (ParametersWithIV)param;
            }
        }
        else if (params instanceof RC5ParameterSpec)
        {
View Full Code Here

            {
                if (parameterVersion != -1)
                {
                    if (parameterVersion < 256)
                    {
                        return new RC2ParameterSpec(ekb[parameterVersion], iv);
                    }
                    else
                    {
                        return new RC2ParameterSpec(parameterVersion, iv);
                    }
                }
            }

            if (paramSpec == IvParameterSpec.class)
View Full Code Here

                keyBits = 64;
            }
            sKey = getKey(password, alg, keyBits / 8, iv);
            if (paramSpec == null) // ECB block mode
            {
                paramSpec = new RC2ParameterSpec(keyBits);
            }
            else
            {
                paramSpec = new RC2ParameterSpec(keyBits, iv);
            }
        }
        else if (dekAlgName.startsWith("AES-"))
        {
            alg = "AES";
View Full Code Here

                if(params != null && params instanceof ASN1OctetString) {
                    if (algo.startsWith("RC2")) {
                        // J9's IBMJCE needs this exceptional RC2 support.
                        // Giving IvParameterSpec throws 'Illegal parameter' on IBMJCE.
                        SecretKeySpec sks = new SecretKeySpec(tmp, algo);
                        RC2ParameterSpec s = new RC2ParameterSpec(tmp.length * 8, ((ASN1OctetString) params).getOctets());
                        evpCipher.init(Cipher.DECRYPT_MODE, sks, s);
                    } else {
                        SecretKeySpec sks = new SecretKeySpec(tmp, algo);
                        IvParameterSpec iv = new IvParameterSpec(((ASN1OctetString) params).getOctets());
                        evpCipher.init(Cipher.DECRYPT_MODE, sks, iv);
View Full Code Here

                if (this.realIV == null) {
                    // no IV yet, start out with all zeros
                    this.realIV = new byte[ivLen];
                }
                if ("RC2".equalsIgnoreCase(cryptoBase)) {
                    this.ciph.init(encryptMode ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE, new SimpleSecretKey("RC2", this.key), new RC2ParameterSpec(this.key.length * 8, this.realIV));
                } else if ("RC4".equalsIgnoreCase(cryptoBase)) {
                    this.ciph.init(encryptMode ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE, new SimpleSecretKey("RC4", this.key));
                } else {
                    this.ciph.init(encryptMode ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE, new SimpleSecretKey(realName.split("/")[0], this.key), new IvParameterSpec(this.realIV));
                }
View Full Code Here

TOP

Related Classes of javax.crypto.spec.RC2ParameterSpec

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.