MCPcopy Create free account
hub / github.com/F-Stack/f-stack / padlock_process

Function padlock_process

freebsd/crypto/via/padlock.c:229–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229static int
230padlock_process(device_t dev, struct cryptop *crp, int hint __unused)
231{
232 const struct crypto_session_params *csp;
233 struct padlock_session *ses;
234 int error;
235
236 if ((crp->crp_payload_length % AES_BLOCK_LEN) != 0) {
237 error = EINVAL;
238 goto out;
239 }
240
241 ses = crypto_get_driver_session(crp->crp_session);
242 csp = crypto_get_params(crp->crp_session);
243
244 /* Perform data authentication if requested before decryption. */
245 if (csp->csp_mode == CSP_MODE_ETA &&
246 !CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) {
247 error = padlock_hash_process(ses, crp, csp);
248 if (error != 0)
249 goto out;
250 }
251
252 error = padlock_cipher_process(ses, crp, csp);
253 if (error != 0)
254 goto out;
255
256 /* Perform data authentication if requested after encryption. */
257 if (csp->csp_mode == CSP_MODE_ETA &&
258 CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) {
259 error = padlock_hash_process(ses, crp, csp);
260 if (error != 0)
261 goto out;
262 }
263
264out:
265#if 0
266 /*
267 * This code is not necessary, because contexts will be freed on next
268 * padlock_setup_mackey() call or at padlock_freesession() call.
269 */
270 if (ses != NULL && maccrd != NULL &&
271 (maccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0) {
272 padlock_free_ctx(ses->ses_axf, ses->ses_ictx);
273 padlock_free_ctx(ses->ses_axf, ses->ses_octx);
274 }
275#endif
276 crp->crp_etype = error;
277 crypto_done(crp);
278 return (0);
279}
280
281static device_method_t padlock_methods[] = {
282 DEVMETHOD(device_identify, padlock_identify),

Callers

nothing calls this directly

Calls 6

crypto_get_paramsFunction · 0.85
padlock_hash_processFunction · 0.85
padlock_cipher_processFunction · 0.85
padlock_free_ctxFunction · 0.85
crypto_doneFunction · 0.85

Tested by

no test coverage detected