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

Java IESParameterSpec类代码示例

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

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



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

示例1: engineInit

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
public void engineInit(
    int opmode,
    Key key,
    AlgorithmParameters params,
    SecureRandom random)
    throws InvalidKeyException, InvalidAlgorithmParameterException
{
    AlgorithmParameterSpec paramSpec = null;

    if (params != null)
    {
        try
        {
            paramSpec = params.getParameterSpec(IESParameterSpec.class);
        }
        catch (Exception e)
        {
            throw new InvalidAlgorithmParameterException("cannot recognise parameters: " + e.toString());
        }
    }

    engineParam = params;
    engineInit(opmode, key, paramSpec, random);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:IESCipher.java


示例2: engineInit

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
public void engineInit(
    int opmode,
    Key key,
    AlgorithmParameters params,
    SecureRandom random)
    throws InvalidKeyException, InvalidAlgorithmParameterException
{
    AlgorithmParameterSpec paramSpec = null;

    if (params != null)
    {
        try
        {
            paramSpec = params.getParameterSpec(IESParameterSpec.class);
        }
        catch (Exception e)
        {
            throw new InvalidAlgorithmParameterException("cannot recognise parameters: " + e.toString());
        }
    }

    engineParam = params;
    engineInit(opmode, key, paramSpec, random);

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


示例3: guessParameterSpec

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
public static IESParameterSpec guessParameterSpec(IESEngine engine)
{
    if (engine.getCipher() == null)
    {
        return new IESParameterSpec(null, null, 128);
    }
    else if (engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("DES") ||
            engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("RC2") ||
            engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("RC5-32") ||
            engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("RC5-64"))
    {
        return new IESParameterSpec(null, null, 64, 64);
    }
    else if (engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("SKIPJACK"))
    {
        return new IESParameterSpec(null, null, 80, 80);
    }
    else if (engine.getCipher().getUnderlyingCipher().getAlgorithmName().equals("GOST28147"))
    {
        return new IESParameterSpec(null, null, 256, 256);
    }

    return new IESParameterSpec(null, null, 128, 128);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:IESUtil.java


示例4: itsEceisEncryptSymmetricKeyVer1

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
/**
 * Help method to perform a ECIES encryption to a recipient of a symmetric key according to the protool version 1 standard. 
 * 
 * @param publicKeyAlgorithm the algorithm used.
 * @param encryptionKey the public encryption key of the recipient
 * @param symmetricKey the symmetric key to encrypt
 * @return a EciesNistP256EncryptedKey to be included in a SecureMessage header.
 * 
 * @throws InvalidKeyException if supplied key was corrupt.
 * @throws InvalidAlgorithmParameterException if algorithm was badly specified.
 * @throws IllegalBlockSizeException if encrypted data was corrupt.
 * @throws BadPaddingException if encrypted data was corrupt.
 * @throws IllegalArgumentException if arguments where invalid or algorithm not supported.
 * @throws InvalidKeySpecException if supplied key specification was faulty.
 * @throws IOException if communication problem occurred with underlying systems.
 */
protected EciesNistP256EncryptedKey itsEceisEncryptSymmetricKeyVer1(PublicKeyAlgorithm publicKeyAlgorithm, PublicKey encryptionKey, Key symmetricKey) throws InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, IllegalArgumentException, InvalidKeySpecException, IOException{
	if(publicKeyAlgorithm != PublicKeyAlgorithm.ecies_nistp256){
		throw new IllegalArgumentException("Unsupported encryption public key algorithm: " + publicKeyAlgorithm);
	}
	byte[] keyData = symmetricKey.getEncoded();
	
	IESCipher eCIESCipher = new ECIES();
	eCIESCipher.engineInit(Cipher.ENCRYPT_MODE, encryptionKey, new IESParameterSpec(null, null, 128),secureRandom);
			
	byte[] encryptedData = eCIESCipher.engineDoFinal(keyData, 0, keyData.length);
	
	byte[] v = new byte[ECIES_NIST_P256_V_LENGTH_VER1];
	System.arraycopy(encryptedData, 0, v, 0,ECIES_NIST_P256_V_LENGTH_VER1);
       
       EccPoint p = new EccPoint(publicKeyAlgorithm);
       p.decode(new DataInputStream(new ByteArrayInputStream(v)));
       
	byte[] c = new byte[publicKeyAlgorithm.getRelatedSymmetricAlgorithm().getKeyLength()];
	byte[] t = new byte[EciesNistP256EncryptedKey.VER1_OUTPUT_TAG_LENGTH];
	System.arraycopy(encryptedData, ECIES_NIST_P256_V_LENGTH_VER1, c, 0, publicKeyAlgorithm.getRelatedSymmetricAlgorithm().getKeyLength());
	System.arraycopy(encryptedData, ECIES_NIST_P256_V_LENGTH_VER1 + publicKeyAlgorithm.getRelatedSymmetricAlgorithm().getKeyLength(), t, 0, EciesNistP256EncryptedKey.VER1_OUTPUT_TAG_LENGTH);
	
	return new EciesNistP256EncryptedKey(1,publicKeyAlgorithm, p, c,t); 
}
 
开发者ID:pvendil,项目名称:c2c-common,代码行数:41,代码来源:DefaultCryptoManager.java


示例5: itsEceisEncryptSymmetricKeyVer2

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
/**
 * Help method to perform a ECIES encryption to a recipient of a symmetric key according to the protocol version 2 standard. 
 * 
 * @param publicKeyAlgorithm the algorithm used.
 * @param encryptionKey the public encryption key of the recipient
 * @param symmetricKey the symmetric key to encrypt
 * @return a EciesNistP256EncryptedKey to be included in a SecureMessage header.
 * 
 * @throws InvalidKeyException if supplied key was corrupt.
 * @throws InvalidAlgorithmParameterException if algorithm was badly specified.
 * @throws IllegalBlockSizeException if encrypted data was corrupt.
 * @throws BadPaddingException if encrypted data was corrupt.
 * @throws IllegalArgumentException if arguments where invalid or algorithm not supported.
 * @throws InvalidKeySpecException if supplied key specification was faulty.
 * @throws IOException if communication problem occurred with underlying systems.
 */
protected EciesNistP256EncryptedKey itsEceisEncryptSymmetricKeyVer2(PublicKeyAlgorithm publicKeyAlgorithm, PublicKey encryptionKey, Key symmetricKey) throws InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, IllegalArgumentException, InvalidKeySpecException, IOException{
	if(publicKeyAlgorithm != PublicKeyAlgorithm.ecies_nistp256){
		throw new IllegalArgumentException("Unsupported encryption public key algorithm: " + publicKeyAlgorithm);
	}
	byte[] keyData = symmetricKey.getEncoded();
	
	IESCipher eCIESCipher = new IEEE1609Dot2ECIES();
	eCIESCipher.engineInit(Cipher.ENCRYPT_MODE, encryptionKey,  new IESParameterSpec(null, null, 128,-1, null, true),secureRandom);
			
	byte[] encryptedData = eCIESCipher.engineDoFinal(keyData, 0, keyData.length);
	
	byte[] v = new byte[ECIES_NIST_P256_V_LENGTH_VER2];
	System.arraycopy(encryptedData, 0, v, 0,ECIES_NIST_P256_V_LENGTH_VER2);
       
       EccPoint p = new EccPoint(publicKeyAlgorithm);
       p.decode(new DataInputStream(new ByteArrayInputStream(v)));
       
	byte[] c = new byte[publicKeyAlgorithm.getRelatedSymmetricAlgorithm().getKeyLength()];
	byte[] t = new byte[EciesNistP256EncryptedKey.VER2_OUTPUT_TAG_LENGTH];
	System.arraycopy(encryptedData, ECIES_NIST_P256_V_LENGTH_VER2, c, 0, publicKeyAlgorithm.getRelatedSymmetricAlgorithm().getKeyLength());
	System.arraycopy(encryptedData, ECIES_NIST_P256_V_LENGTH_VER2 + publicKeyAlgorithm.getRelatedSymmetricAlgorithm().getKeyLength(), t, 0, EciesNistP256EncryptedKey.VER2_OUTPUT_TAG_LENGTH);
	
	return new EciesNistP256EncryptedKey(SecuredMessage.PROTOCOL_VERSION_2,publicKeyAlgorithm, p, c,t); 
}
 
开发者ID:pvendil,项目名称:c2c-common,代码行数:41,代码来源:DefaultCryptoManager.java


示例6: ieeeEceisEncryptSymmetricKey

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
/**
 * Help method to perform a ECIES encryption to a recipient of a symmetric key. 
 * 
 * @param publicKeyAlgorithm the algorithm used.
 * @param encryptionKey the public encryption key of the recipient
 * @param symmetricKey the symmetric key to encrypt
 * @return a EciesNistP256EncryptedKey to be included in a SecureMessage header.
 * 
 * @throws InvalidKeyException if supplied key was corrupt.
 * @throws InvalidAlgorithmParameterException if algorithm was badly specified.
 * @throws IllegalBlockSizeException if encrypted data was corrupt.
 * @throws BadPaddingException if encrypted data was corrupt.
 * @throws IllegalArgumentException if arguments where invalid or algorithm not supported.
 * @throws InvalidKeySpecException if supplied key specification was faulty.
 * @throws IOException if communication problem occurred with underlying systems.
 */
@Override
public EncryptedDataEncryptionKey ieeeEceisEncryptSymmetricKey(EncryptedDataEncryptionKeyChoices keyType, PublicKey encryptionKey, SecretKey symmetricKey, AlgorithmIndicator alg,byte[] eciesDeviation) throws IllegalArgumentException, GeneralSecurityException, IOException{
	byte[] keyData = symmetricKey.getEncoded();

	IESCipher eCIESCipher = new IEEE1609Dot2ECIES();
	eCIESCipher.engineInit(Cipher.ENCRYPT_MODE, encryptionKey, new IESParameterSpec(eciesDeviation, null, 128,-1, null, true),secureRandom);
			
	byte[] encryptedData = eCIESCipher.engineDoFinal(keyData, 0, keyData.length);
	byte[] v = new byte[keyType.getVLength()];
	System.arraycopy(encryptedData, 0, v, 0,keyType.getVLength());
       
	EccP256CurvePoint p = new EccP256CurvePoint(v);
       //p.decode(new DataInputStream(new ByteArrayInputStream(v)));
       
	byte[] c = new byte[alg.getAlgorithm().getSymmetric().getKeyLength()];
	byte[] t = new byte[keyType.getOutputTagLength()];
	System.arraycopy(encryptedData, keyType.getVLength(), c, 0, alg.getAlgorithm().getSymmetric().getKeyLength());
	System.arraycopy(encryptedData, keyType.getVLength() + alg.getAlgorithm().getSymmetric().getKeyLength(), t, 0, keyType.getOutputTagLength());
	
	EciesP256EncryptedKey key = new EciesP256EncryptedKey(p,c,t);
	return new EncryptedDataEncryptionKey(keyType, key);
	 
}
 
开发者ID:pvendil,项目名称:c2c-common,代码行数:40,代码来源:DefaultCryptoManager.java


示例7: itsEceisDecryptSymmetricKeyVer1

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
/**
 * Help method to perform a ECIES decryption of a symmetric key using the ITS protocol version 1 specification. 
 * 
 * @param eciesNistP256EncryptedKey the EciesNistP256EncryptedKey header value from the SecuredMessage
 * @param decryptionKey the receiptients private key
 * @return a decrypted symmetric key.
 * 
 * @throws InvalidKeyException if supplied key was corrupt.
 * @throws InvalidAlgorithmParameterException if algorithm was badly specified.
 * @throws IllegalBlockSizeException if encrypted data was corrupt.
 * @throws BadPaddingException if encrypted data was corrupt.
 * @throws IllegalArgumentException if arguments where invalid or algorithm not supported.
 * @throws InvalidKeySpecException if supplied key specification was faulty.
 * @throws IOException if communication problem occurred with underlying systems.
 */
protected Key itsEceisDecryptSymmetricKeyVer1(EciesNistP256EncryptedKey eciesNistP256EncryptedKey, PrivateKey decryptionKey) throws InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, IllegalArgumentException, InvalidKeySpecException, IOException{
	if(eciesNistP256EncryptedKey.getPublicKeyAlgorithm() != PublicKeyAlgorithm.ecies_nistp256){
		throw new IllegalArgumentException("Unsupported encryption public key algorithm: " + eciesNistP256EncryptedKey.getPublicKeyAlgorithm() );
	}
	
	IESCipher eCIESCipher = new ECIES();
	eCIESCipher.engineInit(Cipher.DECRYPT_MODE, decryptionKey, new IESParameterSpec(null, null, 128),secureRandom);
			
	byte[] encryptedData = new byte[ECIES_NIST_P256_V_LENGTH_VER1 + eciesNistP256EncryptedKey.getPublicKeyAlgorithm().getRelatedSymmetricAlgorithm().getKeyLength() + EciesNistP256EncryptedKey.VER1_OUTPUT_TAG_LENGTH];
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	DataOutputStream dis = new DataOutputStream(baos);
	
	eciesNistP256EncryptedKey.getV().encode(dis);
	baos.close();
	System.arraycopy(baos.toByteArray(), 0, encryptedData, 0, ECIES_NIST_P256_V_LENGTH_VER1);
	System.arraycopy(eciesNistP256EncryptedKey.getC(), 0, encryptedData, ECIES_NIST_P256_V_LENGTH_VER1, eciesNistP256EncryptedKey.getPublicKeyAlgorithm().getRelatedSymmetricAlgorithm().getKeyLength());
	System.arraycopy(eciesNistP256EncryptedKey.getT(), 0, encryptedData, ECIES_NIST_P256_V_LENGTH_VER1+eciesNistP256EncryptedKey.getPublicKeyAlgorithm().getRelatedSymmetricAlgorithm().getKeyLength(), EciesNistP256EncryptedKey.VER1_OUTPUT_TAG_LENGTH);
	
	
	
	byte[] decryptedData = eCIESCipher.engineDoFinal(encryptedData, 0, encryptedData.length);

	return new SecretKeySpec(decryptedData, "AES");
}
 
开发者ID:pvendil,项目名称:c2c-common,代码行数:40,代码来源:DefaultCryptoManager.java


示例8: itsEciesDecryptSymmetricKeyVer2

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
/**
 * Help method to perform a ECIES decryption of a symmetric key using the ITS protocol version 2 specification. 
 * 
 * @param eciesNistP256EncryptedKey the EciesNistP256EncryptedKey header value from the SecuredMessage
 * @param decryptionKey the receiptients private key
 * @return a decrypted symmetric key.
 * 
 * @throws InvalidKeyException if supplied key was corrupt.
 * @throws InvalidAlgorithmParameterException if algorithm was badly specified.
 * @throws IllegalBlockSizeException if encrypted data was corrupt.
 * @throws BadPaddingException if encrypted data was corrupt.
 * @throws IllegalArgumentException if arguments where invalid or algorithm not supported.
 * @throws InvalidKeySpecException if supplied key specification was faulty.
 * @throws IOException if communication problem occurred with underlying systems.
 */
protected Key itsEciesDecryptSymmetricKeyVer2(EciesNistP256EncryptedKey eciesNistP256EncryptedKey, PrivateKey decryptionKey) throws InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, IllegalArgumentException, InvalidKeySpecException, IOException{
	if(eciesNistP256EncryptedKey.getPublicKeyAlgorithm() != PublicKeyAlgorithm.ecies_nistp256){
		throw new IllegalArgumentException("Unsupported encryption public key algorithm: " + eciesNistP256EncryptedKey.getPublicKeyAlgorithm() );
	}
	
	IESCipher eCIESCipher = new IEEE1609Dot2ECIES();
	eCIESCipher.engineInit(Cipher.DECRYPT_MODE, decryptionKey, new IESParameterSpec(null, null, 128,-1, null, true),secureRandom);
			
	byte[] encryptedData = new byte[ECIES_NIST_P256_V_LENGTH_VER2 + eciesNistP256EncryptedKey.getPublicKeyAlgorithm().getRelatedSymmetricAlgorithm().getKeyLength() + EciesNistP256EncryptedKey.VER2_OUTPUT_TAG_LENGTH];
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	DataOutputStream dis = new DataOutputStream(baos);
	
	eciesNistP256EncryptedKey.getV().encode(dis);
	baos.close();
	System.arraycopy(baos.toByteArray(), 0, encryptedData, 0, ECIES_NIST_P256_V_LENGTH_VER2);
	System.arraycopy(eciesNistP256EncryptedKey.getC(), 0, encryptedData, ECIES_NIST_P256_V_LENGTH_VER2, eciesNistP256EncryptedKey.getPublicKeyAlgorithm().getRelatedSymmetricAlgorithm().getKeyLength());
	System.arraycopy(eciesNistP256EncryptedKey.getT(), 0, encryptedData, ECIES_NIST_P256_V_LENGTH_VER2+eciesNistP256EncryptedKey.getPublicKeyAlgorithm().getRelatedSymmetricAlgorithm().getKeyLength(), EciesNistP256EncryptedKey.VER2_OUTPUT_TAG_LENGTH);
	
	
	
	byte[] decryptedData = eCIESCipher.engineDoFinal(encryptedData, 0, encryptedData.length);

	return new SecretKeySpec(decryptedData, "AES");
}
 
开发者ID:pvendil,项目名称:c2c-common,代码行数:40,代码来源:DefaultCryptoManager.java


示例9: ieeeECEISDecryptSymmetricKey

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
/**
 * Help method to perform a ECIES decryption of a symmetric key. 
 * 
 * @param encryptedDataEncryptionKey the EncryptedDataEncryptionKey to decrypt
 * @param decryptionKey the receiptients private key
 * @param alg the related algorithm to use
 * @param eciesDeviation to use as P1 parameter.
 * @return a decrypted symmetric key.
 * 
 * @throws IllegalArgumentException if arguments where invalid or algorithm not supported.
 * @throws GeneralSecurityException if internal problems occurred decrypting key.
 * @throws IOException if communication problem occurred with underlying systems.
 */
@Override
public SecretKey ieeeECEISDecryptSymmetricKey(EncryptedDataEncryptionKey encryptedDataEncryptionKey, PrivateKey decryptionKey, AlgorithmIndicator alg, byte[] eciesDeviation) throws IllegalArgumentException, GeneralSecurityException, IOException{
	try{
		EncryptedDataEncryptionKeyChoices keyType = encryptedDataEncryptionKey.getType();
		IESCipher eCIESCipher = new IEEE1609Dot2ECIES();
		eCIESCipher.engineInit(Cipher.DECRYPT_MODE, decryptionKey, new IESParameterSpec(eciesDeviation, null, 128,-1, null, true),secureRandom);

		byte[] encryptedData = new byte[keyType.getVLength() + alg.getAlgorithm().getSymmetric().getKeyLength() + keyType.getOutputTagLength()];


		EciesP256EncryptedKey eciesP256EncryptedKey = (EciesP256EncryptedKey) encryptedDataEncryptionKey.getValue();
		ECPublicKey pubKey = (ECPublicKey) decodeEccPoint(alg, eciesP256EncryptedKey.getV());
		BCECPublicKey bcPubKey = convertECPublicKeyToBCECPublicKey(alg, pubKey);

		System.arraycopy(bcPubKey.getQ().getEncoded(true), 0, encryptedData, 0, keyType.getVLength());
		System.arraycopy(eciesP256EncryptedKey.getC(), 0, encryptedData, keyType.getVLength(), alg.getAlgorithm().getSymmetric().getKeyLength());
		System.arraycopy(eciesP256EncryptedKey.getT(), 0, encryptedData, keyType.getVLength()+alg.getAlgorithm().getSymmetric().getKeyLength(), keyType.getOutputTagLength());

		byte[] decryptedData = eCIESCipher.engineDoFinal(encryptedData, 0, encryptedData.length);
		return new SecretKeySpec(decryptedData, "AES");
	}catch(BadPaddingException e){
		throw new InvalidKeyException("Error decrypting symmetric key using supplied private key: " + e.getMessage(), e);
	}
}
 
开发者ID:pvendil,项目名称:c2c-common,代码行数:38,代码来源:DefaultCryptoManager.java


示例10: localEngineGetParameterSpec

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == IESParameterSpec.class)
    {
        return currentSpec;
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:AlgorithmParametersSpi.java


示例11: engineInit

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof IESParameterSpec))
    {
        throw new InvalidParameterSpecException("IESParameterSpec required to initialise a IES algorithm parameters object");
    }

    this.currentSpec = (IESParameterSpec)paramSpec;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:AlgorithmParametersSpi.java


示例12: guessParameterSpec

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
public static IESParameterSpec guessParameterSpec(BufferedBlockCipher iesBlockCipher)
{
    if (iesBlockCipher == null)
    {
        return new IESParameterSpec(null, null, 128);
    }
    else
    {
        BlockCipher underlyingCipher = iesBlockCipher.getUnderlyingCipher();

        if (underlyingCipher.getAlgorithmName().equals("DES") ||
            underlyingCipher.getAlgorithmName().equals("RC2") ||
            underlyingCipher.getAlgorithmName().equals("RC5-32") ||
            underlyingCipher.getAlgorithmName().equals("RC5-64"))
        {
            return new IESParameterSpec(null, null, 64, 64);
        }
        else if (underlyingCipher.getAlgorithmName().equals("SKIPJACK"))
        {
            return new IESParameterSpec(null, null, 80, 80);
        }
        else if (underlyingCipher.getAlgorithmName().equals("GOST28147"))
        {
            return new IESParameterSpec(null, null, 256, 256);
        }

        return new IESParameterSpec(null, null, 128, 128);
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:30,代码来源:IESUtil.java


示例13: localEngineGetParameterSpec

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == IESParameterSpec.class || paramSpec == AlgorithmParameterSpec.class)
    {
        return currentSpec;
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:12,代码来源:AlgorithmParametersSpi.java


示例14: localEngineGetParameterSpec

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec) 
    throws InvalidParameterSpecException
{
    if (paramSpec == IESParameterSpec.class)
    {
        return currentSpec;
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:12,代码来源:JDKAlgorithmParameters.java


示例15: engineInit

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
protected void engineInit(
    AlgorithmParameterSpec paramSpec) 
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof IESParameterSpec))
    {
        throw new InvalidParameterSpecException("IESParameterSpec required to initialise a IES algorithm parameters object");
    }

    this.currentSpec = (IESParameterSpec)paramSpec;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:12,代码来源:JDKAlgorithmParameters.java


示例16: doTest

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
public void doTest(
    String                testname,
    KeyPairGenerator     g,
    String              cipher,
    IESParameterSpec    p)
    throws Exception
{
    
    byte[] message = Hex.decode("0102030405060708090a0b0c0d0e0f10111213141516");
    byte[] out1, out2;
  
    Cipher        c1 = Cipher.getInstance(cipher, "BC");
    Cipher        c2 = Cipher.getInstance(cipher, "BC");
    // Generate static key pair
    KeyPair       keyPair = g.generateKeyPair();
    DHPublicKey   pub = (DHPublicKey)keyPair.getPublic();
    DHPrivateKey  priv = (DHPrivateKey)keyPair.getPrivate();
   

    // Testing with null parameters and DHAES mode off
    c1.init(Cipher.ENCRYPT_MODE, pub, new SecureRandom());
    c2.init(Cipher.DECRYPT_MODE, priv, new SecureRandom());
    out1 = c1.doFinal(message, 0, message.length);
    out2 = c2.doFinal(out1, 0, out1.length);
    if (!areEqual(out2, message))
    {
        fail(testname + " test failed with null parameters, DHAES mode false.");
    }

    
    // Testing with given parameters and DHAES mode off
    c1.init(Cipher.ENCRYPT_MODE, pub, p, new SecureRandom());
    c2.init(Cipher.DECRYPT_MODE, priv, p, new SecureRandom());
    out1 = c1.doFinal(message, 0, message.length);
    out2 = c2.doFinal(out1, 0, out1.length);
    if (!areEqual(out2, message))
        fail(testname + " test failed with non-null parameters, DHAES mode false.");
    
    // Testing with null parameters and DHAES mode on
    c1 = Cipher.getInstance(cipher + "/DHAES/PKCS7Padding","BC");
    c2 = Cipher.getInstance(cipher + "/DHAES/PKCS7Padding","BC");
    c1.init(Cipher.ENCRYPT_MODE, pub, new SecureRandom());
    c2.init(Cipher.DECRYPT_MODE, priv, new SecureRandom());
    out1 = c1.doFinal(message, 0, message.length);
    out2 = c2.doFinal(out1, 0, out1.length);
    if (!areEqual(out2, message))
        fail(testname + " test failed with null parameters, DHAES mode true.");
 
    
    // Testing with given parameters and DHAES mode on
    c1 = Cipher.getInstance(cipher + "/DHAES/PKCS7Padding","BC");
    c2 = Cipher.getInstance(cipher + "/DHAES/PKCS7Padding","BC");

    c1.init(Cipher.ENCRYPT_MODE, pub, p, new SecureRandom());
    c2.init(Cipher.DECRYPT_MODE, priv, p, new SecureRandom());

    out1 = c1.doFinal(message, 0, message.length);
    out2 = c2.doFinal(out1, 0, out1.length);
    if (!areEqual(out2, message))
        fail(testname + " test failed with non-null parameters, DHAES mode true.");
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:62,代码来源:DHIESTest.java


示例17: doTest

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
public void doTest(
    KeyPairGenerator g,
    Cipher           c1,
    Cipher           c2)
    throws Exception
{
    //
    // a side
    //
    KeyPair     aKeyPair = g.generateKeyPair();
    PublicKey   aPub = aKeyPair.getPublic();
    PrivateKey  aPriv = aKeyPair.getPrivate();

    //
    // b side
    //
    KeyPair     bKeyPair = g.generateKeyPair();
    PublicKey   bPub = bKeyPair.getPublic();
    PrivateKey  bPriv = bKeyPair.getPrivate();

    //
    // stream test
    //

    IEKeySpec   c1Key = new IEKeySpec(aPriv, bPub);
    IEKeySpec   c2Key = new IEKeySpec(bPriv, aPub);

    byte[]  d = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
    byte[]  e = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 };

    IESParameterSpec param = new IESParameterSpec(d, e, 128);

    c1.init(Cipher.ENCRYPT_MODE, c1Key, param);

    c2.init(Cipher.DECRYPT_MODE, c2Key, param);

    byte[] message = Hex.decode("1234567890abcdef");

    byte[]   out1 = c1.doFinal(message, 0, message.length);

    byte[]   out2 = c2.doFinal(out1, 0, out1.length);

    if (!areEqual(out2, message))
    {
        fail("stream cipher test failed");
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:48,代码来源:IESTest.java


示例18: doTest

import org.bouncycastle.jce.spec.IESParameterSpec; //导入依赖的package包/类
public void doTest(
    String                testname,
    KeyPairGenerator     g,
    String              cipher,
    IESParameterSpec    p)
    throws Exception
{
    
    byte[] message = Hex.decode("0102030405060708090a0b0c0d0e0f10111213141516");
    byte[] out1, out2;

    // Generate static key pair
    KeyPair     KeyPair = g.generateKeyPair();
    ECPublicKey   Pub = (ECPublicKey) KeyPair.getPublic();
    ECPrivateKey  Priv = (ECPrivateKey) KeyPair.getPrivate();

    Cipher c1 = Cipher.getInstance(cipher);
    Cipher c2 = Cipher.getInstance(cipher);

    // Testing with null parameters and DHAES mode off
    c1.init(Cipher.ENCRYPT_MODE, Pub, new SecureRandom());
    c2.init(Cipher.DECRYPT_MODE, Priv, new SecureRandom());
    out1 = c1.doFinal(message, 0, message.length);
    out2 = c2.doFinal(out1, 0, out1.length);
    if (!areEqual(out2, message))
        fail(testname + " test failed with null parameters, DHAES mode false.");

    
    // Testing with given parameters and DHAES mode off
    c1.init(Cipher.ENCRYPT_MODE, Pub, p, new SecureRandom());
    c2.init(Cipher.DECRYPT_MODE, Priv, p, new SecureRandom());
    out1 = c1.doFinal(message, 0, message.length);
    out2 = c2.doFinal(out1, 0, out1.length);
    if (!areEqual(out2, message))
        fail(testname + " test failed with non-null parameters, DHAES mode false.");
    

    c1 = Cipher.getInstance(cipher + "/DHAES/PKCS7Padding","BC");
    c2 = Cipher.getInstance(cipher + "/DHAES/PKCS7Padding","BC");

    // Testing with null parameters and DHAES mode on
    c1.init(Cipher.ENCRYPT_MODE, Pub, new SecureRandom());
    c2.init(Cipher.DECRYPT_MODE, Priv, new SecureRandom());

    out1 = c1.doFinal(message, 0, message.length);
    out2 = c2.doFinal(out1, 0, out1.length);
    if (!areEqual(out2, message))
        fail(testname + " test failed with null parameters, DHAES mode true.");
 
    c1 = Cipher.getInstance(cipher + "/DHAES/PKCS7Padding");
    c2 = Cipher.getInstance(cipher + "/DHAES/PKCS7Padding");

    // Testing with given parameters and DHAES mode on
    c1.init(Cipher.ENCRYPT_MODE, Pub, p, new SecureRandom());
    c2.init(Cipher.DECRYPT_MODE, Priv, p, new SecureRandom());

    out1 = c1.doFinal(message, 0, message.length);
    out2 = c2.doFinal(out1, 0, out1.length);
    if (!areEqual(out2, message))
        fail(testname + " test failed with non-null parameters, DHAES mode true.");
    
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:63,代码来源:ECIESTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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