public bool VerifyHash(byte[] hash, string hashAlgOid, byte[] sig) { InfoCardTrace.ThrowInvalidArgumentConditional((hash == null) || (0 == hash.Length), "hash"); InfoCardTrace.ThrowInvalidArgumentConditional(string.IsNullOrEmpty(hashAlgOid), "hashAlgOid"); InfoCardTrace.ThrowInvalidArgumentConditional((sig == null) || (0 == sig.Length), "sig"); bool verified = false; using (HGlobalSafeHandle handle = HGlobalSafeHandle.Construct(hash.Length)) { using (HGlobalSafeHandle handle2 = HGlobalSafeHandle.Construct(hashAlgOid)) { Marshal.Copy(hash, 0, handle.DangerousGetHandle(), hash.Length); int status = 0; using (HGlobalSafeHandle handle3 = HGlobalSafeHandle.Construct(sig.Length)) { Marshal.Copy(sig, 0, handle3.DangerousGetHandle(), sig.Length); status = CardSpaceSelector.GetShim().m_csShimVerifyHash(this.m_cryptoHandle.InternalHandle, hash.Length, handle, handle2, sig.Length, handle3, out verified); } if (status != 0) { ExceptionHelper.ThrowIfCardSpaceException(status); throw InfoCardTrace.ThrowHelperError(new Win32Exception(status)); } } } return(verified); }
public byte[] Decrypt(byte[] inData, bool fAOEP) { GlobalAllocSafeHandle pOutData = null; byte[] buffer; int pcbOutData = 0; InfoCardTrace.ThrowInvalidArgumentConditional(null == inData, "indata"); using (HGlobalSafeHandle handle2 = HGlobalSafeHandle.Construct(inData.Length)) { Marshal.Copy(inData, 0, handle2.DangerousGetHandle(), inData.Length); int status = CardSpaceSelector.GetShim().m_csShimDecrypt(this.m_cryptoHandle.InternalHandle, fAOEP, inData.Length, handle2, out pcbOutData, out pOutData); if (status != 0) { ExceptionHelper.ThrowIfCardSpaceException(status); throw InfoCardTrace.ThrowHelperError(new Win32Exception(status)); } pOutData.Length = pcbOutData; buffer = DiagnosticUtility.Utility.AllocateByteArray(pOutData.Length); using (pOutData) { Marshal.Copy(pOutData.DangerousGetHandle(), buffer, 0, pOutData.Length); } } return(buffer); }
public byte[] SignHash(byte[] hash, string hashAlgOid) { InfoCardTrace.ThrowInvalidArgumentConditional((hash == null) || (0 == hash.Length), "hash"); InfoCardTrace.ThrowInvalidArgumentConditional(string.IsNullOrEmpty(hashAlgOid), "hashAlgOid"); int pcbSig = 0; GlobalAllocSafeHandle pSig = null; using (HGlobalSafeHandle handle2 = HGlobalSafeHandle.Construct(hash.Length)) { using (HGlobalSafeHandle handle3 = HGlobalSafeHandle.Construct(hashAlgOid)) { Marshal.Copy(hash, 0, handle2.DangerousGetHandle(), hash.Length); RuntimeHelpers.PrepareConstrainedRegions(); int status = CardSpaceSelector.GetShim().m_csShimSignHash(this.m_cryptoHandle.InternalHandle, hash.Length, handle2, handle3, out pcbSig, out pSig); if (status != 0) { ExceptionHelper.ThrowIfCardSpaceException(status); throw InfoCardTrace.ThrowHelperError(new Win32Exception(status)); } pSig.Length = pcbSig; byte[] destination = DiagnosticUtility.Utility.AllocateByteArray(pSig.Length); using (pSig) { Marshal.Copy(pSig.DangerousGetHandle(), destination, 0, pSig.Length); } return(destination); } } }
public CardSpacePolicyElement(XmlElement target, XmlElement issuer, Collection <XmlElement> parameters, Uri privacyNoticeLink, int privacyNoticeVersion, bool isManagedIssuer) { InfoCardTrace.ThrowInvalidArgumentConditional((privacyNoticeVersion == 0) && (null != privacyNoticeLink), "privacyNoticeVersion"); InfoCardTrace.ThrowInvalidArgumentConditional((privacyNoticeVersion != 0) && (null == privacyNoticeLink), "privacyNoticeLink"); this.m_target = target; this.m_issuer = issuer; this.m_parameters = parameters; this.m_policyNoticeLink = privacyNoticeLink; this.m_policyNoticeVersion = privacyNoticeVersion; this.m_isManagedIssuer = isManagedIssuer; }