// This file was extracted from the TCG Published // Trusted Platform Module Library // Part 4: Supporting Routines // Family "2.0" // Level 00 Revision 01.16 // October 30, 2014 #include "stdint.h" #include "TpmBuildSwitches.h" const char notReallyUnique[] = "This is not really a unique value. A real unique value should" " be generated by the platform."; // // // _plat__GetUnique() // // This function is used to access the platform-specific unique value. This function places the unique value // in the provided buffer (b) and returns the number of bytes transferred. The function will not copy more // data than bSize. // // NOTE: If a platform unique value has unequal distribution of uniqueness and bSize is smaller than the size of the // unique value, the bSize portion with the most uniqueness should be returned. // LIB_EXPORT uint32_t _plat__GetUnique( uint32_t which, // authorities (0) or details uint32_t bSize, // size of the buffer unsigned char *b // output buffer ) { const char *from = notReallyUnique; uint32_t retVal = 0; if(which == 0) // the authorities value { for(retVal = 0; *from != 0 && retVal < bSize; retVal++) { *b++ = *from++; } } else { #define uSize sizeof(notReallyUnique) b = &b[((bSize < uSize) ? bSize : uSize) - 1]; for(retVal = 0; *from != 0 && retVal < bSize; retVal++) { *b-- = *from++; } } return retVal; }