Example #1
0
static void sha256_sha224_block(struct sha256_sha224_ctx *ctx, const byte * block)
{
    word32 data[SHA256_SHA224_DATA_LENGTH];
    int i;

    /* Update block count */
    ctx->bitcount += 512;

    /* Endian independent conversion */
    for (i = 0; i < SHA256_SHA224_DATA_LENGTH; i++, block += 4)
        data[i] = STRING2INT(block);

    sha256_sha224_transform(ctx->state, data);
}
Example #2
0
void sha256_sha224_final(struct sha256_sha224_ctx *ctx)
{
    word32 data[SHA256_SHA224_DATA_LENGTH];
    int i;
    int words;

    i = ctx->index;

    /* Set the first char of padding to 0x80.  This is safe since there is
       always at least one byte free */

/*  assert(i < SHA256_SHA224_DATA_SIZE);
 */
    ctx->block[i++] = 0x80;

    /* Fill rest of word */
    for (; i & 3; i++)
        ctx->block[i] = 0;

    /* i is now a multiple of the word size 4 */
    words = i >> 2;
    for (i = 0; i < words; i++)
        data[i] = STRING2INT(ctx->block + 4 * i);

    if (words > (SHA256_SHA224_DATA_LENGTH - 2)) {    /* No room for length in this block. 
                            * Process it and pad with another one */
        for (i = words; i < SHA256_SHA224_DATA_LENGTH; i++)
            data[i] = 0;
        sha256_sha224_transform(ctx->state, data);
        for (i = 0; i < (SHA256_SHA224_DATA_LENGTH - 2); i++)
            data[i] = 0;
    } else
        for (i = words; i < SHA256_SHA224_DATA_LENGTH - 2; i++)
            data[i] = 0;

    ctx->bitcount += 8 * ctx->index;
    data[SHA256_SHA224_DATA_LENGTH - 2] =
      ctx->bitcount >> 32;
    data[SHA256_SHA224_DATA_LENGTH - 1] =
      ctx->bitcount & 0xffffffff;
    sha256_sha224_transform(ctx->state, data);
}
Example #3
0
/* This function reads the next statement in the vectors file and
 * schedules a wakeup in the future to process the data.
 */
static void read_next_statement( inst_rec_ptr ip )
{
    char  buf[100];
    char  line[MAX_INPUT_LINE_SIZE];
    char *kw, *timestamp, *signame, *sigval;
    char  values[MAX_PORT_WIDTH];
    int   done = 0;
    int   time, test_type, portnum;

    while ( ! done ) {
        if ( fgets(line, MAX_INPUT_LINE_SIZE, ip->vectorfile_id) != NULL ) {
            kw = strtok(line, " \t\r\n");
            if ( kw && is_drive_or_test_statement(kw) ) {
                timestamp = strtok(NULL, " \t\r\n");
                STRING2INT(timestamp, time);
                while ( (signame = strtok(NULL, " =\t\r\n")) != NULL ) {
                    sigval  = strtok(NULL, " \t\r\n");
                    portnum = findportnum(signame);
                    if ( portnum >= 0 ) {
                        convert_mvl9_string_to_enums( sigval, values,
                                                   tester_ports[portnum].width);
                        test_type = is_drive_statement(kw) ? DRIVE : TEST;
                        schedule_testpoint( ip, portnum, values, time,
                                           test_type );
                    } else {
                        sprintf(buf, "Can't find port named \"%s\".\n",
                                signame);
                        mti_PrintMessage(buf);
                    }
                }
                done = 1;
            }
        } else {
            done = 1; /* found end of file */
        }
    }
}