当前位置: 首页>>代码示例>>Java>>正文


Java InvalidCipherTextException.getMessage方法代码示例

本文整理汇总了Java中org.bouncycastle.crypto.InvalidCipherTextException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java InvalidCipherTextException.getMessage方法的具体用法?Java InvalidCipherTextException.getMessage怎么用?Java InvalidCipherTextException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.crypto.InvalidCipherTextException的用法示例。


在下文中一共展示了InvalidCipherTextException.getMessage方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateUnwrappedKey

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
public GenericKey generateUnwrappedKey(AlgorithmIdentifier encryptedKeyAlgorithm, byte[] encryptedKey)
    throws OperatorException
{
    AsymmetricBlockCipher keyCipher = createAsymmetricUnwrapper(this.getAlgorithmIdentifier().getAlgorithm());

    keyCipher.init(false, privateKey);
    try
    {
        byte[] key = keyCipher.processBlock(encryptedKey, 0, encryptedKey.length);

        if (encryptedKeyAlgorithm.getAlgorithm().equals(PKCSObjectIdentifiers.des_EDE3_CBC))
        {
            return new GenericKey(encryptedKeyAlgorithm, key);
        }
        else
        {
            return new GenericKey(encryptedKeyAlgorithm, key);
        }
    }
    catch (InvalidCipherTextException e)
    {
        throw new OperatorException("unable to recover secret key: " + e.getMessage(), e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:BcAsymmetricKeyUnwrapper.java

示例2: engineDoFinal

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

    try
    {
        byte[]  buf = buffer.toByteArray();

        buffer.reset();

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

示例3: engineDoFinal

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
protected byte[] engineDoFinal(
    byte[]  input,
    int     inputOffset,
    int     inputLen) 
    throws IllegalBlockSizeException, BadPaddingException
{
    cipher.processBytes(input, inputOffset, inputLen);
    try
    {
        return cipher.doFinal();
    }
    catch (InvalidCipherTextException e)
    {
        throw new BadPaddingException(e.getMessage());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:CipherSpi.java

示例4: extractSecretKey

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
protected KeyParameter extractSecretKey(AlgorithmIdentifier keyEncryptionAlgorithm, AlgorithmIdentifier contentEncryptionAlgorithm, byte[] derivedKey, byte[] encryptedContentEncryptionKey)
    throws CMSException
{
    Wrapper keyEncryptionCipher = EnvelopedDataHelper.createRFC3211Wrapper(keyEncryptionAlgorithm.getAlgorithm());

    keyEncryptionCipher.init(false, new ParametersWithIV(new KeyParameter(derivedKey), ASN1OctetString.getInstance(keyEncryptionAlgorithm.getParameters()).getOctets()));

    try
    {
        return new KeyParameter(keyEncryptionCipher.unwrap(encryptedContentEncryptionKey, 0, encryptedContentEncryptionKey.length));
    }
    catch (InvalidCipherTextException e)
    {
        throw new CMSException("unable to unwrap key: " + e.getMessage(), e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:BcPasswordRecipient.java

示例5: aesEncrypt

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
public static byte[] aesEncrypt(byte[] plaintext, byte[] myPrivateKey, byte[] theirPublicKey, byte[] nonce) {
    try {
        byte[] dhSharedSecret = new byte[32];
        Curve25519.curve(dhSharedSecret, myPrivateKey, theirPublicKey);
        for (int i = 0; i < 32; i++) {
            dhSharedSecret[i] ^= nonce[i];
        }
        byte[] key = sha256().digest(dhSharedSecret);
        byte[] iv = new byte[16];
        secureRandom.get().nextBytes(iv);
        PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new CBCBlockCipher(
                new AESEngine()));
        CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv);
        aes.init(true, ivAndKey);
        byte[] output = new byte[aes.getOutputSize(plaintext.length)];
        int ciphertextLength = aes.processBytes(plaintext, 0, plaintext.length, output, 0);
        ciphertextLength += aes.doFinal(output, ciphertextLength);
        byte[] result = new byte[iv.length + ciphertextLength];
        System.arraycopy(iv, 0, result, 0, iv.length);
        System.arraycopy(output, 0, result, iv.length, ciphertextLength);
        return result;
    } catch (InvalidCipherTextException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:26,代码来源:Crypto.java

示例6: engineDoFinal

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
public byte[] engineDoFinal(
    byte[]  input,
    int     inputOffset,
    int     inputLen) 
    throws IllegalBlockSizeException, BadPaddingException
{
    if (inputLen != 0)
    {
        buffer.write(input, inputOffset, inputLen);
    }

    try
    {
        byte[]  buf = buffer.toByteArray();

        buffer.reset();

        return cipher.processBlock(buf, 0, buf.length);
    }
    catch (InvalidCipherTextException e)
    {
        throw new BadPaddingException(e.getMessage());
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:25,代码来源:JCEIESCipher.java

示例7: aesEncrypt

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
public static byte[] aesEncrypt(byte[] plaintext, byte[] myPrivateKey, byte[] theirPublicKey) {
    try {
        byte[] dhSharedSecret = new byte[32];
        Curve25519.curve(dhSharedSecret, myPrivateKey, theirPublicKey);
        byte[] key = sha256().digest(dhSharedSecret);
        byte[] iv = new byte[16];
        secureRandom.get().nextBytes(iv);
        PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new CBCBlockCipher(
                new AESEngine()));
        CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv);
        aes.init(true, ivAndKey);
        byte[] output = new byte[aes.getOutputSize(plaintext.length)];
        int ciphertextLength = aes.processBytes(plaintext, 0, plaintext.length, output, 0);
        ciphertextLength += aes.doFinal(output, ciphertextLength);
        byte[] result = new byte[iv.length + ciphertextLength];
        System.arraycopy(iv, 0, result, 0, iv.length);
        System.arraycopy(output, 0, result, iv.length, ciphertextLength);
        return result;
    } catch (InvalidCipherTextException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
开发者ID:de-luxe,项目名称:burstcoin-faucet,代码行数:23,代码来源:Crypto.java

示例8: aesDecrypt

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
public static byte[] aesDecrypt(byte[] ivCiphertext, byte[] myPrivateKey, byte theirPublicKey[]) {
    try {
        if (ivCiphertext.length < 16 || ivCiphertext.length % 16 != 0) {
            throw new InvalidCipherTextException("invalid ciphertext");
        }
        byte[] iv = Arrays.copyOfRange(ivCiphertext, 0, 16);
        byte[] ciphertext = Arrays.copyOfRange(ivCiphertext, 16, ivCiphertext.length);
        byte[] dhSharedSecret = new byte[32];
        Curve25519.curve(dhSharedSecret, myPrivateKey, theirPublicKey);
        byte[] key = sha256().digest(dhSharedSecret);
        PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new CBCBlockCipher(
                new AESEngine()));
        CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv);
        aes.init(false, ivAndKey);
        byte[] output = new byte[aes.getOutputSize(ciphertext.length)];
        int plaintextLength = aes.processBytes(ciphertext, 0, ciphertext.length, output, 0);
        plaintextLength += aes.doFinal(output, plaintextLength);
        byte[] result = new byte[plaintextLength];
        System.arraycopy(output, 0, result, 0, result.length);
        return result;
    } catch (InvalidCipherTextException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
开发者ID:de-luxe,项目名称:burstcoin-faucet,代码行数:25,代码来源:Crypto.java

示例9: build

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
public PBESecretKeyDecryptor build(char[] passPhrase)
{
    return new PBESecretKeyDecryptor(passPhrase, calculatorProvider)
    {
        public byte[] recoverKeyData(int encAlgorithm, byte[] key, byte[] iv, byte[] keyData, int keyOff, int keyLen)
            throws PGPException
        {
            try
            {
                BufferedBlockCipher c = BcUtil.createSymmetricKeyWrapper(false, BcImplProvider.createBlockCipher(encAlgorithm), key, iv);

                byte[] out = new byte[keyLen];
                int    outLen = c.processBytes(keyData, keyOff, keyLen, out, 0);

                outLen += c.doFinal(out, outLen);

                return out;
            }
            catch (InvalidCipherTextException e)
            {
                throw new PGPException("decryption failed: " + e.getMessage(), e);
            }
        }
    };
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:26,代码来源:BcPBESecretKeyDecryptorBuilder.java

示例10: encryptSessionInfo

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
protected byte[] encryptSessionInfo(int encAlgorithm, byte[] key, byte[] sessionInfo)
    throws PGPException
{
    try
    {
        BlockCipher engine = BcImplProvider.createBlockCipher(encAlgorithm);
        BufferedBlockCipher cipher = BcUtil.createSymmetricKeyWrapper(true, engine, key, new byte[engine.getBlockSize()]);

        byte[] out = new byte[sessionInfo.length];

        int len = cipher.processBytes(sessionInfo, 0, sessionInfo.length, out, 0);

        len += cipher.doFinal(out, len);

        return out;
    }
    catch (InvalidCipherTextException e)
    {
        throw new PGPException("encryption failed: " + e.getMessage(), e);
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:22,代码来源:BcPBEKeyEncryptionMethodGenerator.java

示例11: generateUnwrappedKey

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
public GenericKey generateUnwrappedKey(AlgorithmIdentifier encryptedKeyAlgorithm, byte[] encryptedKey)
    throws OperatorException
{
    wrapper.init(false, wrappingKey);

    try
    {
        return new GenericKey(encryptedKeyAlgorithm, wrapper.unwrap(encryptedKey, 0, encryptedKey.length));
    }
    catch (InvalidCipherTextException e)
    {
        throw new OperatorException("unable to unwrap key: " + e.getMessage(), e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:BcSymmetricKeyUnwrapper.java

示例12: engineDoFinal

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的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

示例13: aesDecrypt

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
public static byte[] aesDecrypt(byte[] ivCiphertext, byte[] myPrivateKey, byte[] theirPublicKey, byte[] nonce) {
    try {
        if (ivCiphertext.length < 16 || ivCiphertext.length % 16 != 0) {
            throw new InvalidCipherTextException("invalid ciphertext");
        }
        byte[] iv = Arrays.copyOfRange(ivCiphertext, 0, 16);
        byte[] ciphertext = Arrays.copyOfRange(ivCiphertext, 16, ivCiphertext.length);
        byte[] dhSharedSecret = new byte[32];
        Curve25519.curve(dhSharedSecret, myPrivateKey, theirPublicKey);
        for (int i = 0; i < 32; i++) {
            dhSharedSecret[i] ^= nonce[i];
        }
        byte[] key = sha256().digest(dhSharedSecret);
        PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new CBCBlockCipher(
                new AESEngine()));
        CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv);
        aes.init(false, ivAndKey);
        byte[] output = new byte[aes.getOutputSize(ciphertext.length)];
        int plaintextLength = aes.processBytes(ciphertext, 0, ciphertext.length, output, 0);
        plaintextLength += aes.doFinal(output, plaintextLength);
        byte[] result = new byte[plaintextLength];
        System.arraycopy(output, 0, result, 0, result.length);
        return result;
    } catch (InvalidCipherTextException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:28,代码来源:Crypto.java

示例14: doFinal

import org.bouncycastle.crypto.InvalidCipherTextException; //导入方法依赖的package包/类
public int doFinal(byte[] out, int outOff) throws IllegalStateException, BadPaddingException
{
    try
    {
        return cipher.doFinal(out, outOff);
    }
    catch (InvalidCipherTextException e)
    {
        throw new BadPaddingException(e.getMessage());
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:12,代码来源:BaseBlockCipher.java


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