mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
Fix typo. Add TPM support for keyring password.
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
parent
ff89a6e505
commit
b42d73b2ed
@ -33,7 +33,7 @@ import org.openhab.core.thing.type.ChannelTypeUID;
|
||||
public class KNXBindingConstants {
|
||||
|
||||
public static final String BINDING_ID = "knx";
|
||||
public static final String ENCYRPTED_PASSWORD_SERIALIZATION_PREFIX = "TpM2-pRoTeCteD-";
|
||||
public static final String ENCRYPTED_PASSWORD_SERIALIZATION_PREFIX = "TpM2-pRoTeCteD-";
|
||||
|
||||
// Global config
|
||||
public static final String CONFIG_DISABLE_UOM = "disableUoM";
|
||||
|
@ -63,15 +63,15 @@ public class BridgeConfiguration {
|
||||
}
|
||||
|
||||
public String getKeyringPassword() {
|
||||
return keyringPassword;
|
||||
return decrypt(keyringPassword);
|
||||
}
|
||||
|
||||
protected String decrypt(String secret) {
|
||||
if (secret.startsWith(KNXBindingConstants.ENCYRPTED_PASSWORD_SERIALIZATION_PREFIX)) {
|
||||
if (secret.startsWith(KNXBindingConstants.ENCRYPTED_PASSWORD_SERIALIZATION_PREFIX)) {
|
||||
try {
|
||||
logger.info("trying to access TPM module");
|
||||
return TpmInterface.TPM.deserializeAndDecryptSecret(
|
||||
secret.substring(KNXBindingConstants.ENCYRPTED_PASSWORD_SERIALIZATION_PREFIX.length()));
|
||||
secret.substring(KNXBindingConstants.ENCRYPTED_PASSWORD_SERIALIZATION_PREFIX.length()));
|
||||
} catch (SecurityException e) {
|
||||
logger.error("Unable to decode stored password using TPM: {}", e.getMessage());
|
||||
// fall through
|
||||
|
@ -86,7 +86,7 @@ public class KNXCommandExtension extends AbstractConsoleCommandExtension impleme
|
||||
}
|
||||
String p = TpmInterface.TPM.encryptAndSerializeSecret(args[1]);
|
||||
console.println("encrypted representation of password");
|
||||
console.println(KNXBindingConstants.ENCYRPTED_PASSWORD_SERIALIZATION_PREFIX + p);
|
||||
console.println(KNXBindingConstants.ENCRYPTED_PASSWORD_SERIALIZATION_PREFIX + p);
|
||||
|
||||
// check if TPM can decrypt
|
||||
String decrypted = TpmInterface.TPM.deserializeAndDecryptSecret(p);
|
||||
|
Loading…
Reference in New Issue
Block a user