| 1256 | } |
| 1257 | |
| 1258 | static int __must_check |
| 1259 | ccp_do_hmac(struct ccp_queue *qp, struct ccp_session *s, struct cryptop *crp, |
| 1260 | const struct ccp_completion_ctx *cctx) |
| 1261 | { |
| 1262 | device_t dev; |
| 1263 | struct auth_hash *axf; |
| 1264 | int error; |
| 1265 | |
| 1266 | dev = qp->cq_softc->dev; |
| 1267 | axf = s->hmac.auth_hash; |
| 1268 | |
| 1269 | /* |
| 1270 | * Populate the SGL describing inside hash contents. We want to hash |
| 1271 | * the ipad (key XOR fixed bit pattern) concatenated with the user |
| 1272 | * data. |
| 1273 | */ |
| 1274 | sglist_reset(qp->cq_sg_ulptx); |
| 1275 | error = sglist_append(qp->cq_sg_ulptx, s->hmac.ipad, axf->blocksize); |
| 1276 | if (error != 0) |
| 1277 | return (error); |
| 1278 | if (crp->crp_aad_length != 0) { |
| 1279 | error = sglist_append_sglist(qp->cq_sg_ulptx, qp->cq_sg_crp, |
| 1280 | crp->crp_aad_start, crp->crp_aad_length); |
| 1281 | if (error != 0) |
| 1282 | return (error); |
| 1283 | } |
| 1284 | error = sglist_append_sglist(qp->cq_sg_ulptx, qp->cq_sg_crp, |
| 1285 | crp->crp_payload_start, crp->crp_payload_length); |
| 1286 | if (error != 0) { |
| 1287 | DPRINTF(dev, "%s: sglist too short\n", __func__); |
| 1288 | return (error); |
| 1289 | } |
| 1290 | /* Populate SGL for output -- use hmac.res buffer. */ |
| 1291 | sglist_reset(qp->cq_sg_dst); |
| 1292 | error = sglist_append(qp->cq_sg_dst, s->hmac.res, |
| 1293 | roundup2(axf->hashsize, LSB_ENTRY_SIZE)); |
| 1294 | if (error != 0) |
| 1295 | return (error); |
| 1296 | |
| 1297 | error = ccp_sha(qp, s->hmac.auth_mode, qp->cq_sg_ulptx, qp->cq_sg_dst, |
| 1298 | cctx); |
| 1299 | if (error != 0) { |
| 1300 | DPRINTF(dev, "%s: ccp_sha error\n", __func__); |
| 1301 | return (error); |
| 1302 | } |
| 1303 | return (0); |
| 1304 | } |
| 1305 | |
| 1306 | int __must_check |
| 1307 | ccp_hmac(struct ccp_queue *qp, struct ccp_session *s, struct cryptop *crp) |
no test coverage detected