Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static int32_t sadb_sa_setARSN(void) #47

Open
Peco602 opened this issue Jan 4, 2022 · 3 comments
Open

static int32_t sadb_sa_setARSN(void) #47

Peco602 opened this issue Jan 4, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@Peco602
Copy link

Peco602 commented Jan 4, 2022

This function should set the Anti-Replay Counter, but it sets the Initialization Vector.

@jlucas9 jlucas9 moved this to In Progress in CryptoLib Path Forward Aug 23, 2022
@jlucas9 jlucas9 moved this from In Progress to Planned Next Release in CryptoLib Path Forward Mar 23, 2023
@jlucas9 jlucas9 added the bug Something isn't working label Jun 21, 2023
@jlucas9 jlucas9 self-assigned this Jul 24, 2023
@jlucas9 jlucas9 moved this from Planned Next Release to Backlog in CryptoLib Path Forward Sep 13, 2023
@rjbrown2
Copy link
Member

rjbrown2 commented Oct 18, 2023

/**
 * @brief Function: sadb_sa_setASRN
 * @return int32: Success/Failure
 **/
static int32_t sadb_sa_setARSN(void)
{
    // Local variables
    uint16_t spi = 0x0000;
    int x;

    // Read ingest
    spi = ((uint8_t)sdls_frame.pdu.data[0] << 8) | (uint8_t)sdls_frame.pdu.data[1];
    printf("spi = %d \n", spi);

    // TODO: Check SA type (authenticated, encrypted, both) and set appropriately
    // TODO: Add more checks on bounds

    // Check SPI exists
    if (spi < NUM_SA)
    {
#ifdef PDU_DEBUG
        printf("SPI %d IV updated to: 0x", spi);
#endif
        if (sa[spi].shivf_len > 0)
        { // Set IV - authenticated encryption
            for (x = 0; x < IV_SIZE; x++)
            {
                *(sa[spi].iv + x) = (uint8_t)sdls_frame.pdu.data[x + 2];
#ifdef PDU_DEBUG
                printf("%02x", *(sa[spi].iv + x));
#endif
            }
            Crypto_increment(sa[spi].iv, sa[spi].shivf_len);
        }
        else
        { // Set SN
          // TODO
        }
#ifdef PDU_DEBUG
        printf("\n");
#endif
    }
    else
    {
        printf("sadb_sa_setARSN ERROR: SPI %d does not exist.\n", spi);
    }

    return CRYPTO_LIB_SUCCESS;
}

@rjbrown2
Copy link
Member

This is valid. The shivf and iv variables should all be changed to shsnf and arsn, and then validated.

@Donnie-Ice
Copy link
Contributor

This may have been fixed as part of #148 (sa_interface_inmemory sa_setARSN)

@rjbrown2, should all references to IV be removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

When branches are created from issues, their pull requests are automatically linked.

4 participants