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

Function ccp_newsession

freebsd/crypto/ccp/ccp.c:402–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402static int
403ccp_newsession(device_t dev, crypto_session_t cses,
404 const struct crypto_session_params *csp)
405{
406 struct ccp_softc *sc;
407 struct ccp_session *s;
408 struct auth_hash *auth_hash;
409 enum ccp_aes_mode cipher_mode;
410 unsigned auth_mode;
411 unsigned q;
412
413 /* XXX reconcile auth_mode with use by ccp_sha */
414 switch (csp->csp_auth_alg) {
415 case CRYPTO_SHA1_HMAC:
416 auth_hash = &auth_hash_hmac_sha1;
417 auth_mode = SHA1;
418 break;
419 case CRYPTO_SHA2_256_HMAC:
420 auth_hash = &auth_hash_hmac_sha2_256;
421 auth_mode = SHA2_256;
422 break;
423 case CRYPTO_SHA2_384_HMAC:
424 auth_hash = &auth_hash_hmac_sha2_384;
425 auth_mode = SHA2_384;
426 break;
427 case CRYPTO_SHA2_512_HMAC:
428 auth_hash = &auth_hash_hmac_sha2_512;
429 auth_mode = SHA2_512;
430 break;
431 default:
432 auth_hash = NULL;
433 auth_mode = 0;
434 break;
435 }
436
437 switch (csp->csp_cipher_alg) {
438 case CRYPTO_AES_CBC:
439 cipher_mode = CCP_AES_MODE_CBC;
440 break;
441 case CRYPTO_AES_ICM:
442 cipher_mode = CCP_AES_MODE_CTR;
443 break;
444 case CRYPTO_AES_NIST_GCM_16:
445 cipher_mode = CCP_AES_MODE_GCTR;
446 break;
447 case CRYPTO_AES_XTS:
448 cipher_mode = CCP_AES_MODE_XTS;
449 break;
450 default:
451 cipher_mode = CCP_AES_MODE_ECB;
452 break;
453 }
454
455 sc = device_get_softc(dev);
456 mtx_lock(&sc->lock);
457 if (sc->detaching) {
458 mtx_unlock(&sc->lock);
459 return (ENXIO);

Callers

nothing calls this directly

Calls 6

device_get_softcFunction · 0.85
ccp_init_hmac_digestFunction · 0.85
ccp_aes_setkeyFunction · 0.85
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected