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


Java InvalidCipherTextException类代码示例

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


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

示例1: decrypt

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
public static byte[] decrypt(BigInteger privKey, byte[] cipher, byte[] macData) throws IOException, InvalidCipherTextException {

        byte[] plaintext;

        ByteArrayInputStream is = new ByteArrayInputStream(cipher);
        byte[] ephemBytes = new byte[2*((CURVE.getCurve().getFieldSize()+7)/8) + 1];

        is.read(ephemBytes);
        ECPoint ephem = CURVE.getCurve().decodePoint(ephemBytes);
        byte[] IV = new byte[KEY_SIZE /8];
        is.read(IV);
        byte[] cipherBody = new byte[is.available()];
        is.read(cipherBody);

        plaintext = decrypt(ephem, privKey, IV, cipherBody, macData);

        return plaintext;
    }
 
开发者ID:talentchain,项目名称:talchain,代码行数:19,代码来源:ECIESCoder.java

示例2: decryptSimple

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
/**
 *  Encryption equivalent to the Crypto++ default ECIES<ECP> settings:
 *
 *  DL_KeyAgreementAlgorithm:        DL_KeyAgreementAlgorithm_DH<struct ECPPoint,struct EnumToType<enum CofactorMultiplicationOption,0> >
 *  DL_KeyDerivationAlgorithm:       DL_KeyDerivationAlgorithm_P1363<struct ECPPoint,0,class P1363_KDF2<class SHA1> >
 *  DL_SymmetricEncryptionAlgorithm: DL_EncryptionAlgorithm_Xor<class HMAC<class SHA1>,0>
 *  DL_PrivateKey:                   DL_Key<ECPPoint>
 *  DL_PrivateKey_EC<class ECP>
 *
 *  Used for Whisper V3
 */
