author | lana |
Thu, 26 Dec 2013 12:04:16 -0800 | |
changeset 23010 | 6dadb192ad81 |
parent 21278 | ef8a3a2a72f2 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
21278
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 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 |
|
21278 | 33 |
* transform the plain text. |
2 | 34 |
* |
35 |
* @author Li Gong |
|
14014 | 36 |
* @see NullCipher |
2 | 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 |
} |