/** * Returns the name of the given algorithm. * * @param alg the algorithm to look up. * @return the algorithm name. */ public static String lookup(AlgorithmIdentifier alg) { return contents.get(alg.getObjectId()); }
SecretKeySpec keySpec = new SecretKeySpec(rawKey, algoID.getObjectId().getId()); Cipher c = Cipher.getInstance(algoID.getObjectId().getId(), CRYPT_PROVIDER);
private KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0) throws GeneralSecurityException, IOException { ASN1InputStream asn1inputstream = new ASN1InputStream(new ByteArrayInputStream(x509certificate.getTBSCertificate())); TBSCertificateStructure tbscertificatestructure = TBSCertificateStructure.getInstance(asn1inputstream.readObject()); AlgorithmIdentifier algorithmidentifier = tbscertificatestructure.getSubjectPublicKeyInfo().getAlgorithmId(); IssuerAndSerialNumber issuerandserialnumber = new IssuerAndSerialNumber( tbscertificatestructure.getIssuer(), tbscertificatestructure.getSerialNumber().getValue()); Cipher cipher = Cipher.getInstance(algorithmidentifier.getObjectId().getId()); cipher.init(1, x509certificate); DEROctetString deroctetstring = new DEROctetString(cipher.doFinal(abyte0)); RecipientIdentifier recipId = new RecipientIdentifier(issuerandserialnumber); return new KeyTransRecipientInfo( recipId, algorithmidentifier, deroctetstring); } }
private KeyTransRecipientInfo computeRecipientInfo(final X509Certificate x509certificate, final byte[] abyte0) throws GeneralSecurityException, IOException { final ASN1InputStream asn1inputstream = new ASN1InputStream(new ByteArrayInputStream(x509certificate.getTBSCertificate())); final TBSCertificateStructure tbscertificatestructure = TBSCertificateStructure.getInstance(asn1inputstream.readObject()); final AlgorithmIdentifier algorithmidentifier = tbscertificatestructure.getSubjectPublicKeyInfo().getAlgorithmId(); final IssuerAndSerialNumber issuerandserialnumber = new IssuerAndSerialNumber( tbscertificatestructure.getIssuer(), tbscertificatestructure.getSerialNumber().getValue()); final Cipher cipher = Cipher.getInstance(algorithmidentifier.getObjectId().getId()); cipher.init(1, x509certificate); final DEROctetString deroctetstring = new DEROctetString(cipher.doFinal(abyte0)); final RecipientIdentifier recipId = new RecipientIdentifier(issuerandserialnumber); return new KeyTransRecipientInfo( recipId, algorithmidentifier, deroctetstring); } }
DigestInfo signatureDigestInfo = new DigestInfo((ASN1Sequence) aIn.readObject()); if (false == PLAIN_TEXT_DIGEST_ALGO_OID .equals(signatureDigestInfo.getAlgorithmId().getObjectId().getId())) { throw new SecurityException("TransactionMessage signature algo OID incorrect");
/** * {@inheritDoc} */ @Override public void injectReferenceValue(X509Certificate value) throws PolicyProcessException { this.certificate = value; DERObject tbsValue = null; try { tbsValue = this.getDERObject(certificate.getTBSCertificate()); } ///CLOVER:OFF catch (Exception e) { throw new PolicyProcessException("Exception parsing TBS certificate fields.", e); } ///CLOVER:ON final TBSCertificateStructure tbsStruct = TBSCertificateStructure.getInstance(tbsValue); this.policyValue = PolicyValueFactory.getInstance(tbsStruct.getSubjectPublicKeyInfo(). getAlgorithmId().getObjectId().toString()); }
byte[] hashContentSigned = octeto.getOctets(); String algorithm = SignerAlgorithmEnum.getSignerOIDAlgorithmHashEnum(signerInformation.getDigestAlgorithmID().getObjectId().toString()).getAlgorithmHash(); if (!(DigestAlgorithmEnum.SHA_256.getAlgorithm().equalsIgnoreCase(algorithm) || DigestAlgorithmEnum.SHA_512.getAlgorithm().equalsIgnoreCase(algorithm))) { throw new SignerException("Algoritmo de resumo inválido para esta política");
byte[] hashContentSigned = octeto.getOctets(); String algorithm = SignerAlgorithmEnum.getSignerOIDAlgorithmHashEnum(signerInformation.getDigestAlgorithmID().getObjectId().toString()).getAlgorithmHash(); if (!algorithm.equals(DigestAlgorithmEnum.SHA_256.getAlgorithm())) { throw new SignerException("Algoritmo de resumo inválido para esta política");
byte[] hashContentSigned = octeto.getOctets(); String algorithm = SignerAlgorithmEnum.getSignerOIDAlgorithmHashEnum(signerInformation.getDigestAlgorithmID().getObjectId().toString()).getAlgorithmHash(); if (!algorithm.equals(DigestAlgorithmEnum.SHA_256.getAlgorithm())) { throw new SignerException("Algoritmo de resumo inválido para esta política");
final String algOid = pi.getAlgorithmId().getObjectId().getId(); if (RSA_ID.equals(pi.getAlgorithmId().getObjectId())) { algorithm = "RSA"; } else if (EC_ID.equals(pi.getAlgorithmId().getObjectId())) { algorithm = "EC"; } else if (DSA_ID.equals(pi.getAlgorithmId().getObjectId())) { algorithm = "DSA"; } else {
ASN1Object.fromByteArray(encrypted)); final AlgorithmIdentifier alg = ki.getEncryptionAlgorithm(); if (PKCSObjectIdentifiers.id_PBES2.equals(alg.getObjectId())) { PBES1Algorithm.fromOid(alg.getObjectId().getId()), PBEParameter.decode((DERSequence) alg.getParameters()));
byte[] hashContentSigned = octeto.getOctets(); String algorithm = SignerAlgorithmEnum.getSignerOIDAlgorithmHashEnum(signerInformation.getDigestAlgorithmID().getObjectId().toString()).getAlgorithmHash(); if (!algorithm.equals(DigestAlgorithmEnum.SHA_1.getAlgorithm())) { throw new SignerException("Algoritmo de resumo inválido para esta política");
byte[] hashContentSigned = octeto.getOctets(); String algorithm = SignerAlgorithmEnum.getSignerOIDAlgorithmHashEnum(signerInformation.getDigestAlgorithmID().getObjectId().toString()).getAlgorithmHash(); if (!algorithm.equals(DigestAlgorithmEnum.SHA_1.getAlgorithm()) && !algorithm.equals(DigestAlgorithmEnum.SHA_256.getAlgorithm())) { throw new SignerException("Algoritmo de resumo inválido para esta política");
if (algId.getObjectId().equals(PKCSObjectIdentifiers.rsaEncryption)) keyStructure.getCoefficient()); else if (algId.getObjectId().equals(PKCSObjectIdentifiers.dhKeyAgreement)) else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm)) else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa)) else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_ecPublicKey))
if (algId.getObjectId().equals(PKCSObjectIdentifiers.rsaEncryption)) keyStructure.getCoefficient()); else if (algId.getObjectId().equals(PKCSObjectIdentifiers.dhKeyAgreement)) else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm)) else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa)) else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_ecPublicKey))