Exemplo n.º 1
0
TPM_RESULT TPM_Sbuffer_Test(void)
{
    TPM_RESULT  rc = 0;
    TPM_STORE_BUFFER sbuffer;
    size_t total_count;
    unsigned char count;
    unsigned char data[256];    /* dummy data */
    
    printf(" TPM_Sbuffer_Test:\n");
    TPM_Sbuffer_Init(&sbuffer);
    total_count = 0;
    while ((total_count != TPM_ALLOC_MAX) && rc == 0) {
        if (rc == 0) {
            rc = TPM_Random(&count, 1);
        }
        if (rc == 0) {
            printf(" TPM_Sbuffer_Test: count %u\n", count);
            /* last time through */
            if (total_count + count > TPM_ALLOC_MAX) {
                count = TPM_ALLOC_MAX - total_count;
            }
            rc = TPM_Sbuffer_Append(&sbuffer,data, count);
        }
        if (rc == 0) {
            total_count += count;
        }
        printf(" TPM_Sbuffer_Test: total_count %lu\n", (unsigned long)total_count);
    }
    TPM_Sbuffer_Delete(&sbuffer);
    return rc;
}
Exemplo n.º 2
0
TPM_RESULT TPM_Nonce_Generate(TPM_NONCE tpm_nonce)
{
    TPM_RESULT  rc = 0;

    printf("  TPM_Nonce_Generate:\n");
    rc = TPM_Random(tpm_nonce, TPM_NONCE_SIZE);
    return rc;
}