use of com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier in project jmulticard by ctt-gob-es.
the class SignerInformationVerifier method getContentVerifier.
public ContentVerifier getContentVerifier(AlgorithmIdentifier signingAlgorithm, AlgorithmIdentifier digestAlgorithm) throws OperatorCreationException {
String signatureName = sigNameGenerator.getSignatureName(digestAlgorithm, signingAlgorithm);
AlgorithmIdentifier baseAlgID = sigAlgorithmFinder.find(signatureName);
return verifierProvider.get(new AlgorithmIdentifier(baseAlgID.getAlgorithm(), signingAlgorithm.getParameters()));
}
use of com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier in project jmulticard by ctt-gob-es.
the class BCECPublicKey method getEncoded.
public byte[] getEncoded() {
boolean pcSet = Properties.isOverrideSet("org.bouncycastle.ec.enable_pc");
if (encoding == null || oldPcSet != pcSet) {
boolean compress = withCompression || pcSet;
AlgorithmIdentifier algId = new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, ECUtils.getDomainParametersFromName(ecSpec, compress));
byte[] pubKeyOctets = ecPublicKey.getQ().getEncoded(compress);
// stored curve is null if ImplicitlyCa
encoding = KeyUtil.getEncodedSubjectPublicKeyInfo(algId, pubKeyOctets);
oldPcSet = pcSet;
}
return Arrays.clone(encoding);
}
use of com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier in project jmulticard by ctt-gob-es.
the class BCMcElieceCCA2PrivateKey method getEncoded.
/**
* Return the keyData to encode in the SubjectPublicKeyInfo structure.
* <p>
* The ASN.1 definition of the key structure is
* <pre>
* McEliecePrivateKey ::= SEQUENCE {
* m INTEGER -- extension degree of the field
* k INTEGER -- dimension of the code
* field OCTET STRING -- field polynomial
* goppaPoly OCTET STRING -- irreducible Goppa polynomial
* p OCTET STRING -- permutation vector
* matrixH OCTET STRING -- canonical check matrix
* sqRootMatrix SEQUENCE OF OCTET STRING -- square root matrix
* }
* </pre>
* @return the keyData to encode in the SubjectPublicKeyInfo structure
*/
public byte[] getEncoded() {
PrivateKeyInfo pki;
try {
McElieceCCA2PrivateKey privateKey = new McElieceCCA2PrivateKey(getN(), getK(), getField(), getGoppaPoly(), getP(), MessageDigestUtils.getDigestAlgID(params.getDigest()));
AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.mcElieceCca2);
pki = new PrivateKeyInfo(algorithmIdentifier, privateKey);
return pki.getEncoded();
} catch (IOException e) {
return null;
}
}
use of com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier in project jmulticard by ctt-gob-es.
the class BCMcEliecePrivateKey method getEncoded.
/**
* Return the key data to encode in the SubjectPublicKeyInfo structure.
* <p>
* The ASN.1 definition of the key structure is
* </p>
* <pre>
* McEliecePrivateKey ::= SEQUENCE {
* n INTEGER -- length of the code
* k INTEGER -- dimension of the code
* fieldPoly OCTET STRING -- field polynomial defining GF(2ˆm)
* getGoppaPoly() OCTET STRING -- irreducible Goppa polynomial
* sInv OCTET STRING -- matrix Sˆ-1
* p1 OCTET STRING -- permutation P1
* p2 OCTET STRING -- permutation P2
* h OCTET STRING -- canonical check matrix
* qInv SEQUENCE OF OCTET STRING -- matrix used to compute square roots
* }
* </pre>
*
* @return the key data to encode in the SubjectPublicKeyInfo structure
*/
public byte[] getEncoded() {
McEliecePrivateKey privateKey = new McEliecePrivateKey(params.getN(), params.getK(), params.getField(), params.getGoppaPoly(), params.getP1(), params.getP2(), params.getSInv());
PrivateKeyInfo pki;
try {
AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.mcEliece);
pki = new PrivateKeyInfo(algorithmIdentifier, privateKey);
} catch (IOException e) {
return null;
}
try {
byte[] encoded = pki.getEncoded();
return encoded;
} catch (IOException e) {
return null;
}
}
use of com.github.zhenwei.core.asn1.x509.AlgorithmIdentifier in project jmulticard by ctt-gob-es.
the class BCSphincs256PrivateKey method getEncoded.
public byte[] getEncoded() {
try {
PrivateKeyInfo pki;
if (params.getTreeDigest() != null) {
pki = PrivateKeyInfoFactory.createPrivateKeyInfo(params, attributes);
} else {
AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.sphincs256, new SPHINCS256KeyParams(new AlgorithmIdentifier(treeDigest)));
pki = new PrivateKeyInfo(algorithmIdentifier, new DEROctetString(params.getKeyData()), attributes);
}
return pki.getEncoded();
} catch (IOException e) {
return null;
}
}
Aggregations