Decrypt encrypted assertions and add them to the assertions list of the response.

@param response  the response
@param decrypter the decrypter
972509
protected final void decryptEncryptedAssertions(final Response response, final Decrypter decrypter) {

        for (final EncryptedAssertion encryptedAssertion : response.getEncryptedAssertions()) {
            try {
                final Assertion decryptedAssertion = decrypter.decrypt(encryptedAssertion);
                response.getAssertions().add(decryptedAssertion);
            } catch (final DecryptionException e) {
                logger.error("Decryption of assertion failed, continue with the next one", e);
            }
        }

    }
363459
public byte[] decrypt(String iv, String cipherText, Encoder encoder) {
        return decrypt(encoder.decode(iv), encoder.decode(cipherText));
    }
297307
@Restricted(NoExternalUse.class) // TODO pending ApI
    public Cipher decrypt(byte[] iv) {
        try {
            Cipher cipher = Secret.getCipher(ALGORITHM);
            cipher.init(Cipher.DECRYPT_MODE, getKey(), new IvParameterSpec(iv));
            return cipher;
        } catch (GeneralSecurityException e) {
            throw new AssertionError(e);
        }
    }
23027
private Object decrypt(JsonObject object, String providerName) throws Exception {
        Object decrypted;

        String key = object.getString("kid");
        String alg = object.getString("alg");

        CryptoProvider provider = this.cryptoManager.getProvider(providerName);

        if (!provider.checkAlgorithmNameMatch(alg)) {
            cryptoManager.throwMissingPublicKeyEx(providerName);
        }

        if (!key.contentEquals(provider.getKeyStoreProvider().publicKeyName())) {
            cryptoManager.throwMissingPublicKeyEx(providerName);
        }

        byte[] encryptedBytes;
        String encryptedValueWithConfig;

        if (object.containsKey("iv")) {
            encryptedValueWithConfig = object.getString("kid") + object.getString("alg")
                    + object.getString("iv") + object.getString("ciphertext");

            byte[] encrypted = Base64.decode(object.getString("ciphertext"));
            byte[] iv = Base64.decode(object.getString("iv"));
            encryptedBytes = new byte[iv.length + encrypted.length];
            System.arraycopy(iv, 0, encryptedBytes, 0, iv.length);
            System.arraycopy(encrypted, 0, encryptedBytes, iv.length, encrypted.length);
        } else {
            encryptedValueWithConfig = object.getString("kid") + object.getString("alg")
                    + object.getString("ciphertext");
            encryptedBytes = Base64.decode(object.getString("ciphertext"));
        }

        if (object.containsKey("sig")) {
            byte[] signature = Base64.decode(object.getString("sig"));

            if (!provider.verifySignature(encryptedValueWithConfig.getBytes(), signature)) {
                cryptoManager.throwSigningFailedEx(providerName);
            }
        }

        byte[] decryptedBytes = provider.decrypt(encryptedBytes);
        String decryptedString = new String(decryptedBytes, Charset.forName("UTF-8"));
        decrypted = JacksonTransformers.MAPPER.readValue(decryptedString, Object.class);
        if (decrypted instanceof Map) {
            decrypted = JsonObject.from((Map<String, ?>) decrypted);
        } else if (decrypted instanceof List) {
            decrypted = JsonArray.from((List<?>) decrypted);
        }
        return decrypted;
    }
116373
public static String decrypt(String encrypted) {
        try {
            return decrypt(encrypted, null);
        } catch (GeneralSecurityException e) {
            e.printStackTrace();
            return null;
        }
    }
