1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
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
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16package libcore.java.security;
17
18import java.security.AlgorithmParameterGenerator;
19import java.security.AlgorithmParameters;
20import java.security.KeyPair;
21import java.security.KeyPairGenerator;
22import java.security.NoSuchAlgorithmException;
23import java.security.SecureRandom;
24import javax.crypto.spec.DHParameterSpec;
25import junit.framework.TestCase;
26
27public class OldDHTest extends TestCase {
28
29    // BrokenTest Suffers from DH slowness, disabling for now
30    public void testDHGen() throws Exception {
31        KeyPairGenerator gen = null;
32        try {
33            gen = KeyPairGenerator.getInstance("DH");
34        } catch (NoSuchAlgorithmException e) {
35            fail(e.getMessage());
36        }
37
38        AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance("DH");
39        algorithmparametergenerator.init(1024, new SecureRandom());
40        AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
41        DHParameterSpec dhparameterspec = algorithmparameters.getParameterSpec(DHParameterSpec.class);
42
43
44        //gen.initialize(1024);
45        gen.initialize(dhparameterspec);
46        KeyPair key = gen.generateKeyPair();
47    }
48}
49