Skip to content

Commit 7103dff

Browse files
Roberto SassuMimi Zohar
authored andcommitted
encrypted-keys: added additional debug messages
Some debug messages have been added in the function datablob_parse() in order to better identify errors returned when dealing with 'encrypted' keys. Changelog from version v4: - made the debug messages more understandable Signed-off-by: Roberto Sassu <roberto.sassu@polito.it> Acked-by: Gianluca Ramunno <ramunno@polito.it> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
1 parent 08fa2aa commit 7103dff

1 file changed

Lines changed: 34 additions & 11 deletions

File tree

‎security/keys/encrypted.c‎

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,46 +133,69 @@ static int datablob_parse(char *datablob, char **master_desc,
133133
substring_t args[MAX_OPT_ARGS];
134134
int ret = -EINVAL;
135135
int key_cmd;
136-
char *p;
136+
char *keyword;
137137

138-
p = strsep(&datablob, " \t");
139-
if (!p)
138+
keyword = strsep(&datablob, " \t");
139+
if (!keyword) {
140+
pr_info("encrypted_key: insufficient parameters specified\n");
140141
return ret;
141-
key_cmd = match_token(p, key_tokens, args);
142+
}
143+
key_cmd = match_token(keyword, key_tokens, args);
142144

143145
*master_desc = strsep(&datablob, " \t");
144-
if (!*master_desc)
146+
if (!*master_desc) {
147+
pr_info("encrypted_key: master key parameter is missing\n");
145148
goto out;
149+
}
146150

147-
if (valid_master_desc(*master_desc, NULL) < 0)
151+
if (valid_master_desc(*master_desc, NULL) < 0) {
152+
pr_info("encrypted_key: master key parameter \'%s\' "
153+
"is invalid\n", *master_desc);
148154
goto out;
155+
}
149156

150157
if (decrypted_datalen) {
151158
*decrypted_datalen = strsep(&datablob, " \t");
152-
if (!*decrypted_datalen)
159+
if (!*decrypted_datalen) {
160+
pr_info("encrypted_key: keylen parameter is missing\n");
153161
goto out;
162+
}
154163
}
155164

156165
switch (key_cmd) {
157166
case Opt_new:
158-
if (!decrypted_datalen)
167+
if (!decrypted_datalen) {
168+
pr_info("encrypted_key: keyword \'%s\' not allowed "
169+
"when called from .update method\n", keyword);
159170
break;
171+
}
160172
ret = 0;
161173
break;
162174
case Opt_load:
163-
if (!decrypted_datalen)
175+
if (!decrypted_datalen) {
176+
pr_info("encrypted_key: keyword \'%s\' not allowed "
177+
"when called from .update method\n", keyword);
164178
break;
179+
}
165180
*hex_encoded_iv = strsep(&datablob, " \t");
166-
if (!*hex_encoded_iv)
181+
if (!*hex_encoded_iv) {
182+
pr_info("encrypted_key: hex blob is missing\n");
167183
break;
184+
}
168185
ret = 0;
169186
break;
170187
case Opt_update:
171-
if (decrypted_datalen)
188+
if (decrypted_datalen) {
189+
pr_info("encrypted_key: keyword \'%s\' not allowed "
190+
"when called from .instantiate method\n",
191+
keyword);
172192
break;
193+
}
173194
ret = 0;
174195
break;
175196
case Opt_err:
197+
pr_info("encrypted_key: keyword \'%s\' not recognized\n",
198+
keyword);
176199
break;
177200
}
178201
out:

0 commit comments

Comments
 (0)