public class TpmBackEndFile extends TpmBackEnd
| Modifier and Type | Class and Description |
|---|---|
static class |
TpmBackEndFile.Error
A TpmBackEndFile.Error extends TpmBackEnd.Error and represents a
non-semantic error in backend TPM file processing.
|
| Constructor and Description |
|---|
TpmBackEndFile()
Create a TpmBackEndFile to store files in the default location
HOME/.ndn/ndnsec-key-file where HOME is System.getProperty("user.home").
|
TpmBackEndFile(String locationPath)
Create a TpmBackEndFile to use the given path to store files.
|
| Modifier and Type | Method and Description |
|---|---|
protected TpmKeyHandle |
doCreateKey(Name identityName,
KeyParams params)
Create a key for identityName according to params.
|
protected void |
doDeleteKey(Name keyName)
Delete the key with name keyName.
|
protected Blob |
doExportKey(Name keyName,
ByteBuffer password)
Get the encoded private key with name keyName in PKCS #8 format, possibly
password-encrypted.
|
protected TpmKeyHandle |
doGetKeyHandle(Name keyName)
Get the handle of the key with name keyName.
|
protected boolean |
doHasKey(Name keyName)
Check if the key with name keyName exists in the TPM.
|
protected void |
doImportKey(Name keyName,
ByteBuffer pkcs8,
ByteBuffer password)
Import an encoded private key with name keyName in PKCS #8 format, possibly
password-encrypted.
|
static String |
getDefaultDirecoryPath(File filesRoot)
Get the default directory path for private keys based on the files root.
|
static String |
getDefaultDirecoryPath(String filesRoot)
Get the default directory path for private keys based on the files root.
|
static String |
getScheme() |
createKey, deleteKey, exportKey, getKeyHandle, hasKey, importKey, isTerminalMode, isTpmLocked, setKeyName, setTerminalMode, unlockTpmpublic TpmBackEndFile()
public TpmBackEndFile(String locationPath)
locationPath - The full path of the directory to store private keys.
This creates the directory if it doesn't exist.
If locationPath is empty, then store private key files in the default location
HOME/.ndn/ndnsec-key-file where HOME is System.getProperty("user.home").
Note that on Android there is no HOME and you must supply the locationPath.
For example, you can get the default directory path from an Android files
directory with getDefaultDirecoryPath(context.getFilesDir()) .public static String getDefaultDirecoryPath(File filesRoot)
filesRoot - The root file directory. An Android app can use
context.getFilesDir()public static String getDefaultDirecoryPath(String filesRoot)
filesRoot - The root file directory.public static String getScheme()
protected boolean doHasKey(Name keyName) throws TpmBackEnd.Error
doHasKey in class TpmBackEndkeyName - The name of the key.TpmBackEnd.Errorprotected TpmKeyHandle doGetKeyHandle(Name keyName) throws TpmBackEnd.Error
doGetKeyHandle in class TpmBackEndkeyName - The name of the key.TpmBackEnd.Errorprotected TpmKeyHandle doCreateKey(Name identityName, KeyParams params) throws TpmBackEnd.Error
doCreateKey in class TpmBackEndidentityName - The name if the identity.params - The KeyParams for creating the key.TpmBackEnd.Error - if the key cannot be created.protected void doDeleteKey(Name keyName) throws TpmBackEnd.Error
doDeleteKey in class TpmBackEndkeyName - The name of the key to delete.TpmBackEnd.Error - if the deletion fails.protected Blob doExportKey(Name keyName, ByteBuffer password) throws TpmBackEnd.Error
doExportKey in class TpmBackEndkeyName - 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.protected void doImportKey(Name keyName, ByteBuffer pkcs8, ByteBuffer password) throws TpmBackEnd.Error
doImportKey in class TpmBackEndkeyName - 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 - for an error importing the key.Copyright © 2019. All rights reserved.