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