public class FilePrivateKeyStorage extends PrivateKeyStorage
| Constructor and Description |
|---|
FilePrivateKeyStorage()
Create a new FilePrivateKeyStorage to connect to the default directory in
System.getProperty("user.home").
|
FilePrivateKeyStorage(String keyStoreDirectoryPath)
Create a new FilePrivateKeyStorage to connect to the given directory.
|
| Modifier and Type | Method and Description |
|---|---|
Blob |
decrypt(Name keyName,
ByteBuffer data,
boolean isSymmetric)
Decrypt data.
|
void |
deleteKey(Name keyName)
Delete a key by name; checks all KeyClass types
|
void |
deleteKeyPair(Name keyName)
Delete a pair of asymmetric keys.
|
boolean |
doesKeyExist(Name keyName,
KeyClass keyClass)
Check if a particular key exists.
|
Blob |
encrypt(Name keyName,
ByteBuffer data,
boolean isSymmetric)
Encrypt data.
|
void |
generateKey(Name keyName,
KeyParams params)
Generate a symmetric key.
|
void |
generateKeyPair(Name keyName,
KeyParams params)
Generate a pair of asymmetric keys.
|
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.
|
PublicKey |
getPublicKey(Name keyName)
Get the public key
|
Blob |
sign(ByteBuffer data,
Name keyName,
DigestAlgorithm digestAlgorithm)
Fetch the private key for keyName and sign the data, returning a signature
Blob.
|
decrypt, encrypt, signpublic FilePrivateKeyStorage()
public FilePrivateKeyStorage(String keyStoreDirectoryPath)
keyStoreDirectoryPath - The full path of the directory holding the
private key data. This creates the directory if it doesn't exist.
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 final void generateKeyPair(Name keyName, KeyParams params) throws SecurityException
generateKeyPair in class PrivateKeyStoragekeyName - The name of the key pair.params - The parameters of the key.SecurityExceptionpublic void deleteKeyPair(Name keyName) throws SecurityException
deleteKeyPair in class PrivateKeyStoragekeyName - The name of the key pair.SecurityExceptionpublic final PublicKey getPublicKey(Name keyName) throws SecurityException
getPublicKey in class PrivateKeyStoragekeyName - The name of public key.SecurityExceptionpublic final Blob sign(ByteBuffer data, Name keyName, DigestAlgorithm digestAlgorithm) throws SecurityException
sign in class PrivateKeyStoragedata - Pointer the input byte buffer to sign.keyName - The name of the signing key.digestAlgorithm - the digest algorithm.SecurityExceptionpublic final Blob decrypt(Name keyName, ByteBuffer data, boolean isSymmetric) throws SecurityException
decrypt in class PrivateKeyStoragekeyName - The name of the decrypting key.data - The byte buffer to be decrypted, from its position to its
limit.isSymmetric - If true symmetric encryption is used, otherwise
asymmetric encryption is used.SecurityExceptionpublic final Blob encrypt(Name keyName, ByteBuffer data, boolean isSymmetric) throws SecurityException
encrypt in class PrivateKeyStoragekeyName - The name of the encrypting key.data - The byte buffer to be encrypted, from its position to its
limit.isSymmetric - If true symmetric encryption is used, otherwise
asymmetric encryption is used.SecurityExceptionpublic final void generateKey(Name keyName, KeyParams params) throws SecurityException
generateKey in class PrivateKeyStoragekeyName - The name of the key.params - The parameters of the key.SecurityExceptionpublic final void deleteKey(Name keyName) throws SecurityException
keyName - SecurityExceptionpublic final boolean doesKeyExist(Name keyName, KeyClass keyClass) throws SecurityException
doesKeyExist in class PrivateKeyStoragekeyName - The name of the key.keyClass - The class of the key, e.g. KeyClass.PUBLIC,
KeyClass.PRIVATE, or KeyClass.SYMMETRIC.SecurityExceptionCopyright © 2019. All rights reserved.