summaryrefslogtreecommitdiffstats
path: root/bcprov/src/main/java/org/bouncycastle/asn1/DERBoolean.java
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2016-02-01 10:41:58 +0000
committerSergio Giro <sgiro@google.com>2016-02-01 10:41:58 +0000
commit53b61f9fe9d58034fcc7021137e92460f91b70ce (patch)
tree90632062175928181977c1ab3ab59951bc1146c3 /bcprov/src/main/java/org/bouncycastle/asn1/DERBoolean.java
parent3eebc2629986481f9fc77ab101c0c9b8ff2f2660 (diff)
downloadandroid_external_bouncycastle-53b61f9fe9d58034fcc7021137e92460f91b70ce.tar.gz
android_external_bouncycastle-53b61f9fe9d58034fcc7021137e92460f91b70ce.tar.bz2
android_external_bouncycastle-53b61f9fe9d58034fcc7021137e92460f91b70ce.zip
bouncycastle: Android tree with upstream code for version 1.52
Android tree as of 1af9aad12fedf1d93333e19f5ed0ab86f1cc4e2a Change-Id: I714fa0954a5d000cd88d1fb78b0b7fe28246d404
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/asn1/DERBoolean.java')
-rw-r--r--bcprov/src/main/java/org/bouncycastle/asn1/DERBoolean.java173
1 files changed, 8 insertions, 165 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/asn1/DERBoolean.java b/bcprov/src/main/java/org/bouncycastle/asn1/DERBoolean.java
index 8b8d226..378ea35 100644
--- a/bcprov/src/main/java/org/bouncycastle/asn1/DERBoolean.java
+++ b/bcprov/src/main/java/org/bouncycastle/asn1/DERBoolean.java
@@ -1,179 +1,22 @@
package org.bouncycastle.asn1;
-import java.io.IOException;
-
-import org.bouncycastle.util.Arrays;
-
+/**
+ * @deprecated use ASN1Boolean
+ */
public class DERBoolean
- extends ASN1Primitive
+ extends ASN1Boolean
{
- private static final byte[] TRUE_VALUE = new byte[] { (byte)0xff };
- private static final byte[] FALSE_VALUE = new byte[] { 0 };
-
- private byte[] value;
-
- public static final ASN1Boolean FALSE = new ASN1Boolean(false);
- public static final ASN1Boolean TRUE = new ASN1Boolean(true);
-
-
- /**
- * return a boolean from the passed in object.
- *
- * @exception IllegalArgumentException if the object cannot be converted.
- */
- public static ASN1Boolean getInstance(
- Object obj)
- {
- if (obj == null || obj instanceof ASN1Boolean)
- {
- return (ASN1Boolean)obj;
- }
-
- if (obj instanceof DERBoolean)
- {
- return ((DERBoolean)obj).isTrue() ? DERBoolean.TRUE : DERBoolean.FALSE;
- }
-
- throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
- }
-
- /**
- * return a ASN1Boolean from the passed in boolean.
- */
- public static ASN1Boolean getInstance(
- boolean value)
- {
- return (value ? TRUE : FALSE);
- }
-
- /**
- * return a ASN1Boolean from the passed in boolean.
- */
- public static ASN1Boolean getInstance(
- int value)
- {
- return (value != 0 ? TRUE : FALSE);
- }
-
- /**
- * return a Boolean from a tagged object.
- *
- * @param obj the tagged object holding the object we want
- * @param explicit true if the object is meant to be explicitly
- * tagged false otherwise.
- * @exception IllegalArgumentException if the tagged object cannot
- * be converted.
- */
- public static ASN1Boolean getInstance(
- ASN1TaggedObject obj,
- boolean explicit)
- {
- ASN1Primitive o = obj.getObject();
-
- if (explicit || o instanceof DERBoolean)
- {
- return getInstance(o);
- }
- else
- {
- return ASN1Boolean.fromOctetString(((ASN1OctetString)o).getOctets());
- }
- }
-
- DERBoolean(
- byte[] value)
- {
- if (value.length != 1)
- {
- throw new IllegalArgumentException("byte value should have 1 byte in it");
- }
-
- if (value[0] == 0)
- {
- this.value = FALSE_VALUE;
- }
- else if (value[0] == 0xff)
- {
- this.value = TRUE_VALUE;
- }
- else
- {
- this.value = Arrays.clone(value);
- }
- }
-
/**
* @deprecated use getInstance(boolean) method.
* @param value
*/
- public DERBoolean(
- boolean value)
- {
- this.value = (value) ? TRUE_VALUE : FALSE_VALUE;
- }
-
- public boolean isTrue()
- {
- return (value[0] != 0);
- }
-
- boolean isConstructed()
- {
- return false;
- }
-
- int encodedLength()
+ public DERBoolean(boolean value)
{
- return 3;
+ super(value);
}
- void encode(
- ASN1OutputStream out)
- throws IOException
+ DERBoolean(byte[] value)
{
- out.writeEncoded(BERTags.BOOLEAN, value);
- }
-
- protected boolean asn1Equals(
- ASN1Primitive o)
- {
- if ((o == null) || !(o instanceof DERBoolean))
- {
- return false;
- }
-
- return (value[0] == ((DERBoolean)o).value[0]);
- }
-
- public int hashCode()
- {
- return value[0];
- }
-
-
- public String toString()
- {
- return (value[0] != 0) ? "TRUE" : "FALSE";
- }
-
- static ASN1Boolean fromOctetString(byte[] value)
- {
- if (value.length != 1)
- {
- throw new IllegalArgumentException("BOOLEAN value should have 1 byte in it");
- }
-
- if (value[0] == 0)
- {
- return FALSE;
- }
- else if (value[0] == 0xff)
- {
- return TRUE;
- }
- else
- {
- return new ASN1Boolean(value);
- }
+ super(value);
}
}