summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-08-11 08:06:49 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2010-08-11 08:06:49 -0700
commit56ccd9ee97eababf7b9f9f053a8c18dd46007a6f (patch)
treefb9c6d72b2ef685d35d5ea7eb421f97d96ed5f9d
parent680c2510601807cc6ad23626ad98ac8755744a43 (diff)
downloadDotNetOpenAuth-56ccd9ee97eababf7b9f9f053a8c18dd46007a6f.zip
DotNetOpenAuth-56ccd9ee97eababf7b9f9f053a8c18dd46007a6f.tar.gz
DotNetOpenAuth-56ccd9ee97eababf7b9f9f053a8c18dd46007a6f.tar.bz2
Added version number to symmetric encryption blob.
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs9
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingStrings.resx5
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingUtilities.cs7
3 files changed, 17 insertions, 4 deletions
diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs
index f600330..235e558 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs
+++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs
@@ -619,6 +619,15 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
+ /// Looks up a localized string similar to This blob is not a recognized encryption format..
+ /// </summary>
+ internal static string UnsupportedEncryptionAlgorithm {
+ get {
+ return ResourceManager.GetString("UnsupportedEncryptionAlgorithm", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to The HTTP verb &apos;{0}&apos; is unrecognized and unsupported..
/// </summary>
internal static string UnsupportedHttpVerb {
diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx
index 7f9d91b..fdeb756 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx
+++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx
@@ -315,4 +315,7 @@
<data name="MessageTimestampInFuture" xml:space="preserve">
<value>This message has a timestamp of {0}, which is beyond the allowable clock skew for in the future.</value>
</data>
-</root>
+ <data name="UnsupportedEncryptionAlgorithm" xml:space="preserve">
+ <value>This blob is not a recognized encryption format.</value>
+ </data>
+</root> \ No newline at end of file
diff --git a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
index 96b1fcf..7d0b913 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
@@ -513,7 +513,7 @@ namespace DotNetOpenAuth.Messaging {
var ms = new MemoryStream();
var binaryWriter = new BinaryWriter(ms);
- binaryWriter.Write(crypto.IV.Length);
+ binaryWriter.Write((byte)1); // version of encryption algorithm
binaryWriter.Write(crypto.IV);
binaryWriter.Flush();
@@ -535,8 +535,9 @@ namespace DotNetOpenAuth.Messaging {
var ms = new MemoryStream(buffer);
var binaryReader = new BinaryReader(ms);
- int ivLength = binaryReader.ReadInt32();
- crypto.IV = binaryReader.ReadBytes(ivLength);
+ int algorithmVersion = binaryReader.ReadByte();
+ ErrorUtilities.VerifyProtocol(algorithmVersion == 1, MessagingStrings.UnsupportedEncryptionAlgorithm);
+ crypto.IV = binaryReader.ReadBytes(crypto.IV.Length);
// Allocate space for the decrypted buffer. We don't know how long it will be yet,
// but it will never be larger than the encrypted buffer.