Skip to content

Commit ab93a9d

Browse files
committed
adjusted constraint check for NaccacheSternEngine
fixed typo in CramerShoupCoreEngine updated provider numbers
1 parent b80f4d2 commit ab93a9d

File tree

7 files changed

+75
-19
lines changed

7 files changed

+75
-19
lines changed

core/src/main/java/org/bouncycastle/crypto/engines/CramerShoupCoreEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void init(boolean forEncryption, CipherParameters param)
6868
this.random = initSecureRandom(forEncryption, providedRandom);
6969
this.forEncryption = forEncryption;
7070

71-
CryptoServicesRegistrar.checkConstraints(new DefaultServiceProperties("RSA", ConstraintUtils.bitsOfSecurityFor(key.getParameters().getP()), key, Utils.getPurpose(forEncryption)));
71+
CryptoServicesRegistrar.checkConstraints(new DefaultServiceProperties("CramerShoup", ConstraintUtils.bitsOfSecurityFor(key.getParameters().getP()), key, Utils.getPurpose(forEncryption)));
7272
}
7373

7474
/**

core/src/main/java/org/bouncycastle/crypto/engines/NaccacheSternEngine.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import java.math.BigInteger;
44
import java.util.Vector;
55

6-
import org.bouncycastle.crypto.*;
6+
import org.bouncycastle.crypto.AsymmetricBlockCipher;
7+
import org.bouncycastle.crypto.CipherParameters;
8+
import org.bouncycastle.crypto.CryptoServicesRegistrar;
9+
import org.bouncycastle.crypto.DataLengthException;
10+
import org.bouncycastle.crypto.InvalidCipherTextException;
11+
import org.bouncycastle.crypto.constraints.ConstraintUtils;
712
import org.bouncycastle.crypto.constraints.DefaultServiceProperties;
813
import org.bouncycastle.crypto.params.NaccacheSternKeyParameters;
914
import org.bouncycastle.crypto.params.NaccacheSternPrivateKeyParameters;
@@ -82,7 +87,7 @@ public void init(boolean forEncryption, CipherParameters param)
8287
}
8388

8489
CryptoServicesRegistrar.checkConstraints(new DefaultServiceProperties(
85-
"NaccacheStern", 88, param, Utils.getPurpose(forEncryption)));
90+
"NaccacheStern", ConstraintUtils.bitsOfSecurityFor(key.getModulus()), param, Utils.getPurpose(forEncryption)));
8691
}
8792

8893
public void setDebug(boolean debug)

core/src/test/java/org/bouncycastle/crypto/test/AsymmetricConstraintsTest.java

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.bouncycastle.crypto.BasicAgreement;
1010
import org.bouncycastle.crypto.CipherParameters;
1111
import org.bouncycastle.crypto.CryptoServiceConstraintsException;
12-
import org.bouncycastle.crypto.CryptoServicePurpose;
1312
import org.bouncycastle.crypto.CryptoServicesRegistrar;
1413
import org.bouncycastle.crypto.DSA;
1514
import org.bouncycastle.crypto.RawAgreement;
@@ -31,15 +30,67 @@
3130
import org.bouncycastle.crypto.agreement.XDHUnifiedAgreement;
3231
import org.bouncycastle.crypto.constraints.BitsOfSecurityConstraint;
3332
import org.bouncycastle.crypto.constraints.LegacyBitsOfSecurityConstraint;
34-
import org.bouncycastle.crypto.digests.DSTU7564Digest;
3533
import org.bouncycastle.crypto.digests.SHA1Digest;
3634
import org.bouncycastle.crypto.digests.SHA256Digest;
37-
import org.bouncycastle.crypto.engines.*;
38-
import org.bouncycastle.crypto.generators.*;
35+
import org.bouncycastle.crypto.engines.CramerShoupCoreEngine;
36+
import org.bouncycastle.crypto.engines.ElGamalEngine;
37+
import org.bouncycastle.crypto.engines.NaccacheSternEngine;
38+
import org.bouncycastle.crypto.engines.RSAEngine;
39+
import org.bouncycastle.crypto.engines.SM2Engine;
40+
import org.bouncycastle.crypto.generators.CramerShoupKeyPairGenerator;
41+
import org.bouncycastle.crypto.generators.CramerShoupParametersGenerator;
42+
import org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator;
43+
import org.bouncycastle.crypto.generators.DHKeyPairGenerator;
44+
import org.bouncycastle.crypto.generators.DSAKeyPairGenerator;
45+
import org.bouncycastle.crypto.generators.ECKeyPairGenerator;
46+
import org.bouncycastle.crypto.generators.Ed25519KeyPairGenerator;
47+
import org.bouncycastle.crypto.generators.Ed448KeyPairGenerator;
48+
import org.bouncycastle.crypto.generators.ElGamalKeyPairGenerator;
49+
import org.bouncycastle.crypto.generators.GOST3410KeyPairGenerator;
50+
import org.bouncycastle.crypto.generators.KDF2BytesGenerator;
51+
import org.bouncycastle.crypto.generators.NaccacheSternKeyPairGenerator;
52+
import org.bouncycastle.crypto.generators.RSAKeyPairGenerator;
53+
import org.bouncycastle.crypto.generators.X25519KeyPairGenerator;
54+
import org.bouncycastle.crypto.generators.X448KeyPairGenerator;
3955
import org.bouncycastle.crypto.kems.ECIESKeyEncapsulation;
4056
import org.bouncycastle.crypto.kems.RSAKeyEncapsulation;
41-
import org.bouncycastle.crypto.macs.GOST28147Mac;
42-
import org.bouncycastle.crypto.params.*;
57+
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
58+
import org.bouncycastle.crypto.params.CramerShoupKeyGenerationParameters;
59+
import org.bouncycastle.crypto.params.DHKeyGenerationParameters;
60+
import org.bouncycastle.crypto.params.DHMQVPrivateParameters;
61+
import org.bouncycastle.crypto.params.DHMQVPublicParameters;
62+
import org.bouncycastle.crypto.params.DHPrivateKeyParameters;
63+
import org.bouncycastle.crypto.params.DHPublicKeyParameters;
64+
import org.bouncycastle.crypto.params.DHUPrivateParameters;
65+
import org.bouncycastle.crypto.params.DHUPublicParameters;
66+
import org.bouncycastle.crypto.params.DSAKeyGenerationParameters;
67+
import org.bouncycastle.crypto.params.DSAParameters;
68+
import org.bouncycastle.crypto.params.DSAPrivateKeyParameters;
69+
import org.bouncycastle.crypto.params.DSAPublicKeyParameters;
70+
import org.bouncycastle.crypto.params.ECDHUPrivateParameters;
71+
import org.bouncycastle.crypto.params.ECDHUPublicParameters;
72+
import org.bouncycastle.crypto.params.ECDomainParameters;
73+
import org.bouncycastle.crypto.params.ECKeyGenerationParameters;
74+
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
75+
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
76+
import org.bouncycastle.crypto.params.Ed25519KeyGenerationParameters;
77+
import org.bouncycastle.crypto.params.Ed448KeyGenerationParameters;
78+
import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters;
79+
import org.bouncycastle.crypto.params.ElGamalParameters;
80+
import org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters;
81+
import org.bouncycastle.crypto.params.GOST3410Parameters;
82+
import org.bouncycastle.crypto.params.KeyParameter;
83+
import org.bouncycastle.crypto.params.MQVPrivateParameters;
84+
import org.bouncycastle.crypto.params.MQVPublicParameters;
85+
import org.bouncycastle.crypto.params.NaccacheSternKeyGenerationParameters;
86+
import org.bouncycastle.crypto.params.ParametersWithRandom;
87+
import org.bouncycastle.crypto.params.ParametersWithUKM;
88+
import org.bouncycastle.crypto.params.RSAKeyGenerationParameters;
89+
import org.bouncycastle.crypto.params.RSAKeyParameters;
90+
import org.bouncycastle.crypto.params.X25519KeyGenerationParameters;
91+
import org.bouncycastle.crypto.params.X448KeyGenerationParameters;
92+
import org.bouncycastle.crypto.params.XDHUPrivateParameters;
93+
import org.bouncycastle.crypto.params.XDHUPublicParameters;
4394
import org.bouncycastle.crypto.signers.DSASigner;
4495
import org.bouncycastle.crypto.signers.DSTU4145Signer;
4596
import org.bouncycastle.crypto.signers.ECDSASigner;
@@ -84,7 +135,7 @@ public void performTest()
84135
testECIESKEM();
85136
testSM2Cipher();
86137
testCramerShoup();
87-
// testNaccacheStern();
138+
testNaccacheStern();
88139
}
89140

90141
private void test1024bitDSA()
@@ -917,7 +968,7 @@ private void testNaccacheStern()
917968

918969
kpGen.init(new NaccacheSternKeyGenerationParameters(random, 1024, 8, 40));
919970

920-
CryptoServicesRegistrar.setServicesConstraints(new LegacyBitsOfSecurityConstraint(88, 80));
971+
CryptoServicesRegistrar.setServicesConstraints(new LegacyBitsOfSecurityConstraint(128, 80));
921972

922973
AsymmetricCipherKeyPair kp = kpGen.generateKeyPair();
923974

prov/src/main/java/org/bouncycastle/jce/provider/BouncyCastleProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public final class BouncyCastleProvider extends Provider
7070
{
7171
private static final Logger LOG = Logger.getLogger(BouncyCastleProvider.class.getName());
7272

73-
private static String info = "BouncyCastle Security Provider v1.72b";
73+
private static String info = "BouncyCastle Security Provider v1.72";
7474

7575
public static final String PROVIDER_NAME = "BC";
7676

@@ -161,7 +161,7 @@ public final class BouncyCastleProvider extends Provider
161161
*/
162162
public BouncyCastleProvider()
163163
{
164-
super(PROVIDER_NAME, 1.7199, info);
164+
super(PROVIDER_NAME, 1.72, info);
165165

166166
AccessController.doPrivileged(new PrivilegedAction()
167167
{

prov/src/main/java/org/bouncycastle/pqc/jcajce/provider/BouncyCastlePQCProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class BouncyCastlePQCProvider
2222
extends Provider
2323
implements ConfigurableProvider
2424
{
25-
private static String info = "BouncyCastle Post-Quantum Security Provider v1.72b";
25+
private static String info = "BouncyCastle Post-Quantum Security Provider v1.72";
2626

2727
public static String PROVIDER_NAME = "BCPQC";
2828

@@ -49,7 +49,7 @@ public class BouncyCastlePQCProvider
4949
*/
5050
public BouncyCastlePQCProvider()
5151
{
52-
super(PROVIDER_NAME, 1.7199, info);
52+
super(PROVIDER_NAME, 1.72, info);
5353

5454
AccessController.doPrivileged(new PrivilegedAction()
5555
{

prov/src/main/jdk1.1/org/bouncycastle/jce/provider/BouncyCastleProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
public final class BouncyCastleProvider extends Provider
4444
implements ConfigurableProvider
4545
{
46-
private static String info = "BouncyCastle Security Provider v1.71";
46+
private static String info = "BouncyCastle Security Provider v1.72";
4747

4848
public static final String PROVIDER_NAME = "BC";
4949

@@ -118,7 +118,7 @@ public final class BouncyCastleProvider extends Provider
118118
*/
119119
public BouncyCastleProvider()
120120
{
121-
super(PROVIDER_NAME, 1.71, info);
121+
super(PROVIDER_NAME, 1.72, info);
122122

123123
setup();
124124
}

prov/src/main/jdk1.4/org/bouncycastle/jce/provider/BouncyCastleProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
public final class BouncyCastleProvider extends Provider
5050
implements ConfigurableProvider
5151
{
52-
private static String info = "BouncyCastle Security Provider v1.71";
52+
private static String info = "BouncyCastle Security Provider v1.72";
5353

5454
public static final String PROVIDER_NAME = "BC";
5555

@@ -133,7 +133,7 @@ public final class BouncyCastleProvider extends Provider
133133
*/
134134
public BouncyCastleProvider()
135135
{
136-
super(PROVIDER_NAME, 1.71, info);
136+
super(PROVIDER_NAME, 1.72, info);
137137

138138
AccessController.doPrivileged(new PrivilegedAction()
139139
{

0 commit comments

Comments
 (0)