diff --git a/maestro/drc.c b/maestro/drc.c index d06fb481c5c672543011287c207d0dec0b4d4d59..5556920bc31f36337bc9d17d7fc5e2af9be46065 100644 --- a/maestro/drc.c +++ b/maestro/drc.c @@ -347,7 +347,39 @@ mstro_status mstro_drc_init_from_credential(mstro_drc_info *result_p, uint32_t credential) { - return MSTRO_UNIMPL; + mstro_status stat = MSTRO_UNIMPL; + uint32_t id = credential; + int ret; + + if(result_p==NULL) + return MSTRO_INVOUT; + + *result_p = malloc(sizeof(struct mstro_drc_info_)); + if(*result_p) { + drc_info_handle_t info; + (*result_p)->drc_id = id; + + ret = drc_access((*result_p)->drc_id, 0, &info); + if(ret!=DRC_SUCCESS) { + ERR("Failed to drc_access credential %" PRIu32 ": %d\n", id, ret); + goto BAILOUT_FREE; + } + + mstro_drc_init_internal(*result_p, info); + + DEBUG("Accessing DRC credential %d (OOB: is %s), cookie %" PRIx64 ")\n", + (*result_p)->drc_id, + (*result_p)->serialized_id, + (*result_p)->auth_key.raw.protection_key); + stat = MSTRO_OK; + } else { + stat = MSTRO_NOMEM; + } + goto BAILOUT; +BAILOUT_FREE: + NFREE(*result_p); +BAILOUT: + return stat; }