public class KeyStoreSecureStorage extends Object implements SecureStorage
Modifier and Type | Field and Description |
---|---|
static String |
ENTRY_CURRENT_KEY
The current key used to calculate the HEADER_HMAC.
|
static String |
ENTRY_CURRENT_SIGNATURE
The last signature inserted into the file.
|
static String |
ENTRY_INITIAL_KEY
The initial key used to calculate the HEADER_HMAC.
|
static String |
ENTRY_SIGNATURE
The alias to lookup the private/public signature key into the keystore.
|
static String |
HMAC_ALGORITHM
The HMAC algorithm to use.
|
static String |
JCEKS_KEYSTORE_TYPE
The name of the Java Cryptography Extension KeyStore (JCEKS) type.
|
static String |
SIGNATURE_ALGORITHM
The algorithm to use for signing and verifying.
|
Constructor and Description |
---|
KeyStoreSecureStorage(KeyStoreHandler keyStoreHandler,
PrivateKey privateKey)
Creates the storage with a keystore handler, initialized to verify only.
|
KeyStoreSecureStorage(KeyStoreHandler keyStoreHandler,
PublicKey publicKey)
Creates the storage with a keystore handler, initialized to verify only.
|
KeyStoreSecureStorage(KeyStoreHandler keyStoreHandler,
PublicKey publicKey,
PrivateKey privateKey)
Creates the storage with a keystore handler, initialized to verify only.
|
Modifier and Type | Method and Description |
---|---|
String |
getPassword()
Returns the password used to access the storage.
|
SecretKey |
readCurrentKey()
Reads the current key.
|
SecretKey |
readInitialKey()
Reads the initial key.
|
void |
setKeyStoreHandler(KeyStoreHandler keyStoreHandler)
Set the key store handler.
|
byte[] |
sign(byte[] signedData)
Signs the provided data.
|
boolean |
verify(byte[] signedData,
byte[] signature)
Verifies that signed data corresponds to signature.
|
void |
writeCurrentKey(SecretKey key)
Writes the current key.
|
void |
writeCurrentSignatureKey(SecretKey key)
Writes the current signature key.
|
void |
writeInitialKey(SecretKey key)
Writes the initial key.
|
public static final String ENTRY_INITIAL_KEY
public static final String ENTRY_SIGNATURE
public static final String ENTRY_CURRENT_SIGNATURE
public static final String ENTRY_CURRENT_KEY
public static final String SIGNATURE_ALGORITHM
public static final String HMAC_ALGORITHM
public static final String JCEKS_KEYSTORE_TYPE
public KeyStoreSecureStorage(KeyStoreHandler keyStoreHandler, PrivateKey privateKey)
keyStoreHandler
- Handler of a keystore.privateKey
- The private key used to initialize the signerpublic KeyStoreSecureStorage(KeyStoreHandler keyStoreHandler, PublicKey publicKey)
keyStoreHandler
- Handler of a keystore.publicKey
- The public key used to initialize the verifierpublic KeyStoreSecureStorage(KeyStoreHandler keyStoreHandler, PublicKey publicKey, PrivateKey privateKey)
keyStoreHandler
- Handler of a keystore.publicKey
- The public key used to initialize the verifierprivateKey
- The private key used to initialize the signerpublic void setKeyStoreHandler(KeyStoreHandler keyStoreHandler)
keyStoreHandler
- The handler.public String getPassword()
SecureStorage
getPassword
in interface SecureStorage
public SecretKey readCurrentKey() throws SecureStorageException
SecureStorage
readCurrentKey
in interface SecureStorage
SecureStorageException
- If an errors occurs.public SecretKey readInitialKey() throws SecureStorageException
SecureStorage
readInitialKey
in interface SecureStorage
SecureStorageException
- If an errors occurs.public void writeCurrentSignatureKey(SecretKey key) throws SecureStorageException
SecureStorage
writeCurrentSignatureKey
in interface SecureStorage
key
- The secret keySecureStorageException
- If an errors occurs.public void writeCurrentKey(SecretKey key) throws SecureStorageException
SecureStorage
writeCurrentKey
in interface SecureStorage
key
- the current keySecureStorageException
- If an errors occurs.public void writeInitialKey(SecretKey key) throws SecureStorageException
SecureStorage
writeInitialKey
in interface SecureStorage
key
- the initial keySecureStorageException
- If an errors occurs.public byte[] sign(byte[] signedData) throws SecureStorageException
SecureStorage
sign
in interface SecureStorage
signedData
- The data to sign.SecureStorageException
- If an error occured during signing process.public boolean verify(byte[] signedData, byte[] signature) throws SecureStorageException
SecureStorage
verify
in interface SecureStorage
signedData
- the data to verifysignature
- the signaturetrue
if data corresponds, false
otherwiseSecureStorageException
- If an error occured during the verification process.Copyright © 2025 Open Identity Platform Community. All rights reserved.