diff --git a/crypto/src/AssemblyInfo.cs b/crypto/src/AssemblyInfo.cs
index 5cc8fcd2f..43935c8dc 100644
--- a/crypto/src/AssemblyInfo.cs
+++ b/crypto/src/AssemblyInfo.cs
@@ -1,5 +1,6 @@
using System;
using System.Reflection;
+using System.Runtime.CompilerServices;
//using System.Security.Permissions;
#if PORTABLE
@@ -8,70 +9,13 @@ using System.Linq;
using System.Runtime.InteropServices;
#endif
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("BouncyCastle.Crypto")]
-[assembly: AssemblyDescription("Bouncy Castle Cryptography API")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("The Legion of the Bouncy Castle Inc.")]
-[assembly: AssemblyProduct("Bouncy Castle for .NET")]
-[assembly: AssemblyCopyright("Copyright (C) 2000-2018")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("1.8.3.0")]
-[assembly: AssemblyFileVersion("1.8.18223.1")]
-[assembly: AssemblyInformationalVersion("1.8.3")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-#if STRONG_NAME
-[assembly: AssemblyKeyFile(@"../BouncyCastle.snk")]
-#endif
-
[assembly: CLSCompliant(true)]
#if !PORTABLE
[assembly: ComVisible(false)]
#endif
+[assembly: InternalsVisibleTo("crypto.test, PublicKey=002400000480000094000000060200000024000052534131000400000100010083A6A1D0D41B8A0FD3061C8DD2BA14DA98F9BF53576AD386A4D021ABD235EE41BC5416683314816908765FAC4951301E159153CF02BF1B31BEC8A2CE6C0110C30CC7BEF54E514D530B703D37629078AB3ECCE1AFA5ED3F9D63F3B50398188A811ADA59827B9E1A4EEEB87D05E4AFE45BEFD69BF2CDFD37F38334B748C8CB7FBC")]
+
// Start with no permissions
//[assembly: PermissionSet(SecurityAction.RequestOptional, Unrestricted=false)]
//...and explicitly add those we need
@@ -117,3 +61,28 @@ internal class AssemblyInfo
}
}
}
+
+
+#if NET40
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection
+{
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
+ internal sealed class AssemblyMetadataAttribute : Attribute
+ {
+ public AssemblyMetadataAttribute(string key, string value)
+ {
+ Key = key;
+ Value = value;
+ }
+
+ public string Key { get; }
+
+ public string Value { get; }
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/crypto/src/asn1/DerUTCTime.cs b/crypto/src/asn1/DerUTCTime.cs
index 99af8bf6b..5d058619d 100644
--- a/crypto/src/asn1/DerUTCTime.cs
+++ b/crypto/src/asn1/DerUTCTime.cs
@@ -93,7 +93,7 @@ namespace Org.BouncyCastle.Asn1
#endif
}
- internal DerUtcTime(
+ internal DerUtcTime(
byte[] bytes)
{
//
diff --git a/crypto/src/asn1/util/Dump.cs b/crypto/src/asn1/util/Dump.cs
index e313fe879..acae5f1dc 100644
--- a/crypto/src/asn1/util/Dump.cs
+++ b/crypto/src/asn1/util/Dump.cs
@@ -12,7 +12,7 @@ namespace Org.BouncyCastle.Asn1.Utilities
{
}
- public static void Main(string[] args)
+ public static void MainOld(string[] args)
{
FileStream fIn = File.OpenRead(args[0]);
Asn1InputStream bIn = new Asn1InputStream(fIn);
diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
index 8e6d2729b..e0822aa8b 100644
--- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
@@ -287,7 +287,7 @@ namespace Org.BouncyCastle.Cms
// TODO Parent context(s) should really be closed explicitly
- _eiGen.Close();
+ _eiGen.Close();
if (_outer.unprotectedAttributeGenerator != null)
{
diff --git a/crypto/src/cms/CMSProcessableFile.cs b/crypto/src/cms/CMSProcessableFile.cs
index c74d2a846..1b2d8fc49 100644
--- a/crypto/src/cms/CMSProcessableFile.cs
+++ b/crypto/src/cms/CMSProcessableFile.cs
@@ -1,4 +1,4 @@
-#if !PORTABLE || DOTNET
+#if !PORTABLE || NETSTANDARD1_3
using System;
using System.IO;
@@ -15,7 +15,7 @@ namespace Org.BouncyCastle.Cms
{
private const int DefaultBufSize = 32 * 1024;
- private readonly FileInfo _file;
+ private readonly FileInfo _file;
private readonly int _bufSize;
public CmsProcessableFile(FileInfo file)
@@ -29,7 +29,7 @@ namespace Org.BouncyCastle.Cms
_bufSize = bufSize;
}
- public virtual Stream GetInputStream()
+ public virtual Stream GetInputStream()
{
return new FileStream(_file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, _bufSize);
}
@@ -41,7 +41,7 @@ namespace Org.BouncyCastle.Cms
Platform.Dispose(inStr);
}
- /// <returns>The file handle</returns>
+ /// <returns>The file handle</returns>
[Obsolete]
public virtual object GetContent()
{
diff --git a/crypto/src/cms/CMSSignedDataStreamGenerator.cs b/crypto/src/cms/CMSSignedDataStreamGenerator.cs
index 0a3e0c87e..29411e132 100644
--- a/crypto/src/cms/CMSSignedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSSignedDataStreamGenerator.cs
@@ -834,7 +834,7 @@ namespace Org.BouncyCastle.Cms
_eiGen.Close();
- outer._digests.Clear(); // clear the current preserved digest state
+ outer._digests.Clear(); // clear the current preserved digest state
if (outer._certs.Count > 0)
{
@@ -842,8 +842,8 @@ namespace Org.BouncyCastle.Cms
? CmsUtilities.CreateDerSetFromList(outer._certs)
: CmsUtilities.CreateBerSetFromList(outer._certs);
- WriteToGenerator(_sigGen, new BerTaggedObject(false, 0, certs));
- }
+ WriteToGenerator(_sigGen, new BerTaggedObject(false, 0, certs));
+ }
if (outer._crls.Count > 0)
{
@@ -851,48 +851,48 @@ namespace Org.BouncyCastle.Cms
? CmsUtilities.CreateDerSetFromList(outer._crls)
: CmsUtilities.CreateBerSetFromList(outer._crls);
- WriteToGenerator(_sigGen, new BerTaggedObject(false, 1, crls));
- }
+ WriteToGenerator(_sigGen, new BerTaggedObject(false, 1, crls));
+ }
- //
- // Calculate the digest hashes
- //
- foreach (DictionaryEntry de in outer._messageDigests)
- {
- outer._messageHashes.Add(de.Key, DigestUtilities.DoFinal((IDigest)de.Value));
- }
+ //
+ // Calculate the digest hashes
+ //
+ foreach (DictionaryEntry de in outer._messageDigests)
+ {
+ outer._messageHashes.Add(de.Key, DigestUtilities.DoFinal((IDigest)de.Value));
+ }
- // TODO If the digest OIDs for precalculated signers weren't mixed in with
- // the others, we could fill in outer._digests here, instead of SignerInfoGenerator.Generate
+ // TODO If the digest OIDs for precalculated signers weren't mixed in with
+ // the others, we could fill in outer._digests here, instead of SignerInfoGenerator.Generate
- //
- // collect all the SignerInfo objects
- //
+ //
+ // collect all the SignerInfo objects
+ //
Asn1EncodableVector signerInfos = new Asn1EncodableVector();
- //
+ //
// add the generated SignerInfo objects
//
- {
- foreach (DigestAndSignerInfoGeneratorHolder holder in outer._signerInfs)
- {
- AlgorithmIdentifier digestAlgorithm = holder.DigestAlgorithm;
+ {
+ foreach (DigestAndSignerInfoGeneratorHolder holder in outer._signerInfs)
+ {
+ AlgorithmIdentifier digestAlgorithm = holder.DigestAlgorithm;
- byte[] calculatedDigest = (byte[])outer._messageHashes[
- Helper.GetDigestAlgName(holder.digestOID)];
- outer._digests[holder.digestOID] = calculatedDigest.Clone();
+ byte[] calculatedDigest = (byte[])outer._messageHashes[
+ Helper.GetDigestAlgName(holder.digestOID)];
+ outer._digests[holder.digestOID] = calculatedDigest.Clone();
- signerInfos.Add(holder.signerInf.Generate(_contentOID, digestAlgorithm, calculatedDigest));
- }
- }
+ signerInfos.Add(holder.signerInf.Generate(_contentOID, digestAlgorithm, calculatedDigest));
+ }
+ }
- //
+ //
// add the precalculated SignerInfo objects.
//
- {
- foreach (SignerInformation signer in outer._signers)
- {
- // TODO Verify the content type and calculated digest match the precalculated SignerInfo
+ {
+ foreach (SignerInformation signer in outer._signers)
+ {
+ // TODO Verify the content type and calculated digest match the precalculated SignerInfo
// if (!signer.ContentType.Equals(_contentOID))
// {
// // TODO The precalculated content type did not match - error?
@@ -911,11 +911,11 @@ namespace Org.BouncyCastle.Cms
// }
// }
- signerInfos.Add(signer.ToSignerInfo());
- }
- }
+ signerInfos.Add(signer.ToSignerInfo());
+ }
+ }
- WriteToGenerator(_sigGen, new DerSet(signerInfos));
+ WriteToGenerator(_sigGen, new DerSet(signerInfos));
_sigGen.Close();
_sGen.Close();
diff --git a/crypto/src/crypto.csproj b/crypto/src/crypto.csproj
new file mode 100644
index 000000000..fd54d15e9
--- /dev/null
+++ b/crypto/src/crypto.csproj
@@ -0,0 +1,69 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <TargetFrameworks>netstandard2.0;netstandard1.3;netstandard1.0;net4</TargetFrameworks>
+ <AssemblyName>BouncyCastle.Crypto</AssemblyName>
+ <RootNamespace>crypto</RootNamespace>
+ <AssemblyOriginatorKeyFile>..\..\BouncyCastle.snk</AssemblyOriginatorKeyFile>
+ <SignAssembly>true</SignAssembly>
+ <Product>Bouncy Castle for .NET ($(TargetFramework))</Product>
+ <Copyright>© 2000-2018 Legion of the Bouncy Castle Inc. </Copyright>
+ <Company>The Legion of the Bouncy Castle Inc.</Company>
+ <Authors>Oren Novotny</Authors>
+ <Title>Bouncy Castle Portable</Title>
+ <PackageId>Portable.BouncyCastle</PackageId>
+ <Description>BouncyCastle portable version with support for .NET 4, .NET Standard 1.0-2.0, .NET Core</Description>
+ <DebugType>embedded</DebugType>
+ <PackageLicenseUrl>https://www.bouncycastle.org/csharp/licence.html</PackageLicenseUrl>
+ <PackageProjectUrl>https://www.bouncycastle.org/csharp/</PackageProjectUrl>
+ <PackageReleaseNotes>https://www.bouncycastle.org/csharp/#RELEASENOTES183</PackageReleaseNotes>
+ <RepositoryType>git</RepositoryType>
+ <RepositoryUrl>https://github.com/onovotny/bc-csharp</RepositoryUrl>
+ <PackageIconUrl>https://www.bouncycastle.org/images/csharp_logo.gif</PackageIconUrl>
+ <PackageTags>bouncycastle cryptography encryption security</PackageTags>
+ <EmbedUntrackedSources>true</EmbedUntrackedSources>
+ <PublishRepositoryUrl>true</PublishRepositoryUrl>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+ <GenerateDocumentationFile>true</GenerateDocumentationFile>
+ <NoWarn>1591;618;672</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' ">
+ <DefineConstants>$(DefineConstants);PORTABLE;NO_THREADS;NEW_REFLECTION;SYS_RUNTIME</DefineConstants>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
+ <DefineConstants>$(DefineConstants);PORTABLE;NO_THREADS;NEW_REFLECTION;SYS_RUNTIME;DOTNET</DefineConstants>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="..\bzip2\src\**\*.cs" LinkBase="bzip2" />
+ <None Include="..\..\BouncyCastle.snk" />
+ <PackageReference Include="NerdBank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
+ <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="All" />
+ </ItemGroup>
+
+ <Target Name="SetBuildVer" AfterTargets="GetBuildVersion" BeforeTargets="SetCloudBuildVersionVars;SetCloudBuildNumberWithVersion">
+ <PropertyGroup>
+ <CloudBuildNumber>$(BuildVersion)</CloudBuildNumber>
+ <Version>$(BuildVersion)</Version>
+ <PackageVersion>$(BuildVersion)</PackageVersion>
+ <NuGetPackageVersion>$(BuildVersion)</NuGetPackageVersion>
+ <AssemblyVersion>$(BuildVersionSimple)</AssemblyVersion>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(IsMatchingBase)' == 'true'">
+ <CloudBuildNumber>$(BuildVersionSimple)</CloudBuildNumber>
+ <Version>$(BuildVersionSimple)</Version>
+ <PackageVersion>$(BuildVersionSimple)</PackageVersion>
+ <NuGetPackageVersion>$(BuildVersionSimple)</NuGetPackageVersion>
+ <AssemblyVersion>$(BuildVersionSimple)</AssemblyVersion>
+ </PropertyGroup>
+ </Target>
+
+ <Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">
+ <ItemGroup>
+ <AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" '$(SourceRevisionId)' != '' ">
+ <_Parameter1>CommitHash</_Parameter1>
+ <_Parameter2>$(SourceRevisionId)</_Parameter2>
+ </AssemblyAttribute>
+ </ItemGroup>
+ </Target>
+</Project>
\ No newline at end of file
diff --git a/crypto/src/crypto/engines/NaccacheSternEngine.cs b/crypto/src/crypto/engines/NaccacheSternEngine.cs
index 64665c1d4..fe2d78da6 100644
--- a/crypto/src/crypto/engines/NaccacheSternEngine.cs
+++ b/crypto/src/crypto/engines/NaccacheSternEngine.cs
@@ -20,7 +20,7 @@ namespace Org.BouncyCastle.Crypto.Engines
private IList[] lookup = null;
- public string AlgorithmName
+ public string AlgorithmName
{
get { return "NaccacheStern"; }
}
@@ -78,7 +78,7 @@ namespace Org.BouncyCastle.Crypto.Engines
set {}
}
- /**
+ /**
* Returns the input block size of this algorithm.
*
* @see org.bouncycastle.crypto.AsymmetricBlockCipher#GetInputBlockSize()
@@ -261,7 +261,7 @@ namespace Org.BouncyCastle.Crypto.Engines
BigInteger m1m2Crypt = m1Crypt.Multiply(m2Crypt);
m1m2Crypt = m1m2Crypt.Mod(key.Modulus);
- //byte[] output = key.Modulus.ToByteArray();
+ //byte[] output = key.Modulus.ToByteArray();
//Array.Clear(output, 0, output.Length);
byte[] output = new byte[key.Modulus.BitLength / 8 + 1];
diff --git a/crypto/src/crypto/generators/NaccacheSternKeyPairGenerator.cs b/crypto/src/crypto/generators/NaccacheSternKeyPairGenerator.cs
index 618ca9a1c..d68106844 100644
--- a/crypto/src/crypto/generators/NaccacheSternKeyPairGenerator.cs
+++ b/crypto/src/crypto/generators/NaccacheSternKeyPairGenerator.cs
@@ -52,7 +52,7 @@ namespace Org.BouncyCastle.Crypto.Generators
SecureRandom rand = param.Random;
int certainty = param.Certainty;
- IList smallPrimes = findFirstPrimes(param.CountSmallPrimes);
+ IList smallPrimes = findFirstPrimes(param.CountSmallPrimes);
smallPrimes = permuteList(smallPrimes, rand);
@@ -87,7 +87,7 @@ namespace Org.BouncyCastle.Crypto.Generators
long tries = 0;
- BigInteger _2au = a.Multiply(u).ShiftLeft(1);
+ BigInteger _2au = a.Multiply(u).ShiftLeft(1);
BigInteger _2bv = b.Multiply(v).ShiftLeft(1);
for (;;)
@@ -132,7 +132,7 @@ namespace Org.BouncyCastle.Crypto.Generators
BigInteger g;
tries = 0;
- for (;;)
+ for (;;)
{
// TODO After the first loop, just regenerate one randomly-selected gPart each time?
IList gParts = Platform.CreateArrayList();
@@ -205,7 +205,7 @@ namespace Org.BouncyCastle.Crypto.Generators
break;
}
- return new AsymmetricCipherKeyPair(new NaccacheSternKeyParameters(false, g, n, sigma.BitLength),
+ return new AsymmetricCipherKeyPair(new NaccacheSternKeyParameters(false, g, n, sigma.BitLength),
new NaccacheSternPrivateKeyParameters(g, n, sigma.BitLength, smallPrimes, phi_n));
}
diff --git a/crypto/src/openpgp/PgpLiteralDataGenerator.cs b/crypto/src/openpgp/PgpLiteralDataGenerator.cs
index 7672659ca..217d7149e 100644
--- a/crypto/src/openpgp/PgpLiteralDataGenerator.cs
+++ b/crypto/src/openpgp/PgpLiteralDataGenerator.cs
@@ -141,7 +141,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
return new WrappedGeneratorStream(this, pkOut);
}
-#if !PORTABLE || DOTNET
+#if !PORTABLE || NETSTANDARD1_3
/// <summary>
/// <p>
/// Open a literal data packet for the passed in <c>FileInfo</c> object, returning
diff --git a/crypto/src/openpgp/PgpUtilities.cs b/crypto/src/openpgp/PgpUtilities.cs
index 10d1ac398..1a93cc78d 100644
--- a/crypto/src/openpgp/PgpUtilities.cs
+++ b/crypto/src/openpgp/PgpUtilities.cs
@@ -347,7 +347,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
return MakeKey(algorithm, keyBytes);
}
-#if !PORTABLE || DOTNET
+#if !PORTABLE || NETSTANDARD1_3
/// <summary>Write out the passed in file as a literal data packet.</summary>
public static void WriteFileToLiteralData(
Stream output,
diff --git a/crypto/src/pkcs/Pkcs12Store.cs b/crypto/src/pkcs/Pkcs12Store.cs
index 507c0e3ee..7db264232 100644
--- a/crypto/src/pkcs/Pkcs12Store.cs
+++ b/crypto/src/pkcs/Pkcs12Store.cs
@@ -113,88 +113,88 @@ namespace Org.BouncyCastle.Pkcs
{
AsymmetricKeyParameter privKey = PrivateKeyFactory.CreateKey(privKeyInfo);
- IDictionary attributes = Platform.CreateHashtable();
+ IDictionary attributes = Platform.CreateHashtable();
AsymmetricKeyEntry keyEntry = new AsymmetricKeyEntry(privKey, attributes);
- string alias = null;
- Asn1OctetString localId = null;
+ string alias = null;
+ Asn1OctetString localId = null;
if (bagAttributes != null)
- {
+ {
foreach (Asn1Sequence sq in bagAttributes)
- {
+ {
DerObjectIdentifier aOid = DerObjectIdentifier.GetInstance(sq[0]);
Asn1Set attrSet = Asn1Set.GetInstance(sq[1]);
- Asn1Encodable attr = null;
-
- if (attrSet.Count > 0)
- {
- // TODO We should be adding all attributes in the set
- attr = attrSet[0];
-
- // TODO We might want to "merge" attribute sets with
- // the same OID - currently, differing values give an error
- if (attributes.Contains(aOid.Id))
- {
- // OK, but the value has to be the same
- if (!attributes[aOid.Id].Equals(attr))
- throw new IOException("attempt to add existing attribute with different value");
- }
- else
- {
- attributes.Add(aOid.Id, attr);
- }
-
- if (aOid.Equals(PkcsObjectIdentifiers.Pkcs9AtFriendlyName))
- {
- alias = ((DerBmpString)attr).GetString();
- // TODO Do these in a separate loop, just collect aliases here
+ Asn1Encodable attr = null;
+
+ if (attrSet.Count > 0)
+ {
+ // TODO We should be adding all attributes in the set
+ attr = attrSet[0];
+
+ // TODO We might want to "merge" attribute sets with
+ // the same OID - currently, differing values give an error
+ if (attributes.Contains(aOid.Id))
+ {
+ // OK, but the value has to be the same
+ if (!attributes[aOid.Id].Equals(attr))
+ throw new IOException("attempt to add existing attribute with different value");
+ }
+ else
+ {
+ attributes.Add(aOid.Id, attr);
+ }
+
+ if (aOid.Equals(PkcsObjectIdentifiers.Pkcs9AtFriendlyName))
+ {
+ alias = ((DerBmpString)attr).GetString();
+ // TODO Do these in a separate loop, just collect aliases here
keys[alias] = keyEntry;
- }
- else if (aOid.Equals(PkcsObjectIdentifiers.Pkcs9AtLocalKeyID))
- {
- localId = (Asn1OctetString)attr;
- }
- }
- }
- }
+ }
+ else if (aOid.Equals(PkcsObjectIdentifiers.Pkcs9AtLocalKeyID))
+ {
+ localId = (Asn1OctetString)attr;
+ }
+ }
+ }
+ }
- if (localId != null)
- {
- string name = Hex.ToHexString(localId.GetOctets());
+ if (localId != null)
+ {
+ string name = Hex.ToHexString(localId.GetOctets());
- if (alias == null)
- {
+ if (alias == null)
+ {
keys[name] = keyEntry;
- }
- else
- {
- // TODO There may have been more than one alias
- localIds[alias] = name;
- }
- }
- else
- {
+ }
+ else
+ {
+ // TODO There may have been more than one alias
+ localIds[alias] = name;
+ }
+ }
+ else
+ {
unmarkedKeyEntry = keyEntry;
- }
- }
+ }
+ }
protected virtual void LoadPkcs8ShroudedKeyBag(EncryptedPrivateKeyInfo encPrivKeyInfo, Asn1Set bagAttributes,
char[] password, bool wrongPkcs12Zero)
- {
+ {
if (password != null)
- {
+ {
PrivateKeyInfo privInfo = PrivateKeyInfoFactory.CreatePrivateKeyInfo(
password, wrongPkcs12Zero, encPrivKeyInfo);
LoadKeyBag(privInfo, bagAttributes);
- }
- }
+ }
+ }
public void Load(
Stream input,
char[] password)
- {
+ {
if (input == null)
throw new ArgumentNullException("input");
@@ -204,7 +204,7 @@ namespace Org.BouncyCastle.Pkcs
bool wrongPkcs12Zero = false;
if (password != null && bag.MacData != null) // check the mac code
- {
+ {
MacData mData = bag.MacData;
DigestInfo dInfo = mData.Mac;
AlgorithmIdentifier algId = dInfo.AlgorithmID;
@@ -217,7 +217,7 @@ namespace Org.BouncyCastle.Pkcs
byte[] dig = dInfo.GetDigest();
if (!Arrays.ConstantTimeAreEqual(mac, dig))
- {
+ {
if (password.Length > 0)
throw new IOException("PKCS12 key store MAC invalid - wrong password or corrupted file.");
@@ -228,8 +228,8 @@ namespace Org.BouncyCastle.Pkcs
throw new IOException("PKCS12 key store MAC invalid - wrong password or corrupted file.");
wrongPkcs12Zero = true;
- }
- }
+ }
+ }
keys.Clear();
localIds.Clear();
@@ -238,37 +238,37 @@ namespace Org.BouncyCastle.Pkcs
IList certBags = Platform.CreateArrayList();
if (info.ContentType.Equals(PkcsObjectIdentifiers.Data))
- {
+ {
byte[] octs = ((Asn1OctetString)info.Content).GetOctets();
AuthenticatedSafe authSafe = new AuthenticatedSafe(
(Asn1Sequence) Asn1OctetString.FromByteArray(octs));
ContentInfo[] cis = authSafe.GetContentInfo();
foreach (ContentInfo ci in cis)
- {
+ {
DerObjectIdentifier oid = ci.ContentType;
byte[] octets = null;
if (oid.Equals(PkcsObjectIdentifiers.Data))
- {
+ {
octets = ((Asn1OctetString)ci.Content).GetOctets();
}
else if (oid.Equals(PkcsObjectIdentifiers.EncryptedData))
- {
+ {
if (password != null)
- {
+ {
EncryptedData d = EncryptedData.GetInstance(ci.Content);
octets = CryptPbeData(false, d.EncryptionAlgorithm,
password, wrongPkcs12Zero, d.Content.GetOctets());
- }
- }
- else
- {
+ }
+ }
+ else
+ {
// TODO Other data types
- }
+ }
if (octets != null)
- {
+ {
Asn1Sequence seq = (Asn1Sequence)Asn1Object.FromByteArray(octets);
foreach (Asn1Sequence subSeq in seq)
@@ -276,14 +276,14 @@ namespace Org.BouncyCastle.Pkcs
SafeBag b = new SafeBag(subSeq);
if (b.BagID.Equals(PkcsObjectIdentifiers.CertBag))
- {
+ {
certBags.Add(b);
- }
+ }
else if (b.BagID.Equals(PkcsObjectIdentifiers.Pkcs8ShroudedKeyBag))
- {
+ {
LoadPkcs8ShroudedKeyBag(EncryptedPrivateKeyInfo.GetInstance(b.BagValue),
b.BagAttributes, password, wrongPkcs12Zero);
- }
+ }
else if (b.BagID.Equals(PkcsObjectIdentifiers.KeyBag))
{
LoadKeyBag(PrivateKeyInfo.GetInstance(b.BagValue), b.BagAttributes);
@@ -291,9 +291,9 @@ namespace Org.BouncyCastle.Pkcs
else
{
// TODO Other bag types
- }
}
}
+ }
}
}
@@ -736,7 +736,7 @@ namespace Org.BouncyCastle.Pkcs
{
bagOid = PkcsObjectIdentifiers.Pkcs8ShroudedKeyBag;
bagData = EncryptedPrivateKeyInfoFactory.CreateEncryptedPrivateKeyInfo(
- keyAlgorithm, password, kSalt, MinIterations, privKey.Key);
+ keyAlgorithm, password, kSalt, MinIterations, privKey.Key);
}
Asn1EncodableVector kName = new Asn1EncodableVector();
@@ -946,7 +946,7 @@ namespace Org.BouncyCastle.Pkcs
else
{
byte[] certBytes = CryptPbeData(true, cAlgId, password, false, certBagsEncoding);
- EncryptedData cInfo = new EncryptedData(PkcsObjectIdentifiers.Data, cAlgId, new BerOctetString(certBytes));
+ EncryptedData cInfo = new EncryptedData(PkcsObjectIdentifiers.Data, cAlgId, new BerOctetString(certBytes));
certsInfo = new ContentInfo(PkcsObjectIdentifiers.EncryptedData, cInfo.ToAsn1Object());
}
@@ -963,15 +963,15 @@ namespace Org.BouncyCastle.Pkcs
MacData macData = null;
if (password != null)
{
- byte[] mSalt = new byte[20];
- random.NextBytes(mSalt);
+ byte[] mSalt = new byte[20];
+ random.NextBytes(mSalt);
- byte[] mac = CalculatePbeMac(OiwObjectIdentifiers.IdSha1,
- mSalt, MinIterations, password, false, data);
+ byte[] mac = CalculatePbeMac(OiwObjectIdentifiers.IdSha1,
+ mSalt, MinIterations, password, false, data);
- AlgorithmIdentifier algId = new AlgorithmIdentifier(
- OiwObjectIdentifiers.IdSha1, DerNull.Instance);
- DigestInfo dInfo = new DigestInfo(algId, mac);
+ AlgorithmIdentifier algId = new AlgorithmIdentifier(
+ OiwObjectIdentifiers.IdSha1, DerNull.Instance);
+ DigestInfo dInfo = new DigestInfo(algId, mac);
macData = new MacData(dInfo, mSalt, MinIterations);
}
diff --git a/crypto/src/util/zlib/ZDeflaterOutputStream.cs b/crypto/src/util/zlib/ZDeflaterOutputStream.cs
index d0f0bcb8d..d0978942a 100644
--- a/crypto/src/util/zlib/ZDeflaterOutputStream.cs
+++ b/crypto/src/util/zlib/ZDeflaterOutputStream.cs
@@ -135,7 +135,7 @@ namespace Org.BouncyCastle.Utilities.Zlib {
z.free();
z=null;
}
-
+
#if PORTABLE
protected override void Dispose(bool disposing)
{
|