PK: document context validity requirements
Document when a context must be initialized or not, when it must be
set up or not, and whether it needs a private key or a public key will
do.
The implementation is sometimes more liberal than the documentation,
accepting a non-set-up context as a context that can't perform the
requested information. This preserves backward compatibility.
diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function
index bf3cf5d..8a09171 100644
--- a/tests/suites/test_suite_pk.function
+++ b/tests/suites/test_suite_pk.function
@@ -90,10 +90,12 @@
TEST_ASSERT( mbedtls_pk_setup( &pk, NULL ) ==
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+ /* In informational functions, we accept NULL where a context pointer
+ * is expected because that's what the library has done forever.
+ * We do not document that NULL is accepted, so we may wish to change
+ * the behavior in a future version. */
TEST_ASSERT( mbedtls_pk_get_bitlen( NULL ) == 0 );
-
TEST_ASSERT( mbedtls_pk_get_len( NULL ) == 0 );
-
TEST_ASSERT( mbedtls_pk_can_do( NULL, MBEDTLS_PK_NONE ) == 0 );
TEST_ASSERT( mbedtls_pk_sign_restartable( &pk,