Skip to content

Commit

Permalink
moved to 1.77
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Nov 5, 2023
1 parent d66e737 commit 4f8d1ce
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 80 deletions.
2 changes: 1 addition & 1 deletion ant/build.regexp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

regexp: <List<PGPSignature>>|<Map<CertID, OCSPResponse>>|<URI[^>]*>>|<[A-Z?][^>@]*[a-zA-Z0-9\\]]>|<[A-Z]>|<[a-z][^>@]*[a-z\\]]>|@SuppressWarnings(.*)|@Override
regexp: <List<PGPSignature>>|<Map<CertID, OCSPResponse>>|<URI[^>]*>>|<[A-Z?][^>@]*[a-zA-Z0-9\\]]>|<[A-Z]>|<[a-z][^>@]*[a-z\\]]>|@SuppressWarnings(.*)|@Override|@Deprecated

8 changes: 4 additions & 4 deletions bc-build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# intended to hold user-specific settings that are *not* committed to
# the repository.

release.suffix: 177b05
release.name: 1.76.99
release.version: 1.76.99
release.debug: true
release.suffix: 177
release.name: 1.77.00
release.version: 1.77.00
release.debug: false

mail.jar.home: ./libs/javax.mail-1.4.7.jar
activation.jar.home: ./libs/activation-1.1.1.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ public class PublicKeyFactory

converters.put(BCObjectIdentifiers.sphincsPlus_sha2_128s, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_sha2_128f, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_shake_128s, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_shake_128f, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_sha2_192s, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_sha2_192f, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_shake_192s, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_shake_192f, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_sha2_256s, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_sha2_256f, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_shake_256s, new SPHINCSPlusConverter());
converters.put(BCObjectIdentifiers.sphincsPlus_shake_256f, new SPHINCSPlusConverter());
converters.put(new ASN1ObjectIdentifier("1.3.9999.6.4.10"), new SPHINCSPlusConverter());

Expand Down
120 changes: 62 additions & 58 deletions core/src/main/jdk1.4/org/bouncycastle/pqc/crypto/util/Utils.java

Large diffs are not rendered by default.

67 changes: 56 additions & 11 deletions pkix/src/test/java/org/bouncycastle/cert/test/ExternalKeyTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.bouncycastle.cert.test;

import java.io.IOException;
import java.io.StringWriter;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
Expand All @@ -10,9 +12,11 @@
import java.security.cert.X509Certificate;
import java.util.Date;

import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.bc.BCObjectIdentifiers;
import org.bouncycastle.asn1.bc.ExternalValue;
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.asn1.util.ASN1Dump;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.GeneralName;
Expand All @@ -22,6 +26,7 @@
import org.bouncycastle.cert.jcajce.JcaX509v1CertificateBuilder;
import org.bouncycastle.jcajce.ExternalPublicKey;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider;
import org.bouncycastle.util.BigIntegers;
Expand All @@ -40,6 +45,7 @@ public void performTest()
{
checkPublicKeyInfo();
checkCertificate();
checkCertificateDilithium();
}

private void checkPublicKeyInfo()
Expand Down Expand Up @@ -87,30 +93,69 @@ private void checkCertificate()
X509Certificate cert = new JcaX509CertificateConverter().setProvider("BC").getCertificate(certHolder);
}

public static void main(
String[] args)
private void checkCertificateDilithium()
throws Exception
{
Security.addProvider(new BouncyCastleProvider());

runTest(new ExternalKeyTest());

Security.addProvider(new BouncyCastlePQCProvider());
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("CMCE");
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("Dilithium5");

KeyPair kp = kpGen.generateKeyPair();

ExternalPublicKey externalKey = new ExternalPublicKey(kp.getPublic(),
new GeneralName(GeneralName.uniformResourceIdentifier, "https://localhost"),
MessageDigest.getInstance("SHA256"));

X500Name name = new X500Name("CN=Test");
X500Name name = new X500Name("C=XX, O=Royal Institute of Public Key Infrastructure, OU=Post-Heffalump Research Department, CN=External Key Test");
long time = System.currentTimeMillis();
JcaX509v1CertificateBuilder certBldr = new JcaX509v1CertificateBuilder(
name, BigIntegers.ONE, new Date(time - 5000), new Date(time + 50000), name, externalKey);
name, BigInteger.valueOf(System.currentTimeMillis()), new Date(time - 5000), new Date(time + 365L * 24L * 60 * 60 * 5000), name, externalKey);

