示例#1
0
        /// <summary>
        /// Encrypts and signs the specified buffer with data for current enumeration of <see cref="VirgilCard"/> recipients.
        /// </summary>
        /// <param name="task">The list of <see cref="VirgilCard"/> recipients.</param>
        /// <param name="buffer">The buffer data to be encrypted.</param>
        /// <param name="key">The signer's <see cref="VirgilKey"/></param>
        /// <returns>A new <see cref="VirgilBuffer"/> with encrypted data.</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static Task <VirgilBuffer> SignThenEncrypt(this Task <IEnumerable <VirgilCard> > task, VirgilBuffer buffer, VirgilKey key)
        {
            return(task.ContinueWith(t =>
            {
                if (t.Exception == null && !t.Result.Any())
                {
                    throw new RecipientsNotFoundException();
                }

                return key.SignThenEncrypt(buffer, t.Result);
            }));
        }
示例#2
0
 /// <summary>
 /// Encrypts the specified data for current <see cref="VirgilCard" /> recipient.
 /// </summary>
 /// <param name="task">The <see cref="VirgilCard" /> recipient</param>
 /// <param name="buffer">The buffer with data to be encrypted.</param>
 /// <param name="key">The signer's key.</param>
 /// <returns>
 /// A new <see cref="VirgilBuffer" /> with encrypted data.
 /// </returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static Task <VirgilBuffer> SignThenEncrypt(this Task <VirgilCard> task, VirgilBuffer buffer, VirgilKey key)
 {
     return(task.ContinueWith(t => key.SignThenEncrypt(buffer, new[] { t.Result })));
 }
示例#3
0
 /// <summary>
 /// Signs the plaintext using current <see cref="VirgilKey"/> and then encrypt it
 /// using recipient's <see cref="VirgilCard"/>.
 /// </summary>
 /// <param name="virgilKey">The <see cref="VirgilKey"/> used to sign the <paramref name="plaintext"/>.</param>
 /// <param name="plaintext">The plaintext to be encrypted.</param>
 /// <param name="recipient">The recipient's <see cref="VirgilCard"/> used to
 /// encrypt the <paramref name="plaintext"/>.</param>
 /// <returns>A new <see cref="VirgilBuffer"/> instance with encrypted data.</returns>
 public static VirgilBuffer SignThenEncrypt(this VirgilKey virgilKey, string plaintext, VirgilCard recipient)
 {
     return(virgilKey.SignThenEncrypt(VirgilBuffer.From(plaintext), new [] { recipient }));
 }
示例#4
0
 /// <summary>
 /// Signs a byte array data using current <see cref="VirgilKey"/> and then encrypt it
 /// using recipient's <see cref="VirgilCard"/>.
 /// </summary>
 /// <param name="virgilKey">The <see cref="VirgilKey"/> used to sign the <paramref name="data"/>.</param>
 /// <param name="data">The plaintext to be encrypted.</param>
 /// <param name="recipient">The recipient's <see cref="VirgilCard"/> used to
 /// encrypt the <paramref name="data"/>.</param>
 /// <returns>A new <see cref="VirgilBuffer"/> instance with encrypted data.</returns>
 public static VirgilBuffer SignThenEncrypt(this VirgilKey virgilKey, byte[] data, VirgilCard recipient)
 {
     return(virgilKey.SignThenEncrypt(VirgilBuffer.From(data), new[] { recipient }));
 }
示例#5
0
 /// <summary>
 /// Signs a plaintext using current <see cref="VirgilKey"/> and then encrypt it
 /// using multiple recipient's <see cref="VirgilCard"/>s.
 /// </summary>
 /// <param name="virgilKey">The <see cref="VirgilKey"/> used to sign the <paramref name="plaintext"/>.</param>
 /// <param name="plaintext">The plaintext to be encrypted.</param>
 /// <param name="recipients">A list of recipient's <see cref="VirgilCard"/>s used to
 /// encrypt the <paramref name="plaintext"/>.</param>
 /// <returns>A new <see cref="VirgilBuffer"/> instance with encrypted data.</returns>
 public static VirgilBuffer SignThenEncrypt(this VirgilKey virgilKey, string plaintext, IEnumerable <VirgilCard> recipients)
 {
     return(virgilKey.SignThenEncrypt(VirgilBuffer.From(plaintext), recipients));
 }
示例#6
0
 /// <summary>
 /// Signs a byte array data using current <see cref="VirgilKey"/> and then encrypt it
 /// using multiple recipient's <see cref="VirgilCard"/>s.
 /// </summary>
 /// <param name="virgilKey">The <see cref="VirgilKey"/> used to sign the <paramref name="data"/>.</param>
 /// <param name="data">The data to be encrypted.</param>
 /// <param name="recipients">A list of recipient's <see cref="VirgilCard"/>s used to
 /// encrypt the <paramref name="data"/>.</param>
 /// <returns>A new <see cref="VirgilBuffer"/> instance with encrypted data.</returns>
 public static VirgilBuffer SignThenEncrypt(this VirgilKey virgilKey, byte[] data, IEnumerable <VirgilCard> recipients)
 {
     return(virgilKey.SignThenEncrypt(VirgilBuffer.From(data), recipients));
 }