@@ -5117,7 +5117,7 @@ \chapter{Elliptic Curve Cryptography - $GF(p)$}
51175117analogy for digital signatures (also known as \textit {ECDSA }).
51185118
51195119\mysection {Supported Curves}
5120- \label {supported-curvers }
5120+ \label {supported-curves }
51215121
51225122The following table \ref {fig:builtincurves } shows all built--in curves supported by the library. On top of that one can also use a custom curve
51235123defined by own parameters (the only limitation is that the curve must be based on equation \ref {ecc-gf-p-equation }).
@@ -7442,7 +7442,7 @@ \subsection{De- and Encoding with Multiple Argument Lists}
74427442\mysection {PEM Files}
74437443\label {pem-files }
74447444\subsection {Introduction }
7445- LibTomCrypt supports reading of asymmetric cryptography private keys out of
7445+ LibTomCrypt supports reading of asymmetric cryptography keys out of
74467446PEM files in multiple formats.
74477447
74487448The library provides support for:
@@ -7499,6 +7499,17 @@ \subsection{The PKA Union}
74997499void pka_key_free(ltc_pka_key *key);
75007500\end {verbatim }
75017501
7502+ \subsection {Generic PEM API }
7503+
7504+ The generic API functions provided to decode a PEM file into the \texttt {ltc\_ pka\_ key } union are:
7505+
7506+ \begin {verbatim }
7507+ int pem_decode_filehandle(FILE *f, ltc_pka_key *k, const password_ctx *pw_ctx);
7508+ int pem_decode(const void *buf, unsigned long len, ltc_pka_key *k, const password_ctx *pw_ctx);
7509+ \end {verbatim }
7510+
7511+ Additional to that, there exist specific API functions for the two supported classes of PEM files.
7512+
75027513\subsection {PKCS PEM files }
75037514
75047515The library supports the following types of PKCS PEM files:
@@ -7514,42 +7525,83 @@ \subsection{PKCS PEM files}
75147525The identifiers in the PEM headers recognized are as follows:
75157526
75167527\begin {table }[H]
7517- \begin {center }
75187528\begin {small }
7519- \begin {tabular }{|l|l|l|l|}
7520- \hline \textbf {Identifier } & \textbf {Encrypted } & \textbf {Standard } & \textbf {Type } \\
7521- \hline \texttt {BEGIN ENCRYPTED PRIVATE KEY } & Yes & \texttt {PKCS \# 8 } & DSA, ECC, Ed25519, RSA, X25519 \\
7522- \hline \texttt {BEGIN PRIVATE KEY } & No & \texttt {PKCS \# 8 } & DSA, ECC, Ed25519, RSA, X25519 \\
7523- \hline \texttt {BEGIN DSA PRIVATE KEY } & Maybe & \texttt {PKCS \# 1 } & DSA \\
7524- \hline \texttt {BEGIN EC PRIVATE KEY } & Maybe & \texttt {RFC 5915 } & ECC \\
7525- \hline \texttt {BEGIN RSA PRIVATE KEY } & Maybe & \texttt {PKCS \# 1 } & RSA \\
7529+ \begin {tabular }{|l|l|l|l|l|}
7530+ \hline \textbf {Identifier } & \textbf {Key type } & \textbf {File content } & \textbf {Standard } & \textbf {Algorithm } \\
7531+ \hline \texttt {BEGIN CERTIFICATE } & Public & Plain & \texttt {X.509 } & DH, DSA, ECC, Ed25519, RSA, X25519 \\
7532+ \hline \texttt {BEGIN DSA PRIVATE KEY } & Private & Maybe encrypted & \texttt {PKCS \# 1 } & DSA \\
7533+ \hline \texttt {BEGIN EC PRIVATE KEY } & Private & Maybe encrypted & \texttt {RFC 5915 } & ECC \\
7534+ \hline \texttt {BEGIN ENCRYPTED PRIVATE KEY } & Private & Encrypted & \texttt {PKCS \# 8 } & DH, DSA, ECC, Ed25519, RSA, X25519 \\
7535+ \hline \texttt {BEGIN PRIVATE KEY } & Private & Plain & \texttt {PKCS \# 8 } & DH, DSA, ECC, Ed25519, RSA, X25519 \\
7536+ \hline \texttt {BEGIN PUBLIC KEY } & Public & Plain & \texttt {PKCS \# 8 } & DH, DSA, ECC, Ed25519, RSA, X25519 \\
7537+ \hline \texttt {BEGIN RSA PRIVATE KEY } & Private & Maybe encrypted & \texttt {PKCS \# 1 } & RSA \\
7538+ \hline \texttt {BEGIN RSA PUBLIC KEY } & Public & Plain & \texttt {PKCS \# 1 } & RSA \\
75267539\hline
75277540\end {tabular }
75287541\end {small }
7529- \end {center }
7530- \caption {List of supported PKCS private key types}
7531- \label {supported-pkcs-private-key-types }
7542+ \caption {List of supported PEM headers}
7543+ \label {supported-PEM-headers }
75327544\end {table }
75337545
75347546When dealing with PEM formatted private keys the following encryption algorithms are supported:
75357547
75367548\begin {table }[H]
7537- \begin {center }
75387549\begin {small }
75397550\begin {tabular }{|l|l|l|l|}
75407551\hline \textbf {Identifier } & \textbf {Cipher } & \textbf {Key size in bits } & \textbf {Mode } \\
75417552\hline \texttt {AES-128-CBC } & AES & 128 & CBC \\
75427553\hline \texttt {AES-192-CBC } & AES & 192 & CBC \\
75437554\hline \texttt {AES-256-CBC } & AES & 256 & CBC \\
7555+ \hline \texttt {AES-128-CFB } & AES & 128 & CFB \\
7556+ \hline \texttt {AES-192-CFB } & AES & 192 & CFB \\
7557+ \hline \texttt {AES-256-CFB } & AES & 256 & CFB \\
7558+ \hline \texttt {AES-128-CTR } & AES & 128 & CTR \\
7559+ \hline \texttt {AES-192-CTR } & AES & 192 & CTR \\
7560+ \hline \texttt {AES-256-CTR } & AES & 256 & CTR \\
7561+ \hline \texttt {AES-128-OFB } & AES & 128 & OFB \\
7562+ \hline \texttt {AES-192-OFB } & AES & 192 & OFB \\
7563+ \hline \texttt {AES-256-OFB } & AES & 256 & OFB \\
7564+ \hline \texttt {BF-CBC } & Blowfish & 128 & CBC \\
7565+ \hline \texttt {BF-CFB } & Blowfish & 128 & CFB \\
7566+ \hline \texttt {BF-OFB } & Blowfish & 128 & OFB \\
75447567\hline \texttt {CAMELLIA-128-CBC } & Camellia & 128 & CBC \\
75457568\hline \texttt {CAMELLIA-192-CBC } & Camellia & 192 & CBC \\
75467569\hline \texttt {CAMELLIA-256-CBC } & Camellia & 256 & CBC \\
7570+ \hline \texttt {CAMELLIA-128-CFB } & Camellia & 128 & CFB \\
7571+ \hline \texttt {CAMELLIA-192-CFB } & Camellia & 192 & CFB \\
7572+ \hline \texttt {CAMELLIA-256-CFB } & Camellia & 256 & CFB \\
7573+ \hline \texttt {CAMELLIA-128-CTR } & Camellia & 128 & CTR \\
7574+ \hline \texttt {CAMELLIA-192-CTR } & Camellia & 192 & CTR \\
7575+ \hline \texttt {CAMELLIA-256-CTR } & Camellia & 256 & CTR \\
7576+ \hline \texttt {CAMELLIA-128-OFB } & Camellia & 128 & OFB \\
7577+ \hline \texttt {CAMELLIA-192-OFB } & Camellia & 192 & OFB \\
7578+ \hline \texttt {CAMELLIA-256-OFB } & Camellia & 256 & OFB \\
7579+ \hline \texttt {CAST5-CBC } & CAST5 & 128 & CBC \\
7580+ \hline \texttt {CAST5-CFB } & CAST5 & 128 & CFB \\
7581+ \hline \texttt {CAST5-OFB } & CAST5 & 128 & OFB \\
75477582\hline \texttt {DES-EDE3-CBC } & 3DES (EDE) & 192 & CBC \\
7548- \hline \texttt {DES-CBC } & DES & 64 & CBC \\
7583+ \hline \texttt {DES-EDE3-CFB } & 3DES (EDE) & 192 & CFB \\
7584+ \hline \texttt {DES-EDE3-OFB } & 3DES (EDE) & 192 & OFB \\
7585+ \hline \texttt {DES-CBC } & DES & 64 & CBC \\
7586+ \hline \texttt {DES-CFB } & DES & 64 & CFB \\
7587+ \hline \texttt {DES-OFB } & DES & 64 & OFB \\
7588+ \hline \texttt {IDEA-CBC } & IDEA & 128 & CBC \\
7589+ \hline \texttt {IDEA-CFB } & IDEA & 128 & CFB \\
7590+ \hline \texttt {IDEA-OFB } & IDEA & 128 & OFB \\
7591+ \hline \texttt {RC5-CBC } & RC5 & 128 & CBC \\
7592+ \hline \texttt {RC5-CFB } & RC5 & 128 & CFB \\
7593+ \hline \texttt {RC5-OFB } & RC5 & 128 & OFB \\
7594+ \hline \texttt {RC2-40-CBC } & RC2 & 40 & CBC \\
7595+ \hline \texttt {RC2-64-CBC } & RC2 & 64 & CBC \\
7596+ \hline \texttt {RC2-CBC } & RC2 & 128 & CBC \\
7597+ \hline \texttt {RC2-CFB } & RC2 & 128 & CFB \\
7598+ \hline \texttt {RC2-OFB } & RC2 & 128 & OFB \\
7599+ \hline \texttt {SEED-CBC } & SEED & 128 & CBC \\
7600+ \hline \texttt {SEED-CFB } & SEED & 128 & CFB \\
7601+ \hline \texttt {SEED-OFB } & SEED & 128 & OFB \\
75497602\hline
75507603\end {tabular }
75517604\end {small }
7552- \end {center }
75537605\caption {List of supported PEM DEK algorithms}
75547606\label {supported-pem-dek-algorithms }
75557607\end {table }
@@ -7566,27 +7618,61 @@ \subsection{OpenSSH PEM files}
75667618OpenSSH PEM files can contain private keys of the following types:
75677619
75687620\begin {table }[H]
7569- \begin {center }
75707621\begin {small }
75717622\begin {tabular }{|l|l|}
75727623\hline \textbf {Identifier } & \textbf {Type } \\
75737624\hline \texttt {ecdsa-sha2-* } & ECC keys \\
7625+ \hline \texttt {ssh-dss } & DSA \\
75747626\hline \texttt {ssh-ed25519 } & Curve25519 \\
75757627\hline \texttt {ssh-rsa } & RSA \\
75767628\hline
75777629\end {tabular }
75787630\end {small }
7579- \end {center }
75807631\caption {List of supported OpenSSH private key types}
75817632\label {supported-openssh-private-key-types }
75827633\end {table }
75837634
75847635C.f. \href {https://datatracker.ietf.org/doc/html/rfc5656}{\texttt {RFC 5656 }} for details on ECC keys
75857636in OpenSSH. LibTomCrypt should be able to handle all the ECC curves supported by the library,
7586- c.f. Ch. \ref {supported-curvers } for details.
7637+ c.f. Ch. \ref {supported-curves } for details.
7638+
7639+ When dealing with SSH formatted private keys the following encryption algorithms are supported:
75877640
7588- OpenSSH PEM files can either not be encrypted, or the encryption is done via \texttt {aes256-cbc }
7589- and key derivation via \texttt {bcrypt }, c.f. Ch. \ref {bcrypt }.
7641+ \begin {table }[H]
7642+ \begin {small }
7643+ \begin {tabular }{|l|l|l|l|}
7644+ \hline \textbf {Identifier } & \textbf {Cipher } & \textbf {Key size in bits } & \textbf {Mode } \\
7645+ \hline \texttt {none } & none & 0 & none \\
7646+ \hline \texttt {aes128-cbc } & AES & 128 & CBC \\
7647+ \hline \texttt {aes128-ctr } & AES & 128 & CTR \\
7648+ \hline \texttt {aes192-cbc } & AES & 192 & CBC \\
7649+ \hline \texttt {aes192-ctr } & AES & 192 & CTR \\
7650+ \hline \texttt {aes256-cbc } & AES & 256 & CBC \\
7651+ \hline \texttt {aes256-ctr } & AES & 256 & CTR \\
7652+ \hline \texttt {blowfish128-cbc } & Blowfish & 128 & CBC \\
7653+ \hline \texttt {blowfish128-ctr } & Blowfish & 128 & CTR \\
7654+ \hline \texttt {des-cbc } & DES & 64 & CBC \\
7655+ \hline \texttt {3des-cbc } & 3DES (EDE) & 192 & CBC \\
7656+ \hline \texttt {3des-ctr } & 3DES (EDE) & 192 & CTR \\
7657+ \hline \texttt {serpent128-cbc } & Serpent & 128 & CBC \\
7658+ \hline \texttt {serpent128-ctr } & Serpent & 128 & CTR \\
7659+ \hline \texttt {serpent192-cbc } & Serpent & 192 & CBC \\
7660+ \hline \texttt {serpent192-ctr } & Serpent & 192 & CTR \\
7661+ \hline \texttt {serpent256-cbc } & Serpent & 256 & CBC \\
7662+ \hline \texttt {serpent256-ctr } & Serpent & 256 & CTR \\
7663+ \hline \texttt {twofish128-cbc } & Twofish & 128 & CBC \\
7664+ \hline \texttt {twofish128-ctr } & Twofish & 128 & CTR \\
7665+ \hline \texttt {twofish192-cbc } & Twofish & 192 & CBC \\
7666+ \hline \texttt {twofish192-ctr } & Twofish & 192 & CTR \\
7667+ \hline \texttt {twofish-cbc } & Twofish & 256 & CBC \\
7668+ \hline \texttt {twofish256-cbc } & Twofish & 256 & CBC \\
7669+ \hline \texttt {twofish256-ctr } & Twofish & 256 & CTR \\
7670+ \hline
7671+ \end {tabular }
7672+ \end {small }
7673+ \caption {List of supported SSH Encryption algorithms}
7674+ \label {supported-ssh-encryption-algorithms }
7675+ \end {table }
75907676
75917677The API functions provided to decode an OpenSSH PEM file into the \texttt {ltc\_ pka\_ key } union are:
75927678
0 commit comments