2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package tests.security.interfaces;
17 import java.math.BigInteger;
18 import java.security.SecureRandomSpi;
19 import java.security.spec.ECFieldFp;
20 import java.security.spec.ECParameterSpec;
21 import java.security.spec.ECPoint;
22 import java.security.spec.EllipticCurve;
23 import java.security.spec.RSAPrivateCrtKeySpec;
26 * Utility class to provide some constants
31 * Valid P for DSA tests
33 static final BigInteger P = new BigInteger(
34 "178479572281896551646004364479186243274554253442971675202712037168"
35 + "82805439171286757012622742273566628953929784385654859898"
36 + "28019943266498970695878014699423565775500281013661604573"
37 + "09351370942441879889477647669664876805999161358675121909"
38 + "02875461840550932624652402732307184862051812119809510467"
39 + "6997149499533466361");
42 * Valid Q for DSA tests
44 static final BigInteger Q = new BigInteger(
45 "764905408100544417452957057404815852894534709423");
48 * Valid G for DSA tests
50 static final BigInteger G = new BigInteger(
51 "250346303870482828530842176986393415513071912937041425322012361012"
52 + "16575725689706821855929265075265423817009497798948914793"
53 + "36272769721567876826949070538671438636626715308216064610"
54 + "91161573885991070984580607652541845127399865661520191726"
55 + "47818913386618968229835178446104566543814577436312685021"
56 + "713979414153557537");
59 * Value returned using MySecureRandomSpi
61 static final BigInteger RND_RET = new BigInteger("10");
64 * Valid RSA parameters
66 static final RSAPrivateCrtKeySpec rsaCrtParam = new RSAPrivateCrtKeySpec(
67 BigInteger.valueOf(3233), BigInteger.valueOf(17),
68 BigInteger.valueOf(2753), BigInteger.valueOf(61),
69 BigInteger.valueOf(53), BigInteger.valueOf(53),
70 BigInteger.valueOf(49), BigInteger.valueOf(52));
75 static final ECParameterSpec ecParam = new ECParameterSpec(
77 new ECFieldFp(BigInteger.valueOf(23)),
78 BigInteger.valueOf(5), BigInteger.valueOf(3)),
79 new ECPoint(BigInteger.valueOf(1), BigInteger.valueOf(3)),
80 BigInteger.valueOf(23), 1);
87 * Utility class to provide "random" data.
88 * Returned value is always constant 10 if converted to BigInteger
90 @SuppressWarnings("serial")
91 class MySecureRandomSpi extends SecureRandomSpi {
94 protected byte[] engineGenerateSeed(int arg0) {
99 protected void engineNextBytes(byte[] bytes) {
100 java.util.Arrays.fill(bytes, (byte) 0);
101 bytes[bytes.length - 1] = (byte) 10;
105 protected void engineSetSeed(byte[] arg0) {