680671
protected final void validateAssertion(final Assertion assertion, final SAML2MessageContext context,
                                           final SignatureTrustEngine engine, final Decrypter decrypter) {

        validateIssueInstant(assertion.getIssueInstant());

        validateIssuer(assertion.getIssuer(), context);

        if (assertion.getSubject() != null) {
            validateSubject(assertion.getSubject(), context, decrypter);
        } else {
            throw new SAMAssertionSubjectException("Assertion subject cannot be null");
        }

        validateAssertionConditions(assertion.getConditions(), context);

        validateAuthenticationStatements(assertion.getAuthnStatements(), context);

        validateAssertionSignature(assertion.getSignature(), context, engine);

    }
791759
@Override
    public Cipher decrypt() {
        try {
            Cipher cipher = Cipher.getInstance(ALGORITHM);
            cipher.init(Cipher.DECRYPT_MODE, getKey());
            return cipher;
        } catch (GeneralSecurityException e) {
            throw new AssertionError(e);
        }
    }
608825
def decrypt_result(self, *args, **kwargs):
        
        if self.response is None:
            raise ValueError('Empty response')
        if self.response.response is None \
                or 'result' not in self.response.response \
                or self.response.response['result'] is None:
            raise ValueError('No result data')

        res_hex = self.response.response['result']

        # Strip out the plaintext part
        plain_length = bytes_to_long(from_hex(res_hex[0:4]))
        if plain_length > 0:
            res_hex = res_hex[4 + plain_length:]
        else:
            res_hex = res_hex[4:]

        # Optionally strip trailing _... string
        idx_trail = res_hex.find('_')
        if idx_trail != -1:
            res_hex = res_hex[0:idx_trail]

        # Decode hex coding
        res_bytes = from_hex(res_hex)

        # Crypto stuff - check the length & padding
        if len(res_bytes) < 16:
            raise InvalidResponse('Result too short')

        mac_given = res_bytes[-16:]
        res_bytes = res_bytes[:-16]

        # Check the MAC
        mac_computed = cbc_mac(self.uo.mac_key, res_bytes)
        if not str_equals(mac_given, mac_computed):
            raise CryptoError('MAC invalid')

        # Decrypt
        decrypted = aes_dec(self.uo.enc_key, res_bytes)
        if len(decrypted) < 1 + 4 + 8 or decrypted[0:1] != bchr(0xf1):
            raise InvalidResponse('Invalid format')

        self.resp_object_id = bytes_to_long(decrypted[1:5])
        self.resp_nonce = EBUtils.demangle_nonce(decrypted[5:5 + EBConsts.FRESHNESS_NONCE_LEN])
        self.decrypted = decrypted[5 + EBConsts.FRESHNESS_NONCE_LEN:]
        self.decrypted = PKCS7.unpad(self.decrypted)
        return self.response
989972
public static void decryptAsync(String encrypted, String password, RNCryptorNativeCallback RNCryptorNativeCallback) {
        String decrypted;
        try {
            decrypted = new RNCryptorNative().decrypt(encrypted, password);
            RNCryptorNativeCallback.done(decrypted, null);
        } catch (Exception e) {
            RNCryptorNativeCallback.done(null, e);
        }
    }
892379
private byte[] decrypt(final byte[] bytes) throws IOException {
        if (bytes.length < CcAes.BLOCK << 1) {
            throw new DecodingException("Invalid encrypted message format");
        }
        try {
            final byte[] vector = new byte[CcAes.BLOCK];
            final byte[] message = new byte[bytes.length - vector.length];
            System.arraycopy(bytes, 0, vector, 0, vector.length);
            System.arraycopy(
                bytes,
                vector.length,
                message,
                0,
                message.length
            );
            return this.cipher(
                Cipher.DECRYPT_MODE,
                new IvParameterSpec(vector)
            ).doFinal(message);
        } catch (final BadPaddingException | IllegalBlockSizeException ex) {
            throw new DecodingException(ex);
        }
    }
