diff options
Diffstat (limited to 'recipes-kernel/cryptodev/sdk_patches/0038-extend-sha_speed.c-to-test-CIOCHASH.patch')
-rw-r--r-- | recipes-kernel/cryptodev/sdk_patches/0038-extend-sha_speed.c-to-test-CIOCHASH.patch | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/recipes-kernel/cryptodev/sdk_patches/0038-extend-sha_speed.c-to-test-CIOCHASH.patch b/recipes-kernel/cryptodev/sdk_patches/0038-extend-sha_speed.c-to-test-CIOCHASH.patch deleted file mode 100644 index eb8bf197..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0038-extend-sha_speed.c-to-test-CIOCHASH.patch +++ /dev/null | |||
@@ -1,143 +0,0 @@ | |||
1 | From 65704ea24e80647e8c5f938300f51cb70af50c1c Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 21 Jan 2016 17:30:59 +0200 | ||
4 | Subject: [PATCH 38/38] extend sha_speed.c to test CIOCHASH | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/sha_speed.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
9 | 1 file changed, 90 insertions(+) | ||
10 | |||
11 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
12 | index 5f694bd..d731c66 100644 | ||
13 | --- a/tests/sha_speed.c | ||
14 | +++ b/tests/sha_speed.c | ||
15 | @@ -133,6 +133,62 @@ int hash_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
16 | return 0; | ||
17 | } | ||
18 | |||
19 | +int digest_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
20 | +{ | ||
21 | + struct hash_op_data hash_op; | ||
22 | + char *buffer; | ||
23 | + static int val = 23; | ||
24 | + struct timeval start, end; | ||
25 | + double total = 0; | ||
26 | + double secs, ddata, dspeed; | ||
27 | + char metric[16]; | ||
28 | + uint8_t mac[AALG_MAX_RESULT_LEN]; | ||
29 | + | ||
30 | + if (alignmask) { | ||
31 | + if (posix_memalign((void **)&buffer, alignmask + 1, chunksize)) { | ||
32 | + printf("posix_memalign() failed!\n"); | ||
33 | + return 1; | ||
34 | + } | ||
35 | + } else { | ||
36 | + if (!(buffer = malloc(chunksize))) { | ||
37 | + perror("malloc()"); | ||
38 | + return 1; | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + printf("\tEncrypting in chunks of %d bytes: ", chunksize); | ||
43 | + fflush(stdout); | ||
44 | + | ||
45 | + memset(buffer, val++, chunksize); | ||
46 | + | ||
47 | + must_finish = 0; | ||
48 | + alarm(BUFFER_TEST_TIME); | ||
49 | + | ||
50 | + gettimeofday(&start, NULL); | ||
51 | + do { | ||
52 | + memset(&hash_op, 0, sizeof(hash_op)); | ||
53 | + hash_op.mac_op = sess->mac; | ||
54 | + hash_op.len = chunksize; | ||
55 | + hash_op.src = (unsigned char *)buffer; | ||
56 | + hash_op.mac_result = mac; | ||
57 | + | ||
58 | + if (ioctl(fdc, CIOCHASH, hash_op) != 0) { | ||
59 | + perror("ioctl(CIOCHASH)"); | ||
60 | + return 1; | ||
61 | + } | ||
62 | + total += chunksize; | ||
63 | + } while(must_finish == 0); | ||
64 | + gettimeofday(&end, NULL); | ||
65 | + | ||
66 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
67 | + | ||
68 | + value2human(1, total, secs, &ddata, &dspeed, metric); | ||
69 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
70 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
71 | + | ||
72 | + free(buffer); | ||
73 | + return 0; | ||
74 | +} | ||
75 | |||
76 | #ifdef CIOCGSESSINFO | ||
77 | int get_alignmask(struct session_op *sess, int fdc) | ||
78 | @@ -154,6 +210,20 @@ int get_alignmask(struct session_op *sess, int fdc) | ||
79 | #endif | ||
80 | |||
81 | |||
82 | +int ciochash_session(struct session_op *sess, int fdc) | ||
83 | +{ | ||
84 | + int i; | ||
85 | + int err = 0; | ||
86 | + | ||
87 | + err = 0; | ||
88 | + for(i = 0; (err == 0) && (buffer_lengths[i] != 0); i++) { | ||
89 | + err = digest_data(sess, fdc, buffer_lengths[i], 0); | ||
90 | + } | ||
91 | + | ||
92 | + return err; | ||
93 | +} | ||
94 | + | ||
95 | + | ||
96 | int hash_session(struct session_op *sess, int fdc) | ||
97 | { | ||
98 | int i; | ||
99 | @@ -193,6 +263,15 @@ int test_sha1(struct session_op *sess, int fdc) | ||
100 | } | ||
101 | |||
102 | |||
103 | +int test_sha1_ciochash(struct session_op *sess, int fdc) | ||
104 | +{ | ||
105 | + fprintf(stderr, "Testing SHA1 CIOCHASH: \n"); | ||
106 | + memset(sess, 0, sizeof(sess)); | ||
107 | + sess->mac = CRYPTO_SHA1; | ||
108 | + return ciochash_session(sess, fdc); | ||
109 | +} | ||
110 | + | ||
111 | + | ||
112 | int test_sha256(struct session_op *sess, int fdc) | ||
113 | { | ||
114 | fprintf(stderr, "Testing SHA256 Hash: \n"); | ||
115 | @@ -202,6 +281,15 @@ int test_sha256(struct session_op *sess, int fdc) | ||
116 | } | ||
117 | |||
118 | |||
119 | +int test_sha256_ciochash(struct session_op *sess, int fdc) | ||
120 | +{ | ||
121 | + fprintf(stderr, "Testing SHA256 CIOCHASH: \n"); | ||
122 | + memset(sess, 0, sizeof(sess)); | ||
123 | + sess->mac = CRYPTO_SHA2_256; | ||
124 | + return ciochash_session(sess, fdc); | ||
125 | +} | ||
126 | + | ||
127 | + | ||
128 | int main(void) | ||
129 | { | ||
130 | int fd; | ||
131 | @@ -227,7 +315,9 @@ int main(void) | ||
132 | |||
133 | /* run all tests but return an eventual error */ | ||
134 | err |= test_sha1(&sess, fdc); | ||
135 | + err |= test_sha1_ciochash(&sess, fdc); | ||
136 | err |= test_sha256(&sess, fdc); | ||
137 | + err |= test_sha256_ciochash(&sess, fdc); | ||
138 | |||
139 | close(fdc); | ||
140 | close(fd); | ||
141 | -- | ||
142 | 2.7.0 | ||
143 | |||