Skip to content

Commit 24fc92b

Browse files
authored
Merge pull request #668 from levitte/pem-doc-fixes
Fix PEM documentation
2 parents e0d90c5 + 2026e28 commit 24fc92b

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

demos/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Options
33
#-----------------------------------------------------------------------------
44
option(BUILD_USEFUL_DEMOS "Build useful demos (hashsum)" FALSE)
5-
option(BUILD_USABLE_DEMOS "Build usable demos (ltcrypt sizes constants)" FALSE)
5+
option(BUILD_USABLE_DEMOS "Build usable demos (ltcrypt sizes constants pem-info)" FALSE)
66

77
#-----------------------------------------------------------------------------
88
# Useful demos
@@ -38,7 +38,7 @@ endif()
3838

3939
if(BUILD_USABLE_DEMOS)
4040

41-
list(APPEND ALL_DEMOS_TARGETS ltcrypt sizes constants)
41+
list(APPEND ALL_DEMOS_TARGETS ltcrypt sizes constants pem-info)
4242

4343
# ltcrypt
4444
add_executable(ltcrypt
@@ -67,6 +67,15 @@ if(BUILD_USABLE_DEMOS)
6767
${PROJECT_NAME}
6868
)
6969

70+
# pem-info
71+
add_executable(pem-info
72+
${CMAKE_CURRENT_SOURCE_DIR}/pem-info.c
73+
)
74+
75+
target_link_libraries(pem-info PRIVATE
76+
${PROJECT_NAME}
77+
)
78+
7079
endif()
7180

7281
#-----------------------------------------------------------------------------

