cryptodev: remove crypto device type enumeration
[dpdk.git] / test / test / test_cryptodev_perf.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *       * Redistributions of source code must retain the above copyright
11  *         notice, this list of conditions and the following disclaimer.
12  *       * Redistributions in binary form must reproduce the above copyright
13  *         notice, this list of conditions and the following disclaimer in
14  *         the documentation and/or other materials provided with the
15  *         distribution.
16  *       * Neither the name of Intel Corporation nor the names of its
17  *         contributors may be used to endorse or promote products derived
18  *         from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #include <rte_common.h>
34 #include <rte_mbuf.h>
35 #include <rte_malloc.h>
36 #include <rte_memcpy.h>
37
38 #include <rte_crypto.h>
39 #include <rte_cryptodev.h>
40 #include <rte_cycles.h>
41
42 #include "test.h"
43 #include "test_cryptodev.h"
44 #include "test_cryptodev_gcm_test_vectors.h"
45
46 #define AES_CIPHER_IV_LENGTH 16
47 #define TRIPLE_DES_CIPHER_IV_LENGTH 8
48 #define AES_GCM_AAD_LENGTH 16
49
50 #define PERF_NUM_OPS_INFLIGHT           (128)
51 #define DEFAULT_NUM_REQS_TO_SUBMIT      (10000000)
52
53 struct crypto_testsuite_params {
54         struct rte_mempool *mbuf_mp;
55         struct rte_mempool *op_mpool;
56
57         uint16_t nb_queue_pairs;
58
59         struct rte_cryptodev_config conf;
60         struct rte_cryptodev_qp_conf qp_conf;
61         uint8_t dev_id;
62 };
63
64 enum chain_mode {
65         CIPHER_HASH,
66         HASH_CIPHER,
67         CIPHER_ONLY,
68         HASH_ONLY,
69         AEAD
70 };
71
72
73 struct symmetric_op {
74         const uint8_t *aad_data;
75
76         const uint8_t *p_data;
77         uint32_t p_len;
78
79         const uint8_t *c_data;
80         uint32_t c_len;
81
82         const uint8_t *t_data;
83         uint32_t t_len;
84
85 };
86
87 struct symmetric_session_attrs {
88         enum rte_crypto_cipher_operation cipher;
89         enum rte_crypto_auth_operation auth;
90         enum rte_crypto_aead_operation aead;
91
92         enum rte_crypto_cipher_algorithm cipher_algorithm;
93         const uint8_t *key_cipher_data;
94         uint32_t key_cipher_len;
95
96         enum rte_crypto_auth_algorithm auth_algorithm;
97         const uint8_t *key_auth_data;
98         uint32_t key_auth_len;
99
100         enum rte_crypto_aead_algorithm aead_algorithm;
101         const uint8_t *key_aead_data;
102         uint32_t key_aead_len;
103
104         const uint8_t *iv_data;
105         uint16_t iv_len;
106         uint16_t aad_len;
107         uint32_t digest_len;
108 };
109
110 #define ALIGN_POW2_ROUNDUP(num, align) \
111         (((num) + (align) - 1) & ~((align) - 1))
112
113 /*
114  * This struct is needed to avoid unnecessary allocation or checking
115  * of allocation of crypto params with current alloc on the fly
116  * implementation.
117  */
118
119 struct crypto_params {
120         uint8_t *aad;
121         uint8_t *digest;
122 };
123
124 struct perf_test_params {
125
126         unsigned total_operations;
127         unsigned burst_size;
128         unsigned buf_size;
129
130         enum chain_mode chain;
131
132         enum rte_crypto_cipher_algorithm cipher_algo;
133         unsigned int key_length;
134         enum rte_crypto_auth_algorithm auth_algo;
135         enum rte_crypto_aead_algorithm aead_algo;
136
137         struct symmetric_session_attrs *session_attrs;
138
139         struct symmetric_op *symmetric_op;
140 };
141
142 #define MAX_NUM_OF_OPS_PER_UT   (128)
143
144 struct crypto_unittest_params {
145         struct rte_crypto_sym_xform cipher_xform;
146         struct rte_crypto_sym_xform auth_xform;
147
148         struct rte_cryptodev_sym_session *sess;
149
150         struct rte_crypto_op *op;
151
152         struct rte_mbuf *obuf[MAX_NUM_OF_OPS_PER_UT];
153         struct rte_mbuf *ibuf[MAX_NUM_OF_OPS_PER_UT];
154
155         uint8_t *digest;
156 };
157
158 static struct rte_cryptodev_sym_session *
159 test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
160                 enum rte_crypto_cipher_algorithm cipher_algo,
161                 unsigned int cipher_key_len,
162                 enum rte_crypto_auth_algorithm auth_algo);
163 static struct rte_cryptodev_sym_session *
164 test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
165                 enum rte_crypto_cipher_algorithm cipher_algo,
166                 unsigned int cipher_key_len,
167                 enum rte_crypto_auth_algorithm auth_algo,
168                 enum rte_crypto_aead_algorithm aead_algo);
169 static struct rte_cryptodev_sym_session *
170 test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
171                 enum rte_crypto_cipher_algorithm cipher_algo,
172                 unsigned int cipher_key_len,
173                 enum rte_crypto_auth_algorithm auth_algo);
174
175 static struct rte_mbuf *
176 test_perf_create_pktmbuf(struct rte_mempool *mpool, unsigned buf_sz);
177 static inline struct rte_crypto_op *
178 test_perf_set_crypto_op_snow3g(struct rte_crypto_op *op, struct rte_mbuf *m,
179                 struct rte_cryptodev_sym_session *sess, unsigned int data_len);
180 static inline struct rte_crypto_op *
181 test_perf_set_crypto_op_aes(struct rte_crypto_op *op, struct rte_mbuf *m,
182                 struct rte_cryptodev_sym_session *sess, unsigned int data_len,
183                 enum chain_mode chain);
184 static inline struct rte_crypto_op *
185 test_perf_set_crypto_op_aes_gcm(struct rte_crypto_op *op, struct rte_mbuf *m,
186                 struct rte_cryptodev_sym_session *sess, unsigned int data_len,
187                 enum chain_mode chain __rte_unused);
188 static inline struct rte_crypto_op *
189 test_perf_set_crypto_op_3des(struct rte_crypto_op *op, struct rte_mbuf *m,
190                 struct rte_cryptodev_sym_session *sess, unsigned int data_len,
191                 enum chain_mode chain __rte_unused);
192 static uint32_t get_auth_digest_length(enum rte_crypto_auth_algorithm algo);
193
194
195 static const char *chain_mode_name(enum chain_mode mode)
196 {
197         switch (mode) {
198         case CIPHER_HASH: return "cipher_hash"; break;
199         case HASH_CIPHER: return "hash_cipher"; break;
200         case CIPHER_ONLY: return "cipher_only"; break;
201         case HASH_ONLY: return "hash_only"; break;
202         case AEAD: return "aead"; break;
203         default: return ""; break;
204         }
205 }
206
207 static const char *pmd_name(uint8_t driver_id)
208 {
209         uint8_t null_pmd = rte_cryptodev_driver_id_get(
210                         RTE_STR(CRYPTODEV_NAME_NULL_PMD));
211         uint8_t dpaa2_pmd = rte_cryptodev_driver_id_get(
212                         RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
213         uint8_t snow3g_pmd = rte_cryptodev_driver_id_get(
214                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
215         uint8_t aesni_gcm_pmd = rte_cryptodev_driver_id_get(
216                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
217         uint8_t aesni_mb_pmd = rte_cryptodev_driver_id_get(
218                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
219         uint8_t qat_pmd = rte_cryptodev_driver_id_get(
220                         RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
221
222         if (driver_id == null_pmd)
223                 return RTE_STR(CRYPTODEV_NAME_NULL_PMD);
224         else if (driver_id == aesni_gcm_pmd)
225                 return RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD);
226         else if (driver_id == aesni_mb_pmd)
227                 return RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD);
228         else if (driver_id == qat_pmd)
229                 return RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
230         else if (driver_id == snow3g_pmd)
231                 return RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD);
232         else if (driver_id == dpaa2_pmd)
233                 return RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
234         else
235                 return "";
236 }
237
238 static struct rte_mbuf *
239 setup_test_string(struct rte_mempool *mpool,
240                 const uint8_t *data, size_t len, uint8_t blocksize)
241 {
242         struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
243         size_t t_len = len - (blocksize ? (len % blocksize) : 0);
244
245         if (m) {
246                 char *dst = rte_pktmbuf_append(m, t_len);
247
248                 if (!dst) {
249                         rte_pktmbuf_free(m);
250                         return NULL;
251                 }
252
253                 rte_memcpy(dst, (const void *)data, t_len);
254         }
255         return m;
256 }
257
258 static struct crypto_testsuite_params testsuite_params = { NULL };
259 static struct crypto_unittest_params unittest_params;
260 static int gbl_driver_id;
261
262 static int
263 testsuite_setup(void)
264 {
265         struct crypto_testsuite_params *ts_params = &testsuite_params;
266         struct rte_cryptodev_info info;
267         unsigned i, nb_devs, valid_dev_id = 0;
268         int ret;
269         uint16_t qp_id;
270
271         ts_params->mbuf_mp = rte_mempool_lookup("CRYPTO_PERF_MBUFPOOL");
272         if (ts_params->mbuf_mp == NULL) {
273                 /* Not already created so create */
274                 ts_params->mbuf_mp = rte_pktmbuf_pool_create(
275                                 "CRYPTO_PERF_MBUFPOOL",
276                                 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
277                                 rte_socket_id());
278                 if (ts_params->mbuf_mp == NULL) {
279                         RTE_LOG(ERR, USER1, "Can't create CRYPTO_PERF_MBUFPOOL\n");
280                         return TEST_FAILED;
281                 }
282         }
283
284
285         ts_params->op_mpool = rte_crypto_op_pool_create("CRYPTO_OP_POOL",
286                         RTE_CRYPTO_OP_TYPE_SYMMETRIC,
287                         NUM_MBUFS, MBUF_CACHE_SIZE,
288                         DEFAULT_NUM_XFORMS *
289                         sizeof(struct rte_crypto_sym_xform) +
290                         MAXIMUM_IV_LENGTH,
291                         rte_socket_id());
292                 if (ts_params->op_mpool == NULL) {
293                         RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
294                         return TEST_FAILED;
295                 }
296
297         /* Create an AESNI MB device if required */
298         if (gbl_driver_id == rte_cryptodev_driver_id_get(
299                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
300                 nb_devs = rte_cryptodev_device_count_by_driver(
301                                 rte_cryptodev_driver_id_get(
302                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
303                 if (nb_devs < 1) {
304                         ret = rte_vdev_init(
305                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
306
307                         TEST_ASSERT(ret == 0,
308                                 "Failed to create instance of pmd : %s",
309                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
310                 }
311         }
312
313         /* Create an AESNI GCM device if required */
314         if (gbl_driver_id == rte_cryptodev_driver_id_get(
315                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
316                 nb_devs = rte_cryptodev_device_count_by_driver(
317                                 rte_cryptodev_driver_id_get(
318                                 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
319                 if (nb_devs < 1) {
320                         ret = rte_vdev_init(
321                                 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL);
322
323                         TEST_ASSERT(ret == 0,
324                                 "Failed to create instance of pmd : %s",
325                                 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
326                 }
327         }
328
329         /* Create a SNOW3G device if required */
330         if (gbl_driver_id == rte_cryptodev_driver_id_get(
331                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
332                 nb_devs = rte_cryptodev_device_count_by_driver(
333                                 rte_cryptodev_driver_id_get(
334                                 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
335                 if (nb_devs < 1) {
336                         ret = rte_vdev_init(
337                                 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL);
338
339                         TEST_ASSERT(ret == 0,
340                                 "Failed to create instance of pmd : %s",
341                                 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
342                 }
343         }
344
345         /* Create an OPENSSL device if required */
346         if (gbl_driver_id == rte_cryptodev_driver_id_get(
347                         RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
348                 nb_devs = rte_cryptodev_device_count_by_driver(
349                                 rte_cryptodev_driver_id_get(
350                                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
351                 if (nb_devs < 1) {
352                         ret = rte_vdev_init(
353                                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
354                                 NULL);
355
356                         TEST_ASSERT(ret == 0, "Failed to create "
357                                 "instance of pmd : %s",
358                                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
359                 }
360         }
361
362         /* Create an ARMv8 device if required */
363         if (gbl_driver_id == rte_cryptodev_driver_id_get(
364                         RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
365                 nb_devs = rte_cryptodev_device_count_by_driver(
366                                 rte_cryptodev_driver_id_get(
367                                 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
368                 if (nb_devs < 1) {
369                         ret = rte_vdev_init(
370                                 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
371                                 NULL);
372
373                         TEST_ASSERT(ret == 0, "Failed to create "
374                                 "instance of pmd : %s",
375                                 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
376                 }
377         }
378
379         nb_devs = rte_cryptodev_count();
380         if (nb_devs < 1) {
381                 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
382                 return TEST_FAILED;
383         }
384
385         /* Search for the first valid */
386         for (i = 0; i < nb_devs; i++) {
387                 rte_cryptodev_info_get(i, &info);
388                 if (info.driver_id == (uint8_t) gbl_driver_id) {
389                         ts_params->dev_id = i;
390                         valid_dev_id = 1;
391                         break;
392                 }
393         }
394
395         if (!valid_dev_id)
396                 return TEST_FAILED;
397
398         /*
399          * Using Crypto Device Id 0 by default.
400          * Set up all the qps on this device
401          */
402
403         rte_cryptodev_info_get(ts_params->dev_id, &info);
404
405         ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
406         ts_params->conf.socket_id = SOCKET_ID_ANY;
407         ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
408
409         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
410                         &ts_params->conf),
411                         "Failed to configure cryptodev %u",
412                         ts_params->dev_id);
413
414         ts_params->qp_conf.nb_descriptors = PERF_NUM_OPS_INFLIGHT;
415         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
416
417                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
418                         ts_params->dev_id, qp_id,
419                                 &ts_params->qp_conf,
420                                 rte_cryptodev_socket_id(ts_params->dev_id)),
421                                 "Failed to setup queue pair %u on cryptodev %u",
422                                 qp_id, ts_params->dev_id);
423         }
424
425         return TEST_SUCCESS;
426 }
427 static void
428 testsuite_teardown(void)
429 {
430         struct crypto_testsuite_params *ts_params =
431                         &testsuite_params;
432
433         if (ts_params->mbuf_mp != NULL)
434                 RTE_LOG(DEBUG, USER1, "CRYPTO_PERF_MBUFPOOL count %u\n",
435                 rte_mempool_avail_count(ts_params->mbuf_mp));
436         if (ts_params->op_mpool != NULL)
437                 RTE_LOG(DEBUG, USER1, "CRYPTO_PERF_OP POOL count %u\n",
438                 rte_mempool_avail_count(ts_params->op_mpool));
439 }
440
441 static int
442 ut_setup(void)
443 {
444         struct crypto_testsuite_params *ts_params = &testsuite_params;
445         struct crypto_unittest_params *ut_params = &unittest_params;
446
447         /* Clear unit test parameters before running test */
448         memset(ut_params, 0, sizeof(*ut_params));
449
450         rte_cryptodev_stats_reset(ts_params->dev_id);
451
452         /* Start the device */
453         TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->dev_id),
454                         "Failed to start cryptodev %u",
455                         ts_params->dev_id);
456
457         return TEST_SUCCESS;
458 }
459
460 static void
461 ut_teardown(void)
462 {
463         struct crypto_testsuite_params *ts_params = &testsuite_params;
464         struct crypto_unittest_params *ut_params = &unittest_params;
465         struct rte_cryptodev_stats stats;
466
467         unsigned i;
468
469         /* free crypto session structure */
470         if (ut_params->sess)
471                 rte_cryptodev_sym_session_free(ts_params->dev_id,
472                                 ut_params->sess);
473
474         /* free crypto operation structure */
475         if (ut_params->op)
476                 rte_crypto_op_free(ut_params->op);
477
478         for (i = 0; i < MAX_NUM_OF_OPS_PER_UT; i++) {
479                 if (ut_params->obuf[i])
480                         rte_pktmbuf_free(ut_params->obuf[i]);
481                 else if (ut_params->ibuf[i])
482                         rte_pktmbuf_free(ut_params->ibuf[i]);
483         }
484
485         if (ts_params->mbuf_mp != NULL)
486                 RTE_LOG(DEBUG, USER1, "CRYPTO_PERF_MBUFPOOL count %u\n",
487                         rte_mempool_avail_count(ts_params->mbuf_mp));
488
489         rte_cryptodev_stats_get(ts_params->dev_id, &stats);
490
491         /* Stop the device */
492         rte_cryptodev_stop(ts_params->dev_id);
493 }
494
495 const char plaintext_quote[] =
496                 "THE COUNT OF MONTE CRISTO by Alexandre Dumas, Pere Chapter 1. "
497                 "Marseilles--The Arrival. On the 24th of February, 1815, the "
498                 "look-out at Notre-Dame de la Garde signalled the three-master,"
499                 " the Pharaon from Smyrna, Trieste, and Naples. As usual, a "
500                 "pilot put off immediately, and rounding the Chateau d'If, got "
501                 "on board the vessel between Cape Morgion and Rion island. "
502                 "Immediately, and according to custom, the ramparts of Fort "
503                 "Saint-Jean were covered with spectators; it is always an event "
504                 "at Marseilles for a ship to come into port, especially when "
505                 "this ship, like the Pharaon, has been built, rigged, and laden"
506                 " at the old Phocee docks, and belongs to an owner of the city."
507                 " The ship drew on and had safely passed the strait, which some"
508                 " volcanic shock has made between the Calasareigne and Jaros "
509                 "islands; had doubled Pomegue, and approached the harbor under"
510                 " topsails, jib, and spanker, but so slowly and sedately that"
511                 " the idlers, with that instinct which is the forerunner of "
512                 "evil, asked one another what misfortune could have happened "
513                 "on board. However, those experienced in navigation saw plainly"
514                 " that if any accident had occurred, it was not to the vessel "
515                 "herself, for she bore down with all the evidence of being "
516                 "skilfully handled, the anchor a-cockbill, the jib-boom guys "
517                 "already eased off, and standing by the side of the pilot, who"
518                 " was steering the Pharaon towards the narrow entrance of the"
519                 " inner port, was a young man, who, with activity and vigilant"
520                 " eye, watched every motion of the ship, and repeated each "
521                 "direction of the pilot. The vague disquietude which prevailed "
522                 "among the spectators had so much affected one of the crowd "
523                 "that he did not await the arrival of the vessel in harbor, but"
524                 " jumping into a small skiff, desired to be pulled alongside "
525                 "the Pharaon, which he reached as she rounded into La Reserve "
526                 "basin. When the young man on board saw this person approach, "
527                 "he left his station by the pilot, and, hat in hand, leaned "
528                 "over the ship's bulwarks. He was a fine, tall, slim young "
529                 "fellow of eighteen or twenty, with black eyes, and hair as "
530                 "dark as a raven's wing; and his whole appearance bespoke that "
531                 "calmness and resolution peculiar to men accustomed from their "
532                 "cradle to contend with danger. \"Ah, is it you, Dantes?\" "
533                 "cried the man in the skiff. \"What's the matter? and why have "
534                 "you such an air of sadness aboard?\" \"A great misfortune, M. "
535                 "Morrel,\" replied the young man,--\"a great misfortune, for me"
536                 " especially! Off Civita Vecchia we lost our brave Captain "
537                 "Leclere.\" \"And the cargo?\" inquired the owner, eagerly. "
538                 "\"Is all safe, M. Morrel; and I think you will be satisfied on"
539                 " that head. But poor Captain Leclere--\" \"What happened to "
540                 "him?\" asked the owner, with an air of considerable "
541                 "resignation. \"What happened to the worthy captain?\" \"He "
542                 "died.\" \"Fell into the sea?\" \"No, sir, he died of "
543                 "brain-fever in dreadful agony.\" Then turning to the crew, "
544                 "he said, \"Bear a hand there, to take in sail!\" All hands "
545                 "obeyed, and at once the eight or ten seamen who composed the "
546                 "crew, sprang to their respective stations at the spanker "
547                 "brails and outhaul, topsail sheets and halyards, the jib "
548                 "downhaul, and the topsail clewlines and buntlines. The young "
549                 "sailor gave a look to see that his orders were promptly and "
550                 "accurately obeyed, and then turned again to the owner. \"And "
551                 "how did this misfortune occur?\" inquired the latter, resuming"
552                 " the interrupted conversation. \"Alas, sir, in the most "
553                 "unexpected manner. After a long talk with the harbor-master, "
554                 "Captain Leclere left Naples greatly disturbed in mind. In "
555                 "twenty-four hours he was attacked by a fever, and died three "
556                 "days afterwards. We performed the usual burial service, and he"
557                 " is at his rest, sewn up in his hammock with a thirty-six "
558                 "pound shot at his head and his heels, off El Giglio island. "
559                 "We bring to his widow his sword and cross of honor. It was "
560                 "worth while, truly,\" added the young man with a melancholy "
561                 "smile, \"to make war against the English for ten years, and "
562                 "to die in his bed at last, like everybody else.";
563
564 #define QUOTE_LEN_64B           (64)
565 #define QUOTE_LEN_128B          (128)
566 #define QUOTE_LEN_256B          (256)
567 #define QUOTE_LEN_512B          (512)
568 #define QUOTE_LEN_768B          (768)
569 #define QUOTE_LEN_1024B         (1024)
570 #define QUOTE_LEN_1280B         (1280)
571 #define QUOTE_LEN_1536B         (1536)
572 #define QUOTE_LEN_1792B         (1792)
573 #define QUOTE_LEN_2048B         (2048)
574
575
576 /* ***** AES-CBC / HMAC-SHA256 Performance Tests ***** */
577
578 #define HMAC_KEY_LENGTH_SHA256  (DIGEST_BYTE_LENGTH_SHA256)
579
580 #define CIPHER_KEY_LENGTH_AES_CBC       (16)
581 #define CIPHER_IV_LENGTH_AES_CBC        (CIPHER_KEY_LENGTH_AES_CBC)
582
583 static uint8_t aes_cbc_128_key[] = {
584                 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
585                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA };
586
587 static uint8_t aes_cbc_128_iv[] = {
588                 0xf5, 0xd3, 0x89, 0x0f, 0x47, 0x00, 0xcb, 0x52,
589                 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1 };
590
591 static uint8_t hmac_sha256_key[] = {
592                 0xff, 0xcb, 0x37, 0x30, 0x1d, 0x4a, 0xc2, 0x41,
593                 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A,
594                 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
595                 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60 };
596
597
598 /* Cipher text output */
599
600 static const uint8_t AES_CBC_ciphertext_64B[] = {
601                 0x05, 0x15, 0x77, 0x32, 0xc9, 0x66, 0x91, 0x50,
602                 0x93, 0x9f, 0xbb, 0x4e, 0x2e, 0x5a, 0x02, 0xd0,
603                 0x2d, 0x9d, 0x31, 0x5d, 0xc8, 0x9e, 0x86, 0x36,
604                 0x54, 0x5c, 0x50, 0xe8, 0x75, 0x54, 0x74, 0x5e,
605                 0xd5, 0xa2, 0x84, 0x21, 0x2d, 0xc5, 0xf8, 0x1c,
606                 0x55, 0x1a, 0xba, 0x91, 0xce, 0xb5, 0xa3, 0x1e,
607                 0x31, 0xbf, 0xe9, 0xa1, 0x97, 0x5c, 0x2b, 0xd6,
608                 0x57, 0xa5, 0x9f, 0xab, 0xbd, 0xb0, 0x9b, 0x9c
609 };
610
611 static const uint8_t AES_CBC_ciphertext_128B[] = {
612                 0x79, 0x92, 0x65, 0xc8, 0xfb, 0x0a, 0xc7, 0xc4,
613                 0x9b, 0x3b, 0xbe, 0x69, 0x7f, 0x7c, 0xf4, 0x4e,
614                 0xa5, 0x0d, 0xf6, 0x33, 0xc4, 0xdf, 0xf3, 0x0d,
615                 0xdb, 0xb9, 0x68, 0x34, 0xb0, 0x0d, 0xbd, 0xb9,
616                 0xa7, 0xf3, 0x86, 0x50, 0x2a, 0xbe, 0x50, 0x5d,
617                 0xb3, 0xbe, 0x72, 0xf9, 0x02, 0xb1, 0x69, 0x0b,
618                 0x8c, 0x96, 0x4c, 0x3c, 0x0c, 0x1e, 0x76, 0xe5,
619                 0x7e, 0x75, 0xdd, 0xd0, 0xa9, 0x75, 0x00, 0x13,
620                 0x6b, 0x1e, 0xc0, 0xad, 0xfc, 0x03, 0xb5, 0x99,
621                 0xdc, 0x37, 0x35, 0xfc, 0x16, 0x34, 0xfd, 0xb4,
622                 0xea, 0x1e, 0xb6, 0x51, 0xdf, 0xab, 0x87, 0xd6,
623                 0x87, 0x41, 0xfa, 0x1c, 0xc6, 0x78, 0xa6, 0x3c,
624                 0x1d, 0x76, 0xfe, 0xff, 0x65, 0xfc, 0x63, 0x1e,
625                 0x1f, 0xe2, 0x7c, 0x9b, 0xa2, 0x72, 0xc3, 0x34,
626                 0x23, 0xdf, 0x01, 0xf0, 0xfd, 0x02, 0x8b, 0x97,
627                 0x00, 0x2b, 0x97, 0x4e, 0xab, 0x98, 0x21, 0x3c
628 };
629
630 static const uint8_t AES_CBC_ciphertext_256B[] = {
631                 0xc7, 0x71, 0x2b, 0xed, 0x2c, 0x97, 0x59, 0xfa,
632                 0xcf, 0x5a, 0xb9, 0x31, 0x92, 0xe0, 0xc9, 0x92,
633                 0xc0, 0x2d, 0xd5, 0x9c, 0x84, 0xbf, 0x70, 0x36,
634                 0x13, 0x48, 0xe0, 0xb1, 0xbf, 0x6c, 0xcd, 0x91,
635                 0xa0, 0xc3, 0x57, 0x6c, 0x3f, 0x0e, 0x34, 0x41,
636                 0xe7, 0x9c, 0xc0, 0xec, 0x18, 0x0c, 0x05, 0x52,
637                 0x78, 0xe2, 0x3c, 0x6e, 0xdf, 0xa5, 0x49, 0xc7,
638                 0xf2, 0x55, 0x00, 0x8f, 0x65, 0x6d, 0x4b, 0xd0,
639                 0xcb, 0xd4, 0xd2, 0x0b, 0xea, 0xf4, 0xb0, 0x85,
640                 0x61, 0x9e, 0x36, 0xc0, 0x71, 0xb7, 0x80, 0xad,
641                 0x40, 0x78, 0xb4, 0x70, 0x2b, 0xe8, 0x80, 0xc5,
642                 0x19, 0x35, 0x96, 0x55, 0x3b, 0x40, 0x03, 0xbb,
643                 0x9f, 0xa6, 0xc2, 0x82, 0x92, 0x04, 0xc3, 0xa6,
644                 0x96, 0xc4, 0x7f, 0x4c, 0x3e, 0x3c, 0x79, 0x82,
645                 0x88, 0x8b, 0x3f, 0x8b, 0xc5, 0x9f, 0x44, 0xbe,
646                 0x71, 0xe7, 0x09, 0xa2, 0x40, 0xa2, 0x23, 0x4e,
647                 0x9f, 0x31, 0xab, 0x6f, 0xdf, 0x59, 0x40, 0xe1,
648                 0x12, 0x15, 0x55, 0x4b, 0xea, 0x3f, 0xa1, 0x41,
649                 0x4f, 0xaf, 0xcd, 0x27, 0x2a, 0x61, 0xa1, 0x9e,
650                 0x82, 0x30, 0x05, 0x05, 0x55, 0xce, 0x99, 0xd3,
651                 0x8f, 0x3f, 0x86, 0x79, 0xdc, 0x9f, 0x33, 0x07,
652                 0x75, 0x26, 0xc8, 0x72, 0x81, 0x0f, 0x9b, 0xf7,
653                 0xb1, 0xfb, 0xd3, 0x91, 0x36, 0x08, 0xab, 0x26,
654                 0x70, 0x53, 0x0c, 0x99, 0xfd, 0xa9, 0x07, 0xb4,
655                 0xe9, 0xce, 0xc1, 0xd6, 0xd2, 0x2c, 0x71, 0x80,
656                 0xec, 0x59, 0x61, 0x0b, 0x24, 0xf0, 0x6d, 0x33,
657                 0x73, 0x45, 0x6e, 0x80, 0x03, 0x45, 0xf2, 0x76,
658                 0xa5, 0x8a, 0xc9, 0xcf, 0xaf, 0x4a, 0xed, 0x35,
659                 0xc0, 0x97, 0x52, 0xc5, 0x00, 0xdf, 0xef, 0xc7,
660                 0x9f, 0xf2, 0xe8, 0x15, 0x3e, 0xb3, 0x30, 0xe7,
661                 0x00, 0xd0, 0x4e, 0xeb, 0x79, 0xf6, 0xf6, 0xcf,
662                 0xf0, 0xe7, 0x61, 0xd5, 0x3d, 0x6a, 0x73, 0x9d
663 };
664
665 static const uint8_t AES_CBC_ciphertext_512B[] = {
666                 0xb4, 0xc6, 0xc6, 0x5f, 0x7e, 0xca, 0x05, 0x70,
667                 0x21, 0x7b, 0x92, 0x9e, 0x23, 0xe7, 0x92, 0xb8,
668                 0x27, 0x3d, 0x20, 0x29, 0x57, 0xfa, 0x1f, 0x26,
669                 0x0a, 0x04, 0x34, 0xa6, 0xf2, 0xdc, 0x44, 0xb6,
670                 0x43, 0x40, 0x62, 0xde, 0x0c, 0xde, 0x1c, 0x30,
671                 0x43, 0x85, 0x0b, 0xe8, 0x93, 0x1f, 0xa1, 0x2a,
672                 0x8a, 0x27, 0x35, 0x39, 0x14, 0x9f, 0x37, 0x64,
673                 0x59, 0xb5, 0x0e, 0x96, 0x82, 0x5d, 0x63, 0x45,
674                 0xd6, 0x93, 0x89, 0x46, 0xe4, 0x71, 0x31, 0xeb,
675                 0x0e, 0xd1, 0x7b, 0xda, 0x90, 0xb5, 0x81, 0xac,
676                 0x76, 0x54, 0x54, 0x85, 0x0b, 0xa9, 0x46, 0x9c,
677                 0xf0, 0xfd, 0xde, 0x5d, 0xa8, 0xe3, 0xee, 0xe9,
678                 0xf4, 0x9d, 0x34, 0x76, 0x39, 0xe7, 0xc3, 0x4a,
679                 0x84, 0x38, 0x92, 0x61, 0xf1, 0x12, 0x9f, 0x05,
680                 0xda, 0xdb, 0xc1, 0xd4, 0xb0, 0xa0, 0x27, 0x19,
681                 0xa0, 0x56, 0x5d, 0x9b, 0xcc, 0x47, 0x7c, 0x15,
682                 0x1d, 0x52, 0x66, 0xd5, 0xff, 0xef, 0x12, 0x23,
683                 0x86, 0xe2, 0xee, 0x81, 0x2c, 0x3d, 0x7d, 0x28,
684                 0xd5, 0x42, 0xdf, 0xdb, 0x75, 0x1c, 0xeb, 0xdf,
685                 0x13, 0x23, 0xd5, 0x17, 0x89, 0xea, 0xd7, 0x01,
686                 0xff, 0x57, 0x6a, 0x44, 0x61, 0xf4, 0xea, 0xbe,
687                 0x97, 0x9b, 0xc2, 0xb1, 0x9c, 0x5d, 0xff, 0x4f,
688                 0x73, 0x2d, 0x3f, 0x57, 0x28, 0x38, 0xbf, 0x3d,
689                 0x9f, 0xda, 0x49, 0x55, 0x8f, 0xb2, 0x77, 0xec,
690                 0x0f, 0xbc, 0xce, 0xb8, 0xc6, 0xe1, 0x03, 0xed,
691                 0x35, 0x9c, 0xf2, 0x4d, 0xa4, 0x29, 0x6c, 0xd6,
692                 0x6e, 0x05, 0x53, 0x46, 0xc1, 0x41, 0x09, 0x36,
693                 0x0b, 0x7d, 0xf4, 0x9e, 0x0f, 0xba, 0x86, 0x33,
694                 0xdd, 0xf1, 0xa7, 0xf7, 0xd5, 0x29, 0xa8, 0xa7,
695                 0x4d, 0xce, 0x0c, 0xf5, 0xb4, 0x6c, 0xd8, 0x27,
696                 0xb0, 0x87, 0x2a, 0x6f, 0x7f, 0x3f, 0x8f, 0xc3,
697                 0xe2, 0x3e, 0x94, 0xcf, 0x61, 0x4a, 0x09, 0x3d,
698                 0xf9, 0x55, 0x19, 0x31, 0xf2, 0xd2, 0x4a, 0x3e,
699                 0xc1, 0xf5, 0xed, 0x7c, 0x45, 0xb0, 0x0c, 0x7b,
700                 0xdd, 0xa6, 0x0a, 0x26, 0x66, 0xec, 0x85, 0x49,
701                 0x00, 0x38, 0x05, 0x7c, 0x9c, 0x1c, 0x92, 0xf5,
702                 0xf7, 0xdb, 0x5d, 0xbd, 0x61, 0x0c, 0xc9, 0xaf,
703                 0xfd, 0x57, 0x3f, 0xee, 0x2b, 0xad, 0x73, 0xef,
704                 0xa3, 0xc1, 0x66, 0x26, 0x44, 0x5e, 0xf9, 0x12,
705                 0x86, 0x66, 0xa9, 0x61, 0x75, 0xa1, 0xbc, 0x40,
706                 0x7f, 0xa8, 0x08, 0x02, 0xc0, 0x76, 0x0e, 0x76,
707                 0xb3, 0x26, 0x3d, 0x1c, 0x40, 0x65, 0xe4, 0x18,
708                 0x0f, 0x62, 0x17, 0x8f, 0x1e, 0x61, 0xb8, 0x08,
709                 0x83, 0x54, 0x42, 0x11, 0x03, 0x30, 0x8e, 0xb7,
710                 0xc1, 0x9c, 0xec, 0x69, 0x52, 0x95, 0xfb, 0x7b,
711                 0x1a, 0x0c, 0x20, 0x24, 0xf7, 0xb8, 0x38, 0x0c,
712                 0xb8, 0x7b, 0xb6, 0x69, 0x70, 0xd0, 0x61, 0xb9,
713                 0x70, 0x06, 0xc2, 0x5b, 0x20, 0x47, 0xf7, 0xd9,
714                 0x32, 0xc2, 0xf2, 0x90, 0xb6, 0x4d, 0xcd, 0x3c,
715                 0x6d, 0x74, 0xea, 0x82, 0x35, 0x1b, 0x08, 0x44,
716                 0xba, 0xb7, 0x33, 0x82, 0x33, 0x27, 0x54, 0x77,
717                 0x6e, 0x58, 0xfe, 0x46, 0x5a, 0xb4, 0x88, 0x53,
718                 0x8d, 0x9b, 0xb1, 0xab, 0xdf, 0x04, 0xe1, 0xfb,
719                 0xd7, 0x1e, 0xd7, 0x38, 0x64, 0x54, 0xba, 0xb0,
720                 0x6c, 0x84, 0x7a, 0x0f, 0xa7, 0x80, 0x6b, 0x86,
721                 0xd9, 0xc9, 0xc6, 0x31, 0x95, 0xfa, 0x8a, 0x2c,
722                 0x14, 0xe1, 0x85, 0x66, 0x27, 0xfd, 0x63, 0x3e,
723                 0xf0, 0xfa, 0x81, 0xc9, 0x89, 0x4f, 0xe2, 0x6a,
724                 0x8c, 0x17, 0xb5, 0xc7, 0x9f, 0x5d, 0x3f, 0x6b,
725                 0x3f, 0xcd, 0x13, 0x7a, 0x3c, 0xe6, 0x4e, 0xfa,
726                 0x7a, 0x10, 0xb8, 0x7c, 0x40, 0xec, 0x93, 0x11,
727                 0x1f, 0xd0, 0x9e, 0xc3, 0x56, 0xb9, 0xf5, 0x21,
728                 0x18, 0x41, 0x31, 0xea, 0x01, 0x8d, 0xea, 0x1c,
729                 0x95, 0x5e, 0x56, 0x33, 0xbc, 0x7a, 0x3f, 0x6f
730 };
731
732 static const uint8_t AES_CBC_ciphertext_768B[] = {
733                 0x3e, 0x7f, 0x9e, 0x4c, 0x88, 0x15, 0x68, 0x69,
734                 0x10, 0x09, 0xe1, 0xa7, 0x0f, 0x27, 0x88, 0x2d,
735                 0x90, 0x73, 0x4f, 0x67, 0xd3, 0x8b, 0xaf, 0xa1,
736                 0x2c, 0x37, 0xa5, 0x6c, 0x7c, 0xbd, 0x95, 0x4c,
737                 0x82, 0xcf, 0x05, 0x49, 0x16, 0x5c, 0xe7, 0x06,
738                 0xd4, 0xcb, 0x55, 0x65, 0x9a, 0xd0, 0xe1, 0x46,
739                 0x3a, 0x37, 0x71, 0xad, 0xb0, 0xb4, 0x99, 0x1e,
740                 0x23, 0x57, 0x48, 0x96, 0x9c, 0xc5, 0xc4, 0xdb,
741                 0x64, 0x3e, 0xc9, 0x7f, 0x90, 0x5a, 0xa0, 0x08,
742                 0x75, 0x4c, 0x09, 0x06, 0x31, 0x6e, 0x59, 0x29,
743                 0xfc, 0x2f, 0x72, 0xde, 0xf2, 0x40, 0x5a, 0xfe,
744                 0xd3, 0x66, 0x64, 0xb8, 0x9c, 0xc9, 0xa6, 0x1f,
745                 0xc3, 0x52, 0xcd, 0xb5, 0xd1, 0x4f, 0x43, 0x3f,
746                 0xf4, 0x59, 0x25, 0xc4, 0xdd, 0x3e, 0x58, 0x7c,
747                 0x21, 0xd6, 0x21, 0xce, 0xa4, 0xbe, 0x08, 0x23,
748                 0x46, 0x68, 0xc0, 0x00, 0x91, 0x47, 0xca, 0x9b,
749                 0xe0, 0xb4, 0xe3, 0xab, 0xbf, 0xcf, 0x68, 0x26,
750                 0x97, 0x23, 0x09, 0x93, 0x64, 0x8f, 0x57, 0x59,
751                 0xe2, 0x41, 0x7c, 0xa2, 0x48, 0x7e, 0xd5, 0x2c,
752                 0x54, 0x09, 0x1b, 0x07, 0x94, 0xca, 0x39, 0x83,
753                 0xdd, 0xf4, 0x7a, 0x1d, 0x2d, 0xdd, 0x67, 0xf7,
754                 0x3c, 0x30, 0x89, 0x3e, 0xc1, 0xdc, 0x1d, 0x8f,
755                 0xfc, 0xb1, 0xe9, 0x13, 0x31, 0xb0, 0x16, 0xdb,
756                 0x88, 0xf2, 0x32, 0x7e, 0x73, 0xa3, 0xdf, 0x08,
757                 0x6b, 0x53, 0x92, 0x08, 0xc9, 0x9d, 0x98, 0xb2,
758                 0xf4, 0x8c, 0xb1, 0x95, 0xdc, 0xb6, 0xfc, 0xec,
759                 0xf1, 0xc9, 0x0d, 0x6d, 0x42, 0x2c, 0xf5, 0x38,
760                 0x29, 0xf4, 0xd8, 0x98, 0x0f, 0xb0, 0x81, 0xa5,
761                 0xaa, 0xe6, 0x1f, 0x6e, 0x87, 0x32, 0x1b, 0x02,
762                 0x07, 0x57, 0x38, 0x83, 0xf3, 0xe4, 0x54, 0x7c,
763                 0xa8, 0x43, 0xdf, 0x3f, 0x42, 0xfd, 0x67, 0x28,
764                 0x06, 0x4d, 0xea, 0xce, 0x1f, 0x84, 0x4a, 0xcd,
765                 0x8c, 0x61, 0x5e, 0x8f, 0x61, 0xed, 0x84, 0x03,
766                 0x53, 0x6a, 0x9e, 0xbf, 0x68, 0x83, 0xa7, 0x42,
767                 0x56, 0x57, 0xcd, 0x45, 0x29, 0xfc, 0x7b, 0x07,
768                 0xfc, 0xe9, 0xb9, 0x42, 0xfd, 0x29, 0xd5, 0xfd,
769                 0x98, 0x11, 0xd1, 0x8d, 0x67, 0x29, 0x47, 0x61,
770                 0xd8, 0x27, 0x37, 0x79, 0x29, 0xd1, 0x94, 0x6f,
771                 0x8d, 0xf3, 0x1b, 0x3d, 0x6a, 0xb1, 0x59, 0xef,
772                 0x1b, 0xd4, 0x70, 0x0e, 0xac, 0xab, 0xa0, 0x2b,
773                 0x1f, 0x5e, 0x04, 0xf0, 0x0e, 0x35, 0x72, 0x90,
774                 0xfc, 0xcf, 0x86, 0x43, 0xea, 0x45, 0x6d, 0x22,
775                 0x63, 0x06, 0x1a, 0x58, 0xd7, 0x2d, 0xc5, 0xb0,
776                 0x60, 0x69, 0xe8, 0x53, 0xc2, 0xa2, 0x57, 0x83,
777                 0xc4, 0x31, 0xb4, 0xc6, 0xb3, 0xa1, 0x77, 0xb3,
778                 0x1c, 0xca, 0x89, 0x3f, 0xf5, 0x10, 0x3b, 0x36,
779                 0x31, 0x7d, 0x00, 0x46, 0x00, 0x92, 0xa0, 0xa0,
780                 0x34, 0xd8, 0x5e, 0x62, 0xa9, 0xe0, 0x23, 0x37,
781                 0x50, 0x85, 0xc7, 0x3a, 0x20, 0xa3, 0x98, 0xc0,
782                 0xac, 0x20, 0x06, 0x0f, 0x17, 0x3c, 0xfc, 0x43,
783                 0x8c, 0x9d, 0xec, 0xf5, 0x9a, 0x35, 0x96, 0xf7,
784                 0xb7, 0x4c, 0xf9, 0x69, 0xf8, 0xd4, 0x1e, 0x9e,
785                 0xf9, 0x7c, 0xc4, 0xd2, 0x11, 0x14, 0x41, 0xb9,
786                 0x89, 0xd6, 0x07, 0xd2, 0x37, 0x07, 0x5e, 0x5e,
787                 0xae, 0x60, 0xdc, 0xe4, 0xeb, 0x38, 0x48, 0x6d,
788                 0x95, 0x8d, 0x71, 0xf2, 0xba, 0xda, 0x5f, 0x08,
789                 0x9d, 0x4a, 0x0f, 0x56, 0x90, 0x64, 0xab, 0xb6,
790                 0x88, 0x22, 0xa8, 0x90, 0x1f, 0x76, 0x2c, 0x83,
791                 0x43, 0xce, 0x32, 0x55, 0x45, 0x84, 0x57, 0x43,
792                 0xf9, 0xa8, 0xd1, 0x4f, 0xe3, 0xc1, 0x72, 0x9c,
793                 0xeb, 0x64, 0xf7, 0xe4, 0x61, 0x2b, 0x93, 0xd1,
794                 0x1f, 0xbb, 0x5c, 0xff, 0xa1, 0x59, 0x69, 0xcf,
795                 0xf7, 0xaf, 0x58, 0x45, 0xd5, 0x3e, 0x98, 0x7d,
796                 0x26, 0x39, 0x5c, 0x75, 0x3c, 0x4a, 0xbf, 0x5e,
797                 0x12, 0x10, 0xb0, 0x93, 0x0f, 0x86, 0x82, 0xcf,
798                 0xb2, 0xec, 0x70, 0x5c, 0x0b, 0xad, 0x5d, 0x63,
799                 0x65, 0x32, 0xa6, 0x04, 0x58, 0x03, 0x91, 0x2b,
800                 0xdb, 0x8f, 0xd3, 0xa3, 0x2b, 0x3a, 0xf5, 0xa1,
801                 0x62, 0x6c, 0xb6, 0xf0, 0x13, 0x3b, 0x8c, 0x07,
802                 0x10, 0x82, 0xc9, 0x56, 0x24, 0x87, 0xfc, 0x56,
803                 0xe8, 0xef, 0x90, 0x8b, 0xd6, 0x48, 0xda, 0x53,
804                 0x04, 0x49, 0x41, 0xa4, 0x67, 0xe0, 0x33, 0x24,
805                 0x6b, 0x9c, 0x07, 0x55, 0x4c, 0x5d, 0xe9, 0x35,
806                 0xfa, 0xbd, 0xea, 0xa8, 0x3f, 0xe9, 0xf5, 0x20,
807                 0x5c, 0x60, 0x0f, 0x0d, 0x24, 0xcb, 0x1a, 0xd6,
808                 0xe8, 0x5c, 0xa8, 0x42, 0xae, 0xd0, 0xd2, 0xf2,
809                 0xa8, 0xbe, 0xea, 0x0f, 0x8d, 0xfb, 0x81, 0xa3,
810                 0xa4, 0xef, 0xb7, 0x3e, 0x91, 0xbd, 0x26, 0x0f,
811                 0x8e, 0xf1, 0xb2, 0xa5, 0x47, 0x06, 0xfa, 0x40,
812                 0x8b, 0x31, 0x7a, 0x5a, 0x74, 0x2a, 0x0a, 0x7c,
813                 0x62, 0x5d, 0x39, 0xa4, 0xae, 0x14, 0x85, 0x08,
814                 0x5b, 0x20, 0x85, 0xf1, 0x57, 0x6e, 0x71, 0x13,
815                 0x4e, 0x2b, 0x49, 0x87, 0x01, 0xdf, 0x37, 0xed,
816                 0x28, 0xee, 0x4d, 0xa1, 0xf4, 0xb3, 0x3b, 0xba,
817                 0x2d, 0xb3, 0x46, 0x17, 0x84, 0x80, 0x9d, 0xd7,
818                 0x93, 0x1f, 0x28, 0x7c, 0xf5, 0xf9, 0xd6, 0x85,
819                 0x8c, 0xa5, 0x44, 0xe9, 0x2c, 0x65, 0x51, 0x5f,
820                 0x53, 0x7a, 0x09, 0xd9, 0x30, 0x16, 0x95, 0x89,
821                 0x9c, 0x0b, 0xef, 0x90, 0x6d, 0x23, 0xd3, 0x48,
822                 0x57, 0x3b, 0x55, 0x69, 0x96, 0xfc, 0xf7, 0x52,
823                 0x92, 0x38, 0x36, 0xbf, 0xa9, 0x0a, 0xbb, 0x68,
824                 0x45, 0x08, 0x25, 0xee, 0x59, 0xfe, 0xee, 0xf2,
825                 0x2c, 0xd4, 0x5f, 0x78, 0x59, 0x0d, 0x90, 0xf1,
826                 0xd7, 0xe4, 0x39, 0x0e, 0x46, 0x36, 0xf5, 0x75,
827                 0x03, 0x3c, 0x28, 0xfb, 0xfa, 0x8f, 0xef, 0xc9,
828                 0x61, 0x00, 0x94, 0xc3, 0xd2, 0x0f, 0xd9, 0xda
829 };
830
831 static const uint8_t AES_CBC_ciphertext_1024B[] = {
832                 0x7d, 0x01, 0x7e, 0x2f, 0x92, 0xb3, 0xea, 0x72,
833                 0x4a, 0x3f, 0x10, 0xf9, 0x2b, 0xb0, 0xd5, 0xb9,
834                 0x19, 0x68, 0x94, 0xe9, 0x93, 0xe9, 0xd5, 0x26,
835                 0x20, 0x44, 0xe2, 0x47, 0x15, 0x8d, 0x75, 0x48,
836                 0x8e, 0xe4, 0x40, 0x81, 0xb5, 0x06, 0xa8, 0xb8,
837                 0x0e, 0x0f, 0x3b, 0xbc, 0x5b, 0xbe, 0x3b, 0xa2,
838                 0x2a, 0x0c, 0x48, 0x98, 0x19, 0xdf, 0xe9, 0x25,
839                 0x75, 0xab, 0x93, 0x44, 0xb1, 0x72, 0x70, 0xbb,
840                 0x20, 0xcf, 0x78, 0xe9, 0x4d, 0xc6, 0xa9, 0xa9,
841                 0x84, 0x78, 0xc5, 0xc0, 0xc4, 0xc9, 0x79, 0x1a,
842                 0xbc, 0x61, 0x25, 0x5f, 0xac, 0x01, 0x03, 0xb7,
843                 0xef, 0x07, 0xf2, 0x62, 0x98, 0xee, 0xe3, 0xad,
844                 0x94, 0x75, 0x30, 0x67, 0xb9, 0x15, 0x00, 0xe7,
845                 0x11, 0x32, 0x2e, 0x6b, 0x55, 0x9f, 0xac, 0x68,
846                 0xde, 0x61, 0x05, 0x80, 0x01, 0xf3, 0xad, 0xab,
847                 0xaf, 0x45, 0xe0, 0xf4, 0x68, 0x5c, 0xc0, 0x52,
848                 0x92, 0xc8, 0x21, 0xb6, 0xf5, 0x8a, 0x1d, 0xbb,
849                 0xfc, 0x4a, 0x11, 0x62, 0xa2, 0xc4, 0xf1, 0x2d,
850                 0x0e, 0xb2, 0xc7, 0x17, 0x34, 0xb4, 0x2a, 0x54,
851                 0x81, 0xc2, 0x1e, 0xcf, 0x51, 0x0a, 0x76, 0x54,
852                 0xf1, 0x48, 0x0d, 0x5c, 0xcd, 0x38, 0x3e, 0x38,
853                 0x3e, 0xf8, 0x46, 0x1d, 0x00, 0xf5, 0x62, 0xe1,
854                 0x5c, 0xb7, 0x8d, 0xce, 0xd0, 0x3f, 0xbb, 0x22,
855                 0xf1, 0xe5, 0xb1, 0xa0, 0x58, 0x5e, 0x3c, 0x0f,
856                 0x15, 0xd1, 0xac, 0x3e, 0xc7, 0x72, 0xc4, 0xde,
857                 0x8b, 0x95, 0x3e, 0x91, 0xf7, 0x1d, 0x04, 0x9a,
858                 0xc8, 0xe4, 0xbf, 0xd3, 0x22, 0xca, 0x4a, 0xdc,
859                 0xb6, 0x16, 0x79, 0x81, 0x75, 0x2f, 0x6b, 0xa7,
860                 0x04, 0x98, 0xa7, 0x4e, 0xc1, 0x19, 0x90, 0x33,
861                 0x33, 0x3c, 0x7f, 0xdd, 0xac, 0x09, 0x0c, 0xc3,
862                 0x91, 0x34, 0x74, 0xab, 0xa5, 0x35, 0x0a, 0x13,
863                 0xc3, 0x56, 0x67, 0x6d, 0x1a, 0x3e, 0xbf, 0x56,
864                 0x06, 0x67, 0x15, 0x5f, 0xfc, 0x8b, 0xa2, 0x3c,
865                 0x5e, 0xaf, 0x56, 0x1f, 0xe3, 0x2e, 0x9d, 0x0a,
866                 0xf9, 0x9b, 0xc7, 0xb5, 0x03, 0x1c, 0x68, 0x99,
867                 0xfa, 0x3c, 0x37, 0x59, 0xc1, 0xf7, 0x6a, 0x83,
868                 0x22, 0xee, 0xca, 0x7f, 0x7d, 0x49, 0xe6, 0x48,
869                 0x84, 0x54, 0x7a, 0xff, 0xb3, 0x72, 0x21, 0xd8,
870                 0x7a, 0x5d, 0xb1, 0x4b, 0xcc, 0x01, 0x6f, 0x90,
871                 0xc6, 0x68, 0x1c, 0x2c, 0xa1, 0xe2, 0x74, 0x40,
872                 0x26, 0x9b, 0x57, 0x53, 0xa3, 0x7c, 0x0b, 0x0d,
873                 0xcf, 0x05, 0x5d, 0x62, 0x4f, 0x75, 0x06, 0x62,
874                 0x1f, 0x26, 0x32, 0xaa, 0x25, 0xcc, 0x26, 0x8d,
875                 0xae, 0x01, 0x47, 0xa3, 0x00, 0x42, 0xe2, 0x4c,
876                 0xee, 0x29, 0xa2, 0x81, 0xa0, 0xfd, 0xeb, 0xff,
877                 0x9a, 0x66, 0x6e, 0x47, 0x5b, 0xab, 0x93, 0x5a,
878                 0x02, 0x6d, 0x6f, 0xf2, 0x6e, 0x02, 0x9d, 0xb1,
879                 0xab, 0x56, 0xdc, 0x8b, 0x9b, 0x17, 0xa8, 0xfb,
880                 0x87, 0x42, 0x7c, 0x91, 0x1e, 0x14, 0xc6, 0x6f,
881                 0xdc, 0xf0, 0x27, 0x30, 0xfa, 0x3f, 0xc4, 0xad,
882                 0x57, 0x85, 0xd2, 0xc9, 0x32, 0x2c, 0x13, 0xa6,
883                 0x04, 0x04, 0x50, 0x05, 0x2f, 0x72, 0xd9, 0x44,
884                 0x55, 0x6e, 0x93, 0x40, 0xed, 0x7e, 0xd4, 0x40,
885                 0x3e, 0x88, 0x3b, 0x8b, 0xb6, 0xeb, 0xc6, 0x5d,
886                 0x9c, 0x99, 0xa1, 0xcf, 0x30, 0xb2, 0xdc, 0x48,
887                 0x8a, 0x01, 0xa7, 0x61, 0x77, 0x50, 0x14, 0xf3,
888                 0x0c, 0x49, 0x53, 0xb3, 0xb4, 0xb4, 0x28, 0x41,
889                 0x4a, 0x2d, 0xd2, 0x4d, 0x2a, 0x30, 0x31, 0x83,
890                 0x03, 0x5e, 0xaa, 0xd3, 0xa3, 0xd1, 0xa1, 0xca,
891                 0x62, 0xf0, 0xe1, 0xf2, 0xff, 0xf0, 0x19, 0xa6,
892                 0xde, 0x22, 0x47, 0xb5, 0x28, 0x7d, 0xf7, 0x07,
893                 0x16, 0x0d, 0xb1, 0x55, 0x81, 0x95, 0xe5, 0x1d,
894                 0x4d, 0x78, 0xa9, 0x3e, 0xce, 0xe3, 0x1c, 0xf9,
895                 0x47, 0xc8, 0xec, 0xc5, 0xc5, 0x93, 0x4c, 0x34,
896                 0x20, 0x6b, 0xee, 0x9a, 0xe6, 0x86, 0x57, 0x58,
897                 0xd5, 0x58, 0xf1, 0x33, 0x10, 0x29, 0x9e, 0x93,
898                 0x2f, 0xf5, 0x90, 0x00, 0x17, 0x67, 0x4f, 0x39,
899                 0x18, 0xe1, 0xcf, 0x55, 0x78, 0xbb, 0xe6, 0x29,
900                 0x3e, 0x77, 0xd5, 0x48, 0xb7, 0x42, 0x72, 0x53,
901                 0x27, 0xfa, 0x5b, 0xe0, 0x36, 0x14, 0x97, 0xb8,
902                 0x9b, 0x3c, 0x09, 0x77, 0xc1, 0x0a, 0xe4, 0xa2,
903                 0x63, 0xfc, 0xbe, 0x5c, 0x17, 0xcf, 0x01, 0xf5,
904                 0x03, 0x0f, 0x17, 0xbc, 0x93, 0xdd, 0x5f, 0xe2,
905                 0xf3, 0x08, 0xa8, 0xb1, 0x85, 0xb6, 0x34, 0x3f,
906                 0x87, 0x42, 0xa5, 0x42, 0x3b, 0x0e, 0xd6, 0x83,
907                 0x6a, 0xfd, 0x5d, 0xc9, 0x67, 0xd5, 0x51, 0xc9,
908                 0x2a, 0x4e, 0x91, 0xb0, 0x59, 0xb2, 0x0f, 0xa2,
909                 0xe6, 0x47, 0x73, 0xc2, 0xa2, 0xae, 0xbb, 0xc8,
910                 0x42, 0xa3, 0x2a, 0x27, 0x29, 0x48, 0x8c, 0x54,
911                 0x6c, 0xec, 0x00, 0x2a, 0x42, 0xa3, 0x7a, 0x0f,
912                 0x12, 0x66, 0x6b, 0x96, 0xf6, 0xd0, 0x56, 0x4f,
913                 0x49, 0x5c, 0x47, 0xec, 0x05, 0x62, 0x54, 0xb2,
914                 0x64, 0x5a, 0x69, 0x1f, 0x19, 0xb4, 0x84, 0x5c,
915                 0xbe, 0x48, 0x8e, 0xfc, 0x58, 0x21, 0xce, 0xfa,
916                 0xaa, 0x84, 0xd2, 0xc1, 0x08, 0xb3, 0x87, 0x0f,
917                 0x4f, 0xa3, 0x3a, 0xb6, 0x44, 0xbe, 0x2e, 0x9a,
918                 0xdd, 0xb5, 0x44, 0x80, 0xca, 0xf4, 0xc3, 0x6e,
919                 0xba, 0x93, 0x77, 0xe0, 0x53, 0xfb, 0x37, 0xfb,
920                 0x88, 0xc3, 0x1f, 0x25, 0xde, 0x3e, 0x11, 0xf4,
921                 0x89, 0xe7, 0xd1, 0x3b, 0xb4, 0x23, 0xcb, 0x70,
922                 0xba, 0x35, 0x97, 0x7c, 0xbe, 0x84, 0x13, 0xcf,
923                 0xe0, 0x4d, 0x33, 0x91, 0x71, 0x85, 0xbb, 0x4b,
924                 0x97, 0x32, 0x5d, 0xa0, 0xb9, 0x8f, 0xdc, 0x27,
925                 0x5a, 0xeb, 0x71, 0xf1, 0xd5, 0x0d, 0x65, 0xb4,
926                 0x22, 0x81, 0xde, 0xa7, 0x58, 0x20, 0x0b, 0x18,
927                 0x11, 0x76, 0x5c, 0xe6, 0x6a, 0x2c, 0x99, 0x69,
928                 0xdc, 0xed, 0x67, 0x08, 0x5d, 0x5e, 0xe9, 0x1e,
929                 0x55, 0x70, 0xc1, 0x5a, 0x76, 0x1b, 0x8d, 0x2e,
930                 0x0d, 0xf9, 0xcc, 0x30, 0x8c, 0x44, 0x0f, 0x63,
931                 0x8c, 0x42, 0x8a, 0x9f, 0x4c, 0xd1, 0x48, 0x28,
932                 0x8a, 0xf5, 0x56, 0x2e, 0x23, 0x12, 0xfe, 0x67,
933                 0x9a, 0x13, 0x65, 0x75, 0x83, 0xf1, 0x3c, 0x98,
934                 0x07, 0x6b, 0xb7, 0x27, 0x5b, 0xf0, 0x70, 0xda,
935                 0x30, 0xf8, 0x74, 0x4e, 0x7a, 0x32, 0x84, 0xcc,
936                 0x0e, 0xcd, 0x80, 0x8b, 0x82, 0x31, 0x9a, 0x48,
937                 0xcf, 0x75, 0x00, 0x1f, 0x4f, 0xe0, 0x8e, 0xa3,
938                 0x6a, 0x2c, 0xd4, 0x73, 0x4c, 0x63, 0x7c, 0xa6,
939                 0x4d, 0x5e, 0xfd, 0x43, 0x3b, 0x27, 0xe1, 0x5e,
940                 0xa3, 0xa9, 0x5c, 0x3b, 0x60, 0xdd, 0xc6, 0x8d,
941                 0x5a, 0xf1, 0x3e, 0x89, 0x4b, 0x24, 0xcf, 0x01,
942                 0x3a, 0x2d, 0x44, 0xe7, 0xda, 0xe7, 0xa1, 0xac,
943                 0x11, 0x05, 0x0c, 0xa9, 0x7a, 0x82, 0x8c, 0x5c,
944                 0x29, 0x68, 0x9c, 0x73, 0x13, 0xcc, 0x67, 0x32,
945                 0x11, 0x5e, 0xe5, 0xcc, 0x8c, 0xf5, 0xa7, 0x52,
946                 0x83, 0x9a, 0x70, 0xef, 0xde, 0x55, 0x9c, 0xc7,
947                 0x8a, 0xed, 0xad, 0x28, 0x4a, 0xc5, 0x92, 0x6d,
948                 0x8e, 0x47, 0xca, 0xe3, 0xf8, 0x77, 0xb5, 0x26,
949                 0x64, 0x84, 0xc2, 0xf1, 0xd7, 0xae, 0x0c, 0xb9,
950                 0x39, 0x0f, 0x43, 0x6b, 0xe9, 0xe0, 0x09, 0x4b,
951                 0xe5, 0xe3, 0x17, 0xa6, 0x68, 0x69, 0x46, 0xf4,
952                 0xf0, 0x68, 0x7f, 0x2f, 0x1c, 0x7e, 0x4c, 0xd2,
953                 0xb5, 0xc6, 0x16, 0x85, 0xcf, 0x02, 0x4c, 0x89,
954                 0x0b, 0x25, 0xb0, 0xeb, 0xf3, 0x77, 0x08, 0x6a,
955                 0x46, 0x5c, 0xf6, 0x2f, 0xf1, 0x24, 0xc3, 0x4d,
956                 0x80, 0x60, 0x4d, 0x69, 0x98, 0xde, 0xc7, 0xa1,
957                 0xf6, 0x4e, 0x18, 0x0c, 0x2a, 0xb0, 0xb2, 0xe0,
958                 0x46, 0xe7, 0x49, 0x37, 0xc8, 0x5a, 0x23, 0x24,
959                 0xe3, 0x0f, 0xcc, 0x92, 0xb4, 0x8d, 0xdc, 0x9e
960 };
961
962 static const uint8_t AES_CBC_ciphertext_1280B[] = {
963                 0x91, 0x99, 0x5e, 0x9e, 0x84, 0xff, 0x59, 0x45,
964                 0xc1, 0xf4, 0xbc, 0x9c, 0xb9, 0x30, 0x6c, 0x51,
965                 0x73, 0x52, 0xb4, 0x44, 0x09, 0x79, 0xe2, 0x89,
966                 0x75, 0xeb, 0x54, 0x26, 0xce, 0xd8, 0x24, 0x98,
967                 0xaa, 0xf8, 0x13, 0x16, 0x68, 0x58, 0xc4, 0x82,
968                 0x0e, 0x31, 0xd3, 0x6a, 0x13, 0x58, 0x31, 0xe9,
969                 0x3a, 0xc1, 0x8b, 0xc5, 0x3f, 0x50, 0x42, 0xd1,
970                 0x93, 0xe4, 0x9b, 0x65, 0x2b, 0xf4, 0x1d, 0x9e,
971                 0x2d, 0xdb, 0x48, 0xef, 0x9a, 0x01, 0x68, 0xb6,
972                 0xea, 0x7a, 0x2b, 0xad, 0xfe, 0x77, 0x44, 0x7e,
973                 0x5a, 0xc5, 0x64, 0xb4, 0xfe, 0x5c, 0x80, 0xf3,
974                 0x20, 0x7e, 0xaf, 0x5b, 0xf8, 0xd1, 0x38, 0xa0,
975                 0x8d, 0x09, 0x77, 0x06, 0xfe, 0xf5, 0xf4, 0xe4,
976                 0xee, 0xb8, 0x95, 0x27, 0xed, 0x07, 0xb8, 0xaa,
977                 0x25, 0xb4, 0xe1, 0x4c, 0xeb, 0x3f, 0xdb, 0x39,
978                 0x66, 0x28, 0x1b, 0x60, 0x42, 0x8b, 0x99, 0xd9,
979                 0x49, 0xd6, 0x8c, 0xa4, 0x9d, 0xd8, 0x93, 0x58,
980                 0x8f, 0xfa, 0xd3, 0xf7, 0x37, 0x9c, 0x88, 0xab,
981                 0x16, 0x50, 0xfe, 0x01, 0x1f, 0x88, 0x48, 0xbe,
982                 0x21, 0xa9, 0x90, 0x9e, 0x73, 0xe9, 0x82, 0xf7,
983                 0xbf, 0x4b, 0x43, 0xf4, 0xbf, 0x22, 0x3c, 0x45,
984                 0x47, 0x95, 0x5b, 0x49, 0x71, 0x07, 0x1c, 0x8b,
985                 0x49, 0xa4, 0xa3, 0x49, 0xc4, 0x5f, 0xb1, 0xf5,
986                 0xe3, 0x6b, 0xf1, 0xdc, 0xea, 0x92, 0x7b, 0x29,
987                 0x40, 0xc9, 0x39, 0x5f, 0xdb, 0xbd, 0xf3, 0x6a,
988                 0x09, 0x9b, 0x2a, 0x5e, 0xc7, 0x0b, 0x25, 0x94,
989                 0x55, 0x71, 0x9c, 0x7e, 0x0e, 0xb4, 0x08, 0x12,
990                 0x8c, 0x6e, 0x77, 0xb8, 0x29, 0xf1, 0xc6, 0x71,
991                 0x04, 0x40, 0x77, 0x18, 0x3f, 0x01, 0x09, 0x9c,
992                 0x23, 0x2b, 0x5d, 0x2a, 0x88, 0x20, 0x23, 0x59,
993                 0x74, 0x2a, 0x67, 0x8f, 0xb7, 0xba, 0x38, 0x9f,
994                 0x0f, 0xcf, 0x94, 0xdf, 0xe1, 0x8f, 0x35, 0x5e,
995                 0x34, 0x0c, 0x32, 0x92, 0x2b, 0x23, 0x81, 0xf4,
996                 0x73, 0xa0, 0x5a, 0x2a, 0xbd, 0xa6, 0x6b, 0xae,
997                 0x43, 0xe2, 0xdc, 0x01, 0xc1, 0xc6, 0xc3, 0x04,
998                 0x06, 0xbb, 0xb0, 0x89, 0xb3, 0x4e, 0xbd, 0x81,
999                 0x1b, 0x03, 0x63, 0x93, 0xed, 0x4e, 0xf6, 0xe5,
1000                 0x94, 0x6f, 0xd6, 0xf3, 0x20, 0xf3, 0xbc, 0x30,
1001                 0xc5, 0xd6, 0xbe, 0x1c, 0x05, 0x34, 0x26, 0x4d,
1002                 0x46, 0x5e, 0x56, 0x63, 0xfb, 0xdb, 0xcd, 0xed,
1003                 0xb0, 0x7f, 0x83, 0x94, 0x55, 0x54, 0x2f, 0xab,
1004                 0xc9, 0xb7, 0x16, 0x4f, 0x9e, 0x93, 0x25, 0xd7,
1005                 0x9f, 0x39, 0x2b, 0x63, 0xcf, 0x1e, 0xa3, 0x0e,
1006                 0x28, 0x47, 0x8a, 0x5f, 0x40, 0x02, 0x89, 0x1f,
1007                 0x83, 0xe7, 0x87, 0xd1, 0x90, 0x17, 0xb8, 0x27,
1008                 0x64, 0xe1, 0xe1, 0x48, 0x5a, 0x55, 0x74, 0x99,
1009                 0x27, 0x9d, 0x05, 0x67, 0xda, 0x70, 0x12, 0x8f,
1010                 0x94, 0x96, 0xfd, 0x36, 0xa4, 0x1d, 0x22, 0xe5,
1011                 0x0b, 0xe5, 0x2f, 0x38, 0x55, 0xa3, 0x5d, 0x0b,
1012                 0xcf, 0xd4, 0xa9, 0xb8, 0xd6, 0x9a, 0x16, 0x2e,
1013                 0x6c, 0x4a, 0x25, 0x51, 0x7a, 0x09, 0x48, 0xdd,
1014                 0xf0, 0xa3, 0x5b, 0x08, 0x1e, 0x2f, 0x03, 0x91,
1015                 0x80, 0xe8, 0x0f, 0xe9, 0x5a, 0x2f, 0x90, 0xd3,
1016                 0x64, 0xed, 0xd7, 0x51, 0x17, 0x66, 0x53, 0x40,
1017                 0x43, 0x74, 0xef, 0x0a, 0x0d, 0x49, 0x41, 0xf2,
1018                 0x67, 0x6e, 0xea, 0x14, 0xc8, 0x74, 0xd6, 0xa9,
1019                 0xb9, 0x6a, 0xe3, 0xec, 0x7d, 0xe8, 0x6a, 0x21,
1020                 0x3a, 0x52, 0x42, 0xfe, 0x9a, 0x15, 0x6d, 0x60,
1021                 0x64, 0x88, 0xc5, 0xb2, 0x8b, 0x15, 0x2c, 0xff,
1022                 0xe2, 0x35, 0xc3, 0xee, 0x9f, 0xcd, 0x82, 0xd9,
1023                 0x14, 0x35, 0x2a, 0xb7, 0xf5, 0x2f, 0x7b, 0xbc,
1024                 0x01, 0xfd, 0xa8, 0xe0, 0x21, 0x4e, 0x73, 0xf9,
1025                 0xf2, 0xb0, 0x79, 0xc9, 0x10, 0x52, 0x8f, 0xa8,
1026                 0x3e, 0x3b, 0xbe, 0xc5, 0xde, 0xf6, 0x53, 0xe3,
1027                 0x1c, 0x25, 0x3a, 0x1f, 0x13, 0xbf, 0x13, 0xbb,
1028                 0x94, 0xc2, 0x97, 0x43, 0x64, 0x47, 0x8f, 0x76,
1029                 0xd7, 0xaa, 0xeb, 0xa4, 0x03, 0x50, 0x0c, 0x10,
1030                 0x50, 0xd8, 0xf7, 0x75, 0x52, 0x42, 0xe2, 0x94,
1031                 0x67, 0xf4, 0x60, 0xfb, 0x21, 0x9b, 0x7a, 0x05,
1032                 0x50, 0x7c, 0x1b, 0x4a, 0x8b, 0x29, 0xe1, 0xac,
1033                 0xd7, 0x99, 0xfd, 0x0d, 0x65, 0x92, 0xcd, 0x23,
1034                 0xa7, 0x35, 0x8e, 0x13, 0xf2, 0xe4, 0x10, 0x74,
1035                 0xc6, 0x4f, 0x19, 0xf7, 0x01, 0x0b, 0x46, 0xab,
1036                 0xef, 0x8d, 0x4a, 0x4a, 0xfa, 0xda, 0xf3, 0xfb,
1037                 0x40, 0x28, 0x88, 0xa2, 0x65, 0x98, 0x4d, 0x88,
1038                 0xc7, 0xbf, 0x00, 0xc8, 0xd0, 0x91, 0xcb, 0x89,
1039                 0x2f, 0xb0, 0x85, 0xfc, 0xa1, 0xc1, 0x9e, 0x83,
1040                 0x88, 0xad, 0x95, 0xc0, 0x31, 0xa0, 0xad, 0xa2,
1041                 0x42, 0xb5, 0xe7, 0x55, 0xd4, 0x93, 0x5a, 0x74,
1042                 0x4e, 0x41, 0xc3, 0xcf, 0x96, 0x83, 0x46, 0xa1,
1043                 0xb7, 0x5b, 0xb1, 0x34, 0x67, 0x4e, 0xb1, 0xd7,
1044                 0x40, 0x20, 0x72, 0xe9, 0xc8, 0x74, 0xb7, 0xde,
1045                 0x72, 0x29, 0x77, 0x4c, 0x74, 0x7e, 0xcc, 0x18,
1046                 0xa5, 0x8d, 0x79, 0x8c, 0xd6, 0x6e, 0xcb, 0xd9,
1047                 0xe1, 0x61, 0xe7, 0x36, 0xbc, 0x37, 0xea, 0xee,
1048                 0xd8, 0x3c, 0x5e, 0x7c, 0x47, 0x50, 0xd5, 0xec,
1049                 0x37, 0xc5, 0x63, 0xc3, 0xc9, 0x99, 0x23, 0x9f,
1050                 0x64, 0x39, 0xdf, 0x13, 0x96, 0x6d, 0xea, 0x08,
1051                 0x0c, 0x27, 0x2d, 0xfe, 0x0f, 0xc2, 0xa3, 0x97,
1052                 0x04, 0x12, 0x66, 0x0d, 0x94, 0xbf, 0xbe, 0x3e,
1053                 0xb9, 0xcf, 0x8e, 0xc1, 0x9d, 0xb1, 0x64, 0x17,
1054                 0x54, 0x92, 0x3f, 0x0a, 0x51, 0xc8, 0xf5, 0x82,
1055                 0x98, 0x73, 0x03, 0xc0, 0x5a, 0x51, 0x01, 0x67,
1056                 0xb4, 0x01, 0x04, 0x06, 0xbc, 0x37, 0xde, 0x96,
1057                 0x23, 0x3c, 0xce, 0x98, 0x3f, 0xd6, 0x51, 0x1b,
1058                 0x01, 0x83, 0x0a, 0x1c, 0xf9, 0xeb, 0x7e, 0x72,
1059                 0xa9, 0x51, 0x23, 0xc8, 0xd7, 0x2f, 0x12, 0xbc,
1060                 0x08, 0xac, 0x07, 0xe7, 0xa7, 0xe6, 0x46, 0xae,
1061                 0x54, 0xa3, 0xc2, 0xf2, 0x05, 0x2d, 0x06, 0x5e,
1062                 0xfc, 0xe2, 0xa2, 0x23, 0xac, 0x86, 0xf2, 0x54,
1063                 0x83, 0x4a, 0xb6, 0x48, 0x93, 0xa1, 0x78, 0xc2,
1064                 0x07, 0xec, 0x82, 0xf0, 0x74, 0xa9, 0x18, 0xe9,
1065                 0x53, 0x44, 0x49, 0xc2, 0x94, 0xf8, 0x94, 0x92,
1066                 0x08, 0x3f, 0xbf, 0xa6, 0xe5, 0xc6, 0x03, 0x8a,
1067                 0xc6, 0x90, 0x48, 0x6c, 0xee, 0xbd, 0x44, 0x92,
1068                 0x1f, 0x2a, 0xce, 0x1d, 0xb8, 0x31, 0xa2, 0x9d,
1069                 0x24, 0x93, 0xa8, 0x9f, 0x36, 0x00, 0x04, 0x7b,
1070                 0xcb, 0x93, 0x59, 0xa1, 0x53, 0xdb, 0x13, 0x7a,
1071                 0x54, 0xb1, 0x04, 0xdb, 0xce, 0x48, 0x4f, 0xe5,
1072                 0x2f, 0xcb, 0xdf, 0x8f, 0x50, 0x7c, 0xfc, 0x76,
1073                 0x80, 0xb4, 0xdc, 0x3b, 0xc8, 0x98, 0x95, 0xf5,
1074                 0x50, 0xba, 0x70, 0x5a, 0x97, 0xd5, 0xfc, 0x98,
1075                 0x4d, 0xf3, 0x61, 0x0f, 0xcf, 0xac, 0x49, 0x0a,
1076                 0xdb, 0xc1, 0x42, 0x8f, 0xb6, 0x29, 0xd5, 0x65,
1077                 0xef, 0x83, 0xf1, 0x30, 0x4b, 0x84, 0xd0, 0x69,
1078                 0xde, 0xd2, 0x99, 0xe5, 0xec, 0xd3, 0x90, 0x86,
1079                 0x39, 0x2a, 0x6e, 0xd5, 0x32, 0xe3, 0x0d, 0x2d,
1080                 0x01, 0x8b, 0x17, 0x55, 0x1d, 0x65, 0x57, 0xbf,
1081                 0xd8, 0x75, 0xa4, 0x85, 0xb6, 0x4e, 0x35, 0x14,
1082                 0x58, 0xe4, 0x89, 0xb8, 0x7a, 0x58, 0x86, 0x0c,
1083                 0xbd, 0x8b, 0x05, 0x7b, 0x63, 0xc0, 0x86, 0x80,
1084                 0x33, 0x46, 0xd4, 0x9b, 0xb6, 0x0a, 0xeb, 0x6c,
1085                 0xae, 0xd6, 0x57, 0x7a, 0xc7, 0x59, 0x33, 0xa0,
1086                 0xda, 0xa4, 0x12, 0xbf, 0x52, 0x22, 0x05, 0x8d,
1087                 0xeb, 0xee, 0xd5, 0xec, 0xea, 0x29, 0x9b, 0x76,
1088                 0x95, 0x50, 0x6d, 0x99, 0xe1, 0x45, 0x63, 0x09,
1089                 0x16, 0x5f, 0xb0, 0xf2, 0x5b, 0x08, 0x33, 0xdd,
1090                 0x8f, 0xb7, 0x60, 0x7a, 0x8e, 0xc6, 0xfc, 0xac,
1091                 0xa9, 0x56, 0x2c, 0xa9, 0x8b, 0x74, 0x33, 0xad,
1092                 0x2a, 0x7e, 0x96, 0xb6, 0xba, 0x22, 0x28, 0xcf,
1093                 0x4d, 0x96, 0xb7, 0xd1, 0xfa, 0x99, 0x4a, 0x61,
1094                 0xe6, 0x84, 0xd1, 0x94, 0xca, 0xf5, 0x86, 0xb0,
1095                 0xba, 0x34, 0x7a, 0x04, 0xcc, 0xd4, 0x81, 0xcd,
1096                 0xd9, 0x86, 0xb6, 0xe0, 0x5a, 0x6f, 0x9b, 0x99,
1097                 0xf0, 0xdf, 0x49, 0xae, 0x6d, 0xc2, 0x54, 0x67,
1098                 0xe0, 0xb4, 0x34, 0x2d, 0x1c, 0x46, 0xdf, 0x73,
1099                 0x3b, 0x45, 0x43, 0xe7, 0x1f, 0xa3, 0x36, 0x35,
1100                 0x25, 0x33, 0xd9, 0xc0, 0x54, 0x38, 0x6e, 0x6b,
1101                 0x80, 0xcf, 0x50, 0xa4, 0xb6, 0x21, 0x17, 0xfd,
1102                 0x9b, 0x5c, 0x36, 0xca, 0xcc, 0x73, 0x73, 0xad,
1103                 0xe0, 0x57, 0x77, 0x90, 0x0e, 0x7f, 0x0f, 0x87,
1104                 0x7f, 0xdb, 0x73, 0xbf, 0xda, 0xc2, 0xb3, 0x05,
1105                 0x22, 0x06, 0xf5, 0xa3, 0xfc, 0x1e, 0x8f, 0xda,
1106                 0xcf, 0x49, 0xd6, 0xb3, 0x66, 0x2c, 0xb5, 0x00,
1107                 0xaf, 0x85, 0x6e, 0xb8, 0x5b, 0x8c, 0xa1, 0xa4,
1108                 0x21, 0xce, 0x40, 0xf3, 0x98, 0xac, 0xec, 0x88,
1109                 0x62, 0x43, 0x2a, 0xac, 0xca, 0xcf, 0xb9, 0x30,
1110                 0xeb, 0xfc, 0xef, 0xf0, 0x6e, 0x64, 0x6d, 0xe7,
1111                 0x54, 0x88, 0x6b, 0x22, 0x29, 0xbe, 0xa5, 0x8c,
1112                 0x31, 0x23, 0x3b, 0x4a, 0x80, 0x37, 0xe6, 0xd0,
1113                 0x05, 0xfc, 0x10, 0x0e, 0xdd, 0xbb, 0x00, 0xc5,
1114                 0x07, 0x20, 0x59, 0xd3, 0x41, 0x17, 0x86, 0x46,
1115                 0xab, 0x68, 0xf6, 0x48, 0x3c, 0xea, 0x5a, 0x06,
1116                 0x30, 0x21, 0x19, 0xed, 0x74, 0xbe, 0x0b, 0x97,
1117                 0xee, 0x91, 0x35, 0x94, 0x1f, 0xcb, 0x68, 0x7f,
1118                 0xe4, 0x48, 0xb0, 0x16, 0xfb, 0xf0, 0x74, 0xdb,
1119                 0x06, 0x59, 0x2e, 0x5a, 0x9c, 0xce, 0x8f, 0x7d,
1120                 0xba, 0x48, 0xd5, 0x3f, 0x5c, 0xb0, 0xc2, 0x33,
1121                 0x48, 0x60, 0x17, 0x08, 0x85, 0xba, 0xff, 0xb9,
1122                 0x34, 0x0a, 0x3d, 0x8f, 0x21, 0x13, 0x12, 0x1b
1123 };
1124
1125 static const uint8_t AES_CBC_ciphertext_1536B[] = {
1126                 0x89, 0x93, 0x05, 0x99, 0xa9, 0xed, 0xea, 0x62,
1127                 0xc9, 0xda, 0x51, 0x15, 0xce, 0x42, 0x91, 0xc3,
1128                 0x80, 0xc8, 0x03, 0x88, 0xc2, 0x63, 0xda, 0x53,
1129                 0x1a, 0xf3, 0xeb, 0xd5, 0xba, 0x6f, 0x23, 0xb2,
1130                 0xed, 0x8f, 0x89, 0xb1, 0xb3, 0xca, 0x90, 0x7a,
1131                 0xdd, 0x3f, 0xf6, 0xca, 0x86, 0x58, 0x54, 0xbc,
1132                 0xab, 0x0f, 0xf4, 0xab, 0x6d, 0x5d, 0x42, 0xd0,
1133                 0x17, 0x49, 0x17, 0xd1, 0x93, 0xea, 0xe8, 0x22,
1134                 0xc1, 0x34, 0x9f, 0x3a, 0x3b, 0xaa, 0xe9, 0x1b,
1135                 0x93, 0xff, 0x6b, 0x68, 0xba, 0xe6, 0xd2, 0x39,
1136                 0x3d, 0x55, 0x34, 0x8f, 0x98, 0x86, 0xb4, 0xd8,
1137                 0x7c, 0x0d, 0x3e, 0x01, 0x63, 0x04, 0x01, 0xff,
1138                 0x16, 0x0f, 0x51, 0x5f, 0x73, 0x53, 0xf0, 0x3a,
1139                 0x38, 0xb4, 0x4d, 0x8d, 0xaf, 0xa3, 0xca, 0x2f,
1140                 0x6f, 0xdf, 0xc0, 0x41, 0x6c, 0x48, 0x60, 0x1a,
1141                 0xe4, 0xe7, 0x8a, 0x65, 0x6f, 0x8d, 0xd7, 0xe1,
1142                 0x10, 0xab, 0x78, 0x5b, 0xb9, 0x69, 0x1f, 0xe0,
1143                 0x5c, 0xf1, 0x19, 0x12, 0x21, 0xc7, 0x51, 0xbc,
1144                 0x61, 0x5f, 0xc0, 0x36, 0x17, 0xc0, 0x28, 0xd9,
1145                 0x51, 0xcb, 0x43, 0xd9, 0xfa, 0xd1, 0xad, 0x79,
1146                 0x69, 0x86, 0x49, 0xc5, 0xe5, 0x69, 0x27, 0xce,
1147                 0x22, 0xd0, 0xe1, 0x6a, 0xf9, 0x02, 0xca, 0x6c,
1148                 0x34, 0xc7, 0xb8, 0x02, 0xc1, 0x38, 0x7f, 0xd5,
1149                 0x15, 0xf5, 0xd6, 0xeb, 0xf9, 0x30, 0x40, 0x43,
1150                 0xea, 0x87, 0xde, 0x35, 0xf6, 0x83, 0x59, 0x09,
1151                 0x68, 0x62, 0x00, 0x87, 0xb8, 0xe7, 0xca, 0x05,
1152                 0x0f, 0xac, 0x42, 0x58, 0x45, 0xaa, 0xc9, 0x9b,
1153                 0xfd, 0x2a, 0xda, 0x65, 0x33, 0x93, 0x9d, 0xc6,
1154                 0x93, 0x8d, 0xe2, 0xc5, 0x71, 0xc1, 0x5c, 0x13,
1155                 0xde, 0x7b, 0xd4, 0xb9, 0x4c, 0x35, 0x61, 0x85,
1156                 0x90, 0x78, 0xf7, 0x81, 0x98, 0x45, 0x99, 0x24,
1157                 0x58, 0x73, 0x28, 0xf8, 0x31, 0xab, 0x54, 0x2e,
1158                 0xc0, 0x38, 0x77, 0x25, 0x5c, 0x06, 0x9c, 0xc3,
1159                 0x69, 0x21, 0x92, 0x76, 0xe1, 0x16, 0xdc, 0xa9,
1160                 0xee, 0xb6, 0x80, 0x66, 0x43, 0x11, 0x24, 0xb3,
1161                 0x07, 0x17, 0x89, 0x0f, 0xcb, 0xe0, 0x60, 0xa8,
1162                 0x9d, 0x06, 0x4b, 0x6e, 0x72, 0xb7, 0xbc, 0x4f,
1163                 0xb8, 0xc0, 0x80, 0xa2, 0xfb, 0x46, 0x5b, 0x8f,
1164                 0x11, 0x01, 0x92, 0x9d, 0x37, 0x09, 0x98, 0xc8,
1165                 0x0a, 0x46, 0xae, 0x12, 0xac, 0x61, 0x3f, 0xe7,
1166                 0x41, 0x1a, 0xaa, 0x2e, 0xdc, 0xd7, 0x2a, 0x47,
1167                 0xee, 0xdf, 0x08, 0xd1, 0xff, 0xea, 0x13, 0xc6,
1168                 0x05, 0xdb, 0x29, 0xcc, 0x03, 0xba, 0x7b, 0x6d,
1169                 0x40, 0xc1, 0xc9, 0x76, 0x75, 0x03, 0x7a, 0x71,
1170                 0xc9, 0x5f, 0xd9, 0xe0, 0x61, 0x69, 0x36, 0x8f,
1171                 0xb2, 0xbc, 0x28, 0xf3, 0x90, 0x71, 0xda, 0x5f,
1172                 0x08, 0xd5, 0x0d, 0xc1, 0xe6, 0xbd, 0x2b, 0xc6,
1173                 0x6c, 0x42, 0xfd, 0xbf, 0x10, 0xe8, 0x5f, 0x87,
1174                 0x3d, 0x21, 0x42, 0x85, 0x01, 0x0a, 0xbf, 0x8e,
1175                 0x49, 0xd3, 0x9c, 0x89, 0x3b, 0xea, 0xe1, 0xbf,
1176                 0xe9, 0x9b, 0x5e, 0x0e, 0xb8, 0xeb, 0xcd, 0x3a,
1177                 0xf6, 0x29, 0x41, 0x35, 0xdd, 0x9b, 0x13, 0x24,
1178                 0xe0, 0x1d, 0x8a, 0xcb, 0x20, 0xf8, 0x41, 0x51,
1179                 0x3e, 0x23, 0x8c, 0x67, 0x98, 0x39, 0x53, 0x77,
1180                 0x2a, 0x68, 0xf4, 0x3c, 0x7e, 0xd6, 0xc4, 0x6e,
1181                 0xf1, 0x53, 0xe9, 0xd8, 0x5c, 0xc1, 0xa9, 0x38,
1182                 0x6f, 0x5e, 0xe4, 0xd4, 0x29, 0x1c, 0x6c, 0xee,
1183                 0x2f, 0xea, 0xde, 0x61, 0x71, 0x5a, 0xea, 0xce,
1184                 0x23, 0x6e, 0x1b, 0x16, 0x43, 0xb7, 0xc0, 0xe3,
1185                 0x87, 0xa1, 0x95, 0x1e, 0x97, 0x4d, 0xea, 0xa6,
1186                 0xf7, 0x25, 0xac, 0x82, 0x2a, 0xd3, 0xa6, 0x99,
1187                 0x75, 0xdd, 0xc1, 0x55, 0x32, 0x6b, 0xea, 0x33,
1188                 0x88, 0xce, 0x06, 0xac, 0x15, 0x39, 0x19, 0xa3,
1189                 0x59, 0xaf, 0x7a, 0x1f, 0xd9, 0x72, 0x5e, 0xf7,
1190                 0x4c, 0xf3, 0x5d, 0x6b, 0xf2, 0x16, 0x92, 0xa8,
1191                 0x9e, 0x3d, 0xd4, 0x4c, 0x72, 0x55, 0x4e, 0x4a,
1192                 0xf7, 0x8b, 0x2f, 0x67, 0x5a, 0x90, 0xb7, 0xcf,
1193                 0x16, 0xd3, 0x7b, 0x5a, 0x9a, 0xc8, 0x9f, 0xbf,
1194                 0x01, 0x76, 0x3b, 0x86, 0x2c, 0x2a, 0x78, 0x10,
1195                 0x70, 0x05, 0x38, 0xf9, 0xdd, 0x2a, 0x1d, 0x00,
1196                 0x25, 0xb7, 0x10, 0xac, 0x3b, 0x3c, 0x4d, 0x3c,
1197                 0x01, 0x68, 0x3c, 0x5a, 0x29, 0xc2, 0xa0, 0x1b,
1198                 0x95, 0x67, 0xf9, 0x0a, 0x60, 0xb7, 0x11, 0x9c,
1199                 0x40, 0x45, 0xd7, 0xb0, 0xda, 0x49, 0x87, 0xcd,
1200                 0xb0, 0x9b, 0x61, 0x8c, 0xf4, 0x0d, 0x94, 0x1d,
1201                 0x79, 0x66, 0x13, 0x0b, 0xc6, 0x6b, 0x19, 0xee,
1202                 0xa0, 0x6b, 0x64, 0x7d, 0xc4, 0xff, 0x98, 0x72,
1203                 0x60, 0xab, 0x7f, 0x0f, 0x4d, 0x5d, 0x6b, 0xc3,
1204                 0xba, 0x5e, 0x0d, 0x04, 0xd9, 0x59, 0x17, 0xd0,
1205                 0x64, 0xbe, 0xfb, 0x58, 0xfc, 0xed, 0x18, 0xf6,
1206                 0xac, 0x19, 0xa4, 0xfd, 0x16, 0x59, 0x80, 0x58,
1207                 0xb8, 0x0f, 0x79, 0x24, 0x60, 0x18, 0x62, 0xa9,
1208                 0xa3, 0xa0, 0xe8, 0x81, 0xd6, 0xec, 0x5b, 0xfe,
1209                 0x5b, 0xb8, 0xa4, 0x00, 0xa9, 0xd0, 0x90, 0x17,
1210                 0xe5, 0x50, 0x3d, 0x2b, 0x12, 0x6e, 0x2a, 0x13,
1211                 0x65, 0x7c, 0xdf, 0xdf, 0xa7, 0xdd, 0x9f, 0x78,
1212                 0x5f, 0x8f, 0x4e, 0x90, 0xa6, 0x10, 0xe4, 0x7b,
1213                 0x68, 0x6b, 0xfd, 0xa9, 0x6d, 0x47, 0xfa, 0xec,
1214                 0x42, 0x35, 0x07, 0x12, 0x3e, 0x78, 0x23, 0x15,
1215                 0xff, 0xe2, 0x65, 0xc7, 0x47, 0x89, 0x2f, 0x97,
1216                 0x7c, 0xd7, 0x6b, 0x69, 0x35, 0x79, 0x6f, 0x85,
1217                 0xb4, 0xa9, 0x75, 0x04, 0x32, 0x9a, 0xfe, 0xf0,
1218                 0xce, 0xe3, 0xf1, 0xab, 0x15, 0x47, 0xe4, 0x9c,
1219                 0xc1, 0x48, 0x32, 0x3c, 0xbe, 0x44, 0x72, 0xc9,
1220                 0xaa, 0x50, 0x37, 0xa6, 0xbe, 0x41, 0xcf, 0xe8,
1221                 0x17, 0x4e, 0x37, 0xbe, 0xf1, 0x34, 0x2c, 0xd9,
1222                 0x60, 0x48, 0x09, 0xa5, 0x26, 0x00, 0x31, 0x77,
1223                 0x4e, 0xac, 0x7c, 0x89, 0x75, 0xe3, 0xde, 0x26,
1224                 0x4c, 0x32, 0x54, 0x27, 0x8e, 0x92, 0x26, 0x42,
1225                 0x85, 0x76, 0x01, 0x76, 0x62, 0x4c, 0x29, 0xe9,
1226                 0x38, 0x05, 0x51, 0x54, 0x97, 0xa3, 0x03, 0x59,
1227                 0x5e, 0xec, 0x0c, 0xe4, 0x96, 0xb7, 0x15, 0xa8,
1228                 0x41, 0x06, 0x2b, 0x78, 0x95, 0x24, 0xf6, 0x32,
1229                 0xc5, 0xec, 0xd7, 0x89, 0x28, 0x1e, 0xec, 0xb1,
1230                 0xc7, 0x21, 0x0c, 0xd3, 0x80, 0x7c, 0x5a, 0xe6,
1231                 0xb1, 0x3a, 0x52, 0x33, 0x84, 0x4e, 0x32, 0x6e,
1232                 0x7a, 0xf6, 0x43, 0x15, 0x5b, 0xa6, 0xba, 0xeb,
1233                 0xa8, 0xe4, 0xff, 0x4f, 0xbd, 0xbd, 0xa8, 0x5e,
1234                 0xbe, 0x27, 0xaf, 0xc5, 0xf7, 0x9e, 0xdf, 0x48,
1235                 0x22, 0xca, 0x6a, 0x0b, 0x3c, 0xd7, 0xe0, 0xdc,
1236                 0xf3, 0x71, 0x08, 0xdc, 0x28, 0x13, 0x08, 0xf2,
1237                 0x08, 0x1d, 0x9d, 0x7b, 0xd9, 0xde, 0x6f, 0xe6,
1238                 0xe8, 0x88, 0x18, 0xc2, 0xcd, 0x93, 0xc5, 0x38,
1239                 0x21, 0x68, 0x4c, 0x9a, 0xfb, 0xb6, 0x18, 0x16,
1240                 0x73, 0x2c, 0x1d, 0x6f, 0x95, 0xfb, 0x65, 0x4f,
1241                 0x7c, 0xec, 0x8d, 0x6c, 0xa8, 0xc0, 0x55, 0x28,
1242                 0xc6, 0xc3, 0xea, 0xeb, 0x05, 0xf5, 0x65, 0xeb,
1243                 0x53, 0xe1, 0x54, 0xef, 0xb8, 0x64, 0x98, 0x2d,
1244                 0x98, 0x9e, 0xc8, 0xfe, 0xa2, 0x07, 0x30, 0xf7,
1245                 0xf7, 0xae, 0xdb, 0x32, 0xf8, 0x71, 0x9d, 0x06,
1246                 0xdf, 0x9b, 0xda, 0x61, 0x7d, 0xdb, 0xae, 0x06,
1247                 0x24, 0x63, 0x74, 0xb6, 0xf3, 0x1b, 0x66, 0x09,
1248                 0x60, 0xff, 0x2b, 0x29, 0xf5, 0xa9, 0x9d, 0x61,
1249                 0x5d, 0x55, 0x10, 0x82, 0x21, 0xbb, 0x64, 0x0d,
1250                 0xef, 0x5c, 0xe3, 0x30, 0x1b, 0x60, 0x1e, 0x5b,
1251                 0xfe, 0x6c, 0xf5, 0x15, 0xa3, 0x86, 0x27, 0x58,
1252                 0x46, 0x00, 0x20, 0xcb, 0x86, 0x9a, 0x52, 0x29,
1253                 0x20, 0x68, 0x4d, 0x67, 0x88, 0x70, 0xc2, 0x31,
1254                 0xd8, 0xbb, 0xa5, 0xa7, 0x88, 0x7f, 0x66, 0xbc,
1255                 0xaa, 0x0f, 0xe1, 0x78, 0x7b, 0x97, 0x3c, 0xb7,
1256                 0xd7, 0xd8, 0x04, 0xe0, 0x09, 0x60, 0xc8, 0xd0,
1257                 0x9e, 0xe5, 0x6b, 0x31, 0x7f, 0x88, 0xfe, 0xc3,
1258                 0xfd, 0x89, 0xec, 0x76, 0x4b, 0xb3, 0xa7, 0x37,
1259                 0x03, 0xb7, 0xc6, 0x10, 0x7c, 0x9d, 0x0c, 0x75,
1260                 0xd3, 0x08, 0x14, 0x94, 0x03, 0x42, 0x25, 0x26,
1261                 0x85, 0xf7, 0xf0, 0x90, 0x06, 0x3e, 0x6f, 0x60,
1262                 0x52, 0x55, 0xd5, 0x0f, 0x79, 0x64, 0x69, 0x69,
1263                 0x46, 0xf9, 0x7f, 0x7f, 0x03, 0xf1, 0x1f, 0xdb,
1264                 0x39, 0x05, 0xba, 0x4a, 0x8f, 0x17, 0xe7, 0xba,
1265                 0xe2, 0x07, 0x7c, 0x1d, 0x9e, 0xbc, 0x94, 0xc0,
1266                 0x61, 0x59, 0x8e, 0x72, 0xaf, 0xfc, 0x99, 0xe4,
1267                 0xd5, 0xa8, 0xee, 0x0a, 0x48, 0x2d, 0x82, 0x8b,
1268                 0x34, 0x54, 0x8a, 0xce, 0xc7, 0xfa, 0xdd, 0xba,
1269                 0x54, 0xdf, 0xb3, 0x30, 0x33, 0x73, 0x2e, 0xd5,
1270                 0x52, 0xab, 0x49, 0x91, 0x4e, 0x0a, 0xd6, 0x2f,
1271                 0x67, 0xe4, 0xdd, 0x64, 0x48, 0x16, 0xd9, 0x85,
1272                 0xaa, 0x52, 0xa5, 0x0b, 0xd3, 0xb4, 0x2d, 0x77,
1273                 0x5e, 0x52, 0x77, 0x17, 0xcf, 0xbe, 0x88, 0x04,
1274                 0x01, 0x52, 0xe2, 0xf1, 0x46, 0xe2, 0x91, 0x30,
1275                 0x65, 0xcf, 0xc0, 0x65, 0x45, 0xc3, 0x7e, 0xf4,
1276                 0x2e, 0xb5, 0xaf, 0x6f, 0xab, 0x1a, 0xfa, 0x70,
1277                 0x35, 0xb8, 0x4f, 0x2d, 0x78, 0x90, 0x33, 0xb5,
1278                 0x9a, 0x67, 0xdb, 0x2f, 0x28, 0x32, 0xb6, 0x54,
1279                 0xab, 0x4c, 0x6b, 0x85, 0xed, 0x6c, 0x3e, 0x05,
1280                 0x2a, 0xc7, 0x32, 0xe8, 0xf5, 0xa3, 0x7b, 0x4e,
1281                 0x7b, 0x58, 0x24, 0x73, 0xf7, 0xfd, 0xc7, 0xc8,
1282                 0x6c, 0x71, 0x68, 0xb1, 0xf6, 0xc5, 0x9e, 0x1e,
1283                 0xe3, 0x5c, 0x25, 0xc0, 0x5b, 0x3e, 0x59, 0xa1,
1284                 0x18, 0x5a, 0xe8, 0xb5, 0xd1, 0x44, 0x13, 0xa3,
1285                 0xe6, 0x05, 0x76, 0xd2, 0x8d, 0x6e, 0x54, 0x68,
1286                 0x0c, 0xa4, 0x7b, 0x8b, 0xd3, 0x8c, 0x42, 0x13,
1287                 0x87, 0xda, 0xdf, 0x8f, 0xa5, 0x83, 0x7a, 0x42,
1288                 0x99, 0xb7, 0xeb, 0xe2, 0x79, 0xe0, 0xdb, 0xda,
1289                 0x33, 0xa8, 0x50, 0x3a, 0xd7, 0xe7, 0xd3, 0x61,
1290                 0x18, 0xb8, 0xaa, 0x2d, 0xc8, 0xd8, 0x2c, 0x28,
1291                 0xe5, 0x97, 0x0a, 0x7c, 0x6c, 0x7f, 0x09, 0xd7,
1292                 0x88, 0x80, 0xac, 0x12, 0xed, 0xf8, 0xc6, 0xb5,
1293                 0x2d, 0xd6, 0x63, 0x9b, 0x98, 0x35, 0x26, 0xde,
1294                 0xf6, 0x31, 0xee, 0x7e, 0xa0, 0xfb, 0x16, 0x98,
1295                 0xb1, 0x96, 0x1d, 0xee, 0xe3, 0x2f, 0xfb, 0x41,
1296                 0xdd, 0xea, 0x10, 0x1e, 0x03, 0x89, 0x18, 0xd2,
1297                 0x47, 0x0c, 0xa0, 0x57, 0xda, 0x76, 0x3a, 0x37,
1298                 0x2c, 0xe4, 0xf9, 0x77, 0xc8, 0x43, 0x5f, 0xcb,
1299                 0xd6, 0x85, 0xf7, 0x22, 0xe4, 0x32, 0x25, 0xa8,
1300                 0xdc, 0x21, 0xc0, 0xf5, 0x95, 0xb2, 0xf8, 0x83,
1301                 0xf0, 0x65, 0x61, 0x15, 0x48, 0x94, 0xb7, 0x03,
1302                 0x7f, 0x66, 0xa1, 0x39, 0x1f, 0xdd, 0xce, 0x96,
1303                 0xfe, 0x58, 0x81, 0x3d, 0x41, 0x11, 0x87, 0x13,
1304                 0x26, 0x1b, 0x6d, 0xf3, 0xca, 0x2e, 0x2c, 0x76,
1305                 0xd3, 0x2f, 0x6d, 0x49, 0x70, 0x53, 0x05, 0x96,
1306                 0xcc, 0x30, 0x2b, 0x83, 0xf2, 0xc6, 0xb2, 0x4b,
1307                 0x22, 0x13, 0x95, 0x42, 0xeb, 0x56, 0x4d, 0x22,
1308                 0xe6, 0x43, 0x6f, 0xba, 0xe7, 0x3b, 0xe5, 0x59,
1309                 0xce, 0x57, 0x88, 0x85, 0xb6, 0xbf, 0x15, 0x37,
1310                 0xb3, 0x7a, 0x7e, 0xc4, 0xbc, 0x99, 0xfc, 0xe4,
1311                 0x89, 0x00, 0x68, 0x39, 0xbc, 0x5a, 0xba, 0xab,
1312                 0x52, 0xab, 0xe6, 0x81, 0xfd, 0x93, 0x62, 0xe9,
1313                 0xb7, 0x12, 0xd1, 0x18, 0x1a, 0xb9, 0x55, 0x4a,
1314                 0x0f, 0xae, 0x35, 0x11, 0x04, 0x27, 0xf3, 0x42,
1315                 0x4e, 0xca, 0xdf, 0x9f, 0x12, 0x62, 0xea, 0x03,
1316                 0xc0, 0xa9, 0x22, 0x7b, 0x6c, 0x6c, 0xe3, 0xdf,
1317                 0x16, 0xad, 0x03, 0xc9, 0xfe, 0xa4, 0xdd, 0x4f
1318 };
1319
1320 static const uint8_t AES_CBC_ciphertext_1792B[] = {
1321                 0x59, 0xcc, 0xfe, 0x8f, 0xb4, 0x9d, 0x0e, 0xd1,
1322                 0x85, 0xfc, 0x9b, 0x43, 0xc1, 0xb7, 0x54, 0x67,
1323                 0x01, 0xef, 0xb8, 0x71, 0x36, 0xdb, 0x50, 0x48,
1324                 0x7a, 0xea, 0xcf, 0xce, 0xba, 0x30, 0x10, 0x2e,
1325                 0x96, 0x2b, 0xfd, 0xcf, 0x00, 0xe3, 0x1f, 0xac,
1326                 0x66, 0x14, 0x30, 0x86, 0x49, 0xdb, 0x01, 0x8b,
1327                 0x07, 0xdd, 0x00, 0x9d, 0x0d, 0x5c, 0x19, 0x11,
1328                 0xe8, 0x44, 0x2b, 0x25, 0x70, 0xed, 0x7c, 0x33,
1329                 0x0d, 0xe3, 0x34, 0x93, 0x63, 0xad, 0x26, 0xb1,
1330                 0x11, 0x91, 0x34, 0x2e, 0x1d, 0x50, 0xaa, 0xd4,
1331                 0xef, 0x3a, 0x6d, 0xd7, 0x33, 0x20, 0x0d, 0x3f,
1332                 0x9b, 0xdd, 0xc3, 0xa5, 0xc5, 0xf1, 0x99, 0xdc,
1333                 0xea, 0x52, 0xda, 0x55, 0xea, 0xa2, 0x7a, 0xc5,
1334                 0x78, 0x44, 0x4a, 0x02, 0x33, 0x19, 0x62, 0x37,
1335                 0xf8, 0x8b, 0xd1, 0x0c, 0x21, 0xdf, 0x40, 0x19,
1336                 0x81, 0xea, 0xfb, 0x1c, 0xa7, 0xcc, 0x60, 0xfe,
1337                 0x63, 0x25, 0x8f, 0xf3, 0x73, 0x0f, 0x45, 0xe6,
1338                 0x6a, 0x18, 0xbf, 0xbe, 0xad, 0x92, 0x2a, 0x1e,
1339                 0x15, 0x65, 0x6f, 0xef, 0x92, 0xcd, 0x0e, 0x19,
1340                 0x3d, 0x42, 0xa8, 0xfc, 0x0d, 0x32, 0x58, 0xe0,
1341                 0x56, 0x9f, 0xd6, 0x9b, 0x8b, 0xec, 0xe0, 0x45,
1342                 0x4d, 0x7e, 0x73, 0x87, 0xff, 0x74, 0x92, 0x59,
1343                 0x60, 0x13, 0x93, 0xda, 0xec, 0xbf, 0xfa, 0x20,
1344                 0xb6, 0xe7, 0xdf, 0xc7, 0x10, 0xf5, 0x79, 0xb4,
1345                 0xd7, 0xac, 0xaf, 0x2b, 0x37, 0x52, 0x30, 0x1d,
1346                 0xbe, 0x0f, 0x60, 0x77, 0x3d, 0x03, 0x63, 0xa9,
1347                 0xae, 0xb1, 0xf3, 0xca, 0xca, 0xb4, 0x21, 0xd7,
1348                 0x6f, 0x2e, 0x5e, 0x9b, 0x68, 0x53, 0x80, 0xab,
1349                 0x30, 0x23, 0x0a, 0x72, 0x6b, 0xb1, 0xd8, 0x25,
1350                 0x5d, 0x3a, 0x62, 0x9b, 0x4f, 0x59, 0x3b, 0x79,
1351                 0xa8, 0x9e, 0x08, 0x6d, 0x37, 0xb0, 0xfc, 0x42,
1352                 0x51, 0x25, 0x86, 0xbd, 0x54, 0x5a, 0x95, 0x20,
1353                 0x6c, 0xac, 0xb9, 0x30, 0x1c, 0x03, 0xc9, 0x49,
1354                 0x38, 0x55, 0x31, 0x49, 0xed, 0xa9, 0x0e, 0xc3,
1355                 0x65, 0xb4, 0x68, 0x6b, 0x07, 0x4c, 0x0a, 0xf9,
1356                 0x21, 0x69, 0x7c, 0x9f, 0x28, 0x80, 0xe9, 0x49,
1357                 0x22, 0x7c, 0xec, 0x97, 0xf7, 0x70, 0xb4, 0xb8,
1358                 0x25, 0xe7, 0x80, 0x2c, 0x43, 0x24, 0x8a, 0x2e,
1359                 0xac, 0xa2, 0x84, 0x20, 0xe7, 0xf4, 0x6b, 0x86,
1360                 0x37, 0x05, 0xc7, 0x59, 0x04, 0x49, 0x2a, 0x99,
1361                 0x80, 0x46, 0x32, 0x19, 0xe6, 0x30, 0xce, 0xc0,
1362                 0xef, 0x6e, 0xec, 0xe5, 0x2f, 0x24, 0xc1, 0x78,
1363                 0x45, 0x02, 0xd3, 0x64, 0x99, 0xf5, 0xc7, 0xbc,
1364                 0x8f, 0x8c, 0x75, 0xb1, 0x0a, 0xc8, 0xc3, 0xbd,
1365                 0x5e, 0x7e, 0xbd, 0x0e, 0xdf, 0x4b, 0x96, 0x6a,
1366                 0xfd, 0x03, 0xdb, 0xd1, 0x31, 0x1e, 0x27, 0xf9,
1367                 0xe5, 0x83, 0x9a, 0xfc, 0x13, 0x4c, 0xd3, 0x04,
1368                 0xdb, 0xdb, 0x3f, 0x35, 0x93, 0x4e, 0x14, 0x6b,
1369                 0x00, 0x5c, 0xb6, 0x11, 0x50, 0xee, 0x61, 0x5c,
1370                 0x10, 0x5c, 0xd0, 0x90, 0x02, 0x2e, 0x12, 0xe0,
1371                 0x50, 0x44, 0xad, 0x75, 0xcd, 0x94, 0xcf, 0x92,
1372                 0xcb, 0xe3, 0xe8, 0x77, 0x4b, 0xd7, 0x1a, 0x7c,
1373                 0xdd, 0x6b, 0x49, 0x21, 0x7c, 0xe8, 0x2c, 0x25,
1374                 0x49, 0x86, 0x1e, 0x54, 0xae, 0xfc, 0x0e, 0x80,
1375                 0xb1, 0xd5, 0xa5, 0x23, 0xcf, 0xcc, 0x0e, 0x11,
1376                 0xe2, 0x7c, 0x3c, 0x25, 0x78, 0x64, 0x03, 0xa1,
1377                 0xdd, 0x9f, 0x74, 0x12, 0x7b, 0x21, 0xb5, 0x73,
1378                 0x15, 0x3c, 0xed, 0xad, 0x07, 0x62, 0x21, 0x79,
1379                 0xd4, 0x2f, 0x0d, 0x72, 0xe9, 0x7c, 0x6b, 0x96,
1380                 0x6e, 0xe5, 0x36, 0x4a, 0xd2, 0x38, 0xe1, 0xff,
1381                 0x6e, 0x26, 0xa4, 0xac, 0x83, 0x07, 0xe6, 0x67,
1382                 0x74, 0x6c, 0xec, 0x8b, 0x4b, 0x79, 0x33, 0x50,
1383                 0x2f, 0x8f, 0xa0, 0x8f, 0xfa, 0x38, 0x6a, 0xa2,
1384                 0x3a, 0x42, 0x85, 0x15, 0x90, 0xd0, 0xb3, 0x0d,
1385                 0x8a, 0xe4, 0x60, 0x03, 0xef, 0xf9, 0x65, 0x8a,
1386                 0x4e, 0x50, 0x8c, 0x65, 0xba, 0x61, 0x16, 0xc3,
1387                 0x93, 0xb7, 0x75, 0x21, 0x98, 0x25, 0x60, 0x6e,
1388                 0x3d, 0x68, 0xba, 0x7c, 0xe4, 0xf3, 0xd9, 0x9b,
1389                 0xfb, 0x7a, 0xed, 0x1f, 0xb3, 0x4b, 0x88, 0x74,
1390                 0x2c, 0xb8, 0x8c, 0x22, 0x95, 0xce, 0x90, 0xf1,
1391                 0xdb, 0x80, 0xa6, 0x39, 0xae, 0x82, 0xa1, 0xef,
1392                 0x75, 0xec, 0xfe, 0xf1, 0xe8, 0x04, 0xfd, 0x99,
1393                 0x1b, 0x5f, 0x45, 0x87, 0x4f, 0xfa, 0xa2, 0x3e,
1394                 0x3e, 0xb5, 0x01, 0x4b, 0x46, 0xeb, 0x13, 0x9a,
1395                 0xe4, 0x7d, 0x03, 0x87, 0xb1, 0x59, 0x91, 0x8e,
1396                 0x37, 0xd3, 0x16, 0xce, 0xef, 0x4b, 0xe9, 0x46,
1397                 0x8d, 0x2a, 0x50, 0x2f, 0x41, 0xd3, 0x7b, 0xcf,
1398                 0xf0, 0xb7, 0x8b, 0x65, 0x0f, 0xa3, 0x27, 0x10,
1399                 0xe9, 0xa9, 0xe9, 0x2c, 0xbe, 0xbb, 0x82, 0xe3,
1400                 0x7b, 0x0b, 0x81, 0x3e, 0xa4, 0x6a, 0x4f, 0x3b,
1401                 0xd5, 0x61, 0xf8, 0x47, 0x04, 0x99, 0x5b, 0xff,
1402                 0xf3, 0x14, 0x6e, 0x57, 0x5b, 0xbf, 0x1b, 0xb4,
1403                 0x3f, 0xf9, 0x31, 0xf6, 0x95, 0xd5, 0x10, 0xa9,
1404                 0x72, 0x28, 0x23, 0xa9, 0x6a, 0xa2, 0xcf, 0x7d,
1405                 0xe3, 0x18, 0x95, 0xda, 0xbc, 0x6f, 0xe9, 0xd8,
1406                 0xef, 0x49, 0x3f, 0xd3, 0xef, 0x1f, 0xe1, 0x50,
1407                 0xe8, 0x8a, 0xc0, 0xce, 0xcc, 0xb7, 0x5e, 0x0e,
1408                 0x8b, 0x95, 0x80, 0xfd, 0x58, 0x2a, 0x9b, 0xc8,
1409                 0xb4, 0x17, 0x04, 0x46, 0x74, 0xd4, 0x68, 0x91,
1410                 0x33, 0xc8, 0x31, 0x15, 0x84, 0x16, 0x35, 0x03,
1411                 0x64, 0x6d, 0xa9, 0x4e, 0x20, 0xeb, 0xa9, 0x3f,
1412                 0x21, 0x5e, 0x9b, 0x09, 0xc3, 0x45, 0xf8, 0x7c,
1413                 0x59, 0x62, 0x29, 0x9a, 0x5c, 0xcf, 0xb4, 0x27,
1414                 0x5e, 0x13, 0xea, 0xb3, 0xef, 0xd9, 0x01, 0x2a,
1415                 0x65, 0x5f, 0x14, 0xf4, 0xbf, 0x28, 0x89, 0x3d,
1416                 0xdd, 0x9d, 0x52, 0xbd, 0x9e, 0x5b, 0x3b, 0xd2,
1417                 0xc2, 0x81, 0x35, 0xb6, 0xac, 0xdd, 0x27, 0xc3,
1418                 0x7b, 0x01, 0x5a, 0x6d, 0x4c, 0x5e, 0x2c, 0x30,
1419                 0xcb, 0x3a, 0xfa, 0xc1, 0xd7, 0x31, 0x67, 0x3e,
1420                 0x08, 0x6a, 0xe8, 0x8c, 0x75, 0xac, 0x1a, 0x6a,
1421                 0x52, 0xf7, 0x51, 0xcd, 0x85, 0x3f, 0x3c, 0xa7,
1422                 0xea, 0xbc, 0xd7, 0x18, 0x9e, 0x27, 0x73, 0xe6,
1423                 0x2b, 0x58, 0xb6, 0xd2, 0x29, 0x68, 0xd5, 0x8f,
1424                 0x00, 0x4d, 0x55, 0xf6, 0x61, 0x5a, 0xcc, 0x51,
1425                 0xa6, 0x5e, 0x85, 0xcb, 0x0b, 0xfd, 0x06, 0xca,
1426                 0xf5, 0xbf, 0x0d, 0x13, 0x74, 0x78, 0x6d, 0x9e,
1427                 0x20, 0x11, 0x84, 0x3e, 0x78, 0x17, 0x04, 0x4f,
1428                 0x64, 0x2c, 0x3b, 0x3e, 0x93, 0x7b, 0x58, 0x33,
1429                 0x07, 0x52, 0xf7, 0x60, 0x6a, 0xa8, 0x3b, 0x19,
1430                 0x27, 0x7a, 0x93, 0xc5, 0x53, 0xad, 0xec, 0xf6,
1431                 0xc8, 0x94, 0xee, 0x92, 0xea, 0xee, 0x7e, 0xea,
1432                 0xb9, 0x5f, 0xac, 0x59, 0x5d, 0x2e, 0x78, 0x53,
1433                 0x72, 0x81, 0x92, 0xdd, 0x1c, 0x63, 0xbe, 0x02,
1434                 0xeb, 0xa8, 0x1b, 0x2a, 0x6e, 0x72, 0xe3, 0x2d,
1435                 0x84, 0x0d, 0x8a, 0x22, 0xf6, 0xba, 0xab, 0x04,
1436                 0x8e, 0x04, 0x24, 0xdb, 0xcc, 0xe2, 0x69, 0xeb,
1437                 0x4e, 0xfa, 0x6b, 0x5b, 0xc8, 0xc0, 0xd9, 0x25,
1438                 0xcb, 0x40, 0x8d, 0x4b, 0x8e, 0xa0, 0xd4, 0x72,
1439                 0x98, 0x36, 0x46, 0x3b, 0x4f, 0x5f, 0x96, 0x84,
1440                 0x03, 0x28, 0x86, 0x4d, 0xa1, 0x8a, 0xd7, 0xb2,
1441                 0x5b, 0x27, 0x01, 0x80, 0x62, 0x49, 0x56, 0xb9,
1442                 0xa0, 0xa1, 0xe3, 0x6e, 0x22, 0x2a, 0x5d, 0x03,
1443                 0x86, 0x40, 0x36, 0x22, 0x5e, 0xd2, 0xe5, 0xc0,
1444                 0x6b, 0xfa, 0xac, 0x80, 0x4e, 0x09, 0x99, 0xbc,
1445                 0x2f, 0x9b, 0xcc, 0xf3, 0x4e, 0xf7, 0x99, 0x98,
1446                 0x11, 0x6e, 0x6f, 0x62, 0x22, 0x6b, 0x92, 0x95,
1447                 0x3b, 0xc3, 0xd2, 0x8e, 0x0f, 0x07, 0xc2, 0x51,
1448                 0x5c, 0x4d, 0xb2, 0x6e, 0xc0, 0x27, 0x73, 0xcd,
1449                 0x57, 0xb7, 0xf0, 0xe9, 0x2e, 0xc8, 0xe2, 0x0c,
1450                 0xd1, 0xb5, 0x0f, 0xff, 0xf9, 0xec, 0x38, 0xba,
1451                 0x97, 0xd6, 0x94, 0x9b, 0xd1, 0x79, 0xb6, 0x6a,
1452                 0x01, 0x17, 0xe4, 0x7e, 0xa6, 0xd5, 0x86, 0x19,
1453                 0xae, 0xf3, 0xf0, 0x62, 0x73, 0xc0, 0xf0, 0x0a,
1454                 0x7a, 0x96, 0x93, 0x72, 0x89, 0x7e, 0x25, 0x57,
1455                 0xf8, 0xf7, 0xd5, 0x1e, 0xe5, 0xac, 0xd6, 0x38,
1456                 0x4f, 0xe8, 0x81, 0xd1, 0x53, 0x41, 0x07, 0x2d,
1457                 0x58, 0x34, 0x1c, 0xef, 0x74, 0x2e, 0x61, 0xca,
1458                 0xd3, 0xeb, 0xd6, 0x93, 0x0a, 0xf2, 0xf2, 0x86,
1459                 0x9c, 0xe3, 0x7a, 0x52, 0xf5, 0x42, 0xf1, 0x8b,
1460                 0x10, 0xf2, 0x25, 0x68, 0x7e, 0x61, 0xb1, 0x19,
1461                 0xcf, 0x8f, 0x5a, 0x53, 0xb7, 0x68, 0x4f, 0x1a,
1462                 0x71, 0xe9, 0x83, 0x91, 0x3a, 0x78, 0x0f, 0xf7,
1463                 0xd4, 0x74, 0xf5, 0x06, 0xd2, 0x88, 0xb0, 0x06,
1464                 0xe5, 0xc0, 0xfb, 0xb3, 0x91, 0xad, 0xc0, 0x84,
1465                 0x31, 0xf2, 0x3a, 0xcf, 0x63, 0xe6, 0x4a, 0xd3,
1466                 0x78, 0xbe, 0xde, 0x73, 0x3e, 0x02, 0x8e, 0xb8,
1467                 0x3a, 0xf6, 0x55, 0xa7, 0xf8, 0x5a, 0xb5, 0x0e,
1468                 0x0c, 0xc5, 0xe5, 0x66, 0xd5, 0xd2, 0x18, 0xf3,
1469                 0xef, 0xa5, 0xc9, 0x68, 0x69, 0xe0, 0xcd, 0x00,
1470                 0x33, 0x99, 0x6e, 0xea, 0xcb, 0x06, 0x7a, 0xe1,
1471                 0xe1, 0x19, 0x0b, 0xe7, 0x08, 0xcd, 0x09, 0x1b,
1472                 0x85, 0xec, 0xc4, 0xd4, 0x75, 0xf0, 0xd6, 0xfb,
1473                 0x84, 0x95, 0x07, 0x44, 0xca, 0xa5, 0x2a, 0x6c,
1474                 0xc2, 0x00, 0x58, 0x08, 0x87, 0x9e, 0x0a, 0xd4,
1475                 0x06, 0xe2, 0x91, 0x5f, 0xb7, 0x1b, 0x11, 0xfa,
1476                 0x85, 0xfc, 0x7c, 0xf2, 0x0f, 0x6e, 0x3c, 0x8a,
1477                 0xe1, 0x0f, 0xa0, 0x33, 0x84, 0xce, 0x81, 0x4d,
1478                 0x32, 0x4d, 0xeb, 0x41, 0xcf, 0x5a, 0x05, 0x60,
1479                 0x47, 0x6c, 0x2a, 0xc4, 0x17, 0xd5, 0x16, 0x3a,
1480                 0xe4, 0xe7, 0xab, 0x84, 0x94, 0x22, 0xff, 0x56,
1481                 0xb0, 0x0c, 0x92, 0x6c, 0x19, 0x11, 0x4c, 0xb3,
1482                 0xed, 0x58, 0x48, 0x84, 0x2a, 0xe2, 0x19, 0x2a,
1483                 0xe1, 0xc0, 0x56, 0x82, 0x3c, 0x83, 0xb4, 0x58,
1484                 0x2d, 0xf0, 0xb5, 0x1e, 0x76, 0x85, 0x51, 0xc2,
1485                 0xe4, 0x95, 0x27, 0x96, 0xd1, 0x90, 0xc3, 0x17,
1486                 0x75, 0xa1, 0xbb, 0x46, 0x5f, 0xa6, 0xf2, 0xef,
1487                 0x71, 0x56, 0x92, 0xc5, 0x8a, 0x85, 0x52, 0xe4,
1488                 0x63, 0x21, 0x6f, 0x55, 0x85, 0x2b, 0x6b, 0x0d,
1489                 0xc9, 0x92, 0x77, 0x67, 0xe3, 0xff, 0x2a, 0x2b,
1490                 0x90, 0x01, 0x3d, 0x74, 0x63, 0x04, 0x61, 0x3c,
1491                 0x8e, 0xf8, 0xfc, 0x04, 0xdd, 0x21, 0x85, 0x92,
1492                 0x1e, 0x4d, 0x51, 0x8d, 0xb5, 0x6b, 0xf1, 0xda,
1493                 0x96, 0xf5, 0x8e, 0x3c, 0x38, 0x5a, 0xac, 0x9b,
1494                 0xba, 0x0c, 0x84, 0x5d, 0x50, 0x12, 0xc7, 0xc5,
1495                 0x7a, 0xcb, 0xb1, 0xfa, 0x16, 0x93, 0xdf, 0x98,
1496                 0xda, 0x3f, 0x49, 0xa3, 0x94, 0x78, 0x70, 0xc7,
1497                 0x0b, 0xb6, 0x91, 0xa6, 0x16, 0x2e, 0xcf, 0xfd,
1498                 0x51, 0x6a, 0x5b, 0xad, 0x7a, 0xdd, 0xa9, 0x48,
1499                 0x48, 0xac, 0xd6, 0x45, 0xbc, 0x23, 0x31, 0x1d,
1500                 0x86, 0x54, 0x8a, 0x7f, 0x04, 0x97, 0x71, 0x9e,
1501                 0xbc, 0x2e, 0x6b, 0xd9, 0x33, 0xc8, 0x20, 0xc9,
1502                 0xe0, 0x25, 0x86, 0x59, 0x15, 0xcf, 0x63, 0xe5,
1503                 0x99, 0xf1, 0x24, 0xf1, 0xba, 0xc4, 0x15, 0x02,
1504                 0xe2, 0xdb, 0xfe, 0x4a, 0xf8, 0x3b, 0x91, 0x13,
1505                 0x8d, 0x03, 0x81, 0x9f, 0xb3, 0x3f, 0x04, 0x03,
1506                 0x58, 0xc0, 0xef, 0x27, 0x82, 0x14, 0xd2, 0x7f,
1507                 0x93, 0x70, 0xb7, 0xb2, 0x02, 0x21, 0xb3, 0x07,
1508                 0x7f, 0x1c, 0xef, 0x88, 0xee, 0x29, 0x7a, 0x0b,
1509                 0x3d, 0x75, 0x5a, 0x93, 0xfe, 0x7f, 0x14, 0xf7,
1510                 0x4e, 0x4b, 0x7f, 0x21, 0x02, 0xad, 0xf9, 0x43,
1511                 0x29, 0x1a, 0xe8, 0x1b, 0xf5, 0x32, 0xb2, 0x96,
1512                 0xe6, 0xe8, 0x96, 0x20, 0x9b, 0x96, 0x8e, 0x7b,
1513                 0xfe, 0xd8, 0xc9, 0x9c, 0x65, 0x16, 0xd6, 0x68,
1514                 0x95, 0xf8, 0x22, 0xe2, 0xae, 0x84, 0x03, 0xfd,
1515                 0x87, 0xa2, 0x72, 0x79, 0x74, 0x95, 0xfa, 0xe1,
1516                 0xfe, 0xd0, 0x4e, 0x3d, 0x39, 0x2e, 0x67, 0x55,
1517                 0x71, 0x6c, 0x89, 0x33, 0x49, 0x0c, 0x1b, 0x46,
1518                 0x92, 0x31, 0x6f, 0xa6, 0xf0, 0x09, 0xbd, 0x2d,
1519                 0xe2, 0xca, 0xda, 0x18, 0x33, 0xce, 0x67, 0x37,
1520                 0xfd, 0x6f, 0xcb, 0x9d, 0xbd, 0x42, 0xbc, 0xb2,
1521                 0x9c, 0x28, 0xcd, 0x65, 0x3c, 0x61, 0xbc, 0xde,
1522                 0x9d, 0xe1, 0x2a, 0x3e, 0xbf, 0xee, 0x3c, 0xcb,
1523                 0xb1, 0x50, 0xa9, 0x2c, 0xbe, 0xb5, 0x43, 0xd0,
1524                 0xec, 0x29, 0xf9, 0x16, 0x6f, 0x31, 0xd9, 0x9b,
1525                 0x92, 0xb1, 0x32, 0xae, 0x0f, 0xb6, 0x9d, 0x0e,
1526                 0x25, 0x7f, 0x89, 0x1f, 0x1d, 0x01, 0x68, 0xab,
1527                 0x3d, 0xd1, 0x74, 0x5b, 0x4c, 0x38, 0x7f, 0x3d,
1528                 0x33, 0xa5, 0xa2, 0x9f, 0xda, 0x84, 0xa5, 0x82,
1529                 0x2d, 0x16, 0x66, 0x46, 0x08, 0x30, 0x14, 0x48,
1530                 0x5e, 0xca, 0xe3, 0xf4, 0x8c, 0xcb, 0x32, 0xc6,
1531                 0xf1, 0x43, 0x62, 0xc6, 0xef, 0x16, 0xfa, 0x43,
1532                 0xae, 0x9c, 0x53, 0xe3, 0x49, 0x45, 0x80, 0xfd,
1533                 0x1d, 0x8c, 0xa9, 0x6d, 0x77, 0x76, 0xaa, 0x40,
1534                 0xc4, 0x4e, 0x7b, 0x78, 0x6b, 0xe0, 0x1d, 0xce,
1535                 0x56, 0x3d, 0xf0, 0x11, 0xfe, 0x4f, 0x6a, 0x6d,
1536                 0x0f, 0x4f, 0x90, 0x38, 0x92, 0x17, 0xfa, 0x56,
1537                 0x12, 0xa6, 0xa1, 0x0a, 0xea, 0x2f, 0x50, 0xf9,
1538                 0x60, 0x66, 0x6c, 0x7d, 0x5a, 0x08, 0x8e, 0x3c,
1539                 0xf3, 0xf0, 0x33, 0x02, 0x11, 0x02, 0xfe, 0x4c,
1540                 0x56, 0x2b, 0x9f, 0x0c, 0xbd, 0x65, 0x8a, 0x83,
1541                 0xde, 0x7c, 0x05, 0x26, 0x93, 0x19, 0xcc, 0xf3,
1542                 0x71, 0x0e, 0xad, 0x2f, 0xb3, 0xc9, 0x38, 0x50,
1543                 0x64, 0xd5, 0x4c, 0x60, 0x5f, 0x02, 0x13, 0x34,
1544                 0xc9, 0x75, 0xc4, 0x60, 0xab, 0x2e, 0x17, 0x7d
1545 };
1546
1547 static const uint8_t AES_CBC_ciphertext_2048B[] = {
1548                 0x8b, 0x55, 0xbd, 0xfd, 0x2b, 0x35, 0x76, 0x5c,
1549                 0xd1, 0x90, 0xd7, 0x6a, 0x63, 0x1e, 0x39, 0x71,
1550                 0x0d, 0x5c, 0xd8, 0x03, 0x00, 0x75, 0xf1, 0x07,
1551                 0x03, 0x8d, 0x76, 0xeb, 0x3b, 0x00, 0x1e, 0x33,
1552                 0x88, 0xfc, 0x8f, 0x08, 0x4d, 0x33, 0xf1, 0x3c,
1553                 0xee, 0xd0, 0x5d, 0x19, 0x8b, 0x3c, 0x50, 0x86,
1554                 0xfd, 0x8d, 0x58, 0x21, 0xb4, 0xae, 0x0f, 0x81,
1555                 0xe9, 0x9f, 0xc9, 0xc0, 0x90, 0xf7, 0x04, 0x6f,
1556                 0x39, 0x1d, 0x8a, 0x3f, 0x8d, 0x32, 0x23, 0xb5,
1557                 0x1f, 0xcc, 0x8a, 0x12, 0x2d, 0x46, 0x82, 0x5e,
1558                 0x6a, 0x34, 0x8c, 0xb1, 0x93, 0x70, 0x3b, 0xde,
1559                 0x55, 0xaf, 0x16, 0x35, 0x99, 0x84, 0xd5, 0x88,
1560                 0xc9, 0x54, 0xb1, 0xb2, 0xd3, 0xeb, 0x9e, 0x55,
1561                 0x9a, 0xa9, 0xa7, 0xf5, 0xda, 0x29, 0xcf, 0xe1,
1562                 0x98, 0x64, 0x45, 0x77, 0xf2, 0x12, 0x69, 0x8f,
1563                 0x78, 0xd8, 0x82, 0x41, 0xb2, 0x9f, 0xe2, 0x1c,
1564                 0x63, 0x9b, 0x24, 0x81, 0x67, 0x95, 0xa2, 0xff,
1565                 0x26, 0x9d, 0x65, 0x48, 0x61, 0x30, 0x66, 0x41,
1566                 0x68, 0x84, 0xbb, 0x59, 0x14, 0x8e, 0x9a, 0x62,
1567                 0xb6, 0xca, 0xda, 0xbe, 0x7c, 0x41, 0x52, 0x6e,
1568                 0x1b, 0x86, 0xbf, 0x08, 0xeb, 0x37, 0x84, 0x60,
1569                 0xe4, 0xc4, 0x1e, 0xa8, 0x4c, 0x84, 0x60, 0x2f,
1570                 0x70, 0x90, 0xf2, 0x26, 0xe7, 0x65, 0x0c, 0xc4,
1571                 0x58, 0x36, 0x8e, 0x4d, 0xdf, 0xff, 0x9a, 0x39,
1572                 0x93, 0x01, 0xcf, 0x6f, 0x6d, 0xde, 0xef, 0x79,
1573                 0xb0, 0xce, 0xe2, 0x98, 0xdb, 0x85, 0x8d, 0x62,
1574                 0x9d, 0xb9, 0x63, 0xfd, 0xf0, 0x35, 0xb5, 0xa9,
1575                 0x1b, 0xf9, 0xe5, 0xd4, 0x2e, 0x22, 0x2d, 0xcc,
1576                 0x42, 0xbf, 0x0e, 0x51, 0xf7, 0x15, 0x07, 0x32,
1577                 0x75, 0x5b, 0x74, 0xbb, 0x00, 0xef, 0xd4, 0x66,
1578                 0x8b, 0xad, 0x71, 0x53, 0x94, 0xd7, 0x7d, 0x2c,
1579                 0x40, 0x3e, 0x69, 0xa0, 0x4c, 0x86, 0x5e, 0x06,
1580                 0xed, 0xdf, 0x22, 0xe2, 0x24, 0x25, 0x4e, 0x9b,
1581                 0x5f, 0x49, 0x74, 0xba, 0xed, 0xb1, 0xa6, 0xeb,
1582                 0xae, 0x3f, 0xc6, 0x9e, 0x0b, 0x29, 0x28, 0x9a,
1583                 0xb6, 0xb2, 0x74, 0x58, 0xec, 0xa6, 0x4a, 0xed,
1584                 0xe5, 0x10, 0x00, 0x85, 0xe1, 0x63, 0x41, 0x61,
1585                 0x30, 0x7c, 0x97, 0xcf, 0x75, 0xcf, 0xb6, 0xf3,
1586                 0xf7, 0xda, 0x35, 0x3f, 0x85, 0x8c, 0x64, 0xca,
1587                 0xb7, 0xea, 0x7f, 0xe4, 0xa3, 0x4d, 0x30, 0x84,
1588                 0x8c, 0x9c, 0x80, 0x5a, 0x50, 0xa5, 0x64, 0xae,
1589                 0x26, 0xd3, 0xb5, 0x01, 0x73, 0x36, 0x8a, 0x92,
1590                 0x49, 0xc4, 0x1a, 0x94, 0x81, 0x9d, 0xf5, 0x6c,
1591                 0x50, 0xe1, 0x58, 0x0b, 0x75, 0xdd, 0x6b, 0x6a,
1592                 0xca, 0x69, 0xea, 0xc3, 0x33, 0x90, 0x9f, 0x3b,
1593                 0x65, 0x5d, 0x5e, 0xee, 0x31, 0xb7, 0x32, 0xfd,
1594                 0x56, 0x83, 0xb6, 0xfb, 0xa8, 0x04, 0xfc, 0x1e,
1595                 0x11, 0xfb, 0x02, 0x23, 0x53, 0x49, 0x45, 0xb1,
1596                 0x07, 0xfc, 0xba, 0xe7, 0x5f, 0x5d, 0x2d, 0x7f,
1597                 0x9e, 0x46, 0xba, 0xe9, 0xb0, 0xdb, 0x32, 0x04,
1598                 0xa4, 0xa7, 0x98, 0xab, 0x91, 0xcd, 0x02, 0x05,
1599                 0xf5, 0x74, 0x31, 0x98, 0x83, 0x3d, 0x33, 0x11,
1600                 0x0e, 0xe3, 0x8d, 0xa8, 0xc9, 0x0e, 0xf3, 0xb9,
1601                 0x47, 0x67, 0xe9, 0x79, 0x2b, 0x34, 0xcd, 0x9b,
1602                 0x45, 0x75, 0x29, 0xf0, 0xbf, 0xcc, 0xda, 0x3a,
1603                 0x91, 0xb2, 0x15, 0x27, 0x7a, 0xe5, 0xf5, 0x6a,
1604                 0x5e, 0xbe, 0x2c, 0x98, 0xe8, 0x40, 0x96, 0x4f,
1605                 0x8a, 0x09, 0xfd, 0xf6, 0xb2, 0xe7, 0x45, 0xb6,
1606                 0x08, 0xc1, 0x69, 0xe1, 0xb3, 0xc4, 0x24, 0x34,
1607                 0x07, 0x85, 0xd5, 0xa9, 0x78, 0xca, 0xfa, 0x4b,
1608                 0x01, 0x19, 0x4d, 0x95, 0xdc, 0xa5, 0xc1, 0x9c,
1609                 0xec, 0x27, 0x5b, 0xa6, 0x54, 0x25, 0xbd, 0xc8,
1610                 0x0a, 0xb7, 0x11, 0xfb, 0x4e, 0xeb, 0x65, 0x2e,
1611                 0xe1, 0x08, 0x9c, 0x3a, 0x45, 0x44, 0x33, 0xef,
1612                 0x0d, 0xb9, 0xff, 0x3e, 0x68, 0x9c, 0x61, 0x2b,
1613                 0x11, 0xb8, 0x5c, 0x47, 0x0f, 0x94, 0xf2, 0xf8,
1614                 0x0b, 0xbb, 0x99, 0x18, 0x85, 0xa3, 0xba, 0x44,
1615                 0xf3, 0x79, 0xb3, 0x63, 0x2c, 0x1f, 0x2a, 0x35,
1616                 0x3b, 0x23, 0x98, 0xab, 0xf4, 0x16, 0x36, 0xf8,
1617                 0xde, 0x86, 0xa4, 0xd4, 0x75, 0xff, 0x51, 0xf9,
1618                 0xeb, 0x42, 0x5f, 0x55, 0xe2, 0xbe, 0xd1, 0x5b,
1619                 0xb5, 0x38, 0xeb, 0xb4, 0x4d, 0xec, 0xec, 0x99,
1620                 0xe1, 0x39, 0x43, 0xaa, 0x64, 0xf7, 0xc9, 0xd8,
1621                 0xf2, 0x9a, 0x71, 0x43, 0x39, 0x17, 0xe8, 0xa8,
1622                 0xa2, 0xe2, 0xa4, 0x2c, 0x18, 0x11, 0x49, 0xdf,
1623                 0x18, 0xdd, 0x85, 0x6e, 0x65, 0x96, 0xe2, 0xba,
1624                 0xa1, 0x0a, 0x2c, 0xca, 0xdc, 0x5f, 0xe4, 0xf4,
1625                 0x35, 0x03, 0xb2, 0xa9, 0xda, 0xcf, 0xb7, 0x6d,
1626                 0x65, 0x82, 0x82, 0x67, 0x9d, 0x0e, 0xf3, 0xe8,
1627                 0x85, 0x6c, 0x69, 0xb8, 0x4c, 0xa6, 0xc6, 0x2e,
1628                 0x40, 0xb5, 0x54, 0x28, 0x95, 0xe4, 0x57, 0xe0,
1629                 0x5b, 0xf8, 0xde, 0x59, 0xe0, 0xfd, 0x89, 0x48,
1630                 0xac, 0x56, 0x13, 0x54, 0xb9, 0x1b, 0xf5, 0x59,
1631                 0x97, 0xb6, 0xb3, 0xe8, 0xac, 0x2d, 0xfc, 0xd2,
1632                 0xea, 0x57, 0x96, 0x57, 0xa8, 0x26, 0x97, 0x2c,
1633                 0x01, 0x89, 0x56, 0xea, 0xec, 0x8c, 0x53, 0xd5,
1634                 0xd7, 0x9e, 0xc9, 0x98, 0x0b, 0xad, 0x03, 0x75,
1635                 0xa0, 0x6e, 0x98, 0x8b, 0x97, 0x8d, 0x8d, 0x85,
1636                 0x7d, 0x74, 0xa7, 0x2d, 0xde, 0x67, 0x0c, 0xcd,
1637                 0x54, 0xb8, 0x15, 0x7b, 0xeb, 0xf5, 0x84, 0xb9,
1638                 0x78, 0xab, 0xd8, 0x68, 0x91, 0x1f, 0x6a, 0xa6,
1639                 0x28, 0x22, 0xf7, 0x00, 0x49, 0x00, 0xbe, 0x41,
1640                 0x71, 0x0a, 0xf5, 0xe7, 0x9f, 0xb4, 0x11, 0x41,
1641                 0x3f, 0xcd, 0xa9, 0xa9, 0x01, 0x8b, 0x6a, 0xeb,
1642                 0x54, 0x4c, 0x58, 0x92, 0x68, 0x02, 0x0e, 0xe9,
1643                 0xed, 0x65, 0x4c, 0xfb, 0x95, 0x48, 0x58, 0xa2,
1644                 0xaa, 0x57, 0x69, 0x13, 0x82, 0x0c, 0x2c, 0x4b,
1645                 0x5d, 0x4e, 0x18, 0x30, 0xef, 0x1c, 0xb1, 0x9d,
1646                 0x05, 0x05, 0x02, 0x1c, 0x97, 0xc9, 0x48, 0xfe,
1647                 0x5e, 0x7b, 0x77, 0xa3, 0x1f, 0x2a, 0x81, 0x42,
1648                 0xf0, 0x4b, 0x85, 0x12, 0x9c, 0x1f, 0x44, 0xb1,
1649                 0x14, 0x91, 0x92, 0x65, 0x77, 0xb1, 0x87, 0xa2,
1650                 0xfc, 0xa4, 0xe7, 0xd2, 0x9b, 0xf2, 0x17, 0xf0,
1651                 0x30, 0x1c, 0x8d, 0x33, 0xbc, 0x25, 0x28, 0x48,
1652                 0xfd, 0x30, 0x79, 0x0a, 0x99, 0x3e, 0xb4, 0x0f,
1653                 0x1e, 0xa6, 0x68, 0x76, 0x19, 0x76, 0x29, 0xac,
1654                 0x5d, 0xb8, 0x1e, 0x42, 0xd6, 0x85, 0x04, 0xbf,
1655                 0x64, 0x1c, 0x2d, 0x53, 0xe9, 0x92, 0x78, 0xf8,
1656                 0xc3, 0xda, 0x96, 0x92, 0x10, 0x6f, 0x45, 0x85,
1657                 0xaf, 0x5e, 0xcc, 0xa8, 0xc0, 0xc6, 0x2e, 0x73,
1658                 0x51, 0x3f, 0x5e, 0xd7, 0x52, 0x33, 0x71, 0x12,
1659                 0x6d, 0x85, 0xee, 0xea, 0x85, 0xa8, 0x48, 0x2b,
1660                 0x40, 0x64, 0x6d, 0x28, 0x73, 0x16, 0xd7, 0x82,
1661                 0xd9, 0x90, 0xed, 0x1f, 0xa7, 0x5c, 0xb1, 0x5c,
1662                 0x27, 0xb9, 0x67, 0x8b, 0xb4, 0x17, 0x13, 0x83,
1663                 0x5f, 0x09, 0x72, 0x0a, 0xd7, 0xa0, 0xec, 0x81,
1664                 0x59, 0x19, 0xb9, 0xa6, 0x5a, 0x37, 0x34, 0x14,
1665                 0x47, 0xf6, 0xe7, 0x6c, 0xd2, 0x09, 0x10, 0xe7,
1666                 0xdd, 0xbb, 0x02, 0xd1, 0x28, 0xfa, 0x01, 0x2c,
1667                 0x93, 0x64, 0x2e, 0x1b, 0x4c, 0x02, 0x52, 0xcb,
1668                 0x07, 0xa1, 0xb6, 0x46, 0x02, 0x80, 0xd9, 0x8f,
1669                 0x5c, 0x62, 0xbe, 0x78, 0x9e, 0x75, 0xc4, 0x97,
1670                 0x91, 0x39, 0x12, 0x65, 0xb9, 0x3b, 0xc2, 0xd1,
1671                 0xaf, 0xf2, 0x1f, 0x4e, 0x4d, 0xd1, 0xf0, 0x9f,
1672                 0xb7, 0x12, 0xfd, 0xe8, 0x75, 0x18, 0xc0, 0x9d,
1673                 0x8c, 0x70, 0xff, 0x77, 0x05, 0xb6, 0x1a, 0x1f,
1674                 0x96, 0x48, 0xf6, 0xfe, 0xd5, 0x5d, 0x98, 0xa5,
1675                 0x72, 0x1c, 0x84, 0x76, 0x3e, 0xb8, 0x87, 0x37,
1676                 0xdd, 0xd4, 0x3a, 0x45, 0xdd, 0x09, 0xd8, 0xe7,
1677                 0x09, 0x2f, 0x3e, 0x33, 0x9e, 0x7b, 0x8c, 0xe4,
1678                 0x85, 0x12, 0x4e, 0xf8, 0x06, 0xb7, 0xb1, 0x85,
1679                 0x24, 0x96, 0xd8, 0xfe, 0x87, 0x92, 0x81, 0xb1,
1680                 0xa3, 0x38, 0xb9, 0x56, 0xe1, 0xf6, 0x36, 0x41,
1681                 0xbb, 0xd6, 0x56, 0x69, 0x94, 0x57, 0xb3, 0xa4,
1682                 0xca, 0xa4, 0xe1, 0x02, 0x3b, 0x96, 0x71, 0xe0,
1683                 0xb2, 0x2f, 0x85, 0x48, 0x1b, 0x4a, 0x41, 0x80,
1684                 0x4b, 0x9c, 0xe0, 0xc9, 0x39, 0xb8, 0xb1, 0xca,
1685                 0x64, 0x77, 0x46, 0x58, 0xe6, 0x84, 0xd5, 0x2b,
1686                 0x65, 0xce, 0xe9, 0x09, 0xa3, 0xaa, 0xfb, 0x83,
1687                 0xa9, 0x28, 0x68, 0xfd, 0xcd, 0xfd, 0x76, 0x83,
1688                 0xe1, 0x20, 0x22, 0x77, 0x3a, 0xa3, 0xb2, 0x93,
1689                 0x14, 0x91, 0xfc, 0xe2, 0x17, 0x63, 0x2b, 0xa6,
1690                 0x29, 0x38, 0x7b, 0x9b, 0x8b, 0x15, 0x77, 0xd6,
1691                 0xaa, 0x92, 0x51, 0x53, 0x50, 0xff, 0xa0, 0x35,
1692                 0xa0, 0x59, 0x7d, 0xf0, 0x11, 0x23, 0x49, 0xdf,
1693                 0x5a, 0x21, 0xc2, 0xfe, 0x35, 0xa0, 0x1d, 0xe2,
1694                 0xae, 0xa2, 0x8a, 0x61, 0x5b, 0xf7, 0xf1, 0x1c,
1695                 0x1c, 0xec, 0xc4, 0xf6, 0xdc, 0xaa, 0xc8, 0xc2,
1696                 0xe5, 0xa1, 0x2e, 0x14, 0xe5, 0xc6, 0xc9, 0x73,
1697                 0x03, 0x78, 0xeb, 0xed, 0xe0, 0x3e, 0xc5, 0xf4,
1698                 0xf1, 0x50, 0xb2, 0x01, 0x91, 0x96, 0xf5, 0xbb,
1699                 0xe1, 0x32, 0xcd, 0xa8, 0x66, 0xbf, 0x73, 0x85,
1700                 0x94, 0xd6, 0x7e, 0x68, 0xc5, 0xe4, 0xed, 0xd5,
1701                 0xe3, 0x67, 0x4c, 0xa5, 0xb3, 0x1f, 0xdf, 0xf8,
1702                 0xb3, 0x73, 0x5a, 0xac, 0xeb, 0x46, 0x16, 0x24,
1703                 0xab, 0xca, 0xa4, 0xdd, 0x87, 0x0e, 0x24, 0x83,
1704                 0x32, 0x04, 0x4c, 0xd8, 0xda, 0x7d, 0xdc, 0xe3,
1705                 0x01, 0x93, 0xf3, 0xc1, 0x5b, 0xbd, 0xc3, 0x1d,
1706                 0x40, 0x62, 0xde, 0x94, 0x03, 0x85, 0x91, 0x2a,
1707                 0xa0, 0x25, 0x10, 0xd3, 0x32, 0x9f, 0x93, 0x00,
1708                 0xa7, 0x8a, 0xfa, 0x77, 0x7c, 0xaf, 0x4d, 0xc8,
1709                 0x7a, 0xf3, 0x16, 0x2b, 0xba, 0xeb, 0x74, 0x51,
1710                 0xb8, 0xdd, 0x32, 0xad, 0x68, 0x7d, 0xdd, 0xca,
1711                 0x60, 0x98, 0xc9, 0x9b, 0xb6, 0x5d, 0x4d, 0x3a,
1712                 0x66, 0x8a, 0xbe, 0x05, 0xf9, 0x0c, 0xc5, 0xba,
1713                 0x52, 0x82, 0x09, 0x1f, 0x5a, 0x66, 0x89, 0x69,
1714                 0xa3, 0x5d, 0x93, 0x50, 0x7d, 0x44, 0xc3, 0x2a,
1715                 0xb8, 0xab, 0xec, 0xa6, 0x5a, 0xae, 0x4a, 0x6a,
1716                 0xcd, 0xfd, 0xb6, 0xff, 0x3d, 0x98, 0x05, 0xd9,
1717                 0x5b, 0x29, 0xc4, 0x6f, 0xe0, 0x76, 0xe2, 0x3f,
1718                 0xec, 0xd7, 0xa4, 0x91, 0x63, 0xf5, 0x4e, 0x4b,
1719                 0xab, 0x20, 0x8c, 0x3a, 0x41, 0xed, 0x8b, 0x4b,
1720                 0xb9, 0x01, 0x21, 0xc0, 0x6d, 0xfd, 0x70, 0x5b,
1721                 0x20, 0x92, 0x41, 0x89, 0x74, 0xb7, 0xe9, 0x8b,
1722                 0xfc, 0x6d, 0x17, 0x3f, 0x7f, 0x89, 0x3d, 0x6b,
1723                 0x8f, 0xbc, 0xd2, 0x57, 0xe9, 0xc9, 0x6e, 0xa7,
1724                 0x19, 0x26, 0x18, 0xad, 0xef, 0xb5, 0x87, 0xbf,
1725                 0xb8, 0xa8, 0xd6, 0x7d, 0xdd, 0x5f, 0x94, 0x54,
1726                 0x09, 0x92, 0x2b, 0xf5, 0x04, 0xf7, 0x36, 0x69,
1727                 0x8e, 0xf4, 0xdc, 0x1d, 0x6e, 0x55, 0xbb, 0xe9,
1728                 0x13, 0x05, 0x83, 0x35, 0x9c, 0xed, 0xcf, 0x8c,
1729                 0x26, 0x8c, 0x7b, 0xc7, 0x0b, 0xba, 0xfd, 0xe2,
1730                 0x84, 0x5c, 0x2a, 0x79, 0x43, 0x99, 0xb2, 0xc3,
1731                 0x82, 0x87, 0xc8, 0xcd, 0x37, 0x6d, 0xa1, 0x2b,
1732                 0x39, 0xb2, 0x38, 0x99, 0xd9, 0xfc, 0x02, 0x15,
1733                 0x55, 0x21, 0x62, 0x59, 0xeb, 0x00, 0x86, 0x08,
1734                 0x20, 0xbe, 0x1a, 0x62, 0x4d, 0x7e, 0xdf, 0x68,
1735                 0x73, 0x5b, 0x5f, 0xaf, 0x84, 0x96, 0x2e, 0x1f,
1736                 0x6b, 0x03, 0xc9, 0xa6, 0x75, 0x18, 0xe9, 0xd4,
1737                 0xbd, 0xc8, 0xec, 0x9a, 0x5a, 0xb3, 0x99, 0xab,
1738                 0x5f, 0x7c, 0x08, 0x7f, 0x69, 0x4d, 0x52, 0xa2,
1739                 0x30, 0x17, 0x3b, 0x16, 0x15, 0x1b, 0x11, 0x62,
1740                 0x3e, 0x80, 0x4b, 0x85, 0x7c, 0x9c, 0xd1, 0x3a,
1741                 0x13, 0x01, 0x5e, 0x45, 0xf1, 0xc8, 0x5f, 0xcd,
1742                 0x0e, 0x21, 0xf5, 0x82, 0xd4, 0x7b, 0x5c, 0x45,
1743                 0x27, 0x6b, 0xef, 0xfe, 0xb8, 0xc0, 0x6f, 0xdc,
1744                 0x60, 0x7b, 0xe4, 0xd5, 0x75, 0x71, 0xe6, 0xe8,
1745                 0x7d, 0x6b, 0x6d, 0x80, 0xaf, 0x76, 0x41, 0x58,
1746                 0xb7, 0xac, 0xb7, 0x13, 0x2f, 0x81, 0xcc, 0xf9,
1747                 0x19, 0x97, 0xe8, 0xee, 0x40, 0x91, 0xfc, 0x89,
1748                 0x13, 0x1e, 0x67, 0x9a, 0xdb, 0x8f, 0x8f, 0xc7,
1749                 0x4a, 0xc9, 0xaf, 0x2f, 0x67, 0x01, 0x3c, 0xb8,
1750                 0xa8, 0x3e, 0x78, 0x93, 0x1b, 0xdf, 0xbb, 0x34,
1751                 0x0b, 0x1a, 0xfa, 0xc2, 0x2d, 0xc5, 0x1c, 0xec,
1752                 0x97, 0x4f, 0x48, 0x41, 0x15, 0x0e, 0x75, 0xed,
1753                 0x66, 0x8c, 0x17, 0x7f, 0xb1, 0x48, 0x13, 0xc1,
1754                 0xfb, 0x60, 0x06, 0xf9, 0x72, 0x41, 0x3e, 0xcf,
1755                 0x6e, 0xb6, 0xc8, 0xeb, 0x4b, 0x5a, 0xd2, 0x0c,
1756                 0x28, 0xda, 0x02, 0x7a, 0x46, 0x21, 0x42, 0xb5,
1757                 0x34, 0xda, 0xcb, 0x5e, 0xbd, 0x66, 0x5c, 0xca,
1758                 0xff, 0x52, 0x43, 0x89, 0xf9, 0x10, 0x9a, 0x9e,
1759                 0x9b, 0xe3, 0xb0, 0x51, 0xe9, 0xf3, 0x0a, 0x35,
1760                 0x77, 0x54, 0xcc, 0xac, 0xa6, 0xf1, 0x2e, 0x36,
1761                 0x89, 0xac, 0xc5, 0xc6, 0x62, 0x5a, 0xc0, 0x6d,
1762                 0xc4, 0xe1, 0xf7, 0x64, 0x30, 0xff, 0x11, 0x40,
1763                 0x13, 0x89, 0xd8, 0xd7, 0x73, 0x3f, 0x93, 0x08,
1764                 0x68, 0xab, 0x66, 0x09, 0x1a, 0xea, 0x78, 0xc9,
1765                 0x52, 0xf2, 0xfd, 0x93, 0x1b, 0x94, 0xbe, 0x5c,
1766                 0xe5, 0x00, 0x6e, 0x00, 0xb9, 0xea, 0x27, 0xaa,
1767                 0xb3, 0xee, 0xe3, 0xc8, 0x6a, 0xb0, 0xc1, 0x8e,
1768                 0x9b, 0x54, 0x40, 0x10, 0x96, 0x06, 0xe8, 0xb3,
1769                 0xf5, 0x55, 0x77, 0xd7, 0x5c, 0x94, 0xc1, 0x74,
1770                 0xf3, 0x07, 0x64, 0xac, 0x1c, 0xde, 0xc7, 0x22,
1771                 0xb0, 0xbf, 0x2a, 0x5a, 0xc0, 0x8f, 0x8a, 0x83,
1772                 0x50, 0xc2, 0x5e, 0x97, 0xa0, 0xbe, 0x49, 0x7e,
1773                 0x47, 0xaf, 0xa7, 0x20, 0x02, 0x35, 0xa4, 0x57,
1774                 0xd9, 0x26, 0x63, 0xdb, 0xf1, 0x34, 0x42, 0x89,
1775                 0x36, 0xd1, 0x77, 0x6f, 0xb1, 0xea, 0x79, 0x7e,
1776                 0x95, 0x10, 0x5a, 0xee, 0xa3, 0xae, 0x6f, 0xba,
1777                 0xa9, 0xef, 0x5a, 0x7e, 0x34, 0x03, 0x04, 0x07,
1778                 0x92, 0xd6, 0x07, 0x79, 0xaa, 0x14, 0x90, 0x97,
1779                 0x05, 0x4d, 0xa6, 0x27, 0x10, 0x5c, 0x25, 0x24,
1780                 0xcb, 0xcc, 0xf6, 0x77, 0x9e, 0x43, 0x23, 0xd4,
1781                 0x98, 0xef, 0x22, 0xa8, 0xad, 0xf2, 0x26, 0x08,
1782                 0x59, 0x69, 0xa4, 0xc3, 0x97, 0xe0, 0x5c, 0x6f,
1783                 0xeb, 0x3d, 0xd4, 0x62, 0x6e, 0x80, 0x61, 0x02,
1784                 0xf4, 0xfc, 0x94, 0x79, 0xbb, 0x4e, 0x6d, 0xd7,
1785                 0x30, 0x5b, 0x10, 0x11, 0x5a, 0x3d, 0xa7, 0x50,
1786                 0x1d, 0x9a, 0x13, 0x5f, 0x4f, 0xa8, 0xa7, 0xb6,
1787                 0x39, 0xc7, 0xea, 0xe6, 0x19, 0x61, 0x69, 0xc7,
1788                 0x9a, 0x3a, 0xeb, 0x9d, 0xdc, 0xf7, 0x06, 0x37,
1789                 0xbd, 0xac, 0xe3, 0x18, 0xff, 0xfe, 0x11, 0xdb,
1790                 0x67, 0x42, 0xb4, 0xea, 0xa8, 0xbd, 0xb0, 0x76,
1791                 0xd2, 0x74, 0x32, 0xc2, 0xa4, 0x9c, 0xe7, 0x60,
1792                 0xc5, 0x30, 0x9a, 0x57, 0x66, 0xcd, 0x0f, 0x02,
1793                 0x4c, 0xea, 0xe9, 0xd3, 0x2a, 0x5c, 0x09, 0xc2,
1794                 0xff, 0x6a, 0xde, 0x5d, 0xb7, 0xe9, 0x75, 0x6b,
1795                 0x29, 0x94, 0xd6, 0xf7, 0xc3, 0xdf, 0xfb, 0x70,
1796                 0xec, 0xb5, 0x8c, 0xb0, 0x78, 0x7a, 0xee, 0x52,
1797                 0x5f, 0x8c, 0xae, 0x85, 0xe5, 0x98, 0xa2, 0xb7,
1798                 0x7c, 0x02, 0x2a, 0xcc, 0x9e, 0xde, 0x99, 0x5f,
1799                 0x84, 0x20, 0xbb, 0xdc, 0xf2, 0xd2, 0x13, 0x46,
1800                 0x3c, 0xd6, 0x4d, 0xe7, 0x50, 0xef, 0x55, 0xc3,
1801                 0x96, 0x9f, 0xec, 0x6c, 0xd8, 0xe2, 0xea, 0xed,
1802                 0xc7, 0x33, 0xc9, 0xb3, 0x1c, 0x4f, 0x1d, 0x83,
1803                 0x1d, 0xe4, 0xdd, 0xb2, 0x24, 0x8f, 0xf9, 0xf5
1804 };
1805
1806
1807 static const uint8_t HMAC_SHA256_ciphertext_64B_digest[] = {
1808                 0xc5, 0x6d, 0x4f, 0x29, 0xf4, 0xd2, 0xcc, 0x87,
1809                 0x3c, 0x81, 0x02, 0x6d, 0x38, 0x7a, 0x67, 0x3e,
1810                 0x95, 0x9c, 0x5c, 0x8f, 0xda, 0x5c, 0x06, 0xe0,
1811                 0x65, 0xf1, 0x6c, 0x51, 0x52, 0x49, 0x3e, 0x5f
1812 };
1813
1814 static const uint8_t HMAC_SHA256_ciphertext_128B_digest[] = {
1815                 0x76, 0x64, 0x2d, 0x69, 0x71, 0x5d, 0x6a, 0xd8,
1816                 0x9f, 0x74, 0x11, 0x2f, 0x58, 0xe0, 0x4a, 0x2f,
1817                 0x6c, 0x88, 0x5e, 0x4d, 0x9c, 0x79, 0x83, 0x1c,
1818                 0x8a, 0x14, 0xd0, 0x07, 0xfb, 0xbf, 0x6c, 0x8f
1819 };
1820
1821 static const uint8_t HMAC_SHA256_ciphertext_256B_digest[] = {
1822                 0x05, 0xa7, 0x44, 0xcd, 0x91, 0x8c, 0x95, 0xcf,
1823                 0x7b, 0x8f, 0xd3, 0x90, 0x86, 0x7e, 0x7b, 0xb9,
1824                 0x05, 0xd6, 0x6e, 0x7a, 0xc1, 0x7b, 0x26, 0xff,
1825                 0xd3, 0x4b, 0xe0, 0x22, 0x8b, 0xa8, 0x47, 0x52
1826 };
1827
1828 static const uint8_t HMAC_SHA256_ciphertext_512B_digest[] = {
1829                 0x08, 0xb7, 0x29, 0x54, 0x18, 0x7e, 0x97, 0x49,
1830                 0xc6, 0x7c, 0x9f, 0x94, 0xa5, 0x4f, 0xa2, 0x25,
1831                 0xd0, 0xe2, 0x30, 0x7b, 0xad, 0x93, 0xc9, 0x12,
1832                 0x0f, 0xf0, 0xf0, 0x71, 0xc2, 0xf6, 0x53, 0x8f
1833 };
1834
1835 static const uint8_t HMAC_SHA256_ciphertext_768B_digest[] = {
1836                 0xe4, 0x3e, 0x73, 0x93, 0x03, 0xaf, 0x6f, 0x9c,
1837                 0xca, 0x57, 0x3b, 0x4a, 0x6e, 0x83, 0x58, 0xf5,
1838                 0x66, 0xc2, 0xb4, 0xa7, 0xe0, 0xee, 0x63, 0x6b,
1839                 0x48, 0xb7, 0x50, 0x45, 0x69, 0xdf, 0x5c, 0x5b
1840 };
1841
1842 static const uint8_t HMAC_SHA256_ciphertext_1024B_digest[] = {
1843                 0x03, 0xb9, 0x96, 0x26, 0xdc, 0x1c, 0xab, 0xe2,
1844                 0xf5, 0x70, 0x55, 0x15, 0x67, 0x6e, 0x48, 0x11,
1845                 0xe7, 0x67, 0xea, 0xfa, 0x5c, 0x6b, 0x28, 0x22,
1846                 0xc9, 0x0e, 0x67, 0x04, 0xb3, 0x71, 0x7f, 0x88
1847 };
1848
1849 static const uint8_t HMAC_SHA256_ciphertext_1280B_digest[] = {
1850                 0x01, 0x91, 0xb8, 0x78, 0xd3, 0x21, 0x74, 0xa5,
1851                 0x1c, 0x8b, 0xd4, 0xd2, 0xc0, 0x49, 0xd7, 0xd2,
1852                 0x16, 0x46, 0x66, 0x85, 0x50, 0x6d, 0x08, 0xcc,
1853                 0xc7, 0x0a, 0xa3, 0x71, 0xcc, 0xde, 0xee, 0xdc
1854 };
1855
1856 static const uint8_t HMAC_SHA256_ciphertext_1536B_digest[] = {
1857                 0xf2, 0xe5, 0xe9, 0x57, 0x53, 0xd7, 0x69, 0x28,
1858                 0x7b, 0x69, 0xb5, 0x49, 0xa3, 0x31, 0x56, 0x5f,
1859                 0xa4, 0xe9, 0x87, 0x26, 0x2f, 0xe0, 0x2d, 0xd6,
1860                 0x08, 0x44, 0x01, 0x71, 0x0c, 0x93, 0x85, 0x84
1861 };
1862
1863 static const uint8_t HMAC_SHA256_ciphertext_1792B_digest[] = {
1864                 0xf6, 0x57, 0x62, 0x01, 0xbf, 0x2d, 0xea, 0x4a,
1865                 0xef, 0x43, 0x85, 0x60, 0x18, 0xdf, 0x8b, 0xb4,
1866                 0x60, 0xc0, 0xfd, 0x2f, 0x90, 0x15, 0xe6, 0x91,
1867                 0x56, 0x61, 0x68, 0x7f, 0x5e, 0x92, 0xa8, 0xdd
1868 };
1869
1870 static const uint8_t HMAC_SHA256_ciphertext_2048B_digest[] = {
1871                 0x81, 0x1a, 0x29, 0xbc, 0x6b, 0x9f, 0xbb, 0xb8,
1872                 0xef, 0x71, 0x7b, 0x1f, 0x6f, 0xd4, 0x7e, 0x68,
1873                 0x3a, 0x9c, 0xb9, 0x98, 0x22, 0x81, 0xfa, 0x95,
1874                 0xee, 0xbc, 0x7f, 0x23, 0x29, 0x88, 0x76, 0xb8
1875 };
1876
1877 struct crypto_data_params {
1878         const char *name;
1879         uint16_t length;
1880         const char *plaintext;
1881         struct crypto_expected_output {
1882                 const uint8_t *ciphertext;
1883                 const uint8_t *digest;
1884         } expected;
1885 };
1886
1887 #define MAX_PACKET_SIZE_INDEX   10
1888
1889 struct crypto_data_params aes_cbc_hmac_sha256_output[MAX_PACKET_SIZE_INDEX] = {
1890         { "64B", 64, &plaintext_quote[sizeof(plaintext_quote) - 1 - 64],
1891                 { AES_CBC_ciphertext_64B, HMAC_SHA256_ciphertext_64B_digest } },
1892         { "128B", 128, &plaintext_quote[sizeof(plaintext_quote) - 1 - 128],
1893                 { AES_CBC_ciphertext_128B, HMAC_SHA256_ciphertext_128B_digest } },
1894         { "256B", 256, &plaintext_quote[sizeof(plaintext_quote) - 1 - 256],
1895                 { AES_CBC_ciphertext_256B, HMAC_SHA256_ciphertext_256B_digest } },
1896         { "512B", 512, &plaintext_quote[sizeof(plaintext_quote) - 1 - 512],
1897                 { AES_CBC_ciphertext_512B, HMAC_SHA256_ciphertext_512B_digest } },
1898         { "768B", 768, &plaintext_quote[sizeof(plaintext_quote) - 1 - 768],
1899                 { AES_CBC_ciphertext_768B, HMAC_SHA256_ciphertext_768B_digest } },
1900         { "1024B", 1024, &plaintext_quote[sizeof(plaintext_quote) - 1 - 1024],
1901                 { AES_CBC_ciphertext_1024B, HMAC_SHA256_ciphertext_1024B_digest } },
1902         { "1280B", 1280, &plaintext_quote[sizeof(plaintext_quote) - 1 - 1280],
1903                 { AES_CBC_ciphertext_1280B, HMAC_SHA256_ciphertext_1280B_digest } },
1904         { "1536B", 1536, &plaintext_quote[sizeof(plaintext_quote) - 1 - 1536],
1905                 { AES_CBC_ciphertext_1536B, HMAC_SHA256_ciphertext_1536B_digest } },
1906         { "1792B", 1792, &plaintext_quote[sizeof(plaintext_quote) - 1 - 1792],
1907                 { AES_CBC_ciphertext_1792B, HMAC_SHA256_ciphertext_1792B_digest } },
1908         { "2048B", 2048, &plaintext_quote[sizeof(plaintext_quote) - 1 - 2048],
1909                 { AES_CBC_ciphertext_2048B, HMAC_SHA256_ciphertext_2048B_digest } }
1910 };
1911
1912 static int
1913 test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
1914 {
1915         uint32_t num_to_submit = 4096;
1916         struct rte_crypto_op *c_ops[num_to_submit];
1917         struct rte_crypto_op *proc_ops[num_to_submit];
1918         uint64_t failed_polls, retries, start_cycles, end_cycles, total_cycles = 0;
1919         uint32_t burst_sent, burst_received;
1920         uint32_t i, burst_size, num_sent, num_received;
1921         struct crypto_testsuite_params *ts_params = &testsuite_params;
1922         struct crypto_unittest_params *ut_params = &unittest_params;
1923         struct crypto_data_params *data_params = aes_cbc_hmac_sha256_output;
1924
1925         if (rte_cryptodev_count() == 0) {
1926                 printf("\nNo crypto devices available. Is kernel driver loaded?\n");
1927                 return TEST_FAILED;
1928         }
1929
1930         /* Setup Cipher Parameters */
1931         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1932         ut_params->cipher_xform.next = &ut_params->auth_xform;
1933
1934         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1935         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1936         ut_params->cipher_xform.cipher.key.data = aes_cbc_128_key;
1937         ut_params->cipher_xform.cipher.key.length = CIPHER_IV_LENGTH_AES_CBC;
1938         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1939         ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1940
1941         /* Setup HMAC Parameters */
1942         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1943         ut_params->auth_xform.next = NULL;
1944
1945         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1946         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
1947         ut_params->auth_xform.auth.key.data = hmac_sha256_key;
1948         ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA256;
1949         ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA256;
1950
1951         /* Create Crypto session*/
1952         ut_params->sess = rte_cryptodev_sym_session_create(ts_params->dev_id,
1953                 &ut_params->cipher_xform);
1954
1955         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1956
1957         /* Generate Crypto op data structure(s) */
1958         for (i = 0; i < num_to_submit ; i++) {
1959                 struct rte_mbuf *m = setup_test_string(ts_params->mbuf_mp,
1960                                 data_params[0].expected.ciphertext,
1961                                 data_params[0].length, 0);
1962                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate tx_buf");
1963
1964                 ut_params->digest = (uint8_t *)rte_pktmbuf_append(m,
1965                                 DIGEST_BYTE_LENGTH_SHA256);
1966                 TEST_ASSERT_NOT_NULL(ut_params->digest,
1967                                 "no room to append digest");
1968
1969                 rte_memcpy(ut_params->digest, data_params[0].expected.digest,
1970                         DIGEST_BYTE_LENGTH_SHA256);
1971
1972
1973                 struct rte_crypto_op *op =
1974                                 rte_crypto_op_alloc(ts_params->op_mpool,
1975                                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1976
1977                 rte_crypto_op_attach_sym_session(op, ut_params->sess);
1978
1979                 op->sym->auth.digest.data = ut_params->digest;
1980                 op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m,
1981                                 data_params[0].length);
1982
1983                 op->sym->auth.data.offset = 0;
1984                 op->sym->auth.data.length = data_params[0].length;
1985
1986                 rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
1987                                 aes_cbc_128_iv, CIPHER_IV_LENGTH_AES_CBC);
1988
1989                 op->sym->cipher.data.offset = 0;
1990                 op->sym->cipher.data.length = data_params[0].length;
1991
1992                 op->sym->m_src = m;
1993
1994                 c_ops[i] = op;
1995         }
1996
1997         printf("\nTest to measure the IA cycle cost using AES128_CBC_SHA256_HMAC "
1998                         "algorithm with a constant request size of %u.",
1999                         data_params[0].length);
2000         printf("\nThis test will keep retries at 0 and only measure IA cycle "
2001                         "cost for each request.");
2002         printf("\nDev No\tQP No\tNum Sent\tNum Received\tTx/Rx burst");
2003         printf("\tRetries (Device Busy)\tAverage IA cycle cost "
2004                         "(assuming 0 retries)");
2005         for (i = 2; i <= 128 ; i *= 2) {
2006                 num_sent = 0;
2007                 num_received = 0;
2008                 retries = 0;
2009                 failed_polls = 0;
2010                 burst_size = i;
2011                 total_cycles = 0;
2012                 while (num_sent < num_to_submit) {
2013                         start_cycles = rte_rdtsc_precise();
2014                         burst_sent = rte_cryptodev_enqueue_burst(dev_num,
2015                                         0, &c_ops[num_sent],
2016                                         ((num_to_submit-num_sent) < burst_size) ?
2017                                         num_to_submit-num_sent : burst_size);
2018                         if (burst_sent == 0)
2019                                 retries++;
2020                         else
2021                                 num_sent += burst_sent;
2022                         end_cycles = rte_rdtsc_precise();
2023                         total_cycles += (end_cycles - start_cycles);
2024                         /*
2025                          * Wait until requests have been sent.
2026                          */
2027                         rte_delay_ms(1);
2028
2029                         start_cycles = rte_rdtsc_precise();
2030                         burst_received = rte_cryptodev_dequeue_burst(
2031                                         dev_num, 0, proc_ops, burst_size);
2032                         if (burst_received == 0)
2033                                 failed_polls++;
2034                         else
2035                                 num_received += burst_received;
2036                         end_cycles = rte_rdtsc_precise();
2037                         total_cycles += end_cycles - start_cycles;
2038                 }
2039
2040                 while (num_received != num_to_submit) {
2041                         if (gbl_driver_id ==
2042                                         rte_cryptodev_driver_id_get(
2043                                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
2044                                 rte_cryptodev_enqueue_burst(dev_num, 0,
2045                                                 NULL, 0);
2046
2047                         burst_received = rte_cryptodev_dequeue_burst(
2048                                         dev_num, 0, proc_ops, burst_size);
2049                         if (burst_received == 0)
2050                                 failed_polls++;
2051                         else
2052                                 num_received += burst_received;
2053                 }
2054
2055                 printf("\n%u\t%u\t%u\t\t%u\t\t%u", dev_num, 0,
2056                                         num_sent, num_received, burst_size);
2057                 printf("\t\t%"PRIu64, retries);
2058                 printf("\t\t\t%"PRIu64, total_cycles/num_received);
2059         }
2060         printf("\n");
2061
2062         for (i = 0; i < num_to_submit ; i++) {
2063                 rte_pktmbuf_free(c_ops[i]->sym->m_src);
2064                 rte_crypto_op_free(c_ops[i]);
2065         }
2066         return TEST_SUCCESS;
2067 }
2068
2069 static int
2070 test_perf_snow3G_optimise_cyclecount(struct perf_test_params *pparams)
2071 {
2072         uint32_t num_to_submit = pparams->total_operations;
2073         struct rte_crypto_op *c_ops[num_to_submit];
2074         struct rte_crypto_op *proc_ops[num_to_submit];
2075         uint64_t failed_polls, retries, start_cycles, end_cycles, total_cycles = 0;
2076         uint32_t burst_sent = 0, burst_received = 0;
2077         uint32_t i, burst_size, num_sent, num_ops_received;
2078         struct crypto_testsuite_params *ts_params = &testsuite_params;
2079         static struct rte_cryptodev_sym_session *sess;
2080
2081         if (rte_cryptodev_count() == 0) {
2082                 printf("\nNo crypto devices found. Is PMD build configured?\n");
2083                 printf("\nAnd is kernel driver loaded for HW PMDs?\n");
2084                 return TEST_FAILED;
2085         }
2086
2087         /* Create Crypto session*/
2088         sess = test_perf_create_snow3g_session(ts_params->dev_id,
2089                         pparams->chain, pparams->cipher_algo,
2090                         pparams->key_length, pparams->auth_algo);
2091         TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
2092
2093         /* Generate Crypto op data structure(s)*/
2094         for (i = 0; i < num_to_submit ; i++) {
2095                 struct rte_mbuf *m = test_perf_create_pktmbuf(
2096                                                 ts_params->mbuf_mp,
2097                                                 pparams->buf_size);
2098                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate tx_buf");
2099
2100                 struct rte_crypto_op *op =
2101                                 rte_crypto_op_alloc(ts_params->op_mpool,
2102                                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2103                 TEST_ASSERT_NOT_NULL(op, "Failed to allocate op");
2104
2105                 op = test_perf_set_crypto_op_snow3g(op, m, sess, pparams->buf_size);
2106                 TEST_ASSERT_NOT_NULL(op, "Failed to attach op to session");
2107
2108                 c_ops[i] = op;
2109         }
2110
2111         if (pparams->chain == AEAD)
2112                 printf("\nOn %s dev%u qp%u, %s, aead algo:%s, "
2113                         "Packet Size %u bytes",
2114                         pmd_name(gbl_driver_id),
2115                         ts_params->dev_id, 0,
2116                         chain_mode_name(pparams->chain),
2117                         rte_crypto_aead_algorithm_strings[pparams->aead_algo],
2118                         pparams->buf_size);
2119         else
2120                 printf("\nOn %s dev%u qp%u, %s, cipher algo:%s, auth_algo:%s, "
2121                         "Packet Size %u bytes",
2122                         pmd_name(gbl_driver_id),
2123                         ts_params->dev_id, 0,
2124                         chain_mode_name(pparams->chain),
2125                         rte_crypto_cipher_algorithm_strings[pparams->cipher_algo],
2126                         rte_crypto_auth_algorithm_strings[pparams->auth_algo],
2127                         pparams->buf_size);
2128         printf("\nOps Tx\tOps Rx\tOps/burst  ");
2129         printf("Retries  EmptyPolls\tIACycles/CyOp\tIACycles/Burst\tIACycles/Byte");
2130
2131         for (i = 2; i <= 128 ; i *= 2) {
2132                 num_sent = 0;
2133                 num_ops_received = 0;
2134                 retries = 0;
2135                 failed_polls = 0;
2136                 burst_size = i;
2137                 total_cycles = 0;
2138                 while (num_sent < num_to_submit) {
2139                         start_cycles = rte_rdtsc_precise();
2140                         burst_sent = rte_cryptodev_enqueue_burst(ts_params->dev_id,
2141                                         0, &c_ops[num_sent],
2142                                         ((num_to_submit-num_sent) < burst_size) ?
2143                                         num_to_submit-num_sent : burst_size);
2144                         end_cycles = rte_rdtsc_precise();
2145                         if (burst_sent == 0)
2146                                 retries++;
2147                         num_sent += burst_sent;
2148                         total_cycles += (end_cycles - start_cycles);
2149
2150                         /* Wait until requests have been sent. */
2151
2152                         rte_delay_ms(1);
2153
2154                         start_cycles = rte_rdtsc_precise();
2155                         burst_received = rte_cryptodev_dequeue_burst(
2156                                         ts_params->dev_id, 0, proc_ops, burst_size);
2157                         end_cycles = rte_rdtsc_precise();
2158                         if (burst_received < burst_sent)
2159                                 failed_polls++;
2160                         num_ops_received += burst_received;
2161
2162                         total_cycles += end_cycles - start_cycles;
2163                 }
2164
2165                 while (num_ops_received != num_to_submit) {
2166                         if (gbl_driver_id ==
2167                                         rte_cryptodev_driver_id_get(
2168                                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
2169                                 rte_cryptodev_enqueue_burst(ts_params->dev_id, 0,
2170                                                 NULL, 0);
2171                         start_cycles = rte_rdtsc_precise();
2172                         burst_received = rte_cryptodev_dequeue_burst(
2173                                         ts_params->dev_id, 0, proc_ops, burst_size);
2174                         end_cycles = rte_rdtsc_precise();
2175                         total_cycles += end_cycles - start_cycles;
2176                         if (burst_received == 0)
2177                                 failed_polls++;
2178                         num_ops_received += burst_received;
2179                 }
2180
2181                 printf("\n%u\t%u\t%u", num_sent, num_ops_received, burst_size);
2182                 printf("\t\t%"PRIu64, retries);
2183                 printf("\t%"PRIu64, failed_polls);
2184                 printf("\t\t%"PRIu64, total_cycles/num_ops_received);
2185                 printf("\t\t%"PRIu64, (total_cycles/num_ops_received)*burst_size);
2186                 printf("\t\t%"PRIu64, total_cycles/(num_ops_received*pparams->buf_size));
2187         }
2188         printf("\n");
2189
2190         for (i = 0; i < num_to_submit ; i++) {
2191                 rte_pktmbuf_free(c_ops[i]->sym->m_src);
2192                 rte_crypto_op_free(c_ops[i]);
2193         }
2194         rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
2195
2196         return TEST_SUCCESS;
2197 }
2198
2199 static int
2200 test_perf_snow3G_vary_burst_size(void)
2201 {
2202         unsigned total_operations = 4096;
2203         /*no need to vary pkt size for QAT, should have no effect on IA cycles */
2204         uint16_t buf_lengths[] = {40};
2205         uint8_t i, j;
2206
2207         struct perf_test_params params_set[] = {
2208                         {
2209                                         .chain = CIPHER_ONLY,
2210                                         .cipher_algo  = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2211                                         .key_length = 16,
2212                                         .auth_algo  = RTE_CRYPTO_AUTH_NULL,
2213                         },
2214                         {
2215                                         .chain = HASH_ONLY,
2216                                         .cipher_algo = RTE_CRYPTO_CIPHER_NULL,
2217                                         .auth_algo  = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2218                                         .key_length = 16
2219                         },
2220         };
2221
2222         printf("\n\nStart %s.", __func__);
2223         printf("\nThis Test measures the average IA cycle cost using a "
2224                         "constant request(packet) size. ");
2225         printf("Cycle cost is only valid when indicators show device is not busy,"
2226                         " i.e. Retries and EmptyPolls = 0");
2227
2228         for (i = 0; i < RTE_DIM(params_set); i++) {
2229                 printf("\n");
2230                 params_set[i].total_operations = total_operations;
2231
2232                 for (j = 0;
2233                         j < RTE_DIM(buf_lengths);
2234                         j++) {
2235
2236                         params_set[i].buf_size = buf_lengths[j];
2237
2238                         test_perf_snow3G_optimise_cyclecount(&params_set[i]);
2239                 }
2240
2241         }
2242
2243         return 0;
2244 }
2245
2246 static int
2247 test_perf_openssl_optimise_cyclecount(struct perf_test_params *pparams)
2248 {
2249         uint32_t num_to_submit = pparams->total_operations;
2250         struct rte_crypto_op *c_ops[num_to_submit];
2251         struct rte_crypto_op *proc_ops[num_to_submit];
2252         uint64_t failed_polls, retries, start_cycles,
2253                 end_cycles, total_cycles = 0;
2254         uint32_t burst_sent = 0, burst_received = 0;
2255         uint32_t i, burst_size, num_sent, num_ops_received;
2256
2257         struct crypto_testsuite_params *ts_params = &testsuite_params;
2258
2259         static struct rte_cryptodev_sym_session *sess;
2260
2261         static struct rte_crypto_op *(*test_perf_set_crypto_op)
2262                         (struct rte_crypto_op *, struct rte_mbuf *,
2263                                         struct rte_cryptodev_sym_session *,
2264                                         unsigned int,
2265                                         enum chain_mode);
2266
2267         if (rte_cryptodev_count() == 0) {
2268                 printf("\nNo crypto devices found. Is PMD build configured?\n");
2269                 return TEST_FAILED;
2270         }
2271
2272         /* Create Crypto session*/
2273         sess = test_perf_create_openssl_session(ts_params->dev_id,
2274                         pparams->chain, pparams->cipher_algo,
2275                         pparams->key_length, pparams->auth_algo,
2276                         pparams->aead_algo);
2277         TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
2278
2279         /* Generate Crypto op data structure(s)*/
2280         for (i = 0; i < num_to_submit ; i++) {
2281                 struct rte_mbuf *m = test_perf_create_pktmbuf(
2282                                                 ts_params->mbuf_mp,
2283                                                 pparams->buf_size);
2284                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate tx_buf");
2285
2286                 struct rte_crypto_op *op =
2287                                 rte_crypto_op_alloc(ts_params->op_mpool,
2288                                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2289                 TEST_ASSERT_NOT_NULL(op, "Failed to allocate op");
2290
2291                 if (pparams->chain == AEAD)
2292                         test_perf_set_crypto_op =
2293                                                 test_perf_set_crypto_op_aes_gcm;
2294                 else {
2295                         switch (pparams->cipher_algo) {
2296                         case RTE_CRYPTO_CIPHER_3DES_CBC:
2297                         case RTE_CRYPTO_CIPHER_3DES_CTR:
2298                                 test_perf_set_crypto_op = test_perf_set_crypto_op_3des;
2299                                 break;
2300                         case RTE_CRYPTO_CIPHER_AES_CBC:
2301                         case RTE_CRYPTO_CIPHER_AES_CTR:
2302                                 test_perf_set_crypto_op = test_perf_set_crypto_op_aes;
2303                                 break;
2304                         default:
2305                                 return TEST_FAILED;
2306                         }
2307                 }
2308
2309                 op = test_perf_set_crypto_op(op, m, sess, pparams->buf_size,
2310                                 pparams->chain);
2311                 TEST_ASSERT_NOT_NULL(op, "Failed to attach op to session");
2312
2313                 c_ops[i] = op;
2314         }
2315
2316         if (pparams->chain == AEAD)
2317                 printf("\nOn %s dev%u qp%u, %s, aead_algo:%s, "
2318                         "key length:%u, Packet Size %u bytes",
2319                         pmd_name(gbl_driver_id),
2320                         ts_params->dev_id, 0,
2321                         chain_mode_name(pparams->chain),
2322                         rte_crypto_aead_algorithm_strings[pparams->aead_algo],
2323                         pparams->key_length,
2324                         pparams->buf_size);
2325         else
2326                 printf("\nOn %s dev%u qp%u, %s, cipher algo:%s, auth_algo:%s, "
2327                         "key length:%u, Packet Size %u bytes",
2328                         pmd_name(gbl_driver_id),
2329                         ts_params->dev_id, 0,
2330                         chain_mode_name(pparams->chain),
2331                         rte_crypto_cipher_algorithm_strings[pparams->cipher_algo],
2332                         rte_crypto_auth_algorithm_strings[pparams->auth_algo],
2333                         pparams->key_length,
2334                         pparams->buf_size);
2335         printf("\nOps Tx\tOps Rx\tOps/burst  ");
2336         printf("Retries  EmptyPolls\tIACycles/CyOp\tIACycles/Burst\t"
2337                         "IACycles/Byte");
2338
2339         for (i = 2; i <= 128 ; i *= 2) {
2340                 num_sent = 0;
2341                 num_ops_received = 0;
2342                 retries = 0;
2343                 failed_polls = 0;
2344                 burst_size = i;
2345                 total_cycles = 0;
2346                 while (num_sent < num_to_submit) {
2347                         start_cycles = rte_rdtsc_precise();
2348                         burst_sent = rte_cryptodev_enqueue_burst(
2349                                         ts_params->dev_id,
2350                                         0, &c_ops[num_sent],
2351                                         ((num_to_submit - num_sent) <
2352                                                 burst_size) ?
2353                                         num_to_submit - num_sent : burst_size);
2354                         end_cycles = rte_rdtsc_precise();
2355                         if (burst_sent == 0)
2356                                 retries++;
2357                         num_sent += burst_sent;
2358                         total_cycles += (end_cycles - start_cycles);
2359
2360                         /* Wait until requests have been sent. */
2361                         rte_delay_ms(1);
2362
2363                         start_cycles = rte_rdtsc_precise();
2364                         burst_received = rte_cryptodev_dequeue_burst(
2365                                         ts_params->dev_id, 0, proc_ops,
2366                                         burst_size);
2367                         end_cycles = rte_rdtsc_precise();
2368                         if (burst_received < burst_sent)
2369                                 failed_polls++;
2370                         num_ops_received += burst_received;
2371
2372                         total_cycles += end_cycles - start_cycles;
2373                 }
2374
2375                 while (num_ops_received != num_to_submit) {
2376                         /* Sending 0 length burst to flush sw crypto device */
2377                         rte_cryptodev_enqueue_burst(ts_params->dev_id, 0,
2378                                         NULL, 0);
2379
2380                         start_cycles = rte_rdtsc_precise();
2381                         burst_received = rte_cryptodev_dequeue_burst(
2382                                         ts_params->dev_id, 0, proc_ops,
2383                                         burst_size);
2384                         end_cycles = rte_rdtsc_precise();
2385
2386                         total_cycles += end_cycles - start_cycles;
2387                         if (burst_received == 0)
2388                                 failed_polls++;
2389                         num_ops_received += burst_received;
2390                 }
2391
2392                 printf("\n%u\t%u\t%u", num_sent, num_ops_received, burst_size);
2393                 printf("\t\t%"PRIu64, retries);
2394                 printf("\t%"PRIu64, failed_polls);
2395                 printf("\t\t%"PRIu64, total_cycles/num_ops_received);
2396                 printf("\t\t%"PRIu64, (total_cycles/num_ops_received) *
2397                                 burst_size);
2398                 printf("\t\t%"PRIu64,
2399                                 total_cycles /
2400                                 (num_ops_received * pparams->buf_size));
2401         }
2402         printf("\n");
2403
2404         for (i = 0; i < num_to_submit ; i++) {
2405                 rte_pktmbuf_free(c_ops[i]->sym->m_src);
2406                 rte_crypto_op_free(c_ops[i]);
2407         }
2408         rte_cryptodev_sym_session_free(ts_params->dev_id, sess);
2409
2410         return TEST_SUCCESS;
2411 }
2412
2413 static int
2414 test_perf_armv8_optimise_cyclecount(struct perf_test_params *pparams)
2415 {
2416         uint32_t num_to_submit = pparams->total_operations;
2417         struct rte_crypto_op *c_ops[num_to_submit];
2418         struct rte_crypto_op *proc_ops[num_to_submit];
2419         uint64_t failed_polls, retries, start_cycles, end_cycles,
2420                  total_cycles = 0;
2421         uint32_t burst_sent = 0, burst_received = 0;
2422         uint32_t i, burst_size, num_sent, num_ops_received;
2423         uint32_t nb_ops;
2424
2425         struct crypto_testsuite_params *ts_params = &testsuite_params;
2426
2427         static struct rte_cryptodev_sym_session *sess;
2428
2429         if (rte_cryptodev_count() == 0) {
2430                 printf("\nNo crypto devices found. Is PMD build configured?\n");
2431                 return TEST_FAILED;
2432         }
2433
2434         /* Create Crypto session*/
2435         sess = test_perf_create_armv8_session(ts_params->dev_id,
2436                         pparams->chain, pparams->cipher_algo,
2437                         pparams->key_length, pparams->auth_algo);
2438         TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
2439
2440         /* Generate Crypto op data structure(s)*/
2441         for (i = 0; i < num_to_submit ; i++) {
2442                 struct rte_mbuf *m = test_perf_create_pktmbuf(
2443                                                 ts_params->mbuf_mp,
2444                                                 pparams->buf_size);
2445                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate tx_buf");
2446
2447                 struct rte_crypto_op *op =
2448                                 rte_crypto_op_alloc(ts_params->op_mpool,
2449                                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2450                 TEST_ASSERT_NOT_NULL(op, "Failed to allocate op");
2451
2452                 op = test_perf_set_crypto_op_aes(op, m, sess, pparams->buf_size,
2453                                 pparams->chain);
2454                 TEST_ASSERT_NOT_NULL(op, "Failed to attach op to session");
2455
2456                 c_ops[i] = op;
2457         }
2458
2459         printf("\nOn %s dev%u qp%u, %s, cipher algo:%s, cipher key length:%u, "
2460                         "auth_algo:%s, Packet Size %u bytes",
2461                         pmd_name(gbl_driver_id),
2462                         ts_params->dev_id, 0,
2463                         chain_mode_name(pparams->chain),
2464                         rte_crypto_cipher_algorithm_strings[pparams->cipher_algo],
2465                         pparams->key_length,
2466                         rte_crypto_auth_algorithm_strings[pparams->auth_algo],
2467                         pparams->buf_size);
2468         printf("\nOps Tx\tOps Rx\tOps/burst  ");
2469         printf("Retries  "
2470                 "EmptyPolls\tIACycles/CyOp\tIACycles/Burst\tIACycles/Byte");
2471
2472         for (i = 2; i <= 128 ; i *= 2) {
2473                 num_sent = 0;
2474                 num_ops_received = 0;
2475                 retries = 0;
2476                 failed_polls = 0;
2477                 burst_size = i;
2478                 total_cycles = 0;
2479                 while (num_sent < num_to_submit) {
2480                         if ((num_to_submit - num_sent) < burst_size)
2481                                 nb_ops = num_to_submit - num_sent;
2482                         else
2483                                 nb_ops = burst_size;
2484
2485                         start_cycles = rte_rdtsc();
2486                         burst_sent = rte_cryptodev_enqueue_burst(
2487                                 ts_params->dev_id,
2488                                 0, &c_ops[num_sent],
2489                                 nb_ops);
2490                         end_cycles = rte_rdtsc();
2491
2492                         if (burst_sent == 0)
2493                                 retries++;
2494                         num_sent += burst_sent;
2495                         total_cycles += (end_cycles - start_cycles);
2496
2497                         start_cycles = rte_rdtsc();
2498                         burst_received = rte_cryptodev_dequeue_burst(
2499                                         ts_params->dev_id, 0, proc_ops,
2500                                         burst_size);
2501                         end_cycles = rte_rdtsc();
2502                         if (burst_received < burst_sent)
2503                                 failed_polls++;
2504                         num_ops_received += burst_received;
2505
2506                         total_cycles += end_cycles - start_cycles;
2507                 }
2508
2509                 while (num_ops_received != num_to_submit) {
2510                         /* Sending 0 length burst to flush sw crypto device */
2511                         rte_cryptodev_enqueue_burst(
2512                                                 ts_params->dev_id, 0, NULL, 0);
2513
2514                         start_cycles = rte_rdtsc();
2515                         burst_received = rte_cryptodev_dequeue_burst(
2516                                 ts_params->dev_id, 0, proc_ops, burst_size);
2517                         end_cycles = rte_rdtsc();
2518
2519                         total_cycles += end_cycles - start_cycles;
2520                         if (burst_received == 0)
2521                                 failed_polls++;
2522                         num_ops_received += burst_received;
2523                 }
2524
2525                 printf("\n%u\t%u\t%u", num_sent, num_ops_received, burst_size);
2526                 printf("\t\t%"PRIu64, retries);
2527                 printf("\t%"PRIu64, failed_polls);
2528                 printf("\t\t%"PRIu64, total_cycles/num_ops_received);
2529                 printf("\t\t%"PRIu64,
2530                         (total_cycles/num_ops_received)*burst_size);
2531                 printf("\t\t%"PRIu64,
2532                         total_cycles/(num_ops_received*pparams->buf_size));
2533         }
2534         printf("\n");
2535
2536         for (i = 0; i < num_to_submit ; i++) {
2537                 rte_pktmbuf_free(c_ops[i]->sym->m_src);
2538                 rte_crypto_op_free(c_ops[i]);
2539         }
2540
2541         return TEST_SUCCESS;
2542 }
2543
2544 static uint32_t get_auth_key_max_length(enum rte_crypto_auth_algorithm algo)
2545 {
2546         switch (algo) {
2547         case RTE_CRYPTO_AUTH_SNOW3G_UIA2:
2548                 return 16;
2549         case RTE_CRYPTO_AUTH_SHA1_HMAC:
2550                 return 64;
2551         case RTE_CRYPTO_AUTH_SHA224_HMAC:
2552                 return 64;
2553         case RTE_CRYPTO_AUTH_SHA256_HMAC:
2554                 return 64;
2555         case RTE_CRYPTO_AUTH_SHA384_HMAC:
2556                 return 128;
2557         case RTE_CRYPTO_AUTH_SHA512_HMAC:
2558                 return 128;
2559         default:
2560                 return 0;
2561         }
2562 }
2563
2564 static uint32_t get_auth_digest_length(enum rte_crypto_auth_algorithm algo)
2565 {
2566         switch (algo) {
2567         case RTE_CRYPTO_AUTH_SNOW3G_UIA2:
2568                 return 4;
2569         case RTE_CRYPTO_AUTH_SHA1_HMAC:
2570                 return TRUNCATED_DIGEST_BYTE_LENGTH_SHA1;
2571         case RTE_CRYPTO_AUTH_SHA224_HMAC:
2572                 return TRUNCATED_DIGEST_BYTE_LENGTH_SHA224;
2573         case RTE_CRYPTO_AUTH_SHA256_HMAC:
2574                 return TRUNCATED_DIGEST_BYTE_LENGTH_SHA256;
2575         case RTE_CRYPTO_AUTH_SHA384_HMAC:
2576                 return TRUNCATED_DIGEST_BYTE_LENGTH_SHA384;
2577         case RTE_CRYPTO_AUTH_SHA512_HMAC:
2578                 return TRUNCATED_DIGEST_BYTE_LENGTH_SHA512;
2579         default:
2580                 return 0;
2581         }
2582 }
2583
2584 static uint32_t get_aead_digest_length(enum rte_crypto_aead_algorithm algo)
2585 {
2586         switch (algo) {
2587         case RTE_CRYPTO_AEAD_AES_GCM:
2588                 return DIGEST_BYTE_LENGTH_AES_GCM;
2589         default:
2590                 return 0;
2591         }
2592 }
2593
2594 static uint8_t aes_key[] = {
2595                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2596                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2597                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2598                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2599 };
2600
2601 static uint8_t aes_iv[] = {
2602                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2603                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2604 };
2605
2606 static uint8_t aes_gcm_aad[] = {
2607                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2608                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2609 };
2610
2611 static uint8_t triple_des_key[] = {
2612                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2613                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2614                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2615 };
2616
2617 static uint8_t triple_des_iv[] = {
2618                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2619 };
2620
2621 static uint8_t hmac_sha_key[] = {
2622                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2623                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2624                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2625                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2626                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2627                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2628                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2629                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2630                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2631                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2632                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2633                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2634                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2635                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2636                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2637                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2638 };
2639
2640 static uint8_t snow3g_cipher_key[] = {
2641                 0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00,
2642                 0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48
2643 };
2644
2645 static uint8_t snow3g_iv[] = {
2646                 0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00,
2647                 0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00
2648 };
2649
2650 static uint8_t snow3g_hash_key[] = {
2651                 0xC7, 0x36, 0xC6, 0xAA, 0xB2, 0x2B, 0xFF, 0xF9,
2652                 0x1E, 0x26, 0x98, 0xD2, 0xE2, 0x2A, 0xD5, 0x7E
2653 };
2654
2655 static struct rte_cryptodev_sym_session *
2656 test_perf_create_aes_sha_session(uint8_t dev_id, enum chain_mode chain,
2657                 enum rte_crypto_cipher_algorithm cipher_algo,
2658                 unsigned cipher_key_len,
2659                 enum rte_crypto_auth_algorithm auth_algo)
2660 {
2661         struct rte_crypto_sym_xform cipher_xform = { 0 };
2662         struct rte_crypto_sym_xform auth_xform = { 0 };
2663
2664
2665         /* Setup Cipher Parameters */
2666         cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2667         cipher_xform.cipher.algo = cipher_algo;
2668         cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2669
2670         cipher_xform.cipher.key.data = aes_key;
2671         cipher_xform.cipher.key.length = cipher_key_len;
2672         cipher_xform.cipher.iv.offset = IV_OFFSET;
2673         cipher_xform.cipher.iv.length = AES_CIPHER_IV_LENGTH;
2674         if (chain != CIPHER_ONLY) {
2675                 /* Setup HMAC Parameters */
2676                 auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2677                 auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2678                 auth_xform.auth.algo = auth_algo;
2679                 auth_xform.auth.key.data = hmac_sha_key;
2680                 auth_xform.auth.key.length = get_auth_key_max_length(auth_algo);
2681                 auth_xform.auth.digest_length =
2682                                         get_auth_digest_length(auth_algo);
2683         }
2684         switch (chain) {
2685         case CIPHER_HASH:
2686                 cipher_xform.next = &auth_xform;
2687                 auth_xform.next = NULL;
2688                 /* Create Crypto session*/
2689                 return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
2690         case HASH_CIPHER:
2691                 auth_xform.next = &cipher_xform;
2692                 cipher_xform.next = NULL;
2693                 /* Create Crypto session*/
2694                 return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
2695         case CIPHER_ONLY:
2696                 cipher_xform.next = NULL;
2697                 /* Create Crypto session*/
2698                 return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
2699         default:
2700                 return NULL;
2701         }
2702 }
2703
2704 #define SNOW3G_CIPHER_IV_LENGTH 16
2705
2706 static struct rte_cryptodev_sym_session *
2707 test_perf_create_snow3g_session(uint8_t dev_id, enum chain_mode chain,
2708                 enum rte_crypto_cipher_algorithm cipher_algo, unsigned cipher_key_len,
2709                 enum rte_crypto_auth_algorithm auth_algo)
2710 {
2711         struct rte_crypto_sym_xform cipher_xform = {0};
2712         struct rte_crypto_sym_xform auth_xform = {0};
2713
2714
2715         /* Setup Cipher Parameters */
2716         cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2717         cipher_xform.cipher.algo = cipher_algo;
2718         cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2719
2720         cipher_xform.cipher.key.data = snow3g_cipher_key;
2721         cipher_xform.cipher.key.length = cipher_key_len;
2722         cipher_xform.cipher.iv.offset = IV_OFFSET;
2723         cipher_xform.cipher.iv.length = SNOW3G_CIPHER_IV_LENGTH;
2724
2725
2726         /* Setup HMAC Parameters */
2727         auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2728         auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2729         auth_xform.auth.algo = auth_algo;
2730
2731         auth_xform.auth.key.data = snow3g_hash_key;
2732         auth_xform.auth.key.length =  get_auth_key_max_length(auth_algo);
2733         auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
2734         /* Auth IV will be after cipher IV */
2735         auth_xform.auth.iv.offset = IV_OFFSET + SNOW3G_CIPHER_IV_LENGTH;
2736         auth_xform.auth.iv.length = SNOW3G_CIPHER_IV_LENGTH;
2737
2738         switch (chain) {
2739         case CIPHER_HASH:
2740                 cipher_xform.next = &auth_xform;
2741                 auth_xform.next = NULL;
2742                 /* Create Crypto session*/
2743                 return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
2744         case HASH_CIPHER:
2745                 auth_xform.next = &cipher_xform;
2746                 cipher_xform.next = NULL;
2747                 /* Create Crypto session*/
2748                 return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
2749         case CIPHER_ONLY:
2750                 cipher_xform.next = NULL;
2751                 /* Create Crypto session*/
2752                 return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
2753         case HASH_ONLY:
2754                 auth_xform.next = NULL;
2755                 /* Create Crypto session */
2756                 return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
2757         default:
2758                 return NULL;
2759         }
2760 }
2761
2762 static struct rte_cryptodev_sym_session *
2763 test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
2764                 enum rte_crypto_cipher_algorithm cipher_algo,
2765                 unsigned int key_len,
2766                 enum rte_crypto_auth_algorithm auth_algo,
2767                 enum rte_crypto_aead_algorithm aead_algo)
2768 {
2769         struct rte_crypto_sym_xform cipher_xform = { 0 };
2770         struct rte_crypto_sym_xform auth_xform = { 0 };
2771         struct rte_crypto_sym_xform aead_xform = { 0 };
2772
2773         if (chain == CIPHER_HASH || chain == HASH_CIPHER) {
2774                 /* Setup Cipher Parameters */
2775                 cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2776                 cipher_xform.cipher.algo = cipher_algo;
2777                 cipher_xform.cipher.iv.offset = IV_OFFSET;
2778                 cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2779
2780                 switch (cipher_algo) {
2781                 case RTE_CRYPTO_CIPHER_3DES_CBC:
2782                 case RTE_CRYPTO_CIPHER_3DES_CTR:
2783                         cipher_xform.cipher.key.data = triple_des_key;
2784                         cipher_xform.cipher.iv.length = TRIPLE_DES_CIPHER_IV_LENGTH;
2785                         break;
2786                 case RTE_CRYPTO_CIPHER_AES_CBC:
2787                 case RTE_CRYPTO_CIPHER_AES_CTR:
2788                         cipher_xform.cipher.key.data = aes_key;
2789                         cipher_xform.cipher.iv.length = AES_CIPHER_IV_LENGTH;
2790                         break;
2791                 default:
2792                         return NULL;
2793                 }
2794
2795                 cipher_xform.cipher.key.length = key_len;
2796
2797                 /* Setup Auth Parameters */
2798                 auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2799                 auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2800                 auth_xform.auth.algo = auth_algo;
2801
2802                 switch (auth_algo) {
2803                 case RTE_CRYPTO_AUTH_SHA1_HMAC:
2804                         auth_xform.auth.key.data = hmac_sha_key;
2805                         break;
2806                 default:
2807                         return NULL;
2808                 }
2809
2810                 auth_xform.auth.key.length =  get_auth_key_max_length(auth_algo);
2811                 auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
2812         } else if (chain == AEAD) {
2813                 /* Setup AEAD Parameters */
2814                 aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
2815                 aead_xform.aead.op = RTE_CRYPTO_AEAD_OP_ENCRYPT;
2816                 aead_xform.aead.algo = aead_algo;
2817                 aead_xform.aead.iv.offset = IV_OFFSET;
2818
2819                 switch (aead_algo) {
2820                 case RTE_CRYPTO_AEAD_AES_GCM:
2821                         aead_xform.aead.key.data = aes_key;
2822                         aead_xform.aead.iv.length = AES_CIPHER_IV_LENGTH;
2823                         aead_xform.aead.add_auth_data_length = AES_GCM_AAD_LENGTH;
2824                         aead_xform.aead.digest_length = get_aead_digest_length(aead_algo);
2825                         break;
2826                 default:
2827                         return NULL;
2828                 }
2829
2830                 aead_xform.aead.key.length = key_len;
2831         }
2832
2833         switch (chain) {
2834         case CIPHER_HASH:
2835                 cipher_xform.next = &auth_xform;
2836                 auth_xform.next = NULL;
2837                 /* Create Crypto session*/
2838                 return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
2839         case HASH_CIPHER:
2840                 auth_xform.next = &cipher_xform;
2841                 cipher_xform.next = NULL;
2842                 /* Create Crypto session*/
2843                 return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
2844         case AEAD:
2845                 /* Create Crypto session*/
2846                 return rte_cryptodev_sym_session_create(dev_id, &aead_xform);
2847         default:
2848                 return NULL;
2849         }
2850 }
2851
2852 static struct rte_cryptodev_sym_session *
2853 test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain,
2854                 enum rte_crypto_cipher_algorithm cipher_algo,
2855                 unsigned int cipher_key_len,
2856                 enum rte_crypto_auth_algorithm auth_algo)
2857 {
2858         struct rte_crypto_sym_xform cipher_xform = { 0 };
2859         struct rte_crypto_sym_xform auth_xform = { 0 };
2860
2861         /* Setup Cipher Parameters */
2862         cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2863         cipher_xform.cipher.algo = cipher_algo;
2864
2865         switch (cipher_algo) {
2866         case RTE_CRYPTO_CIPHER_AES_CBC:
2867                 cipher_xform.cipher.key.data = aes_cbc_128_key;
2868                 break;
2869         default:
2870                 return NULL;
2871         }
2872
2873         cipher_xform.cipher.key.length = cipher_key_len;
2874         cipher_xform.cipher.iv.offset = IV_OFFSET;
2875         cipher_xform.cipher.iv.length = AES_CIPHER_IV_LENGTH;
2876
2877         /* Setup Auth Parameters */
2878         auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2879         auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2880         auth_xform.auth.algo = auth_algo;
2881
2882         auth_xform.auth.digest_length = get_auth_digest_length(auth_algo);
2883
2884         switch (chain) {
2885         case CIPHER_HASH:
2886                 cipher_xform.next = &auth_xform;
2887                 auth_xform.next = NULL;
2888                 /* Encrypt and hash the result */
2889                 cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2890                 /* Create Crypto session*/
2891                 return rte_cryptodev_sym_session_create(dev_id, &cipher_xform);
2892         case HASH_CIPHER:
2893                 auth_xform.next = &cipher_xform;
2894                 cipher_xform.next = NULL;
2895                 /* Hash encrypted message and decrypt */
2896                 cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2897                 /* Create Crypto session*/
2898                 return rte_cryptodev_sym_session_create(dev_id, &auth_xform);
2899         default:
2900                 return NULL;
2901         }
2902 }
2903
2904 static struct rte_mbuf *
2905 test_perf_create_pktmbuf(struct rte_mempool *mpool, unsigned buf_sz)
2906 {
2907         struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
2908
2909         if (rte_pktmbuf_append(m, buf_sz) == NULL) {
2910                 rte_pktmbuf_free(m);
2911                 return NULL;
2912         }
2913
2914         memset(rte_pktmbuf_mtod(m, uint8_t *), 0, buf_sz);
2915
2916         return m;
2917 }
2918
2919 static inline struct rte_crypto_op *
2920 test_perf_set_crypto_op_aes(struct rte_crypto_op *op, struct rte_mbuf *m,
2921                 struct rte_cryptodev_sym_session *sess, unsigned int data_len,
2922                 enum chain_mode chain)
2923 {
2924         if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
2925                 rte_crypto_op_free(op);
2926                 return NULL;
2927         }
2928
2929         /* Authentication Parameters */
2930         if (chain == CIPHER_ONLY) {
2931                 op->sym->auth.digest.data = NULL;
2932                 op->sym->auth.digest.phys_addr = 0;
2933                 op->sym->auth.data.offset = 0;
2934                 op->sym->auth.data.length = 0;
2935         } else {
2936                 op->sym->auth.digest.data = rte_pktmbuf_mtod_offset(m,
2937                                  uint8_t *, data_len);
2938                 op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m,
2939                                 data_len);
2940                 op->sym->auth.data.offset = 0;
2941                 op->sym->auth.data.length = data_len;
2942         }
2943
2944
2945         /* Copy the IV at the end of the crypto operation */
2946         rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
2947                         aes_iv, AES_CIPHER_IV_LENGTH);
2948
2949         /* Cipher Parameters */
2950         op->sym->cipher.data.offset = 0;
2951         op->sym->cipher.data.length = data_len;
2952
2953         op->sym->m_src = m;
2954
2955         return op;
2956 }
2957
2958 static inline struct rte_crypto_op *
2959 test_perf_set_crypto_op_aes_gcm(struct rte_crypto_op *op, struct rte_mbuf *m,
2960                 struct rte_cryptodev_sym_session *sess, unsigned int data_len,
2961                 enum chain_mode chain __rte_unused)
2962 {
2963         if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
2964                 rte_crypto_op_free(op);
2965                 return NULL;
2966         }
2967
2968         /* Authentication Parameters */
2969         op->sym->aead.digest.data = (uint8_t *)m->buf_addr +
2970                                         (m->data_off + data_len);
2971         op->sym->aead.digest.phys_addr =
2972                                 rte_pktmbuf_mtophys_offset(m, data_len);
2973         op->sym->aead.aad.data = aes_gcm_aad;
2974
2975         /* Copy IV at the end of the crypto operation */
2976         rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
2977                         aes_iv, AES_CIPHER_IV_LENGTH);
2978
2979         /* Data lengths/offsets Parameters */
2980         op->sym->aead.data.offset = 0;
2981         op->sym->aead.data.length = data_len;
2982
2983         op->sym->m_src = m;
2984
2985         return op;
2986 }
2987
2988 static inline struct rte_crypto_op *
2989 test_perf_set_crypto_op_snow3g(struct rte_crypto_op *op, struct rte_mbuf *m,
2990                 struct rte_cryptodev_sym_session *sess, unsigned int data_len)
2991 {
2992         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op,
2993                         uint8_t *, IV_OFFSET);
2994
2995         if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
2996                 rte_crypto_op_free(op);
2997                 return NULL;
2998         }
2999
3000         rte_memcpy(iv_ptr, snow3g_iv, SNOW3G_CIPHER_IV_LENGTH);
3001
3002         /* Authentication Parameters */
3003         op->sym->auth.digest.data = (uint8_t *)m->buf_addr +
3004                                                 (m->data_off + data_len);
3005         op->sym->auth.digest.phys_addr =
3006                                 rte_pktmbuf_mtophys_offset(m, data_len);
3007
3008         /* Data lengths/offsets Parameters */
3009         op->sym->auth.data.offset = 0;
3010         op->sym->auth.data.length = data_len << 3;
3011
3012         op->sym->cipher.data.offset = 0;
3013         op->sym->cipher.data.length = data_len << 3;
3014
3015         op->sym->m_src = m;
3016
3017         return op;
3018 }
3019
3020 static inline struct rte_crypto_op *
3021 test_perf_set_crypto_op_snow3g_cipher(struct rte_crypto_op *op,
3022                 struct rte_mbuf *m,
3023                 struct rte_cryptodev_sym_session *sess,
3024                 unsigned data_len)
3025 {
3026         if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
3027                 rte_crypto_op_free(op);
3028                 return NULL;
3029         }
3030
3031         /* Copy IV at the end of the crypto operation */
3032         rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
3033                         snow3g_iv, SNOW3G_CIPHER_IV_LENGTH);
3034
3035         /* Cipher Parameters */
3036         op->sym->cipher.data.offset = 0;
3037         op->sym->cipher.data.length = data_len << 3;
3038
3039         rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
3040                         snow3g_iv,
3041                         SNOW3G_CIPHER_IV_LENGTH);
3042
3043         op->sym->m_src = m;
3044
3045         return op;
3046 }
3047
3048
3049 static inline struct rte_crypto_op *
3050 test_perf_set_crypto_op_snow3g_hash(struct rte_crypto_op *op,
3051                 struct rte_mbuf *m,
3052                 struct rte_cryptodev_sym_session *sess,
3053                 unsigned int data_len)
3054 {
3055         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op,
3056                         uint8_t *, IV_OFFSET);
3057
3058         if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
3059                 rte_crypto_op_free(op);
3060                 return NULL;
3061         }
3062
3063         rte_memcpy(iv_ptr, snow3g_iv, SNOW3G_CIPHER_IV_LENGTH);
3064
3065         /* Authentication Parameters */
3066
3067         op->sym->auth.digest.data =
3068                         (uint8_t *)rte_pktmbuf_mtod_offset(m, uint8_t *,
3069                         data_len);
3070         op->sym->auth.digest.phys_addr =
3071                                 rte_pktmbuf_mtophys_offset(m, data_len +
3072                                         SNOW3G_CIPHER_IV_LENGTH);
3073
3074         /* Data lengths/offsets Parameters */
3075         op->sym->auth.data.offset = 0;
3076         op->sym->auth.data.length = data_len << 3;
3077
3078         op->sym->m_src = m;
3079
3080         return op;
3081 }
3082
3083
3084 static inline struct rte_crypto_op *
3085 test_perf_set_crypto_op_3des(struct rte_crypto_op *op, struct rte_mbuf *m,
3086                 struct rte_cryptodev_sym_session *sess, unsigned int data_len,
3087                 enum chain_mode chain __rte_unused)
3088 {
3089         if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
3090                 rte_crypto_op_free(op);
3091                 return NULL;
3092         }
3093
3094         /* Authentication Parameters */
3095         op->sym->auth.digest.data = (uint8_t *)m->buf_addr +
3096                                         (m->data_off + data_len);
3097         op->sym->auth.digest.phys_addr =
3098                                 rte_pktmbuf_mtophys_offset(m, data_len);
3099
3100         /* Copy IV at the end of the crypto operation */
3101         rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
3102                         triple_des_iv, TRIPLE_DES_CIPHER_IV_LENGTH);
3103
3104         /* Data lengths/offsets Parameters */
3105         op->sym->auth.data.offset = 0;
3106         op->sym->auth.data.length = data_len;
3107
3108         op->sym->cipher.data.offset = 0;
3109         op->sym->cipher.data.length = data_len;
3110
3111         op->sym->m_src = m;
3112
3113         return op;
3114 }
3115
3116 /* An mbuf set is used in each burst. An mbuf can be used by multiple bursts at
3117  * same time, i.e. as they're not dereferenced there's no need to wait until
3118  * finished with to re-use */
3119 #define NUM_MBUF_SETS 8
3120
3121 static int
3122 test_perf_aes_sha(uint8_t dev_id, uint16_t queue_id,
3123                 struct perf_test_params *pparams)
3124 {
3125         uint16_t i, k, l, m;
3126         uint16_t j = 0;
3127         uint16_t ops_unused = 0;
3128
3129         uint64_t burst_enqueued = 0, total_enqueued = 0, burst_dequeued = 0;
3130         uint64_t processed = 0, failed_polls = 0, retries = 0;
3131         uint64_t tsc_start = 0, tsc_end = 0;
3132
3133         uint16_t digest_length = get_auth_digest_length(pparams->auth_algo);
3134
3135         struct rte_crypto_op *ops[pparams->burst_size];
3136         struct rte_crypto_op *proc_ops[pparams->burst_size];
3137
3138         struct rte_mbuf *mbufs[pparams->burst_size * 8];
3139
3140         struct crypto_testsuite_params *ts_params = &testsuite_params;
3141
3142         static struct rte_cryptodev_sym_session *sess;
3143
3144         if (rte_cryptodev_count() == 0) {
3145                 printf("\nNo crypto devices available. Is kernel driver loaded?\n");
3146                 return TEST_FAILED;
3147         }
3148
3149         /* Create Crypto session*/
3150         sess = test_perf_create_aes_sha_session(ts_params->dev_id,
3151                         pparams->chain, pparams->cipher_algo,
3152                         pparams->key_length, pparams->auth_algo);
3153         TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
3154
3155         /* Generate a burst of crypto operations */
3156         for (i = 0; i < (pparams->burst_size * NUM_MBUF_SETS); i++) {
3157                 mbufs[i] = test_perf_create_pktmbuf(
3158                                 ts_params->mbuf_mp,
3159                                 pparams->buf_size);
3160
3161                 if (mbufs[i] == NULL) {
3162                         printf("\nFailed to get mbuf - freeing the rest.\n");
3163                         for (k = 0; k < i; k++)
3164                                 rte_pktmbuf_free(mbufs[k]);
3165                         return -1;
3166                 }
3167
3168                 /* Make room for Digest in mbuf */
3169                 if (pparams->chain != CIPHER_ONLY)
3170                         rte_pktmbuf_append(mbufs[i], digest_length);
3171         }
3172
3173
3174         tsc_start = rte_rdtsc_precise();
3175
3176         while (total_enqueued < pparams->total_operations) {
3177                 uint16_t burst_size =
3178                 total_enqueued+pparams->burst_size <= pparams->total_operations ?
3179                 pparams->burst_size : pparams->total_operations-total_enqueued;
3180                 uint16_t ops_needed = burst_size-ops_unused;
3181
3182                 if (ops_needed != rte_crypto_op_bulk_alloc(ts_params->op_mpool,
3183                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, ops_needed)){
3184                         printf("\nFailed to alloc enough ops, finish dequeuing "
3185                                 "and free ops below.");
3186                 } else {
3187                         for (i = 0; i < ops_needed; i++)
3188                                 ops[i] = test_perf_set_crypto_op_aes(ops[i],
3189                                         mbufs[i + (pparams->burst_size *
3190                                                 (j % NUM_MBUF_SETS))],
3191                                         sess, pparams->buf_size,
3192                                         pparams->chain);
3193
3194                         /* enqueue burst */
3195                         burst_enqueued = rte_cryptodev_enqueue_burst(dev_id,
3196                                         queue_id, ops, burst_size);
3197
3198                         if (burst_enqueued < burst_size)
3199                                 retries++;
3200
3201                         ops_unused = burst_size-burst_enqueued;
3202                         total_enqueued += burst_enqueued;
3203                 }
3204
3205                 /* dequeue burst */
3206                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
3207                                 proc_ops, pparams->burst_size);
3208                 if (burst_dequeued == 0)
3209                         failed_polls++;
3210                 else {
3211                         processed += burst_dequeued;
3212
3213                         for (l = 0; l < burst_dequeued; l++)
3214                                 rte_crypto_op_free(proc_ops[l]);
3215                 }
3216                 j++;
3217         }
3218
3219         /* Dequeue any operations still in the crypto device */
3220         while (processed < pparams->total_operations) {
3221                 /* Sending 0 length burst to flush sw crypto device */
3222                 rte_cryptodev_enqueue_burst(dev_id, queue_id, NULL, 0);
3223
3224                 /* dequeue burst */
3225                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
3226                                 proc_ops, pparams->burst_size);
3227                 if (burst_dequeued == 0)
3228                         failed_polls++;
3229                 else {
3230                         processed += burst_dequeued;
3231
3232                         for (m = 0; m < burst_dequeued; m++)
3233                                 rte_crypto_op_free(proc_ops[m]);
3234                 }
3235         }
3236
3237         tsc_end = rte_rdtsc_precise();
3238
3239         double ops_s = ((double)processed / (tsc_end - tsc_start)) * rte_get_tsc_hz();
3240         double throughput = (ops_s * pparams->buf_size * 8) / 1000000000;
3241
3242         printf("\t%u\t%6.2f\t%10.2f\t%8"PRIu64"\t%8"PRIu64, pparams->buf_size, ops_s/1000000,
3243                         throughput, retries, failed_polls);
3244
3245         for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
3246                 rte_pktmbuf_free(mbufs[i]);
3247         rte_cryptodev_sym_session_free(dev_id, sess);
3248
3249         printf("\n");
3250         return TEST_SUCCESS;
3251 }
3252
3253
3254 static int
3255 test_perf_snow3g(uint8_t dev_id, uint16_t queue_id,
3256                 struct perf_test_params *pparams)
3257 {
3258         uint16_t i, k, l, m;
3259         uint16_t j = 0;
3260         uint16_t ops_unused = 0;
3261         uint64_t burst_enqueued = 0, total_enqueued = 0, burst_dequeued = 0;
3262         uint64_t processed = 0, failed_polls = 0, retries = 0;
3263         uint64_t tsc_start = 0, tsc_end = 0;
3264
3265         uint16_t digest_length = get_auth_digest_length(pparams->auth_algo);
3266
3267         struct rte_crypto_op *ops[pparams->burst_size];
3268         struct rte_crypto_op *proc_ops[pparams->burst_size];
3269
3270         struct rte_mbuf *mbufs[pparams->burst_size * NUM_MBUF_SETS];
3271
3272         struct crypto_testsuite_params *ts_params = &testsuite_params;
3273
3274         static struct rte_cryptodev_sym_session *sess;
3275
3276         if (rte_cryptodev_count() == 0) {
3277                 printf("\nNo crypto devices found. Is PMD build configured?\n");
3278                 printf("\nAnd is kernel driver loaded for HW PMDs?\n");
3279                 return TEST_FAILED;
3280         }
3281
3282         /* Create Crypto session*/
3283         sess = test_perf_create_snow3g_session(ts_params->dev_id,
3284                         pparams->chain, pparams->cipher_algo,
3285                         pparams->key_length, pparams->auth_algo);
3286         TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
3287
3288         /* Generate a burst of crypto operations */
3289         for (i = 0; i < (pparams->burst_size * NUM_MBUF_SETS); i++) {
3290                 /*
3291                  * Buffer size is allocated, for perf tests they
3292                  * are equal + digest len.
3293                  */
3294                 mbufs[i] = test_perf_create_pktmbuf(
3295                                 ts_params->mbuf_mp,
3296                                 pparams->buf_size  +
3297                                 digest_length);
3298
3299                 if (mbufs[i] == NULL) {
3300                         printf("\nFailed to get mbuf - freeing the rest.\n");
3301                         for (k = 0; k < i; k++)
3302                                 rte_pktmbuf_free(mbufs[k]);
3303                         return -1;
3304                 }
3305
3306         }
3307
3308         tsc_start = rte_rdtsc_precise();
3309
3310         while (total_enqueued < pparams->total_operations) {
3311                 uint16_t burst_size =
3312                                 (total_enqueued+pparams->burst_size)
3313                                                 <= pparams->total_operations ?
3314                 pparams->burst_size : pparams->total_operations-total_enqueued;
3315                 uint16_t ops_needed = burst_size-ops_unused;
3316                 /* Handle the last burst correctly */
3317                 uint16_t op_offset = pparams->burst_size - burst_size;
3318
3319                 if (ops_needed !=
3320                         rte_crypto_op_bulk_alloc(ts_params->op_mpool,
3321                                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
3322                                                 ops+op_offset, ops_needed)) {
3323                         printf("\nFailed to alloc enough ops.");
3324                         /*Don't exit, dequeue, more ops should become available*/
3325                 } else {
3326                         for (i = 0; i < ops_needed; i++) {
3327                                 if (pparams->chain == HASH_ONLY)
3328                                         ops[i+op_offset] =
3329                                         test_perf_set_crypto_op_snow3g_hash(ops[i+op_offset],
3330                                         mbufs[i +
3331                                           (pparams->burst_size * (j % NUM_MBUF_SETS))],
3332                                         sess,
3333                                         pparams->buf_size);
3334                                 else if (pparams->chain == CIPHER_ONLY)
3335                                         ops[i+op_offset] =
3336                                         test_perf_set_crypto_op_snow3g_cipher(ops[i+op_offset],
3337                                         mbufs[i +
3338                                           (pparams->burst_size * (j % NUM_MBUF_SETS))],
3339                                         sess,
3340                                         pparams->buf_size);
3341                                 else
3342                                         return 1;
3343                         }
3344
3345                         /* enqueue burst */
3346                         burst_enqueued =
3347                                 rte_cryptodev_enqueue_burst(dev_id, queue_id,
3348                                                 ops+op_offset, burst_size);
3349
3350                         if (burst_enqueued < burst_size)
3351                                 retries++;
3352
3353                         ops_unused = burst_size-burst_enqueued;
3354                         total_enqueued += burst_enqueued;
3355                 }
3356
3357                 /* dequeue burst */
3358                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
3359                                         proc_ops, pparams->burst_size);
3360                 if (burst_dequeued == 0) {
3361                         failed_polls++;
3362                 } else {
3363                         processed += burst_dequeued;
3364                         for (l = 0; l < burst_dequeued; l++)
3365                                 rte_crypto_op_free(proc_ops[l]);
3366                 }
3367                 j++;
3368         }
3369
3370         /* Dequeue any operations still in the crypto device */
3371         while (processed < pparams->total_operations) {
3372                 /* Sending 0 length burst to flush sw crypto device */
3373                 rte_cryptodev_enqueue_burst(dev_id, queue_id, NULL, 0);
3374
3375                 /* dequeue burst */
3376                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
3377                                 proc_ops, pparams->burst_size);
3378                 if (burst_dequeued == 0)
3379                         failed_polls++;
3380                 else {
3381                         processed += burst_dequeued;
3382                         for (m = 0; m < burst_dequeued; m++)
3383                                 rte_crypto_op_free(proc_ops[m]);
3384                 }
3385         }
3386
3387         tsc_end = rte_rdtsc_precise();
3388
3389         double ops_s = ((double)processed / (tsc_end - tsc_start)) * rte_get_tsc_hz();
3390         double cycles_burst = (double) (tsc_end - tsc_start) /
3391                                         (double) processed * pparams->burst_size;
3392         double cycles_buff = (double) (tsc_end - tsc_start) / (double) processed;
3393         double cycles_B = cycles_buff / pparams->buf_size;
3394         double throughput = (ops_s * pparams->buf_size * 8) / 1000000;
3395
3396         if (gbl_driver_id == rte_cryptodev_driver_id_get(
3397                         RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))) {
3398                 /* Cycle count misleading on HW devices for this test, so don't print */
3399                 printf("%4u\t%6.2f\t%10.2f\t n/a \t\t n/a "
3400                         "\t\t n/a \t\t%8"PRIu64"\t%8"PRIu64,
3401                         pparams->buf_size, ops_s/1000000,
3402                         throughput, retries, failed_polls);
3403         } else {
3404                 printf("%4u\t%6.2f\t%10.2f\t%10.2f\t%8.2f"
3405                         "\t%8.2f\t%8"PRIu64"\t%8"PRIu64,
3406                         pparams->buf_size, ops_s/1000000, throughput, cycles_burst,
3407                         cycles_buff, cycles_B, retries, failed_polls);
3408         }
3409
3410         for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
3411                 rte_pktmbuf_free(mbufs[i]);
3412         rte_cryptodev_sym_session_free(dev_id, sess);
3413
3414         printf("\n");
3415         return TEST_SUCCESS;
3416 }
3417
3418 static int
3419 test_perf_openssl(uint8_t dev_id, uint16_t queue_id,
3420                 struct perf_test_params *pparams)
3421 {
3422         uint16_t i, k, l, m;
3423         uint16_t j = 0;
3424         uint16_t ops_unused = 0;
3425
3426         uint64_t burst_enqueued = 0, total_enqueued = 0, burst_dequeued = 0;
3427         uint64_t processed = 0, failed_polls = 0, retries = 0;
3428         uint64_t tsc_start = 0, tsc_end = 0;
3429
3430         struct rte_crypto_op *ops[pparams->burst_size];
3431         struct rte_crypto_op *proc_ops[pparams->burst_size];
3432
3433         struct rte_mbuf *mbufs[pparams->burst_size * NUM_MBUF_SETS];
3434
3435         struct crypto_testsuite_params *ts_params = &testsuite_params;
3436
3437         static struct rte_cryptodev_sym_session *sess;
3438
3439         static struct rte_crypto_op *(*test_perf_set_crypto_op)
3440                         (struct rte_crypto_op *, struct rte_mbuf *,
3441                                         struct rte_cryptodev_sym_session *,
3442                                         unsigned int,
3443                                         enum chain_mode);
3444
3445         if (pparams->chain == AEAD)
3446                 test_perf_set_crypto_op =
3447                                         test_perf_set_crypto_op_aes_gcm;
3448         else {
3449                 switch (pparams->cipher_algo) {
3450                 case RTE_CRYPTO_CIPHER_3DES_CBC:
3451                 case RTE_CRYPTO_CIPHER_3DES_CTR:
3452                         test_perf_set_crypto_op = test_perf_set_crypto_op_3des;
3453                         break;
3454                 case RTE_CRYPTO_CIPHER_AES_CBC:
3455                 case RTE_CRYPTO_CIPHER_AES_CTR:
3456                         test_perf_set_crypto_op = test_perf_set_crypto_op_aes;
3457                         break;
3458                 default:
3459                         return TEST_FAILED;
3460                 }
3461         }
3462
3463         if (rte_cryptodev_count() == 0) {
3464                 printf("\nNo crypto devices found. Is PMD build configured?\n");
3465                 return TEST_FAILED;
3466         }
3467
3468         /* Create Crypto session*/
3469         sess = test_perf_create_openssl_session(ts_params->dev_id,
3470                         pparams->chain, pparams->cipher_algo,
3471                         pparams->key_length, pparams->auth_algo,
3472                         pparams->aead_algo);
3473         TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
3474
3475         /* Generate a burst of crypto operations */
3476         for (i = 0; i < (pparams->burst_size * NUM_MBUF_SETS); i++) {
3477                 mbufs[i] = test_perf_create_pktmbuf(
3478                                 ts_params->mbuf_mp,
3479                                 pparams->buf_size);
3480
3481                 if (mbufs[i] == NULL) {
3482                         printf("\nFailed to get mbuf - freeing the rest.\n");
3483                         for (k = 0; k < i; k++)
3484                                 rte_pktmbuf_free(mbufs[k]);
3485                         return -1;
3486                 }
3487         }
3488
3489         tsc_start = rte_rdtsc_precise();
3490
3491         while (total_enqueued < pparams->total_operations) {
3492                 uint16_t burst_size =
3493                 total_enqueued + pparams->burst_size <=
3494                 pparams->total_operations ? pparams->burst_size :
3495                                 pparams->total_operations - total_enqueued;
3496                 uint16_t ops_needed = burst_size - ops_unused;
3497
3498                 if (ops_needed != rte_crypto_op_bulk_alloc(ts_params->op_mpool,
3499                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, ops_needed)){
3500                         printf("\nFailed to alloc enough ops, finish dequeuing "
3501                                 "and free ops below.");
3502                 } else {
3503                         for (i = 0; i < ops_needed; i++)
3504                                 ops[i] = test_perf_set_crypto_op(ops[i],
3505                                         mbufs[i + (pparams->burst_size *
3506                                                 (j % NUM_MBUF_SETS))],
3507                                         sess, pparams->buf_size,
3508                                         pparams->chain);
3509
3510                         /* enqueue burst */
3511                         burst_enqueued = rte_cryptodev_enqueue_burst(dev_id,
3512                                         queue_id, ops, burst_size);
3513
3514                         if (burst_enqueued < burst_size)
3515                                 retries++;
3516
3517                         ops_unused = burst_size - burst_enqueued;
3518                         total_enqueued += burst_enqueued;
3519                 }
3520
3521                 /* dequeue burst */
3522                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
3523                                 proc_ops, pparams->burst_size);
3524                 if (burst_dequeued == 0)
3525                         failed_polls++;
3526                 else {
3527                         processed += burst_dequeued;
3528
3529                         for (l = 0; l < burst_dequeued; l++)
3530                                 rte_crypto_op_free(proc_ops[l]);
3531                 }
3532                 j++;
3533         }
3534
3535         /* Dequeue any operations still in the crypto device */
3536         while (processed < pparams->total_operations) {
3537                 /* Sending 0 length burst to flush sw crypto device */
3538                 rte_cryptodev_enqueue_burst(dev_id, queue_id, NULL, 0);
3539
3540                 /* dequeue burst */
3541                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
3542                                 proc_ops, pparams->burst_size);
3543                 if (burst_dequeued == 0)
3544                         failed_polls++;
3545                 else {
3546                         processed += burst_dequeued;
3547
3548                         for (m = 0; m < burst_dequeued; m++)
3549                                 rte_crypto_op_free(proc_ops[m]);
3550                 }
3551         }
3552
3553         tsc_end = rte_rdtsc_precise();
3554
3555         double ops_s = ((double)processed / (tsc_end - tsc_start))
3556                                         * rte_get_tsc_hz();
3557         double throughput = (ops_s * pparams->buf_size * NUM_MBUF_SETS)
3558                                         / 1000000000;
3559
3560         printf("\t%u\t%6.2f\t%10.2f\t%8"PRIu64"\t%8"PRIu64, pparams->buf_size,
3561                         ops_s / 1000000, throughput, retries, failed_polls);
3562
3563         for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
3564                 rte_pktmbuf_free(mbufs[i]);
3565         rte_cryptodev_sym_session_free(dev_id, sess);
3566
3567         printf("\n");
3568         return TEST_SUCCESS;
3569 }
3570
3571 static int
3572 test_perf_armv8(uint8_t dev_id, uint16_t queue_id,
3573                 struct perf_test_params *pparams)
3574 {
3575         uint16_t i, k, l, m;
3576         uint16_t j = 0;
3577         uint16_t ops_unused = 0;
3578         uint16_t burst_size;
3579         uint16_t ops_needed;
3580
3581         uint64_t burst_enqueued = 0, total_enqueued = 0, burst_dequeued = 0;
3582         uint64_t processed = 0, failed_polls = 0, retries = 0;
3583         uint64_t tsc_start = 0, tsc_end = 0;
3584
3585         struct rte_crypto_op *ops[pparams->burst_size];
3586         struct rte_crypto_op *proc_ops[pparams->burst_size];
3587
3588         struct rte_mbuf *mbufs[pparams->burst_size * NUM_MBUF_SETS];
3589
3590         struct crypto_testsuite_params *ts_params = &testsuite_params;
3591
3592         static struct rte_cryptodev_sym_session *sess;
3593
3594         if (rte_cryptodev_count() == 0) {
3595                 printf("\nNo crypto devices found. Is PMD build configured?\n");
3596                 return TEST_FAILED;
3597         }
3598
3599         /* Create Crypto session*/
3600         sess = test_perf_create_armv8_session(ts_params->dev_id,
3601                         pparams->chain, pparams->cipher_algo,
3602                         pparams->key_length, pparams->auth_algo);
3603         TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
3604
3605         /* Generate a burst of crypto operations */
3606         for (i = 0; i < (pparams->burst_size * NUM_MBUF_SETS); i++) {
3607                 mbufs[i] = test_perf_create_pktmbuf(
3608                                 ts_params->mbuf_mp,
3609                                 pparams->buf_size);
3610
3611                 if (mbufs[i] == NULL) {
3612                         printf("\nFailed to get mbuf - freeing the rest.\n");
3613                         for (k = 0; k < i; k++)
3614                                 rte_pktmbuf_free(mbufs[k]);
3615                         return -1;
3616                 }
3617         }
3618
3619         tsc_start = rte_rdtsc();
3620
3621         while (total_enqueued < pparams->total_operations) {
3622                 if ((total_enqueued + pparams->burst_size) <=
3623                                         pparams->total_operations)
3624                         burst_size = pparams->burst_size;
3625                 else
3626                         burst_size = pparams->total_operations - total_enqueued;
3627
3628                 ops_needed = burst_size - ops_unused;
3629
3630                 if (ops_needed != rte_crypto_op_bulk_alloc(ts_params->op_mpool,
3631                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, ops_needed)){
3632                         printf("\nFailed to alloc enough ops, finish dequeuing "
3633                                 "and free ops below.");
3634                 } else {
3635                         for (i = 0; i < ops_needed; i++)
3636                                 ops[i] = test_perf_set_crypto_op_aes(ops[i],
3637                                         mbufs[i + (pparams->burst_size *
3638                                                 (j % NUM_MBUF_SETS))], sess,
3639                                         pparams->buf_size,
3640                                         pparams->chain);
3641
3642                         /* enqueue burst */
3643                         burst_enqueued = rte_cryptodev_enqueue_burst(dev_id,
3644                                         queue_id, ops, burst_size);
3645
3646                         if (burst_enqueued < burst_size)
3647                                 retries++;
3648
3649                         ops_unused = burst_size - burst_enqueued;
3650                         total_enqueued += burst_enqueued;
3651                 }
3652
3653                 /* dequeue burst */
3654                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
3655                                 proc_ops, pparams->burst_size);
3656                 if (burst_dequeued == 0)
3657                         failed_polls++;
3658                 else {
3659                         processed += burst_dequeued;
3660
3661                         for (l = 0; l < burst_dequeued; l++)
3662                                 rte_crypto_op_free(proc_ops[l]);
3663                 }
3664                 j++;
3665         }
3666
3667         /* Dequeue any operations still in the crypto device */
3668         while (processed < pparams->total_operations) {
3669                 /* Sending 0 length burst to flush sw crypto device */
3670                 rte_cryptodev_enqueue_burst(dev_id, queue_id, NULL, 0);
3671
3672                 /* dequeue burst */
3673                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
3674                                 proc_ops, pparams->burst_size);
3675                 if (burst_dequeued == 0)
3676                         failed_polls++;
3677                 else {
3678                         processed += burst_dequeued;
3679
3680                         for (m = 0; m < burst_dequeued; m++)
3681                                 rte_crypto_op_free(proc_ops[m]);
3682                 }
3683         }
3684
3685         tsc_end = rte_rdtsc();
3686
3687         double ops_s = ((double)processed / (tsc_end - tsc_start))
3688                                         * rte_get_tsc_hz();
3689         double throughput = (ops_s * pparams->buf_size * NUM_MBUF_SETS)
3690                                         / 1000000000;
3691
3692         printf("\t%u\t%6.2f\t%10.2f\t%8"PRIu64"\t%8"PRIu64, pparams->buf_size,
3693                         ops_s / 1000000, throughput, retries, failed_polls);
3694
3695         for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++)
3696                 rte_pktmbuf_free(mbufs[i]);
3697
3698         printf("\n");
3699         return TEST_SUCCESS;
3700 }
3701
3702 /*
3703
3704     perf_test_aes_sha("avx2", HASH_CIPHER, 16, CBC, SHA1);
3705     perf_test_aes_sha("avx2", HASH_CIPHER, 16, CBC, SHA_256);
3706     perf_test_aes_sha("avx2", HASH_CIPHER, 16, CBC, SHA_512);
3707
3708     perf_test_aes_sha("avx2", CIPHER_HASH, 32, CBC, SHA1);
3709     perf_test_aes_sha("avx2", CIPHER_HASH, 32, CBC, SHA_256);
3710     perf_test_aes_sha("avx2", CIPHER_HASH, 32, CBC, SHA_512);
3711
3712     perf_test_aes_sha("avx2", HASH_CIPHER, 32, CBC, SHA1);
3713     perf_test_aes_sha("avx2", HASH_CIPHER, 32, CBC, SHA_256);
3714     perf_test_aes_sha("avx2", HASH_CIPHER, 32, CBC, SHA_512);
3715  */
3716 static int
3717 test_perf_aes_cbc_encrypt_digest_vary_pkt_size(void)
3718 {
3719         unsigned total_operations = 1000000;
3720         unsigned burst_size = 32;
3721         unsigned buf_lengths[] = { 64, 128, 256, 512, 768, 1024, 1280, 1536, 1792, 2048 };
3722         uint8_t i, j;
3723
3724         struct perf_test_params params_set[] = {
3725                 {
3726                         .chain = CIPHER_ONLY,
3727                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
3728                         .key_length = 16,
3729                         .auth_algo = RTE_CRYPTO_AUTH_NULL
3730                 },
3731                 {
3732                         .chain = CIPHER_HASH,
3733                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
3734                         .key_length = 16,
3735                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3736                 },
3737                 {
3738                         .chain = CIPHER_HASH,
3739
3740                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
3741                         .key_length = 16,
3742                         .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC
3743                 },
3744                 {
3745                         .chain = CIPHER_HASH,
3746
3747                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
3748                         .key_length = 16,
3749                         .auth_algo = RTE_CRYPTO_AUTH_SHA512_HMAC
3750                 },
3751                 {
3752                         .chain = CIPHER_HASH,
3753
3754                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
3755                         .key_length = 32,
3756                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3757                 },
3758                 {
3759                         .chain = CIPHER_HASH,
3760
3761                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
3762                         .key_length = 32,
3763                         .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC
3764                 },
3765                 {
3766                         .chain = CIPHER_HASH,
3767
3768                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
3769                         .key_length = 32,
3770                         .auth_algo = RTE_CRYPTO_AUTH_SHA512_HMAC
3771                 },
3772         };
3773
3774         for (i = 0; i < RTE_DIM(params_set); i++) {
3775
3776                 params_set[i].total_operations = total_operations;
3777                 params_set[i].burst_size = burst_size;
3778                 printf("\n%s. cipher algo: %s auth algo: %s cipher key size=%u."
3779                         " burst_size: %d ops\n",
3780                         chain_mode_name(params_set[i].chain),
3781                         rte_crypto_cipher_algorithm_strings[params_set[i].cipher_algo],
3782                         rte_crypto_auth_algorithm_strings[params_set[i].auth_algo],
3783                         params_set[i].key_length,
3784                         burst_size);
3785                 printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\t"
3786                         "Retries\tEmptyPolls\n");
3787                 for (j = 0; j < RTE_DIM(buf_lengths); j++) {
3788                         params_set[i].buf_size = buf_lengths[j];
3789                         test_perf_aes_sha(testsuite_params.dev_id, 0,
3790                                         &params_set[i]);
3791                 }
3792         }
3793         return 0;
3794 }
3795
3796 static int
3797 test_perf_snow3G_vary_pkt_size(void)
3798 {
3799         unsigned total_operations = 1000000;
3800         uint8_t i, j;
3801         unsigned k;
3802         uint16_t burst_sizes[] = { 64 };
3803         uint16_t buf_lengths[] = { 40, 64, 80, 120, 240, 256, 400, 512, 600, 1024, 2048 };
3804
3805         struct perf_test_params params_set[] = {
3806                 {
3807                         .chain = CIPHER_ONLY,
3808                         .cipher_algo  = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3809                         .key_length = 16,
3810                         .auth_algo  = RTE_CRYPTO_AUTH_NULL,
3811                 },
3812                 {
3813                         .chain = HASH_ONLY,
3814                         .cipher_algo = RTE_CRYPTO_CIPHER_NULL,
3815                         .auth_algo  = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3816                         .key_length = 16
3817                 },
3818         };
3819
3820         printf("\n\nStart %s.", __func__);
3821         printf("\nTest to measure max throughput at various pkt sizes.");
3822         printf("\nOn HW devices t'put maximised when high Retries and EmptyPolls"
3823                         " so cycle cost not relevant (n/a displayed).");
3824
3825         for (i = 0; i < RTE_DIM(params_set); i++) {
3826                 printf("\n\n");
3827                 params_set[i].total_operations = total_operations;
3828                 for (k = 0; k < RTE_DIM(burst_sizes); k++) {
3829                         enum rte_crypto_cipher_algorithm cipher_algo =
3830                                 params_set[i].cipher_algo;
3831                         enum rte_crypto_auth_algorithm auth_algo =
3832                                 params_set[i].auth_algo;
3833                         printf("\nOn %s dev%u qp%u, %s, "
3834                                 "cipher algo:%s, auth algo:%s, burst_size: %d ops",
3835                                 pmd_name(gbl_driver_id),
3836                                 testsuite_params.dev_id, 0,
3837                                 chain_mode_name(params_set[i].chain),
3838                                 rte_crypto_cipher_algorithm_strings[cipher_algo],
3839                                 rte_crypto_auth_algorithm_strings[auth_algo],
3840                                 burst_sizes[k]);
3841
3842                         params_set[i].burst_size = burst_sizes[k];
3843                         printf("\nPktSzB\tOp/s(M)\tThruput(Mbps)\tCycles/Burst\t"
3844                                 "Cycles/buf\tCycles/B\tRetries\t\tEmptyPolls\n");
3845                         for (j = 0; j < RTE_DIM(buf_lengths); j++) {
3846
3847                                 params_set[i].buf_size = buf_lengths[j];
3848
3849                                 test_perf_snow3g(testsuite_params.dev_id, 0, &params_set[i]);
3850                         }
3851                 }
3852         }
3853
3854         return 0;
3855 }
3856
3857 static int
3858 test_perf_openssl_vary_pkt_size(void)
3859 {
3860         unsigned int total_operations = 10000;
3861         unsigned int burst_size = { 64 };
3862         unsigned int buf_lengths[] = { 64, 128, 256, 512, 768, 1024, 1280, 1536,
3863                         1792, 2048 };
3864         uint8_t i, j;
3865
3866         struct perf_test_params params_set[] = {
3867                 {
3868                         .chain = CIPHER_HASH,
3869
3870                         .cipher_algo  = RTE_CRYPTO_CIPHER_3DES_CBC,
3871                         .key_length = 16,
3872                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3873                 },
3874                 {
3875                         .chain = CIPHER_HASH,
3876
3877                         .cipher_algo  = RTE_CRYPTO_CIPHER_3DES_CBC,
3878                         .key_length = 24,
3879                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3880                 },
3881                 {
3882                         .chain = CIPHER_HASH,
3883
3884                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CTR,
3885                         .key_length = 16,
3886                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3887                 },
3888                 {
3889                         .chain = CIPHER_HASH,
3890
3891                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CTR,
3892                         .key_length = 32,
3893                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3894                 },
3895                 {
3896                         .chain = CIPHER_HASH,
3897
3898                         .cipher_algo  = RTE_CRYPTO_CIPHER_3DES_CTR,
3899                         .key_length = 16,
3900                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3901                 },
3902                 {
3903                         .chain = CIPHER_HASH,
3904
3905                         .cipher_algo  = RTE_CRYPTO_CIPHER_3DES_CTR,
3906                         .key_length = 24,
3907                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3908                 },
3909                 {
3910                         .chain = AEAD,
3911
3912                         .aead_algo  = RTE_CRYPTO_AEAD_AES_GCM,
3913                         .key_length = 16,
3914                 },
3915         };
3916
3917         for (i = 0; i < RTE_DIM(params_set); i++) {
3918                 params_set[i].total_operations = total_operations;
3919                 params_set[i].burst_size = burst_size;
3920                 if (params_set[i].chain == AEAD) {
3921                         enum rte_crypto_aead_algorithm aead_algo =
3922                                 params_set[i].aead_algo;
3923                         printf("\n%s. aead algo: %s  key size=%u."
3924                                 " burst_size: %d ops\n",
3925                                 chain_mode_name(params_set[i].chain),
3926                                 rte_crypto_aead_algorithm_strings[aead_algo],
3927                                 params_set[i].key_length,
3928                                 burst_size);
3929                 } else {
3930                         enum rte_crypto_cipher_algorithm cipher_algo =
3931                                 params_set[i].cipher_algo;
3932                         enum rte_crypto_auth_algorithm auth_algo =
3933                                 params_set[i].auth_algo;
3934                         printf("\n%s. cipher algo: %s auth algo: %s key size=%u."
3935                                 " burst_size: %d ops\n",
3936                                 chain_mode_name(params_set[i].chain),
3937                                 rte_crypto_cipher_algorithm_strings[cipher_algo],
3938                                 rte_crypto_auth_algorithm_strings[auth_algo],
3939                                 params_set[i].key_length,
3940                                 burst_size);
3941                 }
3942                 printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\tRetries\t"
3943                                 "EmptyPolls\n");
3944                 for (j = 0; j < RTE_DIM(buf_lengths); j++) {
3945                         params_set[i].buf_size = buf_lengths[j];
3946                         test_perf_openssl(testsuite_params.dev_id, 0,
3947                                         &params_set[i]);
3948                 }
3949         }
3950
3951         return 0;
3952 }
3953
3954 static int
3955 test_perf_openssl_vary_burst_size(void)
3956 {
3957         unsigned int total_operations = 4096;
3958         uint16_t buf_lengths[] = { 40 };
3959         uint8_t i, j;
3960
3961         struct perf_test_params params_set[] = {
3962                 {
3963                         .chain = CIPHER_HASH,
3964
3965                         .cipher_algo  = RTE_CRYPTO_CIPHER_3DES_CBC,
3966                         .key_length = 16,
3967                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3968                 },
3969                 {
3970                         .chain = CIPHER_HASH,
3971
3972                         .cipher_algo  = RTE_CRYPTO_CIPHER_3DES_CBC,
3973                         .key_length = 24,
3974                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3975                 },
3976                 {
3977                         .chain = CIPHER_HASH,
3978
3979                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CTR,
3980                         .key_length = 16,
3981                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3982                 },
3983                 {
3984                         .chain = CIPHER_HASH,
3985
3986                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CTR,
3987                         .key_length = 32,
3988                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3989                 },
3990                 {
3991                         .chain = CIPHER_HASH,
3992
3993                         .cipher_algo  = RTE_CRYPTO_CIPHER_3DES_CTR,
3994                         .key_length = 16,
3995                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
3996                 },
3997                 {
3998                         .chain = CIPHER_HASH,
3999
4000                         .cipher_algo  = RTE_CRYPTO_CIPHER_3DES_CTR,
4001                         .key_length = 24,
4002                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
4003                 },
4004                 {
4005                         .chain = AEAD,
4006
4007                         .aead_algo  = RTE_CRYPTO_AEAD_AES_GCM,
4008                         .key_length = 16,
4009                 },
4010         };
4011
4012         printf("\n\nStart %s.", __func__);
4013         printf("\nThis Test measures the average IA cycle cost using a "
4014                         "constant request(packet) size. ");
4015         printf("Cycle cost is only valid when indicators show device is not"
4016                         " busy, i.e. Retries and EmptyPolls = 0");
4017
4018         for (i = 0; i < RTE_DIM(params_set); i++) {
4019                 printf("\n");
4020                 params_set[i].total_operations = total_operations;
4021
4022         for (j = 0; j < RTE_DIM(buf_lengths); j++) {
4023                 params_set[i].buf_size = buf_lengths[j];
4024                 test_perf_openssl_optimise_cyclecount(&params_set[i]);
4025                 }
4026         }
4027
4028         return 0;
4029 }
4030
4031 static int
4032 test_perf_armv8_vary_pkt_size(void)
4033 {
4034         unsigned int total_operations = 100000;
4035         unsigned int burst_size = { 64 };
4036         unsigned int buf_lengths[] = { 64, 128, 256, 512, 768, 1024, 1280, 1536,
4037                         1792, 2048 };
4038         uint8_t i, j;
4039
4040         struct perf_test_params params_set[] = {
4041                 {
4042                         .chain = CIPHER_HASH,
4043
4044                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
4045                         .key_length = 16,
4046                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
4047                 },
4048                 {
4049                         .chain = HASH_CIPHER,
4050
4051                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
4052                         .key_length = 16,
4053                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
4054                 },
4055                 {
4056                         .chain = CIPHER_HASH,
4057
4058                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
4059                         .key_length = 16,
4060                         .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC
4061                 },
4062                 {
4063                         .chain = HASH_CIPHER,
4064
4065                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
4066                         .key_length = 16,
4067                         .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC
4068                 },
4069         };
4070
4071         for (i = 0; i < RTE_DIM(params_set); i++) {
4072                 params_set[i].total_operations = total_operations;
4073                 params_set[i].burst_size = burst_size;
4074                 printf("\n%s. cipher algo: %s auth algo: %s cipher key size=%u."
4075                         " burst_size: %d ops\n",
4076                         chain_mode_name(params_set[i].chain),
4077                         rte_crypto_cipher_algorithm_strings[params_set[i].cipher_algo],
4078                         rte_crypto_auth_algorithm_strings[params_set[i].auth_algo],
4079                         params_set[i].key_length,
4080                         burst_size);
4081                 printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\tRetries\t"
4082                                 "EmptyPolls\n");
4083                 for (j = 0; j < RTE_DIM(buf_lengths); j++) {
4084                         params_set[i].buf_size = buf_lengths[j];
4085                         test_perf_armv8(testsuite_params.dev_id, 0,
4086                                                         &params_set[i]);
4087                 }
4088         }
4089
4090         return 0;
4091 }
4092
4093 static int
4094 test_perf_armv8_vary_burst_size(void)
4095 {
4096         unsigned int total_operations = 4096;
4097         uint16_t buf_lengths[] = { 64 };
4098         uint8_t i, j;
4099
4100         struct perf_test_params params_set[] = {
4101                 {
4102                         .chain = CIPHER_HASH,
4103
4104                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
4105                         .key_length = 16,
4106                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
4107                 },
4108                 {
4109                         .chain = HASH_CIPHER,
4110
4111                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
4112                         .key_length = 16,
4113                         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
4114                 },
4115                 {
4116                         .chain = CIPHER_HASH,
4117
4118                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
4119                         .key_length = 16,
4120                         .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC
4121                 },
4122                 {
4123                         .chain = HASH_CIPHER,
4124
4125                         .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
4126                         .key_length = 16,
4127                         .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC
4128                 },
4129         };
4130
4131         printf("\n\nStart %s.", __func__);
4132         printf("\nThis Test measures the average IA cycle cost using a "
4133                         "constant request(packet) size. ");
4134         printf("Cycle cost is only valid when indicators show device is "
4135                         "not busy, i.e. Retries and EmptyPolls = 0");
4136
4137         for (i = 0; i < RTE_DIM(params_set); i++) {
4138                 printf("\n");
4139                 params_set[i].total_operations = total_operations;
4140
4141                 for (j = 0; j < RTE_DIM(buf_lengths); j++) {
4142                         params_set[i].buf_size = buf_lengths[j];
4143                         test_perf_armv8_optimise_cyclecount(&params_set[i]);
4144                 }
4145         }
4146
4147         return 0;
4148 }
4149
4150 static int
4151 test_perf_aes_cbc_vary_burst_size(void)
4152 {
4153         return test_perf_crypto_qp_vary_burst_size(testsuite_params.dev_id);
4154 }
4155
4156
4157 static struct rte_cryptodev_sym_session *
4158 test_perf_create_session(uint8_t dev_id, struct perf_test_params *pparams)
4159 {
4160         static struct rte_cryptodev_sym_session *sess;
4161         struct rte_crypto_sym_xform aead_xform = { 0 };
4162
4163         uint8_t aead_key[pparams->session_attrs->key_aead_len];
4164
4165         memcpy(aead_key, pparams->session_attrs->key_aead_data,
4166                  pparams->session_attrs->key_aead_len);
4167
4168         aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
4169         aead_xform.next = NULL;
4170
4171         aead_xform.aead.algo = pparams->session_attrs->aead_algorithm;
4172         aead_xform.aead.op = pparams->session_attrs->aead;
4173         aead_xform.aead.key.data = aead_key;
4174         aead_xform.aead.key.length = pparams->session_attrs->key_aead_len;
4175         aead_xform.aead.iv.length = pparams->session_attrs->iv_len;
4176         aead_xform.aead.iv.offset = IV_OFFSET;
4177         aead_xform.aead.add_auth_data_length = pparams->session_attrs->aad_len;
4178         aead_xform.aead.digest_length = pparams->session_attrs->digest_len;
4179
4180         sess = rte_cryptodev_sym_session_create(dev_id, &aead_xform);
4181
4182         return sess;
4183 }
4184
4185 static inline struct rte_crypto_op *
4186 perf_gcm_set_crypto_op(struct rte_crypto_op *op, struct rte_mbuf *m,
4187                 struct rte_cryptodev_sym_session *sess,
4188                 struct crypto_params *m_hlp,
4189                 struct perf_test_params *params)
4190 {
4191         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op,
4192                         uint8_t *, IV_OFFSET);
4193
4194         if (rte_crypto_op_attach_sym_session(op, sess) != 0) {
4195                 rte_crypto_op_free(op);
4196                 return NULL;
4197         }
4198
4199         op->sym->aead.digest.data = m_hlp->digest;
4200         op->sym->aead.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4201                                           m,
4202                                           params->session_attrs->aad_len +
4203                                           params->symmetric_op->p_len);
4204
4205
4206         op->sym->aead.aad.data = m_hlp->aad;
4207         op->sym->aead.aad.phys_addr = rte_pktmbuf_mtophys(m);
4208
4209         rte_memcpy(op->sym->aead.aad.data, params->symmetric_op->aad_data,
4210                        params->session_attrs->aad_len);
4211
4212         rte_memcpy(iv_ptr, params->session_attrs->iv_data,
4213                        params->session_attrs->iv_len);
4214         if (params->session_attrs->iv_len == 12)
4215                 iv_ptr[15] = 1;
4216
4217         op->sym->aead.data.offset =
4218                         params->session_attrs->aad_len;
4219         op->sym->aead.data.length = params->symmetric_op->p_len;
4220
4221         op->sym->m_src = m;
4222
4223         return op;
4224 }
4225
4226 static struct rte_mbuf *
4227 test_perf_create_pktmbuf_fill(struct rte_mempool *mpool,
4228                 struct perf_test_params *params,
4229                 unsigned buf_sz, struct crypto_params *m_hlp)
4230 {
4231         struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
4232         uint16_t aad_len = params->session_attrs->aad_len;
4233         uint16_t digest_size = params->symmetric_op->t_len;
4234         char *p;
4235
4236         p = rte_pktmbuf_append(m, aad_len);
4237         if (p == NULL) {
4238                 rte_pktmbuf_free(m);
4239                 return NULL;
4240         }
4241         m_hlp->aad = (uint8_t *)p;
4242
4243         p = rte_pktmbuf_append(m, buf_sz);
4244         if (p == NULL) {
4245                 rte_pktmbuf_free(m);
4246                 return NULL;
4247         }
4248         rte_memcpy(p, params->symmetric_op->p_data, buf_sz);
4249
4250         p = rte_pktmbuf_append(m, digest_size);
4251         if (p == NULL) {
4252                 rte_pktmbuf_free(m);
4253                 return NULL;
4254         }
4255         m_hlp->digest = (uint8_t *)p;
4256
4257         return m;
4258 }
4259
4260 static int
4261 perf_AES_GCM(uint8_t dev_id, uint16_t queue_id,
4262              struct perf_test_params *pparams, uint32_t test_ops)
4263 {
4264         int j = 0;
4265         struct crypto_testsuite_params *ts_params = &testsuite_params;
4266         struct rte_cryptodev_sym_session *sess;
4267         struct rte_crypto_op *ops[pparams->burst_size];
4268         struct rte_crypto_op *proc_ops[pparams->burst_size];
4269         uint32_t total_operations = pparams->total_operations;
4270
4271         uint64_t burst_enqueued = 0, total_enqueued = 0, burst_dequeued = 0;
4272         uint64_t processed = 0, failed_polls = 0, retries = 0;
4273         uint64_t tsc_start = 0, tsc_end = 0;
4274
4275         uint16_t i = 0, l = 0, m = 0;
4276         uint16_t burst = pparams->burst_size * NUM_MBUF_SETS;
4277         uint16_t ops_unused = 0;
4278
4279         struct rte_mbuf *mbufs[burst];
4280         struct crypto_params m_hlp[burst];
4281
4282         if (rte_cryptodev_count() == 0) {
4283                 printf("\nNo crypto devices available. "
4284                                 "Is kernel driver loaded?\n");
4285                 return TEST_FAILED;
4286         }
4287
4288         sess = test_perf_create_session(dev_id, pparams);
4289         TEST_ASSERT_NOT_NULL(sess, "Session creation failed");
4290
4291         for (i = 0; i < burst; i++) {
4292                 mbufs[i] = test_perf_create_pktmbuf_fill(
4293                                 ts_params->mbuf_mp,
4294                                 pparams, pparams->symmetric_op->p_len,
4295                                 &m_hlp[i]);
4296         }
4297
4298         if (test_ops)
4299                 total_operations = test_ops;
4300
4301         tsc_start = rte_rdtsc_precise();
4302         while (total_enqueued < total_operations) {
4303                 uint16_t burst_size =
4304                 total_enqueued+pparams->burst_size <= total_operations ?
4305                 pparams->burst_size : total_operations-total_enqueued;
4306                 uint16_t ops_needed = burst_size-ops_unused;
4307
4308                 if (ops_needed != rte_crypto_op_bulk_alloc(ts_params->op_mpool,
4309                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, ops_needed)){
4310                         printf("\nFailed to alloc enough ops, "
4311                                         "finish dequeuing");
4312                 } else {
4313                         for (i = 0; i < ops_needed; i++)
4314                                 ops[i] = perf_gcm_set_crypto_op(ops[i],
4315                                         mbufs[i + (pparams->burst_size *
4316                                                 (j % NUM_MBUF_SETS))],
4317                                         sess, &m_hlp[i + (pparams->burst_size *
4318                                                 (j % NUM_MBUF_SETS))], pparams);
4319
4320                         /* enqueue burst */
4321                         burst_enqueued = rte_cryptodev_enqueue_burst(dev_id,
4322                                         queue_id, ops, burst_size);
4323
4324                         if (burst_enqueued < burst_size)
4325                                 retries++;
4326
4327                         ops_unused = burst_size-burst_enqueued;
4328                         total_enqueued += burst_enqueued;
4329                 }
4330
4331                 /* dequeue burst */
4332                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
4333                                 proc_ops, pparams->burst_size);
4334                 if (burst_dequeued == 0)
4335                         failed_polls++;
4336                 else {
4337                         processed += burst_dequeued;
4338
4339                         for (l = 0; l < burst_dequeued; l++)
4340                                 rte_crypto_op_free(proc_ops[l]);
4341                 }
4342
4343                 j++;
4344         }
4345
4346         /* Dequeue any operations still in the crypto device */
4347         while (processed < total_operations) {
4348                 /* Sending 0 length burst to flush sw crypto device */
4349                 rte_cryptodev_enqueue_burst(dev_id, queue_id, NULL, 0);
4350
4351                 /* dequeue burst */
4352                 burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id,
4353                                 proc_ops, pparams->burst_size);
4354                 if (burst_dequeued == 0)
4355                         failed_polls++;
4356                 else {
4357                         processed += burst_dequeued;
4358
4359                 for (m = 0; m < burst_dequeued; m++) {
4360                         if (test_ops) {
4361                                 uint8_t *pkt = rte_pktmbuf_mtod(
4362                                         proc_ops[m]->sym->m_src,
4363                                         uint8_t *);
4364
4365                                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4366                                         pparams->symmetric_op->c_data,
4367                                         pkt +
4368                                         pparams->session_attrs->aad_len,
4369                                         pparams->symmetric_op->c_len,
4370                                         "GCM Ciphertext data not as expected");
4371
4372                                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4373                                         pparams->symmetric_op->t_data,
4374                                         pkt +
4375                                         pparams->session_attrs->aad_len +
4376                                         pparams->symmetric_op->c_len,
4377                                         pparams->symmetric_op->t_len,
4378                                         "GCM MAC data not as expected");
4379
4380                                 }
4381                                 rte_crypto_op_free(proc_ops[m]);
4382                         }
4383                 }
4384         }
4385
4386         tsc_end = rte_rdtsc_precise();
4387
4388         double ops_s = ((double)processed / (tsc_end - tsc_start))
4389                         * rte_get_tsc_hz();
4390         double throughput = (ops_s * pparams->symmetric_op->p_len * 8)
4391                         / 1000000000;
4392
4393         if (!test_ops) {
4394                 printf("\n%u\t\t%6.2f\t%16.2f\t%8"PRIu64"\t%10"PRIu64,
4395                 pparams->symmetric_op->p_len,
4396                 ops_s/1000000, throughput, retries, failed_polls);
4397         }
4398
4399         for (i = 0; i < burst; i++)
4400                 rte_pktmbuf_free(mbufs[i]);
4401         rte_cryptodev_sym_session_free(dev_id, sess);
4402
4403         return 0;
4404 }
4405
4406 static int
4407 test_perf_AES_GCM(int continual_buf_len, int continual_size)
4408 {
4409         uint16_t i, j, k, loops = 1;
4410
4411         uint16_t buf_lengths[] = { 64, 128, 256, 512, 1024, 1536, 2048 };
4412
4413         static const struct cryptodev_perf_test_data *gcm_tests[] = {
4414                         &AES_GCM_128_12IV_0AAD
4415         };
4416
4417         if (continual_buf_len)
4418                 loops = continual_size;
4419
4420         int TEST_CASES_GCM = RTE_DIM(gcm_tests);
4421
4422         const unsigned burst_size = 32;
4423
4424         struct symmetric_op ops_set[TEST_CASES_GCM];
4425         struct perf_test_params params_set[TEST_CASES_GCM];
4426         struct symmetric_session_attrs session_attrs[TEST_CASES_GCM];
4427         static const struct cryptodev_perf_test_data *gcm_test;
4428
4429         for (i = 0; i < TEST_CASES_GCM; ++i) {
4430
4431                 gcm_test = gcm_tests[i];
4432
4433                 session_attrs[i].aead =
4434                                 RTE_CRYPTO_AEAD_OP_ENCRYPT;
4435                 session_attrs[i].aead_algorithm =
4436                                 RTE_CRYPTO_AEAD_AES_GCM;
4437                 session_attrs[i].key_aead_data =
4438                                 gcm_test->key.data;
4439                 session_attrs[i].key_aead_len =
4440                                 gcm_test->key.len;
4441                 session_attrs[i].aad_len = gcm_test->aad.len;
4442                 session_attrs[i].digest_len =
4443                                 gcm_test->auth_tag.len;
4444                 session_attrs[i].iv_len = gcm_test->iv.len;
4445                 session_attrs[i].iv_data = gcm_test->iv.data;
4446
4447                 ops_set[i].aad_data = gcm_test->aad.data;
4448                 ops_set[i].p_data = gcm_test->plaintext.data;
4449                 ops_set[i].p_len = buf_lengths[i];
4450                 ops_set[i].c_data = gcm_test->ciphertext.data;
4451                 ops_set[i].c_len = buf_lengths[i];
4452                 ops_set[i].t_data = gcm_test->auth_tags[i].data;
4453                 ops_set[i].t_len = gcm_test->auth_tags[i].len;
4454
4455                 params_set[i].chain = AEAD;
4456                 params_set[i].session_attrs = &session_attrs[i];
4457                 params_set[i].symmetric_op = &ops_set[i];
4458                 if (continual_buf_len)
4459                         params_set[i].total_operations = 0xFFFFFF;
4460                 else
4461                         params_set[i].total_operations = 1000000;
4462
4463                 params_set[i].burst_size = burst_size;
4464
4465         }
4466
4467         if (continual_buf_len)
4468                 printf("\nCipher algo: %s Cipher hash: %s cipher key size: %ub"
4469                         " burst size: %u", "AES_GCM", "AES_GCM",
4470                         gcm_test->key.len << 3, burst_size);
4471
4472         for (i = 0; i < RTE_DIM(gcm_tests); i++) {
4473
4474                 if (!continual_buf_len) {
4475                         printf("\nCipher algo: %s Cipher hash: %s cipher key size: %ub"
4476                                 " burst size: %u", "AES_GCM", "AES_GCM",
4477                                 gcm_test->key.len << 3, burst_size);
4478                         printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\t"
4479                                 " Retries\tEmptyPolls");
4480                 }
4481
4482                 uint16_t len = RTE_DIM(buf_lengths);
4483                 uint16_t p = 0;
4484
4485                 if (continual_buf_len) {
4486                         for (k = 0; k < RTE_DIM(buf_lengths); k++)
4487                                 if (buf_lengths[k] == continual_buf_len) {
4488                                         len = k + 1;
4489                                         p = k;
4490                                         break;
4491                                 }
4492                 }
4493                 for (j = p; j < len; ++j) {
4494
4495                         params_set[i].symmetric_op->c_len = buf_lengths[j];
4496                         params_set[i].symmetric_op->p_len = buf_lengths[j];
4497
4498                         ops_set[i].t_data = gcm_tests[i]->auth_tags[j].data;
4499                         ops_set[i].t_len = gcm_tests[i]->auth_tags[j].len;
4500
4501                         /* Run is twice, one for encryption/hash checks,
4502                          * one for perf
4503                          */
4504                         if (perf_AES_GCM(testsuite_params.dev_id, 0,
4505                                         &params_set[i], 1))
4506                                 return TEST_FAILED;
4507
4508                         for (k = 0; k < loops; k++) {
4509                                 if (continual_buf_len)
4510                                         printf("\n\nBuffer Size(B)\tOPS(M)\t"
4511                                                 "Throughput(Gbps)\t"
4512                                                 "Retries\tEmptyPolls");
4513                                 if (perf_AES_GCM(testsuite_params.dev_id, 0,
4514                                                 &params_set[i], 0))
4515                                         return TEST_FAILED;
4516                                 if (continual_buf_len)
4517                                         printf("\n\nCompleted loop %i of %i ...",
4518                                                 k+1, loops);
4519                         }
4520                 }
4521
4522         }
4523         printf("\n");
4524         return 0;
4525 }
4526
4527 static int test_cryptodev_perf_AES_GCM(void)
4528 {
4529         return test_perf_AES_GCM(0, 0);
4530 }
4531 /*
4532  * This function calls AES GCM performance tests providing
4533  * size of packet as an argument. If size of packet is not
4534  * in the buf_lengths array, all sizes will be used
4535  */
4536 static int test_continual_perf_AES_GCM(void)
4537 {
4538         return test_perf_AES_GCM(1024, 10);
4539 }
4540
4541 static int
4542 test_perf_continual_performance_test(void)
4543 {
4544         unsigned int total_operations = 0xFFFFFF;
4545         unsigned int total_loops = 10;
4546         unsigned int burst_size = 32;
4547         uint8_t i;
4548
4549         struct perf_test_params params_set = {
4550                 .total_operations = total_operations,
4551                 .burst_size = burst_size,
4552                 .buf_size = 1024,
4553
4554                 .chain = CIPHER_HASH,
4555
4556                 .cipher_algo  = RTE_CRYPTO_CIPHER_AES_CBC,
4557                 .key_length = 16,
4558                 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC
4559         };
4560
4561         for (i = 1; i <= total_loops; ++i) {
4562                 printf("\n%s. cipher algo: %s auth algo: %s cipher key size=%u."
4563                         " burst_size: %d ops\n",
4564                         chain_mode_name(params_set.chain),
4565                         rte_crypto_cipher_algorithm_strings[params_set.cipher_algo],
4566                         rte_crypto_auth_algorithm_strings[params_set.auth_algo],
4567                         params_set.key_length,
4568                         burst_size);
4569                 printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\t"
4570                                 "Retries\tEmptyPolls\n");
4571                                 test_perf_aes_sha(testsuite_params.dev_id, 0,
4572                                         &params_set);
4573                 printf("\nCompleted loop %i of %i ...", i, total_loops);
4574         }
4575         return 0;
4576 }
4577
4578 static struct unit_test_suite cryptodev_qat_continual_testsuite  = {
4579         .suite_name = "Crypto Device Continual Performance Test",
4580         .setup = testsuite_setup,
4581         .teardown = testsuite_teardown,
4582         .unit_test_cases = {
4583                 TEST_CASE_ST(ut_setup, ut_teardown,
4584                                 test_perf_continual_performance_test),
4585                 TEST_CASE_ST(ut_setup, ut_teardown,
4586                                 test_continual_perf_AES_GCM),
4587                 TEST_CASES_END() /**< NULL terminate unit test array */
4588         }
4589 };
4590
4591 static struct unit_test_suite cryptodev_testsuite  = {
4592         .suite_name = "Crypto Device Unit Test Suite",
4593         .setup = testsuite_setup,
4594         .teardown = testsuite_teardown,
4595         .unit_test_cases = {
4596                 TEST_CASE_ST(ut_setup, ut_teardown,
4597                                 test_perf_aes_cbc_encrypt_digest_vary_pkt_size),
4598                 TEST_CASE_ST(ut_setup, ut_teardown,
4599                                 test_cryptodev_perf_AES_GCM),
4600                 TEST_CASE_ST(ut_setup, ut_teardown,
4601                                 test_perf_aes_cbc_vary_burst_size),
4602                 TEST_CASES_END() /**< NULL terminate unit test array */
4603         }
4604 };
4605
4606 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
4607         .suite_name = "Crypto Device DPAA2_SEC Unit Test Suite",
4608         .setup = testsuite_setup,
4609         .teardown = testsuite_teardown,
4610         .unit_test_cases = {
4611                 TEST_CASE_ST(ut_setup, ut_teardown,
4612                              test_perf_aes_cbc_encrypt_digest_vary_pkt_size),
4613                 TEST_CASES_END() /**< NULL terminate unit test array */
4614         }
4615 };
4616
4617 static struct unit_test_suite cryptodev_gcm_testsuite  = {
4618         .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
4619         .setup = testsuite_setup,
4620         .teardown = testsuite_teardown,
4621         .unit_test_cases = {
4622                 TEST_CASE_ST(ut_setup, ut_teardown,
4623                                 test_cryptodev_perf_AES_GCM),
4624                 TEST_CASES_END() /**< NULL terminate unit test array */
4625         }
4626 };
4627
4628 static struct unit_test_suite cryptodev_aes_testsuite  = {
4629         .suite_name = "Crypto Device AESNI MB Unit Test Suite",
4630         .setup = testsuite_setup,
4631         .teardown = testsuite_teardown,
4632         .unit_test_cases = {
4633                 TEST_CASE_ST(ut_setup, ut_teardown,
4634                                 test_perf_aes_cbc_encrypt_digest_vary_pkt_size),
4635                 TEST_CASES_END() /**< NULL terminate unit test array */
4636         }
4637 };
4638
4639 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
4640         .suite_name = "Crypto Device SNOW3G Unit Test Suite",
4641         .setup = testsuite_setup,
4642         .teardown = testsuite_teardown,
4643         .unit_test_cases = {
4644                 TEST_CASE_ST(ut_setup, ut_teardown,
4645                                 test_perf_snow3G_vary_pkt_size),
4646                 TEST_CASE_ST(ut_setup, ut_teardown,
4647                                 test_perf_snow3G_vary_burst_size),
4648                 TEST_CASES_END() /**< NULL terminate unit test array */
4649         }
4650 };
4651
4652 static struct unit_test_suite cryptodev_openssl_testsuite  = {
4653         .suite_name = "Crypto Device OPENSSL Unit Test Suite",
4654         .setup = testsuite_setup,
4655         .teardown = testsuite_teardown,
4656         .unit_test_cases = {
4657                 TEST_CASE_ST(ut_setup, ut_teardown,
4658                                 test_perf_openssl_vary_pkt_size),
4659                 TEST_CASE_ST(ut_setup, ut_teardown,
4660                                 test_perf_openssl_vary_burst_size),
4661                 TEST_CASES_END() /**< NULL terminate unit test array */
4662         }
4663 };
4664
4665 static struct unit_test_suite cryptodev_armv8_testsuite  = {
4666         .suite_name = "Crypto Device ARMv8 Unit Test Suite",
4667         .setup = testsuite_setup,
4668         .teardown = testsuite_teardown,
4669         .unit_test_cases = {
4670                 TEST_CASE_ST(ut_setup, ut_teardown,
4671                                 test_perf_armv8_vary_pkt_size),
4672                 TEST_CASE_ST(ut_setup, ut_teardown,
4673                                 test_perf_armv8_vary_burst_size),
4674                 TEST_CASES_END() /**< NULL terminate unit test array */
4675         }
4676 };
4677
4678 static int
4679 perftest_aesni_gcm_cryptodev(void)
4680 {
4681         gbl_driver_id = rte_cryptodev_driver_id_get(
4682                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
4683
4684         if (gbl_driver_id == -1) {
4685                 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
4686                                 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
4687                                 "in config file to run this testsuite.\n");
4688                 return TEST_FAILED;
4689         }
4690
4691         return unit_test_suite_runner(&cryptodev_gcm_testsuite);
4692 }
4693
4694 static int
4695 perftest_aesni_mb_cryptodev(void /*argv __rte_unused, int argc __rte_unused*/)
4696 {
4697         gbl_driver_id = rte_cryptodev_driver_id_get(
4698                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
4699
4700         if (gbl_driver_id == -1) {
4701                 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
4702                                 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
4703                                 "in config file to run this testsuite.\n");
4704                 return TEST_FAILED;
4705         }
4706
4707         return unit_test_suite_runner(&cryptodev_aes_testsuite);
4708 }
4709
4710 static int
4711 perftest_qat_cryptodev(void /*argv __rte_unused, int argc __rte_unused*/)
4712 {
4713         gbl_driver_id = rte_cryptodev_driver_id_get(
4714                         RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
4715
4716         if (gbl_driver_id == -1) {
4717                 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
4718                                 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
4719                                 "in config file to run this testsuite.\n");
4720                 return TEST_FAILED;
4721         }
4722
4723         return unit_test_suite_runner(&cryptodev_testsuite);
4724 }
4725
4726 static int
4727 perftest_sw_snow3g_cryptodev(void /*argv __rte_unused, int argc __rte_unused*/)
4728 {
4729         gbl_driver_id = rte_cryptodev_driver_id_get(
4730                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
4731
4732         if (gbl_driver_id == -1) {
4733                 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
4734                                 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
4735                                 "in config file to run this testsuite.\n");
4736                 return TEST_FAILED;
4737         }
4738
4739         return unit_test_suite_runner(&cryptodev_snow3g_testsuite);
4740 }
4741
4742 static int
4743 perftest_qat_snow3g_cryptodev(void /*argv __rte_unused, int argc __rte_unused*/)
4744 {
4745         gbl_driver_id = rte_cryptodev_driver_id_get(
4746                         RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
4747
4748         if (gbl_driver_id == -1) {
4749                 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
4750                                 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
4751                                 "in config file to run this testsuite.\n");
4752                 return TEST_FAILED;
4753         }
4754
4755         return unit_test_suite_runner(&cryptodev_snow3g_testsuite);
4756 }
4757
4758 static int
4759 perftest_openssl_cryptodev(void /*argv __rte_unused, int argc __rte_unused*/)
4760 {
4761         gbl_driver_id = rte_cryptodev_driver_id_get(
4762                         RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
4763
4764         if (gbl_driver_id == -1) {
4765                 RTE_LOG(ERR, USER1, "OpenSSL PMD must be loaded. Check if "
4766                                 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
4767                                 "in config file to run this testsuite.\n");
4768                 return TEST_FAILED;
4769         }
4770
4771         return unit_test_suite_runner(&cryptodev_openssl_testsuite);
4772 }
4773
4774 static int
4775 perftest_qat_continual_cryptodev(void)
4776 {
4777         gbl_driver_id = rte_cryptodev_driver_id_get(
4778                         RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
4779
4780         if (gbl_driver_id == -1) {
4781                 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
4782                                 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
4783                                 "in config file to run this testsuite.\n");
4784                 return TEST_FAILED;
4785         }
4786
4787         return unit_test_suite_runner(&cryptodev_qat_continual_testsuite);
4788 }
4789
4790 static int
4791 perftest_sw_armv8_cryptodev(void /*argv __rte_unused, int argc __rte_unused*/)
4792 {
4793         gbl_driver_id = rte_cryptodev_driver_id_get(
4794                         RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
4795
4796         if (gbl_driver_id == -1) {
4797                 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
4798                                 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
4799                                 "in config file to run this testsuite.\n");
4800                 return TEST_FAILED;
4801         }
4802
4803         return unit_test_suite_runner(&cryptodev_armv8_testsuite);
4804 }
4805
4806 static int
4807 perftest_dpaa2_sec_cryptodev(void)
4808 {
4809         gbl_driver_id = rte_cryptodev_driver_id_get(
4810                         RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
4811
4812         if (gbl_driver_id == -1) {
4813                 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
4814                                 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
4815                                 "in config file to run this testsuite.\n");
4816                 return TEST_FAILED;
4817         }
4818
4819         return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
4820 }
4821
4822 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_perftest, perftest_aesni_mb_cryptodev);
4823 REGISTER_TEST_COMMAND(cryptodev_qat_perftest, perftest_qat_cryptodev);
4824 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_perftest, perftest_sw_snow3g_cryptodev);
4825 REGISTER_TEST_COMMAND(cryptodev_qat_snow3g_perftest, perftest_qat_snow3g_cryptodev);
4826 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_perftest, perftest_aesni_gcm_cryptodev);
4827 REGISTER_TEST_COMMAND(cryptodev_openssl_perftest,
4828                 perftest_openssl_cryptodev);
4829 REGISTER_TEST_COMMAND(cryptodev_qat_continual_perftest,
4830                 perftest_qat_continual_cryptodev);
4831 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_perftest,
4832                 perftest_sw_armv8_cryptodev);
4833 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_perftest,
4834                       perftest_dpaa2_sec_cryptodev);