Skip to contentSkip to conversation

tls: Move DER / ASN.1 related definitions to asn1-private.h

PATCH Applied Andrew Zaborowski 3 participants 21 messages Aug 14, 2017 – Aug 17, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 tls: Move DER / ASN.1 related definitions to asn1-private.h

Extract those utilities that can be used by pem.c for decoding encrypted certificates and possibly other mechanisms. Introduce the asn1_oid_eq macro for comparing OIDs.

---
 Makefile.am        |   1 +
 ell/asn1-private.h | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 ell/tls.c          | 106 +++--------------------------------------------
 3 files changed, 124 insertions(+), 101 deletions(-)
 create mode 100644 ell/asn1-private.h
Makefile.am +1 -0
index 34ccd55..603b692 100644
@@ -83,6 +83,7 @@ ell_libell_la_SOURCES = $(linux_headers) \
 			ell/random.c \
 			ell/uintset.c \
 			ell/base64.c \
+			ell/asn1-private.h \
 			ell/pem.c \
 			ell/tls-private.h \
 			ell/tls.c \
ell/asn1-private.h new file +118 -0

118 lines not on this page · raw message

ell/tls.c +5 -101

142 lines not on this page · raw message

Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/7 asn1: Use const pointers in ASN1 parsing utilities

For convenience take const pointers as inputs to the ASN1 utilites, we only use those functions for parsing.

---
 ell/asn1-private.h | 11 ++++++-----
 ell/tls.c          |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)
ell/asn1-private.h +6 -5
index d7c8b6b..7827355 100644
@@ -63,8 +63,9 @@ static inline int asn1_parse_definite_length(const uint8_t **buf,
 }
 
 /* Return index'th element in a DER SEQUENCE */
