本文整理汇总了Java中org.bouncycastle.util.io.Streams.readFully方法的典型用法代码示例。如果您正苦于以下问题:Java Streams.readFully方法的具体用法?Java Streams.readFully怎么用?Java Streams.readFully使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.util.io.Streams
的用法示例。
在下文中一共展示了Streams.readFully方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toByteArray
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
byte[] toByteArray()
throws IOException
{
if (_remaining == 0)
{
return EMPTY_BYTES;
}
byte[] bytes = new byte[_remaining];
if ((_remaining -= Streams.readFully(_in, bytes)) != 0)
{
throw new EOFException("DEF length " + _originalLength + " object truncated by " + _remaining);
}
setParentEofDetect(true);
return bytes;
}
示例2: getBuffer
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private static byte[] getBuffer(DefiniteLengthInputStream defIn, byte[][] tmpBuffers)
throws IOException
{
int len = defIn.getRemaining();
if (defIn.getRemaining() < tmpBuffers.length)
{
byte[] buf = tmpBuffers[len];
if (buf == null)
{
buf = tmpBuffers[len] = new byte[len];
}
Streams.readFully(defIn, buf);
return buf;
}
else
{
return defIn.toByteArray();
}
}
示例3: fromInputStream
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
static DERBitString fromInputStream(int length, InputStream stream)
throws IOException
{
if (length < 1)
{
throw new IllegalArgumentException("truncated BIT STRING detected");
}
int padBits = stream.read();
byte[] data = new byte[length - 1];
if (data.length != 0)
{
if (Streams.readFully(stream, data) != data.length)
{
throw new EOFException("EOF encountered in middle of BIT STRING");
}
}
return new DERBitString(data, padBits);
}
示例4: readAllOrNothing
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public static byte[] readAllOrNothing(int length, InputStream input)
throws IOException
{
if (length < 1)
{
return EMPTY_BYTES;
}
byte[] buf = new byte[length];
int read = Streams.readFully(input, buf);
if (read == 0)
{
return null;
}
if (read != length)
{
throw new EOFException();
}
return buf;
}
示例5: readFully
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
protected void readFully(
byte[] bytes)
throws IOException
{
if (Streams.readFully(this, bytes) != bytes.length)
{
throw new EOFException("EOF encountered in middle of object");
}
}
示例6: readFully
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public static byte[] readFully(int length, InputStream input)
throws IOException
{
if (length < 1)
{
return EMPTY_BYTES;
}
byte[] buf = new byte[length];
if (length != Streams.readFully(input, buf))
{
throw new EOFException();
}
return buf;
}
示例7: readFully
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public void readFully(
byte[] buf,
int off,
int len)
throws IOException
{
if (Streams.readFully(this, buf, off, len) < len)
{
throw new EOFException();
}
}
示例8: readBytes
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
static byte[] readBytes(InputStream in, int ch)
throws IOException
{
int len = readLength(in, ch);
byte[] data = new byte[len];
Streams.readFully(in, data);
return data;
}
示例9: readFully
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public static void readFully(byte[] buf, InputStream input)
throws IOException
{
int length = buf.length;
if (length > 0 && length != Streams.readFully(input, buf))
{
throw new EOFException();
}
}
示例10: readKey
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public AsymmetricKeyParameter readKey(InputStream stream)
throws IOException
{
byte[] V;
int first = stream.read();
// Decode the public ephemeral key
switch (first)
{
case 0x00: // infinity
throw new IOException("Sender's public key invalid.");
case 0x02: // compressed
case 0x03: // Byte length calculated as in ECPoint.getEncoded();
V = new byte[1 + (ecParams.getCurve().getFieldSize()+7)/8];
break;
case 0x04: // uncompressed or
case 0x06: // hybrid
case 0x07: // Byte length calculated as in ECPoint.getEncoded();
V = new byte[1 + 2*((ecParams.getCurve().getFieldSize()+7)/8)];
break;
default:
throw new IOException("Sender's public key has invalid point encoding 0x" + Integer.toString(first, 16));
}
V[0] = (byte)first;
Streams.readFully(stream, V, 1, V.length - 1);
return new ECPublicKeyParameters(ecParams.getCurve().decodePoint(V), ecParams);
}
示例11: readKey
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public AsymmetricKeyParameter readKey(InputStream stream)
throws IOException
{
byte[] V = new byte[(dhParams.getP().bitLength() + 7) / 8];
Streams.readFully(stream, V, 0, V.length);
return new DHPublicKeyParameters(new BigInteger(1, V), dhParams);
}
示例12: fromInputStream
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
static ASN1BitString fromInputStream(int length, InputStream stream)
throws IOException
{
if (length < 1)
{
throw new IllegalArgumentException("truncated BIT STRING detected");
}
int padBits = stream.read();
byte[] data = new byte[length - 1];
if (data.length != 0)
{
if (Streams.readFully(stream, data) != data.length)
{
throw new EOFException("EOF encountered in middle of BIT STRING");
}
if (padBits > 0 && padBits < 8)
{
if (data[data.length - 1] != (byte)(data[data.length - 1] & (0xff << padBits)))
{
return new DLBitString(data, padBits);
}
}
}
return new DERBitString(data, padBits);
}
示例13: readNbBytes
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private byte[] readNbBytes(InputStream s, int length) throws IOException {
byte[] array = new byte[length];
if (Streams.readFully(s, array) != length) {
LOG.warn("Cannot read expected length!");
}
return array;
}
示例14: decodeUint32
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private long decodeUint32(InputStream inputStream) throws IOException, X10FlashException {
byte[] buff = new byte[4];
if (Streams.readFully(inputStream, buff) != 4)
{
throw new X10FlashException("Not enough data to read Uint32 when decoding command");
}
long longval = ByteBuffer.wrap(buff).getInt();
return longval & 0xFFFFFFFF;
}
示例15: readFully
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
protected static void readFully(byte[] buf, InputStream is) throws IOException
{
if (Streams.readFully(is, buf) != buf.length)
{
throw new EOFException();
}
}