本文整理汇总了Java中org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory类的典型用法代码示例。如果您正苦于以下问题:Java SubjectPublicKeyInfoFactory类的具体用法?Java SubjectPublicKeyInfoFactory怎么用?Java SubjectPublicKeyInfoFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubjectPublicKeyInfoFactory类属于org.bouncycastle.crypto.util包,在下文中一共展示了SubjectPublicKeyInfoFactory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: fetchPublicKey
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
@Override
public SubjectPublicKeyInfo fetchPublicKey(String keyID)
throws IOException
{
if (sharedPublicKeyMap.containsKey(keyID))
{
Share<ECPoint> share = sharedPublicKeyMap.getShare(keyID, TIME_OUT, TimeUnit.SECONDS);
if (share != null)
{
ECPoint q = share.getValue();
ECDomainParameters params = paramsMap.get(keyID);
return SubjectPublicKeyInfo.getInstance(SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(new ECPublicKeyParameters(q, params)).getEncoded());
}
}
return null;
}
开发者ID:cwgit,项目名称:ximix,代码行数:20,代码来源:ECKeyManager.java
示例2: fetchPartialPublicKey
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
@Override
public PartialPublicKeyInfo fetchPartialPublicKey(String keyID)
throws IOException
{
if (sharedPrivateKeyMap.containsKey(keyID))
{
ECDomainParameters params = paramsMap.get(keyID);
Share<BigInteger> share = sharedPrivateKeyMap.getShare(keyID, TIME_OUT, TimeUnit.SECONDS);
BigInteger d = share.getValue();
ECPoint Q = params.getG().multiply(d);
return new PartialPublicKeyInfo(share.getSequenceNo(), SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(new ECPublicKeyParameters(Q, params)));
}
return null;
}
开发者ID:cwgit,项目名称:ximix,代码行数:17,代码来源:ECKeyManager.java
示例3: getRSAPublicKey
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
public static PublicKey getRSAPublicKey(byte[] encodedPubKey) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
RSAPublicKey pubKey8 = RSAPublicKey.getInstance(encodedPubKey);
SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(new RSAKeyParameters(false, pubKey8.getModulus(), pubKey8.getPublicExponent()));
X509EncodedKeySpec spec = new X509EncodedKeySpec(info.getEncoded());
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
return keyFactory.generatePublic(spec);
}
开发者ID:zsavvas,项目名称:ReCRED_FIDO_UAF_OIDC,代码行数:8,代码来源:KeyCodec.java
示例4: convertToJca
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
public static KeyPair convertToJca(AsymmetricCipherKeyPair keyPair) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
SubjectPublicKeyInfo publicKey = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(keyPair.getPublic());
PrivateKeyInfo privateKey = PrivateKeyInfoFactory.createPrivateKeyInfo(keyPair.getPrivate());
KeyFactory keyFactory = new DefaultJcaJceHelper().createKeyFactory("RSA"); // TODO should we really assume RSA?
return new KeyPair(
keyFactory.generatePublic(new X509EncodedKeySpec(publicKey.getEncoded())),
keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey.getEncoded()))
);
}
开发者ID:grahamedgecombe,项目名称:android-ssl,代码行数:11,代码来源:KeyUtils.java
示例5: generateCertificationRequest
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
private PKCS10CertificationRequest generateCertificationRequest(String dn, KeyPair kp)
throws Exception{
X500Name subject=new X500Name(dn);
PublicKey pubKey=kp.getPublic();
PrivateKey privKey=kp.getPrivate();
AsymmetricKeyParameter pubkeyParam = PublicKeyFactory.createKey(pubKey.getEncoded());
SubjectPublicKeyInfo publicKeyInfo=SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(pubkeyParam);
PKCS10CertificationRequestBuilder builder=new PKCS10CertificationRequestBuilder(subject, publicKeyInfo);
AlgorithmIdentifier signatureAi = new AlgorithmIdentifier(OIWObjectIdentifiers.sha1WithRSA);
BcRSAContentSignerBuilder signerBuilder=new BcRSAContentSignerBuilder(
signatureAi, AlgorithmIdentifier.getInstance(OIWObjectIdentifiers.idSHA1));
AsymmetricKeyParameter pkParam = PrivateKeyFactory.createKey(privKey.getEncoded());
ContentSigner signer=signerBuilder.build(pkParam);
return builder.build(signer);
}
开发者ID:apache,项目名称:airavata,代码行数:16,代码来源:MyProxyLogon.java
示例6: generateCertificationRequest
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
private org.bouncycastle.pkcs.PKCS10CertificationRequest generateCertificationRequest(String dn, KeyPair kp)
throws Exception{
X500Name subject=new X500Name(dn);
PublicKey pubKey=kp.getPublic();
PrivateKey privKey=kp.getPrivate();
AsymmetricKeyParameter pubkeyParam = PublicKeyFactory.createKey(pubKey.getEncoded());
SubjectPublicKeyInfo publicKeyInfo=SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(pubkeyParam);
PKCS10CertificationRequestBuilder builder=new PKCS10CertificationRequestBuilder(subject, publicKeyInfo);
AlgorithmIdentifier signatureAi = new AlgorithmIdentifier(OIWObjectIdentifiers.sha1WithRSA);
BcRSAContentSignerBuilder signerBuilder=new BcRSAContentSignerBuilder(
signatureAi, AlgorithmIdentifier.getInstance(OIWObjectIdentifiers.idSHA1));
AsymmetricKeyParameter pkParam = PrivateKeyFactory.createKey(privKey.getEncoded());
ContentSigner signer=signerBuilder.build(pkParam);
return builder.build(signer);
}
开发者ID:apache,项目名称:airavata,代码行数:16,代码来源:MyProxyLogon.java
示例7: createAuthorityKeyIdentifier
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
public AuthorityKeyIdentifier createAuthorityKeyIdentifier(
AsymmetricKeyParameter publicKey)
throws IOException
{
return super.createAuthorityKeyIdentifier(SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(publicKey));
}
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:BcX509ExtensionUtils.java
示例8: verifyPoints
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
private List<byte[]> verifyPoints(ECPair[] cipherText, ECDomainParameters domainParams, String[] nodeNames, AsymmetricKeyParameter[] pubKeys, List<byte[]>[] partialDecrypts, BigInteger[] weights, int messageIndex)
throws ServiceConnectionException
{
List<byte[]> proofList = new ArrayList<>();
for (int wIndex = 0; wIndex < weights.length; wIndex++)
{
if (weights[wIndex] != null)
{
ECPublicKeyParameters nodeKey = (ECPublicKeyParameters)pubKeys[wIndex];
PairSequenceWithProofs pairSequenceWithProofs = PairSequenceWithProofs.getInstance(domainParams.getCurve(), partialDecrypts[wIndex].get(messageIndex));
ECDecryptionProof[] proofs = pairSequenceWithProofs.getECProofs();
ECPair[] partials = pairSequenceWithProofs.getECPairs();
if (proofs.length != partials.length)
{
eventNotifier.notify(EventNotifier.Level.ERROR, "Partial decrypts and proofs differ in length from node " + nodeNames[wIndex]);
throw new ServiceConnectionException("Partial decrypts and proofs differ in length");
}
ECPoint[] decrypts = new ECPoint[partials.length];
for (int i = 0; i != partials.length; i++)
{
decrypts[i] = partials[i].getX();
}
boolean hasPassed = true;
for (int i = 0; i != partials.length; i++)
{
if (!proofs[i].isVerified(nodeKey, cipherText[i].getX(), partials[i].getX()))
{
hasPassed = false;
}
}
try
{
proofList.add(new ChallengeLogMessage(messageIndex, wIndex, hasPassed, SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(nodeKey), decrypts, proofs).getEncoded());
if (hasPassed)
{
eventNotifier.notify(EventNotifier.Level.INFO, "Proof for message " + messageIndex + " for node " + nodeNames[wIndex] + " passed.");
}
else
{
eventNotifier.notify(EventNotifier.Level.ERROR, "Proof for message " + messageIndex + " for node " + nodeNames[wIndex] + " failed!");
}
}
catch (Exception e)
{
eventNotifier.notify(EventNotifier.Level.ERROR, "Partial decrypts failed to encode from " + nodeNames[wIndex] + ": " + e.getMessage(), e);
throw new ServiceConnectionException("Partial decrypts failed to encode from " + nodeNames[wIndex] + ": " + e.getMessage(), e);
}
}
}
return proofList;
}
开发者ID:cwgit,项目名称:ximix,代码行数:61,代码来源:ClientCommandService.java
示例9: testSingleKeyStoreAndLoad
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
@Test
public void testSingleKeyStoreAndLoad()
throws Exception
{
ECKeyManager keyManager = new ECKeyManager(new TestUtils.BasicNodeContext("Test"));
X9ECParameters ecParameters = CustomNamedCurves.getByName("secp256r1");
ECDomainParameters domainParameters = new ECDomainParameters(ecParameters.getCurve(), ecParameters.getG(), ecParameters.getN(), ecParameters.getH());
ECPoint h = domainParameters.getG().multiply(BigInteger.valueOf(1000001));
AsymmetricCipherKeyPair kp = keyManager.generateKeyPair("Test1", Algorithm.EC_ELGAMAL, 1, domainParameters, h);
ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)kp.getPrivate();
ECPublicKeyParameters pubKey = (ECPublicKeyParameters)kp.getPublic();
ECPoint commitment = pubKey.getParameters().getG().multiply(privKey.getD()).add(h);
keyManager.buildSharedKey("Test1", new ECCommittedSecretShareMessage(0, privKey.getD(), BigInteger.ONE, new ECPoint[]{commitment}, pubKey.getQ(), new ECPoint[]{pubKey.getQ()}));
keyManager.fetchPublicKey("Test1"); // make sure we've synced up
byte[] p12enc = keyManager.getEncoded(passwd);
KeyStore keyStore = KeyStore.getInstance("PKCS12", "BC");
keyStore.load(new ByteArrayInputStream(p12enc), passwd);
Assert.assertEquals(1, keyStore.size());
Assert.assertTrue(keyStore.containsAlias("Test1"));
ECKeyManager rebuiltKeyManager = new ECKeyManager(new TestUtils.BasicNodeContext("Test"));
rebuiltKeyManager.load(passwd, p12enc);
Assert.assertFalse(keyManager.isSigningKey("Test1"));
Assert.assertFalse(rebuiltKeyManager.isSigningKey("Test1"));
Assert.assertEquals(SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(kp.getPublic()), keyManager.fetchPublicKey("Test1"));
Assert.assertEquals(((ECPrivateKeyParameters)kp.getPrivate()).getD(), keyManager.getPartialPrivateKey("Test1"));
Assert.assertEquals(keyManager.fetchPublicKey("Test1"), rebuiltKeyManager.fetchPublicKey("Test1"));
Assert.assertEquals(keyManager.getPartialPrivateKey("Test1"), rebuiltKeyManager.getPartialPrivateKey("Test1"));
}
开发者ID:cwgit,项目名称:ximix,代码行数:42,代码来源:ECKeyManagerTest.java
示例10: createSubjectKeyIdentifier
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
/**
* Return a RFC 3280 type 1 key identifier. As in:
* <pre>
* (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the
* value of the BIT STRING subjectPublicKey (excluding the tag,
* length, and number of unused bits).
* </pre>
* @param publicKey the key object containing the key identifier is to be based on.
* @return the key identifier.
*/
public SubjectKeyIdentifier createSubjectKeyIdentifier(
AsymmetricKeyParameter publicKey)
throws IOException
{
return super.createSubjectKeyIdentifier(SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(publicKey));
}
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:BcX509ExtensionUtils.java
示例11: BcX509v1CertificateBuilder
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
/**
* Initialise the builder using an AsymmetricKeyParameter.
*
* @param issuer X500Name representing the issuer of this certificate.
* @param serial the serial number for the certificate.
* @param notBefore date before which the certificate is not valid.
* @param notAfter date after which the certificate is not valid.
* @param subject X500Name representing the subject of this certificate.
* @param publicKey the public key to be associated with the certificate.
*/
public BcX509v1CertificateBuilder(X500Name issuer, BigInteger serial, Date notBefore, Date notAfter, X500Name subject, AsymmetricKeyParameter publicKey)
throws IOException
{
super(issuer, serial, notBefore, notAfter, subject, SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(publicKey));
}
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:BcX509v1CertificateBuilder.java
示例12: BcX509v3CertificateBuilder
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
/**
* Initialise the builder using a PublicKey.
*
* @param issuer X500Name representing the issuer of this certificate.
* @param serial the serial number for the certificate.
* @param notBefore date before which the certificate is not valid.
* @param notAfter date after which the certificate is not valid.
* @param subject X500Name representing the subject of this certificate.
* @param publicKey the public key to be associated with the certificate.
*/
public BcX509v3CertificateBuilder(X500Name issuer, BigInteger serial, Date notBefore, Date notAfter, X500Name subject, AsymmetricKeyParameter publicKey)
throws IOException
{
super(issuer, serial, notBefore, notAfter, subject, SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(publicKey));
}
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:BcX509v3CertificateBuilder.java
示例13: BcPKCS10CertificationRequestBuilder
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入依赖的package包/类
/**
* Create a PKCS#10 builder for the passed in subject and JCA public key.
*
* @param subject an X500Name containing the subject associated with the request we are building.
* @param publicKey a JCA public key that is to be associated with the request we are building.
* @throws IOException if there is a problem encoding the public key.
*/
public BcPKCS10CertificationRequestBuilder(X500Name subject, AsymmetricKeyParameter publicKey)
throws IOException
{
super(subject, SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(publicKey));
}
开发者ID:Appdome,项目名称:ipack,代码行数:13,代码来源:BcPKCS10CertificationRequestBuilder.java
注:本文中的org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论