mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-22 12:34:19 +00:00
fix(cert-create): key: Avoid having a temporary value for pkey in key_load
key->key and k will point to the same if PEM_read_PrivateKey (pem_read_bio_key_decoder) succeeds. There is no need for the temporary 'k' pointer here. Signed-off-by: Robin van der Gracht <robin@protonic.nl> Change-Id: I219c49d331eb6dd7200b49b75d47fd66da3d82dd
This commit is contained in:
parent
cd83a766d5
commit
ea6f8452f6
1 changed files with 2 additions and 3 deletions
|
@ -192,15 +192,14 @@ int key_create(key_t *key, int type, int key_bits)
|
||||||
int key_load(key_t *key, unsigned int *err_code)
|
int key_load(key_t *key, unsigned int *err_code)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
EVP_PKEY *k;
|
|
||||||
|
|
||||||
if (key->fn) {
|
if (key->fn) {
|
||||||
/* Load key from file */
|
/* Load key from file */
|
||||||
fp = fopen(key->fn, "r");
|
fp = fopen(key->fn, "r");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
k = PEM_read_PrivateKey(fp, &key->key, NULL, NULL);
|
key->key = PEM_read_PrivateKey(fp, NULL, NULL, NULL);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (k) {
|
if (key->key) {
|
||||||
*err_code = KEY_ERR_NONE;
|
*err_code = KEY_ERR_NONE;
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue