@Override protected void updateCertificate0(final P11ObjectIdentifier objectId, final X509Certificate newCert) throws P11TokenException, CertificateException { Asn1EntityIdAndCert asn1 = new Asn1EntityIdAndCert( new P11EntityIdentifier(slotId, objectId), newCert); module.send(P11ProxyConstants.ACTION_UPDATE_CERT, asn1); }
@Override protected void addCert0(final P11ObjectIdentifier objectId, final X509Certificate cert) throws P11TokenException, CertificateException { Asn1EntityIdAndCert asn1 = new Asn1EntityIdAndCert( new P11EntityIdentifier(slotId, objectId), cert); module.send(P11ProxyConstants.ACTION_ADD_CERT, asn1); }
private P11Identity saveP11Entity(final KeyPair keypair, final String label) throws P11TokenException { byte[] id = generateId(); savePkcs11PrivateKey(id, label, keypair.getPrivate()); savePkcs11PublicKey(id, label, keypair.getPublic()); P11EntityIdentifier identityId = new P11EntityIdentifier(slotId, new P11ObjectIdentifier(id, label)); try { return new EmulatorP11Identity(this,identityId, keypair.getPrivate(), keypair.getPublic(), null, maxSessions, random); } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchProviderException ex) { throw new P11TokenException( "could not construct KeyStoreP11Identity: " + ex.getMessage(), ex); } }
private void analyseSingleKey(final SecretKey secretKey, final P11SlotRefreshResult refreshResult) { byte[] id = secretKey.getId().getByteArrayValue(); P11ObjectIdentifier objectId = new P11ObjectIdentifier(id, toString(secretKey.getLabel())); IaikP11Identity identity = new IaikP11Identity(this, new P11EntityIdentifier(slotId, objectId), secretKey); refreshResult.addIdentity(identity); }
public Asn1P11EntityIdentifier(final P11SlotIdentifier slotId, final P11ObjectIdentifier objectId) { ParamUtil.requireNonNull("slotId", slotId); ParamUtil.requireNonNull("objectId", objectId); this.slotId = new Asn1P11SlotIdentifier(slotId); this.objectId = new Asn1P11ObjectIdentifier(objectId); this.entityId = new P11EntityIdentifier(slotId, objectId); }
public Asn1P11EntityIdentifier(final Asn1P11SlotIdentifier slotId, final Asn1P11ObjectIdentifier objectId) { this.slotId = ParamUtil.requireNonNull("slotId", slotId); this.objectId = ParamUtil.requireNonNull("objectId", objectId); this.entityId = new P11EntityIdentifier(slotId.slotId(), objectId.objectId()); }
private PublicKey getPublicKey(final P11ObjectIdentifier objectId) throws P11UnknownEntityException, P11TokenException { P11EntityIdentifier entityId = new P11EntityIdentifier(slotId, objectId); byte[] resp = module.send(P11ProxyConstants.ACTION_GET_PUBLICKEY, new Asn1P11EntityIdentifier(entityId)); if (resp == null) { return null; } SubjectPublicKeyInfo pkInfo = SubjectPublicKeyInfo.getInstance(resp); try { return KeyUtil.generatePublicKey(pkInfo); } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) { throw new P11TokenException("could not generate Public Key from SubjectPublicKeyInfo:" + ex.getMessage(), ex); } }
private P11Identity saveP11Entity(final SecretKey key, final String label) throws P11TokenException { byte[] id = generateId(); savePkcs11SecretKey(id, label, key); P11EntityIdentifier identityId = new P11EntityIdentifier(slotId, new P11ObjectIdentifier(id, label)); try { return new EmulatorP11Identity(this,identityId, key, maxSessions, random); } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchProviderException ex) { throw new P11TokenException( "could not construct KeyStoreP11Identity: " + ex.getMessage(), ex); } }
new P11EntityIdentifier(slotId, p11ObjId), key, maxSessions, random); LOG.info("added PKCS#11 secret key {}", p11ObjId); new P11EntityIdentifier(slotId, p11ObjId), privateKey, publicKey, certs, maxSessions, random); LOG.info("added PKCS#11 key {}", p11ObjId);
private X509Cert getCertificate(final P11ObjectIdentifier certId) throws P11TokenException { P11EntityIdentifier entityId = new P11EntityIdentifier(slotId, certId); byte[] resp = module.send(P11ProxyConstants.ACTION_GET_CERT, new Asn1P11EntityIdentifier(entityId)); if (resp == null) { return null; } try { return new X509Cert(X509Util.parseCert(resp), resp); } catch (CertificateException ex) { throw new P11TokenException("could not parse certificate:" + ex.getMessage(), ex); } }
private void analyseSingleKey(final PrivateKey privKey, final P11SlotRefreshResult refreshResult) throws P11TokenException, XiSecurityException { byte[] id = privKey.getId().getByteArrayValue(); java.security.PublicKey pubKey = null; X509Cert cert = refreshResult.getCertForId(id); if (cert != null) { pubKey = cert.cert().getPublicKey(); } else { PublicKey p11PublicKey = getPublicKeyObject(id, null); if (p11PublicKey == null) { LOG.info("neither certificate nor public key for the key (" + Hex.toHexString(id) + " is available"); return; } pubKey = generatePublicKey(p11PublicKey); } P11ObjectIdentifier objectId = new P11ObjectIdentifier(id, toString(privKey.getLabel())); X509Certificate[] certs = (cert == null) ? null : new X509Certificate[]{cert.cert()}; IaikP11Identity identity = new IaikP11Identity(this, new P11EntityIdentifier(slotId, objectId), privKey, pubKey, certs); refreshResult.addIdentity(identity); }
private Asn1P11EntityIdentifier(final ASN1Sequence seq) throws BadAsn1ObjectException { Asn1Util.requireRange(seq, 2, 2); int idx = 0; this.slotId = Asn1P11SlotIdentifier.getInstance(seq.getObjectAt(idx++)); this.objectId = Asn1P11ObjectIdentifier.getInstance(seq.getObjectAt(idx++)); this.entityId = new P11EntityIdentifier(slotId.slotId(), objectId.objectId()); }
P11EntityIdentifier entityId = new P11EntityIdentifier(slotId, objId);
P11EntityIdentifier entityId = new P11EntityIdentifier(slotId, keyId); ProxyP11Identity identity; if (pubKey == null) {
P11EntityIdentifier entityId = new P11EntityIdentifier(slotId, objId); java.security.PublicKey jcePublicKey; try {
throw new ObjectCreationException("cound not find identity with " + str2); P11EntityIdentifier entityId = new P11EntityIdentifier(slot.slotId(), p11ObjId);
P11EntityIdentifier entityId = new P11EntityIdentifier(slotId, objId);