# < Summary

Information

Class: | Renci.SshNet.Security.Org.BouncyCastle.Crypto.Prng.CryptoApiRandomGenerator
Assembly: | Renci.SshNet
File(s): | \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\BouncyCastle\crypto\prng\CryptoApiRandomGenerator.cs

Line coverage
34%

Covered lines: | 10
Uncovered lines: | 19
Coverable lines: | 29
Total lines: | 59
Line coverage: | 34.4%

Branch coverage
0%

Covered branches: | 0
Total branches: | 8
Branch coverage: | 0%

Method coverage

Feature is only available for sponsors

Upgrade to PRO version

# Metrics

Method | Branch coverage | Cyclomatic complexity | Line coverage
--- | --- | --- | ---
.ctor() | 100% | 1 | 100%
.ctor(...) | 100% | 1 | 100%
AddSeedMaterial(...) | 100% | 1 | 0%
AddSeedMaterial(...) | 100% | 1 | 0%
NextBytes(...) | 100% | 1 | 100%
NextBytes(...) | 0% | 8 | 0%

# File(s)

## \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\BouncyCastle\crypto\prng\CryptoApiRandomGenerator.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using System.Security.Cryptography;`
|  | `3` |  | ``
|  | `4` |  | `namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto.Prng`
|  | `5` |  | `{`
|  | `6` |  | `internal class CryptoApiRandomGenerator`
|  | `7` |  | `: IRandomGenerator`
|  | `8` |  | `{`
|  | `9` |  | `private readonly RandomNumberGenerator rndProv;`
|  | `10` |  | ``
|  | `11` |  | `public CryptoApiRandomGenerator()`
| 1 | `12` |  | `: this(Abstractions.CryptoAbstraction.CreateRandomNumberGenerator())`
| 1 | `13` |  | `{`
| 1 | `14` |  | `}`
|  | `15` |  | ``
| 1 | `16` |  | `public CryptoApiRandomGenerator(RandomNumberGenerator rng)`
| 1 | `17` |  | `{`
| 1 | `18` |  | `this.rndProv = rng;`
| 1 | `19` |  | `}`
|  | `20` |  | ``
|  | `21` |  | `#region IRandomGenerator Members`
|  | `22` |  | ``
|  | `23` |  | `public virtual void AddSeedMaterial(byte[] seed)`
| 0 | `24` |  | `{`
|  | `25` |  | `// We don't care about the seed`
| 0 | `26` |  | `}`
|  | `27` |  | ``
|  | `28` |  | `public virtual void AddSeedMaterial(long seed)`
| 0 | `29` |  | `{`
|  | `30` |  | `// We don't care about the seed`
| 0 | `31` |  | `}`
|  | `32` |  | ``
|  | `33` |  | `public virtual void NextBytes(byte[] bytes)`
| 10 | `34` |  | `{`
| 10 | `35` |  | `rndProv.GetBytes(bytes);`
| 10 | `36` |  | `}`
|  | `37` |  | ``
|  | `38` |  | `public virtual void NextBytes(byte[] bytes, int start, int len)`
| 0 | `39` |  | `{`
| 0 | `40` |  | `if (start < 0)`
| 0 | `41` |  | `throw new ArgumentException("Start offset cannot be negative", "start");`
| 0 | `42` |  | `if (bytes.Length < (start + len))`
| 0 | `43` |  | `throw new ArgumentException("Byte array too small for requested offset and length");`
|  | `44` |  | ``
| 0 | `45` |  | `if (bytes.Length == len && start == 0)`
| 0 | `46` |  | `{`
| 0 | `47` |  | `NextBytes(bytes);`
| 0 | `48` |  | `}`
|  | `49` |  | `else`
| 0 | `50` |  | `{`
| 0 | `51` |  | `byte[] tmpBuf = new byte[len];`
| 0 | `52` |  | `NextBytes(tmpBuf);`
| 0 | `53` |  | `Array.Copy(tmpBuf, 0, bytes, start, len);`
| 0 | `54` |  | `}`
| 0 | `55` |  | `}`
|  | `56` |  | ``
|  | `57` |  | `#endregion`
|  | `58` |  | `}`
|  | `59` |  | `}`

# Methods/Properties

.ctor()
.ctor(System.Security.Cryptography.RandomNumberGenerator)
AddSeedMaterial(System.Byte[])
AddSeedMaterial(System.Int64)
NextBytes(System.Byte[])
NextBytes(System.Byte[],System.Int32,System.Int32)