All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ell@lists.01.org
Subject: Re: [PATCH 08/10] pem: Support encrypted keys in l_pem_load_private_key
Date: Fri, 11 Aug 2017 15:23:55 -0500	[thread overview]
Message-ID: <757437fc-6fa1-6cbf-97a5-be2597ef847b@gmail.com> (raw)
In-Reply-To: <20170810231016.29445-8-andrew.zaborowski@intel.com>

[-- Attachment #1: Type: text/plain, Size: 1635 bytes --]

Hi Andrew,

On 08/10/2017 06:10 PM, Andrew Zaborowski wrote:
> 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 | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
>   ell/pem.h |  4 +--
>   ell/tls.c |  1 +
>   3 files changed, 86 insertions(+), 9 deletions(-)
> 
> diff --git a/ell/pem.c b/ell/pem.c
> index d1f180e..058b8b8 100644
> --- a/ell/pem.c
> +++ b/ell/pem.c
> @@ -36,6 +36,8 @@
>   #include "pem.h"
>   #include "base64.h"
>   #include "string.h"
> +#include "asn1-private.h"
> +#include "cipher.h"
>   
>   #define PEM_START_BOUNDARY	"-----BEGIN "
>   #define PEM_END_BOUNDARY	"-----END "
> @@ -232,11 +234,15 @@ LIB_EXPORT uint8_t *l_pem_load_certificate(const char *filename, size_t *len)
>   
>   LIB_EXPORT uint8_t *l_pem_load_private_key(const char *filename,
>   						const char *passphrase,
> +						bool *encrypted,
>   						size_t *len)
>   {
>   	uint8_t *content;
>   	char *label;
>   
> +	if (encrypted)
> +		*encrypted = false;
> +

So we set encrypted even if we fail?  Right now you're not even using 
this parameter, so I wonder if we should maybe introduce a new function, 
like l_pem_is_encrypted() instead?

>   	content = l_pem_load_file(filename, 0, &label, len);
>   
>   	if (!content)

Rest looks good.

Regards,
-Denis

  reply	other threads:[~2017-08-11 20:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-10 23:10 [PATCH 01/10] checksum: Add SHA224 checksum type Andrew Zaborowski
2017-08-10 23:10 ` [PATCH 02/10] cipher: Add DES-CBC cipher type Andrew Zaborowski
2017-08-11 16:08   ` Denis Kenzior
2017-08-10 23:10 ` [PATCH 03/10] tls: Move DER / ASN.1 related definitions to asn1-private.h Andrew Zaborowski
2017-08-11 16:17   ` Denis Kenzior
2017-08-12  0:08     ` Andrew Zaborowski
2017-08-10 23:10 ` [PATCH 04/10] tls: Report error if private key loading fails Andrew Zaborowski
2017-08-11 16:18   ` Denis Kenzior
2017-08-10 23:10 ` [PATCH 05/10] asn1: Use const pointers in ASN1 parsing utilities Andrew Zaborowski
2017-08-10 23:10 ` [PATCH 06/10][RFC] cipher: Implement PKCS#5 key derivation functions Andrew Zaborowski
2017-08-11 16:28   ` Denis Kenzior
2017-08-12  0:12     ` Andrew Zaborowski
2017-08-10 23:10 ` [PATCH 07/10] cipher: Add l_cipher_from_pkcs5_id Andrew Zaborowski
2017-08-11 16:55   ` Denis Kenzior
2017-08-12  0:17     ` Andrew Zaborowski
2017-08-12  0:30       ` Denis Kenzior
2017-08-12  0:40         ` Andrew Zaborowski
2017-08-12  0:42           ` Denis Kenzior
2017-08-10 23:10 ` [PATCH 08/10] pem: Support encrypted keys in l_pem_load_private_key Andrew Zaborowski
2017-08-11 20:23   ` Denis Kenzior [this message]
2017-08-12  0:30     ` Andrew Zaborowski
2017-08-12  0:40       ` Denis Kenzior
2017-08-12  0:45         ` Andrew Zaborowski
2017-08-12  0:49           ` Denis Kenzior
2017-08-10 23:10 ` [PATCH 09/10] unit: Update for l_pem_load_private_key() parameter change Andrew Zaborowski
2017-08-10 23:10 ` [PATCH 10/10] unit: Test loading encrypted private key PEM files Andrew Zaborowski
2017-08-11 20:26   ` Denis Kenzior
2017-08-11 16:07 ` [PATCH 01/10] checksum: Add SHA224 checksum type Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=757437fc-6fa1-6cbf-97a5-be2597ef847b@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ell@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.