/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* DER input buffer ... this is the main abstraction in the DER library
* which actively works with the "untyped byte stream" abstraction. It
* does so with impunity, since it's not intended to be exposed to
* anyone who could violate the "typed value stream" DER model and hence
* corrupt the input stream of DER values.
*
* @author David Brownell
*/
}
try {
return retval;
} catch (CloneNotSupportedException e) {
throw new IllegalArgumentException(e.toString());
}
}
byte[] toByteArray() {
if (len <= 0)
return null;
return retval;
}
throw new IOException("out of data");
else
}
/**
* Compares this DerInputBuffer for equality with the specified
* object.
*/
if (other instanceof DerInputBuffer)
else
return false;
}
if (this == other)
return true;
return false;
for (int i = 0; i < max; i++) {
return false;
}
}
return true;
}
/**
* Returns a hashcode for this DerInputBuffer.
*
* @return a hashcode for this DerInputBuffer.
*/
public int hashCode() {
int retval = 0;
int p = pos;
for (int i = 0; i < len; i++)
return retval;
}
throw new IOException("insufficient data");
}
/**
* Returns the integer which takes up the specified number
* of bytes in this buffer as a BigInteger.
* @param len the number of bytes to use.
* @param makePositive whether to always return a positive value,
* irrespective of actual encoding
* @return the integer as a BigInteger.
*/
throw new IOException("short read of integer");
if (len == 0) {
throw new IOException("Invalid encoding: zero length Int value");
}
if (makePositive) {
} else {
return new BigInteger(bytes);
}
}
/**
* Returns the integer which takes up the specified number
* of bytes in this buffer.
* @throws IOException if the result is not within the valid
* range for integer, i.e. between Integer.MIN_VALUE and
* Integer.MAX_VALUE.
* @param len the number of bytes to use.
* @return the integer.
*/
throw new IOException("Integer below minimum valid value");
}
throw new IOException("Integer exceeds maximum valid value");
}
}
/**
* Returns the bit string which takes up the specified
* number of bytes in this buffer.
*/
throw new IOException("short read of bit string");
if (len == 0) {
throw new IOException("Invalid encoding: zero length bit string");
}
throw new IOException("Invalid number of padding bits");
}
// minus the first byte which indicates the number of padding bits
if (numOfPadBits != 0) {
// get rid of the padding bits
}
return retval;
}
/**
* Returns the bit string which takes up the rest of this buffer.
*/
return getBitString(available());
}
/**
* Returns the bit string which takes up the rest of this buffer.
* The bit string need not be byte-aligned.
*/
return null;
/*
* Just copy the data into an aligned, padded octet buffer,
* and consume the rest of the buffer.
*/
if (unusedBits > 7 ) {
}
// number of valid bits
return bitArray;
}
/**
* Returns the UTC Time value that takes up the specified number
* of bytes in this buffer.
* @param len the number of bytes to use
*/
throw new IOException("short read of DER UTC Time");
throw new IOException("DER UTC Time length error");
}
/**
* Returns the Generalized Time value that takes up the specified
* number of bytes in this buffer.
* @param len the number of bytes to use
*/
throw new IOException("short read of DER Generalized Time");
throw new IOException("DER Generalized Time length error");
}
/**
* Private helper routine to extract time from the der value.
* @param len the number of bytes to use
* @param generalized true if Generalized Time is to be read, false
* if UTC Time is to be read.
*/
/*
* UTC time encoded as ASCII chars:
* YYMMDDhhmmZ
* YYMMDDhhmmssZ
* YYMMDDhhmm+hhmm
* YYMMDDhhmm-hhmm
* YYMMDDhhmmss+hhmm
* YYMMDDhhmmss-hhmm
* UTC Time is broken in storing only two digits of year.
* If YY < 50, we assume 20YY;
* if YY >= 50, we assume 19YY, as per RFC 3280.
*
* Generalized time has a four-digit year and allows any
* precision specified in ISO 8601. However, for our purposes,
* we will only allow the same format as UTC time, except that
* fractional seconds (millisecond precision) are supported.
*/
if (generalized) {
type = "Generalized";
} else {
type = "UTC";
year += 2000;
else
}
/*
* We allow for non-encoded seconds, even though the
* IETF-PKIX specification says that the seconds should
* always be encoded even if it is zero.
*/
millis = 0;
len -= 2;
// handle fractional seconds (if present)
len --;
pos++;
// handle upto milisecond precision only
int precision = 0;
peek++;
precision++;
}
switch (precision) {
case 3:
break;
case 2:
break;
case 1:
break;
default:
" time, unsupported precision for seconds value");
}
}
} else
second = 0;
/*
* Generalized time can theoretically allow any precision,
* but we're not supporting that.
*/
/*
* Finally, "Z" or "+hhmm" or "-hhmm" ... offsets change hhmm
*/
case '+':
break;
case '-':
break;
case 'Z':
break;
default:
}
}
}