/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4894159
* @summary unit test to test basic functionality of RC2 AlgorithmParameters
* implementation
* @author Sean Mullan
*/
public class RC2AlgorithmParameters {
// much of code copied from test/cipher/rc2arcfour/CipherKAT.java
byte[] iv_1 = {
(byte)0x11,(byte)0x11,(byte)0x11,(byte)0x11,
(byte)0x11,(byte)0x11,(byte)0x11,(byte)0x11,
(byte)0x33,(byte)0x33
};
// check that RC2 is supported by our provider
// check that getAlgorithm returns "RC2"
throw new Exception("getAlgorithm() returned "
}
// test parameters with effective key size and iv
// test parameters with just iv
// test vectors in RFC 2268
}
}
}
// test getParameterSpec returns object equal to input
throw new Exception("AlgorithmParameterSpecs should be equal");
}
// test RC2ParameterSpec with RC2 Cipher
// get IV
throw new Exception("ivs should be equal");
}
// test encoding and decoding
// test RC2 AlgorithmParameters with RC2 Cipher
// get IV
throw new Exception("ivs should be equal");
}
return encoded;
}
throws Exception {
}
if (b == null) {
return "(null)";
}
for (int i = 0; i < b.length; i++) {
int k = b[i] & 0xff;
if (i != 0) {
}
}
}
try {
int n = s.length();
StringReader r = new StringReader(s);
while (true) {
int b1 = nextNibble(r);
if (b1 < 0) {
break;
}
int b2 = nextNibble(r);
if (b2 < 0) {
throw new RuntimeException("Invalid string " + s);
}
}
return out.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static byte[] b(String s) {
return parse(s);
}
while (true) {
if (ch == -1) {
return -1;
return ch - '0';
}
}
}
static class CipherTest {
private final byte[] plaintext;
private final byte[] ciphertext;
private final byte[] key;
private final int effectiveKeySize;
this.ciphertext = b(ciphertext);
this.effectiveKeySize = effectiveKeySize;
}
"encryption failed:");
+ effectiveKeySize);
throw new Exception("RC2AlgorithmParameters Cipher test "
+ "encryption failed");
}
throw new Exception("Re-encryption test failed");
}
+ "decryption failed:");
+ effectiveKeySize);
throw new Exception("RC2AlgorithmParameters Cipher test "
+ "decryption failed");
}
}
}
// test vectors listed in RFC 2268
"00:00:00:00:00:00:00:00", 63),
"FF:FF:FF:FF:FF:FF:FF:FF", 64),
"30:00:00:00:00:00:00:00", 64),
// This vector is not tested because it will throw an exception because the
// key size is too small (less than 40 bits)
// new CipherTest("00:00:00:00:00:00:00:00", "61:A8:A2:44:AD:AC:CC:F0",
// "88", 64),
"88:BC:A9:0E:90:87:5A", 64),
"88:BC:A9:0E:90:87:5A:7F:0F:79:C3:84:62:7B:AF:B2", 64),
"88:BC:A9:0E:90:87:5A:7F:0F:79:C3:84:62:7B:AF:B2", 128),
};
}