protected override TPMCommandResponse InternalProcess() { byte[] ownerAuth = _params.GetValueOf <byte[]> (PARAM_OWNERAUTH); byte[] srkAuth = _params.GetValueOf <byte[]> (PARAM_SRKAUTH); TPMBlob requestBlob = new TPMBlob(); requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_AUTH1_COMMAND, TPMOrdinals.TPM_ORD_TakeOwnership); requestBlob.WriteUInt16((ushort)TPMProtocolId.TPM_PID_OWNER); requestBlob.WriteUInt32((uint)ownerAuth.Length); requestBlob.Write(ownerAuth, 0, ownerAuth.Length); requestBlob.WriteUInt32((uint)srkAuth.Length); requestBlob.Write(srkAuth, 0, srkAuth.Length); _tpmKey.WriteToTpmBlob(requestBlob); _responseBlob = AuthorizeMeAndTransmit(requestBlob); CheckResponseAuthInfo(); return(new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_TakeOwnership, new Parameters())); }
public void WriteAuthorizationInfo(TPMBlob target, AuthorizationInfo authInfo) { target.WriteUInt32(authInfo.Handle.Handle); target.Write(authInfo.Handle.NonceOdd, 0, authInfo.Handle.NonceOdd.Length); target.WriteBool(authInfo.ContinueAuthSession); target.Write(authInfo.AuthData, 0, authInfo.AuthData.Length); }
public override TPMCommandResponse Process() { ITPMHandle handle = _params.GetValueOf <ITPMHandle> ("handle"); TPMBlob requestBlob = new TPMBlob(); requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_FlushSpecific); requestBlob.WriteUInt32(handle.Handle); requestBlob.WriteUInt32((uint)handle.ResourceType); requestBlob.WriteCmdSize(); try { TransmitMe(requestBlob); } catch (Exception) { if (!_params.GetValueOf <bool>("ignore_tpm_error", false)) { throw; } } return(new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_FlushSpecific, new Parameters())); }
public void WriteToTpmBlob(TPMBlob blob) { blob.WriteByte(_major); blob.WriteByte(_minor); blob.WriteByte(_revMajor); blob.WriteByte(_revMinor); }
public void ReadFromTpmBlob(TPMBlob blob) { _major = blob.ReadByte(); _minor = blob.ReadByte(); _revMajor = blob.ReadByte(); _revMinor = blob.ReadByte(); }
public static TPMVersionCore CreateFromTPMBlob(TPMBlob blob) { TPMVersionCore version = new TPMVersionCore(); version.ReadFromTpmBlob(blob); return(version); }
public static TPMStorePubkeyCore CreateFromTpmBlob(TPMBlob blob) { TPMStorePubkeyCore pubkey = new TPMStorePubkeyCore(); pubkey.ReadFromTpmBlob(blob); return(pubkey); }
public static TPMPCRInfoCore CreateFromTPMBlob(TPMBlob blob) { TPMPCRInfoCore pcrInfo = new TPMPCRInfoCore(); pcrInfo.ReadFromTpmBlob(blob); return(pcrInfo); }
public ResponseAuthHandleInfoCore(TPMBlob blob, long startIndex) { blob.Seek(startIndex, SeekOrigin.Begin); _nonceEven = blob.ReadBytes(20); _continueAuthSession = blob.ReadBool(); _tpmAuthData = blob.ReadBytes(20); }
public void WriteToTpmBlob(TPMBlob blob) { blob.WriteUInt32((uint)_algorithmId); blob.WriteUInt16((ushort)_encScheme); blob.WriteUInt16((ushort)_sigScheme); TPMBlobWriteableHelper.WriteITPMBlobWritableWithUIntSize(blob, (ITPMBlobWritable)_params); }
public static TPMStoredDataCore CreateFromTPMBlob(TPMBlob blob) { TPMStoredDataCore storedData = new TPMStoredDataCore(); storedData.ReadFromTpmBlob(blob); return(storedData); }
public static TPMKeyParamsCore CreateFromTPMBlob(TPMBlob blob) { TPMKeyParamsCore keyParams = new TPMKeyParamsCore(); keyParams.ReadFromTpmBlob(blob); return(keyParams); }
public void ReadFromTpmBlob(TPMBlob blob) { _algorithmId = (TPMAlgorithmId)blob.ReadUInt32(); _encScheme = (TPMEncScheme)blob.ReadUInt16(); _sigScheme = (TPMSigScheme)blob.ReadUInt16(); UInt32 paramsSize = blob.ReadUInt32(); byte[] paramsData = new byte[paramsSize]; blob.Read(paramsData, 0, paramsData.Length); using (TPMBlob paramSrc = new TPMBlob(paramsData)) { if (_algorithmId == TPMAlgorithmId.TPM_ALG_RSA) { _params = TPMRSAKeyParamsCore.CreateFromTPMBlob(paramSrc); } else if (_algorithmId == TPMAlgorithmId.TPM_ALG_AES128 || _algorithmId == TPMAlgorithmId.TPM_ALG_AES192 || _algorithmId == TPMAlgorithmId.TPM_ALG_AES256) { //TODO throw new NotImplementedException("Symmetric key params not implemented"); } } }
public override TPMCommandResponse Process() { byte[] nonce = NonceGenerator.GenerateByteNonce(20); TPMBlob requestBlob = new TPMBlob(); requestBlob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_ReadPubek); requestBlob.Write(nonce, 0, nonce.Length); requestBlob.WriteCmdSize(); TPMBlob responseBlob = TransmitMe(requestBlob); responseBlob.SkipHeader(); long posStart = responseBlob.Position; TPMPubkeyCore pubkey = TPMPubkeyCore.CreateFromTPMBlob(responseBlob); long posEnd = responseBlob.Position; Digest digest = new Digest(responseBlob, 20); if (digest.CompareTo( new HashStreamDataProvider(responseBlob, posStart, posEnd - posStart, false), new HashByteDataProvider(nonce)) == false) { throw new TPMResponseException("Local digest does not match remote digest"); } Parameters responseParams = new Parameters(); responseParams.AddValue(TPMPubkey.PARAM_TPM_PUBKEY, pubkey); return(new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_ReadPubek, responseParams)); }
public override TPMCommandResponse Process() { if (_params.IsDefined <ITPMHandle>("handle") == false || _params.IsDefined <byte[]>("context_blob") == false) { return(new TPMCommandResponse(false, TPMCommandNames.TPM_CMD_LoadContext, new Parameters())); } ITPMHandle handle = _params.GetValueOf <ITPMHandle>("handle"); TPMBlob blob = new TPMBlob(); blob.WriteCmdHeader(TPMCmdTags.TPM_TAG_RQU_COMMAND, TPMOrdinals.TPM_ORD_LoadContext); blob.WriteUInt32(handle.Handle); blob.WriteBool(handle.ForceHandle); blob.WriteUInt32((uint)handle.ContextBlob.Length); blob.Write(handle.ContextBlob, 0, handle.ContextBlob.Length); TPMBlob responseBlob = TransmitMe(blob); responseBlob.SkipHeader(); handle.Handle = responseBlob.ReadUInt32(); Parameters responseParameters = new Parameters(); responseParameters.AddValue("handle", handle); return(new TPMCommandResponse(true, TPMCommandNames.TPM_CMD_LoadContext, responseParameters)); }
/// <summary> /// Transmit a blob to the given network stream /// </summary> /// <param name="stm"></param> /// <param name="tpmBlob"></param> public static void SendBlob(Stream stm, TPMBlob tpmBlob) { // We need to have a valid size when working over the network // Disabled for now - tpmBlob.WriteCmdSize(); //tpmBlob.WriteCmdSize(); RawSendBlob(stm, tpmBlob.GetBuffer(), (int)tpmBlob.Length); }
public static TPMPCRSelectionCore CreateFromTPMBlob(TPMBlob blob) { TPMPCRSelectionCore pcrSelection = new TPMPCRSelectionCore(); pcrSelection.ReadFromTpmBlob(blob); return(pcrSelection); }
/// <summary> /// Transmit and check the given TPM blob. /// </summary> /// <param name="blob"></param> /// <returns></returns> public TPMBlob TransmitAndCheck(TPMBlob blob, bool writeSize) { ushort expected_rsp_tag; // Determine the expected RSP tag blob.Position = 0; switch (blob.ReadUInt16()) { case TPMCmdTags.TPM_TAG_RQU_COMMAND: expected_rsp_tag = TPMCmdTags.TPM_TAG_RSP_COMMAND; break; case TPMCmdTags.TPM_TAG_RQU_AUTH1_COMMAND: expected_rsp_tag = TPMCmdTags.TPM_TAG_RSP_AUTH1_COMMAND; break; case TPMCmdTags.TPM_TAG_RQU_AUTH2_COMMAND: expected_rsp_tag = TPMCmdTags.TPM_TAG_RSP_AUTH2_COMMAND; break; default: throw new Exception(); //throw new TpmCommandException("Unsupported TPM request tag", blob); } // Do the actual transaction TPMBlob rsp = Transmit(blob, writeSize); // Check the response CheckTpmReponse(rsp, expected_rsp_tag); return(rsp); }
public static TPMPCRCompositeCore CreateFromTPMBlob(TPMBlob blob) { TPMPCRCompositeCore pcrComposite = new TPMPCRCompositeCore(); pcrComposite.ReadFromTpmBlob(blob); return(pcrComposite); }
public static TPMCounterValueCore CreateFromTPMBlob(TPMBlob blob) { TPMCounterValueCore counterValue = new TPMCounterValueCore(); counterValue.ReadFromTpmBlob(blob); return(counterValue); }
public static TPMPubkeyCore CreateFromTPMBlob(TPMBlob src) { TPMPubkeyCore pubkey = new TPMPubkeyCore(); pubkey.ReadFromTpmBlob(src); return(pubkey); }
public void WriteToTpmBlob(TPMBlob blob) { ((ITPMBlobWritable)_version).WriteToTpmBlob(blob); blob.Write(_fixed, 0, _fixed.Length); blob.Write(_compositeHash, 0, _compositeHash.Length); blob.Write(_nonce, 0, _nonce.Length); }
public void WriteToTpmBlob(TPMBlob blob) { ((ITPMBlobWritable)_versionStruct).WriteToTpmBlob(blob); blob.WriteUInt32((uint)_sealInfo.Length); blob.Write(_sealInfo, 0, _sealInfo.Length); blob.WriteUInt32((uint)_encData.Length); blob.Write(_encData, 0, _encData.Length); }
public void WriteToTpmBlob(TPMBlob blob) { blob.WriteUInt32(_keyLength); blob.WriteUInt32(_numPrimes); blob.WriteUInt32((uint)_exponent.Length); blob.Write(_exponent, 0, _exponent.Length); }
public void ReadFromTpmBlob(TPMBlob blob) { uint size = blob.ReadUInt16(); byte[] selectionBits = new byte[size]; blob.Read(selectionBits, 0, (int)size); _pcrSelection = new BitMap(selectionBits); }
public HashTPMBlobWritableDataProvider(ITPMBlobWritable blobWritable) { TPMBlob tempBlob = new TPMBlob(); blobWritable.WriteToTpmBlob(tempBlob); _subDataProvider = new HashStreamDataProvider(tempBlob, null, null, true); }
/// <summary> /// TPM response check with tag test /// </summary> /// <param name="rsp"></param> /// <param name="p"></param> public void CheckTpmReponse(TPMBlob rsp, ushort expected_tag) { ushort currentTag = CheckTpmReponse(rsp); if (currentTag != expected_tag) { throw new TPMResponseException(-1, string.Format("TPM response tag does not match request tag, received: {0}, expected: {1}", currentTag, expected_tag), rsp); } }
public void ReadFromTpmBlob(TPMBlob blob) { UInt16 handleCount = blob.ReadUInt16(); for (int i = 0; i < handleCount; i++) { _handles.Add(blob.ReadUInt32()); } }
public void ReadFromTpmBlob(TPMBlob blob) { _pcrSelection = TPMPCRSelectionCore.CreateFromTPMBlob(blob); byte[] digestAtRelease = new byte[20]; byte[] digestAtCreation = new byte[20]; blob.Read(digestAtRelease, 0, 20); blob.Read(digestAtCreation, 0, 20); }
public void WriteToTpmBlob(TPMBlob blob) { ((ITPMBlobWritable)_pcrSelection).WriteToTpmBlob(blob); blob.WriteUInt32((uint)_pcrValues.Length * 20); foreach (byte[] pcrValue in _pcrValues) { blob.Write(pcrValue, 0, pcrValue.Length); } }