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