diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-18 20:53:15 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-18 20:53:15 +0700 |
commit | 0f9254b9238d5a36df1217bb354e9e76282067d7 (patch) | |
tree | a8d53d838c49ddc150b5d0ef2a79385fc3ba1d0f /crypto/src/openpgp/PgpUtilities.cs | |
parent | Remove the 'debug' logging from NaccacheStern (diff) | |
download | BouncyCastle.NET-ed25519-0f9254b9238d5a36df1217bb354e9e76282067d7.tar.xz |
http://www.bouncycastle.org/jira/browse/BMA-98
- Support v3 encryption - Port more rewrap tests from Java API
Diffstat (limited to 'crypto/src/openpgp/PgpUtilities.cs')
-rw-r--r-- | crypto/src/openpgp/PgpUtilities.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crypto/src/openpgp/PgpUtilities.cs b/crypto/src/openpgp/PgpUtilities.cs index 65c07b2e2..4f3cb6e73 100644 --- a/crypto/src/openpgp/PgpUtilities.cs +++ b/crypto/src/openpgp/PgpUtilities.cs @@ -488,5 +488,18 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp throw new PgpException("unknown wrap algorithm: " + encAlgorithm); } } + + internal static byte[] GenerateIV(int length, SecureRandom random) + { + byte[] iv = new byte[length]; + random.NextBytes(iv); + return iv; + } + + internal static S2k GenerateS2k(HashAlgorithmTag hashAlgorithm, int s2kCount, SecureRandom random) + { + byte[] iv = GenerateIV(8, random); + return new S2k(hashAlgorithm, iv, s2kCount); + } } } |