Skip to content

Commit 21fec0c

Browse files
committed
psa: Expand documentation for psa_key_agreement()
Document `peer_key` parameter requirements, including an explanation of how the peer key is used and an example for EC keys.
1 parent c67200d commit 21fec0c

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

include/psa/crypto.h

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,21 +2136,28 @@ psa_status_t psa_key_derivation(psa_crypto_generator_t *generator,
21362136
* The resulting generator always has the maximum capacity permitted by
21372137
* the algorithm.
21382138
*
2139-
* \param[in,out] generator The generator object to set up. It must have
2140-
* been initialized as per the documentation for
2141-
* #psa_crypto_generator_t and not yet in use.
2142-
* \param private_key Handle to the private key to use.
2143-
* \param[in] peer_key Public key of the peer. It must be
2144-
* in the same format that psa_import_key()
2145-
* accepts. The standard formats for public
2146-
* keys are documented in the documentation
2147-
* of psa_export_public_key(). For EC keys, it
2148-
* must also be of the same group as the private
2149-
* key.
2150-
* \param peer_key_length Size of \p peer_key in bytes.
2151-
* \param alg The key agreement algorithm to compute
2152-
* (\c PSA_ALG_XXX value such that
2153-
* #PSA_ALG_IS_KEY_AGREEMENT(\p alg) is true).
2139+
* \param[in,out] generator The generator object to set up. It must have been
2140+
* initialized as per the documentation for
2141+
* #psa_crypto_generator_t and not yet in use.
2142+
* \param private_key Handle to the private key to use.
2143+
* \param[in] peer_key Public key of the peer. The peer key must be in the
2144+
* same format that psa_import_key() accepts for the
2145+
* public key type corresponding to the type of
2146+
* \p private_key. That is, this function performs the
2147+
* equivalent of
2148+
* `psa_import_key(internal_public_key_handle,
2149+
* PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR(private_key_type),
2150+
* peer_key, peer_key_length)` where
2151+
* `private_key_type` is the type of \p private_key.
2152+
* For example, for EC keys, this means that \p
2153+
* peer_key is interpreted as a point on the curve
2154+
* that the private key is associated with. The
2155+
* standard formats for public keys are documented in
2156+
* the documentation of psa_export_public_key().
2157+
* \param peer_key_length Size of \p peer_key in bytes.
2158+
* \param alg The key agreement algorithm to compute
2159+
* (\c PSA_ALG_XXX value such that
2160+
* #PSA_ALG_IS_KEY_AGREEMENT(\p alg) is true).
21542161
*
21552162
* \retval #PSA_SUCCESS
21562163
* Success.

0 commit comments

Comments
 (0)