• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RSAESOAEPparams类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.bouncycastle.asn1.pkcs.RSAESOAEPparams的典型用法代码示例。如果您正苦于以下问题:Java RSAESOAEPparams类的具体用法?Java RSAESOAEPparams怎么用?Java RSAESOAEPparams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RSAESOAEPparams类属于org.bouncycastle.asn1.pkcs包,在下文中一共展示了RSAESOAEPparams类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: engineGetEncoded

点赞 3

import org.bouncycastle.asn1.pkcs.RSAESOAEPparams; //导入依赖的package包/类
/**
 * Return the PKCS#1 ASN.1 structure RSAES-OAEP-params.
 */
protected byte[] engineGetEncoded() 
{
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                                    DigestFactory.getOID(currentSpec.getDigestAlgorithm()),
                                                    DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                                    PKCSObjectIdentifiers.id_mgf1,
                                                    new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    PSource.PSpecified      pSource = (PSource.PSpecified)currentSpec.getPSource();
    AlgorithmIdentifier pSourceAlgorithm = new AlgorithmIdentifier(
                                                    PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue()));
    RSAESOAEPparams oaepP = new RSAESOAEPparams(hashAlgorithm, maskGenAlgorithm, pSourceAlgorithm);
    
    try
    {
        return oaepP.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding OAEPParameters");
    }
}
 

开发者ID:Appdome,
项目名称:ipack,
代码行数:27,
代码来源:AlgorithmParametersSpi.java

示例2: getAlgorithmIdentifier

点赞 2

import org.bouncycastle.asn1.pkcs.RSAESOAEPparams; //导入依赖的package包/类
public AlgorithmIdentifier getAlgorithmIdentifier(ASN1ObjectIdentifier algorithm, AlgorithmParameterSpec algorithmSpec)
    throws InvalidAlgorithmParameterException
{
    if (algorithmSpec instanceof OAEPParameterSpec)
    {
        if (algorithmSpec.equals(OAEPParameterSpec.DEFAULT))
        {
            return new AlgorithmIdentifier(algorithm,
                new RSAESOAEPparams(RSAESOAEPparams.DEFAULT_HASH_ALGORITHM, RSAESOAEPparams.DEFAULT_MASK_GEN_FUNCTION, RSAESOAEPparams.DEFAULT_P_SOURCE_ALGORITHM));
        }
        else
        {
            OAEPParameterSpec oaepSpec = (OAEPParameterSpec)algorithmSpec;
            PSource pSource = oaepSpec.getPSource();

            if (!oaepSpec.getMGFAlgorithm().equals(OAEPParameterSpec.DEFAULT.getMGFAlgorithm()))
            {
                throw new InvalidAlgorithmParameterException("only " + OAEPParameterSpec.DEFAULT.getMGFAlgorithm() + " mask generator supported.");
            }

            AlgorithmIdentifier hashAlgorithm = new DefaultDigestAlgorithmIdentifierFinder().find(oaepSpec.getDigestAlgorithm());
            AlgorithmIdentifier mgf1HashAlgorithm = new DefaultDigestAlgorithmIdentifierFinder().find((((MGF1ParameterSpec)oaepSpec.getMGFParameters()).getDigestAlgorithm()));
            return new AlgorithmIdentifier(algorithm,
                                new RSAESOAEPparams(hashAlgorithm, new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, mgf1HashAlgorithm),
                                                    new AlgorithmIdentifier(PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(((PSource.PSpecified)pSource).getValue()))));
        }
    }

    throw new InvalidAlgorithmParameterException("unknown parameter spec passed.");
}
 

开发者ID:thedrummeraki,
项目名称:Aki-SSL,
代码行数:31,
代码来源:JcaAlgorithmParametersConverter.java

示例3: makeOaepCertificate

点赞 2

import org.bouncycastle.asn1.pkcs.RSAESOAEPparams; //导入依赖的package包/类
public static X509Certificate makeOaepCertificate(KeyPair subKP, String _subDN, KeyPair issKP, String _issDN, boolean _ca)
    throws GeneralSecurityException, IOException, OperatorCreationException
{

    SubjectPublicKeyInfo  subPub  = SubjectPublicKeyInfo.getInstance(subKP.getPublic().getEncoded());
    PrivateKey issPriv = issKP.getPrivate();
    PublicKey  issPub  = issKP.getPublic();

    X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(
        new X500Name(_issDN),
        allocateSerialNumber(),
        new Date(System.currentTimeMillis()),
        new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 100)),
        new X500Name(_subDN),
        new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.id_RSAES_OAEP, new RSAESOAEPparams()), subPub.parsePublicKey()));

    JcaContentSignerBuilder contentSignerBuilder = makeContentSignerBuilder(issPub);

    v3CertGen.addExtension(
        Extension.subjectKeyIdentifier,
        false,
        createSubjectKeyId(subPub));

    v3CertGen.addExtension(
        Extension.authorityKeyIdentifier,
        false,
        createAuthorityKeyId(issPub));

    v3CertGen.addExtension(
        Extension.basicConstraints,
        false,
        new BasicConstraints(_ca));

    X509Certificate _cert = new JcaX509CertificateConverter().setProvider("BC").getCertificate(v3CertGen.build(contentSignerBuilder.build(issPriv)));

    _cert.checkValidity(new Date());
    _cert.verify(issPub);

    return _cert;
}
 

开发者ID:credentials,
项目名称:irma_future_id,
代码行数:41,
代码来源:CMSTestUtil.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)