Exemplo n.º 1
0
TSS_RESULT
obj_migdata_get_src_digest(TSS_HMIGDATA hMigData, UINT32 *digestSize, BYTE **digest)
{
	struct tsp_object *obj;
	struct tr_migdata_obj *migdata;
	TSS_RESULT result = TSS_SUCCESS;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	migdata = (struct tr_migdata_obj *)obj->data;

	if ((*digest = calloc_tspi(obj->tspContext, sizeof(migdata->srcDigest.digest))) == NULL) {
		LogError("malloc of %zd bytes failed.", sizeof(migdata->srcDigest.digest));
		result = TSPERR(TSS_E_OUTOFMEMORY);
		goto done;
	}
	memcpy(*digest, migdata->srcDigest.digest, sizeof(migdata->srcDigest.digest));
	*digestSize = sizeof(migdata->srcDigest.digest);

done:
	obj_list_put(&migdata_list);

	return result;
}
Exemplo n.º 2
0
/* called before each TCSP_ExecuteTransport call */
TSS_RESULT
obj_context_transport_init(TSS_HCONTEXT tspContext)
{
    TSS_RESULT result = TSS_SUCCESS;
    struct tsp_object *obj;
    struct tr_context_obj *context;

    if ((obj = obj_list_get_obj(&context_list, tspContext)) == NULL)
        return TSPERR(TSS_E_INVALID_HANDLE);

    context = (struct tr_context_obj *)obj->data;

    /* return immediately if we're not in a transport session */
    if (!(context->flags & TSS_CONTEXT_FLAGS_TRANSPORT_ENABLED)) {
        result = TSPERR(TSS_E_INTERNAL_ERROR);
        goto done;
    }

    /* if the session is not yet established, setup and call EstablishTransport */
    if (!(context->flags & TSS_CONTEXT_FLAGS_TRANSPORT_ESTABLISHED)) {
        if ((result = obj_context_transport_establish(tspContext, context)))
            goto done;
    }

    context->flags |= TSS_CONTEXT_FLAGS_TRANSPORT_ESTABLISHED;

    result = TSS_SUCCESS;
done:
    obj_list_put(&context_list);

    return result;
}
Exemplo n.º 3
0
TSS_RESULT
obj_migdata_set_cmk_auth(TSS_HMIGDATA hMigData, UINT32 digestsSize, BYTE *digests)
{
	struct tsp_object *obj;
	struct tr_migdata_obj *migdata;
	TSS_RESULT result = TSS_SUCCESS;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	migdata = (struct tr_migdata_obj *)obj->data;

	if (digestsSize != (sizeof(migdata->maDigest.digest) +
				sizeof(migdata->destDigest.digest) +
				sizeof(migdata->srcDigest.digest))) {
		result = TSPERR(TSS_E_BAD_PARAMETER);
		goto done;
	}
	memcpy(migdata->maDigest.digest, digests, sizeof(migdata->maDigest.digest));
	digests += sizeof(migdata->maDigest.digest);
	memcpy(migdata->destDigest.digest, digests, sizeof(migdata->destDigest.digest));
	digests += sizeof(migdata->destDigest.digest);
	memcpy(migdata->srcDigest.digest, digests, sizeof(migdata->srcDigest.digest));

	obj_migdata_calc_sig_data_digest(migdata);

done:
	obj_list_put(&migdata_list);

	return result;
}
Exemplo n.º 4
0
TSS_RESULT
obj_nvstore_set_policy(TSS_HNVSTORE hNvstore, TSS_HPOLICY hPolicy)
{
	struct tsp_object *obj;
	struct tr_nvstore_obj *nvstore;
	UINT32 policyType;
	TSS_RESULT result = TSS_SUCCESS;

	if ((result = obj_policy_get_type(hPolicy, &policyType)))
		return result;

	if ((obj = obj_list_get_obj(&nvstore_list, hNvstore)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	nvstore = (struct tr_nvstore_obj *)obj->data;

	switch (policyType) {
		case TSS_POLICY_USAGE:
			nvstore->policy = hPolicy;
			break;
		default:
			result = TSPERR(TSS_E_BAD_PARAMETER);
	}

	obj_list_put(&nvstore_list);

	return result;
}
Exemplo n.º 5
0
TSS_RESULT
obj_context_get_loadkey_ordinal(TSS_HCONTEXT tspContext, TPM_COMMAND_CODE *ordinal)
{
    struct tsp_object *obj;
    struct tr_context_obj *context;

    if ((obj = obj_list_get_obj(&context_list, tspContext)) == NULL)
        return TSPERR(TSS_E_INVALID_HANDLE);

    context = (struct tr_context_obj *)obj->data;

    switch (context->flags & TSS_CONTEXT_FLAGS_TPM_VERSION_MASK) {
    case TSS_CONTEXT_FLAGS_TPM_VERSION_2:
        *ordinal = TPM_ORD_LoadKey2;
        break;
    default:
        LogDebugFn("No TPM version set!");
    /* fall through */
    case TSS_CONTEXT_FLAGS_TPM_VERSION_1:
        *ordinal = TPM_ORD_LoadKey;
        break;
    }

    obj_list_put(&context_list);

    return TSS_SUCCESS;
}
Exemplo n.º 6
0
TSS_RESULT
obj_migdata_get_cmk_auth_blob(TSS_HMIGDATA hMigData, UINT32 *blobSize, BYTE **cmkAuthBlob)
{
	struct tsp_object *obj;
	TPM_CMK_AUTH cmkAuth;
	UINT64 offset;
	TSS_RESULT result;

	if ((result = obj_migdata_get_cmk_auth(hMigData, &cmkAuth)))
		return result;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	offset = 0;
	Trspi_LoadBlob_CMK_AUTH(&offset, NULL, &cmkAuth);

	*blobSize = offset;
	if ((*cmkAuthBlob = calloc_tspi(obj->tspContext, *blobSize)) == NULL) {
		LogError("malloc of %u bytes failed.", *blobSize);
		result = TSPERR(TSS_E_OUTOFMEMORY);
		goto done;
	}
	offset = 0;
	Trspi_LoadBlob_CMK_AUTH(&offset, *cmkAuthBlob, &cmkAuth);

done:
	obj_list_put(&migdata_list);

	return result;
}
Exemplo n.º 7
0
/* XXX change 0,1,2 to #defines */
TSS_RESULT
obj_context_set_tpm_version(TSS_HCONTEXT tspContext, UINT32 ver)
{
    TSS_RESULT result = TSS_SUCCESS;
    struct tsp_object *obj;
    struct tr_context_obj *context;

    if ((obj = obj_list_get_obj(&context_list, tspContext)) == NULL)
        return TSPERR(TSS_E_INVALID_HANDLE);

    context = (struct tr_context_obj *)obj->data;

    switch (ver) {
    case 1:
        context->flags &= ~TSS_CONTEXT_FLAGS_TPM_VERSION_MASK;
        context->flags |= TSS_CONTEXT_FLAGS_TPM_VERSION_1;
        break;
    case 2:
        context->flags &= ~TSS_CONTEXT_FLAGS_TPM_VERSION_MASK;
        context->flags |= TSS_CONTEXT_FLAGS_TPM_VERSION_2;
        break;
    default:
        LogError("Invalid TPM version set: %u", ver);
        result = TSPERR(TSS_E_INTERNAL_ERROR);
        break;
    }

    obj_list_put(&context_list);

    return result;
}
Exemplo n.º 8
0
TSS_RESULT
obj_context_transport_get_control(TSS_HCONTEXT tspContext, UINT32 value, UINT32 *out)
{
    TSS_RESULT result = TSS_SUCCESS;
    struct tsp_object *obj;
    struct tr_context_obj *context;

    if ((obj = obj_list_get_obj(&context_list, tspContext)) == NULL)
        return TSPERR(TSS_E_INVALID_HANDLE);

    context = (struct tr_context_obj *)obj->data;

    switch (value) {
    case TSS_TSPATTRIB_DISABLE_TRANSPORT:
        *out = context->flags & TSS_CONTEXT_FLAGS_TRANSPORT_ENABLED ? FALSE : TRUE;
        break;
    case TSS_TSPATTRIB_ENABLE_TRANSPORT:
        *out = context->flags & TSS_CONTEXT_FLAGS_TRANSPORT_ENABLED ? TRUE : FALSE;
        break;
    default:
        LogError("Invalid attribute subflag: 0x%x", value);
        result = TSPERR(TSS_E_INVALID_ATTRIB_SUBFLAG);
        break;
    }

    obj_list_put(&context_list);

    return result;
}
Exemplo n.º 9
0
TSS_RESULT
obj_migdata_get_sig_value(TSS_HMIGDATA hMigData, UINT32 *sigValueSize, BYTE **sigValue)
{
	struct tsp_object *obj;
	struct tr_migdata_obj *migdata;
	TSS_RESULT result = TSS_SUCCESS;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	migdata = (struct tr_migdata_obj *)obj->data;

	if ((*sigValue = calloc_tspi(obj->tspContext, migdata->sigValueSize)) == NULL) {
		LogError("malloc of %u bytes failed.", migdata->sigValueSize);
		result = TSPERR(TSS_E_OUTOFMEMORY);
		goto done;
	}
	memcpy(*sigValue, migdata->sigValue, migdata->sigValueSize);
	*sigValueSize = migdata->sigValueSize;

done:
	obj_list_put(&migdata_list);

	return result;
}
Exemplo n.º 10
0
TSS_RESULT
obj_pcrs_set_locality(TSS_HPCRS hPcrs, UINT32 locality)
{
	struct tsp_object *obj;
	struct tr_pcrs_obj *pcrs;
	TSS_RESULT result = TSS_SUCCESS;
	BYTE *loc;

	if ((obj = obj_list_get_obj(&pcrs_list, hPcrs)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	pcrs = (struct tr_pcrs_obj *)obj->data;

	switch(pcrs->type) {
		case TSS_PCRS_STRUCT_INFO:
			result = TSPERR(TSS_E_INVALID_OBJ_ACCESS);
			goto done;
		case TSS_PCRS_STRUCT_INFO_SHORT:
			loc = &pcrs->info.infoshort.localityAtRelease;
			break;
		case TSS_PCRS_STRUCT_INFO_LONG:
			loc = &pcrs->info.infolong.localityAtRelease;
			break;
		default:
			LogDebugFn("Undefined type of PCRs object");
			result = TSPERR(TSS_E_INTERNAL_ERROR);
			goto done;
	}

	*loc = locality;
done:
	obj_list_put(&pcrs_list);

	return result;
}
Exemplo n.º 11
0
TSS_RESULT
obj_context_transport_set_control(TSS_HCONTEXT tspContext, UINT32 value)
{
    TSS_RESULT result = TSS_SUCCESS;
    struct tsp_object *obj;
    struct tr_context_obj *context;

    if ((obj = obj_list_get_obj(&context_list, tspContext)) == NULL)
        return TSPERR(TSS_E_INVALID_HANDLE);

    context = (struct tr_context_obj *)obj->data;

    switch (value) {
    case TSS_TSPATTRIB_ENABLE_TRANSPORT:
        context->flags |= TSS_CONTEXT_FLAGS_TRANSPORT_ENABLED;
        context->tcs_api = &tcs_transport_api;
        break;
    case TSS_TSPATTRIB_DISABLE_TRANSPORT:
        context->flags &= ~TSS_CONTEXT_FLAGS_TRANSPORT_ENABLED;
        context->tcs_api = &tcs_normal_api;
        break;
    default:
        LogError("Invalid attribute subflag: 0x%x", value);
        result = TSPERR(TSS_E_INTERNAL_ERROR);
        break;
    }

    obj_list_put(&context_list);

    return result;
}
Exemplo n.º 12
0
TSS_RESULT
obj_migdata_set_src_pubkey(TSS_HMIGDATA hMigData, UINT32 blobSize, BYTE *pubKeyBlob)
{
	struct tsp_object *obj;
	struct tr_migdata_obj *migdata;
	TPM_DIGEST pubKeyDigest;
	TSS_RESULT result = TSS_SUCCESS;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	migdata = (struct tr_migdata_obj *)obj->data;

	if ((result = obj_migdata_calc_pubkey_digest(blobSize, pubKeyBlob, &pubKeyDigest)))
		goto done;

	migdata->srcDigest = pubKeyDigest;

	obj_migdata_calc_sig_data_digest(migdata);

done:
	obj_list_put(&migdata_list);

	return TSS_SUCCESS;
}
Exemplo n.º 13
0
TSS_RESULT
obj_context_set_connection_policy(TSS_HCONTEXT tspContext, UINT32 policy)
{
    struct tsp_object *obj;
    struct tr_context_obj *context;

    switch (policy) {
    case TSS_TSPATTRIB_CONTEXT_VERSION_V1_1:
    case TSS_TSPATTRIB_CONTEXT_VERSION_V1_2:
    case TSS_TSPATTRIB_CONTEXT_VERSION_AUTO:
        break;
    default:
        return TSPERR(TSS_E_INVALID_ATTRIB_DATA);
    }

    if ((obj = obj_list_get_obj(&context_list, tspContext)) == NULL)
        return TSPERR(TSS_E_INVALID_HANDLE);

    context = (struct tr_context_obj *)obj->data;

    context->connection_policy = policy;

    obj_list_put(&context_list);

    return TSS_SUCCESS;
}
Exemplo n.º 14
0
TSS_RESULT
obj_migdata_set_msa_pubkey(TSS_HMIGDATA hMigData, UINT32 blobSize, BYTE *pubKeyBlob)
{
	struct tsp_object *obj;
	struct tr_migdata_obj *migdata;
	UINT32 size;
	TPM_DIGEST msaDigest;
	TPM_DIGEST *digest;
	TSS_RESULT result = TSS_SUCCESS;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	migdata = (struct tr_migdata_obj *)obj->data;

	if ((result = obj_migdata_calc_pubkey_digest(blobSize, pubKeyBlob, &msaDigest)))
		goto done;

	size = (migdata->msaList.MSAlist + 1) * sizeof(*digest);
	if ((migdata->msaList.migAuthDigest = realloc(migdata->msaList.migAuthDigest, size)) == NULL) {
		LogError("malloc of %u bytes failed.", size);
		result = TSPERR(TSS_E_OUTOFMEMORY);
		goto done;
	}
	digest = migdata->msaList.migAuthDigest + migdata->msaList.MSAlist;
	*digest = msaDigest;
	migdata->msaList.MSAlist++;

	result = obj_migdata_calc_msa_digest(migdata);

done:
	obj_list_put(&migdata_list);

	return result;
}
Exemplo n.º 15
0
TSS_RESULT
obj_migdata_get_msa_list_blob(TSS_HMIGDATA hMigData, UINT32 *blobSize, BYTE **msaListBlob)
{
	struct tsp_object *obj;
	struct tr_migdata_obj *migdata;
	UINT64 offset;
	TSS_RESULT result = TSS_SUCCESS;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	migdata = (struct tr_migdata_obj *)obj->data;

	offset = 0;
	Trspi_LoadBlob_MSA_COMPOSITE(&offset, NULL, &migdata->msaList);

	*blobSize = offset;
	if ((*msaListBlob = calloc_tspi(obj->tspContext, *blobSize)) == NULL) {
		LogError("malloc of %u bytes failed.", *blobSize);
		result = TSPERR(TSS_E_OUTOFMEMORY);
		goto done;
	}
	offset = 0;
	Trspi_LoadBlob_MSA_COMPOSITE(&offset, *msaListBlob, &migdata->msaList);

done:
	obj_list_put(&migdata_list);

	return result;
}
Exemplo n.º 16
0
TSS_RESULT
obj_migdata_get_msa_list(TSS_HMIGDATA hMigData, UINT32 *size, BYTE **msaList)
{
	struct tsp_object *obj;
	struct tr_migdata_obj *migdata;
	UINT32 i;
	TPM_DIGEST *digest;
	BYTE *tmpMsaList;
	TSS_RESULT result = TSS_SUCCESS;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	migdata = (struct tr_migdata_obj *)obj->data;

	*size = migdata->msaList.MSAlist * sizeof(migdata->msaList.migAuthDigest->digest);
	if ((*msaList = calloc_tspi(obj->tspContext, *size)) == NULL) {
		LogError("malloc of %u bytes failed.", *size);
		result = TSPERR(TSS_E_OUTOFMEMORY);
		goto done;
	}
	tmpMsaList = *msaList;
	digest = migdata->msaList.migAuthDigest;
	for (i = 0; i < migdata->msaList.MSAlist; i++) {
		memcpy(tmpMsaList, digest->digest, sizeof(digest->digest));
		tmpMsaList += sizeof(digest->digest);
		digest++;
	}

done:
	obj_list_put(&migdata_list);

	return result;
}
Exemplo n.º 17
0
TSS_RESULT
obj_migdata_set_ticket_blob(TSS_HMIGDATA hMigData, UINT32 migTicketSize, BYTE *migTicket)
{
	struct tsp_object *obj;
	struct tr_migdata_obj *migdata;
	TSS_RESULT result = TSS_SUCCESS;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	migdata = (struct tr_migdata_obj *)obj->data;

	migdata->migTicketSize = 0;
	free(migdata->migTicket);
	if ((migdata->migTicket = malloc(migTicketSize)) == NULL) {
		LogError("malloc of %u bytes failed.", migTicketSize);
		result = TSPERR(TSS_E_OUTOFMEMORY);
		goto done;
	}
	memcpy(migdata->migTicket, migTicket, migTicketSize);
	migdata->migTicketSize = migTicketSize;

done:
	obj_list_put(&migdata_list);

	return result;
}
Exemplo n.º 18
0
/* Clean up transport session if necessary. */
void
obj_context_close(TSS_HCONTEXT tspContext)
{
    struct tsp_object *obj;
    struct tr_context_obj *context;

    if ((obj = obj_list_get_obj(&context_list, tspContext)) == NULL)
        return;

    context = (struct tr_context_obj *)obj->data;

#ifdef TSS_BUILD_TRANSPORT
    if (context->transAuth.AuthHandle) {
        RPC_FlushSpecific(tspContext, context->transAuth.AuthHandle, TPM_RT_TRANS);

        memset(&context->transPub, 0, sizeof(TPM_TRANSPORT_PUBLIC));
        memset(&context->transMod, 0, sizeof(TPM_MODIFIER_INDICATOR));
        memset(&context->transSecret, 0, sizeof(TPM_TRANSPORT_AUTH));
        memset(&context->transAuth, 0, sizeof(TPM_AUTH));
        memset(&context->transLogIn, 0, sizeof(TPM_TRANSPORT_LOG_IN));
        memset(&context->transLogOut, 0, sizeof(TPM_TRANSPORT_LOG_OUT));
        memset(&context->transLogDigest, 0, sizeof(TPM_DIGEST));
    }
#endif

    obj_list_put(&context_list);
}
Exemplo n.º 19
0
/* Create a PCR info struct based on the hPcrs object */
TSS_RESULT
obj_pcrs_create_info(TSS_HPCRS hPcrs, UINT32 *size, BYTE **info)
{
	struct tsp_object *obj;
	struct tr_pcrs_obj *pcrs;
	TSS_RESULT result = TSS_SUCCESS;
	TPM_PCR_INFO info11;
	UINT64 offset;
	UINT32 ret_size;
	BYTE *ret;

	if ((obj = obj_list_get_obj(&pcrs_list, hPcrs)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	pcrs = (struct tr_pcrs_obj *)obj->data;

	/* Set everything that is not assigned to be all zeroes */
	memset(&info11, 0, sizeof(info11));

	switch (pcrs->type) {
		case TSS_PCRS_STRUCT_INFO:
			info11 = pcrs->info.info11;
			break;
		case TSS_PCRS_STRUCT_INFO_LONG:
			info11.pcrSelection = pcrs->info.infolong.releasePCRSelection;
			info11.digestAtRelease = pcrs->info.infolong.digestAtRelease;
			break;
		case TSS_PCRS_STRUCT_INFO_SHORT:
			info11.pcrSelection = pcrs->info.infoshort.pcrSelection;
			info11.digestAtRelease = pcrs->info.infoshort.digestAtRelease;
			break;
		default:
			result = TSPERR(TSS_E_INTERNAL_ERROR);
			goto done;
	}

	offset = 0;
	Trspi_LoadBlob_PCR_INFO(&offset, NULL, &info11);
	ret_size = offset;

	if ((ret = calloc(1, ret_size)) == NULL) {
		result = TSPERR(TSS_E_OUTOFMEMORY);
		LogDebug("malloc of %u bytes failed.", ret_size);
		goto done;
	}

	offset = 0;
	Trspi_LoadBlob_PCR_INFO(&offset, ret, &info11);

	*info = ret;
	*size = ret_size;

done:
	obj_list_put(&pcrs_list);

	return result;
}
Exemplo n.º 20
0
TSS_BOOL
obj_is_context(TSS_HOBJECT hObject)
{
    TSS_BOOL answer = FALSE;

    if ((obj_list_get_obj(&context_list, hObject))) {
        answer = TRUE;
        obj_list_put(&context_list);
    }

    return answer;
}
Exemplo n.º 21
0
TSS_BOOL
obj_is_delfamily(TSS_HOBJECT hObject)
{
	TSS_BOOL answer = FALSE;

	if ((obj_list_get_obj(&delfamily_list, hObject))) {
		answer = TRUE;
		obj_list_put(&delfamily_list);
	}

	return answer;
}
Exemplo n.º 22
0
TSS_BOOL
obj_is_migdata(TSS_HOBJECT hObject)
{
	TSS_BOOL answer = FALSE;

	if ((obj_list_get_obj(&migdata_list, hObject))) {
		answer = TRUE;
		obj_list_put(&migdata_list);
	}

	return answer;
}
Exemplo n.º 23
0
TSS_BOOL
obj_is_nvstore(TSS_HOBJECT hObject)
{
	TSS_BOOL answer = FALSE;

	if ((obj_list_get_obj(&nvstore_list, hObject))) {
		answer = TRUE;
		obj_list_put(&nvstore_list);
	}

	return answer;
}
Exemplo n.º 24
0
TSS_RESULT
obj_migdata_get_tsp_context(TSS_HMIGDATA hMigData, TSS_HCONTEXT *hContext)
{
	struct tsp_object *obj;

	if ((obj = obj_list_get_obj(&migdata_list, hMigData)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	*hContext = obj->tspContext;

	obj_list_put(&migdata_list);

	return TSS_SUCCESS;
}
Exemplo n.º 25
0
TSS_RESULT
obj_delfamily_get_tsp_context(TSS_HDELFAMILY hFamily, TSS_HCONTEXT *hContext)
{
	struct tsp_object *obj;

	if ((obj = obj_list_get_obj(&delfamily_list, hFamily)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	*hContext = obj->tspContext;

	obj_list_put(&delfamily_list);

	return TSS_SUCCESS;
}
Exemplo n.º 26
0
TSS_RESULT
obj_nvstore_get_tsp_context(TSS_HNVSTORE hNvstore, TSS_HCONTEXT * tspContext)
{
	struct tsp_object *obj;

	if ((obj = obj_list_get_obj(&nvstore_list, hNvstore)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	*tspContext = obj->tspContext;

	obj_list_put(&nvstore_list);

	return TSS_SUCCESS;
}
Exemplo n.º 27
0
TSS_RESULT
obj_pcrs_get_tsp_context(TSS_HPCRS hPcrs, TSS_HCONTEXT *tspContext)
{
	struct tsp_object *obj;

	if ((obj = obj_list_get_obj(&pcrs_list, hPcrs)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	*tspContext = obj->tspContext;

	obj_list_put(&pcrs_list);

	return TSS_SUCCESS;
}
Exemplo n.º 28
0
TSS_RESULT
obj_pcrs_get_value(TSS_HPCRS hPcrs, UINT32 idx, UINT32 *size, BYTE **value)
{
	struct tsp_object *obj;
	struct tr_pcrs_obj *pcrs;
	TSS_RESULT result = TSS_SUCCESS;
	TPM_PCR_SELECTION *select;

	if ((obj = obj_list_get_obj(&pcrs_list, hPcrs)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	pcrs = (struct tr_pcrs_obj *)obj->data;

	switch(pcrs->type) {
		case TSS_PCRS_STRUCT_INFO:
			select = &pcrs->info.info11.pcrSelection;
			break;
		case TSS_PCRS_STRUCT_INFO_SHORT:
			select = &pcrs->info.infoshort.pcrSelection;
			break;
		case TSS_PCRS_STRUCT_INFO_LONG:
			select = &pcrs->info.infolong.creationPCRSelection;
			break;
		default:
			LogDebugFn("Undefined type of PCRs object");
			result = TSPERR(TSS_E_INTERNAL_ERROR);
			goto done;
			break;
	}

	if (select->sizeOfSelect < (idx / 8) + 1) {
		result = TSPERR(TSS_E_BAD_PARAMETER);
		goto done;
	}

	if ((*value = calloc_tspi(obj->tspContext, TCPA_SHA1_160_HASH_LEN)) == NULL) {
		LogError("malloc of %d bytes failed.", TCPA_SHA1_160_HASH_LEN);
		result = TSPERR(TSS_E_OUTOFMEMORY);
		goto done;
	}

	*size = TCPA_SHA1_160_HASH_LEN;
	memcpy(*value, &pcrs->pcrs[idx], TCPA_SHA1_160_HASH_LEN);

done:
	obj_list_put(&pcrs_list);

	return result;
}
Exemplo n.º 29
0
TSS_RESULT
obj_pcrs_get_digest_at_release(TSS_HPCRS hPcrs, UINT32 *size, BYTE **out)
{
	struct tsp_object *obj;
	struct tr_pcrs_obj *pcrs;
	TSS_RESULT result = TSS_SUCCESS;
	BYTE *digest;

	if ((obj = obj_list_get_obj(&pcrs_list, hPcrs)) == NULL)
		return TSPERR(TSS_E_INVALID_HANDLE);

	pcrs = (struct tr_pcrs_obj *)obj->data;

	switch(pcrs->type) {
		case TSS_PCRS_STRUCT_INFO:
#ifdef TSS_SPEC_COMPLIANCE
			result = TSPERR(TSS_E_INVALID_OBJ_ACCESS);
			goto done;
#else
            digest = (BYTE *)&pcrs->info.info11.digestAtRelease;
            break;
#endif
		case TSS_PCRS_STRUCT_INFO_SHORT:
			digest = (BYTE *)&pcrs->info.infoshort.digestAtRelease;
			break;
		case TSS_PCRS_STRUCT_INFO_LONG:
			digest = (BYTE *)&pcrs->info.infolong.digestAtRelease;
			break;
		default:
			LogDebugFn("Undefined type of PCRs object");
			result = TSPERR(TSS_E_INTERNAL_ERROR);
			goto done;
			break;
	}

	if ((*out = calloc_tspi(obj->tspContext, sizeof(TPM_COMPOSITE_HASH))) == NULL) {
		LogError("malloc of %zd bytes failed.", sizeof(TPM_COMPOSITE_HASH));
		result = TSPERR(TSS_E_OUTOFMEMORY);
		goto done;
	}
	memcpy(*out, digest, sizeof(TPM_COMPOSITE_HASH));
	*size = sizeof(TPM_COMPOSITE_HASH);

done:
	obj_list_put(&pcrs_list);

	return result;
}
Exemplo n.º 30
0
TSS_RESULT
obj_context_get_hash_mode(TSS_HCONTEXT tspContext, UINT32 *mode)
{
    struct tsp_object *obj;
    struct tr_context_obj *context;

    if ((obj = obj_list_get_obj(&context_list, tspContext)) == NULL)
        return TSPERR(TSS_E_INVALID_HANDLE);

    context = (struct tr_context_obj *)obj->data;
    *mode = context->hashMode;

    obj_list_put(&context_list);

    return TSS_SUCCESS;
}