Example #1
0
CK_RV dsa_functions()
{
	SYSTEMTIME t1, t2;
	CK_RV rc = CKR_OK;
	CK_SLOT_ID slot_id;

        /** skip tests if the slot doesn't support this mechanism **/
	slot_id = SLOT_ID;
        if (!(mech_supported(slot_id, CKM_DSA))) {
		printf("Slot %u doesn't support DSA\n", (unsigned int) slot_id);
		return rc;
        }

	GetSystemTime(&t1);
	rc = do_GenerateDSAKeyPair();
	if (rc) {
		PRINT_ERR("ERROR do_GenerateDSAKeyPair failed, rc = 0x%lx\n", rc);
		if (!no_stop)
			return rc;
	}
	GetSystemTime(&t2);
	process_time( t1, t2 );

	GetSystemTime(&t1);
	rc = do_SignDSA();
	if (rc) {
		PRINT_ERR("ERROR do_SignDSA failed, rc = 0x%lx\n", rc);
		if (!no_stop)
			return rc;
	}
	GetSystemTime(&t2);
	process_time( t1, t2 );

	return rc;
}
Example #2
0
int main()
{
    size_t offset;
    if (scanf("%lu", &offset) != 1)
    {
        printf("Invalid input!");
        return 1;
    }
    
    FILE *fileSrc = fopen("source.sub", "r");
    if (!fileSrc)
    {
        die(NULL);
    }
    
    FILE *fileDest = fopen("fixed.sub", "w");
    if (!fileDest)
    {
        die(NULL);
    }
    
    char *line = NULL;
    size_t size = 0;
    while (!feof(fileSrc))
    {
        size_t lineLength = getline(&line, &size, fileSrc);
        char *isTimeLine = strstr(line, " -->");
        if (!isTimeLine)
        {
            fwrite(line, 1, lineLength, fileDest);
        }
        else
        {
            char *token = strtok(line, " --> ");
            char *token1 = strtok(NULL, " --> ");
            struct time t1, t2;
            
            process_time(&t1, token, offset);
            process_time(&t2, token1, offset);
            
            char result[30];
            sprintf(result,
                    "%02lu:%02lu:%02lu,%03lu -->%02lu:%02lu:%02lu,%03lu\n",
                    t1.hours, t1.minutes, t1.seconds, t1.milliseconds,
                    t2.hours, t2.minutes, t2.seconds, t2.milliseconds);
            fwrite(result, 1, strlen(result), fileDest);
        }
    }
    
    printf("Fixed!");
    
    free(line);
    fclose(fileSrc);
    fclose(fileDest);
    
    return 0;
}
Example #3
0
BOOL wait_for_srt_entry_time_fraction_end(char c, t_engine_datas *datas, void *engine) {
	if (datas->options->verbose) fprintf(stderr, "Entering wait_for_srt_entry_time_fraction_end; char is \"%c\".\n", c);
	
	if (( datas->parsing_start_time && (isblank(c) || c == '-')) ||
		 (!datas->parsing_start_time && (isblank(c) || c == '\n' || c == '\r'))) {
		process_time(&datas->cur_parsed_time_seconds, &datas->cur_parsed_number, &datas->previous_time, datas->options);
		print_time(datas->cur_parsed_time_seconds, datas->cur_parsed_number, datas->out_fp);
		
		putc(c, datas->out_fp);
		datas->cur_parsed_number = 0;
		
		if (!datas->parsing_start_time) *(f_engine*)engine = &wait_for_blank_line;
		else {
			if (c != '-') *(f_engine*)engine = &wait_for_srt_entry_arrow_start;
			else          *(f_engine*)engine = &wait_for_srt_entry_arrow_middle;
		}
		return YES;
	}
	
	if (!isdigit(c)) return NO;
	datas->cur_parsed_number *= 10;
	datas->cur_parsed_number += c - '0';
	
	return YES;
}
Example #4
0
int do_SessionPerformance(unsigned int count)
{
	SYSTEMTIME        t1, t2;
	int               rc, i;
	context_table_t   *t = NULL;

	if (count == 0) {
		show_error("   do_SessionPerformance: zero session count", (CK_RV)0);
		return FALSE;
	}

	t = (context_table_t *) calloc(count, sizeof(context_table_t));
	if (t == NULL) {
		show_error("    do_SessionPerformance: insuficient memory", (CK_RV)0);
		return FALSE;
	}

	/* create encryption contexts */
	for (i = 0; i < count; i++) {
		rc = create_des_encrypt_context(&(t[i].hsess), &(t[i].hkey));
		if (rc == FALSE) {
			show_error("    create_des_encrypt_context", (CK_RV)0);
			return FALSE;
		}
	}

        /* Time encrypt operation in the first and last session */
	GetSystemTime(&t1);
	rc = encrypt_DATA(t[0].hsess, t[0].hkey, 8);
	if (rc == FALSE) {
		show_error("   encrypt_DATA #1", (CK_RV)0);
		return FALSE;

	}

	rc = encrypt_DATA(t[count - 1].hsess, t[count - 1].hkey, 8);
	if (rc == FALSE) {
		show_error("   encrypt_DATA #2", (CK_RV)0);
		return FALSE;

	}
	GetSystemTime(&t2);
	process_time( t1, t2 );

	for (i = 0; i < count; i++) {
		rc = finalize_des_encrypt_context(t[i].hsess);
		if (rc == FALSE) {
			show_error("    finalize_des_encrypt_context", (CK_RV)0);
			return FALSE;
		}
	}

	return TRUE;
}