| 973 | } |
| 974 | |
| 975 | static int |
| 976 | swcr_setup_cipher(struct swcr_session *ses, |
| 977 | const struct crypto_session_params *csp) |
| 978 | { |
| 979 | struct swcr_encdec *swe; |
| 980 | struct enc_xform *txf; |
| 981 | int error; |
| 982 | |
| 983 | swe = &ses->swcr_encdec; |
| 984 | txf = crypto_cipher(csp); |
| 985 | MPASS(txf->ivsize == csp->csp_ivlen); |
| 986 | if (txf->ctxsize != 0) { |
| 987 | swe->sw_kschedule = malloc(txf->ctxsize, M_CRYPTO_DATA, |
| 988 | M_NOWAIT); |
| 989 | if (swe->sw_kschedule == NULL) |
| 990 | return (ENOMEM); |
| 991 | } |
| 992 | if (csp->csp_cipher_key != NULL) { |
| 993 | error = txf->setkey(swe->sw_kschedule, |
| 994 | csp->csp_cipher_key, csp->csp_cipher_klen); |
| 995 | if (error) |
| 996 | return (error); |
| 997 | } |
| 998 | swe->sw_exf = txf; |
| 999 | return (0); |
| 1000 | } |
| 1001 | |
| 1002 | static int |
| 1003 | swcr_setup_auth(struct swcr_session *ses, |
no test coverage detected