public override byte[] EncryptKey(string algorithmUri, byte[] keyData)
        {
            AsymmetricKeyExchangeFormatter formatter;
            switch (algorithmUri)
            {
                case "http://www.w3.org/2001/04/xmlenc#rsa-1_5":
                    formatter = new InfoCardRSAPKCS1KeyExchangeFormatter(this.m_rsa);
                    return formatter.CreateKeyExchange(keyData);

                case "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p":
                    formatter = new InfoCardRSAOAEPKeyExchangeFormatter(this.m_rsa);
                    return formatter.CreateKeyExchange(keyData);
            }
            throw InfoCardTrace.ThrowHelperError(new NotSupportedException(Microsoft.InfoCards.SR.GetString("ClientUnsupportedCryptoAlgorithm", new object[] { algorithmUri })));
        }
        public override byte[] EncryptKey(string algorithmUri, byte[] keyData)
        {
            AsymmetricKeyExchangeFormatter formatter;

            switch (algorithmUri)
            {
            case "http://www.w3.org/2001/04/xmlenc#rsa-1_5":
                formatter = new InfoCardRSAPKCS1KeyExchangeFormatter(this.m_rsa);
                return(formatter.CreateKeyExchange(keyData));

            case "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p":
                formatter = new InfoCardRSAOAEPKeyExchangeFormatter(this.m_rsa);
                return(formatter.CreateKeyExchange(keyData));
            }
            throw InfoCardTrace.ThrowHelperError(new NotSupportedException(Microsoft.InfoCards.SR.GetString("ClientUnsupportedCryptoAlgorithm", new object[] { algorithmUri })));
        }
Ejemplo n.º 3
0
        //
        // Summary:
        //  Encrypts a symmetric key using the public key of a public/private key pair.
        //
        // Parameters:
        //  algorithmUri  - The algorithm to use to encrypt the key.
        //  keyData       - the key to encrypt.
        //
        public override byte[] EncryptKey(string algorithmUri, byte[] keyData)
        {
            AsymmetricKeyExchangeFormatter formatter;

            switch (algorithmUri)
            {
            case EncryptedXml.XmlEncRSA15Url:

                formatter = new InfoCardRSAPKCS1KeyExchangeFormatter(m_rsa);
                return(formatter.CreateKeyExchange(keyData));

            case EncryptedXml.XmlEncRSAOAEPUrl:

                formatter = new InfoCardRSAOAEPKeyExchangeFormatter(m_rsa);
                return(formatter.CreateKeyExchange(keyData));

            default:
                throw IDT.ThrowHelperError(new NotSupportedException(SR.GetString(SR.ClientUnsupportedCryptoAlgorithm, algorithmUri)));
            }
        }
        //
        // Summary:
        //  Encrypts a symmetric key using the public key of a public/private key pair.
        //
        // Parameters:
        //  algorithmUri  - The algorithm to use to encrypt the key.
        //  keyData       - the key to encrypt.
        //
        public override byte[] EncryptKey(string algorithmUri, byte[] keyData)
        {
            AsymmetricKeyExchangeFormatter formatter;

            switch (algorithmUri)
            {
                case EncryptedXml.XmlEncRSA15Url:

                    formatter = new InfoCardRSAPKCS1KeyExchangeFormatter(m_rsa);
                    return formatter.CreateKeyExchange(keyData);

                case EncryptedXml.XmlEncRSAOAEPUrl:

                    formatter = new InfoCardRSAOAEPKeyExchangeFormatter(m_rsa);
                    return formatter.CreateKeyExchange(keyData);

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