use of com.github.zhenwei.core.asn1.DERIA5String in project LinLong-Java by zhenwei1108.
the class NetscapeCertRequest method sign.
public void sign(PrivateKey priv_key, SecureRandom rand) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, NoSuchProviderException, InvalidKeySpecException {
Signature sig = Signature.getInstance(sigAlg.getAlgorithm().getId(), "WeGoo");
if (rand != null) {
sig.initSign(priv_key, rand);
} else {
sig.initSign(priv_key);
}
ASN1EncodableVector pkac = new ASN1EncodableVector();
pkac.add(getKeySpec());
pkac.add(new DERIA5String(challenge));
try {
sig.update(new DERSequence(pkac).getEncoded(ASN1Encoding.DER));
} catch (IOException ioe) {
throw new SignatureException(ioe.getMessage());
}
sigBits = sig.sign();
}
use of com.github.zhenwei.core.asn1.DERIA5String in project Conversations by iNPUTmice.
the class XmppDomainVerifier method parseOtherName.
private static Pair<String, String> parseOtherName(byte[] otherName) {
try {
ASN1Primitive asn1Primitive = ASN1Primitive.fromByteArray(otherName);
if (asn1Primitive instanceof DERTaggedObject) {
ASN1Primitive inner = ((DERTaggedObject) asn1Primitive).getObject();
if (inner instanceof DLSequence) {
DLSequence sequence = (DLSequence) inner;
if (sequence.size() >= 2 && sequence.getObjectAt(1) instanceof DERTaggedObject) {
String oid = sequence.getObjectAt(0).toString();
ASN1Primitive value = ((DERTaggedObject) sequence.getObjectAt(1)).getObject();
if (value instanceof DERUTF8String) {
return new Pair<>(oid, ((DERUTF8String) value).getString());
} else if (value instanceof DERIA5String) {
return new Pair<>(oid, ((DERIA5String) value).getString());
}
}
}
}
return null;
} catch (IOException e) {
return null;
}
}
use of com.github.zhenwei.core.asn1.DERIA5String in project attestation by TokenScript.
the class IdentifierAttestationTest method testWrongExtension.
@Test
public void testWrongExtension() throws Exception {
IdentifierAttestation initial = HelperTest.makeUnsignedStandardAtt(subjectKeys.getPublic(), BigInteger.ONE, mail);
Field field = initial.getClass().getSuperclass().getDeclaredField("extensions");
field.setAccessible(true);
// Wrong oid
ASN1EncodableVector extension = new ASN1EncodableVector();
extension.add(new ASN1ObjectIdentifier("1.2.3.4.5"));
extension.add(ASN1Boolean.FALSE);
extension.add(new DERIA5String("something wrong"));
// Change the extensions
DERSequence extensions = new DERSequence(new DERSequence(extension));
field.set(initial, extensions);
// There must be a commitment in the extensions
assertFalse(initial.checkValidity());
}
use of com.github.zhenwei.core.asn1.DERIA5String in project snikket-android by snikket-im.
the class XmppDomainVerifier method parseOtherName.
private static Pair<String, String> parseOtherName(byte[] otherName) {
try {
ASN1Primitive asn1Primitive = ASN1Primitive.fromByteArray(otherName);
if (asn1Primitive instanceof DERTaggedObject) {
ASN1Primitive inner = ((DERTaggedObject) asn1Primitive).getObject();
if (inner instanceof DLSequence) {
DLSequence sequence = (DLSequence) inner;
if (sequence.size() >= 2 && sequence.getObjectAt(1) instanceof DERTaggedObject) {
String oid = sequence.getObjectAt(0).toString();
ASN1Primitive value = ((DERTaggedObject) sequence.getObjectAt(1)).getObject();
if (value instanceof DERUTF8String) {
return new Pair<>(oid, ((DERUTF8String) value).getString());
} else if (value instanceof DERIA5String) {
return new Pair<>(oid, ((DERIA5String) value).getString());
}
}
}
}
return null;
} catch (IOException e) {
return null;
}
}
Aggregations