Skip to content

Commit a658ee7

Browse files
amey-raghatateAkshay-Belsare
authored andcommitted
[REVIEW] update sign_verify host as per comments
Address review comments for the new example Signed-off-by: Amey Avinash Raghatate <[email protected]>
1 parent e567907 commit a658ee7

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

sign_verify/host/main.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,25 @@ static void usage(int argc, char *argv[])
1717
{
1818
printf("%s: optee_example_sign_verify <key_size> <algo_name>\n",
1919
__func__);
20+
printf("Supported values for <key_size> are:\n");
21+
printf("2048 bits\n");
22+
printf("3072 bits\n");
23+
printf("4096 bits\n");
24+
25+
printf("Supported values for are <algo_name>:\n");
26+
printf("TA_ALG_PKCS1_V1_5_SHA1\n");
27+
printf("TA_ALG_PKCS1_V1_5_SHA224\n");
28+
printf("TA_ALG_PKCS1_V1_5_SHA256\n");
29+
printf("TA_ALG_PKCS1_V1_5_SHA384\n");
30+
printf("TA_ALG_PKCS1_V1_5_SHA512\n");
31+
printf("TA_ALG_PKCS1_PSS_MGF1_SHA1\n");
32+
printf("TA_ALG_PKCS1_PSS_MGF1_SHA224\n");
33+
printf("TA_ALG_PKCS1_PSS_MGF1_SHA256\n");
34+
printf("TA_ALG_PKCS1_PSS_MGF1_SHA384\n");
35+
printf("TA_ALG_PKCS1_PSS_MGF1_SHA512\n");
36+
printf("If no algorithm is specified\n");
37+
38+
printf("TA_ALG_PKCS1_V1_5_SHA256 is selected by default.\n");
2039
exit(1);
2140
}
2241

@@ -27,11 +46,9 @@ static void get_args(int argc, char *argv[], size_t *key_size,
2746
long ks;
2847
char *algo;
2948

30-
if ((argc > 3) || (argc < 2)) {
31-
warnx("Unexpected number of arguments %d (expected 2)",
32-
argc - 1);
49+
if (argc < 2 || argc > 3)
3350
usage(argc, argv);
34-
}
51+
3552
ks = strtol(argv[1], &ep, 0);
3653

3754
if (*ep) {
@@ -119,7 +136,7 @@ int main(int argc, char *argv[])
119136
op.params[2].value.a = selected_alg;
120137
op.params[3].value.a = key_size;
121138

122-
printf("prepare sign and verify operations\n");
139+
printf("Prepare sign and verify operations\n");
123140
res = TEEC_InvokeCommand(&sess, TA_RSA_SIGN_CMD_SIGN_VERIFY, &op,
124141
&origin);
125142
if (res != TEEC_SUCCESS)
@@ -128,7 +145,7 @@ int main(int argc, char *argv[])
128145
printf("Sign and verify successful. Signature length: %zu bytes\n",
129146
op.params[1].tmpref.size);
130147

131-
printf("signature: ");
148+
printf("Signature: ");
132149
for (size_t i = 0; i < op.params[1].tmpref.size; i++)
133150
printf("%02x ", signature[i]);
134151

0 commit comments

Comments
 (0)