Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Age.Cli/AgeCommand.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Security.Cryptography;
using System.Text;
using Age.Format;
using Age.Plugin;
Expand Down Expand Up @@ -188,14 +189,15 @@ private static string ReadPassphrase(string prompt)

private static string GeneratePassphrase()
{
var rng = new Random();
// This passphrase is the sole secret protecting the encrypted file, so it
// must come from a cryptographically secure RNG — never System.Random.
var parts = new string[10];

for (var i = 0; i < 10; i++)
{
var chars = new char[6];
for (var j = 0; j < 6; j++)
chars[j] = (char)('a' + rng.Next(26));
chars[j] = (char)('a' + RandomNumberGenerator.GetInt32(26));
parts[i] = new string(chars);
}

Expand Down
Loading