verifier.c revision 1.1.1.1
1 2/* 3 * Licensed Materials - Property of IBM 4 * 5 * trousers - An open source TCG Software Stack 6 * 7 * (C) Copyright International Business Machines Corp. 2006 8 * 9 */ 10 11 12#include <stdlib.h> 13#include <stdio.h> 14#include <string.h> 15 16#include "bi.h" 17#include "daa_parameter.h" 18#include "trousers/tss.h" 19#include "spi_internal_types.h" 20#include "spi_utils.h" 21#include <trousers/trousers.h> 22#include <obj.h> 23#include "tsplog.h" 24#include "tss/tcs.h" 25#include "platform.h" 26 27#include "verifier.h" 28 29TSPICALL Tspi_DAA_VerifyInit_internal 30( 31 TSS_HDAA hDAA, // in 32 UINT32* nonceVerifierLength, // out 33 BYTE** nonceVerifier, // out 34 UINT32 baseNameLength, // out 35 BYTE ** baseName // out 36) { 37 TSS_RESULT result = TSS_SUCCESS; 38 TCS_CONTEXT_HANDLE tcsContext; 39 bi_ptr nounce = NULL; 40 41 //TODO how to setup the baseName & baseNameLength 42 if( (result = obj_daa_get_tsp_context( hDAA, &tcsContext)) != TSS_SUCCESS) 43 goto close; 44 *nonceVerifierLength = DAA_PARAM_LENGTH_MESSAGE_DIGEST; 45 *nonceVerifier = calloc_tspi( tcsContext, DAA_PARAM_LENGTH_MESSAGE_DIGEST); 46 if (*nonceVerifier == NULL) { 47 LogError("malloc of %d bytes failed", DAA_PARAM_LENGTH_MESSAGE_DIGEST); 48 result = TSPERR(TSS_E_OUTOFMEMORY); 49 goto close; 50 } 51 nounce = bi_new_ptr(); 52 bi_urandom( nounce, DAA_PARAM_LENGTH_MESSAGE_DIGEST * 8); 53 bi_2_byte_array( *nonceVerifier, DAA_PARAM_LENGTH_MESSAGE_DIGEST, nounce); 54close: 55 FREE_BI( nounce); 56 return result; 57} 58