|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -1815,8 +1815,8 @@ public final void init(int opmode, Certificate certificate,
|
1815 | 1815 |
|
1816 | 1816 | /**
|
1817 | 1817 | * Ensures that {@code Cipher} object is in a valid state for update() and
|
1818 |
| - * doFinal() calls - should be initialized and in ENCRYPT_MODE or |
1819 |
| - * DECRYPT_MODE. |
| 1818 | + * doFinal() calls - should be initialized and in {@code ENCRYPT_MODE} or |
| 1819 | + * {@code DECRYPT_MODE}. |
1820 | 1820 | * @throws IllegalStateException if this {@code Cipher} object is not in
|
1821 | 1821 | * valid state
|
1822 | 1822 | */
|
@@ -1851,7 +1851,8 @@ private void checkCipherState() {
|
1851 | 1851 | * new block
|
1852 | 1852 | *
|
1853 | 1853 | * @throws IllegalStateException if this {@code Cipher} object is in a
|
1854 |
| - * wrong state (e.g., has not been initialized) |
| 1854 | + * wrong state (e.g., has not been initialized, or is not |
| 1855 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
1855 | 1856 | */
|
1856 | 1857 | public final byte[] update(byte[] input) {
|
1857 | 1858 | checkCipherState();
|
@@ -1890,7 +1891,8 @@ public final byte[] update(byte[] input) {
|
1890 | 1891 | * new block.
|
1891 | 1892 | *
|
1892 | 1893 | * @throws IllegalStateException if this {@code Cipher} object
|
1893 |
| - * is in a wrong state (e.g., has not been initialized) |
| 1894 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 1895 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
1894 | 1896 | */
|
1895 | 1897 | public final byte[] update(byte[] input, int inputOffset, int inputLen) {
|
1896 | 1898 | checkCipherState();
|
@@ -1940,7 +1942,8 @@ public final byte[] update(byte[] input, int inputOffset, int inputLen) {
|
1940 | 1942 | * @return the number of bytes stored in {@code output}
|
1941 | 1943 | *
|
1942 | 1944 | * @throws IllegalStateException if this {@code Cipher} object
|
1943 |
| - * is in a wrong state (e.g., has not been initialized) |
| 1945 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 1946 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
1944 | 1947 | * @throws ShortBufferException if the given output buffer is too small
|
1945 | 1948 | * to hold the result
|
1946 | 1949 | */
|
@@ -1998,7 +2001,8 @@ public final int update(byte[] input, int inputOffset, int inputLen,
|
1998 | 2001 | * @return the number of bytes stored in {@code output}
|
1999 | 2002 | *
|
2000 | 2003 | * @throws IllegalStateException if this {@code Cipher} object
|
2001 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2004 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 2005 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
2002 | 2006 | * @throws ShortBufferException if the given output buffer is too small
|
2003 | 2007 | * to hold the result
|
2004 | 2008 | */
|
@@ -2052,7 +2056,8 @@ public final int update(byte[] input, int inputOffset, int inputLen,
|
2052 | 2056 | * @return the number of bytes stored in {@code output}
|
2053 | 2057 | *
|
2054 | 2058 | * @throws IllegalStateException if this {@code Cipher} object
|
2055 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2059 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 2060 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
2056 | 2061 | * @throws IllegalArgumentException if input and output are the
|
2057 | 2062 | * same object
|
2058 | 2063 | * @throws ReadOnlyBufferException if the output buffer is read-only
|
@@ -2104,7 +2109,8 @@ public final int update(ByteBuffer input, ByteBuffer output)
|
2104 | 2109 | * @return the new buffer with the result
|
2105 | 2110 | *
|
2106 | 2111 | * @throws IllegalStateException if this {@code Cipher} object
|
2107 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2112 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 2113 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
2108 | 2114 | * @throws IllegalBlockSizeException if this cipher is a block cipher,
|
2109 | 2115 | * no padding has been requested (only in encryption mode), and the total
|
2110 | 2116 | * input length of the data processed by this cipher is not a multiple of
|
@@ -2161,7 +2167,8 @@ public final byte[] doFinal()
|
2161 | 2167 | * @return the number of bytes stored in {@code output}
|
2162 | 2168 | *
|
2163 | 2169 | * @throws IllegalStateException if this {@code Cipher} object
|
2164 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2170 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 2171 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
2165 | 2172 | * @throws IllegalBlockSizeException if this cipher is a block cipher,
|
2166 | 2173 | * no padding has been requested (only in encryption mode), and the total
|
2167 | 2174 | * input length of the data processed by this cipher is not a multiple of
|
@@ -2218,7 +2225,8 @@ public final int doFinal(byte[] output, int outputOffset)
|
2218 | 2225 | * @return the new buffer with the result
|
2219 | 2226 | *
|
2220 | 2227 | * @throws IllegalStateException if this {@code Cipher} object
|
2221 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2228 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 2229 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
2222 | 2230 | * @throws IllegalBlockSizeException if this cipher is a block cipher,
|
2223 | 2231 | * no padding has been requested (only in encryption mode), and the total
|
2224 | 2232 | * input length of the data processed by this cipher is not a multiple of
|
@@ -2276,7 +2284,8 @@ public final byte[] doFinal(byte[] input)
|
2276 | 2284 | * @return the new buffer with the result
|
2277 | 2285 | *
|
2278 | 2286 | * @throws IllegalStateException if this {@code Cipher} object
|
2279 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2287 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 2288 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
2280 | 2289 | * @throws IllegalBlockSizeException if this cipher is a block cipher,
|
2281 | 2290 | * no padding has been requested (only in encryption mode), and the total
|
2282 | 2291 | * input length of the data processed by this cipher is not a multiple of
|
@@ -2347,7 +2356,8 @@ public final byte[] doFinal(byte[] input, int inputOffset, int inputLen)
|
2347 | 2356 | * @return the number of bytes stored in {@code output}
|
2348 | 2357 | *
|
2349 | 2358 | * @throws IllegalStateException if this {@code Cipher} object
|
2350 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2359 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 2360 | + * in or {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
2351 | 2361 | * @throws IllegalBlockSizeException if this cipher is a block cipher,
|
2352 | 2362 | * no padding has been requested (only in encryption mode), and the total
|
2353 | 2363 | * input length of the data processed by this cipher is not a multiple of
|
@@ -2427,7 +2437,8 @@ public final int doFinal(byte[] input, int inputOffset, int inputLen,
|
2427 | 2437 | * @return the number of bytes stored in {@code output}
|
2428 | 2438 | *
|
2429 | 2439 | * @throws IllegalStateException if this {@code Cipher} object
|
2430 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2440 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 2441 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
2431 | 2442 | * @throws IllegalBlockSizeException if this cipher is a block cipher,
|
2432 | 2443 | * no padding has been requested (only in encryption mode), and the total
|
2433 | 2444 | * input length of the data processed by this cipher is not a multiple of
|
@@ -2503,7 +2514,8 @@ public final int doFinal(byte[] input, int inputOffset, int inputLen,
|
2503 | 2514 | * @return the number of bytes stored in {@code output}
|
2504 | 2515 | *
|
2505 | 2516 | * @throws IllegalStateException if this {@code Cipher} object
|
2506 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2517 | + * is in a wrong state (e.g., has not been initialized, or is not |
| 2518 | + * in {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}) |
2507 | 2519 | * @throws IllegalArgumentException if input and output are the
|
2508 | 2520 | * same object
|
2509 | 2521 | * @throws ReadOnlyBufferException if the output buffer is read-only
|
@@ -2551,7 +2563,7 @@ public final int doFinal(ByteBuffer input, ByteBuffer output)
|
2551 | 2563 | * @return the wrapped key
|
2552 | 2564 | *
|
2553 | 2565 | * @throws IllegalStateException if this {@code Cipher} object is in a wrong
|
2554 |
| - * state (e.g., has not been initialized) |
| 2566 | + * state (e.g., has not been initialized, or is not in {@code WRAP_MODE}) |
2555 | 2567 | *
|
2556 | 2568 | * @throws IllegalBlockSizeException if this cipher is a block
|
2557 | 2569 | * cipher, no padding has been requested, and the length of the
|
@@ -2595,8 +2607,8 @@ public final byte[] wrap(Key key)
|
2595 | 2607 | *
|
2596 | 2608 | * @return the unwrapped key
|
2597 | 2609 | *
|
2598 |
| - * @throws IllegalStateException if this {@code Cipher} object |
2599 |
| - * is in a wrong state (e.g., has not been initialized) |
| 2610 | + * @throws IllegalStateException if this {@code Cipher} object is in a wrong |
| 2611 | + * state (e.g., has not been initialized, or is not in {@code UNWRAP_MODE}) |
2600 | 2612 | *
|
2601 | 2613 | * @throws NoSuchAlgorithmException if no installed providers
|
2602 | 2614 | * can create keys of type {@code wrappedKeyType} for the
|
@@ -2732,10 +2744,11 @@ public static final AlgorithmParameterSpec getMaxAllowedParameterSpec(
|
2732 | 2744 | * @throws IllegalArgumentException if the {@code src}
|
2733 | 2745 | * byte array is {@code null}
|
2734 | 2746 | * @throws IllegalStateException if this {@code Cipher} object
|
2735 |
| - * is in a wrong state (e.g., has not been initialized), |
2736 |
| - * does not accept AAD, or if operating in either GCM or CCM mode and |
2737 |
| - * one of the {@code update} methods has already been called for the active |
2738 |
| - * encryption/decryption operation |
| 2747 | + * is in a wrong state (e.g., has not been initialized, or is not in |
| 2748 | + * {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}), does not accept AAD, |
| 2749 | + * or if operating in either GCM or CCM mode and one of the {@code update} |
| 2750 | + * methods has already been called for the active encryption/decryption |
| 2751 | + * operation |
2739 | 2752 | * @throws UnsupportedOperationException if the corresponding method
|
2740 | 2753 | * in the {@code CipherSpi} has not been overridden by an
|
2741 | 2754 | * implementation
|
@@ -2770,10 +2783,11 @@ public final void updateAAD(byte[] src) {
|
2770 | 2783 | * {@code len} is greater than the length of the
|
2771 | 2784 | * {@code src} byte array
|
2772 | 2785 | * @throws IllegalStateException if this {@code Cipher} object
|
2773 |
| - * is in a wrong state (e.g., has not been initialized), |
2774 |
| - * does not accept AAD, or if operating in either GCM or CCM mode and |
2775 |
| - * one of the {@code update} methods has already been called for the active |
2776 |
| - * encryption/decryption operation |
| 2786 | + * is in a wrong state (e.g., has not been initialized, or is not in |
| 2787 | + * {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}), does not accept AAD, |
| 2788 | + * or if operating in either GCM or CCM mode and one of the {@code update} |
| 2789 | + * methods has already been called for the active encryption/decryption |
| 2790 | + * operation |
2777 | 2791 | * @throws UnsupportedOperationException if the corresponding method
|
2778 | 2792 | * in the {@code CipherSpi} has not been overridden by an
|
2779 | 2793 | * implementation
|
@@ -2816,10 +2830,11 @@ public final void updateAAD(byte[] src, int offset, int len) {
|
2816 | 2830 | * @throws IllegalArgumentException if the {@code src ByteBuffer}
|
2817 | 2831 | * is {@code null}
|
2818 | 2832 | * @throws IllegalStateException if this {@code Cipher} object
|
2819 |
| - * is in a wrong state (e.g., has not been initialized), |
2820 |
| - * does not accept AAD, or if operating in either GCM or CCM mode and |
2821 |
| - * one of the {@code update} methods has already been called for the active |
2822 |
| - * encryption/decryption operation |
| 2833 | + * is in a wrong state (e.g., has not been initialized, or is not in |
| 2834 | + * {@code ENCRYPT_MODE} or {@code DECRYPT_MODE}), does not accept AAD, |
| 2835 | + * or if operating in either GCM or CCM mode and one of the {@code update} |
| 2836 | + * methods has already been called for the active encryption/decryption |
| 2837 | + * operation |
2823 | 2838 | * @throws UnsupportedOperationException if the corresponding method
|
2824 | 2839 | * in the {@code CipherSpi} has not been overridden by an
|
2825 | 2840 | * implementation
|
|
0 commit comments