Save This Page
Home » openjdk-7 » javax » crypto » [javadoc | source]
    1   /*
    2    * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22    * or visit www.oracle.com if you need additional information or have any
   23    * questions.
   24    */
   25   
   26   package javax.crypto;
   27   
   28   import java.security;
   29   import java.security.spec;
   30   
   31   /**
   32    * This class provides a delegate for the identity cipher - one that does not
   33    * tranform the plaintext.
   34    *
   35    * @author  Li Gong
   36    * @see Nullcipher
   37    *
   38    * @since 1.4
   39    */
   40   
   41   final class NullCipherSpi extends CipherSpi {
   42   
   43       /*
   44        * Do not let anybody instantiate this directly (protected).
   45        */
   46       protected NullCipherSpi() {}
   47   
   48       public void engineSetMode(String mode) {}
   49   
   50       public void engineSetPadding(String padding) {}
   51   
   52       protected int engineGetBlockSize() {
   53           return 1;
   54       }
   55   
   56       protected int engineGetOutputSize(int inputLen) {
   57           return inputLen;
   58       }
   59   
   60       protected byte[] engineGetIV() {
   61           byte[] x = new byte[8];
   62           return x;
   63       }
   64   
   65       protected AlgorithmParameters engineGetParameters() {
   66           return null;
   67       }
   68   
   69       protected void engineInit(int mode, Key key, SecureRandom random) {}
   70   
   71       protected void engineInit(int mode, Key key,
   72                                 AlgorithmParameterSpec params,
   73                                 SecureRandom random) {}
   74   
   75       protected void engineInit(int mode, Key key,
   76                                 AlgorithmParameters params,
   77                                 SecureRandom random) {}
   78   
   79       protected byte[] engineUpdate(byte[] input, int inputOffset,
   80                                     int inputLen) {
   81           if (input == null) return null;
   82           byte[] x = new byte[inputLen];
   83           System.arraycopy(input, inputOffset, x, 0, inputLen);
   84           return x;
   85       }
   86   
   87       protected int engineUpdate(byte[] input, int inputOffset,
   88                                  int inputLen, byte[] output,
   89                                  int outputOffset) {
   90           if (input == null) return 0;
   91           System.arraycopy(input, inputOffset, output, outputOffset, inputLen);
   92           return inputLen;
   93       }
   94   
   95       protected byte[] engineDoFinal(byte[] input, int inputOffset,
   96                                      int inputLen)
   97       {
   98           return engineUpdate(input, inputOffset, inputLen);
   99       }
  100   
  101       protected int engineDoFinal(byte[] input, int inputOffset,
  102                                   int inputLen, byte[] output,
  103                                   int outputOffset)
  104       {
  105           return engineUpdate(input, inputOffset, inputLen,
  106                               output, outputOffset);
  107       }
  108   
  109       protected int engineGetKeySize(Key key)
  110       {
  111           return 0;
  112       }
  113   }

Save This Page
Home » openjdk-7 » javax » crypto » [javadoc | source]