use of com.github.zhenwei.core.asn1.ASN1Primitive in project jmulticard by ctt-gob-es.
the class McElieceCCA2KeyFactorySpi method generatePrivate.
public PrivateKey generatePrivate(PrivateKeyInfo pki) throws IOException {
// get the inner type inside the BIT STRING
ASN1Primitive innerType = pki.parsePrivateKey().toASN1Primitive();
McElieceCCA2PrivateKey key = McElieceCCA2PrivateKey.getInstance(innerType);
return new BCMcElieceCCA2PrivateKey(new McElieceCCA2PrivateKeyParameters(key.getN(), key.getK(), key.getField(), key.getGoppaPoly(), key.getP(), null));
}
use of com.github.zhenwei.core.asn1.ASN1Primitive in project jmulticard by ctt-gob-es.
the class McElieceKeyFactorySpi method generatePublic.
public PublicKey generatePublic(SubjectPublicKeyInfo pki) throws IOException {
// get the inner type inside the BIT STRING
ASN1Primitive innerType = pki.parsePublicKey();
McEliecePublicKey key = McEliecePublicKey.getInstance(innerType);
return new BCMcEliecePublicKey(new McEliecePublicKeyParameters(key.getN(), key.getT(), key.getG()));
}
use of com.github.zhenwei.core.asn1.ASN1Primitive in project signer by demoiselle.
the class CertificateTrustPoint method parse.
@Override
public void parse(ASN1Primitive derObject) {
ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
DERSequence x509Sequence = (DERSequence) derSequence.getObjectAt(0).toASN1Primitive();
try {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(x509Sequence.getEncoded());
this.trustpoint = (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate(byteArrayInputStream);
} catch (Throwable error) {
error.printStackTrace();
}
int total = derSequence.size();
if (total > 0) {
for (int i = 0; i < total; i++) {
ASN1Primitive object = derSequence.getObjectAt(i).toASN1Primitive();
if (object instanceof DERTaggedObject) {
DERTaggedObject derTaggedObject = (DERTaggedObject) object;
TAG tag = TAG.getTag(derTaggedObject.getTagNo());
switch(tag) {
case pathLenConstraint:
this.pathLenConstraint = new PathLenConstraint();
this.pathLenConstraint.parse(object);
break;
case acceptablePolicySet:
this.acceptablePolicySet = new AcceptablePolicySet();
this.acceptablePolicySet.parse(object);
break;
case nameConstraints:
this.nameConstraints = new NameConstraints();
this.nameConstraints.parse(object);
break;
case policyConstraints:
this.policyConstraints = new PolicyConstraints();
this.policyConstraints.parse(object);
break;
default:
break;
}
}
}
}
}
use of com.github.zhenwei.core.asn1.ASN1Primitive in project signer by demoiselle.
the class LPA method parse.
@Override
public void parse(ASN1Primitive derObject) {
ASN1Sequence sequence = ASN1Object.getDERSequence(derObject);
ASN1Primitive policyInfos = sequence.getObjectAt(0).toASN1Primitive();
DLSequence policyInfosSequence = (DLSequence) policyInfos;
if (policyInfosSequence != null && policyInfosSequence.size() > 0) {
this.policyInfos = new ArrayList<>();
for (int i = 0; i < policyInfosSequence.size(); i++) {
PolicyInfo policyInfo = new PolicyInfo();
policyInfo.parse(policyInfosSequence.getObjectAt(i).toASN1Primitive());
this.policyInfos.add(policyInfo);
}
}
this.nextUpdate = new Time();
this.nextUpdate.parse(sequence.getObjectAt(1).toASN1Primitive());
}
use of com.github.zhenwei.core.asn1.ASN1Primitive in project signer by demoiselle.
the class PolicyFactory method loadLPAPAdESUrl.
/**
* Load signature policy for PAdES standard (PDF) from url
*
* @return org.demoiselle.signer.policy.engine.asn1.icpb.v2.LPA
*/
public org.demoiselle.signer.policy.engine.asn1.icpb.v2.LPA loadLPAPAdESUrl() {
org.demoiselle.signer.policy.engine.asn1.icpb.v2.LPA listaPoliticaAssinatura = new org.demoiselle.signer.policy.engine.asn1.icpb.v2.LPA();
InputStream is;
String conURL = ListOfSubscriptionPolicies.PAdES_ITI_URL.getUrl();
try {
LOGGER.info(policyMessagesBundle.getString("info.lpa.load.url", conURL));
is = Downloads.getInputStreamFromURL(conURL);
ASN1Primitive primitive = this.readANS1FromStream(is);
is.close();
if (!LPARepository.saveLocalLPA(conURL, "LPA_PAdES.der")) {
LOGGER.error(policyMessagesBundle.getString("error.lpa.not.saved", "LPA_PAdES.der"));
throw new RuntimeException(policyMessagesBundle.getString("error.lpa.not.saved", conURL));
}
listaPoliticaAssinatura.parse(primitive);
} catch (IOException | RuntimeException e) {
LOGGER.error(e.getMessage());
LOGGER.error(policyMessagesBundle.getString("error.lpa.not.saved", conURL));
listaPoliticaAssinatura = loadLocalLPAPAdESUrl();
return listaPoliticaAssinatura;
}
return listaPoliticaAssinatura;
}
Aggregations