public class Tpm extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Tpm.Error
A Tpm.Error extends Exception and represents a semantic error in TPM
processing.
|
| Constructor and Description |
|---|
Tpm(String scheme,
String location,
TpmBackEnd backEnd) |
| Modifier and Type | Method and Description |
|---|---|
Name |
createKey_(Name identityName,
KeyParams params)
Create a key for the identityName according to params.
|
Blob |
decrypt(ByteBuffer cipherText,
Name keyName)
Return the plain text which is decrypted from cipherText using the key
with name keyName.
|
void |
deleteKey_(Name keyName)
Delete the key with name keyName.
|
Blob |
exportPrivateKey_(Name keyName,
ByteBuffer password)
Get the encoded private key with name keyName in PKCS #8 format, possibly
encrypted.
|
TpmBackEnd |
getBackEnd_()
Get the TpmBackEnd.
|
Blob |
getPublicKey(Name keyName)
Get the public portion of an asymmetric key pair with name keyName.
|
String |
getTpmLocator() |
boolean |
hasKey(Name keyName)
Check if the key with name keyName exists in the TPM.
|
void |
importPrivateKey_(Name keyName,
ByteBuffer pkcs8,
ByteBuffer password)
Import an encoded private key with name keyName in PKCS #8 format, possibly
password-encrypted.
|
boolean |
isTerminalMode()
Check if the TPM is in terminal mode.
|
boolean |
isTpmLocked()
Check if the TPM is locked.
|
void |
setTerminalMode(boolean isTerminal)
Set the terminal mode of the TPM.
|
Blob |
sign(ByteBuffer data,
Name keyName,
DigestAlgorithm digestAlgorithm)
Compute a digital signature from the byte buffer using the key with name
keyName.
|
boolean |
unlockTpm(ByteBuffer password)
Unlock the TPM.
|
public Tpm(String scheme, String location, TpmBackEnd backEnd)
public String getTpmLocator()
public final boolean hasKey(Name keyName) throws TpmBackEnd.Error
keyName - The name of the key.TpmBackEnd.Errorpublic final Blob getPublicKey(Name keyName) throws TpmBackEnd.Error
keyName - The name of the key.TpmBackEnd.Errorpublic final Blob sign(ByteBuffer data, Name keyName, DigestAlgorithm digestAlgorithm) throws TpmBackEnd.Error
data - The input byte buffer.keyName - The name of the key.digestAlgorithm - The digest algorithm for the signature.TpmBackEnd.Errorpublic final Blob decrypt(ByteBuffer cipherText, Name keyName) throws TpmBackEnd.Error
cipherText - The cipher text byte buffer.keyName - The name of the key.TpmBackEnd.Errorpublic final boolean isTerminalMode()
throws TpmBackEnd.Error
TpmBackEnd.Errorpublic final void setTerminalMode(boolean isTerminal)
throws TpmBackEnd.Error
isTerminal - True to enable terminal mode.TpmBackEnd.Errorpublic final boolean isTpmLocked()
throws TpmBackEnd.Error
TpmBackEnd.Errorpublic final boolean unlockTpm(ByteBuffer password) throws TpmBackEnd.Error
password - The password to unlock TPM.TpmBackEnd.Errorpublic final TpmBackEnd getBackEnd_()
public final Name createKey_(Name identityName, KeyParams params) throws Tpm.Error, TpmBackEnd.Error
identityName - The name if the identity.params - The KeyParams for creating the key.Tpm.Error - if params is invalid or the key type is unsupported.TpmBackEnd.Error - if the key already exists or cannot be created.public final void deleteKey_(Name keyName) throws TpmBackEnd.Error
TpmBackEnd.Error - if the deletion fails.public final Blob exportPrivateKey_(Name keyName, ByteBuffer password) throws TpmBackEnd.Error
keyName - The name of the key in the TPM.password - The password for encrypting the private key, which should
have characters in the range of 1 to 127. If the password is supplied, use
it to return a PKCS #8 EncryptedPrivateKeyInfo. If the password is null,
return an unencrypted PKCS #8 PrivateKeyInfo.TpmBackEnd.Error - if the key does not exist or if the key cannot be
exported, e.g., insufficient privileges.public final void importPrivateKey_(Name keyName, ByteBuffer pkcs8, ByteBuffer password) throws TpmBackEnd.Error
keyName - The name of the key to use in the TPM.pkcs8 - The input byte buffer. If the password is supplied, this is a
PKCS #8 EncryptedPrivateKeyInfo. If the password is null, this is an
unencrypted PKCS #8 PrivateKeyInfo.password - The password for decrypting the private key, which should
have characters in the range of 1 to 127. If the password is supplied, use
it to decrypt the PKCS #8 EncryptedPrivateKeyInfo. If the password is null,
import an unencrypted PKCS #8 PrivateKeyInfo.TpmBackEnd.Error - if the key cannot be imported.Copyright © 2019. All rights reserved.