demos/pem-info.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ static const struct {
4949
{ cm_none, "none", },
5050
{ cm_cbc, "CBC", },
5151
{ cm_cfb, "CFB", },
52+
{ cm_cfb1, "CFB1", },
53+
{ cm_cfb8, "CFB8", },
5254
{ cm_ctr, "CTR", },
5355
{ cm_ofb, "OFB", },
5456
{ cm_stream, "STREAM", },
@@ -58,7 +60,7 @@ static const struct {
5860
static const char *s_map_mode(enum cipher_mode mode)
5961
{
6062
size_t n;
61-
mode &= cm_modes;
63+
mode &= cm_modes | cm_1bit | cm_8bit;
6264
for (n = 0; n < sizeof(cipher_mode_map)/sizeof(cipher_mode_map[0]); ++n) {
6365
if (cipher_mode_map[n].mode == mode)
6466
return cipher_mode_map[n].name;

doc/crypt.tex

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7579,11 +7579,19 @@ \subsection{Introduction}
75797579
LibTomCrypt supports reading of asymmetric cryptography keys out of
75807580
PEM files in multiple formats.
75817581

7582-
The library provides support for:
7582+
The library provides support for these PEM content structures:
75837583
\begin{itemize}
7584-
\item OpenSSH - encrypted and plain files (if SSH support is enabled).
7585-
\item PEM - encrypted and plain files.
7586-
\item PKCS \#8 - encrypted and plain files.
7584+
\item Private keys:
7585+
\begin{itemize}
7586+
\item OpenSSH - encrypted and plain files (if SSH support is enabled).
7587+
\item PKCS \#8 - encrypted and plain files.
7588+
\item Algorithm specific - encrypted and plain files.
7589+
\end{itemize}
7590+
\item Public keys:
7591+
\begin{itemize}
7592+
\item X.509 certificates
7593+
\item SubjectPublicKeyInfo (defined by X.509)
7594+
\end{itemize}
75877595
\end{itemize}
75887596

75897597
There is no support for PKCS \#12 containers/PFX files implemented.
@@ -7616,20 +7624,22 @@ \subsection{PKCS PEM files}
76167624
The identifiers in the PEM headers recognized are as follows:
76177625

76187626
\begin{table}[H]
7627+
\begin{minipage}{\textwidth}
76197628
\begin{small}
76207629
\begin{tabular}{|l|l|l|l|l|}
76217630
\hline \textbf{Identifier} & \textbf{Key type} & \textbf{File content} & \textbf{Standard} & \textbf{Algorithm} \\
76227631
\hline \texttt{BEGIN CERTIFICATE} & Public & Plain & \texttt{X.509} & DH, DSA, ECC, Ed25519, RSA, X25519 \\
7623-
\hline \texttt{BEGIN DSA PRIVATE KEY} & Private & Maybe encrypted & \texttt{PKCS \#1} & DSA \\
7632+
\hline \texttt{BEGIN DSA PRIVATE KEY} & Private & Maybe encrypted & \texttt{OpenSSL\footnote{There are two de-facto standard for DSA private key structures, LibTomCrypt implements OpenSSL's}} & DSA \\
76247633
\hline \texttt{BEGIN EC PRIVATE KEY} & Private & Maybe encrypted & \texttt{RFC 5915} & ECC \\
76257634
\hline \texttt{BEGIN ENCRYPTED PRIVATE KEY} & Private & Encrypted & \texttt{PKCS \#8} & DH, DSA, ECC, Ed25519, RSA, X25519 \\
76267635
\hline \texttt{BEGIN PRIVATE KEY} & Private & Plain & \texttt{PKCS \#8} & DH, DSA, ECC, Ed25519, RSA, X25519 \\
7627-
\hline \texttt{BEGIN PUBLIC KEY} & Public & Plain & \texttt{PKCS \#8} & DH, DSA, ECC, Ed25519, RSA, X25519 \\
7636+
\hline \texttt{BEGIN PUBLIC KEY} & Public & Plain & \texttt{X.509\footnote{Specifically, SubjectPublicKeyInfo}} & DH, DSA, ECC, Ed25519, RSA, X25519 \\
76287637
\hline \texttt{BEGIN RSA PRIVATE KEY} & Private & Maybe encrypted & \texttt{PKCS \#1} & RSA \\
76297638
\hline \texttt{BEGIN RSA PUBLIC KEY} & Public & Plain & \texttt{PKCS \#1} & RSA \\
76307639
\hline
76317640
\end{tabular}
76327641
\end{small}
7642+
\end{minipage}
76337643
\caption{List of supported PEM headers}
76347644
\label{supported-PEM-headers}
76357645
\end{table}
@@ -7646,12 +7656,12 @@ \subsection{PKCS PEM files}
76467656
\hline \texttt{AES-128-CFB} & AES & 128 & CFB \\
76477657
\hline \texttt{AES-192-CFB} & AES & 192 & CFB \\
76487658
\hline \texttt{AES-256-CFB} & AES & 256 & CFB \\
7649-
\hline \texttt{AES-128-CFB1} & AES & 128 & CFB \\
7650-
\hline \texttt{AES-192-CFB1} & AES & 192 & CFB \\
7651-
\hline \texttt{AES-256-CFB1} & AES & 256 & CFB \\
7652-
\hline \texttt{AES-128-CFB8} & AES & 128 & CFB \\
7653-
\hline \texttt{AES-192-CFB8} & AES & 192 & CFB \\
7654-
\hline \texttt{AES-256-CFB8} & AES & 256 & CFB \\
7659+
\hline \texttt{AES-128-CFB1} & AES & 128 & CFB1 \\
7660+
\hline \texttt{AES-192-CFB1} & AES & 192 & CFB1 \\
7661+
\hline \texttt{AES-256-CFB1} & AES & 256 & CFB1 \\
7662+
\hline \texttt{AES-128-CFB8} & AES & 128 & CFB8 \\
7663+
\hline \texttt{AES-192-CFB8} & AES & 192 & CFB8 \\
7664+
\hline \texttt{AES-256-CFB8} & AES & 256 & CFB8 \\
76557665
\hline \texttt{AES-128-CTR} & AES & 128 & CTR \\
76567666
\hline \texttt{AES-192-CTR} & AES & 192 & CTR \\
76577667
\hline \texttt{AES-256-CTR} & AES & 256 & CTR \\
@@ -7667,12 +7677,12 @@ \subsection{PKCS PEM files}
76677677
\hline \texttt{CAMELLIA-128-CFB} & Camellia & 128 & CFB \\
76687678
\hline \texttt{CAMELLIA-192-CFB} & Camellia & 192 & CFB \\
76697679
\hline \texttt{CAMELLIA-256-CFB} & Camellia & 256 & CFB \\
7670-
\hline \texttt{CAMELLIA-128-CFB1} & Camellia & 128 & CFB \\
7671-
\hline \texttt{CAMELLIA-192-CFB1} & Camellia & 192 & CFB \\
7672-
\hline \texttt{CAMELLIA-256-CFB1} & Camellia & 256 & CFB \\
7673-
\hline \texttt{CAMELLIA-128-CFB8} & Camellia & 128 & CFB \\
7674-
\hline \texttt{CAMELLIA-192-CFB8} & Camellia & 192 & CFB \\
7675-
\hline \texttt{CAMELLIA-256-CFB8} & Camellia & 256 & CFB \\
7680+
\hline \texttt{CAMELLIA-128-CFB1} & Camellia & 128 & CFB1 \\
7681+
\hline \texttt{CAMELLIA-192-CFB1} & Camellia & 192 & CFB1 \\
7682+
\hline \texttt{CAMELLIA-256-CFB1} & Camellia & 256 & CFB1 \\
7683+
\hline \texttt{CAMELLIA-128-CFB8} & Camellia & 128 & CFB8 \\
7684+
\hline \texttt{CAMELLIA-192-CFB8} & Camellia & 192 & CFB8 \\
7685+
\hline \texttt{CAMELLIA-256-CFB8} & Camellia & 256 & CFB8 \\
76767686
\hline \texttt{CAMELLIA-128-CTR} & Camellia & 128 & CTR \\
76777687
\hline \texttt{CAMELLIA-192-CTR} & Camellia & 192 & CTR \\
76787688
\hline \texttt{CAMELLIA-256-CTR} & Camellia & 256 & CTR \\
@@ -7688,13 +7698,13 @@ \subsection{PKCS PEM files}
76887698
\hline \texttt{DES-EDE-OFB} & 3DES (EDE) & 128 & OFB \\
76897699
\hline \texttt{DES-EDE3-CBC} & 3DES (EDE) & 192 & CBC \\
76907700
\hline \texttt{DES-EDE3-CFB} & 3DES (EDE) & 192 & CFB \\
7691-
\hline \texttt{DES-EDE3-CFB1} & 3DES (EDE) & 192 & CFB \\
7692-
\hline \texttt{DES-EDE3-CFB8} & 3DES (EDE) & 192 & CFB \\
7701+
\hline \texttt{DES-EDE3-CFB1} & 3DES (EDE) & 192 & CFB1 \\
7702+
\hline \texttt{DES-EDE3-CFB8} & 3DES (EDE) & 192 & CFB8 \\
76937703
\hline \texttt{DES-EDE3-OFB} & 3DES (EDE) & 192 & OFB \\
76947704
\hline \texttt{DES-CBC} & DES & 64 & CBC \\
76957705
\hline \texttt{DES-CFB} & DES & 64 & CFB \\
7696-
\hline \texttt{DES-CFB1} & DES & 64 & CFB \\
7697-
\hline \texttt{DES-CFB8} & DES & 64 & CFB \\
7706+
\hline \texttt{DES-CFB1} & DES & 64 & CFB1 \\
7707+
\hline \texttt{DES-CFB8} & DES & 64 & CFB8 \\
76987708
\hline \texttt{DES-OFB} & DES & 64 & OFB \\
76997709
\hline \texttt{DESX-CBC} & DES-X & 192 & CBC \\
77007710
\hline \texttt{IDEA-CBC} & IDEA & 128 & CBC \\

0 commit comments

Comments
 (0)