Examples of PBES2Parameters


Examples of org.bouncycastle.asn1.pkcs.PBES2Parameters

                // we pass "" as the key algorithm type as it is unknown at this point
                return (PrivateKey)cipher.unwrap(data, "", Cipher.PRIVATE_KEY);
            }
            else if (algorithm.equals(PKCSObjectIdentifiers.id_PBES2))
            {
                PBES2Parameters alg = PBES2Parameters.getInstance(algId.getParameters());
                PBKDF2Params func = PBKDF2Params.getInstance(alg.getKeyDerivationFunc().getParameters());

                SecretKeyFactory keyFact = SecretKeyFactory.getInstance(alg.getKeyDerivationFunc().getAlgorithm().getId(), bcProvider);

                SecretKey k = keyFact.generateSecret(new PBEKeySpec(password, func.getSalt(), func.getIterationCount().intValue(), SecretKeyUtil.getKeySize(alg.getEncryptionScheme().getAlgorithm())));

                Cipher cipher = Cipher.getInstance(alg.getEncryptionScheme().getAlgorithm().getId(), bcProvider);

                cipher.init(Cipher.UNWRAP_MODE, k, new IvParameterSpec(ASN1OctetString.getInstance(alg.getEncryptionScheme().getParameters()).getOctets()));

                // we pass "" as the key algorithm type as it is unknown at this point
                return (PrivateKey)cipher.unwrap(data, "", Cipher.PRIVATE_KEY);
            }
        }
View Full Code Here

Examples of org.bouncycastle.asn1.pkcs.PBES2Parameters

            catch (Exception e)
            {
                return new SimpleTestResult(false, getName() + ": failed construction - exception " + e.toString());
            }

            PBES2Parameters         alg = new PBES2Parameters((ASN1Sequence)info.getEncryptionAlgorithm().getParameters());
            PBKDF2Params            func = PBKDF2Params.getInstance(alg.getKeyDerivationFunc().getParameters());
            EncryptionScheme        scheme = alg.getEncryptionScheme();
   
            if (func.getKeyLength() != null)
            {
                keySize = func.getKeyLength().intValue() * 8;
            }
View Full Code Here

Examples of org.bouncycastle.asn1.pkcs.PBES2Parameters

        return (PrivateKey) cipher.unwrap(eIn.getEncryptedData(), "", Cipher.PRIVATE_KEY);
    }

    private static PrivateKey derivePrivateKeyPBES2(org.bouncycastle.asn1.pkcs.EncryptedPrivateKeyInfo eIn, AlgorithmIdentifier algId, char[] password)
            throws GeneralSecurityException, InvalidCipherTextException {
        PBES2Parameters pbeParams = new PBES2Parameters((ASN1Sequence) algId.getParameters());
        CipherParameters cipherParams = extractPBES2CipherParams(password, pbeParams);

        EncryptionScheme scheme = pbeParams.getEncryptionScheme();
        BufferedBlockCipher cipher;
        if (scheme.getAlgorithm().equals(PKCSObjectIdentifiers.RC2_CBC)) {
            RC2CBCParameter rc2Params = new RC2CBCParameter((ASN1Sequence) scheme.getObject());
            byte[] iv = rc2Params.getIV();
            CipherParameters param = new ParametersWithIV(cipherParams, iv);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.