Fix typo. Add TPM support for keyring password.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich 2024-11-09 17:22:53 +01:00
parent ff89a6e505
commit b42d73b2ed
3 changed files with 5 additions and 5 deletions

View File

@ -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";

View File

@ -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

View File

@ -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);