mail-archives/mono-list/2003-October/016121.html

160 строки
5.1 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-list] TripleDES differences between Mono 0.28 &amp; .NET
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:spouliot%40videotron.ca">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK REL="Previous" HREF="016120.html">
<LINK REL="Next" HREF="016124.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-list] TripleDES differences between Mono 0.28 &amp; .NET
</H1>
<B>Sébastien Pouliot
</B>
<A HREF="mailto:spouliot%40videotron.ca"
TITLE="[Mono-list] TripleDES differences between Mono 0.28 &amp; .NET">spouliot@videotron.ca
</A><BR>
<I>Fri, 03 Oct 2003 20:30:32 -0400</I>
<P><UL>
<LI> Previous message: <A HREF="016120.html">[Mono-list] TripleDES differences between Mono 0.28 &amp; .NET
</A></li>
<LI> Next message: <A HREF="016124.html">[Mono-list] TripleDES differences between Mono 0.28 &amp; .NET
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16121">[ date ]</a>
<a href="thread.html#16121">[ thread ]</a>
<a href="subject.html#16121">[ subject ]</a>
<a href="author.html#16121">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Carlos,
I'm happy to report that there are no bug in TripleDES ;-).
The actual problem (still to be found) lies in CryptoStream.
For a quick fix you can rewrite your code to avoid CryptoStream like:
// Encryption ( fragment + mac [+ padding + padding_length] )
MemoryStream ms = new MemoryStream();
ms.Write (fragment, 0, fragment.Length);
ms.Write (mac, 0, mac.Length);
if (cipherMode == CipherMode.CBC) {
// Calculate padding_length
int fragmentLength = fragment.Length + mac.Length + 1;
int padding = (((fragmentLength/blockSize)*8) + blockSize) -
fragmentLength;
// Write padding length byte
ms.WriteByte((byte)padding);
}
byte[] data = ms.ToArray ();
byte[] ecrFragment = encryptionCipher.TransformFinalBlock (data, 0,
data.Length);
// Show result
Print(ecrFragment);
This should work correctly on both Mono and MS framework.
I'll update bugzilla and, hopefully, correct CryptoStream this weekend.
Sebastien Pouliot
Security Architect, Motus Technologies, <A HREF="http://www.motus.com">http://www.motus.com</A>
work: <A HREF="mailto:spouliot@motus.com">spouliot@motus.com</A>
home: <A HREF="mailto:spouliot@videotron.ca">spouliot@videotron.ca</A>
blog: <A HREF="http://pages.infinit.net/ctech/poupou.html">http://pages.infinit.net/ctech/poupou.html</A>
-----Original Message-----
From: <A HREF="mailto:mono-list-admin@lists.ximian.com">mono-list-admin@lists.ximian.com</A>
[mailto:<A HREF="mailto:mono-list-admin@lists.ximian.com">mono-list-admin@lists.ximian.com</A>]On Behalf Of Carlos Guzman
Alvarez
Sent: 3 octobre 2003 06:56
To: Mono-List
Subject: [Mono-list] TripleDES differences between Mono 0.28 &amp; .NET
Hello:
I have made a little test case for test TripleDES using mono &amp; ms.net
and there are differences in the results.
The test case is based on a piece of code from my TLS Library ( that as
i said some time ago is working well under Windows with MS.NET but not
with Mono on Linux ):
Output of the test case using MS.NET:
9c99568e753e02955b5c468bcff82721535f3dd81695823d889b9a47da979086500e48eee79b
2541
1400000cb58608e6b94b1381658e76be
2a94e53ab9f99a839d4fb0a88f470076050a5f08
Output of the Test case using Mono 0.28 (Windows)
9c99568e753e02955b5c468bcff82721535f3dd81695823d889b9a47da9790868f3e78b6ef62
4695
1400000cb58608e6b94b1381
658e76be2a94e53ab9f99a839d4fb0a88f470076
Output of the Test case using Mono 0.28 (Linux Red Hat 8)
9c99568e753e02955b5c468bcff82721535f3dd81695823d889b9a47da9790868f3e78b6ef62
4695
1400000cb58608e6b94b1381
658e76be2a94e53ab9f99a839d4fb0a88f470076
Output of the case using the exe built with mono 0.28 and the MS .NET
runtime ( runnig test.exe directly in the console seems to be using the
MS.NET framework )
9c99568e753e02955b5c468bcff82721535f3dd81695823d889b9a47da979086500e48eee79b
2541
1400000cb58608e6b94b1381658e76be
2a94e53ab9f99a839d4fb0a88f470076050a5f08
If anybody can confirm this i will fill a bug report in mono bugzilla.
The test case source code is attached to this email.
--
Best regards
Carlos Guzmán Álvarez
Vigo-Spain
&quot;Todos somos muy ignorantes. Lo que ocurre es que no todos ignoramos las
mismas cosas.&quot;
Albert Einstein.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="016120.html">[Mono-list] TripleDES differences between Mono 0.28 &amp; .NET
</A></li>
<LI> Next message: <A HREF="016124.html">[Mono-list] TripleDES differences between Mono 0.28 &amp; .NET
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16121">[ date ]</a>
<a href="thread.html#16121">[ thread ]</a>
<a href="subject.html#16121">[ subject ]</a>
<a href="author.html#16121">[ author ]</a>
</LI>
</UL>
</body></html>