* Process a request. */
| 242 | * Process a request. |
| 243 | */ |
| 244 | static int |
| 245 | cryptocteon_process(device_t dev, struct cryptop *crp, int hint) |
| 246 | { |
| 247 | const struct crypto_session_params *csp; |
| 248 | struct octo_sess *od; |
| 249 | size_t iovcnt, iovlen; |
| 250 | struct mbuf *m = NULL; |
| 251 | struct uio *uiop = NULL; |
| 252 | unsigned char *ivp = NULL; |
| 253 | unsigned char iv_data[16]; |
| 254 | unsigned char icv[SHA1_HASH_LEN], icv2[SHA1_HASH_LEN]; |
| 255 | int auth_off, auth_len, crypt_off, crypt_len; |
| 256 | struct cryptocteon_softc *sc; |
| 257 | |
| 258 | sc = device_get_softc(dev); |
| 259 | |
| 260 | crp->crp_etype = 0; |
| 261 | |
| 262 | od = crypto_get_driver_session(crp->crp_session); |
| 263 | csp = crypto_get_params(crp->crp_session); |
| 264 | |
| 265 | /* |
| 266 | * The crypto routines assume that the regions to auth and |
| 267 | * cipher are exactly 8 byte multiples and aligned on 8 |
| 268 | * byte logical boundaries within the iovecs. |
| 269 | */ |
| 270 | if (crp->crp_aad_length % 8 != 0 || crp->crp_payload_length % 8 != 0) { |
| 271 | crp->crp_etype = EFBIG; |
| 272 | goto done; |
| 273 | } |
| 274 | |
| 275 | /* |
| 276 | * As currently written, the crypto routines assume the AAD and |
| 277 | * payload are adjacent. |
| 278 | */ |
| 279 | if (crp->crp_aad_length != 0 && crp->crp_payload_start != |
| 280 | crp->crp_aad_start + crp->crp_aad_length) { |
| 281 | crp->crp_etype = EFBIG; |
| 282 | goto done; |
| 283 | } |
| 284 | |
| 285 | crypt_off = crp->crp_payload_start; |
| 286 | crypt_len = crp->crp_payload_length; |
| 287 | if (crp->crp_aad_length != 0) { |
| 288 | auth_off = crp->crp_aad_start; |
| 289 | auth_len = crp->crp_aad_length + crp->crp_payload_length; |
| 290 | } else { |
| 291 | auth_off = crypt_off; |
| 292 | auth_len = crypt_len; |
| 293 | } |
| 294 | |
| 295 | /* |
| 296 | * do some error checking outside of the loop for m and IOV processing |
| 297 | * this leaves us with valid m or uiop pointers for later |
| 298 | */ |
| 299 | switch (crp->crp_buf.cb_type) { |
| 300 | case CRYPTO_BUF_MBUF: |
| 301 | { |
nothing calls this directly
no test coverage detected