/*
* 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 4794996
* @summary Ensure basic functionality of these new ECC classes.
* @author Valerie Peng
*/
public class ECCBasic {
private static final int[] F2M_KS;
static {
F2M_KS = new int[1];
}
new ECGenParameterSpec("prime192v1");
try {
throw new Exception("...should throw IAE");
} catch (IllegalArgumentException iae) {
}
try {
throw new Exception("...should throw NPE");
} catch (NullPointerException npe) {
}
throw new Exception("...error in getP()");
}
throw new Exception("...error in getFieldSize()");
}
}
// invalid parameters
int mBad = 0;
int[] ksBad;
for (int i=0; i<7; i++) {
try {
switch (i) {
case 0:
new ECFieldF2m(mBad);
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
ksBad = new int[2];
break;
case 5:
ksBad = new int[1];
break;
case 6:
ksBad = new int[3];
break;
}
throw new Exception("...should throw IAE");
} catch (IllegalArgumentException iae) {
}
}
for (int i=0; i<2; i++) {
try {
switch (i) {
case 0:
break;
case 1:
break;
}
throw new Exception("...should throw NPE");
} catch (NullPointerException npe) {
}
}
throw new Exception("...error in getReductionPolynomial()");
}
throw new Exception("...error in getMidTermsOfReductionPolynomial()");
}
throw new Exception("...error in getFieldSize()");
}
}
for (int i = 0; i < 2; i++) {
try {
switch (i) {
case 0:
break;
case 1:
break;
}
throw new Exception("...should throw IAE");
} catch (IllegalArgumentException iae) {
}
}
for (int i = 0; i < 3; i++) {
try {
switch (i) {
case 0:
break;
case 1:
break;
case 2:
break;
}
throw new Exception("...should throw NPE");
} catch (NullPointerException npe) {
}
}
throw new Exception("...error in getCurve()");
}
throw new Exception("...error in getGenerator()");
}
throw new Exception("...error in getOrder()");
}
throw new Exception("...error in getCofactor()");
}
}
try {
new ECGenParameterSpec(null);
throw new Exception("...should throw NPE");
} catch (NullPointerException npe) {
}
throw new Exception("...error in getName()");
}
}
for (int i = 0; i < 2; i++) {
try {
switch (i) {
case 0:
break;
case 1:
break;
}
throw new Exception("...should throw NPE");
} catch (NullPointerException npe) {
}
}
throw new Exception("...error in getAffineX()");
}
throw new Exception("...error in getAffineY()");
}
}
for (int i = 0; i < 2; i++) {
try {
switch (i) {
case 0:
break;
case 1:
break;
}
throw new Exception("...should throw NPE");
} catch (NullPointerException npe) {
}
}
throw new Exception("...error in getW()");
}
throw new Exception("...error in getParams()");
}
}
for (int i = 0; i < 2; i++) {
try {
switch (i) {
case 0:
break;
case 1:
break;
}
throw new Exception("...should throw NPE");
} catch (NullPointerException npe) {
}
}
throw new Exception("...error in getS()");
}
throw new Exception("...error in getParams()");
}
}
for (int j = 0; j < 2; j++) {
BigInteger a = ONE;
BigInteger b = ONE;
if (j == 0) { // test a out of range
} else { // test b out of range
}
for (int i = 0; i < 3; i++) {
try {
switch (i) {
case 0:
new EllipticCurve(FP, a, b);
break;
case 1:
break;
case 2:
break;
}
throw new Exception("...should throw IAE");
} catch (IllegalArgumentException iae) {
}
}
for (int i = 0; i < 3; i++) {
try {
switch (i) {
case 0:
new EllipticCurve(F2M, a, b);
break;
case 1:
break;
case 2:
break;
}
throw new Exception("...should throw IAE");
} catch (IllegalArgumentException iae) {
}
}
}
for (int i = 0; i < 6; i++) {
try {
switch (i) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
}
throw new Exception("...should throw NPE");
} catch (NullPointerException npe) {
}
}
throw new Exception("...error in getField()");
}
throw new Exception("...error in getA()");
}
throw new Exception("...error in getB()");
}
throw new Exception("...error in equals()");
}
}
// make sure no unexpected exception when hashCode() is called.
}
testECPoint();
}
}