Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 126 additions & 4 deletions doc/crypt.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7062,6 +7062,7 @@ \subsection{DSA Key Import}

\chapter{The PKA Union}
\index{ltc\_pka\_key}
\label{pka-union}

To be able to refer to all the potential public key algorithms via a central API,
a tagged union \texttt{ltc\_pka\_key} is used.
Expand Down Expand Up @@ -7122,6 +7123,19 @@ \chapter{The PKA Union}
void pka_key_destroy(ltc_pka_key **key);
\end{verbatim}

\index{pka\_key\_export}
To export the key held by such a union in its standard format the following API function is provided:

\begin{verbatim}
int pka_key_export(unsigned char *out, unsigned long *outlen, int which, const ltc_pka_key *key);
\end{verbatim}

The parameter \textit{which} must be \texttt{PK\_PRIVATE | PK\_STD} to get a PKCS \#8 \textit{PrivateKeyInfo}, or
\texttt{PK\_PUBLIC | PK\_STD} to get an X.509 \textit{SubjectPublicKeyInfo}. Any other value results in \texttt{CRYPT\_INVALID\_ARG}.
An ECC key is written with the OID of its curve, the explicit curve parameters are only used for a curve without OID.
\texttt{CRYPT\_PK\_INVALID\_TYPE} is returned for the keys this function cannot export: public DH keys and RSA keys that are restricted to PSS or OAEP.
If \textit{out} is too small the function returns \texttt{CRYPT\_BUFFER\_OVERFLOW} and stores the required size in \textit{outlen}.

