diffie-hellman: Use bool instead of status_t as get_shared_secret() return value

While such a change is not unproblematic, keeping status_t makes the API
inconsistent once we introduce return values for the public value operations.
This commit is contained in:
Martin Willi
2015-03-23 17:54:02 +01:00
parent 4909612c3b
commit bace1d6479
18 changed files with 41 additions and 43 deletions
+3 -3
View File
@@ -138,15 +138,15 @@ METHOD(diffie_hellman_t, get_my_public_value, void,
*value = export_mpi(this->ya, this->p_len);
}
METHOD(diffie_hellman_t, get_shared_secret, status_t,
METHOD(diffie_hellman_t, get_shared_secret, bool,
private_gcrypt_dh_t *this, chunk_t *secret)
{
if (!this->zz)
{
return FAILED;
return FALSE;
}
*secret = export_mpi(this->zz, this->p_len);
return SUCCESS;
return TRUE;
}
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
@@ -155,20 +155,20 @@ METHOD(diffie_hellman_t, get_my_public_value, void,
}
}
METHOD(diffie_hellman_t, get_shared_secret, status_t,
METHOD(diffie_hellman_t, get_shared_secret, bool,
private_gmp_diffie_hellman_t *this, chunk_t *secret)
{
if (!this->computed)
{
return FAILED;
return FALSE;
}
secret->len = this->p_len;
secret->ptr = mpz_export(NULL, NULL, 1, secret->len, 1, 0, this->zz);
if (secret->ptr == NULL)
{
return FAILED;
return FALSE;
}
return SUCCESS;
return TRUE;
}
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+3 -3
View File
@@ -139,17 +139,17 @@ METHOD(diffie_hellman_t, get_my_public_value, void,
}
}
METHOD(diffie_hellman_t, get_shared_secret, status_t,
METHOD(diffie_hellman_t, get_shared_secret, bool,
private_ntru_ke_t *this, chunk_t *secret)
{
if (!this->computed || !this->shared_secret.len)
{
*secret = chunk_empty;
return FAILED;
return FALSE;
}
*secret = chunk_clone(this->shared_secret);
return SUCCESS;
return TRUE;
}
@@ -70,19 +70,19 @@ METHOD(diffie_hellman_t, get_my_public_value, void,
value->ptr + value->len - BN_num_bytes(this->dh->pub_key));
}
METHOD(diffie_hellman_t, get_shared_secret, status_t,
METHOD(diffie_hellman_t, get_shared_secret, bool,
private_openssl_diffie_hellman_t *this, chunk_t *secret)
{
if (!this->computed)
{
return FAILED;
return FALSE;
}
/* shared secret should requires a len according the DH group */
*secret = chunk_alloc(DH_size(this->dh));
memset(secret->ptr, 0, secret->len);
memcpy(secret->ptr + secret->len - this->shared_secret.len,
this->shared_secret.ptr, this->shared_secret.len);
return SUCCESS;
return TRUE;
}
@@ -241,15 +241,15 @@ METHOD(diffie_hellman_t, get_my_public_value, void,
ecp2chunk(this->ec_group, EC_KEY_get0_public_key(this->key), value, FALSE);
}
METHOD(diffie_hellman_t, get_shared_secret, status_t,
METHOD(diffie_hellman_t, get_shared_secret, bool,
private_openssl_ec_diffie_hellman_t *this, chunk_t *secret)
{
if (!this->computed)
{
return FAILED;
return FALSE;
}
*secret = chunk_clone(this->shared_secret);
return SUCCESS;
return TRUE;
}
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+3 -3
View File
@@ -154,15 +154,15 @@ METHOD(diffie_hellman_t, get_my_public_value, void,
*value = chunk_clone(this->pub_key);
}
METHOD(diffie_hellman_t, get_shared_secret, status_t,
METHOD(diffie_hellman_t, get_shared_secret, bool,
private_pkcs11_dh_t *this, chunk_t *secret)
{
if (!this->secret.ptr)
{
return FAILED;
return FALSE;
}
*secret = chunk_clone(this->secret);
return SUCCESS;
return TRUE;
}
METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,