2003-05-12 Sebastien Pouliot <spouliot@videotron.ca>
authorSebastien Pouliot <sebastien@ximian.com>
Tue, 13 May 2003 01:44:47 +0000 (01:44 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Tue, 13 May 2003 01:44:47 +0000 (01:44 -0000)
* PKCS1.cs: Corrected I2OSP to match PKCS#1 v.2.1 test vector
and fix the OAEP incompatibility issue.

svn path=/trunk/mcs/; revision=14522

mcs/class/corlib/Mono.Security.Cryptography/ChangeLog
mcs/class/corlib/Mono.Security.Cryptography/PKCS1.cs

index b4f67b24d75ea7e7073268d7222dcdeacc2ff8f7..89edfcc0d84dd82bbc7480da02e058b44fdab6a4 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-12  Sebastien Pouliot  <spouliot@videotron.ca>
+
+       * PKCS1.cs: Corrected I2OSP to match PKCS#1 v.2.1 test vector
+       and fix the OAEP incompatibility issue.
+
 2003-04-01  Sebastien Pouliot  <spouliot@videotron.ca>
 
        * PKCS1.cs: Corrected fix (partially) for the lame PKCS1 v1.5
index fd93f0d9dd28be5a4cb744f8d4cbe70dfb2bfa67..63321e6d07a38091c8d0f2cd66609bc9270f6a48 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Sebastien Pouliot (spouliot@motus.com)
 //
-// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
 //
 
 using System;
@@ -61,6 +61,7 @@ namespace Mono.Security.Cryptography {
                public static byte[] I2OSP (int x, int size) 
                {
                        byte[] array = BitConverter.GetBytes (x);
+                       Array.Reverse (array, 0, array.Length);
                        return I2OSP (array, size);
                }
        
@@ -176,7 +177,7 @@ namespace Mono.Security.Cryptography {
                        byte[] DB = xor (maskedDB, dbMask);
        
                        byte[] lHash = GetEmptyHash (hash);
-                       // split DB = lHash\19 || PS || 0x01 || M
+                       // split DB = lHash' || PS || 0x01 || M
                        byte[] dbHash = new byte [lHash.Length];
                        Array.Copy (DB, 0, dbHash, 0, dbHash.Length);
                        bool h = Compare (lHash, dbHash);
@@ -375,7 +376,7 @@ namespace Mono.Security.Cryptography {
                        // 3. For counter from 0 to (maskLen / hLen) \13 1, do the following:
                        for (int counter = 0; counter < iterations; counter++) {
                                // a.   Convert counter to an octet string C of length 4 octets
-                               byte[] C = I2OSP (counter, 4);
+                               byte[] C = I2OSP (counter, 4); 
        
                                // b.   Concatenate the hash of the seed mgfSeed and C to the octet string T:
                                //      T = T || Hash (mgfSeed || C)