Package org.xipki.security.pkcs11
Class P11Slot
- java.lang.Object
-
- org.xipki.security.pkcs11.P11Slot
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public abstract class P11Slot extends Object implements Closeable
PKCS#11 slot.- Since:
- 2.0.0
- Author:
- Lijun Liao (xipki)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classP11Slot.P11KeyUsagestatic classP11Slot.P11NewKeyControlstatic classP11Slot.P11NewObjectControl
-
Field Summary
Fields Modifier and Type Field Description protected List<Long>keyPairTypesprotected StringmoduleNameprotected P11ModuleConf.P11NewObjectConfnewObjectConfprotected List<Long>secretKeyTypesprotected P11SlotIdslotId
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidassertMechanismSupported(long mechanism, long flagBit)protected voidassertNoObjects(byte[] id, String label)protected voidassertWritable(String operationName)abstract voidclose()protected static byte[]decodeHex(String hex)Returns the hex representation of the bytes.abstract intdestroyAllObjects()!!!DANGEROUS OPERATION!!! Destroys all objects.abstract long[]destroyObjectsByHandle(long... handles)Destroys objects.intdestroyObjectsById(byte[] id)Remove objects.abstract intdestroyObjectsByIdLabel(byte[] id, String label)Remove objects.intdestroyObjectsByLabel(String label)Remove objects.protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyIddoGenerateDSAKeypair(BigInteger p, BigInteger q, BigInteger g, P11Slot.P11NewKeyControl control)Generates a DSA keypair on-the-fly.protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyIddoGenerateECEdwardsKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId, P11Slot.P11NewKeyControl control)Generates an EC Edwards keypair.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfodoGenerateECEdwardsKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId)Generates an EC Edwards keypair on-the-fly.protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyIddoGenerateECKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId, P11Slot.P11NewKeyControl control)Generates an EC keypair.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfodoGenerateECKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId)Generates an EC keypair over-the-air.protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyIddoGenerateECMontgomeryKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId, P11Slot.P11NewKeyControl control)Generates an EC Montgomery keypair.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfodoGenerateECMontgomeryKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId)Generates an EC Montgomery keypair on-the-fly.protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyIddoGenerateRSAKeypair(int keysize, BigInteger publicExponent, P11Slot.P11NewKeyControl control)Generates an RSA keypair.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfodoGenerateRSAKeypairOtf(int keysize, BigInteger publicExponent)protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyIddoGenerateSecretKey(long keyType, Integer keysize, P11Slot.P11NewKeyControl control)Generates a secret key in the PKCS#11 token.protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyIddoGenerateSM2Keypair(P11Slot.P11NewKeyControl control)Generates an SM2p256v1 keypair.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfodoGenerateSM2KeypairOtf()Generates an SM2p256v1 keypair on-the-fly.protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyIddoImportSecretKey(long keyType, byte[] keyValue, P11Slot.P11NewKeyControl control)Imports secret key object in the PKCS#11 token.protected static StringformatNumber(int value, int numChars)org.xipki.pkcs11.wrapper.PKCS11KeyIdgenerateDSAKeypair(int plength, int qlength, P11Slot.P11NewKeyControl control)Generates a DSA keypair.org.xipki.pkcs11.wrapper.PKCS11KeyIdgenerateDSAKeypair(BigInteger p, BigInteger q, BigInteger g, P11Slot.P11NewKeyControl control)Generates a DSA keypair.org.bouncycastle.asn1.pkcs.PrivateKeyInfogenerateDSAKeypairOtf(BigInteger p, BigInteger q, BigInteger g)Generates a DSA keypair on-the-fly.protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfogenerateDSAKeypairOtf0(BigInteger p, BigInteger q, BigInteger g)org.xipki.pkcs11.wrapper.PKCS11KeyIdgenerateECKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOid, P11Slot.P11NewKeyControl control)Generates an EC keypair.org.bouncycastle.asn1.pkcs.PrivateKeyInfogenerateECKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOid)Generates an EC keypair on-the-fly.org.xipki.pkcs11.wrapper.PKCS11KeyIdgenerateRSAKeypair(int keysize, BigInteger publicExponent, P11Slot.P11NewKeyControl control)Generates an RSA keypair.org.bouncycastle.asn1.pkcs.PrivateKeyInfogenerateRSAKeypairOtf(int keysize, BigInteger publicExponent)Generates an RSA keypair on the fly.org.xipki.pkcs11.wrapper.PKCS11KeyIdgenerateSecretKey(long keyType, Integer keysize, P11Slot.P11NewKeyControl control)Generates a secret key in the PKCS#11 token.org.xipki.pkcs11.wrapper.PKCS11KeyIdgenerateSM2Keypair(P11Slot.P11NewKeyControl control)Generates an SM2 keypair.org.bouncycastle.asn1.pkcs.PrivateKeyInfogenerateSM2KeypairOtf()Generates an SM2 keypair on the fly.protected static StringgetDescription(byte[] keyId, String keyLabel)abstract P11KeygetKey(byte[] keyId, String keyLabel)abstract P11KeygetKey(org.xipki.pkcs11.wrapper.PKCS11KeyId keyId)abstract org.xipki.pkcs11.wrapper.PKCS11KeyIdgetKeyId(byte[] keyId, String keyLabel)Map<Long,org.xipki.pkcs11.wrapper.MechanismInfo>getMechanisms()StringgetModuleName()protected abstract PublicKeygetPublicKey(P11Key key)P11SlotIdgetSlotId()protected static Stringhex(byte[] bytes)Returns the hex representation of the bytes.org.xipki.pkcs11.wrapper.PKCS11KeyIdimportSecretKey(long keyType, byte[] keyValue, P11Slot.P11NewKeyControl control)Imports secret key object in the PKCS#11 token.protected voidinitMechanisms(Map<Long,org.xipki.pkcs11.wrapper.MechanismInfo> supportedMechanisms, P11ModuleConf.P11MechanismFilter mechanismFilter)booleanisReadOnly()abstract booleanobjectExistsByIdLabel(byte[] id, String label)protected voidprintSupportedMechanism(OutputStream stream)abstract voidshowDetails(OutputStream stream, Long objectHandle, boolean verbose)Writes the token details to the givenstream.booleansupportsMechanism(long mechanism, long flagBit)
-
-
-
Method Detail
-
hex
protected static String hex(byte[] bytes)
Returns the hex representation of the bytes.- Parameters:
bytes- Data to be encoded. Must not benull.- Returns:
- the hex representation of the bytes.
-
decodeHex
protected static byte[] decodeHex(String hex)
Returns the hex representation of the bytes.- Parameters:
hex- Data to be decoded. Must not benull.- Returns:
- the hex representation of the bytes.
-
getKeyId
public abstract org.xipki.pkcs11.wrapper.PKCS11KeyId getKeyId(byte[] keyId, String keyLabel) throws org.xipki.pkcs11.wrapper.TokenException- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
getKey
public abstract P11Key getKey(org.xipki.pkcs11.wrapper.PKCS11KeyId keyId) throws org.xipki.pkcs11.wrapper.TokenException
- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
getKey
public abstract P11Key getKey(byte[] keyId, String keyLabel) throws org.xipki.pkcs11.wrapper.TokenException
- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
getPublicKey
protected abstract PublicKey getPublicKey(P11Key key) throws org.xipki.pkcs11.wrapper.TokenException
- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
destroyObjectsByHandle
public abstract long[] destroyObjectsByHandle(long... handles)
Destroys objects.- Parameters:
handles- handles of objects to be destroyed.- Returns:
- handles of objects which could not been destroyed.
-
destroyAllObjects
public abstract int destroyAllObjects()
!!!DANGEROUS OPERATION!!! Destroys all objects.- Returns:
- number of destroyed objects.
-
destroyObjectsByIdLabel
public abstract int destroyObjectsByIdLabel(byte[] id, String label) throws org.xipki.pkcs11.wrapper.TokenExceptionRemove objects.- Parameters:
id- ID of the objects to be deleted. At least one of id and label may not benull.label- Label of the objects to be deleted- Returns:
- how many objects have been deleted
- Throws:
org.xipki.pkcs11.wrapper.TokenException- If PKCS#11 error happens.
-
objectExistsByIdLabel
public abstract boolean objectExistsByIdLabel(byte[] id, String label) throws org.xipki.pkcs11.wrapper.TokenException- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
doGenerateSecretKey
protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyId doGenerateSecretKey(long keyType, Integer keysize, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates a secret key in the PKCS#11 token.- Parameters:
keyType- key typekeysize- key sizecontrol- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doImportSecretKey
protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyId doImportSecretKey(long keyType, byte[] keyValue, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionImports secret key object in the PKCS#11 token. The key itself will not be generated within the PKCS#11 token.- Parameters:
keyType- key type.keyValue- Key value. Must not benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateDSAKeypair
protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyId doGenerateDSAKeypair(BigInteger p, BigInteger q, BigInteger g, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
Generates a DSA keypair on-the-fly.- Parameters:
p- p of DSA. Must not benull.q- q of DSA. Must not benull.g- g of DSA. Must not benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateECEdwardsKeypair
protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyId doGenerateECEdwardsKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an EC Edwards keypair.- Parameters:
curveId- Object Identifier of the curve. Must not benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateECEdwardsKeypairOtf
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateECEdwardsKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an EC Edwards keypair on-the-fly.- Parameters:
curveId- Object Identifier of the curve. Must not benull.- Returns:
- the ASN.1 keypair.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateECMontgomeryKeypair
protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyId doGenerateECMontgomeryKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an EC Montgomery keypair.- Parameters:
curveId- Object Identifier of the curve. Must not benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateECMontgomeryKeypairOtf
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateECMontgomeryKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an EC Montgomery keypair on-the-fly.- Parameters:
curveId- Object Identifier of the curve. Must not benull.- Returns:
- the ASN.1 keypair.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateECKeypair
protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyId doGenerateECKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an EC keypair.- Parameters:
curveId- Object identifier of the EC curve. Must not benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateECKeypairOtf
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateECKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveId) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an EC keypair over-the-air.- Parameters:
curveId- Object identifier of the EC curve. Must not benull.- Returns:
- the ASN.1 encoded keypair.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateSM2Keypair
protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyId doGenerateSM2Keypair(P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
Generates an SM2p256v1 keypair.- Parameters:
control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateSM2KeypairOtf
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateSM2KeypairOtf() throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an SM2p256v1 keypair on-the-fly.- Returns:
- the ASN.1 encoded keypair.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateRSAKeypair
protected abstract org.xipki.pkcs11.wrapper.PKCS11KeyId doGenerateRSAKeypair(int keysize, BigInteger publicExponent, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an RSA keypair.- Parameters:
keysize- key size in bitpublicExponent- RSA public exponent. Could benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
showDetails
public abstract void showDetails(OutputStream stream, Long objectHandle, boolean verbose) throws IOException
Writes the token details to the givenstream.- Parameters:
stream- Output stream. Must not benull.verbose- Whether to show the details verbosely.objectHandle- If present, only details of this object will be shown.- Throws:
IOException- if IO error occurs.
-
close
public abstract void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
initMechanisms
protected void initMechanisms(Map<Long,org.xipki.pkcs11.wrapper.MechanismInfo> supportedMechanisms, P11ModuleConf.P11MechanismFilter mechanismFilter)
-
supportsMechanism
public boolean supportsMechanism(long mechanism, long flagBit)
-
assertMechanismSupported
public void assertMechanismSupported(long mechanism, long flagBit) throws org.xipki.pkcs11.wrapper.TokenException- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
getModuleName
public String getModuleName()
-
getSlotId
public P11SlotId getSlotId()
-
isReadOnly
public boolean isReadOnly()
-
assertNoObjects
protected void assertNoObjects(byte[] id, String label) throws org.xipki.pkcs11.wrapper.TokenException- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
destroyObjectsById
public int destroyObjectsById(byte[] id) throws org.xipki.pkcs11.wrapper.TokenExceptionRemove objects.- Parameters:
id- ID of the objects to be deleted.- Returns:
- how many objects have been deleted
- Throws:
org.xipki.pkcs11.wrapper.TokenException- If PKCS#11 error happens.
-
destroyObjectsByLabel
public int destroyObjectsByLabel(String label) throws org.xipki.pkcs11.wrapper.TokenException
Remove objects.- Parameters:
label- Label of the objects to be deleted- Returns:
- how many objects have been deleted
- Throws:
org.xipki.pkcs11.wrapper.TokenException- If PKCS#11 error happens.
-
generateSecretKey
public org.xipki.pkcs11.wrapper.PKCS11KeyId generateSecretKey(long keyType, Integer keysize, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates a secret key in the PKCS#11 token.- Parameters:
keyType- Key typekeysize- Key size in bitcontrol- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
importSecretKey
public org.xipki.pkcs11.wrapper.PKCS11KeyId importSecretKey(long keyType, byte[] keyValue, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionImports secret key object in the PKCS#11 token. The key itself will not be generated within the PKCS#11 token.- Parameters:
keyType- Key typekeyValue- Key value. Must not benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
generateRSAKeypairOtf
public org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateRSAKeypairOtf(int keysize, BigInteger publicExponent) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an RSA keypair on the fly.- Parameters:
keysize- key size in bitpublicExponent- RSA public exponent. Could benull.- Returns:
- the ASN.1 keypair.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
doGenerateRSAKeypairOtf
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo doGenerateRSAKeypairOtf(int keysize, BigInteger publicExponent) throws org.xipki.pkcs11.wrapper.TokenException- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
generateRSAKeypair
public org.xipki.pkcs11.wrapper.PKCS11KeyId generateRSAKeypair(int keysize, BigInteger publicExponent, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an RSA keypair.- Parameters:
keysize- key size in bitpublicExponent- RSA public exponent. Could benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
generateDSAKeypairOtf
public org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateDSAKeypairOtf(BigInteger p, BigInteger q, BigInteger g) throws org.xipki.pkcs11.wrapper.TokenException
Generates a DSA keypair on-the-fly.- Parameters:
p- p of DSA. Must not benull.q- q of DSA. Must not benull.g- g of DSA. Must not benull.- Returns:
- the ASN.1 keypair.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
generateDSAKeypairOtf0
protected abstract org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateDSAKeypairOtf0(BigInteger p, BigInteger q, BigInteger g) throws org.xipki.pkcs11.wrapper.TokenException
- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
generateDSAKeypair
public org.xipki.pkcs11.wrapper.PKCS11KeyId generateDSAKeypair(int plength, int qlength, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates a DSA keypair.- Parameters:
plength- bit length of Pqlength- bit length of Qcontrol- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
generateDSAKeypair
public org.xipki.pkcs11.wrapper.PKCS11KeyId generateDSAKeypair(BigInteger p, BigInteger q, BigInteger g, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
Generates a DSA keypair.- Parameters:
p- p of DSA. Must not benull.q- q of DSA. Must not benull.g- g of DSA. Must not benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
generateECKeypairOtf
public org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateECKeypairOtf(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOid) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an EC keypair on-the-fly.- Parameters:
curveOid- Object identifier of the EC curve. Must not benull.- Returns:
- the ASN.1 keypair.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
generateECKeypair
public org.xipki.pkcs11.wrapper.PKCS11KeyId generateECKeypair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOid, P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an EC keypair.- Parameters:
curveOid- Object identifier of the EC curve. Must not benull.control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
generateSM2KeypairOtf
public org.bouncycastle.asn1.pkcs.PrivateKeyInfo generateSM2KeypairOtf() throws org.xipki.pkcs11.wrapper.TokenExceptionGenerates an SM2 keypair on the fly.- Returns:
- the ASN.1 keypair.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
generateSM2Keypair
public org.xipki.pkcs11.wrapper.PKCS11KeyId generateSM2Keypair(P11Slot.P11NewKeyControl control) throws org.xipki.pkcs11.wrapper.TokenException
Generates an SM2 keypair.- Parameters:
control- Control of the key generation process. Must not benull.- Returns:
- the identifier of the key within the PKCS#P11 token.
- Throws:
org.xipki.pkcs11.wrapper.TokenException- if PKCS#11 token exception occurs.
-
printSupportedMechanism
protected void printSupportedMechanism(OutputStream stream) throws IOException
- Throws:
IOException
-
assertWritable
protected void assertWritable(String operationName) throws org.xipki.pkcs11.wrapper.TokenException
- Throws:
org.xipki.pkcs11.wrapper.TokenException
-
formatNumber
protected static String formatNumber(int value, int numChars)
-
-