本文整理汇总了Java中org.bouncycastle.util.io.Streams.readAll方法的典型用法代码示例。如果您正苦于以下问题:Java Streams.readAll方法的具体用法?Java Streams.readAll怎么用?Java Streams.readAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.util.io.Streams
的用法示例。
在下文中一共展示了Streams.readAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processClientKeyExchange
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public void processClientKeyExchange(InputStream input)
throws IOException
{
byte[] encryptedPreMasterSecret;
if (TlsUtils.isSSL(context))
{
// TODO Do any SSLv3 clients actually include the length?
encryptedPreMasterSecret = Streams.readAll(input);
}
else
{
encryptedPreMasterSecret = TlsUtils.readOpaque16(input);
}
this.premasterSecret = serverCredentials.decryptPreMasterSecret(encryptedPreMasterSecret);
}
示例2: processClientKeyExchange
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public void processClientKeyExchange(InputStream input)
throws IOException
{
byte[] encryptedPreMasterSecret;
if (TlsUtils.isSSL(context))
{
// TODO Do any SSLv3 clients actually include the length?
encryptedPreMasterSecret = Streams.readAll(input);
}
else
{
encryptedPreMasterSecret = TlsUtils.readOpaque16(input);
}
this.premasterSecret = TlsRSAUtils.safeDecryptPreMasterSecret(context, serverCredentials, encryptedPreMasterSecret);
}
示例3: getRfc4134Data
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private static byte[] getRfc4134Data(String name)
{
String dataHome = System.getProperty(TEST_DATA_HOME);
if (dataHome == null)
{
throw new IllegalStateException(TEST_DATA_HOME + " property not set");
}
try
{
return Streams.readAll(new FileInputStream(dataHome + "/rfc4134/" + name));
}
catch (IOException e)
{
throw new RuntimeException(e.toString());
}
}
示例4: getDERObject
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public DERObject getDERObject()
{
try
{
return new BERConstructedOctetString(Streams.readAll(getOctetStream()));
}
catch (IOException e)
{
throw new ASN1ParsingException("IOException converting stream to byte array: " + e.getMessage(), e);
}
}
示例5: decryptValue
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private byte[] decryptValue(ValueDecryptorGenerator decGen)
throws CRMFException
{
if (value.getIntendedAlg() != null)
{
throw new UnsupportedOperationException();
}
if (value.getValueHint() != null)
{
throw new UnsupportedOperationException();
}
InputDecryptor decryptor = decGen.getValueDecryptor(value.getKeyAlg(),
value.getSymmAlg(), value.getEncSymmKey().getBytes());
InputStream dataIn = decryptor.getInputStream(new ByteArrayInputStream(
value.getEncValue().getBytes()));
try
{
byte[] data = Streams.readAll(dataIn);
if (padder != null)
{
return padder.getUnpaddedData(data);
}
return data;
}
catch (IOException e)
{
throw new CRMFException("Cannot parse decrypted data: " + e.getMessage(), e);
}
}
示例6: decryptValue
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private byte[] decryptValue(ValueDecryptorGenerator decGen)
throws CRMFException
{
if (value.getIntendedAlg() != null)
{
throw new IllegalStateException("unsupported operation");
}
if (value.getValueHint() != null)
{
throw new IllegalStateException("unsupported operation");
}
InputDecryptor decryptor = decGen.getValueDecryptor(value.getKeyAlg(),
value.getSymmAlg(), value.getEncSymmKey().getBytes());
InputStream dataIn = decryptor.getInputStream(new ByteArrayInputStream(
value.getEncValue().getBytes()));
try
{
byte[] data = Streams.readAll(dataIn);
if (padder != null)
{
return padder.getUnpaddedData(data);
}
return data;
}
catch (IOException e)
{
throw new CRMFException("Cannot parse decrypted data: " + e.getMessage(), e);
}
}
示例7: decryptText
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public String decryptText(String text) throws CloudsyncException
{
text = text.replace('_', '/');
final byte[] data = Base64.decodeBase64(text);
try
{
return new String(Streams.readAll(decryptData(new ByteArrayInputStream(data))));
}
catch (IOException e)
{
throw new CloudsyncException("can't encrypt data", e);
}
}
示例8: processClientKeyExchange
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public void processClientKeyExchange(InputStream input)
throws IOException
{
byte[] encryptedPreMasterSecret;
if (context.getServerVersion().isSSL())
{
// TODO Do any SSLv3 clients actually include the length?
encryptedPreMasterSecret = Streams.readAll(input);
}
else
{
encryptedPreMasterSecret = TlsUtils.readOpaque16(input);
}
ProtocolVersion clientVersion = context.getClientVersion();
/*
* RFC 5246 7.4.7.1.
*/
{
// TODO Provide as configuration option?
boolean versionNumberCheckDisabled = false;
/*
* See notes regarding Bleichenbacher/Klima attack. The code here implements the first
* construction proposed there, which is RECOMMENDED.
*/
byte[] R = new byte[48];
this.context.getSecureRandom().nextBytes(R);
byte[] M = TlsUtils.EMPTY_BYTES;
try
{
M = serverCredentials.decryptPreMasterSecret(encryptedPreMasterSecret);
}
catch (Exception e)
{
/*
* In any case, a TLS server MUST NOT generate an alert if processing an
* RSA-encrypted premaster secret message fails, or the version number is not as
* expected. Instead, it MUST continue the handshake with a randomly generated
* premaster secret.
*/
}
if (M.length != 48)
{
TlsUtils.writeVersion(clientVersion, R, 0);
this.premasterSecret = R;
}
else
{
/*
* If ClientHello.client_version is TLS 1.1 or higher, server implementations MUST
* check the version number [..].
*/
if (versionNumberCheckDisabled && clientVersion.isEqualOrEarlierVersionOf(ProtocolVersion.TLSv10))
{
/*
* If the version number is TLS 1.0 or earlier, server implementations SHOULD
* check the version number, but MAY have a configuration option to disable the
* check.
*/
}
else
{
/*
* Note that explicitly constructing the pre_master_secret with the
* ClientHello.client_version produces an invalid master_secret if the client
* has sent the wrong version in the original pre_master_secret.
*/
TlsUtils.writeVersion(clientVersion, M, 0);
}
this.premasterSecret = M;
}
}
}
示例9: getLoadedObject
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public ASN1Primitive getLoadedObject()
throws IOException
{
return new BEROctetString(Streams.readAll(getOctetStream()));
}
示例10: streamToByteArray
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public static byte[] streamToByteArray(
InputStream in)
throws IOException
{
return Streams.readAll(in);
}
示例11: readAll
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public byte[] readAll()
throws IOException
{
return Streams.readAll(this);
}
示例12: PublicKeyEncSessionPacket
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
PublicKeyEncSessionPacket(
BCPGInputStream in)
throws IOException
{
version = in.read();
keyID |= (long)in.read() << 56;
keyID |= (long)in.read() << 48;
keyID |= (long)in.read() << 40;
keyID |= (long)in.read() << 32;
keyID |= (long)in.read() << 24;
keyID |= (long)in.read() << 16;
keyID |= (long)in.read() << 8;
keyID |= in.read();
algorithm = in.read();
switch (algorithm)
{
case RSA_ENCRYPT:
case RSA_GENERAL:
data = new byte[1][];
data[0] = new MPInteger(in).getEncoded();
break;
case ELGAMAL_ENCRYPT:
case ELGAMAL_GENERAL:
data = new byte[2][];
data[0] = new MPInteger(in).getEncoded();
data[1] = new MPInteger(in).getEncoded();
break;
case ECDH:
data = new byte[1][];
data[0] = Streams.readAll(in);
break;
default:
throw new IOException("unknown PGP public key algorithm encountered");
}
}
示例13: processClientKeyExchange
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public void processClientKeyExchange(InputStream input) throws IOException
{
byte[] psk_identity = TlsUtils.readOpaque16(input);
this.psk = pskIdentityManager.getPSK(psk_identity);
if (psk == null)
{
throw new TlsFatalAlert(AlertDescription.unknown_psk_identity);
}
context.getSecurityParameters().pskIdentity = psk_identity;
if (this.keyExchange == KeyExchangeAlgorithm.DHE_PSK)
{
BigInteger Yc = TlsDHUtils.readDHParameter(input);
this.dhAgreePublicKey = TlsDHUtils.validateDHPublicKey(new DHPublicKeyParameters(Yc, dhParameters));
}
else if (this.keyExchange == KeyExchangeAlgorithm.ECDHE_PSK)
{
byte[] point = TlsUtils.readOpaque8(input);
ECDomainParameters curve_params = this.ecAgreePrivateKey.getParameters();
this.ecAgreePublicKey = TlsECCUtils.validateECPublicKey(TlsECCUtils.deserializeECPublicKey(
serverECPointFormats, curve_params, point));
}
else if (this.keyExchange == KeyExchangeAlgorithm.RSA_PSK)
{
byte[] encryptedPreMasterSecret;
if (TlsUtils.isSSL(context))
{
// TODO Do any SSLv3 clients actually include the length?
encryptedPreMasterSecret = Streams.readAll(input);
}
else
{
encryptedPreMasterSecret = TlsUtils.readOpaque16(input);
}
this.premasterSecret = serverCredentials.decryptPreMasterSecret(encryptedPreMasterSecret);
}
}
示例14: getInput
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private byte[] getInput(String name)
throws IOException
{
return Streams.readAll(getClass().getResourceAsStream(name));
}
示例15: testV1CRL
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private void testV1CRL()
throws Exception
{
byte[] certData = Streams.readAll(this.getClass().getResourceAsStream("ThawteSGCCA.cer"));
byte[] crlData = Streams.readAll(this.getClass().getResourceAsStream("ThawteSGCCA.crl"));
// verify CRL with default (JCE) provider
CertificateFactory jceFac = CertificateFactory.getInstance("X.509");
X509Certificate jceIssuer = (X509Certificate)
jceFac.generateCertificate(new ByteArrayInputStream(certData));
X509CRL jceCRL = (X509CRL)jceFac.generateCRL(new ByteArrayInputStream(crlData));
jceCRL.verify(jceIssuer.getPublicKey());
// verify CRL with BC provider
CertificateFactory bcFac = CertificateFactory.getInstance("X.509", "BC");
X509Certificate bcIssuer = (X509Certificate)
bcFac.generateCertificate(new ByteArrayInputStream(certData));
X509CRL bcCRL = (X509CRL)bcFac.generateCRL(new ByteArrayInputStream(crlData));
jceCRL.verify(bcIssuer.getPublicKey());
bcCRL.verify(bcIssuer.getPublicKey());
}