2677 lines · 110.0 KB · Java
RawDownload
        String[] parts = tokenizeTransformation(transformation);        return JceSecurityManager.INSTANCE.getCryptoPermission(parts[0]);    }     /**     * Returns the maximum key length for the specified transformation     * according to the installed JCE jurisdiction policy files. If     * JCE unlimited strength jurisdiction policy files are installed,     * Integer.MAX_VALUE will be returned.     * For more information on default key size in JCE jurisdiction     * policy files, please see Appendix E in the     * <a href=     *   "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppC">     * Java Cryptography Architecture Reference Guide</a>.     *     * @param transformation the cipher transformation.     * @return the maximum key length in bits or Integer.MAX_VALUE.     * @exception NullPointerException if <code>transformation</code> is null.     * @exception NoSuchAlgorithmException if <code>transformation</code>     * is not a valid transformation, i.e. in the form of "algorithm" or     * "algorithm/mode/padding".     * @since 1.5     */    public static final int getMaxAllowedKeyLength(String transformation)            throws NoSuchAlgorithmException {        CryptoPermission cp = getConfiguredPermission(transformation);        return cp.getMaxKeySize();    }     /**     * Returns an AlgorithmParameterSpec object which contains     * the maximum cipher parameter value according to the     * jurisdiction policy file. If JCE unlimited strength jurisdiction     * policy files are installed or there is no maximum limit on the     * parameters for the specified transformation in the policy file,     * null will be returned.     *     * @param transformation the cipher transformation.     * @return an AlgorithmParameterSpec which holds the maximum     * value or null.     * @exception NullPointerException if <code>transformation</code>     * is null.     * @exception NoSuchAlgorithmException if <code>transformation</code>     * is not a valid transformation, i.e. in the form of "algorithm" or     * "algorithm/mode/padding".     * @since 1.5     */    public static final AlgorithmParameterSpec getMaxAllowedParameterSpec(            String transformation) throws NoSuchAlgorithmException {        CryptoPermission cp = getConfiguredPermission(transformation);        return cp.getAlgorithmParameterSpec();    }     /**     * Continues a multi-part update of the Additional Authentication     * Data (AAD).     * <p>     * Calls to this method provide AAD to the cipher when operating in     * modes such as AEAD (GCM/CCM).  If this cipher is operating in     * either GCM or CCM mode, all AAD must be supplied before beginning     * operations on the ciphertext (via the {@code update} and {@code     * doFinal} methods).     *     * @param src the buffer containing the Additional Authentication Data     *     * @throws IllegalArgumentException if the {@code src}     * byte array is null     * @throws IllegalStateException if this cipher is in a wrong state     * (e.g., has not been initialized), does not accept AAD, or if     * operating in either GCM or CCM mode and one of the {@code update}     * methods has already been called for the active     * encryption/decryption operation     * @throws UnsupportedOperationException if the corresponding method     * in the {@code CipherSpi} has not been overridden by an     * implementation     *     * @since 1.7     */    public final void updateAAD(byte[] src) {        if (src == null) {            throw new IllegalArgumentException("src buffer is null");        }         updateAAD(src, 0, src.length);    }     /**     * Continues a multi-part update of the Additional Authentication     * Data (AAD), using a subset of the provided buffer.     * <p>     * Calls to this method provide AAD to the cipher when operating in     * modes such as AEAD (GCM/CCM).  If this cipher is operating in     * either GCM or CCM mode, all AAD must be supplied before beginning     * operations on the ciphertext (via the {@code update} and {@code     * doFinal} methods).     *     * @param src the buffer containing the AAD     * @param offset the offset in {@code src} where the AAD input starts     * @param len the number of AAD bytes     *     * @throws IllegalArgumentException if the {@code src}     * byte array is null, or the {@code offset} or {@code length}     * is less than 0, or the sum of the {@code offset} and     * {@code len} is greater than the length of the     * {@code src} byte array     * @throws IllegalStateException if this cipher is in a wrong state     * (e.g., has not been initialized), does not accept AAD, or if     * operating in either GCM or CCM mode and one of the {@code update}     * methods has already been called for the active     * encryption/decryption operation     * @throws UnsupportedOperationException if the corresponding method     * in the {@code CipherSpi} has not been overridden by an     * implementation     *     * @since 1.7     */    public final void updateAAD(byte[] src, int offset, int len) {        checkCipherState();         // Input sanity check        if ((src == null) || (offset < 0) || (len < 0)                || ((len + offset) > src.length)) {            throw new IllegalArgumentException("Bad arguments");        }         chooseFirstProvider();        if (len == 0) {            return;        }        spi.engineUpdateAAD(src, offset, len);    }     /**     * Continues a multi-part update of the Additional Authentication     * Data (AAD).     * <p>     * Calls to this method provide AAD to the cipher when operating in     * modes such as AEAD (GCM/CCM).  If this cipher is operating in     * either GCM or CCM mode, all AAD must be supplied before beginning     * operations on the ciphertext (via the {@code update} and {@code     * doFinal} methods).     * <p>     * All {@code src.remaining()} bytes starting at     * {@code src.position()} are processed.     * Upon return, the input buffer's position will be equal     * to its limit; its limit will not have changed.     *     * @param src the buffer containing the AAD     *     * @throws IllegalArgumentException if the {@code src ByteBuffer}     * is null     * @throws IllegalStateException if this cipher is in a wrong state     * (e.g., has not been initialized), does not accept AAD, or if     * operating in either GCM or CCM mode and one of the {@code update}     * methods has already been called for the active     * encryption/decryption operation     * @throws UnsupportedOperationException if the corresponding method     * in the {@code CipherSpi} has not been overridden by an     * implementation     *     * @since 1.7     */    public final void updateAAD(ByteBuffer src) {        checkCipherState();         // Input sanity check        if (src == null) {            throw new IllegalArgumentException("src ByteBuffer is null");        }         chooseFirstProvider();        if (src.remaining() == 0) {            return;        }        spi.engineUpdateAAD(src);    }}

Lines 2501–2677 of 2677. Previous lines

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t