• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RSABlindedEngine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: decryptPreMasterSecret

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
public byte[] decryptPreMasterSecret(byte[] encryptedPreMasterSecret)
    throws IOException
{

    PKCS1Encoding encoding = new PKCS1Encoding(new RSABlindedEngine());
    encoding.init(false, new ParametersWithRandom(this.privateKey, context.getSecureRandom()));

    try
    {
        return encoding.processBlock(encryptedPreMasterSecret, 0,
            encryptedPreMasterSecret.length);
    }
    catch (InvalidCipherTextException e)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:DefaultTlsEncryptionCredentials.java


示例2: engineUpdate

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
protected byte[] engineUpdate(
    byte[]  input,
    int     inputOffset,
    int     inputLen) 
{
    bOut.write(input, inputOffset, inputLen);

    if (cipher instanceof RSABlindedEngine)
    {
        if (bOut.size() > cipher.getInputBlockSize() + 1)
        {
            throw new ArrayIndexOutOfBoundsException("too much data for RSA block");
        }
    }
    else
    {
        if (bOut.size() > cipher.getInputBlockSize())
        {
            throw new ArrayIndexOutOfBoundsException("too much data for RSA block");
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:CipherSpi.java


示例3: getRSADecryptCipher

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
/**
 * @return an RSA decryption cipher
 */
protected synchronized AsymmetricBlockCipher getRSADecryptCipher()
{
	if (decodeCipher == null)
	{
		try
		{
			byte[] bytes = getEncoder().decode(privateKey);
			EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(bytes);

			KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM);
			PrivateKey key = keyFactory.generatePrivate(privateKeySpec);

			this.decodeCipher = new PKCS1Encoding(new RSABlindedEngine());
			decodeCipher.init(false, generatePrivateKeyParameter((RSAPrivateKey) key));
		}
		catch (Exception e)
		{
			throw new RuntimeException("Error constructing Cipher: ", e);
		}
	}

	return decodeCipher;
}
 
开发者ID:chuckbuckethead,项目名称:cypher,代码行数:27,代码来源:RSAKey.java


示例4: getRSAEncryptCipher

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
/**
 * @return
 */
protected synchronized AsymmetricBlockCipher getRSAEncryptCipher()
{
	if (encodeCipher == null)
	{
		try
		{
			byte[] bytes = getEncoder().decode(publicKey);
			EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(bytes);

			KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM);
			PublicKey key = keyFactory.generatePublic(publicKeySpec);

			this.encodeCipher = new PKCS1Encoding(new RSABlindedEngine());
			encodeCipher.init(true, generatePublicKeyParameter((RSAPublicKey) key));
		}
		catch (Exception e)
		{
			throw new RuntimeException("Error constructing Cipher: ", e);
		}
	}

	return encodeCipher;
}
 
开发者ID:chuckbuckethead,项目名称:cypher,代码行数:27,代码来源:RSAKey.java


示例5: engineUpdate

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
protected int engineUpdate(
    byte[]  input,
    int     inputOffset,
    int     inputLen,
    byte[]  output,
    int     outputOffset) 
{
    bOut.write(input, inputOffset, inputLen);

    if (cipher instanceof RSABlindedEngine)
    {
        if (bOut.size() > cipher.getInputBlockSize() + 1)
        {
            throw new ArrayIndexOutOfBoundsException("too much data for RSA block");
        }
    }
    else
    {
        if (bOut.size() > cipher.getInputBlockSize())
        {
            throw new ArrayIndexOutOfBoundsException("too much data for RSA block");
        }
    }

    return 0;
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:27,代码来源:CipherSpi.java


示例6: generateClientKeyExchange

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
public byte[] generateClientKeyExchange() throws IOException
{
    /*
     * Choose a PremasterSecret and send it encrypted to the server
     */
    premasterSecret = new byte[48];
    handler.getRandom().nextBytes(premasterSecret);
    TlsUtils.writeVersion(premasterSecret, 0);

    PKCS1Encoding encoding = new PKCS1Encoding(new RSABlindedEngine());
    encoding.init(true, new ParametersWithRandom(this.rsaServerPublicKey, handler.getRandom()));

    try
    {
        return encoding.processBlock(premasterSecret, 0, premasterSecret.length);
    }
    catch (InvalidCipherTextException e)
    {
        /*
         * This should never happen, only during decryption.
         */
        handler.failWithError(TlsProtocolHandler.AL_fatal, TlsProtocolHandler.AP_internal_error);
        return null; // Unreachable!
    }
}
 
开发者ID:coova,项目名称:jradius,代码行数:26,代码来源:TlsRSAKeyExchange.java


示例7: createRSAImpl

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
protected AsymmetricBlockCipher createRSAImpl()
{
    /*
     * RFC 5264 7.4.7.1. Implementation note: It is now known that remote timing-based attacks
     * on TLS are possible, at least when the client and server are on the same LAN.
     * Accordingly, implementations that use static RSA keys MUST use RSA blinding or some other
     * anti-timing technique, as described in [TIMING].
     */
    return new PKCS1Encoding(new RSABlindedEngine());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:11,代码来源:TlsRSASigner.java


示例8: generateEncryptedPreMasterSecret

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
public static byte[] generateEncryptedPreMasterSecret(TlsContext context, RSAKeyParameters rsaServerPublicKey,
                                                      OutputStream output)
    throws IOException
{
    /*
     * Choose a PremasterSecret and send it encrypted to the server
     */
    byte[] premasterSecret = new byte[48];
    context.getSecureRandom().nextBytes(premasterSecret);
    TlsUtils.writeVersion(context.getClientVersion(), premasterSecret, 0);

    PKCS1Encoding encoding = new PKCS1Encoding(new RSABlindedEngine());
    encoding.init(true, new ParametersWithRandom(rsaServerPublicKey, context.getSecureRandom()));

    try
    {
        byte[] encryptedPreMasterSecret = encoding.processBlock(premasterSecret, 0, premasterSecret.length);

        if (context.getServerVersion().isSSL())
        {
            // TODO Do any SSLv3 servers actually expect the length?
            output.write(encryptedPreMasterSecret);
        }
        else
        {
            TlsUtils.writeOpaque16(encryptedPreMasterSecret, output);
        }
    }
    catch (InvalidCipherTextException e)
    {
        /*
         * This should never happen, only during decryption.
         */
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }

    return premasterSecret;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:39,代码来源:TlsRSAUtils.java


示例9: initFromSpec

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
private void initFromSpec(
    OAEPParameterSpec pSpec)
    throws NoSuchPaddingException
{
    MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)pSpec.getMGFParameters();
    Digest digest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm());
    
    if (digest == null)
    {
        throw new NoSuchPaddingException("no match on OAEP constructor for digest algorithm: "+ mgfParams.getDigestAlgorithm());
    }

    cipher = new OAEPEncoding(new RSABlindedEngine(), digest, ((PSource.PSpecified)pSpec.getPSource()).getValue());
    paramSpec = pSpec;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:CipherSpi.java


示例10: engineDoFinal

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
protected byte[] engineDoFinal(
    byte[]  input,
    int     inputOffset,
    int     inputLen) 
    throws IllegalBlockSizeException, BadPaddingException
{
    if (input != null)
    {
        bOut.write(input, inputOffset, inputLen);
    }

    if (cipher instanceof RSABlindedEngine)
    {
        if (bOut.size() > cipher.getInputBlockSize() + 1)
        {
            throw new ArrayIndexOutOfBoundsException("too much data for RSA block");
        }
    }
    else
    {
        if (bOut.size() > cipher.getInputBlockSize())
        {
            throw new ArrayIndexOutOfBoundsException("too much data for RSA block");
        }
    }

    try
    {
        byte[]  bytes = bOut.toByteArray();

        bOut.reset();

        return cipher.processBlock(bytes, 0, bytes.length);
    }
    catch (InvalidCipherTextException e)
    {
        throw new BadPaddingException(e.getMessage());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:40,代码来源:CipherSpi.java


示例11: createPSSRSASigner

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
public static PSSSigner createPSSRSASigner(AlgorithmIdentifier sigAlgId,
        AsymmetricBlockCipher cipher) throws XiSecurityException {
    ParamUtil.requireNonNull("sigAlgId", sigAlgId);
    if (!PKCSObjectIdentifiers.id_RSASSA_PSS.equals(sigAlgId.getAlgorithm())) {
        throw new XiSecurityException("signature algorithm " + sigAlgId.getAlgorithm()
            + " is not allowed");
    }

    AlgorithmIdentifier digAlgId;
    try {
        digAlgId = AlgorithmUtil.extractDigesetAlgFromSigAlg(sigAlgId);
    } catch (NoSuchAlgorithmException ex) {
        throw new XiSecurityException(ex.getMessage(), ex);
    }

    RSASSAPSSparams param = RSASSAPSSparams.getInstance(sigAlgId.getParameters());

    AlgorithmIdentifier mfgDigAlgId = AlgorithmIdentifier.getInstance(
            param.getMaskGenAlgorithm().getParameters());

    Digest dig = getDigest(digAlgId);
    Digest mfgDig = getDigest(mfgDigAlgId);

    int saltSize = param.getSaltLength().intValue();
    int trailerField = param.getTrailerField().intValue();
    AsymmetricBlockCipher tmpCipher = (cipher == null) ? new RSABlindedEngine() : cipher;

    return new PSSSigner(tmpCipher, dig, mfgDig, saltSize, getTrailer(trailerField));
}
 
开发者ID:xipki,项目名称:xitk,代码行数:30,代码来源:SignerUtil.java


示例12: generateEncryptedPreMasterSecret

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
public static byte[] generateEncryptedPreMasterSecret(TlsContext context, RSAKeyParameters rsaServerPublicKey,
    OutputStream output) throws IOException
{
    /*
     * Choose a PremasterSecret and send it encrypted to the server
     */
    byte[] premasterSecret = new byte[48];
    context.getSecureRandom().nextBytes(premasterSecret);
    TlsUtils.writeVersion(context.getClientVersion(), premasterSecret, 0);

    PKCS1Encoding encoding = new PKCS1Encoding(new RSABlindedEngine());
    encoding.init(true, new ParametersWithRandom(rsaServerPublicKey, context.getSecureRandom()));

    try
    {
        byte[] encryptedPreMasterSecret = encoding.processBlock(premasterSecret, 0, premasterSecret.length);

        if (TlsUtils.isSSL(context))
        {
            // TODO Do any SSLv3 servers actually expect the length?
            output.write(encryptedPreMasterSecret);
        }
        else
        {
            TlsUtils.writeOpaque16(encryptedPreMasterSecret, output);
        }
    }
    catch (InvalidCipherTextException e)
    {
        /*
         * This should never happen, only during decryption.
         */
        throw new TlsFatalAlert(AlertDescription.internal_error, e);
    }

    return premasterSecret;
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:38,代码来源:TlsRSAUtils.java


示例13: doFullMessageTest

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
private void doFullMessageTest()
    throws Exception
{
    BigInteger modulus = new BigInteger(1, Hex.decode("CDCBDABBF93BE8E8294E32B055256BBD0397735189BF75816341BB0D488D05D627991221DF7D59835C76A4BB4808ADEEB779E7794504E956ADC2A661B46904CDC71337DD29DDDD454124EF79CFDD7BC2C21952573CEFBA485CC38C6BD2428809B5A31A898A6B5648CAA4ED678D9743B589134B7187478996300EDBA16271A861"));
    BigInteger pubExp = new BigInteger(1, Hex.decode("010001"));
    BigInteger privExp = new BigInteger(1, Hex.decode("4BA6432AD42C74AA5AFCB6DF60FD57846CBC909489994ABD9C59FE439CC6D23D6DE2F3EA65B8335E796FD7904CA37C248367997257AFBD82B26F1A30525C447A236C65E6ADE43ECAAF7283584B2570FA07B340D9C9380D88EAACFFAEEFE7F472DBC9735C3FF3A3211E8A6BBFD94456B6A33C17A2C4EC18CE6335150548ED126D"));

    RSAKeyParameters pubParams = new RSAKeyParameters(false, modulus, pubExp);
    RSAKeyParameters privParams = new RSAKeyParameters(true, modulus, privExp);

    AsymmetricBlockCipher rsaEngine = new RSABlindedEngine();

    // set challenge to all zero's for verification
    byte[] challenge = new byte[8];

    ISO9796d2PSSSigner pssSign = new ISO9796d2PSSSigner(new RSAEngine(), new SHA256Digest(), 20, true);

    pssSign.init(true, privParams);

    pssSign.update(challenge, 0, challenge.length);

    byte[] sig = pssSign.generateSignature();

    pssSign.init(false, pubParams);

    pssSign.updateWithRecoveredMessage(sig);

    if (!pssSign.verifySignature(sig))
    {
        fail("challenge PSS sig verification failed.");
    }

    byte[] mm = pssSign.getRecoveredMessage();

    if (!Arrays.areEqual(challenge, mm))
    {
        fail("challenge partial PSS recovery failed");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:40,代码来源:ISO9796Test.java


示例14: generateEncryptedPreMasterSecret

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
public static byte[] generateEncryptedPreMasterSecret(TlsContext context, RSAKeyParameters rsaServerPublicKey,
    OutputStream output) throws IOException
{
    /*
     * Choose a PremasterSecret and send it encrypted to the server
     */
    byte[] premasterSecret = new byte[48];
    context.getSecureRandom().nextBytes(premasterSecret);
    TlsUtils.writeVersion(context.getClientVersion(), premasterSecret, 0);

    PKCS1Encoding encoding = new PKCS1Encoding(new RSABlindedEngine());
    encoding.init(true, new ParametersWithRandom(rsaServerPublicKey, context.getSecureRandom()));

    try
    {
        byte[] encryptedPreMasterSecret = encoding.processBlock(premasterSecret, 0, premasterSecret.length);

        if (TlsUtils.isSSL(context))
        {
            // TODO Do any SSLv3 servers actually expect the length?
            output.write(encryptedPreMasterSecret);
        }
        else
        {
            TlsUtils.writeOpaque16(encryptedPreMasterSecret, output);
        }
    }
    catch (InvalidCipherTextException e)
    {
        /*
         * This should never happen, only during decryption.
         */
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }

    return premasterSecret;
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:38,代码来源:TlsRSAUtils.java


示例15: calculateRawSignature

import org.bouncycastle.crypto.engines.RSABlindedEngine; //导入依赖的package包/类
public byte[] calculateRawSignature(AsymmetricKeyParameter privateKey, byte[] md5andsha1)
    throws CryptoException
{
    Signer sig = new GenericSigner(new PKCS1Encoding(new RSABlindedEngine()), new NullDigest());
    sig.init(true, privateKey);
    sig.update(md5andsha1, 0, md5andsha1.length);
    return sig.generateSignature();
}
 
开发者ID:coova,项目名称:jradius,代码行数:9,代码来源:TlsRSASigner.java



注:本文中的org.bouncycastle.crypto.engines.RSABlindedEngine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ObservableRecyclerView类代码示例发布时间:2022-05-21
下一篇:
Java StartTlsRequest类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap