001/*
002 * nimbus-jose-jwt
003 *
004 * Copyright 2012-2016, Connect2id Ltd.
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
007 * this file except in compliance with the License. You may obtain a copy of the
008 * License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software distributed
013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
015 * specific language governing permissions and limitations under the License.
016 */
017
018package com.nimbusds.jose;
019
020
021import com.nimbusds.jose.util.Base64URL;
022
023
024/**
025 * JSON Web Encryption (JWE) decrypter.
026 *
027 * @author Vladimir Dzhuvinov
028 * @version 2015-04-21
029 */
030public interface JWEDecrypter extends JWEProvider {
031
032
033        /**
034         * Decrypts the specified cipher text of a {@link JWEObject JWE Object}.
035         *
036         * @param header       The JSON Web Encryption (JWE) header. Must
037         *                     specify a supported JWE algorithm and method.
038         *                     Must not be {@code null}.
039         * @param encryptedKey The encrypted key, {@code null} if not required
040         *                     by the JWE algorithm.
041         * @param iv           The initialisation vector, {@code null} if not
042         *                     required by the JWE algorithm.
043         * @param cipherText   The cipher text to decrypt. Must not be
044         *                     {@code null}.
045         * @param authTag      The authentication tag, {@code null} if not
046         *                     required.
047         *
048         * @return The clear text.
049         *
050         * @throws JOSEException If the JWE algorithm or method is not
051         *                       supported, if a critical header parameter is
052         *                       not supported or marked for deferral to the
053         *                       application, or if decryption failed for some
054         *                       other reason.
055         */
056        byte[] decrypt(final JWEHeader header,
057                       final Base64URL encryptedKey,
058                       final Base64URL iv,
059                       final Base64URL cipherText,
060                       final Base64URL authTag)
061                throws JOSEException;
062}