* ipcomp_init() is called when an CPI is being set up. */
| 154 | * ipcomp_init() is called when an CPI is being set up. |
| 155 | */ |
| 156 | static int |
| 157 | ipcomp_init(struct secasvar *sav, struct xformsw *xsp) |
| 158 | { |
| 159 | const struct comp_algo *tcomp; |
| 160 | struct crypto_session_params csp; |
| 161 | |
| 162 | /* NB: algorithm really comes in alg_enc and not alg_comp! */ |
| 163 | tcomp = comp_algorithm_lookup(sav->alg_enc); |
| 164 | if (tcomp == NULL) { |
| 165 | DPRINTF(("%s: unsupported compression algorithm %d\n", __func__, |
| 166 | sav->alg_comp)); |
| 167 | return EINVAL; |
| 168 | } |
| 169 | sav->alg_comp = sav->alg_enc; /* set for doing histogram */ |
| 170 | sav->tdb_xform = xsp; |
| 171 | sav->tdb_compalgxform = tcomp; |
| 172 | |
| 173 | /* Initialize crypto session */ |
| 174 | memset(&csp, 0, sizeof(csp)); |
| 175 | csp.csp_mode = CSP_MODE_COMPRESS; |
| 176 | csp.csp_cipher_alg = sav->tdb_compalgxform->type; |
| 177 | |
| 178 | return crypto_newsession(&sav->tdb_cryptoid, &csp, V_crypto_support); |
| 179 | } |
| 180 | |
| 181 | /* |
| 182 | * ipcomp_cleanup() used when IPCA is deleted |
nothing calls this directly
no test coverage detected