@@ -111,8 +111,10 @@ cperf_verify_op(struct rte_crypto_op *op,
111
111
uint32_t len ;
112
112
uint16_t nb_segs ;
113
113
uint8_t * data ;
114
- uint32_t cipher_offset , auth_offset ;
115
- uint8_t cipher , auth ;
114
+ uint32_t cipher_offset , auth_offset = 0 ;
115
+ bool cipher = false;
116
+ bool digest_verify = false;
117
+ bool is_encrypt = false;
116
118
int res = 0 ;
117
119
118
120
if (op -> status != RTE_CRYPTO_OP_STATUS_SUCCESS )
@@ -150,42 +152,43 @@ cperf_verify_op(struct rte_crypto_op *op,
150
152
151
153
switch (options -> op_type ) {
152
154
case CPERF_CIPHER_ONLY :
153
- cipher = 1 ;
155
+ cipher = true ;
154
156
cipher_offset = 0 ;
155
- auth = 0 ;
156
- auth_offset = 0 ;
157
- break ;
158
- case CPERF_CIPHER_THEN_AUTH :
159
- cipher = 1 ;
160
- cipher_offset = 0 ;
161
- auth = 1 ;
162
- auth_offset = options -> test_buffer_size ;
157
+ is_encrypt = options -> cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT ;
163
158
break ;
164
159
case CPERF_AUTH_ONLY :
165
- cipher = 0 ;
166
160
cipher_offset = 0 ;
167
- auth = 1 ;
168
- auth_offset = options -> test_buffer_size ;
161
+ if (options -> auth_op == RTE_CRYPTO_AUTH_OP_GENERATE ) {
162
+ auth_offset = options -> test_buffer_size ;
163
+ digest_verify = true;
164
+ }
169
165
break ;
166
+ case CPERF_CIPHER_THEN_AUTH :
170
167
case CPERF_AUTH_THEN_CIPHER :
171
- cipher = 1 ;
168
+ cipher = true ;
172
169
cipher_offset = 0 ;
173
- auth = 1 ;
174
- auth_offset = options -> test_buffer_size ;
170
+ if (options -> cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT ) {
171
+ auth_offset = options -> test_buffer_size ;
172
+ digest_verify = true;
173
+ is_encrypt = true;
174
+ }
175
175
break ;
176
176
case CPERF_AEAD :
177
- cipher = 1 ;
177
+ cipher = true ;
178
178
cipher_offset = 0 ;
179
- auth = 1 ;
180
- auth_offset = options -> test_buffer_size ;
179
+ if (options -> aead_op == RTE_CRYPTO_AEAD_OP_ENCRYPT ) {
180
+ auth_offset = options -> test_buffer_size ;
181
+ digest_verify = true;
182
+ is_encrypt = true;
183
+ }
181
184
break ;
182
185
default :
183
186
res = 1 ;
184
187
goto out ;
185
188
}
186
189
187
- if (cipher == 1 ) {
188
- if (options -> cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT )
190
+ if (cipher ) {
191
+ if (is_encrypt )
189
192
res += !!memcmp (data + cipher_offset ,
190
193
vector -> ciphertext .data ,
191
194
options -> test_buffer_size );
@@ -195,12 +198,8 @@ cperf_verify_op(struct rte_crypto_op *op,
195
198
options -> test_buffer_size );
196
199
}
197
200
198
- if (auth == 1 ) {
199
- if (options -> auth_op == RTE_CRYPTO_AUTH_OP_GENERATE )
200
- res += !!memcmp (data + auth_offset ,
201
- vector -> digest .data ,
202
- options -> digest_sz );
203
- }
201
+ if (digest_verify )
202
+ res += !!memcmp (data + auth_offset , vector -> digest .data , options -> digest_sz );
204
203
205
204
out :
206
205
rte_free (data );
0 commit comments