581760
private void saveCertificateFromResponse(Response response) {
        try {
            String responseBody = response.getResponseText();
            JSONObject jsonResponse = new JSONObject(responseBody);

            //handle certificate
            String certificateString = jsonResponse.getString("certificate");
            X509Certificate certificate = CertificatesUtility.base64StringToCertificate(certificateString);

            CertificatesUtility.checkValidityWithPublicKey(certificate, registrationKeyPair.getPublic());

            certificateStore.saveCertificate(registrationKeyPair, certificate);

            //save the clientId separately
            preferences.clientId.set(jsonResponse.getString("clientId"));

        } catch (Exception e) {
            throw new RuntimeException("Failed to save certificate from response", e);
        }

        logger.debug("certificate successfully saved");
    }
1268513
@Override
    public void decryptBlock(byte[] data, int offset, byte[] dest, int destOffset) {
        // w128_t x;
        // x.q[0] = ((uint64_t *) blk)[0] ^ key->k[9].q[0];
        // x.q[1] = ((uint64_t *) blk)[1] ^ key->k[9].q[1];
        Kuz128 x = new Kuz128();
        x.setQ(0, ByteStrings.bytesToLong(data, offset) ^ key.getK()[9].getQ(0));
        x.setQ(1, ByteStrings.bytesToLong(data, offset + 8) ^ key.getK()[9].getQ(1));

        for (int i = 8; i >= 0; i--) {
            // kuz_l_inv(&x);
            KuznechikMath.kuz_l_inv(x);

            for (int j = 0; j < 16; j++) {
                // x.b[j] = kuz_pi_inv[x.b[j]];
                x.getB()[j] = KuznechikTables.kuz_pi_inv[x.getB()[j] & 0xFF];
            }

            // x.q[0] ^= key->k[i].q[0];
            x.setQ(0, x.getQ(0) ^ key.getK()[i].getQ(0));
            // x.q[1] ^= key->k[i].q[1];
            x.setQ(1, x.getQ(1) ^ key.getK()[i].getQ(1));
        }

        // ((uint64_t *) blk)[0] = x.q[0];
        // ((uint64_t *) blk)[1] = x.q[1];
        ByteStrings.write(dest, destOffset, ByteStrings.longToBytes(x.getQ(0)), 0, 8);
        ByteStrings.write(dest, destOffset + 8, ByteStrings.longToBytes(x.getQ(1)), 0, 8);
    }
1254268
function decryptObject(obj, decryptFunction) {
    if (_.isArray(obj)) {
        for (var i = 0; i < obj.length; i++) {
            if (_.isString(obj[i])) {
                if (isEncrypted(obj[i])) {
                    obj[i] = decryptFunction(obj[i]);
                }
            } else {
                decryptObject(obj[i], decryptFunction);
            }
        }
    } else if (_.isObject(obj)) {
        for (var key in obj) {
            if (_.isString(obj[key])) {
                if (isEncrypted(obj[key])) {
                    obj[key] = decryptFunction(obj[key]);
                }
            } else {
                decryptObject(obj[key], decryptFunction);
            }
        }
    }
}
1104354
def decrypt(self, password_encrypted):
        
        if not password_encrypted or not self._crypter:
            return password_encrypted or b''
        return self._crypter.decrypt(password_encrypted)
313137
public static String decrypt(byte[] key256Bits, String encrypted) {
        SecretKey secretKey = new SecretKeySpec(key256Bits, "AES");
        return decryptBouncyCastle(secretKey, encrypted);
    }
456307
public byte[] decrypt(byte[] cipherBytes) throws MissingParameterException {
		if (cipherBytes == null || cipherBytes.length == 0) {
			throw new MissingParameterException("Missing parameter: cipherBytes");
		}

		return byteEncryptor.decrypt(cipherBytes);

	}
1220172
public static void decryptFile(File encryptedFile, File result, String password) throws IOException {
        byte[] b = readBytes(encryptedFile);
        String decryptedImageString = new RNCryptorNative().decrypt(new String(b), password);
        byte[] decodedBytes = Base64.decode(decryptedImageString, 0);
        writeBytes(result, decodedBytes);
    }