\chapter{Standards Support}
\mysection{ASN.1 Formats}
LibTomCrypt supports a variety of ASN.1 data types encoded with the Distinguished Encoding Rules (DER) suitable for various cryptographic protocols. The data types
Expand Down Expand Up @@ -8104,11 +8118,9 @@ \subsection{scrypt}
\index{PKCS \#8}
\label{pkcs8}

The library has built-in support for PKCS \#8 decoding as specified in \href{https://datatracker.ietf.org/doc/html/rfc5208}{\texttt{RFC 5208}}.

Encoding of private keys into PKCS \#8 is not supported.
The library has built-in support for PKCS \#8 decoding and encoding as specified in \href{https://datatracker.ietf.org/doc/html/rfc5208}{\texttt{RFC 5208}}.

The library supports the following encryption algorithms:
The library supports the following encryption algorithms when decoding:

\begin{table}[H]
\begin{center}
Expand Down Expand Up @@ -8137,6 +8149,60 @@ \subsection{scrypt}
The PKCS \#8 import has no direct API endpoints, but it is available either through Public Key Algorithm-specific
\textit{pkaX\_import\_pkcs8()} functions or the PEM decoding API (c.f. Ch. \ref{pem-files}).

\subsection{Encoding}

An unencrypted PKCS \#8 \textit{PrivateKeyInfo} is created by \textit{pka\_key\_export()} (c.f. Ch. \ref{pka-union}).

\index{pbes2\_encrypt}
To protect it with a password the following API function is provided:

\begin{verbatim}
typedef struct {
const char *cipher;
unsigned long keylen;
const char *prf;
unsigned long iterations;
unsigned long saltlen;
} pbes2_enc_params;

int pbes2_encrypt( unsigned char *out, unsigned long *outlen,
const unsigned char *in, unsigned long inlen,
const unsigned char *pw, unsigned long pwlen,
const pbes2_enc_params *params,
prng_state *prng, int wprng);
\end{verbatim}

This encrypts the \textit{PrivateKeyInfo} of length \textit{inlen} in \textit{in} with the password \textit{pw} and
stores the resulting \textit{EncryptedPrivateKeyInfo} in \textit{out}.
The scheme is always PBES2 with PBKDF2 and a cipher in CBC mode. The salt and the IV are read from the PRNG, so they are different for every call.
The cipher and the hash must be registered.
The buffers \textit{in} and \textit{out} must not overlap.

\textit{params} may be \texttt{NULL}. A field that is \texttt{0} or \texttt{NULL} selects its default:

\begin{table}[H]
\begin{small}
\begin{tabular}{|l|l|l|}
\hline \textbf{Field} & \textbf{Default} & \textbf{Accepted values} \\
\hline \texttt{cipher} & \texttt{"aes"} & \texttt{"aes"}, \texttt{"3des"} \\
\hline \texttt{keylen} & the longest key of the cipher & 16, 24 or 32 bytes for AES, 24 bytes for 3DES \\
\hline \texttt{prf} & \texttt{"sha256"} & the SHA-1, SHA-2 and SHA-3 hashes \\
\hline \texttt{iterations} & \texttt{LTC\_PBES2\_DEFAULT\_ITERATIONS} & 1 to \texttt{LTC\_PBES\_MAX\_ITERATIONS} \\
\hline \texttt{saltlen} & 16 & 8 to 64 bytes \\
\hline
\end{tabular}
\end{small}
\caption{Parameters of \textit{pbes2\_encrypt()}}
\label{pbes2-enc-params}
\end{table}

DES and RC2 are only supported when decoding. An empty password is refused with \texttt{CRYPT\_INVALID\_ARG}.

If \textit{out} is too small the function returns \texttt{CRYPT\_BUFFER\_OVERFLOW} and stores the required size in \textit{outlen}.
Such a call reads nothing from the PRNG and does not run the key derivation.

The PEM encoding API (c.f. Ch. \ref{pem-encode}) combines both steps.


\mysection{Key Derviation Functions}
\subsection{HKDF}
Expand Down Expand Up @@ -8323,6 +8389,7 @@ \subsection{OpenSSH authorized\_keys files}
\subsection{Introduction}
LibTomCrypt supports reading of asymmetric cryptography keys out of
PEM files in multiple formats.
Writing is supported for the PKCS \#8 and the SubjectPublicKeyInfo format (c.f. Ch. \ref{pem-encode}).

The library provides support for these PEM content structures:
\begin{itemize}
Expand Down Expand Up @@ -8500,6 +8567,61 @@ \subsection{PKCS PEM files}
int pem_decode_pkcs(const void *buf, unsigned long len, ltc_pka_key *k, const password_ctx *pw_ctx);
\end{verbatim}

\subsection{Encoding PKCS PEM files}
\label{pem-encode}

\index{pem\_encode\_pkcs\_filehandle}
\index{pem\_encode\_pkcs}
The API functions provided to encode a key held by the \texttt{ltc\_pka\_key} union as PEM file
according to \href{https://datatracker.ietf.org/doc/html/rfc7468}{\texttt{RFC 7468}} are:

\begin{verbatim}
typedef struct {
const unsigned char *pw;
unsigned long pwlen;
const pbes2_enc_params *enc;
unsigned int flags;
} pem_encode_opts;

int pem_encode_pkcs_filehandle(FILE *f, int which, const ltc_pka_key *key,
const pem_encode_opts *opts,
prng_state *prng, int wprng);
int pem_encode_pkcs( unsigned char *out, unsigned long *outlen,
int which, const ltc_pka_key *key,
const pem_encode_opts *opts,
prng_state *prng, int wprng);
\end{verbatim}

The label of the PEM file is not chosen by the caller. It follows from \textit{which} and from the password in \textit{opts}:

\begin{table}[H]
\begin{small}
\begin{tabular}{|l|l|l|l|}
\hline \textbf{which} & \textbf{Password} & \textbf{Identifier} & \textbf{File content} \\
\hline \texttt{PK\_PRIVATE | PK\_STD} & no & \texttt{BEGIN PRIVATE KEY} & PKCS \#8 \textit{PrivateKeyInfo} \\
\hline \texttt{PK\_PRIVATE | PK\_STD} & yes & \texttt{BEGIN ENCRYPTED PRIVATE KEY} & PKCS \#8 \textit{EncryptedPrivateKeyInfo} \\
\hline \texttt{PK\_PUBLIC | PK\_STD} & no & \texttt{BEGIN PUBLIC KEY} & X.509 \textit{SubjectPublicKeyInfo} \\
\hline
\end{tabular}
\end{small}
\caption{PEM headers written by \textit{pem\_encode\_pkcs()}}
\label{written-PEM-headers}
\end{table}

All other combinations return \texttt{CRYPT\_INVALID\_ARG}, including a password for a public key.
The headers \texttt{Proc-Type} and \texttt{DEK-Info} of the older PEM encryption are never written.

\textit{opts} may be \texttt{NULL}, which means an unencrypted key and \texttt{\textbackslash n} as line separator.
The key gets encrypted if \textit{opts->pw} is not \texttt{NULL}. This is done by \textit{pbes2\_encrypt()} with the parameters in \textit{opts->enc},
c.f. Ch. \ref{pkcs8} for the parameters and the limitations. An empty password is refused with \texttt{CRYPT\_INVALID\_ARG}, it never leads to an unencrypted key.
Setting \texttt{LTC\_PEM\_CRLF} in \textit{opts->flags} selects \texttt{\textbackslash r\textbackslash n} as line separator.
The PRNG is only used for an encrypted key.

The supported keys are those of \textit{pka\_key\_export()} (c.f. Ch. \ref{pka-union}). Everything this API writes can be read back with \textit{pem\_decode\_pkcs()}.

The output of \textit{pem\_encode\_pkcs()} is NUL terminated and \textit{outlen} does not count the NUL.
If \textit{out} is too small the function returns \texttt{CRYPT\_BUFFER\_OVERFLOW} and stores the required size, including the NUL, in \textit{outlen}.

\subsection{OpenSSH PEM files}

OpenSSH PEM files can contain private keys of the following types:
Expand Down
12 changes: 12 additions & 0 deletions libtomcrypt_VS2008.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,10 @@
RelativePath="src\misc\pbes\pbes2.c"
>
</File>
<File
RelativePath="src\misc\pbes\pbes2_encrypt.c"
>
</File>
</Filter>
<Filter
Name="pem"
Expand All @@ -1694,6 +1698,10 @@
RelativePath="src\misc\pem\pem.c"
>
</File>
<File
RelativePath="src\misc\pem\pem_encode.c"
>
</File>
<File
RelativePath="src\misc\pem\pem_pkcs.c"
>
Expand Down Expand Up @@ -2333,6 +2341,10 @@
RelativePath="src\pk\asn1\pkcs8\pkcs8_decode_flexi.c"
>
</File>
<File
RelativePath="src\pk\asn1\pkcs8\pkcs8_encode.c"
>
</File>
<File
RelativePath="src\pk\asn1\pkcs8\pkcs8_get.c"
>
Expand Down
10 changes: 5 additions & 5 deletions makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o
src/misc/crypt/crypt_unregister_prng.o src/misc/deprecated.o src/misc/error_to_string.o \
src/misc/hkdf/hkdf.o src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/padding/padding_depad.o \
src/misc/padding/padding_pad.o src/misc/password_free.o src/misc/pbes/pbes.o src/misc/pbes/pbes1.o \
src/misc/pbes/pbes2.o src/misc/pem/pem.o src/misc/pem/pem_pkcs.o src/misc/pem/pem_read.o \
src/misc/pem/pem_ssh.o src/misc/pkcs12/pkcs12_kdf.o src/misc/pkcs12/pkcs12_utf8_to_utf16.o \
src/misc/pkcs5/pkcs_5_1.o src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o \
src/misc/scrypt/scrypt.o src/misc/ssh/ssh_decode_sequence_multi.o \
src/misc/pbes/pbes2.o src/misc/pbes/pbes2_encrypt.o src/misc/pem/pem.o src/misc/pem/pem_encode.o \
src/misc/pem/pem_pkcs.o src/misc/pem/pem_read.o src/misc/pem/pem_ssh.o src/misc/pkcs12/pkcs12_kdf.o \
src/misc/pkcs12/pkcs12_utf8_to_utf16.o src/misc/pkcs5/pkcs_5_1.o src/misc/pkcs5/pkcs_5_2.o \
src/misc/pkcs5/pkcs_5_test.o src/misc/scrypt/scrypt.o src/misc/ssh/ssh_decode_sequence_multi.o \
src/misc/ssh/ssh_encode_sequence_multi.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \
src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \
src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \
Expand Down Expand Up @@ -178,7 +178,7 @@ src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_
src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
src/pk/asn1/oid/pk_get.o src/pk/asn1/oid/pk_oid_cmp.o src/pk/asn1/oid/pk_oid_str.o \
src/pk/asn1/pkcs8/pkcs8_decode_flexi.o src/pk/asn1/pkcs8/pkcs8_get.o \
src/pk/asn1/pkcs8/pkcs8_decode_flexi.o src/pk/asn1/pkcs8/pkcs8_encode.o src/pk/asn1/pkcs8/pkcs8_get.o \
src/pk/asn1/x509/x509_decode_public_key_from_certificate.o src/pk/asn1/x509/x509_decode_spki.o \
src/pk/asn1/x509/x509_decode_subject_public_key_info.o \
src/pk/asn1/x509/x509_encode_subject_public_key_info.o src/pk/asn1/x509/x509_get_pka.o \
Expand Down
10 changes: 5 additions & 5 deletions makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ src/misc/crypt/crypt_unregister_cipher.obj src/misc/crypt/crypt_unregister_hash.
src/misc/crypt/crypt_unregister_prng.obj src/misc/deprecated.obj src/misc/error_to_string.obj \
src/misc/hkdf/hkdf.obj src/misc/hkdf/hkdf_test.obj src/misc/mem_neq.obj src/misc/padding/padding_depad.obj \
src/misc/padding/padding_pad.obj src/misc/password_free.obj src/misc/pbes/pbes.obj src/misc/pbes/pbes1.obj \
src/misc/pbes/pbes2.obj src/misc/pem/pem.obj src/misc/pem/pem_pkcs.obj src/misc/pem/pem_read.obj \
src/misc/pem/pem_ssh.obj src/misc/pkcs12/pkcs12_kdf.obj src/misc/pkcs12/pkcs12_utf8_to_utf16.obj \
src/misc/pkcs5/pkcs_5_1.obj src/misc/pkcs5/pkcs_5_2.obj src/misc/pkcs5/pkcs_5_test.obj \
src/misc/scrypt/scrypt.obj src/misc/ssh/ssh_decode_sequence_multi.obj \
src/misc/pbes/pbes2.obj src/misc/pbes/pbes2_encrypt.obj src/misc/pem/pem.obj src/misc/pem/pem_encode.obj \
src/misc/pem/pem_pkcs.obj src/misc/pem/pem_read.obj src/misc/pem/pem_ssh.obj src/misc/pkcs12/pkcs12_kdf.obj \
src/misc/pkcs12/pkcs12_utf8_to_utf16.obj src/misc/pkcs5/pkcs_5_1.obj src/misc/pkcs5/pkcs_5_2.obj \
src/misc/pkcs5/pkcs_5_test.obj src/misc/scrypt/scrypt.obj src/misc/ssh/ssh_decode_sequence_multi.obj \
src/misc/ssh/ssh_encode_sequence_multi.obj src/misc/zeromem.obj src/modes/cbc/cbc_decrypt.obj \
src/modes/cbc/cbc_done.obj src/modes/cbc/cbc_encrypt.obj src/modes/cbc/cbc_getiv.obj \
src/modes/cbc/cbc_setiv.obj src/modes/cbc/cbc_start.obj src/modes/cfb/cfb_decrypt.obj \
Expand Down Expand Up @@ -171,7 +171,7 @@ src/pk/asn1/der/utctime/der_decode_utctime.obj src/pk/asn1/der/utctime/der_encod
src/pk/asn1/der/utctime/der_length_utctime.obj src/pk/asn1/der/utf8/der_decode_utf8_string.obj \
src/pk/asn1/der/utf8/der_encode_utf8_string.obj src/pk/asn1/der/utf8/der_length_utf8_string.obj \
src/pk/asn1/oid/pk_get.obj src/pk/asn1/oid/pk_oid_cmp.obj src/pk/asn1/oid/pk_oid_str.obj \
src/pk/asn1/pkcs8/pkcs8_decode_flexi.obj src/pk/asn1/pkcs8/pkcs8_get.obj \
src/pk/asn1/pkcs8/pkcs8_decode_flexi.obj src/pk/asn1/pkcs8/pkcs8_encode.obj src/pk/asn1/pkcs8/pkcs8_get.obj \
src/pk/asn1/x509/x509_decode_public_key_from_certificate.obj src/pk/asn1/x509/x509_decode_spki.obj \
src/pk/asn1/x509/x509_decode_subject_public_key_info.obj \
src/pk/asn1/x509/x509_encode_subject_public_key_info.obj src/pk/asn1/x509/x509_get_pka.obj \
Expand Down
10 changes: 5 additions & 5 deletions makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o
src/misc/crypt/crypt_unregister_prng.o src/misc/deprecated.o src/misc/error_to_string.o \
src/misc/hkdf/hkdf.o src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/padding/padding_depad.o \
src/misc/padding/padding_pad.o src/misc/password_free.o src/misc/pbes/pbes.o src/misc/pbes/pbes1.o \
src/misc/pbes/pbes2.o src/misc/pem/pem.o src/misc/pem/pem_pkcs.o src/misc/pem/pem_read.o \
src/misc/pem/pem_ssh.o src/misc/pkcs12/pkcs12_kdf.o src/misc/pkcs12/pkcs12_utf8_to_utf16.o \
src/misc/pkcs5/pkcs_5_1.o src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o \
src/misc/scrypt/scrypt.o src/misc/ssh/ssh_decode_sequence_multi.o \
src/misc/pbes/pbes2.o src/misc/pbes/pbes2_encrypt.o src/misc/pem/pem.o src/misc/pem/pem_encode.o \
src/misc/pem/pem_pkcs.o src/misc/pem/pem_read.o src/misc/pem/pem_ssh.o src/misc/pkcs12/pkcs12_kdf.o \
src/misc/pkcs12/pkcs12_utf8_to_utf16.o src/misc/pkcs5/pkcs_5_1.o src/misc/pkcs5/pkcs_5_2.o \
src/misc/pkcs5/pkcs_5_test.o src/misc/scrypt/scrypt.o src/misc/ssh/ssh_decode_sequence_multi.o \
src/misc/ssh/ssh_encode_sequence_multi.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \
src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \
src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \
Expand Down Expand Up @@ -192,7 +192,7 @@ src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_
src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
src/pk/asn1/oid/pk_get.o src/pk/asn1/oid/pk_oid_cmp.o src/pk/asn1/oid/pk_oid_str.o \
src/pk/asn1/pkcs8/pkcs8_decode_flexi.o src/pk/asn1/pkcs8/pkcs8_get.o \
src/pk/asn1/pkcs8/pkcs8_decode_flexi.o src/pk/asn1/pkcs8/pkcs8_encode.o src/pk/asn1/pkcs8/pkcs8_get.o \
src/pk/asn1/x509/x509_decode_public_key_from_certificate.o src/pk/asn1/x509/x509_decode_spki.o \
src/pk/asn1/x509/x509_decode_subject_public_key_info.o \
src/pk/asn1/x509/x509_encode_subject_public_key_info.o src/pk/asn1/x509/x509_get_pka.o \
Expand Down
10 changes: 5 additions & 5 deletions makefile_include.mk
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o
src/misc/crypt/crypt_unregister_prng.o src/misc/deprecated.o src/misc/error_to_string.o \
src/misc/hkdf/hkdf.o src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/padding/padding_depad.o \
src/misc/padding/padding_pad.o src/misc/password_free.o src/misc/pbes/pbes.o src/misc/pbes/pbes1.o \
src/misc/pbes/pbes2.o src/misc/pem/pem.o src/misc/pem/pem_pkcs.o src/misc/pem/pem_read.o \
src/misc/pem/pem_ssh.o src/misc/pkcs12/pkcs12_kdf.o src/misc/pkcs12/pkcs12_utf8_to_utf16.o \
src/misc/pkcs5/pkcs_5_1.o src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o \
src/misc/scrypt/scrypt.o src/misc/ssh/ssh_decode_sequence_multi.o \
src/misc/pbes/pbes2.o src/misc/pbes/pbes2_encrypt.o src/misc/pem/pem.o src/misc/pem/pem_encode.o \
src/misc/pem/pem_pkcs.o src/misc/pem/pem_read.o src/misc/pem/pem_ssh.o src/misc/pkcs12/pkcs12_kdf.o \
src/misc/pkcs12/pkcs12_utf8_to_utf16.o src/misc/pkcs5/pkcs_5_1.o src/misc/pkcs5/pkcs_5_2.o \
src/misc/pkcs5/pkcs_5_test.o src/misc/scrypt/scrypt.o src/misc/ssh/ssh_decode_sequence_multi.o \
src/misc/ssh/ssh_encode_sequence_multi.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \
src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \
src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \
Expand Down Expand Up @@ -363,7 +363,7 @@ src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_
src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
src/pk/asn1/oid/pk_get.o src/pk/asn1/oid/pk_oid_cmp.o src/pk/asn1/oid/pk_oid_str.o \
src/pk/asn1/pkcs8/pkcs8_decode_flexi.o src/pk/asn1/pkcs8/pkcs8_get.o \
src/pk/asn1/pkcs8/pkcs8_decode_flexi.o src/pk/asn1/pkcs8/pkcs8_encode.o src/pk/asn1/pkcs8/pkcs8_get.o \
src/pk/asn1/x509/x509_decode_public_key_from_certificate.o src/pk/asn1/x509/x509_decode_spki.o \
src/pk/asn1/x509/x509_decode_subject_public_key_info.o \
src/pk/asn1/x509/x509_encode_subject_public_key_info.o src/pk/asn1/x509/x509_get_pka.o \
Expand Down
3 changes: 3 additions & 0 deletions sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ src/misc/password_free.c
src/misc/pbes/pbes.c
src/misc/pbes/pbes1.c
src/misc/pbes/pbes2.c
src/misc/pbes/pbes2_encrypt.c
src/misc/pem/pem.c
src/misc/pem/pem_encode.c
src/misc/pem/pem_pkcs.c
src/misc/pem/pem_read.c
src/misc/pem/pem_ssh.c
Expand Down Expand Up @@ -384,6 +386,7 @@ src/pk/asn1/oid/pk_get.c
src/pk/asn1/oid/pk_oid_cmp.c
src/pk/asn1/oid/pk_oid_str.c
src/pk/asn1/pkcs8/pkcs8_decode_flexi.c
src/pk/asn1/pkcs8/pkcs8_encode.c
src/pk/asn1/pkcs8/pkcs8_get.c
src/pk/asn1/x509/x509_decode_public_key_from_certificate.c
src/pk/asn1/x509/x509_decode_spki.c
Expand Down
4 changes: 4 additions & 0 deletions src/headers/tomcrypt_custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,10 @@
/* Max KDF iterations accepted when importing an encrypted PKCS#8 object (PBES1/PBES2); attacker-controlled. */
#define LTC_PBES_MAX_ITERATIONS 20000000
#endif
#ifndef LTC_PBES2_DEFAULT_ITERATIONS
/* PBKDF2 iterations pbes2_encrypt() uses when the caller sets none. */
#define LTC_PBES2_DEFAULT_ITERATIONS 100000
#endif
#endif

#if defined(LTC_CLEAN_STACK)
Expand Down
Loading
Loading