version 1.1.1.6, 2016/03/11 01:50:02 |
version 1.1.1.7, 2016/08/02 13:30:10 |
|
|
/* $OpenBSD: sshkey.c,v 1.31 2015/12/11 04:21:12 mmcc Exp $ */ |
/* $OpenBSD: sshkey.c,v 1.35 2016/06/19 07:48:02 djm Exp $ */ |
/* |
/* |
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. |
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. |
* Copyright (c) 2008 Alexander von Gernler. All rights reserved. |
* Copyright (c) 2008 Alexander von Gernler. All rights reserved. |
Line 1930 sshkey_from_blob_internal(struct sshbuf |
|
Line 1930 sshkey_from_blob_internal(struct sshbuf |
|
#ifdef DEBUG_PK /* XXX */ |
#ifdef DEBUG_PK /* XXX */ |
sshbuf_dump(b, stderr); |
sshbuf_dump(b, stderr); |
#endif |
#endif |
*keyp = NULL; |
if (keyp != NULL) |
|
*keyp = NULL; |
if ((copy = sshbuf_fromb(b)) == NULL) { |
if ((copy = sshbuf_fromb(b)) == NULL) { |
ret = SSH_ERR_ALLOC_FAIL; |
ret = SSH_ERR_ALLOC_FAIL; |
goto out; |
goto out; |
Line 2083 sshkey_from_blob_internal(struct sshbuf |
|
Line 2084 sshkey_from_blob_internal(struct sshbuf |
|
goto out; |
goto out; |
} |
} |
ret = 0; |
ret = 0; |
*keyp = key; |
if (keyp != NULL) { |
key = NULL; |
*keyp = key; |
|
key = NULL; |
|
} |
out: |
out: |
sshbuf_free(copy); |
sshbuf_free(copy); |
sshkey_free(key); |
sshkey_free(key); |
Line 2323 sshkey_drop_cert(struct sshkey *k) |
|
Line 2326 sshkey_drop_cert(struct sshkey *k) |
|
|
|
/* Sign a certified key, (re-)generating the signed certblob. */ |
/* Sign a certified key, (re-)generating the signed certblob. */ |
int |
int |
sshkey_certify(struct sshkey *k, struct sshkey *ca) |
sshkey_certify(struct sshkey *k, struct sshkey *ca, const char *alg) |
{ |
{ |
struct sshbuf *principals = NULL; |
struct sshbuf *principals = NULL; |
u_char *ca_blob = NULL, *sig_blob = NULL, nonce[32]; |
u_char *ca_blob = NULL, *sig_blob = NULL, nonce[32]; |
Line 2411 sshkey_certify(struct sshkey *k, struct |
|
Line 2414 sshkey_certify(struct sshkey *k, struct |
|
|
|
/* Sign the whole mess */ |
/* Sign the whole mess */ |
if ((ret = sshkey_sign(ca, &sig_blob, &sig_len, sshbuf_ptr(cert), |
if ((ret = sshkey_sign(ca, &sig_blob, &sig_len, sshbuf_ptr(cert), |
sshbuf_len(cert), NULL, 0)) != 0) |
sshbuf_len(cert), alg, 0)) != 0) |
goto out; |
goto out; |
|
|
/* Append signature and we are done */ |
/* Append signature and we are done */ |
Line 3575 sshkey_parse_public_rsa1_fileblob(struct |
|
Line 3578 sshkey_parse_public_rsa1_fileblob(struct |
|
/* The encrypted private part is not parsed by this function. */ |
/* The encrypted private part is not parsed by this function. */ |
|
|
r = 0; |
r = 0; |
if (keyp != NULL) |
if (keyp != NULL) { |
*keyp = pub; |
*keyp = pub; |
else |
pub = NULL; |
sshkey_free(pub); |
} |
pub = NULL; |
|
|
|
out: |
out: |
sshbuf_free(copy); |
sshbuf_free(copy); |
sshkey_free(pub); |
sshkey_free(pub); |
Line 3601 sshkey_parse_private_rsa1(struct sshbuf |
|
Line 3602 sshkey_parse_private_rsa1(struct sshbuf |
|
const struct sshcipher *cipher; |
const struct sshcipher *cipher; |
struct sshkey *prv = NULL; |
struct sshkey *prv = NULL; |
|
|
*keyp = NULL; |
if (keyp != NULL) |
|
*keyp = NULL; |
if (commentp != NULL) |
if (commentp != NULL) |
*commentp = NULL; |
*commentp = NULL; |
|
|
Line 3687 sshkey_parse_private_rsa1(struct sshbuf |
|
Line 3689 sshkey_parse_private_rsa1(struct sshbuf |
|
goto out; |
goto out; |
} |
} |
r = 0; |
r = 0; |
*keyp = prv; |
if (keyp != NULL) { |
prv = NULL; |
*keyp = prv; |
|
prv = NULL; |
|
} |
if (commentp != NULL) { |
if (commentp != NULL) { |
*commentp = comment; |
*commentp = comment; |
comment = NULL; |
comment = NULL; |
Line 3713 sshkey_parse_private_pem_fileblob(struct |
|
Line 3717 sshkey_parse_private_pem_fileblob(struct |
|
BIO *bio = NULL; |
BIO *bio = NULL; |
int r; |
int r; |
|
|
*keyp = NULL; |
if (keyp != NULL) |
|
*keyp = NULL; |
|
|
if ((bio = BIO_new(BIO_s_mem())) == NULL || sshbuf_len(blob) > INT_MAX) |
if ((bio = BIO_new(BIO_s_mem())) == NULL || sshbuf_len(blob) > INT_MAX) |
return SSH_ERR_ALLOC_FAIL; |
return SSH_ERR_ALLOC_FAIL; |
Line 3780 sshkey_parse_private_pem_fileblob(struct |
|
Line 3785 sshkey_parse_private_pem_fileblob(struct |
|
goto out; |
goto out; |
} |
} |
r = 0; |
r = 0; |
*keyp = prv; |
if (keyp != NULL) { |
prv = NULL; |
*keyp = prv; |
|
prv = NULL; |
|
} |
out: |
out: |
BIO_free(bio); |
BIO_free(bio); |
if (pk != NULL) |
if (pk != NULL) |
|
|
sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type, |
sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type, |
const char *passphrase, struct sshkey **keyp, char **commentp) |
const char *passphrase, struct sshkey **keyp, char **commentp) |
{ |
{ |
*keyp = NULL; |
if (keyp != NULL) |
|
*keyp = NULL; |
if (commentp != NULL) |
if (commentp != NULL) |
*commentp = NULL; |
*commentp = NULL; |
|
|