Skip to content

Commit

Permalink
Followup OAEP changes
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdettman committed Jul 21, 2021
1 parent a2a91fc commit 711fda7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
4 changes: 2 additions & 2 deletions crypto/src/asn1/pkcs/RSAESOAEPparams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public static RsaesOaepParameters GetInstance(
* The default version
*/
public RsaesOaepParameters()
: this(DefaultHashAlgorithm, DefaultMaskGenFunction, DefaultPSourceAlgorithm)
: this(DefaultHashAlgorithm, DefaultMaskGenFunction, DefaultPSourceAlgorithm)
{
}

public RsaesOaepParameters(
AlgorithmIdentifier hashAlgorithm,
AlgorithmIdentifier maskGenAlgorithm)
: this(DefaultHashAlgorithm, DefaultMaskGenFunction, DefaultPSourceAlgorithm)
: this(hashAlgorithm, maskGenAlgorithm, DefaultPSourceAlgorithm)
{
}

Expand Down
1 change: 0 additions & 1 deletion crypto/src/security/WrapperUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Org.BouncyCastle.Asn1.Nist;
using Org.BouncyCastle.Asn1.Ntt;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Utilities;
Expand Down
62 changes: 31 additions & 31 deletions crypto/test/src/cms/test/EnvelopedDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void TestKeyTransSmallAes()
}

[Test]
public void TestKeyTransSmallAesUsingAoep()
public void TestKeyTransSmallAesUsingOaep()
{
byte[] data = new byte[] { 0, 1, 2, 3 };

Expand Down Expand Up @@ -356,7 +356,7 @@ public void TestKeyTransSmallAesUsingAoep()
}

[Test]
public void TestKeyTransSmallAesUsingAoepMixed()
public void TestKeyTransSmallAesUsingOaepMixed()
{
byte[] data = new byte[] { 0, 1, 2, 3 };

Expand Down Expand Up @@ -384,44 +384,44 @@ public void TestKeyTransSmallAesUsingAoepMixed()
}
}

[Test]
public void TestKeyTransSmallAesUsingAoepMixedParams()
{
byte[] data = new byte[] { 0, 1, 2, 3 };
[Test]
public void TestKeyTransSmallAesUsingOaepMixedParams()
{
byte[] data = new byte[]{ 0, 1, 2, 3 };

CmsEnvelopedDataGenerator edGen = new CmsEnvelopedDataGenerator();
CmsEnvelopedDataGenerator edGen = new CmsEnvelopedDataGenerator();

edGen.AddRecipientInfoGenerator(
new KeyTransRecipientInfoGenerator(
ReciCert,
new Asn1KeyWrapper(
PkcsObjectIdentifiers.IdRsaesOaep,
new RsaesOaepParameters(
new AlgorithmIdentifier(NistObjectIdentifiers.IdSha256, DerNull.Instance),
new AlgorithmIdentifier(PkcsObjectIdentifiers.IdMgf1, new AlgorithmIdentifier(NistObjectIdentifiers.IdSha224, DerNull.Instance))),
ReciCert)));
edGen.AddRecipientInfoGenerator(
new KeyTransRecipientInfoGenerator(
ReciCert,
new Asn1KeyWrapper(
PkcsObjectIdentifiers.IdRsaesOaep,
new RsaesOaepParameters(
new AlgorithmIdentifier(NistObjectIdentifiers.IdSha256, DerNull.Instance),
new AlgorithmIdentifier(PkcsObjectIdentifiers.IdMgf1,
new AlgorithmIdentifier(NistObjectIdentifiers.IdSha224, DerNull.Instance))),
ReciCert)));

CmsEnvelopedData ed = edGen.Generate(
new CmsProcessableByteArray(data),
CmsEnvelopedDataGenerator.Aes128Cbc);
CmsEnvelopedData ed = edGen.Generate(
new CmsProcessableByteArray(data),
CmsEnvelopedGenerator.Aes128Cbc);

RecipientInformationStore recipients = ed.GetRecipientInfos();
RecipientInformationStore recipients = ed.GetRecipientInfos();

Assert.AreEqual(ed.EncryptionAlgOid,
CmsEnvelopedDataGenerator.Aes128Cbc);
Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedGenerator.Aes128Cbc);

ICollection c = recipients.GetRecipients();
ICollection c = recipients.GetRecipients();

Assert.AreEqual(1, c.Count);
Assert.AreEqual(1, c.Count);

foreach (RecipientInformation recipient in c)
{
byte[] recData = recipient.GetContent(ReciKP.Private);
Assert.IsTrue(Arrays.AreEqual(data, recData));
}
}
foreach (RecipientInformation recipient in c)
{
byte[] recData = recipient.GetContent(ReciKP.Private);
Assert.IsTrue(Arrays.AreEqual(data, recData));
}
}

[Test]
[Test]
public void TestKeyTransSmallAesUsingPkcs1()
{
byte[] data = new byte[] { 0, 1, 2, 3 };
Expand Down

0 comments on commit 711fda7

Please sign in to comment.