int pos = 0; while ((pos < length) && (is.available()>0)) { int read = is.read(value); if (read > 0) {
public static DHParameters getDHParametersFromBER(OctetString berValue) throws IOException { BERInputStream inputStream = new BERInputStream(ByteBuffer.wrap(berValue.getValue())); BER.MutableByte sequenceType = new BER.MutableByte(); int sequenceLength = BER.decodeHeader(inputStream, sequenceType); long headerOffset = inputStream.getPosition(); BER.MutableByte integerType = new BER.MutableByte(); BigInteger prime = BER.decodeBigInteger(inputStream, integerType); BigInteger generator = BER.decodeBigInteger(inputStream, integerType); int privateValueLength = 0; if (inputStream.available() > 0 && inputStream.getPosition() < sequenceLength + headerOffset) { privateValueLength = BER.decodeInteger(inputStream, integerType); } return new DHParameters(prime, generator, privateValueLength); }
public static DHParameters getDHParametersFromBER(OctetString berValue) throws IOException { BERInputStream inputStream = new BERInputStream(ByteBuffer.wrap(berValue.getValue())); BER.MutableByte sequenceType = new BER.MutableByte(); int sequenceLength = BER.decodeHeader(inputStream, sequenceType); long headerOffset = inputStream.getPosition(); BER.MutableByte integerType = new BER.MutableByte(); BigInteger prime = BER.decodeBigInteger(inputStream, integerType); BigInteger generator = BER.decodeBigInteger(inputStream, integerType); int privateValueLength = 0; if (inputStream.available() > 0 && inputStream.getPosition() < sequenceLength + headerOffset) { privateValueLength = BER.decodeInteger(inputStream, integerType); } return new DHParameters(prime, generator, privateValueLength); }
protected static byte[] buildMessageBuffer(BERInputStream scopedPDU) throws IOException { scopedPDU.mark(16); int readLengthBytes = (int)scopedPDU.getPosition(); BER.MutableByte mutableByte = new BER.MutableByte(); int length = BER.decodeHeader(scopedPDU, mutableByte); readLengthBytes = (int)scopedPDU.getPosition() - readLengthBytes; byte[] buf = new byte[length + readLengthBytes]; scopedPDU.reset(); int offset = 0; int avail = scopedPDU.available(); while ((offset < buf.length) && (avail > 0)) { int read = scopedPDU.read(buf, offset, buf.length - offset); if (read < 0) { break; } offset += read; } return buf; }
protected static byte[] buildMessageBuffer(BERInputStream scopedPDU) throws IOException { scopedPDU.mark(16); int readLengthBytes = (int)scopedPDU.getPosition(); BER.MutableByte mutableByte = new BER.MutableByte(); int length = BER.decodeHeader(scopedPDU, mutableByte); readLengthBytes = (int)scopedPDU.getPosition() - readLengthBytes; byte[] buf = new byte[length + readLengthBytes]; scopedPDU.reset(); int offset = 0; int avail = scopedPDU.available(); while ((offset < buf.length) && (avail > 0)) { int read = scopedPDU.read(buf, offset, buf.length - offset); if (read < 0) { break; } offset += read; } return buf; }
private static byte[] buildMessageBuffer(BERInputStream scopedPDU) throws IOException { // return scopedPDU.getBuffer().array(); scopedPDU.mark(16); int readLengthBytes = (int)scopedPDU.getPosition(); MutableByte mutableByte = new MutableByte(); int length = BER.decodeHeader(scopedPDU, mutableByte); readLengthBytes = (int)scopedPDU.getPosition() - readLengthBytes; byte[] buf = new byte[length + readLengthBytes]; scopedPDU.reset(); int offset = 0; int avail = scopedPDU.available(); while ((offset < buf.length) && (avail > 0)) { int read = scopedPDU.read(buf, offset, buf.length - offset); if (read < 0) { break; } offset += read; } return buf; }