本文整理汇总了Java中org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo方法的典型用法代码示例。如果您正苦于以下问题:Java SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo方法的具体用法?Java SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo怎么用?Java SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory
的用法示例。
在下文中一共展示了SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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()))
);
}
示例4: 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);
}
示例5: 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);
}
示例6: createAuthorityKeyIdentifier
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory; //导入方法依赖的package包/类
public AuthorityKeyIdentifier createAuthorityKeyIdentifier(
AsymmetricKeyParameter publicKey)
throws IOException
{
return super.createAuthorityKeyIdentifier(SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(publicKey));
}
示例7: 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));
}
示例8: 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));
}
示例9: 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));
}
示例10: 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));
}