Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hook <dgh@cryptoworkshop.com>2014-03-25 15:07:38 +0400
committerDavid Hook <dgh@cryptoworkshop.com>2014-03-25 15:07:38 +0400
commit6cbd4d951d11139acb519de66dcfafff1775a622 (patch)
tree438920d2d495f85e7229dafdded30dcbbf873126 /prov/src/test
parent70b80f276825d91946fbc62b0b185f5a44a8b05f (diff)
fixed compilation issue
Diffstat (limited to 'prov/src/test')
-rw-r--r--prov/src/test/java/org/bouncycastle/jce/provider/test/PKCS10CertRequestTest.java16
-rw-r--r--prov/src/test/java/org/bouncycastle/jce/provider/test/TestUtils.java19
2 files changed, 32 insertions, 3 deletions
diff --git a/prov/src/test/java/org/bouncycastle/jce/provider/test/PKCS10CertRequestTest.java b/prov/src/test/java/org/bouncycastle/jce/provider/test/PKCS10CertRequestTest.java
index 115aa3ff..863246eb 100644
--- a/prov/src/test/java/org/bouncycastle/jce/provider/test/PKCS10CertRequestTest.java
+++ b/prov/src/test/java/org/bouncycastle/jce/provider/test/PKCS10CertRequestTest.java
@@ -23,10 +23,13 @@ import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.KeyUsage;
import org.bouncycastle.asn1.x509.SubjectKeyIdentifier;
+import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.asn1.x509.X509Extension;
import org.bouncycastle.asn1.x509.X509Extensions;
import org.bouncycastle.asn1.x509.X509Name;
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
+import org.bouncycastle.crypto.Digest;
+import org.bouncycastle.crypto.digests.SHA1Digest;
import org.bouncycastle.jce.ECGOST3410NamedCurveTable;
import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.PKCS10CertificationRequest;
@@ -424,7 +427,7 @@ public class PKCS10CertRequestTest
oids.add(X509Extensions.KeyUsage);
values.add(new X509Extension(true, new DEROctetString(
new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign))));
- SubjectKeyIdentifier subjectKeyIdentifier = new SubjectKeyIdentifierStructure(pair.getPublic());
+ SubjectKeyIdentifier subjectKeyIdentifier = new SubjectKeyIdentifierStructure(getDigest(SubjectPublicKeyInfo.getInstance(pair.getPublic().getEncoded())));
X509Extension ski = new X509Extension(false, new DEROctetString(subjectKeyIdentifier));
oids.add(X509Extensions.SubjectKeyIdentifier);
values.add(ski);
@@ -533,6 +536,17 @@ public class PKCS10CertRequestTest
nullPointerTest();
}
+ private static byte[] getDigest(SubjectPublicKeyInfo spki)
+ {
+ Digest digest = new SHA1Digest();
+ byte[] resBuf = new byte[digest.getDigestSize()];
+
+ byte[] bytes = spki.getPublicKeyData().getBytes();
+ digest.update(bytes, 0, bytes.length);
+ digest.doFinal(resBuf, 0);
+ return resBuf;
+ }
+
public static void main(
String[] args)
{
diff --git a/prov/src/test/java/org/bouncycastle/jce/provider/test/TestUtils.java b/prov/src/test/java/org/bouncycastle/jce/provider/test/TestUtils.java
index 4751fb2b..bd4cfa64 100644
--- a/prov/src/test/java/org/bouncycastle/jce/provider/test/TestUtils.java
+++ b/prov/src/test/java/org/bouncycastle/jce/provider/test/TestUtils.java
@@ -24,7 +24,10 @@ import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.CRLNumber;
import org.bouncycastle.asn1.x509.CRLReason;
import org.bouncycastle.asn1.x509.KeyUsage;
+import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.asn1.x509.X509Extensions;
+import org.bouncycastle.crypto.Digest;
+import org.bouncycastle.crypto.digests.SHA1Digest;
import org.bouncycastle.jce.PrincipalUtil;
import org.bouncycastle.jce.X509Principal;
import org.bouncycastle.x509.X509V1CertificateGenerator;
@@ -81,7 +84,7 @@ class TestUtils
certGen.setSignatureAlgorithm("SHA256WithRSAEncryption");
certGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(caCert));
- certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false, new SubjectKeyIdentifierStructure(intKey));
+ certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false, new SubjectKeyIdentifierStructure(getDigest(SubjectPublicKeyInfo.getInstance(intKey.getEncoded()))));
certGen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(0));
certGen.addExtension(X509Extensions.KeyUsage, true, new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyCertSign | KeyUsage.cRLSign));
@@ -102,7 +105,7 @@ class TestUtils
certGen.setSignatureAlgorithm("SHA256WithRSAEncryption");
certGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(caCert));
- certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false, new SubjectKeyIdentifierStructure(entityKey));
+ certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false, new SubjectKeyIdentifierStructure(getDigest(SubjectPublicKeyInfo.getInstance(entityKey.getEncoded()))));
certGen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(false));
certGen.addExtension(X509Extensions.KeyUsage, true, new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment));
@@ -282,5 +285,17 @@ class TestUtils
{
return new byte[0];
}
+
+ }
+
+ private static byte[] getDigest(SubjectPublicKeyInfo spki)
+ {
+ Digest digest = new SHA1Digest();
+ byte[] resBuf = new byte[digest.getDigestSize()];
+
+ byte[] bytes = spki.getPublicKeyData().getBytes();
+ digest.update(bytes, 0, bytes.length);
+ digest.doFinal(resBuf, 0);
+ return resBuf;
}
}