| 1758 | } |
| 1759 | |
| 1760 | static int __must_check |
| 1761 | ccp_do_gctr(struct ccp_queue *qp, struct ccp_session *s, |
| 1762 | enum ccp_cipher_dir dir, struct sglist_seg *seg, bool som, bool eom) |
| 1763 | { |
| 1764 | struct ccp_desc *desc; |
| 1765 | |
| 1766 | if (ccp_queue_get_ring_space(qp) == 0) |
| 1767 | return (EAGAIN); |
| 1768 | |
| 1769 | desc = &qp->desc_ring[qp->cq_tail]; |
| 1770 | |
| 1771 | desc->engine = CCP_ENGINE_AES; |
| 1772 | desc->aes.mode = CCP_AES_MODE_GCTR; |
| 1773 | desc->aes.type = s->blkcipher.cipher_type; |
| 1774 | desc->aes.encrypt = dir; |
| 1775 | desc->aes.size = 8 * (seg->ss_len % GMAC_BLOCK_LEN) - 1; |
| 1776 | |
| 1777 | desc->som = som; |
| 1778 | desc->eom = eom; |
| 1779 | |
| 1780 | /* Trailing bytes will be masked off by aes.size above. */ |
| 1781 | desc->length = roundup2(seg->ss_len, GMAC_BLOCK_LEN); |
| 1782 | |
| 1783 | desc->dst_lo = desc->src_lo = (uint32_t)seg->ss_paddr; |
| 1784 | desc->dst_hi = desc->src_hi = seg->ss_paddr >> 32; |
| 1785 | desc->dst_mem = desc->src_mem = CCP_MEMTYPE_SYSTEM; |
| 1786 | |
| 1787 | desc->lsb_ctx_id = ccp_queue_lsb_entry(qp, LSB_ENTRY_IV); |
| 1788 | |
| 1789 | desc->key_lo = ccp_queue_lsb_address(qp, LSB_ENTRY_KEY); |
| 1790 | desc->key_mem = CCP_MEMTYPE_SB; |
| 1791 | |
| 1792 | qp->cq_tail = (qp->cq_tail + 1) % |
| 1793 | (1 << qp->cq_softc->ring_size_order); |
| 1794 | return (0); |
| 1795 | } |
| 1796 | |
| 1797 | static int __must_check |
| 1798 | ccp_do_ghash_final(struct ccp_queue *qp, struct ccp_session *s) |
no test coverage detected