diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-05-28 11:36:08 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-06-17 20:47:38 +0200 |
commit | e1e9463cca0bd41f56897c14014f714e48afe543 (patch) | |
tree | f25d4d350e1a289f9809d803342bf5545e214996 | |
parent | 0ccc614c7d1b74f34abeeee34fe1e5f11820f39c (diff) | |
download | cryptodev-linux-e1e9463cca0bd41f56897c14014f714e48afe543.tar.gz cryptodev-linux-e1e9463cca0bd41f56897c14014f714e48afe543.tar.xz cryptodev-linux-e1e9463cca0bd41f56897c14014f714e48afe543.zip |
Added test to verify that data that are not marked as exportable cannot be read.
-rw-r--r-- | examples/new.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/examples/new.c b/examples/new.c index 1f507be..db46927 100644 --- a/examples/new.c +++ b/examples/new.c @@ -104,7 +104,38 @@ test_ncr_data(int cfd) } fprintf(stderr, "Verified new data\n"); - return 0; /* ok */ + if (ioctl(cfd, NCRIO_DATA_DEINIT, &kdata.desc)) { + perror("ioctl(NCRIO_DATA_DEINIT)"); + return 1; + } + + fprintf(stderr, "Initializing unexportable data\n"); + randomize_data(data, sizeof(data)); + + init.max_object_size = DATA_SIZE; + init.flags = 0; + init.initial_data = data; + init.initial_data_size = sizeof(data); + + if (ioctl(cfd, NCRIO_DATA_INIT, &init)) { + perror("ioctl(NCRIO_DATA_INIT)"); + return 1; + } + + 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"); + fprintf(stderr, "Verified that unexportable data cannot be exported\n"); + return 0; + } + + fprintf(stderr, "Unexportable data were exported!?\n"); + + return 1; /* ok */ } int |