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

Function blake2_cipher_process

freebsd/crypto/blake2/blake2_cryptodev.c:329–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327}
328
329static int
330blake2_cipher_process(struct blake2_session *ses, struct cryptop *crp)
331{
332 union {
333 blake2b_state sb;
334 blake2s_state ss;
335 } bctx;
336 char res[BLAKE2B_OUTBYTES], res2[BLAKE2B_OUTBYTES];
337 const struct crypto_session_params *csp;
338 struct fpu_kern_ctx *ctx;
339 const void *key;
340 int ctxidx;
341 bool kt;
342 int error, rc;
343 unsigned klen;
344
345 ctx = NULL;
346 ctxidx = 0;
347 error = EINVAL;
348
349 kt = is_fpu_kern_thread(0);
350 if (!kt) {
351 ACQUIRE_CTX(ctxidx, ctx);
352 fpu_kern_enter(curthread, ctx,
353 FPU_KERN_NORMAL | FPU_KERN_KTHR);
354 }
355
356 csp = crypto_get_params(crp->crp_session);
357 if (crp->crp_auth_key != NULL)
358 key = crp->crp_auth_key;
359 else
360 key = csp->csp_auth_key;
361 klen = csp->csp_auth_klen;
362 switch (csp->csp_auth_alg) {
363 case CRYPTO_BLAKE2B:
364 if (klen > 0)
365 rc = blake2b_init_key(&bctx.sb, ses->mlen, key, klen);
366 else
367 rc = blake2b_init(&bctx.sb, ses->mlen);
368 if (rc != 0)
369 goto out;
370 error = crypto_apply(crp, crp->crp_payload_start,
371 crp->crp_payload_length, blake2b_applicator, &bctx.sb);
372 if (error != 0)
373 goto out;
374 rc = blake2b_final(&bctx.sb, res, ses->mlen);
375 if (rc != 0) {
376 error = EINVAL;
377 goto out;
378 }
379 break;
380 case CRYPTO_BLAKE2S:
381 if (klen > 0)
382 rc = blake2s_init_key(&bctx.ss, ses->mlen, key, klen);
383 else
384 rc = blake2s_init(&bctx.ss, ses->mlen);
385 if (rc != 0)
386 goto out;

Callers 1

blake2_processFunction · 0.85

Calls 15

crypto_get_paramsFunction · 0.85
crypto_applyFunction · 0.85
crypto_copydataFunction · 0.85
timingsafe_bcmpFunction · 0.85
crypto_copybackFunction · 0.85
is_fpu_kern_threadFunction · 0.50
fpu_kern_enterFunction · 0.50
blake2b_init_keyFunction · 0.50
blake2b_initFunction · 0.50
blake2b_finalFunction · 0.50
blake2s_init_keyFunction · 0.50
blake2s_initFunction · 0.50

Tested by

no test coverage detected