equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, 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 |
29 import java.security.*; |
29 import java.security.*; |
30 import java.security.spec.*; |
30 import java.security.spec.*; |
31 import javax.crypto.spec.DHParameterSpec; |
31 import javax.crypto.spec.DHParameterSpec; |
32 import javax.crypto.spec.DHGenParameterSpec; |
32 import javax.crypto.spec.DHGenParameterSpec; |
33 |
33 |
|
34 import static sun.security.util.SecurityProviderConstants.DEF_DH_KEY_SIZE; |
|
35 |
34 /* |
36 /* |
35 * This class generates parameters for the Diffie-Hellman algorithm. |
37 * This class generates parameters for the Diffie-Hellman algorithm. |
36 * The parameters are a prime, a base, and optionally the length in bits of |
38 * The parameters are a prime, a base, and optionally the length in bits of |
37 * the private value. |
39 * the private value. |
38 * |
40 * |
39 * <p>The Diffie-Hellman parameter generation accepts the size in bits of the |
41 * <p>The Diffie-Hellman parameter generation accepts the size in bits of the |
40 * prime modulus and the size in bits of the random exponent as input. |
42 * prime modulus and the size in bits of the random exponent as input. |
41 * The size of the prime modulus defaults to 2048 bits. |
|
42 * |
43 * |
43 * @author Jan Luehe |
44 * @author Jan Luehe |
44 * |
45 * |
45 * |
46 * |
46 * @see java.security.AlgorithmParameters |
47 * @see java.security.AlgorithmParameters |
48 * @see DHParameters |
49 * @see DHParameters |
49 */ |
50 */ |
50 public final class DHParameterGenerator extends AlgorithmParameterGeneratorSpi { |
51 public final class DHParameterGenerator extends AlgorithmParameterGeneratorSpi { |
51 |
52 |
52 // The size in bits of the prime modulus |
53 // The size in bits of the prime modulus |
53 private int primeSize = 2048; |
54 private int primeSize = DEF_DH_KEY_SIZE; |
54 |
55 |
55 // The size in bits of the random exponent (private value) |
56 // The size in bits of the random exponent (private value) |
56 private int exponentSize = 0; |
57 private int exponentSize = 0; |
57 |
58 |
58 // The source of randomness |
59 // The source of randomness |