Lines Matching refs:crp

91 swcr_null(struct swcr_session *ses, struct cryptop *crp)  in swcr_null()  argument
101 swcr_encdec(struct swcr_session *ses, struct cryptop *crp) in swcr_encdec() argument
123 if ((crp->crp_payload_length % exf->blocksize) != 0) in swcr_encdec()
131 (crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) in swcr_encdec()
134 if (crp->crp_cipher_key != NULL) { in swcr_encdec()
135 csp = crypto_get_params(crp->crp_session); in swcr_encdec()
137 crp->crp_cipher_key, csp->csp_cipher_klen); in swcr_encdec()
142 crypto_read_iv(crp, iv); in swcr_encdec()
154 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_encdec()
155 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_encdec()
158 if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { in swcr_encdec()
159 crypto_cursor_init(&cc_out, &crp->crp_obuf); in swcr_encdec()
160 crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); in swcr_encdec()
166 resid = crp->crp_payload_length; in swcr_encdec()
167 encrypting = CRYPTO_OP_IS_ENCRYPT(crp->crp_op); in swcr_encdec()
317 swcr_authcompute(struct swcr_session *ses, struct cryptop *crp) in swcr_authcompute() argument
330 csp = crypto_get_params(crp->crp_session); in swcr_authcompute()
331 if (crp->crp_auth_key != NULL) { in swcr_authcompute()
332 swcr_authprepare(axf, sw, crp->crp_auth_key, in swcr_authcompute()
338 if (crp->crp_aad != NULL) in swcr_authcompute()
339 err = axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length); in swcr_authcompute()
341 err = crypto_apply(crp, crp->crp_aad_start, crp->crp_aad_length, in swcr_authcompute()
346 if (CRYPTO_HAS_OUTPUT_BUFFER(crp) && in swcr_authcompute()
347 CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) in swcr_authcompute()
348 err = crypto_apply_buf(&crp->crp_obuf, in swcr_authcompute()
349 crp->crp_payload_output_start, crp->crp_payload_length, in swcr_authcompute()
352 err = crypto_apply(crp, crp->crp_payload_start, in swcr_authcompute()
353 crp->crp_payload_length, axf->Update, &ctx); in swcr_authcompute()
358 axf->Update(&ctx, crp->crp_esn, 4); in swcr_authcompute()
367 if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { in swcr_authcompute()
370 crypto_copydata(crp, crp->crp_digest_start, sw->sw_mlen, uaalg); in swcr_authcompute()
376 crypto_copyback(crp, crp->crp_digest_start, sw->sw_mlen, aalg); in swcr_authcompute()
388 swcr_gmac(struct swcr_session *ses, struct cryptop *crp) in swcr_gmac() argument
412 crypto_read_iv(crp, iv); in swcr_gmac()
415 crypto_cursor_init(&cc, &crp->crp_buf); in swcr_gmac()
416 crypto_cursor_advance(&cc, crp->crp_payload_start); in swcr_gmac()
417 for (resid = crp->crp_payload_length; resid >= blksz; resid -= len) { in swcr_gmac()
439 *blkp = htobe32(crp->crp_payload_length * 8); in swcr_gmac()
446 if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { in swcr_gmac()
449 crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_gmac()
456 crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, tag); in swcr_gmac()
465 swcr_gcm(struct swcr_session *ses, struct cryptop *crp) in swcr_gcm() argument
495 if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) in swcr_gcm()
500 bcopy(crp->crp_iv, iv, ivlen); in swcr_gcm()
506 if (crp->crp_aad != NULL) { in swcr_gcm()
507 len = rounddown(crp->crp_aad_length, blksz); in swcr_gcm()
509 axf->Update(&ctx, crp->crp_aad, len); in swcr_gcm()
510 if (crp->crp_aad_length != len) { in swcr_gcm()
512 memcpy(blk, (char *)crp->crp_aad + len, in swcr_gcm()
513 crp->crp_aad_length - len); in swcr_gcm()
517 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_gcm()
518 crypto_cursor_advance(&cc_in, crp->crp_aad_start); in swcr_gcm()
519 for (resid = crp->crp_aad_length; resid >= blksz; in swcr_gcm()
543 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_gcm()
544 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_gcm()
545 if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { in swcr_gcm()
546 crypto_cursor_init(&cc_out, &crp->crp_obuf); in swcr_gcm()
547 crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); in swcr_gcm()
550 for (resid = crp->crp_payload_length; resid >= blksz; resid -= blksz) { in swcr_gcm()
558 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_gcm()
575 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_gcm()
585 *blkp = htobe32(crp->crp_aad_length * 8); in swcr_gcm()
587 *blkp = htobe32(crp->crp_payload_length * 8); in swcr_gcm()
595 if (!CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_gcm()
598 crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, tag2); in swcr_gcm()
608 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_gcm()
609 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_gcm()
610 for (resid = crp->crp_payload_length; resid > blksz; in swcr_gcm()
636 crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, tag); in swcr_gcm()
648 swcr_ccm_cbc_mac(struct swcr_session *ses, struct cryptop *crp) in swcr_ccm_cbc_mac() argument
664 crypto_read_iv(crp, iv); in swcr_ccm_cbc_mac()
670 ctx.aes_cbc_mac_ctx.authDataLength = crp->crp_payload_length; in swcr_ccm_cbc_mac()
674 if (crp->crp_aad != NULL) in swcr_ccm_cbc_mac()
675 error = axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length); in swcr_ccm_cbc_mac()
677 error = crypto_apply(crp, crp->crp_payload_start, in swcr_ccm_cbc_mac()
678 crp->crp_payload_length, axf->Update, &ctx); in swcr_ccm_cbc_mac()
685 if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { in swcr_ccm_cbc_mac()
688 crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_ccm_cbc_mac()
695 crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, tag); in swcr_ccm_cbc_mac()
703 swcr_ccm(struct swcr_session *ses, struct cryptop *crp) in swcr_ccm() argument
732 if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) in swcr_ccm()
737 bcopy(crp->crp_iv, iv, ivlen); in swcr_ccm()
743 ctx.aes_cbc_mac_ctx.authDataLength = crp->crp_aad_length; in swcr_ccm()
744 ctx.aes_cbc_mac_ctx.cryptDataLength = crp->crp_payload_length; in swcr_ccm()
750 if (crp->crp_aad != NULL) in swcr_ccm()
751 error = axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length); in swcr_ccm()
753 error = crypto_apply(crp, crp->crp_aad_start, in swcr_ccm()
754 crp->crp_aad_length, axf->Update, &ctx); in swcr_ccm()
761 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_ccm()
762 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_ccm()
763 if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { in swcr_ccm()
764 crypto_cursor_init(&cc_out, &crp->crp_obuf); in swcr_ccm()
765 crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); in swcr_ccm()
768 for (resid = crp->crp_payload_length; resid >= blksz; resid -= blksz) { in swcr_ccm()
776 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_ccm()
802 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_ccm()
817 if (!CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_ccm()
820 crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_ccm()
832 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_ccm()
833 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_ccm()
834 for (resid = crp->crp_payload_length; resid > blksz; in swcr_ccm()
860 crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, tag); in swcr_ccm()
874 swcr_eta(struct swcr_session *ses, struct cryptop *crp) in swcr_eta() argument
878 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_eta()
879 error = swcr_encdec(ses, crp); in swcr_eta()
881 error = swcr_authcompute(ses, crp); in swcr_eta()
883 error = swcr_authcompute(ses, crp); in swcr_eta()
885 error = swcr_encdec(ses, crp); in swcr_eta()
894 swcr_compdec(struct swcr_session *ses, struct cryptop *crp) in swcr_compdec() argument
908 data = malloc(crp->crp_payload_length, M_CRYPTO_DATA, M_NOWAIT); in swcr_compdec()
911 crypto_copydata(crp, crp->crp_payload_start, crp->crp_payload_length, in swcr_compdec()
914 if (CRYPTO_OP_IS_COMPRESS(crp->crp_op)) in swcr_compdec()
915 result = cxf->compress(data, crp->crp_payload_length, &out); in swcr_compdec()
917 result = cxf->decompress(data, crp->crp_payload_length, &out); in swcr_compdec()
922 crp->crp_olen = result; in swcr_compdec()
925 if (CRYPTO_OP_IS_COMPRESS(crp->crp_op)) { in swcr_compdec()
926 if (result >= crp->crp_payload_length) { in swcr_compdec()
936 crypto_copyback(crp, crp->crp_payload_start, result, out); in swcr_compdec()
937 if (result < crp->crp_payload_length) { in swcr_compdec()
938 switch (crp->crp_buf.cb_type) { in swcr_compdec()
940 adj = result - crp->crp_payload_length; in swcr_compdec()
941 m_adj(crp->crp_buf.cb_mbuf, adj); in swcr_compdec()
944 struct uio *uio = crp->crp_buf.cb_uio; in swcr_compdec()
947 adj = crp->crp_payload_length - result; in swcr_compdec()
964 adj = crp->crp_payload_length - result; in swcr_compdec()
965 crp->crp_buf.cb_vm_page_len -= adj; in swcr_compdec()
1429 swcr_process(device_t dev, struct cryptop *crp, int hint) in swcr_process() argument
1433 ses = crypto_get_driver_session(crp->crp_session); in swcr_process()
1436 crp->crp_etype = ses->swcr_process(ses, crp); in swcr_process()
1439 crypto_done(crp); in swcr_process()