X509CertificateHolder certHolder = certBldr.build(new JcaContentSignerBuilder("SHA256withECDSA").build(kp.getPrivate()));
X509CertificateHolder certHolder = certBldr.build(new JcaContentSignerBuilder("Dilithium5").build(kp.getPrivate()));

X509Certificate cert = new JcaX509CertificateConverter().setProvider("BC").getCertificate(certHolder);
System.err.println(ASN1Dump.dumpAsString(ASN1Primitive.fromByteArray(cert.getEncoded())));

StringWriter sWrt = new StringWriter();
JcaPEMWriter pWrt = new JcaPEMWriter(sWrt);

pWrt.writeObject(cert);

pWrt.writeObject(kp.getPublic());

pWrt.close();

SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(externalKey.getEncoded());

System.err.println(externalKey.getEncoded().length + " " + kp.getPublic().getEncoded().length);
System.err.println(ASN1Dump.dumpAsString(info, true));

System.err.println(ASN1Dump.dumpAsString(ASN1Primitive.fromByteArray(info.getPublicKeyData().getOctets())));
System.err.println(sWrt.toString());
}

public static void main(
String[] args)
throws Exception
{
Security.addProvider(new BouncyCastleProvider());

runTest(new ExternalKeyTest());

Security.addProvider(new BouncyCastlePQCProvider());
// KeyPairGenerator kpGen = KeyPairGenerator.getInstance("CMCE");
//
// KeyPair kp = kpGen.generateKeyPair();
//
// ExternalPublicKey externalKey = new ExternalPublicKey(kp.getPublic(),
// new GeneralName(GeneralName.uniformResourceIdentifier, "https://localhost"),
// MessageDigest.getInstance("SHA256"));
//
// X500Name name = new X500Name("CN=Test");
// long time = System.currentTimeMillis();
// JcaX509v1CertificateBuilder certBldr = new JcaX509v1CertificateBuilder(
// name, BigIntegers.ONE, new Date(time - 5000), new Date(time + 50000), name, externalKey);
//
// X509CertificateHolder certHolder = certBldr.build(new JcaContentSignerBuilder("SHA256withECDSA").build(kp.getPrivate()));
//
// X509Certificate cert = new JcaX509CertificateConverter().setProvider("BC").getCertificate(certHolder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public final class BouncyCastleProvider extends Provider
{
private static final Logger LOG = Logger.getLogger(BouncyCastleProvider.class.getName());

private static String info = "BouncyCastle Security Provider v1.76";
private static String info = "BouncyCastle Security Provider v1.77";

public static final String PROVIDER_NAME = "BC";

Expand Down Expand Up @@ -167,7 +167,7 @@ public final class BouncyCastleProvider extends Provider
*/
public BouncyCastleProvider()
{
super(PROVIDER_NAME, 1.76, info);
super(PROVIDER_NAME, 1.77, info);

AccessController.doPrivileged(new PrivilegedAction()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BouncyCastlePQCProvider
extends Provider
implements ConfigurableProvider
{
private static String info = "BouncyCastle Post-Quantum Security Provider v1.76";
private static String info = "BouncyCastle Post-Quantum Security Provider v1.77";

public static String PROVIDER_NAME = "BCPQC";

Expand Down Expand Up @@ -50,7 +50,7 @@ public class BouncyCastlePQCProvider
*/
public BouncyCastlePQCProvider()
{
super(PROVIDER_NAME, 1.76, info);
super(PROVIDER_NAME, 1.77, info);

AccessController.doPrivileged(new PrivilegedAction()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
public final class BouncyCastleProvider extends Provider
implements ConfigurableProvider
{
private static String info = "BouncyCastle Security Provider v1.76";
private static String info = "BouncyCastle Security Provider v1.77";

public static final String PROVIDER_NAME = "BC";

Expand Down Expand Up @@ -118,7 +118,7 @@ public final class BouncyCastleProvider extends Provider
*/
public BouncyCastleProvider()
{
super(PROVIDER_NAME, 1.76, info);
super(PROVIDER_NAME, 1.77, info);

setup();
}
Expand Down

0 comments on commit 4f8d1ce

Please sign in to comment.