public class ExternalKeyStoreNatives extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
ENTRY_TYPE_CERTIFICATE
Certificate Entry Type.
|
static int |
ENTRY_TYPE_KEY
Key Entry Type.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
closeCertificateChainHandle(int handle)
Closes a handle to a certificate chain (opened with
getCertificateChainHandle(byte[])). |
static int |
closeKeyEntry(int handle)
Closes a key entry.
|
static boolean |
containsAlias(byte[] alias)
Returns whether the KeyStore contains the given alias or not.
|
static int |
deleteEntry(byte[] alias)
Delete an entry.
|
static int |
getAlias(int i,
byte[] alias)
Returns the alias at given index in the KeyStore.
|
static int |
getCertificateChainHandle(byte[] alias)
Returns a handle for the certificate chain loaded from
KeyStore with given alias. |
static int |
getCertificateChainLength(int handle)
Returns the length of the given certificate chain.
|
static void |
getCertificateData(int handle,
byte[] buffer)
Fills the given buffer with the encoded X509 certificate.
|
static int |
getCertificateFromChain(int handle,
int index)
Returns a handle for the certificate at given index from given certificate chain.
|
static int |
getCertificateHandle(byte[] alias)
Returns a handle for the certificate loaded from
KeyStore with given alias. |
static int |
getCertificateSize(int handle)
Returns the size of the encoded X509 certificate.
|
static int |
getEntryType(byte[] alias)
Get the entry type (certificate or key).
|
static void |
getKeyAlgorithm(int keyId,
byte[] algorithm)
Returns the algorithm of the key with the given ID.
|
static int |
getKeyId(byte[] alias,
char[] password)
Returns the ID of the key for the given alias.
|
static int |
getKeyType(int keyId)
Returns the type of the key with the given ID.
|
static int |
insertCertificateInChain(int handle,
int index,
byte[] certificate)
Insert a new certificate in the certificate chain associated to a given key entry.
|
static void |
login(char[] password)
Logs in to the KeyStore with the given password.
|
static int |
openKeyEntryWithData(byte[] alias,
byte[] key,
int chainLength)
Open a key entry with the key data.
|
static int |
openKeyEntryWithNativeId(byte[] alias,
int keyId,
char[] password,
int chainLength)
Open a key entry with a handle to a native key.
|
static int |
setCertificateEntry(byte[] alias,
byte[] certificate)
Set a new certificate entry.
|
static int |
size()
Returns the size of the KeyStore (the number of "objects": keys, certificates, certificate chains).
|
public static final int ENTRY_TYPE_CERTIFICATE
public static final int ENTRY_TYPE_KEY
public static int closeCertificateChainHandle(int handle)
getCertificateChainHandle(byte[])).handle - the handle of the certificate chaingetCertificateChainHandle(byte[])public static int closeKeyEntry(int handle)
handle - the handle to the key entry (returned by openKeyEntryWithNativeId(byte[], int, char[], int)
or openKeyEntryWithData(byte[], byte[], int)).public static boolean containsAlias(byte[] alias)
alias - the alias.public static int deleteEntry(byte[] alias)
alias - the alias of the entry.public static int getAlias(int i,
byte[] alias)
i - the key index, between 0 and size() (excluded).alias - the byte array in which the next alias will be stored.NativeConstants.SUCCESS if successful, NativeConstants.ERROR if no such element at this
index.public static int getCertificateChainHandle(byte[] alias)
KeyStore with given alias.alias - the alias of the certificate chain.getCertificateChainLength(int),
getCertificateFromChain(int, int),
closeCertificateChainHandle(int)public static int getCertificateChainLength(int handle)
handle - the handle of the certificate chain.getCertificateChainHandle(byte[])public static void getCertificateData(int handle,
byte[] buffer)
handle - the handle of the certificate.buffer - the buffer to fill.getCertificateHandle(byte[]),
getCertificateFromChain(int, int)public static int getCertificateFromChain(int handle,
int index)
handle - the handle of the certificate chainindex - the index of the certificate in the chain.getCertificateChainHandle(byte[])public static int getCertificateHandle(byte[] alias)
KeyStore with given alias.alias - the alias of the certificate.getCertificateSize(int),
getCertificateData(int, byte[])public static int getCertificateSize(int handle)
handle - the handle of the certificate.getCertificateHandle(byte[]),
getCertificateFromChain(int, int)public static int getEntryType(byte[] alias)
public static void getKeyAlgorithm(int keyId,
byte[] algorithm)
keyId - the ID of the key.algorithm - the buffer to use to fill in the algorithm name.getKeyId(byte[], char[])public static int getKeyId(byte[] alias,
@Nullable
char[] password)
The key will be "closed" using the close function associated with the key type.
alias - the alias of the key to get the ID from.password - the password to access the key (for authorization or integrity check).getKeyType(int),
getKeyAlgorithm(int, byte[])public static int getKeyType(int keyId)
keyId - the ID of the key.NativeConstants.KEY_TYPE_PRIVATE,
NativeConstants.KEY_TYPE_PUBLIC or NativeConstants.KEY_TYPE_SECRET.getKeyId(byte[], char[])public static int insertCertificateInChain(int handle,
int index,
byte[] certificate)
handle - the handle to the key entry (returned by openKeyEntryWithNativeId(byte[], int, char[], int)
or openKeyEntryWithData(byte[], byte[], int)).index - the index of the certificate in the chain.certificate - the X.509 encoded certificate.public static void login(@Nullable char[] password) throws IOException
password - the password to login in with.IOException - if login fails such as because no external keystore available or the password check failed.public static int openKeyEntryWithData(byte[] alias,
byte[] key,
int chainLength)
KeyStore.setKeyEntry(String, byte[], Certificate[]).alias - the alias of the key.key - the key (in protected format) to be associated with the alias.chainLength - the size of the certificate chain (number of certificates).insertCertificateInChain(int, int, byte[]),
closeKeyEntry(int)public static int openKeyEntryWithNativeId(byte[] alias,
int keyId,
char[] password,
int chainLength)
KeyStore.setKeyEntry(String, Key, char[], Certificate[]).alias - the alias of the key.keyId - the id of the native key.password - the password to protect the key.chainLength - the size of the certificate chain (number of certificates).insertCertificateInChain(int, int, byte[]),
closeKeyEntry(int)public static int setCertificateEntry(byte[] alias,
byte[] certificate)
alias - the alias of the key.certificate - the X.509 encoded certificate.public static int size()