本文整理汇总了Java中org.bouncycastle.util.Arrays类的典型用法代码示例。如果您正苦于以下问题:Java Arrays类的具体用法?Java Arrays怎么用?Java Arrays使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Arrays类属于org.bouncycastle.util包,在下文中一共展示了Arrays类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyUserSig
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
@Override
public boolean verifyUserSig(String identifier, String sig)throws QCloudException {
try {
Security.addProvider(new BouncyCastleProvider());
//DeBaseUrl64 urlSig to json
Base64 decoder = new Base64();
byte [] compressBytes = Base64Url.base64DecodeUrl(sig.getBytes(Charset.forName("UTF-8")));
//Decompression
Inflater decompression = new Inflater();
decompression.setInput(compressBytes, 0, compressBytes.length);
byte [] decompressBytes = new byte [1024];
int decompressLength = decompression.inflate(decompressBytes);
decompression.end();
String jsonString = new String(Arrays.copyOfRange(decompressBytes, 0, decompressLength));
//Get TLS.Sig from json
JSONObject jsonObject= JSON.parseObject(jsonString);
String sigTLS = jsonObject.getString("TLS.sig");
//debase64 TLS.Sig to get serailString
byte[] signatureBytes = decoder.decode(sigTLS.getBytes(Charset.forName("UTF-8")));
String strSdkAppid = jsonObject.getString("TLS.sdk_appid");
String sigTime = jsonObject.getString("TLS.time");
String sigExpire = jsonObject.getString("TLS.expire_after");
if (!imConfig.getSdkAppId().equals(strSdkAppid))
{
return false;
}
if ( System.currentTimeMillis()/1000 - Long.parseLong(sigTime) > Long.parseLong(sigExpire)) {
return false;
}
//Get Serial String from json
String SerialString =
"TLS.appid_at_3rd:" + 0 + "\n" +
"TLS.account_type:" + 0 + "\n" +
"TLS.identifier:" + identifier + "\n" +
"TLS.sdk_appid:" + imConfig.getSdkAppId() + "\n" +
"TLS.time:" + sigTime + "\n" +
"TLS.expire_after:" + sigExpire + "\n";
Reader reader = new CharArrayReader(imConfig.getPublicKey().toCharArray());
PEMParser parser = new PEMParser(reader);
JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
Object obj = parser.readObject();
parser.close();
PublicKey pubKeyStruct = converter.getPublicKey((SubjectPublicKeyInfo) obj);
Signature signature = Signature.getInstance("SHA256withECDSA","BC");
signature.initVerify(pubKeyStruct);
signature.update(SerialString.getBytes(Charset.forName("UTF-8")));
return signature.verify(signatureBytes);
}catch (Exception e) {
throw new QCloudException(e);
}
}
示例2: processFinishedMessage
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
protected void processFinishedMessage(ByteArrayInputStream buf)
throws IOException
{
byte[] verify_data = TlsUtils.readFully(expected_verify_data.length, buf);
assertEmpty(buf);
/*
* Compare both checksums.
*/
if (!Arrays.constantTimeAreEqual(expected_verify_data, verify_data))
{
/*
* Wrong checksum in the finished message.
*/
this.failWithError(AlertLevel.fatal, AlertDescription.decrypt_error);
}
}
示例3: asn1Equals
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
boolean asn1Equals(
DERObject o)
{
if (!(o instanceof DEREnumerated))
{
return false;
}
DEREnumerated other = (DEREnumerated)o;
return Arrays.areEqual(this.bytes, other.bytes);
}
示例4: hashCode
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
public int hashCode()
{
int code = Arrays.hashCode(subjectKeyId);
if (this.serialNumber != null)
{
code ^= this.serialNumber.hashCode();
}
if (this.issuer != null)
{
code ^= this.issuer.hashCode();
}
return code;
}
示例5: equals
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
public boolean equals(
Object o)
{
if (!(o instanceof X509CertificateHolderSelector))
{
return false;
}
X509CertificateHolderSelector id = (X509CertificateHolderSelector)o;
return Arrays.areEqual(subjectKeyId, id.subjectKeyId)
&& equalsObj(this.serialNumber, id.serialNumber)
&& equalsObj(this.issuer, id.issuer);
}
示例6: exponentiateX
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
public void exponentiateX(long pow, byte[] output)
{
// Initial value is little-endian 1
byte[] y = GCMUtil.oneAsBytes();
if (pow > 0)
{
byte[] powX = Arrays.clone(x);
do
{
if ((pow & 1L) != 0)
{
GCMUtil.multiply(y, powX);
}
GCMUtil.multiply(powX, powX);
pow >>>= 1;
}
while (pow > 0);
}
System.arraycopy(y, 0, output, 0, 16);
}
示例7: isValid
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
public boolean isValid(PKMACValue value, char[] password, SubjectPublicKeyInfo keyInfo)
throws CRMFException
{
builder.setParameters(PBMParameter.getInstance(value.getAlgId().getParameters()));
MacCalculator calculator = builder.build(password);
OutputStream macOut = calculator.getOutputStream();
try
{
macOut.write(keyInfo.getEncoded(ASN1Encoding.DER));
macOut.close();
}
catch (IOException e)
{
throw new CRMFException("exception encoding mac input: " + e.getMessage(), e);
}
return Arrays.areEqual(calculator.getMac(), value.getValue().getBytes());
}
示例8: unionIPRange
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
/**
* Calculates the union if two IP ranges.
*
* @param ipWithSubmask1 The first IP address with its subnet mask.
* @param ipWithSubmask2 The second IP address with its subnet mask.
* @return A <code>Set</code> with the union of both addresses.
*/
private Set unionIPRange(byte[] ipWithSubmask1, byte[] ipWithSubmask2)
{
Set set = new HashSet();
// difficult, adding always all IPs is not wrong
if (Arrays.areEqual(ipWithSubmask1, ipWithSubmask2))
{
set.add(ipWithSubmask1);
}
else
{
set.add(ipWithSubmask1);
set.add(ipWithSubmask2);
}
return set;
}
示例9: isIPConstrained
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
/**
* Checks if the IP address <code>ip</code> is constrained by
* <code>constraint</code>.
*
* @param ip The IP address.
* @param constraint The constraint. This is an IP address concatenated with
* its subnetmask.
* @return <code>true</code> if constrained, <code>false</code>
* otherwise.
*/
private boolean isIPConstrained(byte ip[], byte[] constraint)
{
int ipLength = ip.length;
if (ipLength != (constraint.length / 2))
{
return false;
}
byte[] subnetMask = new byte[ipLength];
System.arraycopy(constraint, ipLength, subnetMask, 0, ipLength);
byte[] permittedSubnetAddress = new byte[ipLength];
byte[] ipSubnetAddress = new byte[ipLength];
// the resulting IP address by applying the subnet mask
for (int i = 0; i < ipLength; i++)
{
permittedSubnetAddress[i] = (byte)(constraint[i] & subnetMask[i]);
ipSubnetAddress[i] = (byte)(ip[i] & subnetMask[i]);
}
return Arrays.areEqual(permittedSubnetAddress, ipSubnetAddress);
}
示例10: reset
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
private void reset(
boolean clearMac)
{
cipher.reset(); // TODO Redundant since the mac will reset it?
mac.reset();
bufOff = 0;
Arrays.fill(bufBlock, (byte)0);
if (clearMac)
{
Arrays.fill(macBlock, (byte)0);
}
byte[] tag = new byte[blockSize];
tag[blockSize - 1] = hTAG;
mac.update(tag, 0, blockSize);
cipherInitialized = false;
if (initialAssociatedText != null)
{
processAADBytes(initialAssociatedText, 0, initialAssociatedText.length);
}
}
示例11: engineInit
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
protected void engineInit(
byte[] params)
throws IOException
{
//
// check that we don't have a DER encoded octet string
//
if ((params.length % 8) != 0
&& params[0] == 0x04 && params[1] == params.length - 2)
{
ASN1OctetString oct = (ASN1OctetString)ASN1Primitive.fromByteArray(params);
params = oct.getOctets();
}
this.iv = Arrays.clone(params);
}
示例12: equals
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
private boolean equals(Object o1, Object o2)
{
if (o1 == o2)
{
return true;
}
if (o1 == null || o2 == null)
{
return false;
}
if (o1 instanceof byte[] && o2 instanceof byte[])
{
return Arrays.areEqual((byte[])o1, (byte[])o2);
}
else
{
return o1.equals(o2);
}
}
示例13: isMacValid
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
/**
* Verify the MacData attached to the PFX is consistent with what is expected.
*
* @param macCalcProviderBuilder provider builder for the calculator for the MAC
* @param password password to use
* @return true if mac data is valid, false otherwise.
* @throws PKCSException if there is a problem evaluating the MAC.
* @throws IllegalStateException if no MAC is actually present
*/
public boolean isMacValid(PKCS12MacCalculatorBuilderProvider macCalcProviderBuilder, char[] password)
throws PKCSException
{
if (hasMac())
{
MacData pfxmData = pfx.getMacData();
MacDataGenerator mdGen = new MacDataGenerator(macCalcProviderBuilder.get(new AlgorithmIdentifier(pfxmData.getMac().getAlgorithmId().getAlgorithm(), new PKCS12PBEParams(pfxmData.getSalt(), pfxmData.getIterationCount().intValue()))));
try
{
MacData mData = mdGen.build(
password,
ASN1OctetString.getInstance(pfx.getAuthSafe().getContent()).getOctets());
return Arrays.constantTimeAreEqual(mData.getEncoded(), pfx.getMacData().getEncoded());
}
catch (IOException e)
{
throw new PKCSException("unable to process AuthSafe: " + e.getMessage());
}
}
throw new IllegalStateException("no MAC present on PFX");
}
示例14: equals
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
BigIntPolynomial other = (BigIntPolynomial)obj;
if (!Arrays.areEqual(coeffs, other.coeffs))
{
return false;
}
return true;
}
示例15: reset
import org.bouncycastle.util.Arrays; //导入依赖的package包/类
public void reset()
{
v0 = k0 ^ 0x736f6d6570736575L;
v1 = k1 ^ 0x646f72616e646f6dL;
v2 = k0 ^ 0x6c7967656e657261L;
v3 = k1 ^ 0x7465646279746573L;
Arrays.fill(buf, (byte)0);
bufPos = 0;
wordCount = 0;
}