Commit 01474b7
crypto: ecdh - Initialize ctx->private_key in proper byte order
The private key in ctx->private_key is currently initialized in reverse
byte order in ecdh_set_secret and whenever the key is needed in proper
byte order the variable priv is introduced and the bytes from
ctx->private_key are copied into priv while being byte-swapped
(ecc_swap_digits). To get rid of the unnecessary byte swapping initialize
ctx->private_key in proper byte order and clean up all functions that were
previously using priv or were called with ctx->private_key:
- ecc_gen_privkey: Directly initialize the passed ctx->private_key with
random bytes filling all the digits of the private key. Get rid of the
priv variable. This function only has ecdh_set_secret as a caller to
create NIST P192/256/384 private keys.
- crypto_ecdh_shared_secret: Called only from ecdh_compute_value with
ctx->private_key. Get rid of the priv variable and work with the passed
private_key directly.
- ecc_make_pub_key: Called only from ecdh_compute_value with
ctx->private_key. Get rid of the priv variable and work with the passed
private_key directly.
Cc: Salvatore Benedetto <salvatore.benedetto@intel.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>1 parent bd955a4 commit 01474b7
3 files changed
Lines changed: 15 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1497 | 1497 | | |
1498 | 1498 | | |
1499 | 1499 | | |
1500 | | - | |
| 1500 | + | |
| 1501 | + | |
1501 | 1502 | | |
1502 | 1503 | | |
1503 | | - | |
1504 | 1504 | | |
1505 | 1505 | | |
1506 | 1506 | | |
| |||
1509 | 1509 | | |
1510 | 1510 | | |
1511 | 1511 | | |
1512 | | - | |
| 1512 | + | |
1513 | 1513 | | |
1514 | 1514 | | |
1515 | 1515 | | |
| |||
1527 | 1527 | | |
1528 | 1528 | | |
1529 | 1529 | | |
1530 | | - | |
| 1530 | + | |
| 1531 | + | |
1531 | 1532 | | |
1532 | 1533 | | |
1533 | 1534 | | |
1534 | 1535 | | |
1535 | 1536 | | |
1536 | | - | |
| 1537 | + | |
1537 | 1538 | | |
1538 | 1539 | | |
1539 | | - | |
1540 | | - | |
1541 | 1540 | | |
1542 | 1541 | | |
1543 | 1542 | | |
| |||
1547 | 1546 | | |
1548 | 1547 | | |
1549 | 1548 | | |
1550 | | - | |
1551 | 1549 | | |
1552 | 1550 | | |
1553 | | - | |
| 1551 | + | |
1554 | 1552 | | |
1555 | 1553 | | |
1556 | 1554 | | |
1557 | 1555 | | |
1558 | | - | |
1559 | | - | |
1560 | 1556 | | |
1561 | 1557 | | |
1562 | 1558 | | |
1563 | 1559 | | |
1564 | 1560 | | |
1565 | 1561 | | |
1566 | | - | |
| 1562 | + | |
1567 | 1563 | | |
1568 | 1564 | | |
1569 | 1565 | | |
| |||
1647 | 1643 | | |
1648 | 1644 | | |
1649 | 1645 | | |
1650 | | - | |
1651 | 1646 | | |
1652 | 1647 | | |
1653 | 1648 | | |
1654 | 1649 | | |
1655 | | - | |
1656 | | - | |
| 1650 | + | |
1657 | 1651 | | |
1658 | 1652 | | |
1659 | 1653 | | |
| |||
1674 | 1668 | | |
1675 | 1669 | | |
1676 | 1670 | | |
1677 | | - | |
1678 | | - | |
1679 | 1671 | | |
1680 | 1672 | | |
1681 | 1673 | | |
1682 | 1674 | | |
1683 | 1675 | | |
1684 | 1676 | | |
1685 | | - | |
| 1677 | + | |
1686 | 1678 | | |
1687 | 1679 | | |
1688 | 1680 | | |
| |||
1692 | 1684 | | |
1693 | 1685 | | |
1694 | 1686 | | |
1695 | | - | |
1696 | 1687 | | |
1697 | 1688 | | |
1698 | 1689 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
44 | | - | |
45 | | - | |
| 43 | + | |
| 44 | + | |
46 | 45 | | |
47 | 46 | | |
48 | | - | |
| 47 | + | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
52 | | - | |
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
0 commit comments