summaryrefslogtreecommitdiff
path: root/futility/vb2_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'futility/vb2_helper.c')
-rw-r--r--futility/vb2_helper.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/futility/vb2_helper.c b/futility/vb2_helper.c
index 4ee0a28b..51a78375 100644
--- a/futility/vb2_helper.c
+++ b/futility/vb2_helper.c
@@ -184,6 +184,11 @@ static RSA *rsa_from_buffer(uint8_t *buf, uint32_t len)
rsa_key = PEM_read_bio_RSAPrivateKey(bp, NULL, NULL, NULL);
if (!rsa_key) {
+ if (BIO_reset(bp) < 0)
+ return 0;
+ rsa_key = PEM_read_bio_RSA_PUBKEY(bp, NULL, NULL, NULL);
+ }
+ if (!rsa_key) {
BIO_free(bp);
return 0;
}
@@ -212,13 +217,15 @@ int ft_show_pem(const char *name, uint8_t *buf, uint32_t len, void *data)
uint32_t keyb_len;
int i, bits;
- printf("Private Key file: %s\n", name);
-
/* We're called only after ft_recognize_pem, so this should work. */
rsa_key = rsa_from_buffer(buf, len);
if (!rsa_key)
DIE;
+ /* Use to presence of the private exponent to decide if it's public */
+ printf("%s Key file: %s\n", rsa_key->d ? "Private" : "Public",
+ name);
+
bits = BN_num_bits(rsa_key->n);
printf(" Key length: %d\n", bits);