use of org.bouncycastle.asn1.ASN1InputStream in project nhin-d by DirectProject.
the class CRLRevocationManager method getObject.
private static DERObject getObject(String oid, byte[] ext) throws AnnotatedException {
ASN1InputStream aIn = null;
try {
aIn = new ASN1InputStream(ext);
ASN1OctetString octs = (ASN1OctetString) aIn.readObject();
IOUtils.closeQuietly(aIn);
aIn = new ASN1InputStream(octs.getOctets());
return aIn.readObject();
} catch (Exception e) {
throw new NHINDException("exception processing extension " + oid, e);
} finally {
IOUtils.closeQuietly(aIn);
}
}
use of org.bouncycastle.asn1.ASN1InputStream in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class CredentialStorage method isHardwareBackedKey.
private boolean isHardwareBackedKey(byte[] keyData) {
try {
ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream(keyData));
PrivateKeyInfo pki = PrivateKeyInfo.getInstance(bIn.readObject());
String algOid = pki.getAlgorithmId().getAlgorithm().getId();
String algName = new AlgorithmId(new ObjectIdentifier(algOid)).getName();
return KeyChain.isBoundKeyAlgorithm(algName);
} catch (IOException e) {
Log.e(TAG, "Failed to parse key data");
return false;
}
}
use of org.bouncycastle.asn1.ASN1InputStream in project nuls by nuls-io.
the class SM2Utils method decrypt.
public static byte[] decrypt(byte[] privateKey, byte[] encryptedData) throws IOException {
if (privateKey == null || privateKey.length == 0) {
return null;
}
if (encryptedData == null || encryptedData.length == 0) {
return null;
}
byte[] enc = new byte[encryptedData.length];
System.arraycopy(encryptedData, 0, enc, 0, encryptedData.length);
SM2 sm2 = SM2.Instance();
BigInteger userD = new BigInteger(1, privateKey);
ByteArrayInputStream bis = new ByteArrayInputStream(enc);
ASN1InputStream dis = new ASN1InputStream(bis);
DERObject derObj = dis.readObject();
ASN1Sequence asn1 = (ASN1Sequence) derObj;
DERInteger x = (DERInteger) asn1.getObjectAt(0);
DERInteger y = (DERInteger) asn1.getObjectAt(1);
ECPoint c1 = sm2.ecc_curve.createPoint(x.getValue(), y.getValue(), true);
Cipher cipher = new Cipher();
cipher.initDec(userD, c1);
DEROctetString data = (DEROctetString) asn1.getObjectAt(3);
enc = data.getOctets();
cipher.decrypt(enc);
byte[] c3 = new byte[32];
cipher.dofinal(c3);
return enc;
}
use of org.bouncycastle.asn1.ASN1InputStream in project BiglyBT by BiglySoftware.
the class PrincipalUtil method getIssuerX509Principal.
/**
* return the issuer of the given CRL as an X509PrincipalObject.
*/
public static X509Principal getIssuerX509Principal(X509CRL crl) throws CRLException {
try {
ByteArrayInputStream bIn = new ByteArrayInputStream(crl.getTBSCertList());
ASN1InputStream aIn = new ASN1InputStream(bIn);
TBSCertList tbsCertList = new TBSCertList((ASN1Sequence) aIn.readObject());
return new X509Principal(tbsCertList.getIssuer());
} catch (IOException e) {
throw new CRLException(e.toString());
}
}
use of org.bouncycastle.asn1.ASN1InputStream in project BiglyBT by BiglySoftware.
the class PrincipalUtil method getIssuerX509Principal.
/**
* return the issuer of the given cert as an X509PrincipalObject.
*/
public static X509Principal getIssuerX509Principal(X509Certificate cert) throws CertificateEncodingException {
try {
ByteArrayInputStream bIn = new ByteArrayInputStream(cert.getTBSCertificate());
ASN1InputStream aIn = new ASN1InputStream(bIn);
TBSCertificateStructure tbsCert = new TBSCertificateStructure((ASN1Sequence) aIn.readObject());
return new X509Principal(tbsCert.getIssuer());
} catch (IOException e) {
throw new CertificateEncodingException(e.toString());
}
}
Aggregations