Skip to content

Commit a9020f2

Browse files
author
Hanno Becker
committed
Clarify the need for a PRNG in various RSA operations
1 parent b06f193 commit a9020f2

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

include/mbedtls/rsa.h

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,12 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
588588
* return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED.
589589
*
590590
* \param ctx The initialized RSA context to use.
591-
* \param f_rng This is the RNG function used to generate the
592-
* PKCS#1 v2.1 padding encoding if \p mode is
593-
* #MBEDTLS_RSA_PRIVATE.
591+
* \param f_rng The RNG to use. If PKCS#1 v2.1 padding encoding is
592+
* used, this must be provided. Additionally, it is
593+
* used for blinding if \p mode is #MBEDTLS_RSA_PRIVATE
594+
* and should be provided in this case; see
595+
* mbedtls_rsa_private() for more. It is ignored
596+
* for PKCS#1 v1.5 padding with #MBEDTLS_RSA_PUBLIC.
594597
* \param p_rng The RNG context to be passed to \p f_rng. May be
595598
* \c NULL if \p f_rng is \c NULL or if \p f_rng doesn't
596599
* need a context argument.
@@ -628,8 +631,10 @@ int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
628631
* return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED.
629632
*
630633
* \param ctx The initialized RSA context to use.
631-
* \param f_rng The RNG function, needed for padding generation if
632-
* \p mode is #MBEDTLS_RSA_PRIVATE.
634+
* \param f_rng The RNG function to use. It is needed for padding generation
635+
* if \p mode is #MBEDTLS_RSA_PUBLIC. If \p mode is
636+
* #MBEDTLS_RSA_PRIVATE (discouraged), it is used for
637+
* blinding and should be provided; see mbedtls_rsa_private().
633638
* \param p_rng The RNG context to be passed to \p f_rng. This may
634639
* be \c NULL if \p f_rng is \c NULL or if \p f_rng
635640
* doesn't need a context argument.
@@ -670,11 +675,10 @@ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
670675
* return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED.
671676
*
672677
* \param ctx The initnialized RSA context to use.
673-
* \param f_rng The RNG function, needed for padding and PKCS#1 v2.1
674-
* encoding if \p mode is #MBEDTLS_RSA_PRIVATE.
678+
* \param f_rng The RNG function to use. This is needed for padding
679+
* generation and must be provided.
675680
* \param p_rng The RNG context to be passed to \p f_rng. This may
676-
* be \c NULL if \p f_rng is \c NULL or if \p f_rng
677-
* doesn't need a context argument.
681+
* be \c NULL if \p f_rng doesn't need a context argument.
678682
* \param mode The mode of operation. This must be either
679683
* #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated).
680684
* \param label The buffer holding the custom label to use.
@@ -883,10 +887,11 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
883887
* return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED.
884888
*
885889
* \param ctx The initialized RSA context to use.
886-
* \param f_rng The RNG function. If the padding mode is PKCS#1 v2.1
887-
* and \p mode is set to #MBEDTLS_RSA_PRIVATE, it is used for
888-
* blinding and should be provided; see mbedtls_rsa_private().
889-
* It is ignored otherwise.
890+
* \param f_rng The RNG function to use. If the padding mode is PKCS#1 v2.1,
891+
* this must be provided. If the padding mode is PKCS#1 v1.5 and
892+
* \p mode is #MBEDTLS_RSA_PRIVATE, it is used for blinding
893+
* and should be provided; see mbedtls_rsa_private() for more
894+
* more. It is ignored otherwise.
890895
* \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL
891896
* if \p f_rng is \c NULL or doesn't need a context argument.
892897
* \param mode The mode of operation. This must be either
@@ -1045,8 +1050,9 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
10451050
* return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED.
10461051
*
10471052
* \param ctx The initialized RSA public key context to use.
1048-
* \param f_rng The RNG function to use. This is only needed if
1049-
* \p mode is #MBEDTLS_RSA_PRIVATE.
1053+
* \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE,
1054+
* this is used for blinding and should be provided; see
1055+
* mbedtls_rsa_private() for more. Otherwise, it is ignored.
10501056
* \param p_rng The RNG context to be passed to \p f_rng. This may be
10511057
* \c NULL if \p f_rng is \c NULL or doesn't need a context.
10521058
* \param mode The mode of operation. This must be either
@@ -1090,8 +1096,9 @@ int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx,
10901096
* return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED.
10911097
*
10921098
* \param ctx The initialized RSA public key context to use.
1093-
* \param f_rng The RNG function to use. This is only needed if
1094-
* \p mode is #MBEDTLS_RSA_PRIVATE.
1099+
* \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE,
1100+
* this is used for blinding and should be provided; see
1101+
* mbedtls_rsa_private() for more. Otherwise, it is ignored.
10951102
* \param p_rng The RNG context to be passed to \p f_rng. This may be
10961103
* \c NULL if \p f_rng is \c NULL or doesn't need a context.
10971104
* \param mode The mode of operation. This must be either
@@ -1146,8 +1153,9 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
11461153
* return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED.
11471154
*
11481155
* \param ctx The initialized RSA public key context to use.
1149-
* \param f_rng The RNG function to use. This is only needed if
1150-
* \p mode is #MBEDTLS_RSA_PRIVATE.
1156+
* \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE,
1157+
* this is used for blinding and should be provided; see
1158+
* mbedtls_rsa_private() for more. Otherwise, it is ignored.
11511159
* \param p_rng The RNG context to be passed to \p f_rng. This may be
11521160
* \c NULL if \p f_rng is \c NULL or doesn't need a context.
11531161
* \param mode The mode of operation. This must be either
@@ -1190,8 +1198,9 @@ int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx,
11901198
* \note The \p hash_id in the RSA context is ignored.
11911199
*
11921200
* \param ctx The initialized RSA public key context to use.
1193-
* \param f_rng The RNG function to use. This is only needed if
1194-
* \p mode is #MBEDTLS_RSA_PRIVATE.
1201+
* \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE,
1202+
* this is used for blinding and should be provided; see
1203+
* mbedtls_rsa_private() for more. Otherwise, it is ignored.
11951204
* \param p_rng The RNG context to be passed to \p f_rng. This may be
11961205
* \c NULL if \p f_rng is \c NULL or doesn't need a context.
11971206
* \param mode The mode of operation. This must be either

0 commit comments

Comments
 (0)