-static inline uint8_t *asn1_der_find_elem(uint8_t *buf, size_t len_in,
-				int index, uint8_t *tag, size_t *len_out)
+static inline const uint8_t *asn1_der_find_elem(const uint8_t *buf,
+						size_t len_in, int index,
+						uint8_t *tag, size_t *len_out)
 {
 	int tlv_len;
 
@@ -90,9 +91,9 @@ static inline uint8_t *asn1_der_find_elem(uint8_t *buf, size_t len_in,
 }
 
 /* Return an element in a DER SEQUENCE structure by path */
-static inline uint8_t *asn1_der_find_elem_by_path(uint8_t *buf, size_t len_in,
-						uint8_t tag, size_t *len_out,
-						...)
+static inline const uint8_t *asn1_der_find_elem_by_path(const uint8_t *buf,
+						size_t len_in, uint8_t tag,
+						size_t *len_out, ...)
 {
 	uint8_t elem_tag;
 	int pos;
ell/tls.c +1 -1
index 894389a..ecdcff4 100644
@@ -2489,7 +2489,7 @@ void tls_cert_free_certchain(struct tls_cert *cert)
 
 enum tls_cert_key_type tls_cert_get_pubkey_type(struct tls_cert *cert)
 {
-	uint8_t *key_type;
+	const uint8_t *key_type;
 	size_t key_type_len;
 	int i;
 
Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH 2/7] asn1: Use const pointers in ASN1 parsing utilities

Hi Andrew,

Quoted 7 lines · Andrew Zaborowski

For convenience take const pointers as inputs to the ASN1 utilites, we only use those functions for parsing.

---
  ell/asn1-private.h | 11 ++++++-----
  ell/tls.c          |  2 +-
  2 files changed, 7 insertions(+), 6 deletions(-)

Applied, thanks.

Regards,
-Denis

#3 lore raw

PATCH 3/7 pkcs5: Implement PKCS#5 key derivation functions

In reply to Andrew Zaborowski

Implement the PBKDF1 and PBKDF2 functions from PKCS#4 - RFC8018. This a dependency for the pkcs5_cipher_from_alg_id but is export publically so that iwd can switch to this implementation and drop its own.

---
 Makefile.am |   6 ++-
 ell/ell.h   |   1 +
 ell/pkcs5.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ell/pkcs5.h |  47 ++++++++++++++++++
 4 files changed, 213 insertions(+), 2 deletions(-)
 create mode 100644 ell/pkcs5.c
 create mode 100644 ell/pkcs5.h
Makefile.am +4 -2
index 603b692..7f680b9 100644
@@ -40,7 +40,8 @@ pkginclude_HEADERS = ell/ell.h \
 			ell/pem.h \
 			ell/tls.h \
 			ell/uuid.h \
-			ell/key.h
+			ell/key.h \
+			ell/pkcs5.h
 
 lib_LTLIBRARIES = ell/libell.la
 
@@ -89,7 +90,8 @@ ell_libell_la_SOURCES = $(linux_headers) \
 			ell/tls.c \
 			ell/tls-record.c \
 			ell/uuid.c \
-			ell/key.c
+			ell/key.c \
+			ell/pkcs5.c
 
 ell_libell_la_LDFLAGS = -no-undefined \
 			-version-info $(ELL_CURRENT):$(ELL_REVISION):$(ELL_AGE)
ell/ell.h +1 -0
index 390743f..b43804d 100644
@@ -44,6 +44,7 @@
 #include <ell/tls.h>
 #include <ell/uuid.h>
 #include <ell/key.h>
+#include <ell/pkcs5.h>
 
 #include <ell/netlink.h>
 #include <ell/genl.h>
ell/pkcs5.c new file +161 -0

161 lines not on this page · raw message

ell/pkcs5.h new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.11.0
#4 lore raw

Re: [PATCH 3/7] pkcs5: Implement PKCS#5 key derivation functions

Hi Andrew,

Quoted 3 lines · Andrew Zaborowski

Implement the PBKDF1 and PBKDF2 functions from PKCS#4 - RFC8018. This a dependency for the pkcs5_cipher_from_alg_id but is export publically so that iwd can switch to this implementation and drop its own.

I reworded the description slightly...

Quoted 9 lines
---
  Makefile.am |   6 ++-
  ell/ell.h   |   1 +
  ell/pkcs5.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  ell/pkcs5.h |  47 ++++++++++++++++++
  4 files changed, 213 insertions(+), 2 deletions(-)

create mode 100644 ell/pkcs5.c
create mode 100644 ell/pkcs5.h

Applied, thanks.

Regards,
-Denis

#5 lore raw

PATCH 4/7 pkcs5: Add pkcs5_cipher_from_alg_id

In reply to Andrew Zaborowski

Add a utility to parse all of the PKCS#5 DER-encoded encryption scheme information, use the right PBKDF function to calculate the key, create the appropriate l_cipher object type (if we support that PKCS#5 cipher type) with that key and set the IV on the l_cipher object.

We don't support any of the RC2 or RC5 based encryption schemes or those that use MD2, SHA512-224 or SHA512-256 for the hash, because there's no kernel support for those algorithms. OpenSSL can create RSA private keys encrypted with some of these algorithms but MD5+DES and DES3-EDE are the default and the popular algorithms. OpenSSL also supports camellia ciphers in those scenarios which we could add.

Note that the caller still needs to add or remove the padding from the data encrypted or decrypted with the l_cipher object.

---
 Makefile.am         |   1 +
 ell/pkcs5-private.h |  25 +++++
 ell/pkcs5.c         | 311 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 337 insertions(+)
 create mode 100644 ell/pkcs5-private.h
Makefile.am +1 -0
index 7f680b9..9f7183c 100644
@@ -91,6 +91,7 @@ ell_libell_la_SOURCES = $(linux_headers) \
 			ell/tls-record.c \
 			ell/uuid.c \
 			ell/key.c \
+			ell/pkcs5-private.h \
 			ell/pkcs5.c
 
 ell_libell_la_LDFLAGS = -no-undefined \
ell/pkcs5-private.h new file +25 -0
new file mode 100644
index 0000000..f4f41f5
@@ -0,0 +1,25 @@
+/*
+ *
+ *  Embedded Linux library
+ *
+ *  Copyright (C) 2017  Intel Corporation. All rights reserved.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+struct l_cipher *pkcs5_cipher_from_alg_id(const uint8_t *id_asn1,
+						size_t id_asn1_len,
+						const char *password);
ell/pkcs5.c +311 -0

323 lines not on this page · raw message

Signature · 1 line
2.11.0
#6 lore raw

Re: [PATCH 4/7] pkcs5: Add pkcs5_cipher_from_alg_id

Hi Andrew,

Quoted 12 lines · Andrew Zaborowski

Add a utility to parse all of the PKCS#5 DER-encoded encryption scheme information, use the right PBKDF function to calculate the key, create the appropriate l_cipher object type (if we support that PKCS#5 cipher type) with that key and set the IV on the l_cipher object.

We don't support any of the RC2 or RC5 based encryption schemes or those that use MD2, SHA512-224 or SHA512-256 for the hash, because there's no kernel support for those algorithms. OpenSSL can create RSA private keys encrypted with some of these algorithms but MD5+DES and DES3-EDE are the default and the popular algorithms. OpenSSL also supports camellia ciphers in those scenarios which we could add.

Quoted 9 lines

Note that the caller still needs to add or remove the padding from the data encrypted or decrypted with the l_cipher object.

---
  Makefile.am         |   1 +
  ell/pkcs5-private.h |  25 +++++
  ell/pkcs5.c         | 311 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 337 insertions(+)

create mode 100644 ell/pkcs5-private.h

Applied, thanks.

Regards,
-Denis

#7 lore raw

PATCH 5/7 pem: Support encrypted keys in l_pem_load_private_key

In reply to Andrew Zaborowski

Add support for loading PKCS#8 encrypted private key files (those generated with "openssl pkcs8 ..." or "openssl pkey ..." commands, not "openssl rsa ..." commands). The 'encrypted' parameter can be used to check if a password is required to decode the key if the caller knows nothing about the key other than the file path.

---
 ell/pem.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 ell/pem.h |   4 +--
 ell/tls.c |   1 +
 3 files changed, 107 insertions(+), 10 deletions(-)
ell/pem.c +104 -8
index d1f180e..4f38d88 100644
@@ -36,6 +36,9 @@
 #include "pem.h"
 #include "base64.h"
 #include "string.h"
+#include "asn1-private.h"
+#include "pkcs5-private.h"
+#include "cipher.h"
 
 #define PEM_START_BOUNDARY	"-----BEGIN "
 #define PEM_END_BOUNDARY	"-----END "
@@ -230,13 +233,33 @@ LIB_EXPORT uint8_t *l_pem_load_certificate(const char *filename, size_t *len)
 	return content;
 }
 
+/**
+ * l_pem_load_private_key
+ * @filename: path string to the PEM file to load
+ * @passphrase: private key encryption passphrase or NULL for unencrypted
+ * @encrypted: receives indication whether the file was encrypted if non-NULL
+ * @len: receives the length of the returned buffer
+ *
+ * Load the PEM encoded RSA Private Key file at @filename.  If it is an
+ * encrypted private key and @passphrase was non-NULL, the file is
+ * decrypted.  If it's unencrypted @passphrase is ignored.  @encrypted
+ * stores information of whether the file was encrypted, both in a
+ * success case and on error when NULL is returned.  This can be used to
+ * check if a passphrase is required without prior information.
+ *
+ * Returns: Buffer containing raw DER data for the private key or NULL, to
+ * be freed with l_free.
+ **/
 LIB_EXPORT uint8_t *l_pem_load_private_key(const char *filename,
 						const char *passphrase,
-						size_t *len)
+						bool *encrypted, size_t *len)
 {
 	uint8_t *content;
 	char *label;
 
+	if (encrypted)
+		*encrypted = false;
+
 	content = l_pem_load_file(filename, 0, &label, len);
 
 	if (!content)
@@ -246,19 +269,92 @@ LIB_EXPORT uint8_t *l_pem_load_private_key(const char *filename,
 	 * RFC7469- and PKCS#8-compatible label (default in OpenSSL 1.0.1+)
 	 * and the older (OpenSSL <= 0.9.8 default) label.
 	 */
-	if (strcmp(label, "PRIVATE KEY") && strcmp(label, "RSA PRIVATE KEY")) {
+	if (!strcmp(label, "PRIVATE KEY") ||
+			!strcmp(label, "RSA PRIVATE KEY"))
+		goto done;
+
+	/* RFC5958 (PKCS#8) section 3 type encrypted key label */
+	if (!strcmp(label, "ENCRYPTED PRIVATE KEY")) {
+		const uint8_t *key_info, *alg_id, *data;
+		uint8_t tag;
+		size_t key_info_len, alg_id_len, data_len, tmp_len;
+		struct l_cipher *alg;
+		uint8_t *decrypted;
+		int i;
+
+		if (encrypted)
+			*encrypted = true;
+
+		if (!passphrase)
+			goto err;
+
+		/* Technically this is BER, not limited to DER */
+		key_info = asn1_der_find_elem(content, *len, 0, &tag,
+						&key_info_len);
+		if (!key_info || tag != ASN1_ID_SEQUENCE)
+			goto err;
+
+		alg_id = asn1_der_find_elem(key_info, key_info_len, 0, &tag,
+						&alg_id_len);
+		if (!alg_id || tag != ASN1_ID_SEQUENCE)
+			goto err;
+
+		data = asn1_der_find_elem(key_info, key_info_len, 1, &tag,
+						&data_len);
+		if (!data || tag != ASN1_ID_OCTET_STRING || data_len < 8 ||
+				(data_len & 7) != 0)
+			goto err;
+
+		if (asn1_der_find_elem(content, *len, 2, &tag, &tmp_len))
+			goto err;
+
+		alg = pkcs5_cipher_from_alg_id(alg_id, alg_id_len, passphrase);
+		if (!alg)
+			goto err;
+
+		decrypted = l_malloc(data_len);
+
+		if (!l_cipher_decrypt(alg, data, decrypted, data_len)) {
+			l_cipher_free(alg);
+			l_free(decrypted);
+			goto err;
+		}
+
+		l_cipher_free(alg);
 		l_free(content);
-		content = NULL;
+		content = decrypted;
+
+		/*
+		 * Strip padding as defined in RFC8018 (for PKCS#5 v1) or
+		 * RFC1423 / RFC5652 (for v2).
+		 */
+
+		if (content[data_len - 1] >= data_len ||
+				content[data_len - 1] > 16)
+			goto err;
+
+		for (i = 1; i < content[data_len - 1]; i++)
+			if (content[data_len - 1 - i] != content[data_len - 1])
+				goto err;
+
+		*len = data_len - content[data_len - 1];
+
+		goto done;
 	}
 
 	/*
-	 * TODO: handle ENCRYPTED PRIVATE KEY - RFC5958 section 3.
-	 *
-	 * TODO: handle RSA PRIVATE KEY encrypted keys (OpenSSL <= 0.9.8),
-	 * incompatible with RFC7468 parsing because of the headers present
-	 * before base64 encoded data.
+	 * TODO: handle RSA PRIVATE KEY format encrypted keys
+	 * (as produced by "openssl rsa" commands), incompatible with
+	 * RFC7468 parsing because of the headers present before
+	 * base64-encoded data.
 	 */
 
+	/* Label not known */
+err:
+	l_free(content);
+	content = NULL;
+
+done:
 	l_free(label);
 
 	return content;
ell/pem.h +2 -2
index c220fd4..93282a3 100644
@@ -34,8 +34,8 @@ uint8_t *l_pem_load_file(const char *filename, int index,
 
 uint8_t *l_pem_load_certificate(const char *filename, size_t *len);
 
-uint8_t *l_pem_load_private_key(const char *filename,
-				const char *passphrase, size_t *len);
+uint8_t *l_pem_load_private_key(const char *filename, const char *passphrase,
+				bool *encrypted, size_t *len);
 
 #ifdef __cplusplus
 }
ell/tls.c +1 -0
index ecdcff4..d3b4809 100644
@@ -2223,6 +2223,7 @@ LIB_EXPORT bool l_tls_set_auth_data(struct l_tls *tls, const char *cert_path,
 
 		priv_key = l_pem_load_private_key(priv_key_path,
 							priv_key_passphrase,
+							NULL,
 							&tls->priv_key_size);
 		if (!priv_key)
 			return false;
Signature · 1 line
2.11.0
#8 lore raw

Re: [PATCH 5/7] pem: Support encrypted keys in l_pem_load_private_key

Hi Andrew,

Quoted 11 lines · Andrew Zaborowski

Add support for loading PKCS#8 encrypted private key files (those generated with "openssl pkcs8 ..." or "openssl pkey ..." commands, not "openssl rsa ..." commands). The 'encrypted' parameter can be used to check if a password is required to decode the key if the caller knows nothing about the key other than the file path.

---
  ell/pem.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
  ell/pem.h |   4 +--
  ell/tls.c |   1 +
  3 files changed, 107 insertions(+), 10 deletions(-)

Applied, thanks.

Regards,
-Denis

#9 lore raw

PATCH 6/7 unit: Update for l_pem_load_private_key() signature change

In reply to Andrew Zaborowski
---
 unit/test-key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
unit/test-key.c +1 -1
index 7513b38..9e87fed 100644
@@ -575,7 +575,7 @@ static void test_key_crypto(const void *data)
 	int rsa = L_KEY_RSA_PKCS1_V1_5;
 
 	cert = l_pem_load_private_key(TESTDATADIR "/cert-client-key-pkcs8.pem",
-					NULL, &certlen);
+					NULL, NULL, &certlen);
 	assert(cert);
 	pubcert = l_pem_load_certificate(TESTDATADIR "/cert-client.pem",
 						&pubcertlen);
Signature · 1 line
2.11.0
#10 lore raw

Re: [PATCH 6/7] unit: Update for l_pem_load_private_key() signature change

Hi Andrew,

Quoted 4 lines · Andrew Zaborowski
---
  unit/test-key.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Regards,
-Denis

#11 lore raw

PATCH 7/7 unit: Test loading encrypted private key PEM files

In reply to Andrew Zaborowski

New test cert files are encrytped versions of cert-client-key-pkcs8.pem generated with:

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256

---
 Makefile.am                          |  5 ++++
 unit/cert-client-key-md5-des.pem     | 29 ++++++++++++++++++++++
 unit/cert-client-key-v2-aes128.pem   | 30 ++++++++++++++++++++++
 unit/cert-client-key-v2-aes256.pem   | 30 ++++++++++++++++++++++
 unit/cert-client-key-v2-des-ede3.pem | 30 ++++++++++++++++++++++
 unit/cert-client-key-v2-des.pem      | 29 ++++++++++++++++++++++
 unit/test-pem.c                      | 48 ++++++++++++++++++++++++++++++++++++
 7 files changed, 201 insertions(+)
 create mode 100644 unit/cert-client-key-md5-des.pem
 create mode 100644 unit/cert-client-key-v2-aes128.pem
 create mode 100644 unit/cert-client-key-v2-aes256.pem
 create mode 100644 unit/cert-client-key-v2-des-ede3.pem
 create mode 100644 unit/cert-client-key-v2-des.pem
Makefile.am +5 -0
index 9f7183c..533153b 100644
@@ -234,6 +234,11 @@ unit_test_data_files = unit/settings.test unit/cert-ca.pem \
 			unit/cert-intca.pem unit/cert-entity-int.pem \
 			unit/cert-client-key-pkcs8.pem \
 			unit/cert-server-key-pkcs8.pem \
+			unit/cert-client-key-md5-des.pem \
+			unit/cert-client-key-v2-aes128.pem \
+			unit/cert-client-key-v2-aes256.pem \
+			unit/cert-client-key-v2-des-ede3.pem \
+			unit/cert-client-key-v2-des.pem \
 			unit/dbus.conf
 
 examples = examples/dbus-service examples/https-client-test \
unit/cert-client-key-md5-des.pem new file +29 -0
new file mode 100644
index 0000000..e3edfc5
@@ -0,0 +1,29 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIE6TAbBgkqhkiG9w0BBQMwDgQI4Jws4ZHp7oQCA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3UCa
+8Agc1nYXs8VH9sV+LMMGdCVoY/RwJvZwf13fqnLcmIA4iI8cDf1beUVm1JvdgIL/
+5Pbxyh2sAzyk/DIFD6yCQUacBKkR3EAXPG9gm5jebjHOU+gxSt69e3jgA1BvuoS5
+S3xLePrZnGZuPjM2PQX6LW1wWBtNlhbqWAkyeL3YwEwv2FjluFqALB/He/MaNly3
+UXFULImo8C/2UF9y9hgoSuamFqlKtgaNBUlqNPxX0EQmyCuqBEGYaouZ2TzPfZ44
+Jf6p6sQZeEmklEIDkaC9DvAGU7DPRfxolLpYHvdHQTwnjKMbFkg7FSAzzdNiKKeR
+nEnCkaofA2FASfQaZvOkewACaZfqJ1FCSsoetYq2Ulf8o1f8j/QM+JIq4p0DIybz
+4gsBmg05xufNiZNqZrrFc0/HcZkT3ahgtY+TMzU8d0hAS7roFNlM2lpaE69HJeTZ
+rhRO7/VAU2Kb0bQI5UWe4yfvbPBmmaxw06lPahlBAEgqeULwfVWBPafjSyq8vPag
+9RzpwSASqL6dv89qdOPE0JioA9xZ3cemlVOgqzd04AkdnDf3flGCJa6O9BujGm72
+8t0TmXLstK7YNaxQYA==
+-----END ENCRYPTED PRIVATE KEY-----
unit/cert-client-key-v2-aes128.pem new file +30 -0
new file mode 100644
index 0000000..01cf80d
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIruvC4dfgwlMCAggA
+MB0GCWCGSAFlAwQBAgQQGE5EgJ6nZ5bHxZLAs90seQSCBNBZaeeYO7dFK8301zHn
+ESNjgFaiB11ipzPxjpdJ0+cuP3ljfO+6RD31zANbE7Cpn1NjlhdFVDe5zzK8/1fY
+FnWBbRF4+jYbIppjjwmGjzEEo2NO0kc022RkeIIX+EDWzi25+Vu6LFf5brCybElY
+ObT+kgRGE6mzCDGuUBWiiR+XinqOK9hcYmLo8RtyQ3bLq2aWRDSSQXcCY/Il52c7
+F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qwhQxilCl4lzHN3QGtcg/6fU6VV68IrgU4lD5iKwWDcRBXaCgks/E3
+5useAMJAIJR0qJ2RBnNcfl9QX2qlDqeZKa2CqLHwc4BrEx+QHi8r2bJL1ChRNH9F
+dRaKXPWLWh9vx4d6Xw/xWBMQ3PIEM5JN3oZonFKMfYnRU4ncGQjxoR8PWwr1UEcA
+iT0JqgHX3PnWvSR5DfIJJHGlKTWZlMwtOdgB1Q1eSuIkkkU8JJCuIts4T9juLr0U
+Nng85ZA58JqHpLvPLAecRdMB652lBu4V63XyobnbkQH6rxvF5dh/wi/YyJ3EQgc/
+Lvh068Dheyegbg7B2tDbKvf7Xvjkzmd1T4KZcF0P7iuyq9tzWfQl+8bYmRW+VsR3
+g3GTgMVXQFVQz0+jFSM3Q/JWPA==
+-----END ENCRYPTED PRIVATE KEY-----
unit/cert-client-key-v2-aes256.pem new file +30 -0
new file mode 100644
index 0000000..cfca70c
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIpk7ueupozNMCAggA
+MB0GCWCGSAFlAwQBKgQQSlv6z6I4xJfloAEAyx3F7ASCBNDpL021QN2prL3hlTjK
+qea2QZu9xwAxQljKRL00T7i6VcDOJ//YwOgc83GHYjNf47bTIYmzuYvDta6zV82D
+huOMERS3Ep/bIWAf8Jd0bR1vbrvWcDI285083EFbh9PZqnUrFRPdJiqBu/VgyqiE
+2UNjK1s8l8SERVbOSTRNs1glHpUztuvrUxgDsvUqDrFDs8HIfRlOriI2NFIW5kPb
+ncSl5yrUlzerZWmXgF5KCKOh/ojyV56v4UUWaiFzAL7GBxLnYR4EaW3p8xKP/Adq
+vZMkAHX7YzMi9NEWVPmGVLPxkFC50d8XVOOaeI9nt6LAdsnba4xjLvih5dvtIUGc
+LrIgRrc+7l1r+/bZjpFOov4+jTX11cW0HCkm5G6ewuxp57t2XM3cZYk0gGsixGNd
+r3IdW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0BMg0/41lbsuYMqEYpkgFQfYl
+7RsW7w7djVEOKpZOglBWVFUBOHYVyZru4ISzrp5KZxTvtLn8Avqi7gbNV7jZ0XqN
+C7uvJLPB3wyM17KAyW5iNldjXEpkwfle6txMxabmrAJiVBqs8VPagWtz2G5Sfhuc
+N7Om2aewyGHSTP+FVKJo5Zg94Q==
+-----END ENCRYPTED PRIVATE KEY-----
unit/cert-client-key-v2-des-ede3.pem new file +30 -0
new file mode 100644
index 0000000..e94d345
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIVG6rLrQ+fVgCAggA
+MBQGCCqGSIb3DQMHBAizDQ76m4Q4ZQSCBMh50R/dRYR4agewBCpNNVYIHV/wotfZ
+PhhwcJQFZMmp50rCI9rh13w8TSr+KDreXTY+XzvqFS7fbB0JV3QWlv2wvqkAFXoJ
+CYlE40WXg5Qd2H849IyLEil8J5mvoZohDZYNk82zi+PSvkvxJ8d1RJIiHHhmReeC
+0+rDHd9C+Xr2MVBOMA+gimx/P3qtS4jI0qjmzyUiorHa9lvY5qzxbMibi4mEAjBy
+VWviWHszpCwKVapODFlG2r5R2wvmhp4GUGSigi7KtL7hijEbsh4CW2RqYLR733Nx
+WdsyIc4sD3908ttfQSmsSt6vchAMkelwFizGSEFLMsCne3MGjVsLpVitg6nswl6N
+pvngZu0zaggWFVPRIt+vIimeHrujzoiUuzDizjOVzCiyRkrFuJEMwN3l/AaSxUiG
+lOWga1Eb+McH3oJNU1WtrL7gDwfmKFc26D7xNMnGLcdYxfM1F98XfM3FVswaHdC7
+0uTmEmMdhpoNw4CWai37NpigW01cDnxMMpFuX0yTU8GUU/JkBgZ4NHE1sTZrFiOf
+mMr83waumMGwwChhZAd1qDRB35c1HLvVqBt3HkdcyCZP1JBxG4QLrw7IVzG+knlj
+QdrBC/lDNA15wG27v5hRUVEoeFRJkOllUlSqfh0PmJw2t32BP8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IRzH6I8kRDNdYOcSit4HbIOzGy6unJhfVHhMBH7zIVWF1se8+Ri7M7veeiixbE/
+aWl0qZ1wMIZYKSHwgNl4LZwaxyvLR9n0rPkrJVOEmuKq2vyIjcus41YqKVm6zYWf
+gJSBXSYBEJq11wDCWJGVIi1VGS4PeA4t0u8af0PD9+Nyj2DfaQENaOyKsCAFqfZU
+rjk10dmpuAnEEE+uEqrpHeqaYSPZT08EkaZy9meUgtFeIqTzgXC9oHxTqJpj3+as
+ln7p28gMosEEK3At7kpMyD/gQmCeP+cyK7dFGP46D1qTtlSeWi+ZNa/W/ULvDcQw
+SWmT168M1aA5bHkHfK+xcFo776YGoP6tOaJeT684Tyj/35GTNldYdeQIFykQ5dRV
+TO/zO1WopBNVT+RQnOzJXvsiRJZ7c6Y2S1XyOj9t9LJndDD65leLWqKeepHmKMqD
+h78Kea72+3s+STj7D2pJFSeaPaBc9G0vZhDFqWyga9nHFNcF/k6jj22NDJyfgj1F
+1tEoMNn+Cu1xh1Krl6KHEFlcMm6j9XuU/BhDBMJhO8DfpQye/xNSYq+KFrQ1Emdl
+X/ynmsFsfmVv4P1YSg7/z87ZlBmcJUHePHpM1eiWygW8ujCsOybihAj3OxVpDF9R
+RGlsGvHXkNDVSQG5y/zron8IJjbixdAe1BUdYfI8V6f13fUbJVOg5oeICsEcna3v
+wnNE+gYCF3uEzoBx+N+tRHvJ0t2U9rHGXphefCE50mPCZ0nYps/OPSq0OCeGjgA=
+-----END ENCRYPTED PRIVATE KEY-----
unit/test-pem.c +48 -0

59 lines not on this page · raw message

Signature · 1 line
2.11.0
#12 lore raw

Re: [PATCH 7/7] unit: Test loading encrypted private key PEM files

Andrew,

Quoted 5 lines · Andrew Zaborowski

New test cert files are encrytped versions of cert-client-key-pkcs8.pem generated with:

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8

Quoted 7 lines

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256

Please update unit/gencerts.sh to create these files too. This makes it easy to regenerate them when the certs expire and ensures that the commands are documented for developers who don't have the git history handy.

Thanks,
Mat

Quoted 282 lines

---

Makefile.am                          |  5 ++++
unit/cert-client-key-md5-des.pem     | 29 ++++++++++++++++++++++
unit/cert-client-key-v2-aes128.pem   | 30 ++++++++++++++++++++++
unit/cert-client-key-v2-aes256.pem   | 30 ++++++++++++++++++++++
unit/cert-client-key-v2-des-ede3.pem | 30 ++++++++++++++++++++++
unit/cert-client-key-v2-des.pem      | 29 ++++++++++++++++++++++
unit/test-pem.c                      | 48 ++++++++++++++++++++++++++++++++++++
7 files changed, 201 insertions(+)

create mode 100644 unit/cert-client-key-md5-des.pem create mode 100644 unit/cert-client-key-v2-aes128.pem create mode 100644 unit/cert-client-key-v2-aes256.pem create mode 100644 unit/cert-client-key-v2-des-ede3.pem create mode 100644 unit/cert-client-key-v2-des.pem

Makefile.am +5 -0
index 9f7183c..533153b 100644
@@ -234,6 +234,11 @@ unit_test_data_files = unit/settings.test unit/cert-ca.pem \
 			unit/cert-intca.pem unit/cert-entity-int.pem \
 			unit/cert-client-key-pkcs8.pem \
 			unit/cert-server-key-pkcs8.pem \
+			unit/cert-client-key-md5-des.pem \
+			unit/cert-client-key-v2-aes128.pem \
+			unit/cert-client-key-v2-aes256.pem \
+			unit/cert-client-key-v2-des-ede3.pem \
+			unit/cert-client-key-v2-des.pem \
 			unit/dbus.conf
 
 examples = examples/dbus-service examples/https-client-test \
unit/cert-client-key-md5-des.pem new file +29 -0
new file mode 100644
index 0000000..e3edfc5
@@ -0,0 +1,29 @@
+-----BEGIN ENCRYPTED PRIVATE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HLPyXxuaJkzcZs7EOG5S5MT7tDW9i72RZUiUPGztmhOLxkYrH/r3UCa
+8Agc1nYXs8VH9sV+LMMGdCVoY/RwJvZwf13fqnLcmIA4iI8cDf1beUVm1JvdgIL/
+5Pbxyh2sAzyk/DIFD6yCQUacBKkR3EAXPG9gm5jebjHOU+gxSt69e3jgA1BvuoS5
+S3xLePrZnGZuPjM2PQX6LW1wWBtNlhbqWAkyeL3YwEwv2FjluFqALB/He/MaNly3
+UXFULImo8C/2UF9y9hgoSuamFqlKtgaNBUlqNPxX0EQmyCuqBEGYaouZ2TzPfZ44
+Jf6p6sQZeEmklEIDkaC9DvAGU7DPRfxolLpYHvdHQTwnjKMbFkg7FSAzzdNiKKeR
+nEnCkaofA2FASfQaZvOkewACaZfqJ1FCSsoetYq2Ulf8o1f8j/QM+JIq4p0DIybz
+4gsBmg05xufNiZNqZrrFc0/HcZkT3ahgtY+TMzU8d0hAS7roFNlM2lpaE69HJeTZ
+rhRO7/VAU2Kb0bQI5UWe4yfvbPBmmaxw06lPahlBAEgqeULwfVWBPafjSyq8vPag
+9RzpwSASqL6dv89qdOPE0JioA9xZ3cemlVOgqzd04AkdnDf3flGCJa6O9BujGm72
+8t0TmXLstK7YNaxQYA==
+-----END ENCRYPTED PRIVATE KEY-----
unit/cert-client-key-v2-aes128.pem new file +30 -0
new file mode 100644
index 0000000..01cf80d
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIruvC4dfgwlMCAggA
+MB0GCWCGSAFlAwQBAgQQGE5EgJ6nZ5bHxZLAs90seQSCBNBZaeeYO7dFK8301zHn
+ESNjgFaiB11ipzPxjpdJ0+cuP3ljfO+6RD31zANbE7Cpn1NjlhdFVDe5zzK8/1fY
+FnWBbRF4+jYbIppjjwmGjzEEo2NO0kc022RkeIIX+EDWzi25+Vu6LFf5brCybElY
+ObT+kgRGE6mzCDGuU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X7sQhN9Ozmd1HPh6araDAKBnA9IdTWdZKtgefp
+/gsZJ6rgBgqwhQxilCl4lzHN3QGtcg/6fU6VV68IrgU4lD5iKwWDcRBXaCgks/E3
+5useAMJAIJR0qJ2RBnNcfl9QX2qlDqeZKa2CqLHwc4BrEx+QHi8r2bJL1ChRNH9F
+dRaKXPWLWh9vx4d6Xw/xWBMQ3PIEM5JN3oZonFKMfYnRU4ncGQjxoR8PWwr1UEcA
+iT0JqgHX3PnWvSR5DfIJJHGlKTWZlMwtOdgB1Q1eSuIkkkU8JJCuIts4T9juLr0U
+Nng85ZA58JqHpLvPLAecRdMB652lBu4V63XyobnbkQH6rxvF5dh/wi/YyJ3EQgc/
+Lvh068Dheyegbg7B2tDbKvf7Xvjkzmd1T4KZcF0P7iuyq9tzWfQl+8bYmRW+VsR3
+g3GTgMVXQFVQz0+jFSM3Q/JWPA==
+-----END ENCRYPTED PRIVATE KEY-----
unit/cert-client-key-v2-aes256.pem new file +30 -0
new file mode 100644
index 0000000..cfca70c
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIpk7ueupozNMCAggA
+MB0GCWCGSAFlAwQBKgQQSlv6z6I4xJfloAEAyx3F7ASCBNDpL021QN2prL3hlTjK
+qea2QZu9xwAxQljKRL00T7i6VcDOJ//YwOgc83GHYjNf47bTIYmzuYvDta6zV82D
+huOMERS3Ep/bIWAf8Jd0bR1vbrvWcDI285083EFbh9PZqnUrFRPdJiqBu/VgyqiE
+2UNjK1s8l8SERVbOSTRNs1glHpUztuvrUxgDsvUqDrFDs8HIfRlOriI2NFIW5kPb
+ncSl5yrUlzerZWmXgF5KCKOh/ojyV56v4UUWaiFzAL7GBxLnYR4EaW3p8xKP/Adq
+vZMkAHX7YzMi9NEWVPmGVLPxkFC50d8XVOOaeI9nt6LAdsnba4xjLvih5dvtIUGc
+LrIgRrc+7l1r+/bZjp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S5yObb5lUznT
+BQQ1SFct8/3JLdgke6lml/PdjL0T1Q98T8mKXAi0BMg0/41lbsuYMqEYpkgFQfYl
+7RsW7w7djVEOKpZOglBWVFUBOHYVyZru4ISzrp5KZxTvtLn8Avqi7gbNV7jZ0XqN
+C7uvJLPB3wyM17KAyW5iNldjXEpkwfle6txMxabmrAJiVBqs8VPagWtz2G5Sfhuc
+N7Om2aewyGHSTP+FVKJo5Zg94Q==
+-----END ENCRYPTED PRIVATE KEY-----
unit/cert-client-key-v2-des-ede3.pem new file +30 -0
new file mode 100644
index 0000000..e94d345
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIVG6rLrQ+fVgCAggA
+MBQGCCqGSIb3DQMHBAizDQ76m4Q4ZQSCBMh50R/dRYR4agewBCpNNVYIHV/wotfZ
+PhhwcJQFZMmp50rCI9rh13w8TSr+KDreXTY+XzvqFS7fbB0JV3QWlv2wvqkAFXoJ
+CYlE40WXg5Qd2H849IyLEil8J5mvoZohDZYNk82zi+PSvkvxJ8d1RJIiHHhmReeC
+0+rDHd9C+Xr2MVBOMA+gimx/P3qtS4jI0qjmzyUiorHa9lvY5qzxbMibi4mEAjBy
+VWviWHszpCwKVapODFlG2r5R2wvmhp4GUGSigi7KtL7hijEbsh4CW2RqYLR733Nx
+WdsyIc4sD3908ttfQSmsSt6vchAMkelwFizGSEFLMsCne3MGjVsLpVitg6nswl6N
+pvngZu0zaggWFVPRIt+vIimeHrujzoiUuzDizjOVzCiyRkrFuJEMwN3l/AaSxUiG
+lOWga1Eb+McH3oJNU1WtrL7gDwfmKFc26D7xNMnGLcdYxfM1F98XfM3FVswaHdC7
+0uTmEmMdhpoNw4CWai37NpigW01cDnxMMpFuX0yTU8GUU/JkBgZ4NHE1sTZrFiOf
+mMr83waumMGwwChhZAd1qDRB35c1HLvVqBt3HkdcyCZP1JBxG4QLrw7IVzG+knl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QYxmh46TqYiPtdmOZ7RKdAMnX50PRYroMMu91VCmkKlr1Twnj
+jIRzH6I8kRDNdYOcSit4HbIOzGy6unJhfVHhMBH7zIVWF1se8+Ri7M7veeiixbE/
+aWl0qZ1wMIZYKSHwgNl4LZwaxyvLR9n0rPkrJVOEmuKq2vyIjcus41YqKVm6zYWf
+gJSBXSYBEJq11wDCWJGVIi1VGS4PeA4t0u8af0PD9+Nyj2DfaQENaOyKsCAFqfZU
+rjk10dmpuAnEEE+uEqrpHeqaYSPZT08EkaZy9meUgtFeIqTzgXC9oHxTqJpj3+as
+ln7p28gMosEEK3At7kpMyD/gQmCeP+cyK7dFGP46D1qTtlSeWi+ZNa/W/ULvDcQw
+SWmT168M1aA5bHkHfK+xcFo776YGoP6tOaJeT684Tyj/35GTNldYdeQIFykQ5dRV
+TO/zO1WopBNVT+RQnOzJXvsiRJZ7c6Y2S1XyOj9t9LJndDD65leLWqKeepHmKMqD
+h78Kea72+3s+STj7D2pJFSeaPaBc9G0vZhDFqWyga9nHFNcF/k6jj22NDJyfgj1F
+1tEoMNn+Cu1xh1Krl6KHEFlcMm6j9XuU/BhDBMJhO8DfpQye/xNSYq+KFrQ1Emdl
+X/ynmsFsfmVv4P1YSg7/z87ZlBmcJUHePHpM1eiWygW8ujCsOybihAj3OxVpDF9R
+RGlsGvHXkNDVSQG5y/zron8IJjbixdAe1BUdYfI8V6f13fUbJVOg5oeICsEcna3v
+wnNE+gYCF3uEzoBx+N+tRHvJ0t2U9rHGXphefCE50mPCZ0nYps/OPSq0OCeGjgA=
+-----END ENCRYPTED PRIVATE KEY-----
unit/test-pem.c +48 -0
index 0a075dd..9090a24 100644
@@ -87,6 +87,42 @@ static void test_pem(const void *data)
 	l_free(decoded);
 }
 
+static void test_encrypted_pkey(const void *data)
+{
+	const char *encrypted_pem = data;
+	const char *plaintext_pem = "unit/cert-client-key-pkcs8.pem";
+	bool encrypted;
+	size_t size1, size2;
+	uint8_t *pkey1, *pkey2;
+
+	encrypted = false;
+	assert(!l_pem_load_private_key(encrypted_pem, NULL,
+					&encrypted, &size1));
+	assert(encrypted);
+
+	encrypted = false;
+	assert(!l_pem_load_private_key(encrypted_pem, "wrong-passwd",
+					&encrypted, &size1));
+	assert(encrypted);
+
+	encrypted = false;
+	pkey1 = l_pem_load_private_key(encrypted_pem, "abc",
+					&encrypted, &size1);
+	assert(pkey1);
+	assert(encrypted);
+
+	pkey2 = l_pem_load_private_key(plaintext_pem, NULL,
+					&encrypted, &size2);
+	assert(pkey2);
+	assert(!encrypted);
+
+	assert(size1 == size2);
+	assert(!memcmp(pkey1, pkey2, size1));
+
+	l_free(pkey1);
+	l_free(pkey2);
+}
+
 int main(int argc, char *argv[])
 {
 	l_test_init(&argc, &argv);
@@ -98,5 +134,17 @@ int main(int argc, char *argv[])
 
 	l_test_add("pem/empty label", test_pem, &empty_label);
 
+	l_test_add("pem/v1 MD5AndDES encrypted Private Key",
+			test_encrypted_pkey,
+			"unit/cert-client-key-md5-des.pem");
+	l_test_add("pem/v2 DES encrypted Private Key", test_encrypted_pkey,
+			"unit/cert-client-key-v2-des.pem");
+	l_test_add("pem/v2 DES EDE3 encrypted Private Key", test_encrypted_pkey,
+			"unit/cert-client-key-v2-des-ede3.pem");
+	l_test_add("pem/v2 AES128 encrypted Private Key", test_encrypted_pkey,
+			"unit/cert-client-key-v2-aes128.pem");
+	l_test_add("pem/v2 AES256 encrypted Private Key", test_encrypted_pkey,
+			"unit/cert-client-key-v2-aes256.pem");
+
 	return l_test_run();
 }
Signature · 6 lines
2.11.0

_______________________________________________
ell mailing list
ell(a)lists.01.org
https://lists.01.org/mailman/listinfo/ell

--
Mat Martineau
Intel OTC

#13 lore raw

Re: [PATCH 7/7] unit: Test loading encrypted private key PEM files

Hi Andrew/Mat,

Quoted 20 lines · Mat Martineau

Andrew,

Quoted 15 lines · Andrew Zaborowski

New test cert files are encrytped versions of cert-client-key-pkcs8.pem generated with:

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128

Quoted 8 lines
Quoted 2 lines

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256

Please update unit/gencerts.sh to create these files too. This makes it easy to regenerate them when the certs expire and ensures that the commands are documented for developers who don't have the git history handy.

Yes, please do this. I've applied this patch in the meantime.

By the way, on my Gentoo box I get:

bash: unit/gencerts.sh: /usr/bin/sh: bad interpreter: No such file or directory

Should we drop the .pem files from the tree and simply use gencerts.sh when running configure?

Regards,
-Denis

#14 lore raw

Re: [PATCH 7/7] unit: Test loading encrypted private key PEM files

Quoted 31 lines · Denis Kenzior

Hi Andrew/Mat,

Quoted 20 lines · Mat Martineau

Andrew,

Quoted 15 lines · Andrew Zaborowski

New test cert files are encrytped versions of cert-client-key-pkcs8.pem generated with:

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128

Quoted 7 lines
Quoted 2 lines

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256

Please update unit/gencerts.sh to create these files too. This makes it easy to regenerate them when the certs expire and ensures that the commands are documented for developers who don't have the git history handy.

Quoted 6 lines

Yes, please do this. I've applied this patch in the meantime.

By the way, on my Gentoo box I get:

bash: unit/gencerts.sh: /usr/bin/sh: bad interpreter: No such file or directory

Whoops. /bin/sh would be more likely to work everywhere.

Quoted 2 lines

Should we drop the .pem files from the tree and simply use gencerts.sh when running configure?

That would add openssl to our build time dependencies for unit tests. How about regenerating the .pem files before tagging a release?

--
Mat Martineau
Intel OTC

#15 lore raw

Re: [PATCH 7/7] unit: Test loading encrypted private key PEM files

Hi Mat,

Quoted 4 lines
Quoted 2 lines

bash: unit/gencerts.sh: /usr/bin/sh: bad interpreter: No such file or directory

Whoops. /bin/sh would be more likely to work everywhere.

yep

Quoted 7 lines
Quoted 3 lines

Should we drop the .pem files from the tree and simply use gencerts.sh when running configure?

That would add openssl to our build time dependencies for unit tests. How about regenerating the .pem files before tagging a release?

I was thinking we simply generate the pem files for maintainer builds. I would assume that introducing an openssl dependency for such builds shouldn't be an issue. Then have 'make dist' package the generated files into the tarball so that official 'released' versions build without openssl.

Regards,
-Denis

#16 lore raw

Re: [PATCH 7/7] unit: Test loading encrypted private key PEM files

Quoted 8 lines · Denis Kenzior

Hi Mat,

Quoted 4 lines
Quoted 2 lines

bash: unit/gencerts.sh: /usr/bin/sh: bad interpreter: No such file or directory

Whoops. /bin/sh would be more likely to work everywhere.

yep

I'll send that trivial patch

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Should we drop the .pem files from the tree and simply use gencerts.sh when running configure?

Quoted 8 lines
Quoted 3 lines

That would add openssl to our build time dependencies for unit tests. How about regenerating the .pem files before tagging a release?

I was thinking we simply generate the pem files for maintainer builds. I would assume that introducing an openssl dependency for such builds shouldn't be an issue. Then have 'make dist' package the generated files into the tarball so that official 'released' versions build without openssl.

One catch with that approach: test-key has reference ciphertext and a reference signature that were generated with one of those certs.

Some options:

* Keep one cert around for this test (which seems to defeat the whole purpose)

* Dynamically generate the ciphertext & signature along with the certs

* Leave the certs checked in

I favor leaving the .pems in the tree.

--
Mat Martineau
Intel OTC

#17 lore raw

Re: [PATCH 7/7] unit: Test loading encrypted private key PEM files

Hi Mat,

Quoted 8 lines
Quoted 4 lines

I was thinking we simply generate the pem files for maintainer builds. >> I would assume that introducing an openssl dependency for such builds shouldn't be an issue. Then have 'make dist' package the generated
files into the tarball so that official 'released' versions build
without openssl.

One catch with that approach: test-key has reference ciphertext and a reference signature that were generated with one of those certs.

So every X months we'd need to regenerate all the pem files, recommit them to the tree and fix up some unit test? That sounds awful :)

Quoted 6 lines

Some options:

* Keep one cert around for this test (which seems to defeat the whole purpose) >
* Dynamically generate the ciphertext & signature along with the certs

We could just generate a .h file with the above and include it into the unit test. That really sounds like a winner to me.

Regards,
-Denis

#18 lore raw

Re: [PATCH 7/7] unit: Test loading encrypted private key PEM files

Quoted 8 lines · Denis Kenzior

Hi Mat,

Quoted 6 lines
Quoted 5 lines

I was thinking we simply generate the pem files for maintainer builds. >> I would assume that introducing an openssl dependency for such builds shouldn't be an issue. Then have 'make dist' package the generated files into the tarball so that official 'released' versions build without openssl.

Quoted 6 lines
Quoted 3 lines

One catch with that approach: test-key has reference ciphertext and a reference signature that were generated with one of those certs.

So every X months we'd need to regenerate all the pem files, recommit them to the tree and fix up some unit test? That sounds awful :)

More like "every X decades". The certs don't expire for 27+ years (10000 days).

Quoted 9 lines
Quoted 6 lines

Some options:

* Keep one cert around for this test (which seems to defeat the whole purpose)
* Dynamically generate the ciphertext & signature along with the certs

We could just generate a .h file with the above and include it into the unit test. That really sounds like a winner to me.

If you skip the conversion to C array, the unit test could read the binary data from a couple of files instead of compiling it in.

--
Mat Martineau
Intel OTC

#19 lore raw

Re: [PATCH 7/7] unit: Test loading encrypted private key PEM files

In reply to Denis Kenzior

Hi,

Quoted 21 lines · Denis Kenzior
Quoted 20 lines · Mat Martineau
Quoted 17 lines · Andrew Zaborowski

New test cert files are encrytped versions of cert-client-key-pkcs8.pem generated with:

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256

Quoted 6 lines
Quoted 4 lines

Please update unit/gencerts.sh to create these files too. This makes it easy to regenerate them when the certs expire and ensures that the commands are documented for developers who don't have the git history handy.

Yes, please do this. I've applied this patch in the meantime.

Thanks, good point, I'll send a patch.

Quoted 8 lines

By the way, on my Gentoo box I get:

bash: unit/gencerts.sh: /usr/bin/sh: bad interpreter: No such file or directory

Should we drop the .pem files from the tree and simply use gencerts.sh when running configure?

Also note that openssl installations differ in compile options, probably not enough to cause problems with our usage.

Best regards

#20 lore raw
In reply to Andrew Zaborowski

Hi Andrew,

Quoted 10 lines · Andrew Zaborowski

Extract those utilities that can be used by pem.c for decoding encrypted certificates and possibly other mechanisms. Introduce the asn1_oid_eq macro for comparing OIDs.

---
  Makefile.am        |   1 +
  ell/asn1-private.h | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++
  ell/tls.c          | 106 +++--------------------------------------------
  3 files changed, 124 insertions(+), 101 deletions(-)

create mode 100644 ell/asn1-private.h

Applied, thanks.

Regards,
-Denis