@@ -83,9 +83,6 @@ ALL_F: .octa 0xffffffffffffffffffffffffffffffff
8383
8484.text
8585
86-
87- #define STACK_OFFSET 8*3
88-
8986#define AadHash 16*0
9087#define AadLen 16*1
9188#define InLen (16*1 )+8
@@ -116,11 +113,6 @@ ALL_F: .octa 0xffffffffffffffffffffffffffffffff
116113#define arg4 rcx
117114#define arg5 r8
118115#define arg6 r9
119- #define arg7 STACK_OFFSET+8 (%rsp )
120- #define arg8 STACK_OFFSET+16 (%rsp )
121- #define arg9 STACK_OFFSET+24 (%rsp )
122- #define arg10 STACK_OFFSET+32 (%rsp )
123- #define arg11 STACK_OFFSET+40 (%rsp )
124116#define keysize 2*15*16 (%arg1)
125117#endif
126118
@@ -1507,184 +1499,6 @@ _esb_loop_\@:
15071499 MOVADQ (%r10 ),\TMP1
15081500 aesenclast \TMP1,\XMM0
15091501.endm
1510- /*****************************************************************************
1511- * void aesni_gcm_dec(void *aes_ctx, // AES Key schedule. Starts on a 16 byte boundary.
1512- * struct gcm_context_data *data
1513- * // Context data
1514- * u8 *out, // Plaintext output. Encrypt in-place is allowed.
1515- * const u8 *in, // Ciphertext input
1516- * u64 plaintext_len, // Length of data in bytes for decryption.
1517- * u8 *iv, // Pre-counter block j0: 4 byte salt (from Security Association)
1518- * // concatenated with 8 byte Initialisation Vector (from IPSec ESP Payload)
1519- * // concatenated with 0x00000001. 16-byte aligned pointer.
1520- * u8 *hash_subkey, // H, the Hash sub key input. Data starts on a 16-byte boundary.
1521- * const u8 *aad, // Additional Authentication Data (AAD)
1522- * u64 aad_len, // Length of AAD in bytes. With RFC4106 this is going to be 8 or 12 bytes
1523- * u8 *auth_tag, // Authenticated Tag output. The driver will compare this to the
1524- * // given authentication tag and only return the plaintext if they match.
1525- * u64 auth_tag_len); // Authenticated Tag Length in bytes. Valid values are 16
1526- * // (most likely), 12 or 8.
1527- *
1528- * Assumptions:
1529- *
1530- * keys:
1531- * keys are pre-expanded and aligned to 16 bytes. we are using the first
1532- * set of 11 keys in the data structure void *aes_ctx
1533- *
1534- * iv:
1535- * 0 1 2 3
1536- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1537- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1538- * | Salt (From the SA) |
1539- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1540- * | Initialization Vector |
1541- * | (This is the sequence number from IPSec header) |
1542- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1543- * | 0x1 |
1544- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1545- *
1546- *
1547- *
1548- * AAD:
1549- * AAD padded to 128 bits with 0
1550- * for example, assume AAD is a u32 vector
1551- *
1552- * if AAD is 8 bytes:
1553- * AAD[3] = {A0, A1};
1554- * padded AAD in xmm register = {A1 A0 0 0}
1555- *
1556- * 0 1 2 3
1557- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1558- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1559- * | SPI (A1) |
1560- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1561- * | 32-bit Sequence Number (A0) |
1562- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1563- * | 0x0 |
1564- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1565- *
1566- * AAD Format with 32-bit Sequence Number
1567- *
1568- * if AAD is 12 bytes:
1569- * AAD[3] = {A0, A1, A2};
1570- * padded AAD in xmm register = {A2 A1 A0 0}
1571- *
1572- * 0 1 2 3
1573- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1574- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1575- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1576- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1577- * | SPI (A2) |
1578- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1579- * | 64-bit Extended Sequence Number {A1,A0} |
1580- * | |
1581- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1582- * | 0x0 |
1583- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1584- *
1585- * AAD Format with 64-bit Extended Sequence Number
1586- *
1587- * poly = x^128 + x^127 + x^126 + x^121 + 1
1588- *
1589- *****************************************************************************/
1590- SYM_FUNC_START(aesni_gcm_dec)
1591- FUNC_SAVE
1592-
1593- GCM_INIT %arg6, arg7, arg8, arg9
1594- GCM_ENC_DEC dec
1595- GCM_COMPLETE arg10, arg11
1596- FUNC_RESTORE
1597- RET
1598- SYM_FUNC_END(aesni_gcm_dec)
1599-
1600-
1601- /*****************************************************************************
1602- * void aesni_gcm_enc(void *aes_ctx, // AES Key schedule. Starts on a 16 byte boundary.
1603- * struct gcm_context_data *data
1604- * // Context data
1605- * u8 *out, // Ciphertext output. Encrypt in-place is allowed.
1606- * const u8 *in, // Plaintext input
1607- * u64 plaintext_len, // Length of data in bytes for encryption.
1608- * u8 *iv, // Pre-counter block j0: 4 byte salt (from Security Association)
1609- * // concatenated with 8 byte Initialisation Vector (from IPSec ESP Payload)
1610- * // concatenated with 0x00000001. 16-byte aligned pointer.
1611- * u8 *hash_subkey, // H, the Hash sub key input. Data starts on a 16-byte boundary.
1612- * const u8 *aad, // Additional Authentication Data (AAD)
1613- * u64 aad_len, // Length of AAD in bytes. With RFC4106 this is going to be 8 or 12 bytes
1614- * u8 *auth_tag, // Authenticated Tag output.
1615- * u64 auth_tag_len); // Authenticated Tag Length in bytes. Valid values are 16 (most likely),
1616- * // 12 or 8.
1617- *
1618- * Assumptions:
1619- *
1620- * keys:
1621- * keys are pre-expanded and aligned to 16 bytes. we are using the
1622- * first set of 11 keys in the data structure void *aes_ctx
1623- *
1624- *
1625- * iv:
1626- * 0 1 2 3
1627- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1628- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1629- * | Salt (From the SA) |
1630- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1631- * | Initialization Vector |
1632- * | (This is the sequence number from IPSec header) |
1633- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1634- * | 0x1 |
1635- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1636- *
1637- *
1638- *
1639- * AAD:
1640- * AAD padded to 128 bits with 0
1641- * for example, assume AAD is a u32 vector
1642- *
1643- * if AAD is 8 bytes:
1644- * AAD[3] = {A0, A1};
1645- * padded AAD in xmm register = {A1 A0 0 0}
1646- *
1647- * 0 1 2 3
1648- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1649- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1650- * | SPI (A1) |
1651- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1652- * | 32-bit Sequence Number (A0) |
1653- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1654- * | 0x0 |
1655- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1656- *
1657- * AAD Format with 32-bit Sequence Number
1658- *
1659- * if AAD is 12 bytes:
1660- * AAD[3] = {A0, A1, A2};
1661- * padded AAD in xmm register = {A2 A1 A0 0}
1662- *
1663- * 0 1 2 3
1664- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1665- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1666- * | SPI (A2) |
1667- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1668- * | 64-bit Extended Sequence Number {A1,A0} |
1669- * | |
1670- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1671- * | 0x0 |
1672- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1673- *
1674- * AAD Format with 64-bit Extended Sequence Number
1675- *
1676- * poly = x^128 + x^127 + x^126 + x^121 + 1
1677- ***************************************************************************/
1678- SYM_FUNC_START(aesni_gcm_enc)
1679- FUNC_SAVE
1680-
1681- GCM_INIT %arg6, arg7, arg8, arg9
1682- GCM_ENC_DEC enc
1683-
1684- GCM_COMPLETE arg10, arg11
1685- FUNC_RESTORE
1686- RET
1687- SYM_FUNC_END(aesni_gcm_enc)
16881502
16891503/*****************************************************************************
16901504* void aesni_gcm_init(void *aes_ctx, // AES Key schedule. Starts on a 16 byte boundary.
0 commit comments