mirrored from https://www.bouncycastle.org/repositories/bc-java
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added equals/hashCode for OCSP CertID,changed algID check in revocati…
…on checker - relates to github #1789
- Loading branch information
Showing
4 changed files
with
161 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
core/src/test/java/org/bouncycastle/asn1/test/CertIDTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.bouncycastle.asn1.test; | ||
|
||
import org.bouncycastle.asn1.ASN1Integer; | ||
import org.bouncycastle.asn1.DERNull; | ||
import org.bouncycastle.asn1.DEROctetString; | ||
import org.bouncycastle.asn1.ocsp.CertID; | ||
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; | ||
import org.bouncycastle.internal.asn1.oiw.OIWObjectIdentifiers; | ||
import org.bouncycastle.util.BigIntegers; | ||
import org.bouncycastle.util.Strings; | ||
import org.bouncycastle.util.test.SimpleTest; | ||
|
||
public class CertIDTest | ||
extends SimpleTest | ||
{ | ||
public String getName() | ||
{ | ||
return "CertID"; | ||
} | ||
|
||
public void performTest() | ||
throws Exception | ||
{ | ||
DEROctetString issuerAHash = new DEROctetString(Strings.toByteArray("IssuerAHash")); | ||
DEROctetString issuerBHash = new DEROctetString(Strings.toByteArray("IssuerBHash")); | ||
DEROctetString issuerAKeyHash = new DEROctetString(Strings.toByteArray("IssuerAKeyHash")); | ||
DEROctetString issuerBKeyHash = new DEROctetString(Strings.toByteArray("IssuerBKeyHash")); | ||
|
||
CertID a = new CertID(new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1), issuerAHash, issuerAKeyHash, new ASN1Integer(BigIntegers.ONE)); | ||
CertID b = new CertID(new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE), issuerAHash, issuerAKeyHash, new ASN1Integer(BigIntegers.ONE)); | ||
CertID c = new CertID(new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DEROctetString(new byte[1])), issuerAHash, issuerAKeyHash, new ASN1Integer(BigIntegers.ONE)); | ||
|
||
isTrue(a.equals(a)); | ||
isTrue(a.equals(b)); | ||
isTrue(a.hashCode() == b.hashCode()); | ||
isTrue(!a.equals(c)); | ||
isTrue(a.hashCode() != c.hashCode()); | ||
|
||
b = new CertID(new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1), issuerAHash, issuerAKeyHash, new ASN1Integer(BigIntegers.TWO)); | ||
isTrue(!a.equals(b)); | ||
b = new CertID(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm), issuerAHash, issuerAKeyHash, new ASN1Integer(BigIntegers.ONE)); | ||
isTrue(!a.equals(b)); | ||
b = new CertID(new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1), issuerBHash, issuerAKeyHash, new ASN1Integer(BigIntegers.ONE)); | ||
isTrue(!a.equals(b)); | ||
b = new CertID(new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1), issuerAHash, issuerBKeyHash, new ASN1Integer(BigIntegers.ONE)); | ||
isTrue(!a.equals(b)); | ||
} | ||
|
||
public static void main( | ||
String[] args) | ||
{ | ||
runTest(new CertIDTest()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters