/// <summary>
        /// <inheritdoc cref="Encrypter.Decrypt{T}"/>
        /// </summary>
        /// <param name="encryptedObject"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public override T Decrypt <T>(EncryptedObject encryptedObject)
        {
            if (!(encryptedObject is EncryptedObjectPKCS7 eo))
            {
                return(null);
            }
            var plainString = Decrypt(eo.CipherText);

            return(JsonConvert.DeserializeObject <T>(plainString, encryptionSerializerSettings));
        }
Пример #2
0
        /// <summary>
        /// <inheritdoc cref="Encrypter.Decrypt{T}"/>
        /// </summary>
        /// <param name="encryptedObject"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public override T Decrypt <T>(EncryptedObject encryptedObject)
        {
            var eo = (EncryptedObjectAEAD)encryptedObject;

            if (eo == null)
            {
                return(null);
            }
            var plainString = Decrypt(eo.CipherText, eo.AssociatedData, eo.Nonce);

            return(JsonConvert.DeserializeObject <T>(plainString, encryptionSerializerSettings));
        }
Пример #3
0
        /// <summary>
        /// <inheritdoc cref="Encrypter.Decrypt"/>
        /// </summary>
        /// <param name="encryptedObject"></param>
        /// <returns></returns>
        public override BusinessObject Decrypt(EncryptedObject encryptedObject)
        {
            var
                eo = (EncryptedObjectAEAD)encryptedObject; //(EncryptedObjectAEAD)BoMapper.MapObject("EncryptedObjectAEAD", JObject.FromObject(encryptedObject));

            if (eo == null)
            {
                return(null);
            }
            var plainString = Decrypt(eo.CipherText, eo.AssociatedData, eo.Nonce);

            return(JsonConvert.DeserializeObject <BusinessObject>(plainString, encryptionSerializerSettings));
        }
Пример #4
0
        /// <summary>
        /// <inheritdoc cref="Encrypter.Decrypt{T}"/>
        /// </summary>
        /// <param name="encryptedObject"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public override T Decrypt <T>(EncryptedObject encryptedObject)
        {
            var
                eo = (EncryptedObjectPublicKeyBox)
                     encryptedObject; // (EncryptedObjectPublicKeyBox)BoMapper.MapObject("EncryptedObjectPublicKeyBox", JObject.FromObject(encryptedObject));

            if (eo == null)
            {
                return(null);
            }
            var plainString = Decrypt(eo.CipherText, eo.PublicKey, eo.Nonce);

            return(JsonConvert.DeserializeObject <T>(plainString, encryptionSerializerSettings));
        }
Пример #5
0
 /// <summary>
 /// Decrypt <paramref name="encryptedObject"/>
 /// </summary>
 /// <param name="encryptedObject"></param>
 /// <typeparam name="T">expected type</typeparam>
 /// <returns>decrypted object</returns>
 public abstract T Decrypt <T>(EncryptedObject encryptedObject) where T : BusinessObject;
Пример #6
0
 /// <summary>
 ///     decrypt an encrypted Business Object
 /// </summary>
 /// <param name="encryptedObject">an encrypted Business Object</param>
 /// <returns>a decrypted Business Object</returns>
 public abstract BusinessObject Decrypt(EncryptedObject encryptedObject);