summaryrefslogtreecommitdiffstats
path: root/lib/pb-protocol
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2019-02-15 10:39:30 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2019-03-06 09:54:10 +1300
commit5f8fa2c151b8f0e568dc4015b7d307250b354a04 (patch)
tree70f626a58f3f83c53dfb0194bbcf77584dbdf00a /lib/pb-protocol
parentba8144f917f5603e507e9c72aed4ae3257c6b0ce (diff)
downloadtalos-petitboot-5f8fa2c151b8f0e568dc4015b7d307250b354a04.tar.gz
talos-petitboot-5f8fa2c151b8f0e568dc4015b7d307250b354a04.zip
lib: Add AUTH_MSG_DECRYPT
Extend the auth_message struct to support the AUTH_MSG_DECRYPT operation, allowing the existing authentications methods to be used for passing a disk password from the UI to pb-discover. In addition add DEVICE_TYPE_LUKS to identify encrypted disk devices. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'lib/pb-protocol')
-rw-r--r--lib/pb-protocol/pb-protocol.c17
-rw-r--r--lib/pb-protocol/pb-protocol.h5
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index b4138bb..33bd4e6 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -394,6 +394,10 @@ int pb_protocol_authenticate_len(struct auth_message *msg)
/* enum + password + password */
return 4 + 4 + optional_strlen(msg->set_password.password) +
4 + optional_strlen(msg->set_password.new_password);
+ case AUTH_MSG_DECRYPT:
+ /* enum + password + device id */
+ return 4 + 4 + optional_strlen(msg->decrypt_dev.password) +
+ 4 + optional_strlen(msg->decrypt_dev.device_id);
default:
pb_log("%s: invalid input\n", __func__);
return 0;
@@ -750,6 +754,12 @@ int pb_protocol_serialise_authenticate(struct auth_message *msg,
pos += pb_protocol_serialise_string(pos,
msg->set_password.new_password);
break;
+ case AUTH_MSG_DECRYPT:
+ pos += pb_protocol_serialise_string(pos,
+ msg->decrypt_dev.password);
+ pos += pb_protocol_serialise_string(pos,
+ msg->decrypt_dev.device_id);
+ break;
default:
pb_log("%s: invalid msg\n", __func__);
return -1;
@@ -1439,6 +1449,13 @@ int pb_protocol_deserialise_authenticate(struct auth_message *msg,
&msg->set_password.new_password))
return -1;
break;
+ case AUTH_MSG_DECRYPT:
+ if (read_string(msg, &pos, &len, &msg->decrypt_dev.password))
+ return -1;
+ if (read_string(msg, &pos, &len,
+ &msg->decrypt_dev.device_id))
+ return -1;
+ break;
default:
pb_log("%s: unable to parse\n", __func__);
return -1;
diff --git a/lib/pb-protocol/pb-protocol.h b/lib/pb-protocol/pb-protocol.h
index 1d6c048..f4975bc 100644
--- a/lib/pb-protocol/pb-protocol.h
+++ b/lib/pb-protocol/pb-protocol.h
@@ -40,6 +40,7 @@ enum auth_msg_type {
AUTH_MSG_REQUEST,
AUTH_MSG_RESPONSE,
AUTH_MSG_SET,
+ AUTH_MSG_DECRYPT,
};
struct auth_message {
@@ -51,6 +52,10 @@ struct auth_message {
char *password;
char *new_password;
} set_password;
+ struct {
+ char *password;
+ char *device_id;
+ } decrypt_dev;
};
};
OpenPOWER on IntegriCloud