From 6a2560330da7bc05ccb9bc75e70ce745acba7d6c Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 25 Jul 2010 22:17:22 +0200 Subject: No need for ncr-direct. All session operations are being done on keys or on userspace data. --- examples/ncr.c | 116 ++++++++++++++++----------------------------------------- 1 file changed, 32 insertions(+), 84 deletions(-) (limited to 'examples/ncr.c') diff --git a/examples/ncr.c b/examples/ncr.c index be3dec9..f2c4b72 100644 --- a/examples/ncr.c +++ b/examples/ncr.c @@ -734,6 +734,7 @@ test_ncr_aes(int cfd) uint8_t data[KEY_DATA_SIZE]; int i, j; struct ncr_session_once_op_st nop; + int data_size; dinit.max_object_size = KEY_DATA_SIZE; dinit.flags = NCR_DATA_FLAG_EXPORTABLE; @@ -791,26 +792,17 @@ test_ncr_aes(int cfd) perror("ioctl(NCRIO_KEY_IMPORT)"); return 1; } - /* import data */ - - kdata.data = (void*)aes_vectors[i].plaintext; - kdata.data_size = 16; - kdata.desc = dd; - - if (ioctl(cfd, NCRIO_DATA_SET, &kdata)) { - fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__); - perror("ioctl(NCRIO_DATA_SET)"); - return 1; - } /* encrypt */ memset(&nop, 0, sizeof(nop)); nop.init.algorithm = NCR_ALG_AES_ECB; nop.init.key = key; nop.init.op = NCR_OP_ENCRYPT; - nop.op.data.ndata.input = dd; - nop.op.data.ndata.output = dd2; - nop.op.type = NCR_DATA; + nop.op.data.udata.input = (void*)aes_vectors[i].plaintext; + nop.op.data.udata.input_size = 16; + nop.op.data.udata.output = data; + nop.op.data.udata.output_size = sizeof(data); + nop.op.type = NCR_DIRECT_DATA; if (ioctl(cfd, NCRIO_SESSION_ONCE, &nop)) { fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__); @@ -818,22 +810,14 @@ test_ncr_aes(int cfd) return 1; } + data_size = nop.op.data.udata.output_size; /* verify */ - kdata.desc = dd2; - kdata.data = data; - kdata.data_size = sizeof(data); - - if (ioctl(cfd, NCRIO_DATA_GET, &kdata)) { - fprintf(stderr, "Error: %s:%d\n", __func__, __LINE__); - perror("ioctl(NCRIO_DATA_GET)"); - return 1; - } - if (kdata.data_size != 16 || memcmp(kdata.data, aes_vectors[i].ciphertext, 16) != 0) { + if (data_size != 16 || memcmp(data, aes_vectors[i].ciphertext, 16) != 0) { fprintf(stderr, "AES test vector %d failed!\n", i); - fprintf(stderr, "Cipher[%d]: ", (int)kdata.data_size); - for(j=0;j