mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
mbedtls: Rename label to match the current meaning
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
(cherry picked from commit b314fd3e04)
This commit is contained in:
@@ -930,7 +930,7 @@ ssh_string pki_key_to_blob(const ssh_key key, enum ssh_key_e type)
|
|||||||
#if MBEDTLS_VERSION_MAJOR > 2
|
#if MBEDTLS_VERSION_MAJOR > 2
|
||||||
rc = mbedtls_rsa_export(rsa, &N, NULL, NULL, NULL, &E);
|
rc = mbedtls_rsa_export(rsa, &N, NULL, NULL, NULL, &E);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
E_ptr = &E;
|
E_ptr = &E;
|
||||||
@@ -942,24 +942,24 @@ ssh_string pki_key_to_blob(const ssh_key key, enum ssh_key_e type)
|
|||||||
|
|
||||||
e = ssh_make_bignum_string(E_ptr);
|
e = ssh_make_bignum_string(E_ptr);
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = ssh_make_bignum_string(N_ptr);
|
n = ssh_make_bignum_string(N_ptr);
|
||||||
if (n == NULL) {
|
if (n == NULL) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == SSH_KEY_PUBLIC) {
|
if (type == SSH_KEY_PUBLIC) {
|
||||||
/* The N and E parts are swapped in the public key export ! */
|
/* The N and E parts are swapped in the public key export ! */
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, e);
|
rc = ssh_buffer_add_ssh_string(buffer, e);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, n);
|
rc = ssh_buffer_add_ssh_string(buffer, n);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
} else if (type == SSH_KEY_PRIVATE) {
|
} else if (type == SSH_KEY_PRIVATE) {
|
||||||
mbedtls_mpi *P_ptr = NULL, *Q_ptr = NULL, *D_ptr = NULL;
|
mbedtls_mpi *P_ptr = NULL, *Q_ptr = NULL, *D_ptr = NULL;
|
||||||
@@ -967,23 +967,23 @@ ssh_string pki_key_to_blob(const ssh_key key, enum ssh_key_e type)
|
|||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, n);
|
rc = ssh_buffer_add_ssh_string(buffer, n);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, e);
|
rc = ssh_buffer_add_ssh_string(buffer, e);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MBEDTLS_VERSION_MAJOR > 2
|
#if MBEDTLS_VERSION_MAJOR > 2
|
||||||
rc = mbedtls_rsa_export(rsa, NULL, &P, &Q, &D, NULL);
|
rc = mbedtls_rsa_export(rsa, NULL, &P, &Q, &D, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = mbedtls_rsa_export_crt(rsa, NULL, NULL, &IQMP);
|
rc = mbedtls_rsa_export_crt(rsa, NULL, NULL, &IQMP);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
P_ptr = &P;
|
P_ptr = &P;
|
||||||
@@ -999,42 +999,42 @@ ssh_string pki_key_to_blob(const ssh_key key, enum ssh_key_e type)
|
|||||||
|
|
||||||
p = ssh_make_bignum_string(P_ptr);
|
p = ssh_make_bignum_string(P_ptr);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
q = ssh_make_bignum_string(Q_ptr);
|
q = ssh_make_bignum_string(Q_ptr);
|
||||||
if (q == NULL) {
|
if (q == NULL) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
d = ssh_make_bignum_string(D_ptr);
|
d = ssh_make_bignum_string(D_ptr);
|
||||||
if (d == NULL) {
|
if (d == NULL) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
iqmp = ssh_make_bignum_string(IQMP_ptr);
|
iqmp = ssh_make_bignum_string(IQMP_ptr);
|
||||||
if (iqmp == NULL) {
|
if (iqmp == NULL) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, d);
|
rc = ssh_buffer_add_ssh_string(buffer, d);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, iqmp);
|
rc = ssh_buffer_add_ssh_string(buffer, iqmp);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, p);
|
rc = ssh_buffer_add_ssh_string(buffer, p);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, q);
|
rc = ssh_buffer_add_ssh_string(buffer, q);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1067,7 +1067,7 @@ ssh_string pki_key_to_blob(const ssh_key key, enum ssh_key_e type)
|
|||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, e);
|
rc = ssh_buffer_add_ssh_string(buffer, e);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == SSH_KEY_PRIVATE) {
|
if (type == SSH_KEY_PRIVATE) {
|
||||||
@@ -1080,13 +1080,13 @@ ssh_string pki_key_to_blob(const ssh_key key, enum ssh_key_e type)
|
|||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, d);
|
rc = ssh_buffer_add_ssh_string(buffer, d);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
} else if (key->type == SSH_KEYTYPE_SK_ECDSA) {
|
} else if (key->type == SSH_KEYTYPE_SK_ECDSA) {
|
||||||
/* public key can contain certificate sk information */
|
/* public key can contain certificate sk information */
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, key->sk_application);
|
rc = ssh_buffer_add_ssh_string(buffer, key->sk_application);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1095,29 +1095,29 @@ ssh_string pki_key_to_blob(const ssh_key key, enum ssh_key_e type)
|
|||||||
if (type == SSH_KEY_PUBLIC) {
|
if (type == SSH_KEY_PUBLIC) {
|
||||||
rc = pki_ed25519_public_key_to_blob(buffer, key);
|
rc = pki_ed25519_public_key_to_blob(buffer, key);
|
||||||
if (rc == SSH_ERROR) {
|
if (rc == SSH_ERROR) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
/* public key can contain certificate sk information */
|
/* public key can contain certificate sk information */
|
||||||
if (key->type == SSH_KEYTYPE_SK_ED25519) {
|
if (key->type == SSH_KEYTYPE_SK_ED25519) {
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, key->sk_application);
|
rc = ssh_buffer_add_ssh_string(buffer, key->sk_application);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rc = pki_ed25519_private_key_to_blob(buffer, key);
|
rc = pki_ed25519_private_key_to_blob(buffer, key);
|
||||||
if (rc == SSH_ERROR) {
|
if (rc == SSH_ERROR) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
makestring:
|
makestring:
|
||||||
str = ssh_string_new(ssh_buffer_get_len(buffer));
|
str = ssh_string_new(ssh_buffer_get_len(buffer));
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_string_fill(str,
|
rc = ssh_string_fill(str,
|
||||||
@@ -1126,10 +1126,9 @@ makestring:
|
|||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ssh_string_burn(str);
|
ssh_string_burn(str);
|
||||||
SSH_STRING_FREE(str);
|
SSH_STRING_FREE(str);
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
out:
|
||||||
SSH_BUFFER_FREE(buffer);
|
SSH_BUFFER_FREE(buffer);
|
||||||
ssh_string_burn(e);
|
ssh_string_burn(e);
|
||||||
SSH_STRING_FREE(e);
|
SSH_STRING_FREE(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user