public abstract class P11Slot extends Object implements Closeable
| Modifier and Type | Class and Description |
|---|---|
static class |
P11Slot.P11KeyUsage |
static class |
P11Slot.P11NewKeyControl |
static class |
P11Slot.P11NewObjectControl |
| Modifier and Type | Field and Description |
|---|---|
protected List<Long> |
keyPairTypes |
protected String |
moduleName |
protected P11ModuleConf.P11NewObjectConf |
newObjectConf |
protected List<Long> |
secretKeyTypes |
protected P11SlotId |
slotId |
| Modifier | Constructor and Description |
|---|---|
protected |
P11Slot(String moduleName,
P11SlotId slotId,
boolean readOnly,
List<Long> secretKeyTypes,
List<Long> keyPairTypes,
P11ModuleConf.P11NewObjectConf newObjectConf) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertMechanismSupported(long mechanism) |
protected void |
assertNoObjects(byte[] id,
String label) |
protected void |
assertWritable(String operationName) |
abstract void |
close() |
protected static byte[] |
decodeHex(String hex)
Returns the hex representation of the bytes.
|
abstract int |
destroyAllObjects()
!!!DANGEROUS OPERATION!!! Destroys all objects.
|
abstract long[] |
destroyObjectsByHandle(long... handles)
Destroys objects.
|
int |
destroyObjectsById(byte[] id)
Remove objects.
|
abstract int |
destroyObjectsByIdLabel(byte[] id,
String label)
Remove objects.
|
int |
destroyObjectsByLabel(String label)
Remove objects.
|
protected abstract P11IdentityId |
doGenerateDSAKeypair(BigInteger p,
BigInteger q,
BigInteger g,
P11Slot.P11NewKeyControl control)
Generates a DSA keypair on-the-fly.
|
protected abstract P11IdentityId |
doGenerateECEdwardsKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId,
P11Slot.P11NewKeyControl control)
Generates an EC Edwards keypair.
|
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
doGenerateECEdwardsKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId)
Generates an EC Edwards keypair on-the-fly.
|
protected abstract P11IdentityId |
doGenerateECKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId,
P11Slot.P11NewKeyControl control)
Generates an EC keypair.
|
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
doGenerateECKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId)
Generates an EC keypair over-the-air.
|
protected abstract P11IdentityId |
doGenerateECMontgomeryKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId,
P11Slot.P11NewKeyControl control)
Generates an EC Montgomery keypair.
|
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
doGenerateECMontgomeryKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId)
Generates an EC Montgomery keypair on-the-fly.
|
protected abstract P11IdentityId |
doGenerateRSAKeypair(int keysize,
BigInteger publicExponent,
P11Slot.P11NewKeyControl control)
Generates an RSA keypair.
|
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
doGenerateRSAKeypairOtf(int keysize,
BigInteger publicExponent) |
protected abstract P11IdentityId |
doGenerateSecretKey(long keyType,
Integer keysize,
P11Slot.P11NewKeyControl control)
Generates a secret key in the PKCS#11 token.
|
protected abstract P11IdentityId |
doGenerateSM2Keypair(P11Slot.P11NewKeyControl control)
Generates an SM2p256v1 keypair.
|
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
doGenerateSM2KeypairOtf()
Generates an SM2p256v1 keypair on-the-fly.
|
protected abstract P11IdentityId |
doImportSecretKey(long keyType,
byte[] keyValue,
P11Slot.P11NewKeyControl control)
Imports secret key object in the PKCS#11 token.
|
protected static String |
formatNumber(int value,
int numChars) |
P11IdentityId |
generateDSAKeypair(BigInteger p,
BigInteger q,
BigInteger g,
P11Slot.P11NewKeyControl control)
Generates a DSA keypair.
|
P11IdentityId |
generateDSAKeypair(int plength,
int qlength,
P11Slot.P11NewKeyControl control)
Generates a DSA keypair.
|
org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
generateDSAKeypairOtf(BigInteger p,
BigInteger q,
BigInteger g)
Generates a DSA keypair on-the-fly.
|
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
generateDSAKeypairOtf0(BigInteger p,
BigInteger q,
BigInteger g) |
P11IdentityId |
generateECKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOid,
P11Slot.P11NewKeyControl control)
Generates an EC keypair.
|
org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
generateECKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOid)
Generates an EC keypair on-the-fly.
|
P11IdentityId |
generateRSAKeypair(int keysize,
BigInteger publicExponent,
P11Slot.P11NewKeyControl control)
Generates an RSA keypair.
|
org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
generateRSAKeypairOtf(int keysize,
BigInteger publicExponent)
Generates an RSA keypair on the fly.
|
P11IdentityId |
generateSecretKey(long keyType,
Integer keysize,
P11Slot.P11NewKeyControl control)
Generates a secret key in the PKCS#11 token.
|
P11IdentityId |
generateSM2Keypair(P11Slot.P11NewKeyControl control)
Generates an SM2 keypair.
|
org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
generateSM2KeypairOtf()
Generates an SM2 keypair on the fly.
|
protected static String |
getDescription(byte[] keyId,
String keyLabel) |
P11Identity |
getIdentity(byte[] keyId,
String keyLabel) |
abstract P11Identity |
getIdentity(P11IdentityId identityId) |
abstract P11IdentityId |
getIdentityId(byte[] keyId,
String keyLabel) |
Set<Long> |
getMechanisms() |
String |
getModuleName() |
protected abstract PublicKey |
getPublicKey(P11Identity identity) |
P11SlotId |
getSlotId() |
protected static String |
hex(byte[] bytes)
Returns the hex representation of the bytes.
|
P11IdentityId |
importSecretKey(long keyType,
byte[] keyValue,
P11Slot.P11NewKeyControl control)
Imports secret key object in the PKCS#11 token.
|
protected void |
initMechanisms(long[] supportedMechanisms,
P11ModuleConf.P11MechanismFilter mechanismFilter) |
boolean |
isReadOnly() |
abstract boolean |
objectExistsByIdLabel(byte[] id,
String label) |
protected void |
printSupportedMechanism(OutputStream stream) |
abstract void |
showDetails(OutputStream stream,
boolean verbose)
Writes the token details to the given
stream. |
boolean |
supportsMechanism(long mechanism) |
protected final String moduleName
protected final P11SlotId slotId
protected final P11ModuleConf.P11NewObjectConf newObjectConf
protected static String hex(byte[] bytes)
bytes - Data to be encoded. Must not be null.protected static byte[] decodeHex(String hex)
hex - Data to be decoded. Must not be null.public abstract P11IdentityId getIdentityId(byte[] keyId, String keyLabel) throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionpublic abstract P11Identity getIdentity(P11IdentityId identityId) throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionpublic P11Identity getIdentity(byte[] keyId, String keyLabel) throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionprotected abstract PublicKey getPublicKey(P11Identity identity) throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionpublic abstract long[] destroyObjectsByHandle(long... handles)
handles - handles of objects to be destroyed.public abstract int destroyAllObjects()
public abstract int destroyObjectsByIdLabel(byte[] id,
String label)
throws org.xipki.pkcs11.wrapper.TokenException
id - ID of the objects to be deleted. At least one of id and label may not be null.label - Label of the objects to be deletedorg.xipki.pkcs11.wrapper.TokenException - If PKCS#11 error happens.public abstract boolean objectExistsByIdLabel(byte[] id,
String label)
throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionprotected abstract P11IdentityId doGenerateSecretKey(long keyType, Integer keysize, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
keyType - key typekeysize - key sizecontrol - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract P11IdentityId doImportSecretKey(long keyType, byte[] keyValue, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
keyType - key type.keyValue - Key value. Must not be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract P11IdentityId doGenerateDSAKeypair(BigInteger p, BigInteger q, BigInteger g, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
p - p of DSA. Must not be null.q - q of DSA. Must not be null.g - g of DSA. Must not be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract P11IdentityId doGenerateECEdwardsKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
curveId - Object Identifier of the curve. Must not be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateECEdwardsKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId)
throws org.xipki.pkcs11.wrapper.TokenException
curveId - Object Identifier of the curve. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract P11IdentityId doGenerateECMontgomeryKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
curveId - Object Identifier of the curve. Must not be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateECMontgomeryKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId)
throws org.xipki.pkcs11.wrapper.TokenException
curveId - Object Identifier of the curve. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract P11IdentityId doGenerateECKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
curveId - Object identifier of the EC curve. Must not be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateECKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId)
throws org.xipki.pkcs11.wrapper.TokenException
curveId - Object identifier of the EC curve. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract P11IdentityId doGenerateSM2Keypair(P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateSM2KeypairOtf()
throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract P11IdentityId doGenerateRSAKeypair(int keysize, BigInteger publicExponent, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
keysize - key size in bitpublicExponent - RSA public exponent. Could be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.public abstract void showDetails(OutputStream stream, boolean verbose) throws IOException
stream.stream - Output stream. Must not be null.verbose - Whether to show the details verbosely.IOException - if IO error occurs.public abstract void close()
close in interface Closeableclose in interface AutoCloseableprotected void initMechanisms(long[] supportedMechanisms,
P11ModuleConf.P11MechanismFilter mechanismFilter)
public boolean supportsMechanism(long mechanism)
public void assertMechanismSupported(long mechanism)
throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionpublic String getModuleName()
public P11SlotId getSlotId()
public boolean isReadOnly()
protected void assertNoObjects(byte[] id,
String label)
throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionpublic int destroyObjectsById(byte[] id)
throws org.xipki.pkcs11.wrapper.TokenException
id - ID of the objects to be deleted.org.xipki.pkcs11.wrapper.TokenException - If PKCS#11 error happens.public int destroyObjectsByLabel(String label) throws org.xipki.pkcs11.wrapper.TokenException
label - Label of the objects to be deletedorg.xipki.pkcs11.wrapper.TokenException - If PKCS#11 error happens.public P11IdentityId generateSecretKey(long keyType, Integer keysize, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
keyType - Key typekeysize - Key size in bitcontrol - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.public P11IdentityId importSecretKey(long keyType, byte[] keyValue, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
keyType - Key typekeyValue - Key value. Must not be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.public org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateRSAKeypairOtf(int keysize,
BigInteger publicExponent)
throws org.xipki.pkcs11.wrapper.TokenException
keysize - key size in bitpublicExponent - RSA public exponent. Could be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateRSAKeypairOtf(int keysize,
BigInteger publicExponent)
throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionpublic P11IdentityId generateRSAKeypair(int keysize, BigInteger publicExponent, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
keysize - key size in bitpublicExponent - RSA public exponent. Could be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.public org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateDSAKeypairOtf(BigInteger p, BigInteger q, BigInteger g) throws org.xipki.pkcs11.wrapper.TokenException
p - p of DSA. Must not be null.q - q of DSA. Must not be null.g - g of DSA. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateDSAKeypairOtf0(BigInteger p, BigInteger q, BigInteger g) throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionpublic P11IdentityId generateDSAKeypair(int plength, int qlength, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
plength - bit length of Pqlength - bit length of Qcontrol - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.public P11IdentityId generateDSAKeypair(BigInteger p, BigInteger q, BigInteger g, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
p - p of DSA. Must not be null.q - q of DSA. Must not be null.g - g of DSA. Must not be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.public org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateECKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOid)
throws org.xipki.pkcs11.wrapper.TokenException
curveOid - Object identifier of the EC curve. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.public P11IdentityId generateECKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOid, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
curveOid - Object identifier of the EC curve. Must not be null.control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.public org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateSM2KeypairOtf()
throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.public P11IdentityId generateSM2Keypair(P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
control - Control of the key generation process. Must not be null.org.xipki.pkcs11.wrapper.TokenException - if PKCS#11 token exception occurs.protected void printSupportedMechanism(OutputStream stream) throws IOException
IOExceptionprotected void assertWritable(String operationName) throws org.xipki.pkcs11.wrapper.TokenException
org.xipki.pkcs11.wrapper.TokenExceptionprotected static String formatNumber(int value, int numChars)
Copyright © 2023. All rights reserved.