Skip to content

Questionable data transfer inference in conditional statements #66

@acalvert

Description

@acalvert

The Inferences copyout finalK rather than copy it. However, finalK is conditionally assigned - if we copy it out and the assignment didn't occur, we copy out garbage and overwrite what was initialized.

Occurs when introducing a data construct around this loop:

for (uint32_t i = 0; i < 0xFFFFFFFFL && !setFinalK; i += 65535) {
#pragma acc parallel loop copyin(i) copyout(setFinalK)
            for (uint32_t j = 0; j < 65535; j++) {
                uint32_t fakeK = i + j;
                int32_t score = 0;
                for (int32_t c = 0; c < numPlain; c++) {
                    uint32_t cipherLeft = (cipher0[c] >> 32LL);
                    cipherLeft ^= (cipher1[c] >> 32LL);
                    uint32_t cipherRight = cipher0[c] & 0xFFFFFFFFLL;
                    cipherRight ^= (cipher1[c] & 0xFFFFFFFFLL);
                    uint32_t Y = cipherRight;
                    uint32_t Z = cipherLeft ^ outdiff;
                    uint32_t fakeRight = cipher0[c] & 0xFFFFFFFFLL;
                    uint32_t fakeLeft = cipher0[c] >> 32LL;
                    uint32_t fakeRight2 = cipher1[c] & 0xFFFFFFFFLL;
                    uint32_t fakeLeft2 = cipher1[c] >> 32LL;
                    uint32_t Y0 = fakeRight;
                    uint32_t Y1 = fakeRight2;
                    int32_t fakeInput0 = Y0 ^ fakeK;
                    uint32_t fakeInput1 = Y1 ^ fakeK;
                    uint32_t fakeOut0 = fBox(fakeInput0);
                    uint32_t fakeOut1 = fBox(fakeInput1);
                    uint32_t fakeDiff = fakeOut0 ^ fakeOut1;
                    if (fakeDiff == Z) {
                        score++;
                    } else {
                        break;
                    }
                }
                if (score == numPlain) {
                    finalK = fakeK;
                    setFinalK = 1;
                }
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions