📄 cipherspi.java
字号:
* <code>abstract</code>, and the default implementation will throw an * {@link java.lang.UnsupportedOperationException}. Concrete * subclasses should override this method to return the correct * value.</p> * * @param key The key to get the size for. * @return The size of the key, in bits. * @throws java.security.InvalidKeyException If the key's length * cannot be determined by this implementation. */ protected int engineGetKeySize(Key key) throws InvalidKeyException { throw new UnsupportedOperationException(); } /** * <p>Returns the size, in bytes, an output buffer must be for a call * to {@link #engineUpdate(byte[],int,int,byte[],int)} or {@link * #engineDoFinal(byte[],int,int,byte[],int)} to succeed.</p> * * <p>The actual output length may be smaller than the value returned * by this method, as it considers the padding length as well. The * length considered is the argument plus the length of any buffered, * unprocessed bytes.</p> * * @param inputLength The input length, in bytes. * @return The size an output buffer must be. */ protected abstract int engineGetOutputSize(int inputLength); /** * Returns the parameters that this cipher is using. This may be the * parameters used to initialize this cipher, or it may be parameters * that have been initialized with random values. * * @return This cipher's parameters, or <code>null</code> if this * cipher does not use parameters. */ protected abstract AlgorithmParameters engineGetParameters(); /** * Initializes this cipher with an operation mode, key, and source of * randomness. If this cipher requires any other initializing data, * for example an initialization vector, then it should generate it * from the provided source of randomness. * * @param opmode The operation mode, one of {@link * Cipher#DECRYPT_MODE}, {@link Cipher#ENCRYPT_MODE}, {@link * Cipher#UNWRAP_MODE}, or {@link Cipher#WRAP_MODE}. * @param key The key to initialize this cipher with. * @param random The source of random bytes to use. * @throws java.security.InvalidKeyException If the given key is not * acceptable for this implementation. */ protected abstract void engineInit(int opmode, Key key, SecureRandom random) throws InvalidKeyException; /** * Initializes this cipher with an operation mode, key, parameters, * and source of randomness. If this cipher requires any other * initializing data, for example an initialization vector, then it should * generate it from the provided source of randomness. * * @param opmode The operation mode, one of {@link * Cipher#DECRYPT_MODE}, {@link Cipher#ENCRYPT_MODE}, {@link * Cipher#UNWRAP_MODE}, or {@link Cipher#WRAP_MODE}. * @param key The key to initialize this cipher with. * @param params The algorithm parameters to initialize with. * @param random The source of random bytes to use. * @throws java.security.InvalidAlgorithmParameterException If the * given parameters are not appropriate for this * implementation. * @throws java.security.InvalidKeyException If the given key is not * acceptable for this implementation. */ protected abstract void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random) throws InvalidAlgorithmParameterException, InvalidKeyException; /** * Initializes this cipher with an operation mode, key, parameters, * and source of randomness. If this cipher requires any other * initializing data, for example an initialization vector, then it should * generate it from the provided source of randomness. * * @param opmode The operation mode, one of {@link * Cipher#DECRYPT_MODE}, {@link Cipher#ENCRYPT_MODE}, {@link * Cipher#UNWRAP_MODE}, or {@link Cipher#WRAP_MODE}. * @param key The key to initialize this cipher with. * @param params The algorithm parameters to initialize with. * @param random The source of random bytes to use. * @throws java.security.InvalidAlgorithmParameterException If the * given parameters are not appropriate for this * implementation. * @throws java.security.InvalidKeyException If the given key is not * acceptable for this implementation. */ protected abstract void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException, InvalidKeyException; /** * Set the mode in which this cipher is to run. * * @param mode The name of the mode to use. * @throws java.security.NoSuchAlgorithmException If the mode is * not supported by this cipher's provider. */ protected abstract void engineSetMode(String mode) throws NoSuchAlgorithmException; /** * Set the method with which the input is to be padded. * * @param padding The name of the padding to use. * @throws javax.crypto.NoSuchPaddingException If the padding is not * supported by this cipher's provider. */ protected abstract void engineSetPadding(String padding) throws NoSuchPaddingException; /** * <p>Unwraps a previously-wrapped key.</p> * * <p>For compatibility this method is not declared * <code>abstract</code>, and the default implementation will throw an * {@link java.lang.UnsupportedOperationException}.</p> * * @param wrappedKey The wrapped key. * @param wrappedKeyAlgorithm The name of the algorithm used to wrap * this key. * @param wrappedKeyType The type of wrapped key; one of * {@link Cipher#PRIVATE_KEY}, * {@link Cipher#PUBLIC_KEY}, or * {@link Cipher#SECRET_KEY}. * @return The unwrapped key. * @throws java.security.InvalidKeyException If the key cannot be * unwrapped, or if <code>wrappedKeyType</code> is an * inappropriate type for the unwrapped key. * @throws java.security.NoSuchAlgorithmException If the * <code>wrappedKeyAlgorithm</code> is unknown. */ protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException { throw new UnsupportedOperationException(); } /** * Continue with a multi-part transformation, returning a new array of * the transformed bytes. * * @param input The next input bytes. * @param inputOffset The index in the input array from which to start. * @param inputLength The number of bytes to input. * @return The transformed bytes. */ protected abstract byte[] engineUpdate(byte[] input, int inputOffset, int inputLength); /** * Continue with a multi-part transformation, storing the transformed * bytes into the specified array. * * @param input The next input bytes. * @param inputOffset The index in the input from which to start. * @param inputLength The number of bytes to input. * @param output The output buffer. * @param outputOffset The index in the output array from which to start. * @return The transformed bytes. * @throws javax.crypto.ShortBufferException If there is not enough * space in the output array to store the transformed bytes. */ protected abstract int engineUpdate(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws ShortBufferException; /** * <p>Wrap a key.</p> * * <p>For compatibility this method is not declared * <code>abstract</code>, and the default implementation will throw an * {@link java.lang.UnsupportedOperationException}.</p> * * @param key The key to wrap. * @return The wrapped key. * @throws java.security.InvalidKeyException If the key cannot be * wrapped. */ protected byte[] engineWrap(Key key) throws InvalidKeyException, IllegalBlockSizeException { throw new UnsupportedOperationException(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -