public GetQuoteResponse(UInt32 i_error_code, RSACryptoServiceProvider i_public_key) { error_code = i_error_code; public_key = i_public_key; pcr_info = new byte[25]; pcr_info[0] = 0; pcr_info[1] = 3; pcr_info[2] = 0; pcr_info[3] = 0; pcr_info[4] = 14; if (CommonParams.loaderHash.Length == 40 && CommonParams.appHash.Length == 40) { SHA1Managed hasher = new SHA1Managed(); byte[] encoded_public_key = CommonRoutines.EncodePublicKey(public_key); byte[] pcr17 = GetExpectedPCR17(); byte[] pcr18 = GetZeroPCR(); byte[] pcr19 = GetExpectedPCR19(hasher, encoded_public_key); byte[] tpm_pcr_composite = CommonRoutines.CombineByteArrays(pcr_info.Take(5).ToArray(), BitConverter.GetBytes((UInt32)60), pcr17, pcr18, pcr19); byte[] h1 = hasher.ComputeHash(tpm_pcr_composite); Array.Copy(h1, 0, pcr_info, 5, 20); } sig = new byte[1]; sig[0] = 0; }
public byte[] Encode() { byte[] header = new byte[1]; header[0] = 1; byte[] error_code = CommonRoutines.EncodeBEWord(0); byte[] encoded_public_key = CommonRoutines.EncodePublicKey(public_key); byte[] encoded_public_key_length = CommonRoutines.EncodeBEWord((uint)encoded_public_key.Length); byte[] pcr_info_length = CommonRoutines.EncodeBEWord((uint)pcr_info.Length); byte[] sig_length = CommonRoutines.EncodeBEWord((uint)sig.Length); return(CommonRoutines.CombineByteArrays(header, error_code, encoded_public_key_length, pcr_info_length, sig_length, encoded_public_key, pcr_info, sig)); }