Java源码示例:org.bouncycastle.cert.bc.BcX509ExtensionUtils
示例1
static SubjectKeyIdentifier createSubjectKeyId(
PublicKey pub)
throws IOException
{
SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(pub.getEncoded());
return new BcX509ExtensionUtils().createSubjectKeyIdentifier(info);
}
示例2
private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key key) throws IOException {
try (var is = new ASN1InputStream(new ByteArrayInputStream(key.getEncoded()))) {
ASN1Sequence seq = (ASN1Sequence) is.readObject();
var info = SubjectPublicKeyInfo.getInstance(seq);
return new BcX509ExtensionUtils().createSubjectKeyIdentifier(info);
}
}
示例3
/**
* Create subjectKeyIdentifier
* The Subject Key Identifier extension identifies the public key certified by this certificate.
* This extension provides a way of distinguishing public keys if more than one is available for
* a given subject name.
* i.e.
* Identifier: Subject Key Identifier - 2.5.29.14
* Critical: no
* Key Identifier:
* 3B:46:83:85:27:BC:F5:9D:8E:63:E3:BE:79:EF:AF:79:
* 9C:37:85:84
*
* */
protected SubjectKeyIdentifier createSubjectKeyIdentifier(PublicKey publicKey)
throws IOException {
try (ByteArrayInputStream bais = new ByteArrayInputStream(publicKey.getEncoded());
ASN1InputStream ais = new ASN1InputStream(bais)) {
ASN1Sequence asn1Sequence = (ASN1Sequence) ais.readObject();
SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(asn1Sequence);
return new BcX509ExtensionUtils().createSubjectKeyIdentifier(subjectPublicKeyInfo);
}
}
示例4
/**
* Creates the SubjectKeyIdentifier for a Bouncy Castle X590CertificateHolder.
*
* @param key public key to identify
* @return SubjectKeyIdentifier for the specified key
*/
private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key key) {
SubjectPublicKeyInfo publicKeyInfo = SubjectPublicKeyInfo.getInstance(key.getEncoded());
return new BcX509ExtensionUtils().createSubjectKeyIdentifier(publicKeyInfo);
}
示例5
/**
* Creates the SubjectKeyIdentifier for a Bouncy Castle X590CertificateHolder.
*
* @param key public key to identify
* @return SubjectKeyIdentifier for the specified key
*/
private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key key) {
SubjectPublicKeyInfo publicKeyInfo = SubjectPublicKeyInfo.getInstance(key.getEncoded());
return new BcX509ExtensionUtils().createSubjectKeyIdentifier(publicKeyInfo);
}
示例6
/**
* Creates the SubjectKeyIdentifier for a Bouncy Castle X590CertificateHolder.
*
* @param key public key to identify
* @return SubjectKeyIdentifier for the specified key
*/
private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key key) {
SubjectPublicKeyInfo publicKeyInfo = SubjectPublicKeyInfo.getInstance(key.getEncoded());
return new BcX509ExtensionUtils().createSubjectKeyIdentifier(publicKeyInfo);
}
示例7
/**
* Creates the SubjectKeyIdentifier for a Bouncy Castle X590CertificateHolder.
*
* @param key public key to identify
* @return SubjectKeyIdentifier for the specified key
*/
private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key key) {
SubjectPublicKeyInfo publicKeyInfo = SubjectPublicKeyInfo.getInstance(key.getEncoded());
return new BcX509ExtensionUtils().createSubjectKeyIdentifier(publicKeyInfo);
}