// // Summary: // Given a pointer to a native cryptosession this method creates the appropriate CryptoHandle type. // static internal CryptoHandle Create(InternalRefCountedHandle nativeHandle) { CryptoHandle handle = null; bool mustRelease = false; RuntimeHelpers.PrepareConstrainedRegions(); try { nativeHandle.DangerousAddRef(ref mustRelease); RpcInfoCardCryptoHandle hCrypto = (RpcInfoCardCryptoHandle)Marshal.PtrToStructure(nativeHandle.DangerousGetHandle(), typeof(RpcInfoCardCryptoHandle)); DateTime expiration = DateTime.FromFileTimeUtc(hCrypto.expiration); switch (hCrypto.type) { case RpcInfoCardCryptoHandle.HandleType.Asymmetric: handle = new AsymmetricCryptoHandle(nativeHandle, expiration, hCrypto.cryptoParameters); break; case RpcInfoCardCryptoHandle.HandleType.Symmetric: handle = new SymmetricCryptoHandle(nativeHandle, expiration, hCrypto.cryptoParameters); break; case RpcInfoCardCryptoHandle.HandleType.Transform: handle = new TransformCryptoHandle(nativeHandle, expiration, hCrypto.cryptoParameters); break; case RpcInfoCardCryptoHandle.HandleType.Hash: handle = new HashCryptoHandle(nativeHandle, expiration, hCrypto.cryptoParameters); break; default: IDT.DebugAssert(false, "Invalid crypto operation type"); throw IDT.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.GeneralExceptionMessage))); } return(handle); } finally { if (mustRelease) { nativeHandle.DangerousRelease(); } } }
public InfoCardRSACryptoProvider(AsymmetricCryptoHandle cryptoHandle) { this.m_cryptoHandle = (AsymmetricCryptoHandle)cryptoHandle.Duplicate(); try { this.m_params = (RpcAsymmetricCryptoParameters)this.m_cryptoHandle.Parameters; int keySize = this.m_params.keySize; base.LegalKeySizesValue = new KeySizes[1]; base.KeySizeValue = keySize; base.LegalKeySizesValue[0] = new KeySizes(keySize, keySize, 0); } catch { this.m_cryptoHandle.Dispose(); this.m_cryptoHandle = null; throw; } }
public InfoCardRSACryptoProvider(AsymmetricCryptoHandle cryptoHandle) { this.m_cryptoHandle = (AsymmetricCryptoHandle) cryptoHandle.Duplicate(); try { this.m_params = (RpcAsymmetricCryptoParameters) this.m_cryptoHandle.Parameters; int keySize = this.m_params.keySize; base.LegalKeySizesValue = new KeySizes[1]; base.KeySizeValue = keySize; base.LegalKeySizesValue[0] = new KeySizes(keySize, keySize, 0); } catch { this.m_cryptoHandle.Dispose(); this.m_cryptoHandle = null; throw; } }
internal static CryptoHandle Create(InternalRefCountedHandle nativeHandle) { CryptoHandle handle = null; CryptoHandle handle3; bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { nativeHandle.DangerousAddRef(ref success); RpcInfoCardCryptoHandle handle2 = (RpcInfoCardCryptoHandle)Marshal.PtrToStructure(nativeHandle.DangerousGetHandle(), typeof(RpcInfoCardCryptoHandle)); DateTime expiration = DateTime.FromFileTimeUtc(handle2.expiration); switch (handle2.type) { case RpcInfoCardCryptoHandle.HandleType.Asymmetric: handle = new AsymmetricCryptoHandle(nativeHandle, expiration, handle2.cryptoParameters); break; case RpcInfoCardCryptoHandle.HandleType.Symmetric: handle = new SymmetricCryptoHandle(nativeHandle, expiration, handle2.cryptoParameters); break; case RpcInfoCardCryptoHandle.HandleType.Transform: handle = new TransformCryptoHandle(nativeHandle, expiration, handle2.cryptoParameters); break; case RpcInfoCardCryptoHandle.HandleType.Hash: handle = new HashCryptoHandle(nativeHandle, expiration, handle2.cryptoParameters); break; default: throw InfoCardTrace.ThrowHelperError(new InvalidOperationException(Microsoft.InfoCards.SR.GetString("GeneralExceptionMessage"))); } handle3 = handle; } finally { if (success) { nativeHandle.DangerousRelease(); } } return(handle3); }
public InfoCardProofToken(AsymmetricCryptoHandle cryptoHandle, DateTime expiration) : this(expiration) { this.InitCrypto(new InfoCardAsymmetricCrypto(cryptoHandle)); }
public InfoCardProofToken(AsymmetricCryptoHandle cryptoHandle, DateTime expiration) : this( expiration ) { InitCrypto(new InfoCardAsymmetricCrypto(cryptoHandle)); }
// // Summary: // Constructs a new InfoCardAsymmetricCrypto given an InfoCardRSACryptoProvider. // // Parameters: // cryptoHandle - the handle to the asymmetric key to base this crypto object on. public InfoCardAsymmetricCrypto(AsymmetricCryptoHandle cryptoHandle) { m_rsa = new InfoCardRSACryptoProvider(cryptoHandle); }
// // Summary: // Given a pointer to a native cryptosession this method creates the appropriate CryptoHandle type. // static internal CryptoHandle Create(InternalRefCountedHandle nativeHandle) { CryptoHandle handle = null; bool mustRelease = false; RuntimeHelpers.PrepareConstrainedRegions(); try { nativeHandle.DangerousAddRef(ref mustRelease); RpcInfoCardCryptoHandle hCrypto = (RpcInfoCardCryptoHandle)Marshal.PtrToStructure(nativeHandle.DangerousGetHandle(), typeof(RpcInfoCardCryptoHandle)); DateTime expiration = DateTime.FromFileTimeUtc(hCrypto.expiration); switch (hCrypto.type) { case RpcInfoCardCryptoHandle.HandleType.Asymmetric: handle = new AsymmetricCryptoHandle(nativeHandle, expiration, hCrypto.cryptoParameters); break; case RpcInfoCardCryptoHandle.HandleType.Symmetric: handle = new SymmetricCryptoHandle(nativeHandle, expiration, hCrypto.cryptoParameters); break; case RpcInfoCardCryptoHandle.HandleType.Transform: handle = new TransformCryptoHandle(nativeHandle, expiration, hCrypto.cryptoParameters); break; case RpcInfoCardCryptoHandle.HandleType.Hash: handle = new HashCryptoHandle(nativeHandle, expiration, hCrypto.cryptoParameters); break; default: IDT.DebugAssert(false, "Invalid crypto operation type"); throw IDT.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.GeneralExceptionMessage))); } return handle; } finally { if (mustRelease) { nativeHandle.DangerousRelease(); } } }