examples/l2fwd-crypto: fix AEAD key setting
[dpdk.git] / examples / l2fwd-crypto / main.c
index 71cb133..8d4a10a 100644 (file)
@@ -752,6 +752,8 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
                                port_cparams[i].hash_verify = 0;
 
                        port_cparams[i].auth_algo = options->auth_xform.auth.algo;
+                       port_cparams[i].digest_length =
+                                       options->auth_xform.auth.digest_length;
                        /* Set IV parameters */
                        if (options->auth_iv.length) {
                                options->auth_xform.auth.iv.offset =
@@ -762,10 +764,15 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
                }
 
                if (port_cparams[i].do_aead) {
+                       port_cparams[i].aead_iv.data = options->aead_iv.data;
+                       port_cparams[i].aead_iv.length = options->aead_iv.length;
+                       if (!options->aead_iv_param)
+                               generate_random_key(port_cparams[i].aead_iv.data,
+                                               port_cparams[i].aead_iv.length);
                        port_cparams[i].aead_algo = options->aead_xform.aead.algo;
                        port_cparams[i].digest_length =
                                        options->aead_xform.aead.digest_length;
-                       if (options->aead_xform.aead.add_auth_data_length) {
+                       if (options->aead_xform.aead.aad_length) {
                                port_cparams[i].aad.data = options->aad.data;
                                port_cparams[i].aad.phys_addr = options->aad.phys_addr;
                                port_cparams[i].aad.length = options->aad.length;
@@ -2031,7 +2038,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
                         * is supported by the algorithm chosen.
                         */
                        } else if (options->aead_key_random_size != -1) {
-                               if (check_supported_size(options->ckey_random_size,
+                               if (check_supported_size(options->aead_key_random_size,
                                                cap->sym.aead.key_size.min,
                                                cap->sym.aead.key_size.max,
                                                cap->sym.aead.key_size.increment)
@@ -2040,7 +2047,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
                                        return -1;
                                }
                                options->aead_xform.aead.key.length =
-                                                       options->ckey_random_size;
+                                                       options->aead_key_random_size;
                        /* No size provided, use minimum size. */
                        } else
                                options->aead_xform.aead.key.length =
@@ -2082,7 +2089,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
                        } else
                                options->aad.length = cap->sym.auth.aad_size.min;
 
-                       options->aead_xform.aead.add_auth_data_length =
+                       options->aead_xform.aead.aad_length =
                                                options->aad.length;
 
                        /* Check if digest size is supported by the algorithm. */