Skip to content

Commit dc2cf37

Browse files
authored
Merge pull request #5 from mrhpearson/tc-cert2pass
tlmi_auth: Add handling for cert2pass on ThinkCenter
2 parents b1ebc14 + 2192112 commit dc2cf37

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/tlmi_auth.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "tlmi_crypto.h"
3030

3131
#ifndef TLMI_PROG_VER
32-
#define TLMI_PROG_VER "0.0.0"
32+
#define TLMI_PROG_VER "0.0.1"
3333
#endif
3434

3535
#define TLMI_ADMIN "/sys/class/firmware-attributes/thinklmi/authentication/Admin"
@@ -41,6 +41,7 @@
4141
#define WMI_SET_ATTR "Lenovo_SetBiosSettingEx"
4242
#define WMI_SAVE_ATTR "Lenovo_SaveBiosSettingsEx"
4343
#define WMI_CERT2PASS "Lenovo_ChangeBiosCertificateToPassword"
44+
#define WMI_CERT2PASS_TC "Lenovo_ChangeCertificateToSvp"
4445

4546
#define WMI_ADMIN_USER "SVC" /* AKA SuperVisor */
4647
#define WMI_SYSTEM_USER "SMC"
@@ -56,6 +57,7 @@ static void usage(void)
5657
fprintf(stderr, " clearcert -s serial -k privkey.pem - Clear installed certificate\n");
5758
fprintf(stderr, " attribute -a attribute -v value -k privkey.pem - Set attribute to given value\n");
5859
fprintf(stderr, " cert2pass -p passwd -k privkey.pem - Go from certificate to password authentication\n");
60+
fprintf(stderr, " cert2pass-tc -p passwd -k privkey.pem - Certificate to password for ThinkCenter platforms\n");
5961
fprintf(stderr, " unlock -f request.txt -k privkey.pem - Generate unlock code from request file.\n");
6062
fprintf(stderr, " unlock -r request-string -k privkey.pem - Generate unlock code from request string.\n");
6163

@@ -304,19 +306,26 @@ int main(int argc, char* argv[])
304306
fclose(fp);
305307
free(base64sig);
306308
}
307-
else if (!strcmp(command, "cert2pass")) {
309+
else if (!strcmp(command, "cert2pass") || !strcmp(command, "cert2pass-tc")) {
310+
char wmi_cert2pass[50];
311+
308312
if (!password || !key) {
309313
usage();
310314
exit(1);
311315
}
312-
wmistr = (char *)malloc(strlen(WMI_ADMIN_USER) + 1 + strlen(WMI_CERT2PASS) + 1 + strlen(password) + 1);
316+
317+
if (!strcmp(command, "cert2pass-tc"))
318+
sprintf(wmi_cert2pass, WMI_CERT2PASS_TC);
319+
else
320+
sprintf(wmi_cert2pass, WMI_CERT2PASS);
321+
wmistr = (char *)malloc(strlen(WMI_ADMIN_USER) + 1 + strlen(wmi_cert2pass) + 1 + strlen(password) + 1);
313322
if (!wmistr)
314323
return -1;
315324

316325
if (user)
317-
ret = sprintf(wmistr, "%s,%s,%s", WMI_CERT2PASS, determine_user_type(user), password);
326+
ret = sprintf(wmistr, "%s,%s,%s", wmi_cert2pass, determine_user_type(user), password);
318327
else
319-
ret = sprintf(wmistr, "%s,%s", WMI_CERT2PASS, password);
328+
ret = sprintf(wmistr, "%s,%s", wmi_cert2pass, password);
320329
if (ret < 0) {
321330
free(wmistr);
322331
return ret;

0 commit comments

Comments
 (0)