public PKCS12BagAttributeSetter setLocalKeyId(PublicKey key) { carrier.setBagAttribute(PKCSObjectIdentifiers.pkcs_9_at_localKeyId, new SubjectKeyIdentifier(key.getEncoded())); return this; } }
/** * @deprecated use version taking a SubjectKeyIdentifier */ public OriginatorIdentifierOrKey( ASN1OctetString id) { this(new SubjectKeyIdentifier(id.getOctets())); }
/** * @deprecated use version taking a SubjectKeyIdentifier */ public OriginatorIdentifierOrKey( ASN1OctetString id) { this(new SubjectKeyIdentifier(id.getOctets())); }
public static SubjectKeyIdentifier getInstance( Object obj) { if (obj instanceof SubjectKeyIdentifier) { return (SubjectKeyIdentifier)obj; } else if (obj != null) { return new SubjectKeyIdentifier(ASN1OctetString.getInstance(obj)); } return null; }
public static SubjectKeyIdentifier getInstance( Object obj) { if (obj instanceof SubjectKeyIdentifier) { return (SubjectKeyIdentifier)obj; } else if (obj != null) { return new SubjectKeyIdentifier(ASN1OctetString.getInstance(obj)); } return null; }
private SubjectKeyIdentifier createSubjectKeyId( PublicKey pubKey) { try { SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(pubKey.getEncoded()); return new SubjectKeyIdentifier(getDigest(info)); } catch (Exception e) { throw new RuntimeException("error creating key"); } }
@SuppressWarnings("resource") static SubjectKeyIdentifier createSubjectKeyId( PublicKey pub) throws IOException { ByteArrayInputStream bIn = new ByteArrayInputStream(pub.getEncoded()); SubjectPublicKeyInfo info = new SubjectPublicKeyInfo( (ASN1Sequence)new ASN1InputStream(bIn).readObject()); return new SubjectKeyIdentifier(info); }
@Override public SubjectKeyIdentifier buildSubjectKeyIdentifier( PublicKey publicKey ) { try { ByteArrayInputStream octets = new ByteArrayInputStream( publicKey.getEncoded() ); SubjectPublicKeyInfo spki = new SubjectPublicKeyInfo( ( ASN1Sequence ) new ASN1InputStream( octets ).readObject() ); return new SubjectKeyIdentifier( spki ); } catch ( IOException ex ) { throw new CryptoFailure( "Unable to build SubjectKeyIdentifier", ex ); } }
private void okPressed() { byte[] keyIdentifier = jkiKeyIdentifier.getKeyIdentifier(); if (keyIdentifier == null) { JOptionPane.showMessageDialog(this, res.getString("DSubjectKeyIdentifier.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } SubjectKeyIdentifier subjectKeyIdentifier = new SubjectKeyIdentifier(keyIdentifier); try { value = subjectKeyIdentifier.getEncoded(ASN1Encoding.DER); } catch (IOException e) { DError.displayError(this, e); return; } closeDialog(); }
certGen.addExtension(Extension.subjectKeyIdentifier, false, new SubjectKeyIdentifier(pubKey.getEncoded())); certGen.addExtension(Extension.basicConstraints, true, new BasicConstraints(true)); certGen.addExtension(Extension.keyUsage, false, new KeyUsage(KeyUsage.keyCertSign | KeyUsage.digitalSignature | KeyUsage.keyEncipherment | KeyUsage.dataEncipherment | KeyUsage.cRLSign));
private void addSubjectKeyIdentifier(X509ExtensionSet extensionSet) throws CryptoException, IOException { KeyIdentifierGenerator skiGenerator = new KeyIdentifierGenerator(subjectPublicKey); SubjectKeyIdentifier ski = new SubjectKeyIdentifier(skiGenerator.generate160BitHashId()); byte[] skiEncoded = wrapInOctetString(ski.getEncoded()); extensionSet.addExtension(X509ExtensionType.SUBJECT_KEY_IDENTIFIER.oid(), false, skiEncoded); }
); certGen.addExtension(Extension.subjectKeyIdentifier, false, new SubjectKeyIdentifier(pubKey.getEncoded())); certGen.addExtension(Extension.basicConstraints, false, new BasicConstraints(false)); certGen.addExtension(Extension.subjectAlternativeName, false, new GeneralNames(new GeneralName(GeneralName.dNSName, hostname)));
SubjectKeyIdentifier responderSubjectKey = new SubjectKeyIdentifier(responderKey); logger.log(Level.INFO, "Responder Key: {0}", Arrays.toString(responderKey)); for (X509CertificateHolder certHolder : certs) {
byte[] encodedSpki = publicKeyInfo.getPublicKeyData().getBytes(); byte[] skiValue = HashAlgo.SHA1.hash(encodedSpki); SubjectKeyIdentifier value = new SubjectKeyIdentifier(skiValue); addExtension(values, extType, value, extControl, neededExtTypes, wantedExtTypes);
SubjectKeyIdentifier aKI = new SubjectKeyIdentifier(ski); certificateGenerator.addExtension(X509Extensions.SubjectKeyIdentifier, true, aKI);