Lines Matching refs:crp

88 swcr_null(const struct swcr_session *ses, struct cryptop *crp)  in swcr_null()  argument
98 swcr_encdec(const struct swcr_session *ses, struct cryptop *crp) in swcr_encdec() argument
117 csp = crypto_get_params(crp->crp_session); in swcr_encdec()
121 if ((crp->crp_payload_length % exf->blocksize) != 0) in swcr_encdec()
129 (crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) in swcr_encdec()
133 if (crp->crp_cipher_key != NULL) { in swcr_encdec()
134 error = exf->setkey(ctx, crp->crp_cipher_key, in swcr_encdec()
141 crypto_read_iv(crp, blk); in swcr_encdec()
144 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_encdec()
145 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_encdec()
146 if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { in swcr_encdec()
147 crypto_cursor_init(&cc_out, &crp->crp_obuf); in swcr_encdec()
148 crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); in swcr_encdec()
152 encrypting = CRYPTO_OP_IS_ENCRYPT(crp->crp_op); in swcr_encdec()
161 for (resid = crp->crp_payload_length; resid >= blksz; resid -= todo) { in swcr_encdec()
241 swcr_authcompute(const struct swcr_session *ses, struct cryptop *crp) in swcr_authcompute() argument
257 csp = crypto_get_params(crp->crp_session); in swcr_authcompute()
258 if (crp->crp_auth_key != NULL) { in swcr_authcompute()
260 hmac_init_ipad(axf, crp->crp_auth_key, in swcr_authcompute()
264 axf->Setkey(&s.ctx, crp->crp_auth_key, in swcr_authcompute()
270 if (crp->crp_aad != NULL) in swcr_authcompute()
271 err = axf->Update(&s.ctx, crp->crp_aad, crp->crp_aad_length); in swcr_authcompute()
273 err = crypto_apply(crp, crp->crp_aad_start, crp->crp_aad_length, in swcr_authcompute()
278 if (CRYPTO_HAS_OUTPUT_BUFFER(crp) && in swcr_authcompute()
279 CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) in swcr_authcompute()
280 err = crypto_apply_buf(&crp->crp_obuf, in swcr_authcompute()
281 crp->crp_payload_output_start, crp->crp_payload_length, in swcr_authcompute()
284 err = crypto_apply(crp, crp->crp_payload_start, in swcr_authcompute()
285 crp->crp_payload_length, axf->Update, &s.ctx); in swcr_authcompute()
290 axf->Update(&s.ctx, crp->crp_esn, 4); in swcr_authcompute()
294 if (crp->crp_auth_key != NULL) in swcr_authcompute()
295 hmac_init_opad(axf, crp->crp_auth_key, in swcr_authcompute()
303 if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { in swcr_authcompute()
304 crypto_copydata(crp, crp->crp_digest_start, sw->sw_mlen, s.uaalg); in swcr_authcompute()
309 crypto_copyback(crp, crp->crp_digest_start, sw->sw_mlen, s.aalg); in swcr_authcompute()
320 swcr_gmac(const struct swcr_session *ses, struct cryptop *crp) in swcr_gmac() argument
343 if (crp->crp_auth_key != NULL) { in swcr_gmac()
345 axf->Setkey(&s.ctx, crp->crp_auth_key, in swcr_gmac()
346 crypto_get_params(crp->crp_session)->csp_auth_klen); in swcr_gmac()
352 crypto_read_iv(crp, blk); in swcr_gmac()
355 crypto_cursor_init(&cc, &crp->crp_buf); in swcr_gmac()
356 crypto_cursor_advance(&cc, crp->crp_payload_start); in swcr_gmac()
357 for (resid = crp->crp_payload_length; resid >= blksz; resid -= len) { in swcr_gmac()
378 *blkp = htobe32(crp->crp_payload_length * 8); in swcr_gmac()
385 if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { in swcr_gmac()
386 crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_gmac()
392 crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, s.tag); in swcr_gmac()
399 swcr_gcm(const struct swcr_session *ses, struct cryptop *crp) in swcr_gcm() argument
425 if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) in swcr_gcm()
431 if (crp->crp_cipher_key != NULL) in swcr_gcm()
432 exf->setkey(ctx, crp->crp_cipher_key, in swcr_gcm()
433 crypto_get_params(crp->crp_session)->csp_cipher_klen); in swcr_gcm()
436 exf->reinit(ctx, crp->crp_iv, ivlen); in swcr_gcm()
439 if (crp->crp_aad != NULL) { in swcr_gcm()
440 inlen = rounddown2(crp->crp_aad_length, blksz); in swcr_gcm()
442 exf->update(ctx, crp->crp_aad, inlen); in swcr_gcm()
443 if (crp->crp_aad_length != inlen) { in swcr_gcm()
445 memcpy(blk, (char *)crp->crp_aad + inlen, in swcr_gcm()
446 crp->crp_aad_length - inlen); in swcr_gcm()
450 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_gcm()
451 crypto_cursor_advance(&cc_in, crp->crp_aad_start); in swcr_gcm()
452 for (resid = crp->crp_aad_length; resid >= blksz; in swcr_gcm()
473 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_gcm()
474 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_gcm()
475 if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { in swcr_gcm()
476 crypto_cursor_init(&cc_out, &crp->crp_obuf); in swcr_gcm()
477 crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); in swcr_gcm()
482 for (resid = crp->crp_payload_length; resid >= blksz; resid -= todo) { in swcr_gcm()
494 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_gcm()
529 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_gcm()
539 *blkp = htobe32(crp->crp_aad_length * 8); in swcr_gcm()
541 *blkp = htobe32(crp->crp_payload_length * 8); in swcr_gcm()
549 if (!CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_gcm()
550 crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_gcm()
559 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_gcm()
560 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_gcm()
563 for (resid = crp->crp_payload_length; resid > blksz; in swcr_gcm()
609 crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_gcm()
673 swcr_ccm_cbc_mac(const struct swcr_session *ses, struct cryptop *crp) in swcr_ccm_cbc_mac() argument
686 csp = crypto_get_params(crp->crp_session); in swcr_ccm_cbc_mac()
690 if (crp->crp_auth_key != NULL) { in swcr_ccm_cbc_mac()
692 axf->Setkey(&s.ctx, crp->crp_auth_key, csp->csp_auth_klen); in swcr_ccm_cbc_mac()
700 axf->Reinit(&s.ctx, crp->crp_iv, ivlen); in swcr_ccm_cbc_mac()
703 build_ccm_b0(crp->crp_iv, ivlen, crp->crp_payload_length, 0, in swcr_ccm_cbc_mac()
707 len = build_ccm_aad_length(crp->crp_payload_length, s.blk); in swcr_ccm_cbc_mac()
710 crypto_apply(crp, crp->crp_payload_start, crp->crp_payload_length, in swcr_ccm_cbc_mac()
717 if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { in swcr_ccm_cbc_mac()
718 crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_ccm_cbc_mac()
724 crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_ccm_cbc_mac()
732 swcr_ccm(const struct swcr_session *ses, struct cryptop *crp) in swcr_ccm() argument
752 csp = crypto_get_params(crp->crp_session); in swcr_ccm()
760 if (crp->crp_payload_length > ccm_max_payload_length(csp)) in swcr_ccm()
763 if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) in swcr_ccm()
769 if (crp->crp_cipher_key != NULL) in swcr_ccm()
770 exf->setkey(ctx, crp->crp_cipher_key, in swcr_ccm()
771 crypto_get_params(crp->crp_session)->csp_cipher_klen); in swcr_ccm()
774 exf->reinit(ctx, crp->crp_iv, ivlen); in swcr_ccm()
779 build_ccm_b0(crp->crp_iv, ivlen, crp->crp_aad_length, in swcr_ccm()
780 crp->crp_payload_length, swa->sw_mlen, blk); in swcr_ccm()
784 if (crp->crp_aad_length != 0) { in swcr_ccm()
785 len = build_ccm_aad_length(crp->crp_aad_length, blk); in swcr_ccm()
787 if (crp->crp_aad != NULL) in swcr_ccm()
788 exf->update(ctx, crp->crp_aad, crp->crp_aad_length); in swcr_ccm()
790 crypto_apply(crp, crp->crp_aad_start, in swcr_ccm()
791 crp->crp_aad_length, exf->update, ctx); in swcr_ccm()
794 len = (len + crp->crp_aad_length) % CCM_CBC_BLOCK_LEN; in swcr_ccm()
803 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_ccm()
804 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_ccm()
805 if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { in swcr_ccm()
806 crypto_cursor_init(&cc_out, &crp->crp_obuf); in swcr_ccm()
807 crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); in swcr_ccm()
812 for (resid = crp->crp_payload_length; resid >= blksz; resid -= todo) { in swcr_ccm()
824 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_ccm()
868 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_ccm()
883 if (!CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_ccm()
884 crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_ccm()
893 exf->reinit(ctx, crp->crp_iv, ivlen); in swcr_ccm()
894 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_ccm()
895 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_ccm()
898 for (resid = crp->crp_payload_length; resid >= blksz; in swcr_ccm()
946 crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_ccm()
957 swcr_chacha20_poly1305(const struct swcr_session *ses, struct cryptop *crp) in swcr_chacha20_poly1305() argument
983 if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) in swcr_chacha20_poly1305()
986 csp = crypto_get_params(crp->crp_session); in swcr_chacha20_poly1305()
989 if (crp->crp_cipher_key != NULL) in swcr_chacha20_poly1305()
990 exf->setkey(ctx, crp->crp_cipher_key, in swcr_chacha20_poly1305()
994 exf->reinit(ctx, crp->crp_iv, csp->csp_ivlen); in swcr_chacha20_poly1305()
997 if (crp->crp_aad != NULL) in swcr_chacha20_poly1305()
998 exf->update(ctx, crp->crp_aad, crp->crp_aad_length); in swcr_chacha20_poly1305()
1000 crypto_apply(crp, crp->crp_aad_start, crp->crp_aad_length, in swcr_chacha20_poly1305()
1002 if (crp->crp_aad_length % POLY1305_BLOCK_LEN != 0) { in swcr_chacha20_poly1305()
1006 crp->crp_aad_length % POLY1305_BLOCK_LEN); in swcr_chacha20_poly1305()
1010 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_chacha20_poly1305()
1011 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_chacha20_poly1305()
1012 if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { in swcr_chacha20_poly1305()
1013 crypto_cursor_init(&cc_out, &crp->crp_obuf); in swcr_chacha20_poly1305()
1014 crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); in swcr_chacha20_poly1305()
1019 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_chacha20_poly1305()
1020 for (resid = crp->crp_payload_length; resid >= blksz; in swcr_chacha20_poly1305()
1069 crypto_apply(crp, crp->crp_payload_start, in swcr_chacha20_poly1305()
1070 crp->crp_payload_length, exf->update, ctx); in swcr_chacha20_poly1305()
1071 if (crp->crp_payload_length % POLY1305_BLOCK_LEN != 0) { in swcr_chacha20_poly1305()
1075 crp->crp_payload_length % POLY1305_BLOCK_LEN); in swcr_chacha20_poly1305()
1080 blkp[0] = htole64(crp->crp_aad_length); in swcr_chacha20_poly1305()
1081 blkp[1] = htole64(crp->crp_payload_length); in swcr_chacha20_poly1305()
1089 if (!CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_chacha20_poly1305()
1090 crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_chacha20_poly1305()
1099 crypto_cursor_init(&cc_in, &crp->crp_buf); in swcr_chacha20_poly1305()
1100 crypto_cursor_advance(&cc_in, crp->crp_payload_start); in swcr_chacha20_poly1305()
1103 for (resid = crp->crp_payload_length; resid > blksz; in swcr_chacha20_poly1305()
1150 crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, in swcr_chacha20_poly1305()
1164 swcr_eta(const struct swcr_session *ses, struct cryptop *crp) in swcr_eta() argument
1168 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { in swcr_eta()
1169 error = swcr_encdec(ses, crp); in swcr_eta()
1171 error = swcr_authcompute(ses, crp); in swcr_eta()
1173 error = swcr_authcompute(ses, crp); in swcr_eta()
1175 error = swcr_encdec(ses, crp); in swcr_eta()
1184 swcr_compdec(const struct swcr_session *ses, struct cryptop *crp) in swcr_compdec() argument
1198 data = malloc(crp->crp_payload_length, M_CRYPTO_DATA, M_NOWAIT); in swcr_compdec()
1201 crypto_copydata(crp, crp->crp_payload_start, crp->crp_payload_length, in swcr_compdec()
1204 if (CRYPTO_OP_IS_COMPRESS(crp->crp_op)) in swcr_compdec()
1205 result = cxf->compress(data, crp->crp_payload_length, &out); in swcr_compdec()
1207 result = cxf->decompress(data, crp->crp_payload_length, &out); in swcr_compdec()
1212 crp->crp_olen = result; in swcr_compdec()
1215 if (CRYPTO_OP_IS_COMPRESS(crp->crp_op)) { in swcr_compdec()
1216 if (result >= crp->crp_payload_length) { in swcr_compdec()
1226 crypto_copyback(crp, crp->crp_payload_start, result, out); in swcr_compdec()
1227 if (result < crp->crp_payload_length) { in swcr_compdec()
1228 switch (crp->crp_buf.cb_type) { in swcr_compdec()
1231 adj = result - crp->crp_payload_length; in swcr_compdec()
1232 m_adj(crp->crp_buf.cb_mbuf, adj); in swcr_compdec()
1235 struct uio *uio = crp->crp_buf.cb_uio; in swcr_compdec()
1238 adj = crp->crp_payload_length - result; in swcr_compdec()
1255 adj = crp->crp_payload_length - result; in swcr_compdec()
1256 crp->crp_buf.cb_vm_page_len -= adj; in swcr_compdec()
1673 swcr_process(device_t dev, struct cryptop *crp, int hint) in swcr_process() argument
1677 ses = crypto_get_driver_session(crp->crp_session); in swcr_process()
1679 crp->crp_etype = ses->swcr_process(ses, crp); in swcr_process()
1681 crypto_done(crp); in swcr_process()