void KeccakP200_StatePermute(void *state, unsigned int nr)
{
    displayStateAsBytes(1, "Input of permutation", (const unsigned char *)state);
    for(nr=nrRounds-nr; nr<nrRounds; nr++)
		KeccakF200Round(state, nr);
    displayStateAsBytes(1, "State after permutation", (const unsigned char *)state);
}
void KeccakP200_StatePermute(void *state, unsigned int nr)
{
    displayStateAsBytes(1, "Input of permutation", (const unsigned char *)state);
    for(nr=nrRounds-nr; nr<nrRounds; nr++)
        // CHANGE static cast added
		KeccakF200Round(static_cast<tKeccakLane*>(state), nr);
    displayStateAsBytes(1, "State after permutation", (const unsigned char *)state);
}
void KeccakP800_12_StatePermute(void *state)
{
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
    tKeccakLane stateAsWords[KeccakF_width/32];
#endif

    displayStateAsBytes(1, "Input of permutation", (const unsigned char *)state);
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
    KeccakP800_12_OnWords((tKeccakLane*)state);
#else
    fromBytesToWords(stateAsWords, (const unsigned char *)state);
    KeccakP800_12_OnWords(stateAsWords);
    fromWordsToBytes((unsigned char *)state, stateAsWords);
#endif
    displayStateAsBytes(1, "State after permutation", (const unsigned char *)state);
}
示例#4
0
void displayDuplexIntermediateValuesOne(FILE *f, unsigned int rate, unsigned int capacity)
{
    Keccak_DuplexInstance duplex;
    unsigned char input[512];
    unsigned int inBitLen;
    unsigned char output[512];
    unsigned int outBitLen;
    unsigned int i, j;
    const unsigned int M = 239*251;
    unsigned int x = 33;

    Keccak_DuplexInitialize(&duplex, rate, capacity);
    displayStateAsBytes(1, "Initial state", duplex.state);
    
    for(i=0; i<=rate+120; i+=123) {
        inBitLen = i;
        if (inBitLen > (rate-2)) inBitLen = rate-2;
        memset(input, 0, 512);
        for(j=0; j<inBitLen; j++) {
            x = (x*x) % M;
            if ((x % 2) != 0)
                input[j/8] |= 1 << (j%8);
        }
        {
            char text[100];
            sprintf(text, "Input (%d bits)", inBitLen);
            displayBytes(1, text, input, (inBitLen+7)/8);
        }
        outBitLen = rate;
        if ((inBitLen%8) == 0)
            Keccak_Duplexing(&duplex, input, inBitLen/8, output, (outBitLen+7)/8, 0x01);
        else
            Keccak_Duplexing(&duplex, input, inBitLen/8, output, (outBitLen+7)/8, input[inBitLen/8] | (1 << (inBitLen%8)));
        {
            char text[100];
            sprintf(text, "Output (%d bits)", outBitLen);
            displayBytes(1, text, output, (outBitLen+7)/8);
        }
    }
}
示例#5
0
void displaySpongeIntermediateValuesOne(const unsigned char *message, unsigned int messageLength, unsigned int rate, unsigned int capacity)
{
    Keccak_SpongeInstance sponge;
    unsigned char output[512];
    unsigned char *messageInternal;

    messageInternal = malloc((messageLength+7)/8);
    alignLastByteOnLSB(message, messageInternal, messageLength);

    displayBytes(1, "Input message (last byte aligned on MSB)", message, (messageLength+7)/8);
    displayBits(2, "Input message (in bits)", message, messageLength, 1);
    displayBits(2, "Input message (in bits, after the formal bit reordering)", messageInternal, messageLength, 0);
    displayBytes(2, "Input message (last byte aligned on LSB)", messageInternal, (messageLength+7)/8);

    Keccak_SpongeInitialize(&sponge, rate, capacity);
    displayStateAsBytes(1, "Initial state", sponge.state);
    Keccak_SpongeAbsorb(&sponge, messageInternal, messageLength/8);
    if ((messageLength % 8) != 0)
        Keccak_SpongeAbsorbLastFewBits(&sponge, messageInternal[messageLength/8] | (1 << (messageLength % 8)));
    Keccak_SpongeSqueeze(&sponge, output, sizeof(output));

    free(messageInternal);
}