Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2002-10-15 06:38:08 +0400
committerSebastien Pouliot <sebastien@ximian.com>2002-10-15 06:38:08 +0400
commit5b34a1b4540b3376cb78b40b37055287000a271e (patch)
tree1bb74e676752d9a218e87e80d134df5ac0db69b6 /mcs
parentbc3ac058f58075044c6d6fc8cd446b519d8af314 (diff)
2002-10-14 Sebastien Pouliot <spouliot@videotron.ca>
* PKCS1MaskGenerationMethod.cs: Added [CLSCompliant(false)] to methods using uint svn path=/trunk/mcs/; revision=8275
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/PKCS1MaskGenerationMethod.cs63
1 files changed, 32 insertions, 31 deletions
diff --git a/mcs/class/corlib/System.Security.Cryptography/PKCS1MaskGenerationMethod.cs b/mcs/class/corlib/System.Security.Cryptography/PKCS1MaskGenerationMethod.cs
index 1824edd43f1..e07db5a0cbf 100644
--- a/mcs/class/corlib/System.Security.Cryptography/PKCS1MaskGenerationMethod.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/PKCS1MaskGenerationMethod.cs
@@ -2,7 +2,7 @@
// PKCS1MaskGenerationMethod.cs: Handles PKCS#1 mask generation.
//
// Author:
-// Sebastien Pouliot (spouliot@motus.com)
+// Sebastien Pouliot (spouliot@motus.com)
//
// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
//
@@ -10,13 +10,13 @@
using System;
using System.Security.Cryptography;
-namespace System.Security.Cryptography
-{
+namespace System.Security.Cryptography {
-// PKCS#1: RSA Cryptography Standard
-// http://www.rsasecurity.com/rsalabs/pkcs/pkcs-1/index.html
-public class PKCS1MaskGenerationMethod : MaskGenerationMethod
-{
+// References:
+// a. PKCS#1: RSA Cryptography Standard
+// http://www.rsasecurity.com/rsalabs/pkcs/pkcs-1/index.html
+
+public class PKCS1MaskGenerationMethod : MaskGenerationMethod {
private string hashName;
public PKCS1MaskGenerationMethod()
@@ -32,49 +32,50 @@ public class PKCS1MaskGenerationMethod : MaskGenerationMethod
// I2OSP converts a nonnegative integer to an octet string of a specified length.
// in this case xLen is always 4 so we simplify the function
- protected byte[] I2OSP( uint x )
+ [CLSCompliant(false)]
+ protected byte[] I2OSP (uint x)
{
- byte[] array = BitConverter.GetBytes( x );
- Array.Reverse( array ); // big-little endian issues
+ byte[] array = BitConverter.GetBytes (x);
+ Array.Reverse (array); // big-little endian issues
return array;
}
// from MGF1 on page 48 from PKCS#1 v2.1 (pdf version)
- public override byte[] GenerateMask( byte[] mgfSeed, int maskLen )
+ [CLSCompliant(false)]
+ public override byte[] GenerateMask (byte[] mgfSeed, int maskLen)
{
// 1. If maskLen > 2^32 hLen, output “mask too long” and stop.
// easy - this is impossible by using a int (32bits) as parameter ;-)
int mgfSeedLength = mgfSeed.Length;
- HashAlgorithm hash = HashAlgorithm.Create( hashName );
- int hLen = ( hash.HashSize >> 3 ); // from bits to bytes
- int iterations = ( maskLen / hLen );
- if ( maskLen % hLen != 0 )
+ HashAlgorithm hash = HashAlgorithm.Create (hashName);
+ int hLen = (hash.HashSize >> 3); // from bits to bytes
+ int iterations = (maskLen / hLen);
+ if (maskLen % hLen != 0)
iterations++;
// 2. Let T be the empty octet string.
- byte[] T = new byte[ ( iterations * hLen ) ];
+ byte[] T = new byte [iterations * hLen];
- byte[] toBeHashed = new byte[ mgfSeedLength + 4 ];
+ byte[] toBeHashed = new byte [mgfSeedLength + 4];
int pos = 0;
- // 3. For counter from 0 to ( maskLen / hLen ) – 1, do the following:
- for ( uint counter = 0; counter < iterations; counter++ )
- {
- // a. Convert counter to an octet string C of length 4 octets
- // C = I2OSP (counter, 4)
- byte[] C = I2OSP( counter );
+ // 3. For counter from 0 to (maskLen / hLen) – 1, do the following:
+ for (uint counter = 0; counter < iterations; counter++) {
+ // a. Convert counter to an octet string C of length 4 octets
+ // C = I2OSP (counter, 4)
+ byte[] C = I2OSP (counter);
- // b. Concatenate the hash of the seed mgfSeed and C to the octet string T:
- // T = T || Hash (mgfSeed || C)
- Array.Copy( mgfSeed, 0, toBeHashed, 0, mgfSeedLength );
- Array.Copy( C, 0, toBeHashed, mgfSeedLength, 4 );
- byte[] output = hash.ComputeHash( toBeHashed );
- Array.Copy( output, 0, T, pos, hLen );
+ // b. Concatenate the hash of the seed mgfSeed and C to the octet string T:
+ // T = T || Hash (mgfSeed || C)
+ Array.Copy (mgfSeed, 0, toBeHashed, 0, mgfSeedLength);
+ Array.Copy (C, 0, toBeHashed, mgfSeedLength, 4);
+ byte[] output = hash.ComputeHash (toBeHashed);
+ Array.Copy (output, 0, T, pos, hLen);
pos += mgfSeedLength;
}
// 4. Output the leading maskLen octets of T as the octet string mask.
- byte[] mask = new byte[ maskLen ];
- Array.Copy( T, 0, mask, 0, maskLen );
+ byte[] mask = new byte [maskLen];
+ Array.Copy (T, 0, mask, 0, maskLen);
return mask;
}
}