src/java.base/share/classes/sun/security/provider/DSAKeyPairGenerator.java

Print this page
8072452 Support DHE sizes up to 8192-bits

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -44,11 +44,11 @@
  * @author Benjamin Renaud
  * @author Andreas Sterbenz
  *
  */
 public class DSAKeyPairGenerator extends KeyPairGenerator
-implements java.security.interfaces.DSAKeyPairGenerator {
+        implements java.security.interfaces.DSAKeyPairGenerator {
 
     /* Length for prime P and subPrime Q in bits */
     private int plen;
     private int qlen;
 

@@ -72,10 +72,12 @@
             // traditional - allow for backward compatibility
             // L=multiples of 64 and between 512 and 1024 (inclusive)
             // N=160
         } else if (sizeP == 2048 && (sizeQ == 224 || sizeQ == 256)) {
             // L=2048, N=224 or 256
+        } else if (sizeP == 3072 && sizeQ == 256) {
+            // L=3072, N=256
         } else {
             throw new InvalidParameterException
                 ("Unsupported prime and subprime size combination: " +
                  sizeP + ", " + sizeQ);
         }

@@ -89,16 +91,21 @@
 
     /**
      * Initializes the DSA key pair generator. If <code>genParams</code>
      * is false, a set of pre-computed parameters is used.
      */
-    public void initialize(int modlen, boolean genParams, SecureRandom random) {
+    @Override
+    public void initialize(int modlen, boolean genParams, SecureRandom random)
+            throws InvalidParameterException {
+
         int subPrimeLen = -1;
         if (modlen <= 1024) {
             subPrimeLen = 160;
         } else if (modlen == 2048) {
             subPrimeLen = 224;
+        } else if (modlen == 3072) {
+            subPrimeLen = 256;
         }
         checkStrength(modlen, subPrimeLen);
         if (genParams) {
             params = null;
         } else {

@@ -120,11 +127,14 @@
     /**
      * Initializes the DSA object using a DSA parameter object.
      *
      * @param params a fully initialized DSA parameter object.
      */
-    public void initialize(DSAParams params, SecureRandom random) {
+    @Override
+    public void initialize(DSAParams params, SecureRandom random)
+            throws InvalidParameterException {
+
         if (params == null) {
             throw new InvalidParameterException("Params must not be null");
         }
         DSAParameterSpec spec = new DSAParameterSpec
                                 (params.getP(), params.getQ(), params.getG());