Skip to content

Commit

Permalink
[#211] Modify sadb_get_sa_from_spi. Unnecessary NULL comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbrown2 committed Apr 30, 2024
1 parent 58f82ff commit d28cb6e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/sa/internal/sa_interface_inmemory.template.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,16 +439,13 @@ static int32_t sa_close(void)
static int32_t sa_get_from_spi(uint16_t spi, SecurityAssociation_t** security_association)
{
int32_t status = CRYPTO_LIB_SUCCESS;
if (sa == NULL)
{
return CRYPTO_LIB_ERR_NO_INIT;
}
*security_association = &sa[spi];
if (sa[spi].iv == NULL && (sa[spi].shivf_len > 0) && crypto_config.cryptography_type != CRYPTOGRAPHY_TYPE_KMCCRYPTO)
if ((sa[spi].iv == NULL) && (sa[spi].shivf_len > 0) && crypto_config.cryptography_type != CRYPTOGRAPHY_TYPE_KMCCRYPTO)
{
return CRYPTO_LIB_ERR_NULL_IV;
} // Must have IV if doing encryption or authentication
if (sa[spi].abm == NULL && sa[spi].ast)

if ((sa[spi].abm_len == 0) && sa[spi].ast)
{
return CRYPTO_LIB_ERR_NULL_ABM;
} // Must have abm if doing authentication
Expand Down

0 comments on commit d28cb6e

Please sign in to comment.