protected ArraySegment<byte> Encrypt(
ArraySegment<byte> dataToEncrypt,
ArraySegment<byte> headerToCopy,
X509Certificate2 receiverCertificate)
{
switch (SecurityPolicyUri)
{
default:
case SecurityPolicies.None:
{
byte[] encryptedBuffer = BufferManager.TakeBuffer(SendBufferSize, "Encrypt");
Array.Copy(headerToCopy.Array, headerToCopy.Offset, encryptedBuffer, 0, headerToCopy.Count);
Array.Copy(dataToEncrypt.Array, dataToEncrypt.Offset, encryptedBuffer, headerToCopy.Count, dataToEncrypt.Count);
return new ArraySegment<byte>(encryptedBuffer, 0, dataToEncrypt.Count+headerToCopy.Count);
}
case SecurityPolicies.Basic256:
case SecurityPolicies.Basic256Sha256:
{
return Rsa_Encrypt(dataToEncrypt, headerToCopy, receiverCertificate, true);
}
case SecurityPolicies.Basic128Rsa15:
{
return Rsa_Encrypt(dataToEncrypt, headerToCopy, receiverCertificate, false);
}
}
}