public static byte[] decryptSimple(BigInteger privKey, byte[] cipher) throws IOException, InvalidCipherTextException {
    EthereumIESEngine iesEngine = new EthereumIESEngine(
            new ECDHBasicAgreement(),
            new MGF1BytesGeneratorExt(new SHA1Digest(), 1),
            new HMac(new SHA1Digest()),
            new SHA1Digest(),
            null);

    IESParameters p = new IESParameters(null, null, KEY_SIZE);
    ParametersWithIV parametersWithIV = new ParametersWithIV(p, new byte[0]);

    iesEngine.setHashMacKey(false);

    iesEngine.init(new ECPrivateKeyParameters(privKey, CURVE), parametersWithIV,
            new ECIESPublicKeyParser(ECKey.CURVE));

    return iesEngine.processBlock(cipher, 0, cipher.length);
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:30,代码来源:ECIESCoder.java

示例3: decryptAuthResponseV4

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
public AuthResponseMessageV4 decryptAuthResponseV4(byte[] in, ECKey myKey) {
    try {

        byte[] prefix = new byte[2];
        System.arraycopy(in, 0, prefix, 0, 2);
        short size = ByteUtil.bigEndianToShort(prefix, 0);
        byte[] ciphertext = new byte[size];
        System.arraycopy(in, 2, ciphertext, 0, size);

        byte[] plaintext = ECIESCoder.decrypt(myKey.getPrivKey(), ciphertext, prefix);

        return AuthResponseMessageV4.decode(plaintext);
    } catch (IOException | InvalidCipherTextException e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:17,代码来源:EncryptionHandshake.java

示例4: test2

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
@Test
public void test2() throws InvalidCipherTextException {

    byte[] authMessageData = decode(
            "01b8044c6c312173685d1edd268aa95e1d495474c6959bcdd10067ba4c9013df9e40ff45f5bfd6f7" +
            "2471f93a91b493f8e00abc4b80f682973de715d77ba3a005a242eb859f9a211d93a347fa64b597bf" +
            "280a6b88e26299cf263b01b8dfdb712278464fd1c25840b995e84d367d743f66c0e54a586725b7bb" +
            "f12acca27170ae3283c1073adda4b6d79f27656993aefccf16e0d0409fe07db2dc398a1b7e8ee93b" +
            "cd181485fd332f381d6a050fba4c7641a5112ac1b0b61168d20f01b479e19adf7fdbfa0905f63352" +
            "bfc7e23cf3357657455119d879c78d3cf8c8c06375f3f7d4861aa02a122467e069acaf513025ff19" +
            "6641f6d2810ce493f51bee9c966b15c5043505350392b57645385a18c78f14669cc4d960446c1757" +
            "1b7c5d725021babbcd786957f3d17089c084907bda22c2b2675b4378b114c601d858802a55345a15" +
            "116bc61da4193996187ed70d16730e9ae6b3bb8787ebcaea1871d850997ddc08b4f4ea668fbf3740" +
            "7ac044b55be0908ecb94d4ed172ece66fd31bfdadf2b97a8bc690163ee11f5b575a4b44e36e2bfb2" +
            "f0fce91676fd64c7773bac6a003f481fddd0bae0a1f31aa27504e2a533af4cef3b623f4791b2cca6" +
            "d490");

    AuthInitiateMessageV4 msg2 = handshakerB.decryptAuthInitiateV4(authMessageData, keyB);

    assertEquals(56, msg2.version);
    assertArrayEquals(nonceA, msg2.nonce);
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:23,代码来源:EIP8HandshakeTest.java

示例5: test4

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
@Test
public void test4() throws InvalidCipherTextException {

    byte[] authMessageData = decode(
            "01f004076e58aae772bb101ab1a8e64e01ee96e64857ce82b1113817c6cdd52c09d26f7b90981cd7" +
            "ae835aeac72e1573b8a0225dd56d157a010846d888dac7464baf53f2ad4e3d584531fa203658fab0" +
            "3a06c9fd5e35737e417bc28c1cbf5e5dfc666de7090f69c3b29754725f84f75382891c561040ea1d" +
            "dc0d8f381ed1b9d0d4ad2a0ec021421d847820d6fa0ba66eaf58175f1b235e851c7e2124069fbc20" +
            "2888ddb3ac4d56bcbd1b9b7eab59e78f2e2d400905050f4a92dec1c4bdf797b3fc9b2f8e84a482f3" +
            "d800386186712dae00d5c386ec9387a5e9c9a1aca5a573ca91082c7d68421f388e79127a5177d4f8" +
            "590237364fd348c9611fa39f78dcdceee3f390f07991b7b47e1daa3ebcb6ccc9607811cb17ce51f1" +
            "c8c2c5098dbdd28fca547b3f58c01a424ac05f869f49c6a34672ea2cbbc558428aa1fe48bbfd6115" +
            "8b1b735a65d99f21e70dbc020bfdface9f724a0d1fb5895db971cc81aa7608baa0920abb0a565c9c" +
            "436e2fd13323428296c86385f2384e408a31e104670df0791d93e743a3a5194ee6b076fb6323ca59" +
            "3011b7348c16cf58f66b9633906ba54a2ee803187344b394f75dd2e663a57b956cb830dd7a908d4f" +
            "39a2336a61ef9fda549180d4ccde21514d117b6c6fd07a9102b5efe710a32af4eeacae2cb3b1dec0" +
            "35b9593b48b9d3ca4c13d245d5f04169b0b1");

    // decode (on A side)

    AuthResponseMessageV4 msg2 = handshakerA.decryptAuthResponseV4(authMessageData, keyA);

    assertEquals(57, msg2.version);
    assertArrayEquals(nonceB, msg2.nonce);
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:26,代码来源:EIP8HandshakeTest.java

示例6: decrypt

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
public static byte[] decrypt(BigInteger privKey, byte[] cipher, byte[] macData) throws IOException, InvalidCipherTextException {

        byte[] plaintext;

        ByteArrayInputStream is = new ByteArrayInputStream(cipher);
        byte[] ephemBytes = new byte[2*((CURVE.getCurve().getFieldSize()+7)/8) + 1];

        is.read(ephemBytes);
        ECPoint ephem = CURVE.getCurve().decodePoint(ephemBytes);
        byte[] iv = new byte[KEY_SIZE /8];
        is.read(iv);
        byte[] cipherBody = new byte[is.available()];
        is.read(cipherBody);

        plaintext = decrypt(ephem, privKey, iv, cipherBody, macData);

        return plaintext;
    }
 
开发者ID:rsksmart,项目名称:rskj,代码行数:19,代码来源:ECIESCoder.java

示例7: encryptSimple

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
/**
 *  Encryption equivalent to the Crypto++ default ECIES<ECP> settings:
 *
 *  DL_KeyAgreementAlgorithm:        DL_KeyAgreementAlgorithm_DH<struct ECPPoint,struct EnumToType<enum CofactorMultiplicationOption,0> >
 *  DL_KeyDerivationAlgorithm:       DL_KeyDerivationAlgorithm_P1363<struct ECPPoint,0,class P1363_KDF2<class SHA1> >
 *  DL_SymmetricEncryptionAlgorithm: DL_EncryptionAlgorithm_Xor<class HMAC<class SHA1>,0>
 *  DL_PrivateKey:                   DL_Key<ECPPoint>
 *  DL_PrivateKey_EC<class ECP>
 *
 *  Used for Whisper V3
 */
public static byte[] encryptSimple(ECPoint pub, byte[] plaintext) throws IOException, InvalidCipherTextException {
    EthereumIESEngine iesEngine = new EthereumIESEngine(
            new ECDHBasicAgreement(),
            new MGF1BytesGeneratorExt(new SHA1Digest(), 1),
            new HMac(new SHA1Digest()),
            new SHA1Digest(),
            null);

    IESParameters p = new IESParameters(null, null, KEY_SIZE);
    ParametersWithIV parametersWithIV = new ParametersWithIV(p, new byte[0]);

    iesEngine.setHashMacKey(false);

    ECKeyPairGenerator eGen = new ECKeyPairGenerator();
    SecureRandom random = new SecureRandom();
    KeyGenerationParameters gParam = new ECKeyGenerationParameters(CURVE, random);
    eGen.init(gParam);

    EphemeralKeyPairGenerator ephemeralKeyPairGenerator =
            new EphemeralKeyPairGenerator(/*testGen*/eGen, new ECIESPublicKeyEncoder());

    iesEngine.init(new ECPublicKeyParameters(pub, CURVE), parametersWithIV, ephemeralKeyPairGenerator);

    return iesEngine.processBlock(plaintext, 0, plaintext.length);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:37,代码来源:ECIESCoder.java

示例8: aesEncrypt

import org.spongycastle.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:filipnyquist,项目名称:lbry-android,代码行数:26,代码来源:Crypto.java

示例9: encrypt

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
protected byte[] encrypt(byte[] data) {
    // 16 bytes is the IV size for AES256
    try {
        SecretKey key = loadKey();

        // Random IV
        SecureRandom rng = new SecureRandom();
        byte[] ivBytes = new byte[16];                                                                  // 16 bytes is the IV size for AES256
        rng.nextBytes(ivBytes);

        PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
        cipher.init(true, new ParametersWithIV(new KeyParameter(key.getEncoded()), ivBytes));

        byte[] encryptedData = cipherData(cipher, data);
        byte[] encryptedDataWithIV = new byte[encryptedData.length + ivBytes.length];                   // Make room for IV
        System.arraycopy(ivBytes, 0, encryptedDataWithIV, 0, ivBytes.length);                           // Add IV
        System.arraycopy(encryptedData, 0, encryptedDataWithIV, ivBytes.length, encryptedData.length);  // Then the encrypted data
        return encryptedDataWithIV;
    }
    catch(InvalidCipherTextException e) {
        Log.e(TAG, "Can't encrypt data", e);
    }
    return null;
}
 
开发者ID:kalemontes,项目名称:OIDCAndroidLib,代码行数:25,代码来源:SensitiveDataPreApi23.java

示例10: decrypt

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
protected byte[] decrypt(byte[] data) {

        try {
            SecretKey key = loadKey();

            byte[] ivBytes = new byte[16];                                                                  // 16 bytes is the IV size for AES256
            System.arraycopy(data, 0, ivBytes, 0, ivBytes.length);                                          // Get IV from data
            byte[] dataWithoutIV = new byte[data.length - ivBytes.length];                                  // Remove the room made for the IV
            System.arraycopy(data, ivBytes.length, dataWithoutIV, 0, dataWithoutIV.length);                 // Then the encrypted data

            PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
            cipher.init(false, new ParametersWithIV(new KeyParameter(key.getEncoded()), ivBytes));

            return cipherData(cipher, dataWithoutIV);
        }
        catch(InvalidCipherTextException e) {
            Log.e(TAG, "Can't decrypt data", e);
        }
        return null;
    }
 
开发者ID:kalemontes,项目名称:OIDCAndroidLib,代码行数:21,代码来源:SensitiveDataPreApi23.java

示例11: create

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
/**
     * Create a User on the Gem platform.  At the time of user creation a default HD multi-sig wallet is created
     * labeled "default".  The wallet requires a passphrase to encrypt the primary key and the network for address
     * creation.
     * @param email of the user
     * @param firstName of the user
     * @param lastName of the user
     * @param passphrase to encrypt the primary seed
     * @param redirectUri the user is sent to after confirming his/her email
     * @return String deviceToken, used to authenticate device
     * @throws Client.UnexpectedStatusCodeException
     * @throws IOException
     * @throws InvalidKeySpecException
     * @throws NoSuchAlgorithmException
     */
    public String create(String email, String firstName, String lastName, String passphrase,
                         String deviceName, String redirectUri)
            throws Client.UnexpectedStatusCodeException, IOException, InvalidKeySpecException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidAlgorithmParameterException, BadPaddingException, NoSuchPaddingException, InvalidKeyException, NoSuchProviderException, InvalidCipherTextException {
        MultiWallet multiWallet = MultiWallet.generate(Network.blockchainNetwork("bitcoin"));
        String primaryPrivateSeed = multiWallet.serializedPrimaryPrivateSeed();
        EncryptedMessage encryptedPrivateSeed = PassphraseBox.encrypt(passphrase, primaryPrivateSeed);
        JsonObject wallet = new JsonObject();
        wallet.addProperty("name", "default");
        wallet.addProperty("primary_public_seed", multiWallet.serializedPrimaryPublicKey());
        wallet.add("primary_private_seed", encryptedPrivateSeed.asJsonObject());

        JsonObject payload = new JsonObject();
        if (redirectUri != null) {
//      payload.addProperty("redirect_uri", redirectUri);
        }
        payload.addProperty("email", email);
        payload.addProperty("device_name", deviceName);
        payload.add("default_wallet", wallet);
        payload.addProperty("first_name", firstName);
        payload.addProperty("last_name", lastName);

        Resource resource = this.resource.action("create", payload);
        return resource.attributes().get("metadata").getAsJsonObject().get("device_token").getAsString();
    }
 
开发者ID:GemHQ,项目名称:round-java,代码行数:40,代码来源:UserCollection.java

示例12: create

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
/**
 * Creates an additional wallet on the authenticated user.
 * @param name of the wallet
 * @param passphrase to encrypt the primary seed
 * @return Wallet.Wrapper were you can get the user object to initiate begin/complete device authentication.  This is
 * depricated and will be replaced with returning only a Wallet object.
 * @throws Client.UnexpectedStatusCodeException
 * @throws IOException
 * @throws InvalidKeySpecException
 * @throws NoSuchAlgorithmException
 */
public Wallet.Wrapper create(String name, String passphrase)
        throws IOException, Client.UnexpectedStatusCodeException,
        InvalidKeySpecException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidAlgorithmParameterException, BadPaddingException, NoSuchPaddingException, InvalidKeyException, NoSuchProviderException, InvalidCipherTextException {

    MultiWallet multiWallet = MultiWallet.generate(Network.blockchainNetwork("bitcoin"));
    String primaryPrivateSeed = multiWallet.serializedPrimaryPrivateSeed();
    EncryptedMessage encryptedPrivateSeed = PassphraseBox.encrypt(passphrase, primaryPrivateSeed);

    JsonObject wallet = new JsonObject();
    wallet.addProperty("name", name);
    wallet.addProperty("backup_public_seed", multiWallet.serializedBackupPublicKey());
    wallet.addProperty("primary_public_seed", multiWallet.serializedPrimaryPublicKey());
    wallet.add("primary_private_seed", encryptedPrivateSeed.asJsonObject());

    Resource resource = this.resource.action("create", wallet);
    Wallet gemWallet = new Wallet(resource, round, app);

    Wallet.Wrapper wrapper = new Wallet.Wrapper(gemWallet, multiWallet.serializedBackupPrivateSeed());
    multiWallet.purgeSeeds();
    return wrapper;
}
 
开发者ID:GemHQ,项目名称:round-java,代码行数:33,代码来源:WalletCollection.java

示例13: encryptSimple

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
/**
     *  Encryption equivalent to the Crypto++ default ECIES<ECP> settings:
     *
     *  DL_KeyAgreementAlgorithm:        DL_KeyAgreementAlgorithm_DH<struct ECPPoint,struct EnumToType<enum CofactorMultiplicationOption,0> >
     *  DL_KeyDerivationAlgorithm:       DL_KeyDerivationAlgorithm_P1363<struct ECPPoint,0,class P1363_KDF2<class SHA1> >
     *  DL_SymmetricEncryptionAlgorithm: DL_EncryptionAlgorithm_Xor<class HMAC<class SHA1>,0>
     *  DL_PrivateKey:                   DL_Key<ECPPoint>
     *  DL_PrivateKey_EC<class ECP>
     *
     *  Used for Whisper V3
     */
    public static byte[] encryptSimple(ECPoint pub, byte[] plaintext) throws IOException, InvalidCipherTextException {
        EthereumIESEngine iesEngine = new EthereumIESEngine(
                new ECDHBasicAgreement(),
                new MGF1BytesGeneratorExt(new SHA1Digest(), 1),
                new HMac(new SHA1Digest()),
                new SHA1Digest(),
                null);

        IESParameters p = new IESParameters(null, null, KEY_SIZE);
        ParametersWithIV parametersWithIV = new ParametersWithIV(p, new byte[0]);

        iesEngine.setHashMacKey(false);

        ECKeyPairGenerator eGen = new ECKeyPairGenerator();
        SecureRandom random = new SecureRandom();
        KeyGenerationParameters gParam = new ECKeyGenerationParameters(CURVE, random);
        eGen.init(gParam);

//        AsymmetricCipherKeyPairGenerator testGen = new AsymmetricCipherKeyPairGenerator() {
//            ECKey priv = ECKey.fromPrivate(Hex.decode("d0b043b4c5d657670778242d82d68a29d25d7d711127d17b8e299f156dad361a"));
//
//            @Override
//            public void init(KeyGenerationParameters keyGenerationParameters) {
//            }
//
//            @Override
//            public AsymmetricCipherKeyPair generateKeyPair() {
//                return new AsymmetricCipherKeyPair(new ECPublicKeyParameters(priv.getPubKeyPoint(), CURVE),
//                        new ECPrivateKeyParameters(priv.getPrivKey(), CURVE));
//            }
//        };

        EphemeralKeyPairGenerator ephemeralKeyPairGenerator =
                new EphemeralKeyPairGenerator(/*testGen*/eGen, new ECIESPublicKeyEncoder());

        iesEngine.init(new ECPublicKeyParameters(pub, CURVE), parametersWithIV, ephemeralKeyPairGenerator);

        return iesEngine.processBlock(plaintext, 0, plaintext.length);
    }
 
开发者ID:talentchain,项目名称:talchain,代码行数:51,代码来源:ECIESCoder.java

示例14: decryptAuthResponse

import org.spongycastle.crypto.InvalidCipherTextException; //导入依赖的package包/类
public AuthResponseMessage decryptAuthResponse(byte[] ciphertext, ECKey myKey) {
    try {
        byte[] plaintext = ECIESCoder.decrypt(myKey.getPrivKey(), ciphertext);
        return AuthResponseMessage.decode(plaintext);
    } catch (IOException | InvalidCipherTextException e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:9,代码来源:EncryptionHandshake.java

示例15: aesDecrypt

import org.spongycastle.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:filipnyquist,项目名称:lbry-android,代码行数:28,代码来源:Crypto.java


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