use of org.xipki.security.pkcs11.P11Slot in project xipki by xipki.
the class BSpeedP11ECSignCmd method nextTester.
@Override
protected LoadExecutor nextTester() throws Exception {
ECControl control = queue.poll();
if (control == null) {
return null;
}
P11Slot slot = getSlot();
return new P11ECSignLoadTest(securityFactory, slot, sigAlgo, control.curveName());
}
use of org.xipki.security.pkcs11.P11Slot in project xipki by xipki.
the class BSpeedP11RSASignCmd method nextTester.
@Override
protected LoadExecutor nextTester() throws Exception {
RSAControl control = queue.poll();
if (control == null) {
return null;
}
P11Slot slot = getSlot();
return new P11RSASignLoadTest(securityFactory, slot, sigAlgo, control.modulusLen(), toBigInt("0x10001"));
}
use of org.xipki.security.pkcs11.P11Slot in project xipki by xipki.
the class P11DSAKeyGenCmd method execute0.
@Override
protected Object execute0() throws Exception {
if (plen % 1024 != 0) {
throw new IllegalCmdParamException("plen is not multiple of 1024: " + plen);
}
if (qlen == null) {
if (plen <= 1024) {
qlen = 160;
} else if (plen <= 2048) {
qlen = 224;
} else {
qlen = 256;
}
}
P11Slot slot = getSlot();
P11ObjectIdentifier objId = slot.generateDSAKeypair(plen, qlen, label, getControl());
finalize("DSA", objId);
return null;
}
use of org.xipki.security.pkcs11.P11Slot in project xipki by xipki.
the class ProxyP11Module method refresh.
public void refresh() throws P11TokenException {
byte[] resp = send(P11ProxyConstants.ACTION_GET_SERVER_CAPS, null);
Asn1ServerCaps caps;
try {
caps = Asn1ServerCaps.getInstance(resp);
} catch (BadAsn1ObjectException ex) {
throw new P11TokenException("response is a valid Asn1ServerCaps", ex);
}
if (!caps.getVersions().contains(version)) {
throw new P11TokenException("Server does not support any version supported by the client");
}
this.readOnly = caps.isReadOnly();
resp = send(P11ProxyConstants.ACTION_GET_SLOT_IDS, null);
ASN1Sequence seq;
try {
seq = ASN1Sequence.getInstance(resp);
} catch (IllegalArgumentException ex) {
throw new P11TokenException("response is not ASN1Sequence", ex);
}
final int n = seq.size();
Set<P11Slot> slots = new HashSet<>();
for (int i = 0; i < n; i++) {
Asn1P11SlotIdentifier asn1SlotId;
try {
ASN1Encodable obj = seq.getObjectAt(i);
asn1SlotId = Asn1P11SlotIdentifier.getInstance(obj);
} catch (Exception ex) {
throw new P11TokenException(ex.getMessage(), ex);
}
P11SlotIdentifier slotId = asn1SlotId.getSlotId();
if (!conf.isSlotIncluded(slotId)) {
continue;
}
if (!conf.isSlotIncluded(slotId)) {
LOG.info("skipped slot {}", slotId);
continue;
}
P11Slot slot = new ProxyP11Slot(this, slotId, conf.isReadOnly(), conf.getP11MechanismFilter());
slots.add(slot);
}
setSlots(slots);
}
use of org.xipki.security.pkcs11.P11Slot in project xipki by xipki.
the class P11CertUpdateCmd method execute0.
@Override
protected Object execute0() throws Exception {
P11Slot slot = getSlot();
P11ObjectIdentifier objIdentifier = getObjectIdentifier();
X509Certificate newCert = X509Util.parseCert(certFile);
slot.updateCertificate(objIdentifier, newCert);
println("updated certificate");
return null;
}
Aggregations