|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -1837,6 +1837,11 @@ private void doGenSecretKey(String alias, String keyAlgName,
|
1837 | 1837 | useDefaultPBEAlgorithm = false;
|
1838 | 1838 | }
|
1839 | 1839 |
|
| 1840 | + SecretKeyConstraintsParameters skcp = |
| 1841 | + new SecretKeyConstraintsParameters(secKey); |
| 1842 | + checkWeakConstraint(rb.getString("the.generated.secretkey"), |
| 1843 | + keyAlgName, skcp); |
| 1844 | + |
1840 | 1845 | if (verbose) {
|
1841 | 1846 | MessageFormat form = new MessageFormat(rb.getString(
|
1842 | 1847 | "Generated.keyAlgName.secret.key"));
|
@@ -5068,6 +5073,16 @@ private void checkWeakConstraint(String label, CRL crl, Key key,
|
5068 | 5073 | }
|
5069 | 5074 | }
|
5070 | 5075 |
|
| 5076 | + private void checkWeakConstraint(String label, String keyAlg, |
| 5077 | + SecretKeyConstraintsParameters skcp) { |
| 5078 | + try { |
| 5079 | + LEGACY_CHECK.permits(keyAlg, skcp, false); |
| 5080 | + } catch (CertPathValidatorException e) { |
| 5081 | + weakWarnings.add(String.format( |
| 5082 | + rb.getString("key.algorithm.weak"), label, keyAlg)); |
| 5083 | + } |
| 5084 | + } |
| 5085 | + |
5071 | 5086 | private void checkWeak(String label, CRL crl, Key key) {
|
5072 | 5087 | if (crl instanceof X509CRLImpl impl) {
|
5073 | 5088 | checkWeak(label, impl.getSigAlgName(), key);
|
|
0 commit comments