equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
113 * @param in the buffer with the input data to be encrypted |
113 * @param in the buffer with the input data to be encrypted |
114 * @param inOffset the offset in <code>plain</code> |
114 * @param inOffset the offset in <code>plain</code> |
115 * @param len the length of the input data |
115 * @param len the length of the input data |
116 * @param out the buffer for the result |
116 * @param out the buffer for the result |
117 * @param outOff the offset in <code>cipher</code> |
117 * @param outOff the offset in <code>cipher</code> |
|
118 * @return the length of the encrypted data |
118 */ |
119 */ |
119 void encrypt(byte[] in, int inOff, int len, byte[] out, int outOff) { |
120 int encrypt(byte[] in, int inOff, int len, byte[] out, int outOff) { |
120 while (len >= blockSize) { |
121 for (int i = len; i >= blockSize; i -= blockSize) { |
121 embeddedCipher.encryptBlock(in, inOff, out, outOff); |
122 embeddedCipher.encryptBlock(in, inOff, out, outOff); |
122 len -= blockSize; |
|
123 inOff += blockSize; |
123 inOff += blockSize; |
124 outOff += blockSize; |
124 outOff += blockSize; |
125 } |
125 } |
|
126 return len; |
126 } |
127 } |
127 |
128 |
128 /** |
129 /** |
129 * Performs decryption operation. |
130 * Performs decryption operation. |
130 * |
131 * |
145 * @param in the buffer with the input data to be decrypted |
146 * @param in the buffer with the input data to be decrypted |
146 * @param inOff the offset in <code>cipherOffset</code> |
147 * @param inOff the offset in <code>cipherOffset</code> |
147 * @param len the length of the input data |
148 * @param len the length of the input data |
148 * @param out the buffer for the result |
149 * @param out the buffer for the result |
149 * @param outOff the offset in <code>plain</code> |
150 * @param outOff the offset in <code>plain</code> |
|
151 * @return the length of the decrypted data |
150 */ |
152 */ |
151 void decrypt(byte[] in, int inOff, int len, byte[] out, int outOff) { |
153 int decrypt(byte[] in, int inOff, int len, byte[] out, int outOff) { |
152 while (len >= blockSize) { |
154 for (int i = len; i >= blockSize; i -= blockSize) { |
153 embeddedCipher.decryptBlock(in, inOff, out, outOff); |
155 embeddedCipher.decryptBlock(in, inOff, out, outOff); |
154 len -= blockSize; |
|
155 inOff += blockSize; |
156 inOff += blockSize; |
156 outOff += blockSize; |
157 outOff += blockSize; |
157 } |
158 } |
|
159 return len; |
158 } |
160 } |
159 |
|
160 } |
161 } |