/// <summary>
 /// Initializes a new instance of <see cref="SymmetricEncryptionConfiguration"/> with default settings consisting of:
 /// <see cref="SymmetricAlgorithmType.Aes"/> encryption using <see cref="System.Security.Cryptography.CipherMode.CBC"/> and <see cref="System.Security.Cryptography.PaddingMode.PKCS7"/>.
 /// Plaintext strings are encoded using a UTF8 transform.
 /// All other strings (ciphertext, key, and IV strings) are encoded using a hex transform.
 /// </summary>
 public SymmetricEncryptionConfiguration()
 {
     AlgorithmType       = SymmetricAlgorithmType.Aes;
     CipherMode          = CipherMode.CBC;
     PaddingMode         = PaddingMode.PKCS7;
     PlainTextTransform  = StringTransform.FromEncoding(Encoding.UTF8);
     CipherTextTransform = StringTransform.GetHexTransform();
     KeyTransform        = StringTransform.GetHexTransform();
     IvTransform         = StringTransform.GetHexTransform();
 }
Exemplo n.º 2
0
 public static IStringTransform[] IntroduceAntecedent(IStringTransform[] lhs, IStringTransform[] rhs)
 {
     var temp = new List<IStringTransform>(lhs);
     foreach (var rhsTransform in rhs) {
         var temp2 = new List<IStringTransform>();
         foreach (var lhsTransform in lhs) {
             temp2.AddRange(IntroduceAntecedent(lhsTransform, rhsTransform));
         }
         temp = temp2;
     }
     return Coallesce(temp);
 }
Exemplo n.º 3
0
 public static IStringTransform[] WithdrawSubsequent(IStringTransform[] lhs, IStringTransform[] rhs)
 {
     var temp = new List<IStringTransform>(lhs);
     foreach (var rhsTransform in rhs.Reverse<IStringTransform>()) {
         var temp2 = new List<IStringTransform>();
         foreach (var lhsTransform in lhs) {
             temp2.AddRange(IntroduceSubsequent(lhsTransform, rhsTransform));
         }
         temp = temp2;
     }
     return Coallesce(temp);
 }
Exemplo n.º 4
0
 static bool TryCoallesce(IStringTransform a, IStringTransform b, out IStringTransform[] result)
 {
     bool aIsInsertion = a is Insertion;
     bool bIsInsertion = b is Insertion;
     if (aIsInsertion) {
         if (bIsInsertion) {
             return TryCoallesce(a as Insertion, b as Insertion, out result);
         }
         else {
             return TryCoallesce(a as Insertion, b as Deletion, out result);
         }
     }
     else {
         if (bIsInsertion) {
             return TryCoallesce(a as Deletion, b as Insertion, out result);
         } else {
             return TryCoallesce(a as Deletion, b as Deletion, out result);
         }
     }
 }
Exemplo n.º 5
0
 static bool TryCoallesce(Insertion antecedent, Insertion subsequent, out IStringTransform[] result)
 {
     if (subsequent.Position >= antecedent.Position &&
         subsequent.Position <= antecedent.Position + antecedent.Length) {
         result = new IStringTransform[] {
             new Insertion(antecedent.Position,
                 antecedent.Contents.Substring(0, (int) (subsequent.Position - antecedent.Position)) +
                 subsequent.Contents +
                 antecedent.Contents.Substring((int) (subsequent.Position - antecedent.Position)))
         };
         return true;
     }
     else {
         result = new IStringTransform[] { antecedent, subsequent };
         return false;
     }
 }
