Method SSL.Cipher.generate_key_share()


Method generate_key_share

array(Gmp.mpz|string(8bit)) generate_key_share(object context, int group)

Description

RFC 8446 4.2.8: Generate an ephemeral key share for the given named Constants.NamedGroup.

Unlike the TLS 1.2 and earlier KeyExchangeECDHE (which drives key agreement through a ServerKeyExchange/ClientKeyExchange message pair), TLS 1.3 key shares travel in ClientHello/ServerHello extensions, so this is a plain function pair rather than a KeyExchange subclass.

Returns
Array
Gmp.mpz|string(8bit) 0

The ephemeral secret (scalar), to keep and pass to compute_key_share_secret() once the peer's share arrives.

string(8bit) 1

The encoded public key, suitable for the key_exchange field of a KeyShareEntry.