summaryrefslogtreecommitdiffstats
path: root/examples/ncr.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ncr.c')
-rw-r--r--examples/ncr.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/examples/ncr.c b/examples/ncr.c
index d5d3e20c23f..69e699abd23 100644
--- a/examples/ncr.c
+++ b/examples/ncr.c
@@ -55,7 +55,6 @@ test_ncr_key(int cfd)
dinit.flags = NCR_DATA_FLAG_EXPORTABLE;
dinit.initial_data = data;
dinit.initial_data_size = sizeof(data);
- dinit.type = NCR_DATA_KERNEL;
if (ioctl(cfd, NCRIO_DATA_INIT, &dinit)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -97,7 +96,6 @@ test_ncr_key(int cfd)
dinit.flags = NCR_DATA_FLAG_EXPORTABLE;
dinit.initial_data = NULL;
dinit.initial_data_size = 0;
- dinit.type = NCR_DATA_KERNEL;
if (ioctl(cfd, NCRIO_DATA_INIT, &dinit)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -116,10 +114,12 @@ test_ncr_key(int cfd)
}
/* now read data */
- memset(&kdata, 0, sizeof(kdata));
+ memset(data, 0, sizeof(data));
+
kdata.desc = dinit.desc;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -129,7 +129,7 @@ test_ncr_key(int cfd)
if (memcmp(data, data_bak, sizeof(data))!=0) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
- fprintf(stderr, "data returned but differ (%d, %d)!\n", (int)kdata.data_size, sizeof(data));
+ fprintf(stderr, "data returned but differ!\n");
return 1;
}
@@ -179,6 +179,7 @@ test_ncr_key(int cfd)
kdata.desc = dinit.desc;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -236,6 +237,7 @@ test_ncr_key(int cfd)
kdata.desc = dinit.desc;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)==0) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -270,7 +272,6 @@ static int test_ncr_data(int cfd)
init.flags = NCR_DATA_FLAG_EXPORTABLE;
init.initial_data = data;
init.initial_data_size = sizeof(data);
- init.type = NCR_DATA_KERNEL;
if (ioctl(cfd, NCRIO_DATA_INIT, &init)) {
perror("ioctl(NCRIO_DATA_INIT)");
@@ -284,6 +285,7 @@ static int test_ncr_data(int cfd)
kdata.desc = init.desc;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)) {
perror("ioctl(NCRIO_DATA_GET)");
@@ -303,6 +305,7 @@ static int test_ncr_data(int cfd)
kdata.desc = init.desc;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) {
perror("ioctl(NCRIO_DATA_SET)");
@@ -315,6 +318,7 @@ static int test_ncr_data(int cfd)
kdata.desc = init.desc;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)) {
perror("ioctl(NCRIO_DATA_GET)");
@@ -341,7 +345,6 @@ static int test_ncr_data(int cfd)
init.flags = 0;
init.initial_data = data;
init.initial_data_size = sizeof(data);
- init.type = NCR_DATA_KERNEL;
if (ioctl(cfd, NCRIO_DATA_INIT, &init)) {
perror("ioctl(NCRIO_DATA_INIT)");
@@ -351,6 +354,7 @@ static int test_ncr_data(int cfd)
kdata.desc = init.desc;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)==0) {
fprintf(stderr, "Unexportable data were exported!?\n");
@@ -363,7 +367,6 @@ static int test_ncr_data(int cfd)
init.flags = 0;
init.initial_data = data;
init.initial_data_size = sizeof(data);
- init.type = NCR_DATA_KERNEL;
if (ioctl(cfd, NCRIO_DATA_INIT, &init)) {
//fprintf(stderr, "Reached maximum limit at: %d data items\n", i);
@@ -401,7 +404,6 @@ test_ncr_wrap_key(int cfd)
dinit.flags = NCR_DATA_FLAG_EXPORTABLE;
dinit.initial_data = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F";
dinit.initial_data_size = 16;
- dinit.type = NCR_DATA_KERNEL;
if (ioctl(cfd, NCRIO_DATA_INIT, &dinit)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -436,10 +438,11 @@ test_ncr_wrap_key(int cfd)
kdata.data = DKEY;
kdata.data_size = 16;
kdata.desc = dinit.desc;
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
- perror("ioctl(NCRIO_DATA_SET)");
+ perror("ioctl(NCRIO_DATA_INIT)");
return 1;
}
@@ -480,6 +483,7 @@ test_ncr_wrap_key(int cfd)
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -585,7 +589,6 @@ test_ncr_store_wrap_key(int cfd)
memset(&dinit, 0, sizeof(dinit));
dinit.max_object_size = DATA_SIZE;
dinit.flags = NCR_DATA_FLAG_EXPORTABLE;
- dinit.type = NCR_DATA_KERNEL;
if (ioctl(cfd, NCRIO_DATA_INIT, &dinit)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -600,10 +603,11 @@ test_ncr_store_wrap_key(int cfd)
kdata.data = DKEY;
kdata.data_size = 16;
kdata.desc = dd;
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
- perror("ioctl(NCRIO_DATA_SET)");
+ perror("ioctl(NCRIO_DATA_INIT)");
return 1;
}
@@ -746,7 +750,6 @@ test_ncr_aes(int cfd)
dinit.flags = NCR_DATA_FLAG_EXPORTABLE;
dinit.initial_data = NULL;
dinit.initial_data_size = 0;
- dinit.type = NCR_DATA_KERNEL;
if (ioctl(cfd, NCRIO_DATA_INIT, &dinit)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -785,10 +788,11 @@ test_ncr_aes(int cfd)
kdata.data = (void*)aes_vectors[i].key;
kdata.data_size = 16;
kdata.desc = dd;
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
- perror("ioctl(NCRIO_DATA_SET)");
+ perror("ioctl(NCRIO_DATA_INIT)");
return 1;
}
@@ -804,10 +808,11 @@ test_ncr_aes(int cfd)
kdata.data = (void*)aes_vectors[i].plaintext;
kdata.data_size = 16;
kdata.desc = dd;
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
- perror("ioctl(NCRIO_DATA_SET)");
+ perror("ioctl(NCRIO_DATA_INIT)");
return 1;
}
@@ -829,6 +834,7 @@ test_ncr_aes(int cfd)
kdata.desc = dd2;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -859,10 +865,11 @@ test_ncr_aes(int cfd)
kdata.data = (void*)aes_vectors[i].key;
kdata.data_size = 16;
kdata.desc = dd;
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
- perror("ioctl(NCRIO_DATA_SET)");
+ perror("ioctl(NCRIO_DATA_INIT)");
return 1;
}
@@ -879,10 +886,11 @@ test_ncr_aes(int cfd)
kdata.data = (void*)aes_vectors[i].ciphertext;
kdata.data_size = 16;
kdata.desc = dd;
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
- perror("ioctl(NCRIO_DATA_SET)");
+ perror("ioctl(NCRIO_DATA_INIT)");
return 1;
}
@@ -904,6 +912,7 @@ test_ncr_aes(int cfd)
kdata.desc = dd2;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -1032,7 +1041,6 @@ test_ncr_hash(int cfd)
dinit.flags = NCR_DATA_FLAG_EXPORTABLE;
dinit.initial_data = NULL;
dinit.initial_data_size = 0;
- dinit.type = NCR_DATA_KERNEL;
if (ioctl(cfd, NCRIO_DATA_INIT, &dinit)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
@@ -1073,10 +1081,11 @@ test_ncr_hash(int cfd)
kdata.data = (void*)hash_vectors[i].key;
kdata.data_size = hash_vectors[i].key_size;
kdata.desc = dd;
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
- perror("ioctl(NCRIO_DATA_SET)");
+ perror("ioctl(NCRIO_DATA_INIT)");
return 1;
}
@@ -1093,10 +1102,11 @@ test_ncr_hash(int cfd)
kdata.data = (void*)hash_vectors[i].plaintext;
kdata.data_size = hash_vectors[i].plaintext_size;
kdata.desc = dd;
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);
- perror("ioctl(NCRIO_DATA_SET)");
+ perror("ioctl(NCRIO_DATA_INIT)");
return 1;
}
@@ -1116,10 +1126,10 @@ test_ncr_hash(int cfd)
}
/* verify */
- memset(&kdata, 0, sizeof(kdata));
kdata.desc = dd2;
kdata.data = data;
kdata.data_size = sizeof(data);
+ kdata.append_flag = 0;
if (ioctl(cfd, NCRIO_DATA_GET, &kdata)) {
fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__);