[System.Security.SecuritySafeCritical] // auto-generated public RNGCryptoServiceProvider(CspParameters cspParams) { if (cspParams != null) { m_safeProvHandle = Utils.AcquireProvHandle(cspParams); m_ownsHandle = true; } else { m_safeProvHandle = Utils.StaticProvHandle; m_ownsHandle = false; } }
public RNGCryptoServiceProvider(CspParameters cspParams) { if (cspParams != null) { this.m_safeProvHandle = Utils.AcquireProvHandle(cspParams); this.m_ownsHandle = true; return; } this.m_safeProvHandle = Utils.StaticProvHandle; this.m_ownsHandle = false; }
[System.Security.SecurityCritical] // auto-generated internal CryptoAPITransform(int algid, int cArgs, int[] rgArgIds, Object[] rgArgValues, byte[] rgbKey, PaddingMode padding, CipherMode cipherChainingMode, int blockSize, int feedbackSize, bool useSalt, CryptoAPITransformMode encDecMode) { int dwValue; byte[] rgbValue; BlockSizeValue = blockSize; ModeValue = cipherChainingMode; PaddingValue = padding; encryptOrDecrypt = encDecMode; // Copy the input args int _cArgs = cArgs; int[] _rgArgIds = new int[rgArgIds.Length]; Array.Copy(rgArgIds, _rgArgIds, rgArgIds.Length); _rgbKey = new byte[rgbKey.Length]; Array.Copy(rgbKey, _rgbKey, rgbKey.Length); Object[] _rgArgValues = new Object[rgArgValues.Length]; // an element of rgArgValues can only be an int or a byte[] for (int j = 0; j < rgArgValues.Length; j++) { if (rgArgValues[j] is byte[]) { byte[] rgbOrig = (byte[])rgArgValues[j]; byte[] rgbNew = new byte[rgbOrig.Length]; Array.Copy(rgbOrig, rgbNew, rgbOrig.Length); _rgArgValues[j] = rgbNew; continue; } if (rgArgValues[j] is int) { _rgArgValues[j] = (int)rgArgValues[j]; continue; } if (rgArgValues[j] is CipherMode) { _rgArgValues[j] = (int)rgArgValues[j]; continue; } } _safeProvHandle = Utils.AcquireProvHandle(new CspParameters(Utils.DefaultRsaProviderType)); SafeKeyHandle safeKeyHandle = SafeKeyHandle.InvalidHandle; // _ImportBulkKey will check for failures and throw an exception Utils._ImportBulkKey(_safeProvHandle, algid, useSalt, _rgbKey, ref safeKeyHandle); _safeKeyHandle = safeKeyHandle; for (int i = 0; i < cArgs; i++) { switch (rgArgIds[i]) { case Constants.KP_IV: IVValue = (byte[])_rgArgValues[i]; rgbValue = IVValue; Utils.SetKeyParamRgb(_safeKeyHandle, _rgArgIds[i], rgbValue, rgbValue.Length); break; case Constants.KP_MODE: ModeValue = (CipherMode)_rgArgValues[i]; dwValue = (Int32)_rgArgValues[i]; SetAsDWord: Utils.SetKeyParamDw(_safeKeyHandle, _rgArgIds[i], dwValue); break; case Constants.KP_MODE_BITS: dwValue = (Int32)_rgArgValues[i]; goto SetAsDWord; case Constants.KP_EFFECTIVE_KEYLEN: dwValue = (Int32)_rgArgValues[i]; goto SetAsDWord; default: throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeyParameter"), "_rgArgIds[i]"); } } }
internal CryptoAPITransform(int algid, int cArgs, int[] rgArgIds, object[] rgArgValues, byte[] rgbKey, PaddingMode padding, CipherMode cipherChainingMode, int blockSize, int feedbackSize, bool useSalt, CryptoAPITransformMode encDecMode) { this.BlockSizeValue = blockSize; this.ModeValue = cipherChainingMode; this.PaddingValue = padding; this.encryptOrDecrypt = encDecMode; int[] numArray1 = new int[rgArgIds.Length]; Array.Copy((Array)rgArgIds, (Array)numArray1, rgArgIds.Length); this._rgbKey = new byte[rgbKey.Length]; Array.Copy((Array)rgbKey, (Array)this._rgbKey, rgbKey.Length); object[] objArray = new object[rgArgValues.Length]; for (int index = 0; index < rgArgValues.Length; ++index) { if (rgArgValues[index] is byte[]) { byte[] numArray2 = (byte[])rgArgValues[index]; byte[] numArray3 = new byte[numArray2.Length]; Array.Copy((Array)numArray2, (Array)numArray3, numArray2.Length); objArray[index] = (object)numArray3; } else if (rgArgValues[index] is int) { objArray[index] = (object)(int)rgArgValues[index]; } else if (rgArgValues[index] is CipherMode) { objArray[index] = (object)(int)rgArgValues[index]; } } this._safeProvHandle = Utils.AcquireProvHandle(new CspParameters(24)); SafeKeyHandle invalidHandle = SafeKeyHandle.InvalidHandle; Utils._ImportBulkKey(this._safeProvHandle, algid, useSalt, this._rgbKey, ref invalidHandle); this._safeKeyHandle = invalidHandle; for (int index = 0; index < cArgs; ++index) { int dwValue; switch (rgArgIds[index]) { case 1: this.IVValue = (byte[])objArray[index]; byte[] numArray2 = this.IVValue; SafeKeyHandle hKey = this._safeKeyHandle; int num = numArray1[index]; byte[] numArray3 = numArray2; int length = numArray3.Length; Utils.SetKeyParamRgb(hKey, num, numArray3, length); continue; case 4: this.ModeValue = (CipherMode)objArray[index]; dwValue = (int)objArray[index]; break; case 5: dwValue = (int)objArray[index]; break; case 19: dwValue = (int)objArray[index]; break; default: throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeyParameter"), "_rgArgIds[i]"); } Utils.SetKeyParamDw(this._safeKeyHandle, numArray1[index], dwValue); } }
internal CryptoAPITransform(int algid, int cArgs, int[] rgArgIds, object[] rgArgValues, byte[] rgbKey, PaddingMode padding, CipherMode cipherChainingMode, int blockSize, int feedbackSize, bool useSalt, CryptoAPITransformMode encDecMode) { this.BlockSizeValue = blockSize; this.ModeValue = cipherChainingMode; this.PaddingValue = padding; this.encryptOrDecrypt = encDecMode; int[] array = new int[rgArgIds.Length]; Array.Copy(rgArgIds, array, rgArgIds.Length); this._rgbKey = new byte[rgbKey.Length]; Array.Copy(rgbKey, this._rgbKey, rgbKey.Length); object[] array2 = new object[rgArgValues.Length]; for (int i = 0; i < rgArgValues.Length; i++) { if (rgArgValues[i] is byte[]) { byte[] array3 = (byte[])rgArgValues[i]; byte[] array4 = new byte[array3.Length]; Array.Copy(array3, array4, array3.Length); array2[i] = array4; } else if (rgArgValues[i] is int) { array2[i] = (int)rgArgValues[i]; } else if (rgArgValues[i] is CipherMode) { array2[i] = (int)rgArgValues[i]; } } this._safeProvHandle = Utils.AcquireProvHandle(new CspParameters(24)); SafeKeyHandle invalidHandle = SafeKeyHandle.InvalidHandle; Utils._ImportBulkKey(this._safeProvHandle, algid, useSalt, this._rgbKey, ref invalidHandle); this._safeKeyHandle = invalidHandle; int j = 0; while (j < cArgs) { int num = rgArgIds[j]; int dwValue; switch (num) { case 1: { this.IVValue = (byte[])array2[j]; byte[] ivvalue = this.IVValue; Utils.SetKeyParamRgb(this._safeKeyHandle, array[j], ivvalue, ivvalue.Length); break; } case 2: case 3: goto IL_1D7; case 4: this.ModeValue = (CipherMode)array2[j]; dwValue = (int)array2[j]; goto IL_1AB; case 5: dwValue = (int)array2[j]; goto IL_1AB; default: if (num != 19) { goto IL_1D7; } dwValue = (int)array2[j]; goto IL_1AB; } IL_1EC: j++; continue; IL_1AB: Utils.SetKeyParamDw(this._safeKeyHandle, array[j], dwValue); goto IL_1EC; IL_1D7: throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeyParameter"), "_rgArgIds[i]"); } }
internal CryptoAPITransform(int algid, int cArgs, int[] rgArgIds, object[] rgArgValues, byte[] rgbKey, PaddingMode padding, CipherMode cipherChainingMode, int blockSize, int feedbackSize, bool useSalt, CryptoAPITransformMode encDecMode) { this.BlockSizeValue = blockSize; this.ModeValue = cipherChainingMode; this.PaddingValue = padding; this.encryptOrDecrypt = encDecMode; int[] destinationArray = new int[rgArgIds.Length]; Array.Copy(rgArgIds, destinationArray, rgArgIds.Length); this._rgbKey = new byte[rgbKey.Length]; Array.Copy(rgbKey, this._rgbKey, rgbKey.Length); object[] objArray = new object[rgArgValues.Length]; for (int i = 0; i < rgArgValues.Length; i++) { if (rgArgValues[i] is byte[]) { byte[] sourceArray = (byte[])rgArgValues[i]; byte[] buffer3 = new byte[sourceArray.Length]; Array.Copy(sourceArray, buffer3, sourceArray.Length); objArray[i] = buffer3; } else if (rgArgValues[i] is int) { objArray[i] = (int)rgArgValues[i]; } else if (rgArgValues[i] is CipherMode) { objArray[i] = (int)rgArgValues[i]; } } this._safeProvHandle = Utils.AcquireProvHandle(new CspParameters(Utils.DefaultRsaProviderType)); SafeKeyHandle invalidHandle = SafeKeyHandle.InvalidHandle; Utils._ImportBulkKey(this._safeProvHandle, algid, useSalt, this._rgbKey, ref invalidHandle); this._safeKeyHandle = invalidHandle; for (int j = 0; j < cArgs; j++) { int num; switch (rgArgIds[j]) { case 1: { this.IVValue = (byte[])objArray[j]; byte[] iVValue = this.IVValue; Utils.SetKeyParamRgb(this._safeKeyHandle, destinationArray[j], iVValue, iVValue.Length); continue; } case 4: this.ModeValue = (CipherMode)objArray[j]; num = (int)objArray[j]; break; case 5: num = (int)objArray[j]; break; case 0x13: num = (int)objArray[j]; break; default: throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeyParameter"), "_rgArgIds[i]"); } Utils.SetKeyParamDw(this._safeKeyHandle, destinationArray[j], num); } }