PKCS1MaskGenerationMethod.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Cryptography / PKCS1MaskGenerationMethod.cs / 1305376 / PKCS1MaskGenerationMethod.cs

                            // ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 
// [....]
// 
 
namespace System.Security.Cryptography {
[System.Runtime.InteropServices.ComVisible(true)] 
    public class PKCS1MaskGenerationMethod : MaskGenerationMethod
    {
        private String HashNameValue;
 
        //
        // public constructors 
        // 

        public PKCS1MaskGenerationMethod() { 
            HashNameValue = "SHA1";
        }

        // 
        // public properties
        // 
 
        public String HashName {
            get { return HashNameValue; } 
            set {
                HashNameValue = value;
                if (HashNameValue == null) {
                    HashNameValue = "SHA1"; 
                }
            } 
        } 

        // 
        // public methods
        //

        [System.Security.SecuritySafeCritical]  // auto-generated 
        public override byte[] GenerateMask(byte[] rgbSeed, int cbReturn)
        { 
            HashAlgorithm hash = (HashAlgorithm) CryptoConfig.CreateFromName(HashNameValue); 
            byte[] rgbCounter = new byte[4];
            byte[] rgbT = new byte[cbReturn]; 

            uint counter = 0;
            for (int ib=0; ib _hash.Length) {
                    Buffer.BlockCopy(_hash, 0, rgbT, ib, _hash.Length);
                } else {
                    Buffer.BlockCopy(_hash, 0, rgbT, ib, rgbT.Length - ib); 
                }
                ib += hash.Hash.Length; 
            } 
            return rgbT;
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK