< prev index next >

jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java

Print this page




  42 
  43 import java.security.spec.AlgorithmParameterSpec;
  44 import java.security.spec.InvalidParameterSpecException;
  45 
  46 import javax.crypto.BadPaddingException;
  47 import javax.crypto.Cipher;
  48 import javax.crypto.CipherSpi;
  49 import javax.crypto.IllegalBlockSizeException;
  50 import javax.crypto.NoSuchPaddingException;
  51 import javax.crypto.ShortBufferException;
  52 
  53 import javax.crypto.spec.IvParameterSpec;
  54 
  55 /**
  56  * Wrapper class which uses NativeCipher class and Java impls of padding scheme.
  57  * This class currently supports
  58  * - AES/ECB/PKCS5PADDING
  59  * - AES/CBC/PKCS5PADDING
  60  * - AES/CFB128/PKCS5PADDING
  61  *
  62  * @since 1.9
  63  */
  64 public class NativeCipherWithJavaPadding extends CipherSpi {
  65 
  66     private static interface Padding {
  67         // ENC: generate and return the necessary padding bytes
  68         int getPadLen(int dataLen);
  69 
  70         // ENC: generate and return the necessary padding bytes
  71         byte[] getPaddingBytes(int dataLen);
  72 
  73         // DEC: process the decrypted data and buffer up the potential padding
  74         // bytes
  75         byte[] bufferBytes(byte[] intermediateData);
  76 
  77         // DEC: return the length of internally buffered pad bytes
  78         int getBufferedLength();
  79 
  80         // DEC: unpad and place the output in 'out', starting from outOfs
  81         // and return the number of bytes unpadded into 'out'.
  82         int unpad(byte[] paddedData, byte[] out, int outOfs)




  42 
  43 import java.security.spec.AlgorithmParameterSpec;
  44 import java.security.spec.InvalidParameterSpecException;
  45 
  46 import javax.crypto.BadPaddingException;
  47 import javax.crypto.Cipher;
  48 import javax.crypto.CipherSpi;
  49 import javax.crypto.IllegalBlockSizeException;
  50 import javax.crypto.NoSuchPaddingException;
  51 import javax.crypto.ShortBufferException;
  52 
  53 import javax.crypto.spec.IvParameterSpec;
  54 
  55 /**
  56  * Wrapper class which uses NativeCipher class and Java impls of padding scheme.
  57  * This class currently supports
  58  * - AES/ECB/PKCS5PADDING
  59  * - AES/CBC/PKCS5PADDING
  60  * - AES/CFB128/PKCS5PADDING
  61  *
  62  * @since 9
  63  */
  64 public class NativeCipherWithJavaPadding extends CipherSpi {
  65 
  66     private static interface Padding {
  67         // ENC: generate and return the necessary padding bytes
  68         int getPadLen(int dataLen);
  69 
  70         // ENC: generate and return the necessary padding bytes
  71         byte[] getPaddingBytes(int dataLen);
  72 
  73         // DEC: process the decrypted data and buffer up the potential padding
  74         // bytes
  75         byte[] bufferBytes(byte[] intermediateData);
  76 
  77         // DEC: return the length of internally buffered pad bytes
  78         int getBufferedLength();
  79 
  80         // DEC: unpad and place the output in 'out', starting from outOfs
  81         // and return the number of bytes unpadded into 'out'.
  82         int unpad(byte[] paddedData, byte[] out, int outOfs)


< prev index next >