diff options
Diffstat (limited to 'sshkey.c')
-rw-r--r-- | sshkey.c | 26 |
1 files changed, 7 insertions, 19 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshkey.c,v 1.7 2014/12/21 22:27:55 djm Exp $ */ | 1 | /* $OpenBSD: sshkey.c,v 1.8 2015/01/08 10:14:08 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2008 Alexander von Gernler. All rights reserved. | 4 | * Copyright (c) 2008 Alexander von Gernler. All rights reserved. |
@@ -3719,20 +3719,16 @@ sshkey_parse_private_rsa1(struct sshbuf *blob, const char *passphrase, | |||
3719 | #endif /* WITH_SSH1 */ | 3719 | #endif /* WITH_SSH1 */ |
3720 | 3720 | ||
3721 | #ifdef WITH_OPENSSL | 3721 | #ifdef WITH_OPENSSL |
3722 | /* XXX make private once ssh-keysign.c fixed */ | 3722 | static int |
3723 | int | ||
3724 | sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type, | 3723 | sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type, |
3725 | const char *passphrase, struct sshkey **keyp, char **commentp) | 3724 | const char *passphrase, struct sshkey **keyp) |
3726 | { | 3725 | { |
3727 | EVP_PKEY *pk = NULL; | 3726 | EVP_PKEY *pk = NULL; |
3728 | struct sshkey *prv = NULL; | 3727 | struct sshkey *prv = NULL; |
3729 | char *name = "<no key>"; | ||
3730 | BIO *bio = NULL; | 3728 | BIO *bio = NULL; |
3731 | int r; | 3729 | int r; |
3732 | 3730 | ||
3733 | *keyp = NULL; | 3731 | *keyp = NULL; |
3734 | if (commentp != NULL) | ||
3735 | *commentp = NULL; | ||
3736 | 3732 | ||
3737 | if ((bio = BIO_new(BIO_s_mem())) == NULL || sshbuf_len(blob) > INT_MAX) | 3733 | if ((bio = BIO_new(BIO_s_mem())) == NULL || sshbuf_len(blob) > INT_MAX) |
3738 | return SSH_ERR_ALLOC_FAIL; | 3734 | return SSH_ERR_ALLOC_FAIL; |
@@ -3755,7 +3751,6 @@ sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type, | |||
3755 | } | 3751 | } |
3756 | prv->rsa = EVP_PKEY_get1_RSA(pk); | 3752 | prv->rsa = EVP_PKEY_get1_RSA(pk); |
3757 | prv->type = KEY_RSA; | 3753 | prv->type = KEY_RSA; |
3758 | name = "rsa w/o comment"; | ||
3759 | #ifdef DEBUG_PK | 3754 | #ifdef DEBUG_PK |
3760 | RSA_print_fp(stderr, prv->rsa, 8); | 3755 | RSA_print_fp(stderr, prv->rsa, 8); |
3761 | #endif | 3756 | #endif |
@@ -3771,7 +3766,6 @@ sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type, | |||
3771 | } | 3766 | } |
3772 | prv->dsa = EVP_PKEY_get1_DSA(pk); | 3767 | prv->dsa = EVP_PKEY_get1_DSA(pk); |
3773 | prv->type = KEY_DSA; | 3768 | prv->type = KEY_DSA; |
3774 | name = "dsa w/o comment"; | ||
3775 | #ifdef DEBUG_PK | 3769 | #ifdef DEBUG_PK |
3776 | DSA_print_fp(stderr, prv->dsa, 8); | 3770 | DSA_print_fp(stderr, prv->dsa, 8); |
3777 | #endif | 3771 | #endif |
@@ -3793,7 +3787,6 @@ sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type, | |||
3793 | r = SSH_ERR_INVALID_FORMAT; | 3787 | r = SSH_ERR_INVALID_FORMAT; |
3794 | goto out; | 3788 | goto out; |
3795 | } | 3789 | } |
3796 | name = "ecdsa w/o comment"; | ||
3797 | # ifdef DEBUG_PK | 3790 | # ifdef DEBUG_PK |
3798 | if (prv != NULL && prv->ecdsa != NULL) | 3791 | if (prv != NULL && prv->ecdsa != NULL) |
3799 | sshkey_dump_ec_key(prv->ecdsa); | 3792 | sshkey_dump_ec_key(prv->ecdsa); |
@@ -3803,11 +3796,6 @@ sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type, | |||
3803 | r = SSH_ERR_INVALID_FORMAT; | 3796 | r = SSH_ERR_INVALID_FORMAT; |
3804 | goto out; | 3797 | goto out; |
3805 | } | 3798 | } |
3806 | if (commentp != NULL && | ||
3807 | (*commentp = strdup(name)) == NULL) { | ||
3808 | r = SSH_ERR_ALLOC_FAIL; | ||
3809 | goto out; | ||
3810 | } | ||
3811 | r = 0; | 3799 | r = 0; |
3812 | *keyp = prv; | 3800 | *keyp = prv; |
3813 | prv = NULL; | 3801 | prv = NULL; |
@@ -3839,8 +3827,8 @@ sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type, | |||
3839 | case KEY_DSA: | 3827 | case KEY_DSA: |
3840 | case KEY_ECDSA: | 3828 | case KEY_ECDSA: |
3841 | case KEY_RSA: | 3829 | case KEY_RSA: |
3842 | return sshkey_parse_private_pem_fileblob(blob, type, passphrase, | 3830 | return sshkey_parse_private_pem_fileblob(blob, type, |
3843 | keyp, commentp); | 3831 | passphrase, keyp); |
3844 | #endif /* WITH_OPENSSL */ | 3832 | #endif /* WITH_OPENSSL */ |
3845 | case KEY_ED25519: | 3833 | case KEY_ED25519: |
3846 | return sshkey_parse_private2(blob, type, passphrase, | 3834 | return sshkey_parse_private2(blob, type, passphrase, |
@@ -3850,8 +3838,8 @@ sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type, | |||
3850 | commentp)) == 0) | 3838 | commentp)) == 0) |
3851 | return 0; | 3839 | return 0; |
3852 | #ifdef WITH_OPENSSL | 3840 | #ifdef WITH_OPENSSL |
3853 | return sshkey_parse_private_pem_fileblob(blob, type, passphrase, | 3841 | return sshkey_parse_private_pem_fileblob(blob, type, |
3854 | keyp, commentp); | 3842 | passphrase, keyp); |
3855 | #else | 3843 | #else |
3856 | return SSH_ERR_INVALID_FORMAT; | 3844 | return SSH_ERR_INVALID_FORMAT; |
3857 | #endif /* WITH_OPENSSL */ | 3845 | #endif /* WITH_OPENSSL */ |