Skip to content

Commit

Permalink
Merge branch 'master' into netstandard
Browse files Browse the repository at this point in the history
  • Loading branch information
clairernovotny committed Mar 21, 2020
2 parents 9c1d2ff + 2f8db06 commit 086e981
Show file tree
Hide file tree
Showing 15 changed files with 266 additions and 299 deletions.
2 changes: 1 addition & 1 deletion crypto/NBuild.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<property name="dist-path" value="./dist"/>

<!-- Version -->
<property name="version" value="1.8.5"/>
<property name="version" value="1.8.6"/>
<property name="name" value="BouncyCastle.Crypto"/>

<property name="OPTIONAL_STRONG_NAME" value="" />
Expand Down
6 changes: 5 additions & 1 deletion crypto/Readme.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ <h3><a class="mozTocH3" name="mozTocId685176"></a>Contents:<br/></h3>
<li>
<a href="#mozTocId3413">Notes:</a>
<ol>
<li>
<a href="#mozTocId85321">Release 1.8.7</a>
<li>
<a href="#mozTocId85320">Release 1.8.6</a>
<li>
Expand Down Expand Up @@ -300,7 +302,9 @@ <h3><a class="mozTocH3" name="mozTocId358608"></a>For first time users.</h3>
<hr style="WIDTH: 100%; HEIGHT: 2px">
<h3><a class="mozTocH3" name="mozTocId3413"></a>Notes:</h3>

<h4><a class="mozTocH4" name="mozTocId85320"></a>Release 1.8.6, TBD</h4>
<h4><a class="mozTocH4" name="mozTocId85321"></a>Release 1.8.7, TBD</h4>

<h4><a class="mozTocH4" name="mozTocId85320"></a>Release 1.8.6, Friday February 21, 2020</h4>

