1 | <?php |
||
42 | final class EcDH |
||
43 | { |
||
44 | /** |
||
45 | * Adapter used for math calculations |
||
46 | * |
||
47 | * @var GmpMath |
||
48 | */ |
||
49 | private $adapter; |
||
50 | |||
51 | /** |
||
52 | * Secret key between the two parties |
||
53 | * |
||
54 | * @var Point |
||
55 | */ |
||
56 | private $secretKey = null; |
||
57 | |||
58 | /** |
||
59 | * |
||
60 | * @var PublicKey |
||
61 | */ |
||
62 | private $recipientKey; |
||
63 | |||
64 | /** |
||
65 | * |
||
66 | * @var PrivateKey |
||
67 | */ |
||
68 | private $senderKey; |
||
69 | |||
70 | /** |
||
71 | * Initialize a new exchange from a generator point. |
||
72 | * |
||
73 | * @param GmpMath $adapter A math adapter instance. |
||
74 | */ |
||
75 | public function __construct(GmpMath $adapter) |
||
79 | |||
80 | /** |
||
81 | * {@inheritDoc} |
||
82 | * @see \Jose\Component\Core\Util\Ecc\Crypto\EcDH\EcDH::calculateSharedKey() |
||
83 | */ |
||
84 | public function calculateSharedKey() |
||
90 | |||
91 | /** |
||
92 | * {@inheritDoc} |
||
93 | * @see \Jose\Component\Core\Util\Ecc\Crypto\EcDH\EcDH::createMultiPartyKey() |
||
94 | */ |
||
95 | public function createMultiPartyKey() |
||
101 | |||
102 | /** |
||
103 | * {@inheritDoc} |
||
104 | * @see \Jose\Component\Core\Util\Ecc\Crypto\EcDH\EcDH::setRecipientKey() |
||
105 | */ |
||
106 | public function setRecipientKey(PublicKey $key = null) |
||
111 | |||
112 | /** |
||
113 | * {@inheritDoc} |
||
114 | * @see \Jose\Component\Core\Util\Ecc\Crypto\EcDH\EcDH::setSenderKey() |
||
115 | */ |
||
116 | public function setSenderKey(PrivateKey $key) |
||
121 | |||
122 | /** |
||
123 | * |
||
124 | */ |
||
125 | private function calculateKey() |
||
133 | |||
134 | /** |
||
135 | * Verifies that the shared secret is known, or that the required keys are available |
||
136 | * to calculate the shared secret. |
||
137 | * @throws \RuntimeException when the exchange has not been made. |
||
138 | */ |
||
139 | private function checkExchangeState() |
||
153 | } |
||
154 |