Skip to content

Commit fa26d13

Browse files
karel-msjaeckel
authored andcommitted
RSA: update documentation (crypt.tex) to reflect the latest changes
1 parent 7ab625c commit fa26d13

1 file changed

Lines changed: 19 additions & 23 deletions

File tree

doc/crypt.tex

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4568,30 +4568,26 @@ \subsection{RSA Key Size}
45684568
\begin{small}
45694569
\begin{verbatim}
45704570
typedef struct ltc_rsa_parameters {
4571-
/** PSS/OAEP or PKCS #1 v1.5 style
4572-
* 0 -> PKCS #1 v1.5, 1 -> PSS/OAEP */
4573-
int pss_oaep;
4574-
/** saltLength is only defined for PSS
4575-
* If saltLength == 0 -> OAEP, else -> PSS */
4571+
/** saltLength for PSS */
45764572
unsigned long saltlen;
4577-
/** lparam hash for OAEP
4578-
* resp.
4579-
* signature hash for PSS
4580-
* and MGF hash algorithms */
4581-
const char *hash_alg, *mgf1_hash_alg;
4573+
/** Hash algorithm index for OAEP/PSS, -1 if unset */
4574+
int hash_idx;
4575+
/** MGF1 hash algorithm index, -1 if unset */
4576+
int mgf1_hash_idx;
45824577
} ltc_rsa_parameters;
45834578
\end{verbatim}
45844579
\end{small}
45854580

45864581
The \code{struct ltc\_rsa\_parameters} represents the RSA parameters as defined in \code{RSASSA-PSS-params}.
4587-
This \code{struct} is used in two points, first when parsing an RSA key which contains those parameters in order to restrict the usage of the RSA key
4588-
to the given set of parameters, c.f. TBD. Its second use is explained below and defines the parameters used for an RSA operation.
4582+
This \code{struct} is used in two places: first, embedded in \code{rsa\_key} when parsing an RSA key which contains those parameters
4583+
in order to restrict the usage of the RSA key to the given set of parameters (the \code{rsa\_key.pss\_oaep} flag indicates whether
4584+
the key is constrained). Its second use is explained below and defines the parameters used for an RSA operation.
4585+
The hash algorithms are identified by their descriptor index (as returned by \code{find\_hash()}).
45894586

45904587
\index{ltc\_rsa\_op\_parameters}
45914588
\begin{small}
45924589
\begin{verbatim}
45934590
typedef struct ltc_rsa_op_parameters {
4594-
/* pss_oaep flag is unused */
45954591
ltc_rsa_parameters params;
45964592
/* The padding type */
45974593
int padding;
@@ -4646,7 +4642,7 @@ \subsection{Extended Encryption v2}
46464642
\begin{verbatim}
46474643
int rsa_encrypt_key_v2(const unsigned char *in, unsigned long inlen,
46484644
unsigned char *out, unsigned long *outlen,
4649-
ltc_rsa_op_parameters *opts,
4645+
ltc_rsa_op_parameters *params,
46504646
const rsa_key *key);
46514647
\end{verbatim}
46524648

@@ -4688,15 +4684,15 @@ \subsection{Extended Decryption v2}
46884684
\begin{verbatim}
46894685
int rsa_decrypt_key_v2(const unsigned char *in, unsigned long inlen,
46904686
unsigned char *out, unsigned long *outlen,
4691-
ltc_rsa_op_parameters *opts,
4687+
ltc_rsa_op_parameters *params,
46924688
int *stat,
46934689
const rsa_key *key);
46944690
\end{verbatim}
46954691

4696-
Similar to the extended encryption, the parameter \textit{opts.padding} indicates which version of the PKCS \#1 standard to use.
4692+
Similar to the extended encryption, the parameter \textit{params.padding} indicates which version of the PKCS \#1 standard to use.
46974693
It must be set to \code{LTC\_PKCS\_1\_V1\_5} to perform v1.5 decryption, or set to \code{LTC\_PKCS\_1\_OAEP} to perform v2.1 decryption.
46984694

4699-
When performing v1.5 decryption, the \textit{opts.params.hash\_alg} and \textit{opts.u.crypt.lparam} parameters are totally ignored and can be set to \code{NULL} or zero (respectively).
4695+
When performing v1.5 decryption, the \textit{params.params.hash\_idx} and \textit{params.u.crypt.lparam} parameters are totally ignored and can be set to \code{-1} or \code{NULL} (respectively).
47004696

47014697

47024698
\mysection{RSA Signature Generation}
@@ -4735,22 +4731,22 @@ \subsection{Extended Signatures v2}
47354731
\begin{verbatim}
47364732
int rsa_sign_hash_v2(const unsigned char *hash, unsigned long hashlen,
47374733
unsigned char *sig, unsigned long *siglen,
4738-
ltc_rsa_op_parameters *opts,
4734+
ltc_rsa_op_parameters *params,
47394735
const rsa_key *key);
47404736
\end{verbatim}
47414737

47424738
This will PKCS encode the message digest pointed to by \textit{in} of length \textit{inlen} octets. Next, the PKCS encoded hash will be RSA
4743-
\textit{signed} and the output stored in the buffer pointed to by \textit{out} of length \textit{outlen} octets. The \textit{opts.padding} parameter
4739+
\textit{signed} and the output stored in the buffer pointed to by \textit{out} of length \textit{outlen} octets. The \textit{params.padding} parameter
47444740
must be set to \code{LTC\_PKCS\_1\_V1\_5} to produce a v1.5 signature, otherwise, it must be set to \code{LTC\_PKCS\_1\_PSS} to produce a
47454741
v2.1 signature.
47464742

47474743
\index{LTC\_PKCS\_1\_V1\_5\_NA1}
47484744
As of v1.18.0, the library also supports v1.5 signature generation without ASN.1 encoding the signature which can be indicated by passing
4749-
\code{LTC\_PKCS\_1\_V1\_5\_NA1} as \textit{opts.padding} parameter. This option has been introduced to provide compatibilty to SSL3.0 implementations
4745+
\code{LTC\_PKCS\_1\_V1\_5\_NA1} as \textit{params.padding} parameter. This option has been introduced to provide compatibilty to SSL3.0 implementations
47504746
which implemented this.
47514747

4752-
When generating a standard v1.5 signature the \textit{opts.prng}, and \textit{opts.wprng} parameters are ignored.
4753-
When generating a v1.5 signature without ASN.1 decoding additionally the \textit{opts.params.hash\_alg} parameter is ignored.
4748+
When generating a standard v1.5 signature the \textit{params.prng}, and \textit{params.wprng} parameters are ignored.
4749+
When generating a v1.5 signature without ASN.1 decoding additionally the \textit{params.params.hash\_idx} parameter is ignored.
47544750

47554751
\mysection{RSA Signature Verification}
47564752
\index{rsa\_verify\_hash()}
@@ -4798,7 +4794,7 @@ \subsection{Extended Verification v2}
47984794
\begin{verbatim}
47994795
int rsa_verify_hash_v2(const unsigned char *sig, unsigned long siglen,
48004796
const unsigned char *hash, unsigned long hashlen,
4801-
ltc_rsa_op_parameters *opts,
4797+
ltc_rsa_op_parameters *params,
48024798
int *stat,
48034799
const rsa_key *key);
48044800
\end{verbatim}

0 commit comments

Comments
 (0)