Exemplo n.º 6
0
 static bool TryCoallesce(Insertion antecedent, Deletion subsequent, out IStringTransform[] result)
 {
     uint lengthReduction = Math.Max(0,
         Math.Min(antecedent.Position + antecedent.Length, subsequent.Position + subsequent.Length) -
         Math.Max(antecedent.Position, subsequent.Position));
     if (lengthReduction > 0) {
         List<IStringTransform> temp = new List<IStringTransform>(2);
         if (lengthReduction < antecedent.Length) {
             temp.Add(new Insertion(Math.Min(antecedent.Position, subsequent.Position),
                 antecedent.Contents.Remove((int) Math.Max((uint) 0, subsequent.Position - antecedent.Position),
                     (int) lengthReduction)));
         }
         if (lengthReduction < subsequent.Length) {
             temp.Add(new Deletion(subsequent.Position, subsequent.Length - lengthReduction));
         }
         result = temp.ToArray();
         return true;
     } else {
         result = new IStringTransform[] {antecedent, subsequent};
         return false;
     }
 }
 /// <summary>
 /// Initializes an instance of <see cref="XmlObjectCommandSerializer{TRequest, TResponse}"/> using the specified <see cref="IStringTransform"/>
 /// instances for requests and responses, respectively.
 /// </summary>
 /// <param name="requestSerializationTransform">The <see cref="IStringTransform"/> to use when transforming request data between string and byte representations.</param>
 /// <param name="responseSerializationTransform">The <see cref="IStringTransform"/> to use when transforming response data between string and byte representations.</param>
 protected XmlObjectCommandSerializer(IStringTransform requestSerializationTransform, IStringTransform responseSerializationTransform)
 {
     _requestSerializationTransform  = requestSerializationTransform;
     _responseSerializationTransform = responseSerializationTransform;
 }
 /// <summary>
 /// Initializes an instance of <see cref="NetDataContractRequestSerializer{T}"/> using the specified <see cref="IStringTransform"/> instance.
 /// </summary>
 /// <param name="serializationTransform">The <see cref="IStringTransform"/> to use when transforming data between string and byte representations.</param>
 public NetDataContractRequestSerializer(IStringTransform serializationTransform)
     : base(serializationTransform)
 {
 }
 /// <summary>
 /// Creates an instance of <see cref="NetDataContractResponseSerializer{TResponse}"/> to use for response serialization.
 /// </summary>
 /// <param name="responseSerializationTransform">The <see cref="IStringTransform"/> to use when constructing the <see cref="NetDataContractResponseSerializer{TResponse}"/></param>
 /// <returns></returns>
 protected override XmlObjectResponseSerializer <TResponse> CreateResponseSerializer(IStringTransform responseSerializationTransform)
 {
     return(new NetDataContractResponseSerializer <TResponse>(responseSerializationTransform));
 }
 /// <summary>
 /// Initializes an instance of <see cref="NetDataContractCommandSerializer{TRequest, TResponse}"/> using the specified <see cref="IStringTransform"/>
 /// instances for requests and responses, respectively.
 /// </summary>
 /// <param name="requestSerializationTransform">The <see cref="IStringTransform"/> to use when transforming request data between string and byte representations.</param>
 /// <param name="responseSerializationTransform">The <see cref="IStringTransform"/> to use when transforming response data between string and byte representations.</param>
 public NetDataContractCommandSerializer(IStringTransform requestSerializationTransform, IStringTransform responseSerializationTransform)
     : base(requestSerializationTransform, responseSerializationTransform)
 {
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes an instance of <see cref="XmlObjectResponseSerializer{T}"/> using the specified <see cref="IStringTransform"/> instance.
 /// </summary>
 /// <param name="serializationTransform">The <see cref="IStringTransform"/> to use when transforming data between string and byte representations.</param>
 protected XmlObjectResponseSerializer(IStringTransform serializationTransform)
     : base(serializationTransform)
 {
 }
 /// <summary>
 /// Initializes an instance of <see cref="XmlObjectSerializerWrapper{T}"/> using the specified <see cref="IStringTransform"/> instance.
 /// </summary>
 /// <param name="serializationTransform">The <see cref="IStringTransform"/> to use when transforming data between string and byte representations.</param>
 protected XmlObjectSerializerWrapper(IStringTransform serializationTransform)
     : base(serializationTransform)
 {
 }
 /// <summary>
 /// When overridden in a derived class, creates an instance of <see cref="XmlObjectResponseSerializer{T}"/> to use for serialization.
 /// </summary>
 /// <param name="responseSerializationTransform">The <see cref="IStringTransform"/> to use when constructing the <see cref="XmlObjectResponseSerializer{T}"/></param>
 /// <returns></returns>
 protected abstract XmlObjectResponseSerializer <TResponse> CreateResponseSerializer(IStringTransform responseSerializationTransform);
 /// <summary>
 /// When overridden in a derived class, creates an instance of <see cref="XmlObjectRequestSerializer{T}"/> to use for serialization.
 /// </summary>
 /// <param name="requestSerializationTransform">The <see cref="IStringTransform"/> to use when constructing the <see cref="XmlObjectRequestSerializer{T}"/></param>
 /// <returns></returns>
 protected abstract XmlObjectRequestSerializer <TRequest> CreateRequestSerializer(IStringTransform requestSerializationTransform);
Exemplo n.º 15
0
 static IStringTransform[] WithdrawSubsequent(IStringTransform lhs, IStringTransform rhs)
 {
     bool onIsInsertion = lhs is Insertion;
     bool itemIsInsertion = rhs is Insertion;
     if (onIsInsertion) {
         if (itemIsInsertion) {
             return WithdrawSubsequent((Insertion)lhs, (Insertion)rhs);
         } else {
             return WithdrawSubsequent((Insertion)lhs, (Deletion)rhs);
         }
     } else {
         if (itemIsInsertion) {
             return WithdrawSubsequent((Deletion)lhs, (Insertion)rhs);
         } else {
             return WithdrawSubsequent((Deletion)lhs, (Deletion)rhs);
         }
     }
 }
Exemplo n.º 16
0
 static IStringTransform[] IntroduceAntecedent(IStringTransform lhs, IStringTransform rhs)
 {
     bool onIsInsertion = lhs is Insertion;
     bool itemIsInsertion = rhs is Insertion;
     if (onIsInsertion) {
         if (itemIsInsertion) {
             return IntroduceAntecedent((Insertion) lhs, (Insertion) rhs);
         } else {
             return IntroduceAntecedent((Insertion) lhs, (Deletion) rhs);
         }
     }
     else {
         if (itemIsInsertion) {
             return IntroduceAntecedent((Deletion)lhs, (Insertion)rhs);
         } else {
             return IntroduceAntecedent((Deletion)lhs, (Deletion)rhs);
         }
     }
 }
Exemplo n.º 17
0
 static bool TryCoallesce(Deletion antecedent, Deletion subsequent, out IStringTransform[] result)
 {
     if (subsequent.Position == antecedent.Position) {
         result = new IStringTransform[]
         {new Deletion(antecedent.Position, antecedent.Length + subsequent.Length)};
         return true;
     } else {
         result = new IStringTransform[] {antecedent, subsequent};
         return false;
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Initializes an instance of <see cref="DataContractResponseSerializer{T}"/> using the specified <see cref="IStringTransform"/> instance.
 /// </summary>
 /// <param name="serializationTransform">The <see cref="IStringTransform"/> to use when transforming data between string and byte representations.</param>
 public DataContractResponseSerializer(IStringTransform serializationTransform)
     : base(serializationTransform)
 {
 }
Exemplo n.º 19
0
 static bool TryCoallesce(Deletion antecedent, Insertion subsequent, out IStringTransform[] result)
 {
     result = new IStringTransform[] { antecedent, subsequent };
     return false;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes an instance of <see cref="XmlObjectSerializerWrapper"/> using the specified <see cref="IStringTransform"/> instance.
 /// </summary>
 /// <param name="serializationTransform">The <see cref="IStringTransform"/> to use when transforming data between string and byte representations.</param>
 protected XmlObjectSerializerWrapper(IStringTransform serializationTransform)
 {
     SerializationTransform = serializationTransform;
 }
 /// <summary>
 /// Creates an instance of <see cref="DataContractRequestSerializer{TRequest}"/> to use for request serialization.
 /// </summary>
 /// <param name="requestSerializationTransform">The <see cref="IStringTransform"/> to use when constructing the <see cref="DataContractRequestSerializer{TRequest}"/></param>
 /// <returns></returns>
 protected override XmlObjectRequestSerializer <TRequest> CreateRequestSerializer(IStringTransform requestSerializationTransform)
 {
     return(new DataContractRequestSerializer <TRequest>(requestSerializationTransform));
 }