public override ICryptoTransform GetEncryptionTransform(string algorithmUri, byte[] iv)
        {
            string str;

            if (((str = algorithmUri) != null) && (str == "http://www.w3.org/2001/04/xmlenc#aes128-cbc"))
            {
                using (InfoCardSymmetricAlgorithm algorithm = new InfoCardSymmetricAlgorithm(this.m_cryptoHandle))
                {
                    algorithm.IV = iv;
                    return(algorithm.CreateEncryptor());
                }
            }
            throw InfoCardTrace.ThrowHelperError(new NotSupportedException(Microsoft.InfoCards.SR.GetString("ClientUnsupportedCryptoAlgorithm", new object[] { algorithmUri })));
        }
        //
        // Summary:
        //  Returns a SymmetricAlgorithm based on the underlying crypto handle and the algorithm passed in.
        //
        public override SymmetricAlgorithm GetSymmetricAlgorithm(string algorithmUri)
        {
            SymmetricAlgorithm algorithm;

            switch (algorithmUri)
            {
            case SecurityAlgorithms.Aes128Encryption:
                algorithm = new InfoCardSymmetricAlgorithm(m_cryptoHandle);
                break;

            default:
                throw IDT.ThrowHelperError(new NotSupportedException(SR.GetString(SR.ClientUnsupportedCryptoAlgorithm, algorithmUri)));
            }

            return(algorithm);
        }
            public CryptoTransform(InfoCardSymmetricAlgorithm symAlgo, Direction cryptoDirection)
            {
                InternalRefCountedHandle nativeTransformHandle = null;

                byte[] iV = symAlgo.IV;
                using (HGlobalSafeHandle handle2 = HGlobalSafeHandle.Construct(iV.Length))
                {
                    Marshal.Copy(iV, 0, handle2.DangerousGetHandle(), iV.Length);
                    int status = CardSpaceSelector.GetShim().m_csShimGetCryptoTransform(symAlgo.m_cryptoHandle.InternalHandle, (int)symAlgo.Mode, (int)symAlgo.Padding, symAlgo.FeedbackSize, (int)cryptoDirection, iV.Length, handle2, out nativeTransformHandle);
                    if (status != 0)
                    {
                        InfoCardTrace.CloseInvalidOutSafeHandle(nativeTransformHandle);
                        ExceptionHelper.ThrowIfCardSpaceException(status);
                        throw InfoCardTrace.ThrowHelperError(new Win32Exception(status));
                    }
                    this.m_transCryptoHandle = (TransformCryptoHandle)CryptoHandle.Create(nativeTransformHandle);
                    this.m_param             = (RpcTransformCryptoParameters)this.m_transCryptoHandle.Parameters;
                }
            }
        //
        // Summary:
        //  Returns an ICryptoTransform based on the algorithm and initialization vector passed in and the underlying
        //  CryptoHandle.
        //
        // Parameters:
        //  algorithmUri  - The algorithm that the transform you implement.
        //  iv            - The initialization vector to use in the transform
        //
        public override ICryptoTransform GetEncryptionTransform(string algorithmUri, byte[] iv)
        {
            ICryptoTransform transform;

            switch (algorithmUri)
            {
            case SecurityAlgorithms.Aes128Encryption:
                using (InfoCardSymmetricAlgorithm symAlgo = new InfoCardSymmetricAlgorithm(m_cryptoHandle))
                {
                    symAlgo.IV = iv;
                    transform  = symAlgo.CreateEncryptor();
                }
                break;

            default:
                throw IDT.ThrowHelperError(new NotSupportedException(SR.GetString(SR.ClientUnsupportedCryptoAlgorithm, algorithmUri)));
            }

            return(transform);
        }
            //
            // Parameters:
            //  symAlgo  - the algorithm being requested.
            //  cryptoDirection - determines whether the transform will encrypt or decrypt.
            //
            public CryptoTransform(InfoCardSymmetricAlgorithm symAlgo, Direction cryptoDirection)
            {
                InternalRefCountedHandle nativeHandle = null;

                byte[] iv = symAlgo.IV;
                using (HGlobalSafeHandle pIV = HGlobalSafeHandle.Construct(iv.Length))
                {
                    //
                    // Marshal the initialization vector.
                    //
                    Marshal.Copy(iv, 0, pIV.DangerousGetHandle(), iv.Length);

                    //
                    // Call native method to get a handle to a native transform.
                    //
                    int status = CardSpaceSelector.GetShim().m_csShimGetCryptoTransform(symAlgo.m_cryptoHandle.InternalHandle,
                                                                                        (int)symAlgo.Mode,
                                                                                        (int)symAlgo.Padding,
                                                                                        symAlgo.FeedbackSize,
                                                                                        (int)cryptoDirection,
                                                                                        iv.Length,
                                                                                        pIV,
                                                                                        out nativeHandle);

                    if (0 != status)
                    {
                        IDT.CloseInvalidOutSafeHandle(nativeHandle);
                        ExceptionHelper.ThrowIfCardSpaceException(status);
                        throw IDT.ThrowHelperError(new Win32Exception(status));
                    }

                    m_transCryptoHandle = (TransformCryptoHandle)CryptoHandle.Create(nativeHandle);

                    m_param = (RpcTransformCryptoParameters)m_transCryptoHandle.Parameters;
                }
            }
 public CryptoTransform(InfoCardSymmetricAlgorithm symAlgo, Direction cryptoDirection)
 {
     InternalRefCountedHandle nativeTransformHandle = null;
     byte[] iV = symAlgo.IV;
     using (HGlobalSafeHandle handle2 = HGlobalSafeHandle.Construct(iV.Length))
     {
         Marshal.Copy(iV, 0, handle2.DangerousGetHandle(), iV.Length);
         int status = CardSpaceSelector.GetShim().m_csShimGetCryptoTransform(symAlgo.m_cryptoHandle.InternalHandle, (int) symAlgo.Mode, (int) symAlgo.Padding, symAlgo.FeedbackSize, (int) cryptoDirection, iV.Length, handle2, out nativeTransformHandle);
         if (status != 0)
         {
             InfoCardTrace.CloseInvalidOutSafeHandle(nativeTransformHandle);
             ExceptionHelper.ThrowIfCardSpaceException(status);
             throw InfoCardTrace.ThrowHelperError(new Win32Exception(status));
         }
         this.m_transCryptoHandle = (TransformCryptoHandle) CryptoHandle.Create(nativeTransformHandle);
         this.m_param = (RpcTransformCryptoParameters) this.m_transCryptoHandle.Parameters;
     }
 }
            //
            // Parameters:
            //  symAlgo  - the algorithm being requested.
            //  cryptoDirection - determines whether the transform will encrypt or decrypt.
            //
            public CryptoTransform(InfoCardSymmetricAlgorithm symAlgo, Direction cryptoDirection)
            {
                InternalRefCountedHandle nativeHandle = null;
                byte[] iv = symAlgo.IV;
                using (HGlobalSafeHandle pIV = HGlobalSafeHandle.Construct(iv.Length))
                {
                    //
                    // Marshal the initialization vector.
                    //
                    Marshal.Copy(iv, 0, pIV.DangerousGetHandle(), iv.Length);

                    //
                    // Call native method to get a handle to a native transform.
                    //
                    int status = CardSpaceSelector.GetShim().m_csShimGetCryptoTransform(symAlgo.m_cryptoHandle.InternalHandle,
                                                                   (int)symAlgo.Mode,
                                                                   (int)symAlgo.Padding,
                                                                   symAlgo.FeedbackSize,
                                                                   (int)cryptoDirection,
                                                                   iv.Length,
                                                                   pIV,
                                                                   out nativeHandle);

                    if (0 != status)
                    {
                        IDT.CloseInvalidOutSafeHandle(nativeHandle);
                        ExceptionHelper.ThrowIfCardSpaceException(status);
                        throw IDT.ThrowHelperError(new Win32Exception(status));
                    }

                    m_transCryptoHandle = (TransformCryptoHandle)CryptoHandle.Create(nativeHandle);

                    m_param = (RpcTransformCryptoParameters)m_transCryptoHandle.Parameters;
                }

            }
 public override ICryptoTransform GetEncryptionTransform(string algorithmUri, byte[] iv)
 {
     string str;
     if (((str = algorithmUri) != null) && (str == "http://www.w3.org/2001/04/xmlenc#aes128-cbc"))
     {
         using (InfoCardSymmetricAlgorithm algorithm = new InfoCardSymmetricAlgorithm(this.m_cryptoHandle))
         {
             algorithm.IV = iv;
             return algorithm.CreateEncryptor();
         }
     }
     throw InfoCardTrace.ThrowHelperError(new NotSupportedException(Microsoft.InfoCards.SR.GetString("ClientUnsupportedCryptoAlgorithm", new object[] { algorithmUri })));
 }
        //
        // Summary:
        //  Returns a SymmetricAlgorithm based on the underlying crypto handle and the algorithm passed in.
        //
        public override SymmetricAlgorithm GetSymmetricAlgorithm(string algorithmUri)
        {
            SymmetricAlgorithm algorithm;
            switch (algorithmUri)
            {
                case SecurityAlgorithms.Aes128Encryption:
                    algorithm = new InfoCardSymmetricAlgorithm(m_cryptoHandle);
                    break;
                default:
                    throw IDT.ThrowHelperError(new NotSupportedException(SR.GetString(SR.ClientUnsupportedCryptoAlgorithm, algorithmUri)));
            }

            return algorithm;
        }
        //
        // Summary:
        //  Returns an ICryptoTransform based on the algorithm and initialization vector passed in and the underlying
        //  CryptoHandle.
        //
        // Parameters:
        //  algorithmUri  - The algorithm that the transform you implement.
        //  iv            - The initialization vector to use in the transform
        //
        public override ICryptoTransform GetEncryptionTransform(string algorithmUri, byte[] iv)
        {
            ICryptoTransform transform;

            switch (algorithmUri)
            {
                case SecurityAlgorithms.Aes128Encryption:
                    using (InfoCardSymmetricAlgorithm symAlgo = new InfoCardSymmetricAlgorithm(m_cryptoHandle))
                    {
                        symAlgo.IV = iv;
                        transform = symAlgo.CreateEncryptor();
                    }
                    break;
                default:
                    throw IDT.ThrowHelperError(new NotSupportedException(SR.GetString(SR.ClientUnsupportedCryptoAlgorithm, algorithmUri)));
            }

            return transform;
        }