466
467 // cache to speed up the parameters construction
468 static final Map<NamedGroup,
469 AlgorithmParameters> namedGroupParams = new HashMap<>();
470
471 // the supported named groups
472 static final NamedGroup[] supportedNamedGroups;
473
474 static {
475 boolean requireFips = SunJSSE.isFIPS();
476
477 // The value of the System Property defines a list of enabled named
478 // groups in preference order, separated with comma. For example:
479 //
480 // jdk.tls.namedGroups="secp521r1, secp256r1, ffdhe2048"
481 //
482 // If the System Property is not defined or the value is empty, the
483 // default groups and preferences will be used.
484 String property = GetPropertyAction
485 .privilegedGetProperty("jdk.tls.namedGroups");
486 if (property != null && property.length() != 0) {
487 // remove double quote marks from beginning/end of the property
488 if (property.length() > 1 && property.charAt(0) == '"' &&
489 property.charAt(property.length() - 1) == '"') {
490 property = property.substring(1, property.length() - 1);
491 }
492 }
493
494 ArrayList<NamedGroup> groupList;
495 if (property != null && property.length() != 0) {
496 String[] groups = property.split(",");
497 groupList = new ArrayList<>(groups.length);
498 for (String group : groups) {
499 group = group.trim();
500 if (!group.isEmpty()) {
501 NamedGroup namedGroup = NamedGroup.nameOf(group);
502 if (namedGroup != null &&
503 (!requireFips || namedGroup.isFips)) {
504 if (isAvailableGroup(namedGroup)) {
505 groupList.add(namedGroup);
506 }
507 } // ignore unknown groups
508 }
509 }
510
511 if (groupList.isEmpty()) {
512 throw new IllegalArgumentException(
513 "System property jdk.tls.namedGroups(" +
514 property + ") contains no supported named groups");
515 }
|
466
467 // cache to speed up the parameters construction
468 static final Map<NamedGroup,
469 AlgorithmParameters> namedGroupParams = new HashMap<>();
470
471 // the supported named groups
472 static final NamedGroup[] supportedNamedGroups;
473
474 static {
475 boolean requireFips = SunJSSE.isFIPS();
476
477 // The value of the System Property defines a list of enabled named
478 // groups in preference order, separated with comma. For example:
479 //
480 // jdk.tls.namedGroups="secp521r1, secp256r1, ffdhe2048"
481 //
482 // If the System Property is not defined or the value is empty, the
483 // default groups and preferences will be used.
484 String property = GetPropertyAction
485 .privilegedGetProperty("jdk.tls.namedGroups");
486 if (property != null && !property.isEmpty()) {
487 // remove double quote marks from beginning/end of the property
488 if (property.length() > 1 && property.charAt(0) == '"' &&
489 property.charAt(property.length() - 1) == '"') {
490 property = property.substring(1, property.length() - 1);
491 }
492 }
493
494 ArrayList<NamedGroup> groupList;
495 if (property != null && !property.isEmpty()) {
496 String[] groups = property.split(",");
497 groupList = new ArrayList<>(groups.length);
498 for (String group : groups) {
499 group = group.trim();
500 if (!group.isEmpty()) {
501 NamedGroup namedGroup = NamedGroup.nameOf(group);
502 if (namedGroup != null &&
503 (!requireFips || namedGroup.isFips)) {
504 if (isAvailableGroup(namedGroup)) {
505 groupList.add(namedGroup);
506 }
507 } // ignore unknown groups
508 }
509 }
510
511 if (groupList.isEmpty()) {
512 throw new IllegalArgumentException(
513 "System property jdk.tls.namedGroups(" +
514 property + ") contains no supported named groups");
515 }
|