<h5>Defects Fixed</h5>
<ul>
Expand Down
4 changes: 2 additions & 2 deletions crypto/src/asn1/Asn1Sequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public static Asn1Sequence GetInstance(
}
else if (obj is Asn1SequenceParser)
{
return Asn1Sequence.GetInstance(((Asn1SequenceParser)obj).ToAsn1Object());
return GetInstance(((Asn1SequenceParser)obj).ToAsn1Object());
}
else if (obj is byte[])
{
try
{
return Asn1Sequence.GetInstance(FromByteArray((byte[])obj));
return GetInstance(FromByteArray((byte[])obj));
}
catch (IOException e)
{
Expand Down
26 changes: 9 additions & 17 deletions crypto/src/asn1/tsp/Accuracy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,16 @@ private Accuracy(
}
}

public static Accuracy GetInstance(
object o)
{
if (o == null || o is Accuracy)
{
return (Accuracy) o;
}

if (o is Asn1Sequence)
{
return new Accuracy((Asn1Sequence) o);
}

throw new ArgumentException(
"Unknown object in 'Accuracy' factory: " + Platform.GetTypeName(o));
}
public static Accuracy GetInstance(object obj)
{
if (obj is Accuracy)
return (Accuracy)obj;
if (obj == null)
return null;
return new Accuracy(Asn1Sequence.GetInstance(obj));
}

public DerInteger Seconds
public DerInteger Seconds
{
get { return seconds; }
}
Expand Down
32 changes: 10 additions & 22 deletions crypto/src/asn1/tsp/MessageImprint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,16 @@ public class MessageImprint
private readonly AlgorithmIdentifier hashAlgorithm;
private readonly byte[] hashedMessage;

/**
* @param o
* @return a MessageImprint object.
*/
public static MessageImprint GetInstance(
object o)
{
if (o == null || o is MessageImprint)
{
return (MessageImprint) o;
}

if (o is Asn1Sequence)
{
return new MessageImprint((Asn1Sequence) o);
}

throw new ArgumentException(
"Unknown object in 'MessageImprint' factory: " + Platform.GetTypeName(o));
}

private MessageImprint(
public static MessageImprint GetInstance(object obj)
{
if (obj is MessageImprint)
return (MessageImprint)obj;
if (obj == null)
return null;
return new MessageImprint(Asn1Sequence.GetInstance(obj));
}

private MessageImprint(
Asn1Sequence seq)
{
if (seq.Count != 2)
Expand Down
34 changes: 6 additions & 28 deletions crypto/src/asn1/tsp/TSTInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,13 @@ public class TstInfo
private readonly GeneralName tsa;
private readonly X509Extensions extensions;

public static TstInfo GetInstance(
object o)
public static TstInfo GetInstance(object obj)
{
if (o == null || o is TstInfo)
{
return (TstInfo) o;
}

if (o is Asn1Sequence)
{
return new TstInfo((Asn1Sequence) o);
}

if (o is Asn1OctetString)
{
try
{
byte[] octets = ((Asn1OctetString)o).GetOctets();
return GetInstance(Asn1Object.FromByteArray(octets));
}
catch (IOException)
{
throw new ArgumentException(
"Bad object format in 'TstInfo' factory.");
}
}

throw new ArgumentException(
"Unknown object in 'TstInfo' factory: " + Platform.GetTypeName(o));
if (obj is TstInfo)
return (TstInfo)obj;
if (obj == null)
return null;
return new TstInfo(Asn1Sequence.GetInstance(obj));
}

private TstInfo(
Expand Down
26 changes: 9 additions & 17 deletions crypto/src/asn1/tsp/TimeStampReq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,16 @@ public class TimeStampReq
private readonly DerBoolean certReq;
private readonly X509Extensions extensions;

public static TimeStampReq GetInstance(
object o)
{
if (o == null || o is TimeStampReq)
{
return (TimeStampReq) o;
}

if (o is Asn1Sequence)
{
return new TimeStampReq((Asn1Sequence) o);
}

throw new ArgumentException(
"Unknown object in 'TimeStampReq' factory: " + Platform.GetTypeName(o));
}
public static TimeStampReq GetInstance(object obj)
{
if (obj is TimeStampReq)
return (TimeStampReq)obj;
if (obj == null)
return null;
return new TimeStampReq(Asn1Sequence.GetInstance(obj));
}

private TimeStampReq(
private TimeStampReq(
Asn1Sequence seq)
{
int nbObjects = seq.Count;
Expand Down
26 changes: 9 additions & 17 deletions crypto/src/asn1/tsp/TimeStampResp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,16 @@ public class TimeStampResp
private readonly PkiStatusInfo pkiStatusInfo;
private readonly ContentInfo timeStampToken;

public static TimeStampResp GetInstance(
object o)
{
if (o == null || o is TimeStampResp)
{
return (TimeStampResp) o;
}

if (o is Asn1Sequence)
{
return new TimeStampResp((Asn1Sequence) o);
}

throw new ArgumentException(
"Unknown object in 'TimeStampResp' factory: " + Platform.GetTypeName(o));
}
public static TimeStampResp GetInstance(object obj)
{
if (obj is TimeStampResp)
return (TimeStampResp)obj;
if (obj == null)
return null;
return new TimeStampResp(Asn1Sequence.GetInstance(obj));
}

private TimeStampResp(
private TimeStampResp(
Asn1Sequence seq)
{
this.pkiStatusInfo = PkiStatusInfo.GetInstance(seq[0]);
Expand Down
10 changes: 4 additions & 6 deletions crypto/src/asn1/x509/X509Name.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,11 @@ public static X509Name GetInstance(
public static X509Name GetInstance(
object obj)
{
if (obj == null || obj is X509Name)
if (obj is X509Name)
return (X509Name)obj;

if (obj != null)
return new X509Name(Asn1Sequence.GetInstance(obj));

throw new ArgumentException("null object in factory", "obj");
if (obj == null)
return null;
return new X509Name(Asn1Sequence.GetInstance(obj));
}

protected X509Name()
Expand Down
21 changes: 20 additions & 1 deletion crypto/src/openpgp/PgpObjectFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,24 @@ public IList AllPgpObjects()
}
return result;
}
}

/// <summary>
/// Read all available objects, returning only those that are assignable to the specified type.
/// </summary>
/// <param name="type">The type of objects to return. All other objects are ignored.</param>
/// <returns>An <c>IList</c> containing the filtered objects from this factory, in order.</returns>
public IList FilterPgpObjects(Type type)
{
IList result = Platform.CreateArrayList();
PgpObject pgpObject;
while ((pgpObject = NextPgpObject()) != null)
{
if (type.IsAssignableFrom(pgpObject.GetType()))
{
result.Add(pgpObject);
}
}
return result;
}
}
}
82 changes: 43 additions & 39 deletions crypto/src/pkix/PkixCertPathValidatorUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,46 +529,50 @@ internal static void GetCertStatus(

X509Name issuer = GetIssuerPrincipal(cert);

if (issuer.Equivalent(crl_entry.GetCertificateIssuer(), true)
|| issuer.Equivalent(crl.IssuerDN, true))
{
DerEnumerated reasonCode = null;
if (crl_entry.HasExtensions)
{
try
{
reasonCode = DerEnumerated.GetInstance(
GetExtensionValue(crl_entry, X509Extensions.ReasonCode));
}
catch (Exception e)
{
throw new Exception(
"Reason code CRL entry extension could not be decoded.",
e);
}
}
if (!issuer.Equivalent(crl_entry.GetCertificateIssuer(), true)
&& !issuer.Equivalent(crl.IssuerDN, true))
{
return;
}

// for reason keyCompromise, caCompromise, aACompromise or
// unspecified
if (!(validDate.Ticks < crl_entry.RevocationDate.Ticks)
|| reasonCode == null
|| reasonCode.Value.TestBit(0)
|| reasonCode.Value.TestBit(1)
|| reasonCode.Value.TestBit(2)
|| reasonCode.Value.TestBit(8))
{
if (reasonCode != null) // (i) or (j) (1)
{
certStatus.Status = reasonCode.Value.SignValue;
}
else // (i) or (j) (2)
{
certStatus.Status = CrlReason.Unspecified;
}
certStatus.RevocationDate = new DateTimeObject(crl_entry.RevocationDate);
}
}
}
int reasonCodeValue = CrlReason.Unspecified;

if (crl_entry.HasExtensions)
{
try
{
Asn1Object extValue = GetExtensionValue(crl_entry, X509Extensions.ReasonCode);
DerEnumerated reasonCode = DerEnumerated.GetInstance(extValue);
if (null != reasonCode)
{
reasonCodeValue = reasonCode.IntValueExact;
}
}
catch (Exception e)
{
throw new Exception("Reason code CRL entry extension could not be decoded.", e);
}
}

DateTime revocationDate = crl_entry.RevocationDate;
if (validDate.Ticks < revocationDate.Ticks)
{
switch (reasonCodeValue)
{
case CrlReason.Unspecified:
case CrlReason.KeyCompromise:
case CrlReason.CACompromise:
case CrlReason.AACompromise:
break;
default:
return;
}
}

// (i) or (j)
certStatus.Status = reasonCodeValue;
certStatus.RevocationDate = new DateTimeObject(revocationDate);
}

/**
* Return the next working key inheriting DSA parameters if necessary.
Expand Down
Loading

0 comments on commit 086e981

Please sign in to comment.