Search in sources :

Example 21 with PKCS12PBEParams

use of com.github.zhenwei.core.asn1.pkcs.PKCS12PBEParams in project LinLong-Java by zhenwei1108.

the class MacDataGenerator method build.

public MacData build(char[] password, byte[] data) throws PKCSException {
    MacCalculator macCalculator;
    try {
        macCalculator = builder.build(password);
        OutputStream out = macCalculator.getOutputStream();
        out.write(data);
        out.close();
    } catch (Exception e) {
        throw new PKCSException("unable to process data: " + e.getMessage(), e);
    }
    AlgorithmIdentifier algId = macCalculator.getAlgorithmIdentifier();
    DigestInfo dInfo = new DigestInfo(builder.getDigestAlgorithmIdentifier(), macCalculator.getMac());
    PKCS12PBEParams params = PKCS12PBEParams.getInstance(algId.getParameters());
    return new MacData(dInfo, params.getIV(), params.getIterations().intValue());
}
Also used : MacData(com.github.zhenwei.core.asn1.pkcs.MacData) DigestInfo(com.github.zhenwei.core.asn1.x509.DigestInfo) PKCS12PBEParams(com.github.zhenwei.core.asn1.pkcs.PKCS12PBEParams) OutputStream(java.io.OutputStream) MacCalculator(com.github.zhenwei.pkix.operator.MacCalculator) AlgorithmIdentifier(com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier)

Aggregations

PKCS12PBEParams (com.github.zhenwei.core.asn1.pkcs.PKCS12PBEParams)13 AlgorithmIdentifier (com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier)11 IOException (java.io.IOException)11 Cipher (javax.crypto.Cipher)10 PBEParameterSpec (javax.crypto.spec.PBEParameterSpec)10 KeyStoreException (java.security.KeyStoreException)9 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)9 UnrecoverableKeyException (java.security.UnrecoverableKeyException)9 CertificateEncodingException (java.security.cert.CertificateEncodingException)9 CertificateException (java.security.cert.CertificateException)9 SecretKey (javax.crypto.SecretKey)7 SecretKeyFactory (javax.crypto.SecretKeyFactory)7 PBEKeySpec (javax.crypto.spec.PBEKeySpec)7 GenericKey (com.github.zhenwei.pkix.operator.GenericKey)6 PKCS12PBEParams (org.bouncycastle.asn1.pkcs.PKCS12PBEParams)6 ASN1ObjectIdentifier (com.github.zhenwei.core.asn1.ASN1ObjectIdentifier)5 OperatorCreationException (com.github.zhenwei.pkix.operator.OperatorCreationException)5 PrivateKey (java.security.PrivateKey)5 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)5 DEROctetString (org.bouncycastle.asn1.DEROctetString)5