org.bouncycastle.asn1.x509.AlgorithmIdentifier.getAlgorithm()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(30)

本文整理了Java中org.bouncycastle.asn1.x509.AlgorithmIdentifier.getAlgorithm()方法的一些代码示例,展示了AlgorithmIdentifier.getAlgorithm()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AlgorithmIdentifier.getAlgorithm()方法的具体详情如下:
包路径:org.bouncycastle.asn1.x509.AlgorithmIdentifier
类名称:AlgorithmIdentifier
方法名:getAlgorithm

AlgorithmIdentifier.getAlgorithm介绍

暂无

代码示例

代码示例来源:origin: Meituan-Dianping/walle

@Override
  public AlgorithmIdentifier findEncryptionAlgorithm(AlgorithmIdentifier id) {
    // Use the default chooser, but replace dsaWithSha1 with dsa. This is because "dsa" is
    // accepted by any Android platform whereas "dsaWithSha1" is accepted only since
    // API Level 9.
    id = mDefault.findEncryptionAlgorithm(id);
    if (id != null) {
      ASN1ObjectIdentifier oid = id.getAlgorithm();
      if (X9ObjectIdentifiers.id_dsa_with_sha1.equals(oid)) {
        return DSA;
      }
    }
    return id;
  }
}

代码示例来源:origin: apache/tika

private List<TSDMetas> extractMetas(InputStream stream) {
  List<TSDMetas> tsdMetasList = new ArrayList<>();
  try {
    CMSTimeStampedData cmsTimeStampedData = new CMSTimeStampedData(stream);
    TimeStampToken[] tokens = cmsTimeStampedData.getTimeStampTokens();
    for (int i = 0; i < tokens.length; i++) {
      TSDMetas tsdMetas = new TSDMetas(true,
          tokens[i].getTimeStampInfo().getGenTime(),
          tokens[i].getTimeStampInfo().getPolicy().getId(),
          tokens[i].getTimeStampInfo().getSerialNumber(),
          tokens[i].getTimeStampInfo().getTsa(),
          tokens[i].getTimeStampInfo().getHashAlgorithm().getAlgorithm().getId());
      tsdMetasList.add(tsdMetas);
    }
  } catch (Exception ex) {
    LOG.error("Error in TSDParser.buildMetas {}", ex.getMessage());
    tsdMetasList.clear();
  }
  return tsdMetasList;
}

代码示例来源:origin: apache/pdfbox

private KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0)
  throws IOException, CertificateEncodingException, InvalidKeyException,
    BadPaddingException, IllegalBlockSizeException
{
  TBSCertificate certificate;
  try (ASN1InputStream input = new ASN1InputStream(x509certificate.getTBSCertificate()))
  {
    certificate = TBSCertificate.getInstance(input.readObject());
  }
  AlgorithmIdentifier algorithmId = certificate.getSubjectPublicKeyInfo().getAlgorithm();
  IssuerAndSerialNumber serial = new IssuerAndSerialNumber(
      certificate.getIssuer(),
      certificate.getSerialNumber().getValue());
  Cipher cipher;
  try
  {
    cipher = Cipher.getInstance(algorithmId.getAlgorithm().getId(),
        SecurityProvider.getProvider());
  }
  catch (NoSuchAlgorithmException | NoSuchPaddingException e)
  {
    // should never happen, if this happens throw IOException instead
    throw new RuntimeException("Could not find a suitable javax.crypto provider", e);
  }
  cipher.init(1, x509certificate.getPublicKey());
  DEROctetString octets = new DEROctetString(cipher.doFinal(abyte0));
  RecipientIdentifier recipientId = new RecipientIdentifier(serial);
  return new KeyTransRecipientInfo(recipientId, algorithmId, octets);
}

代码示例来源:origin: stackoverflow.com

algorithms.put(X9ObjectIdentifiers.id_ecPublicKey, "ECDSA");
...
private KeyFactory getKeyFactory(AlgorithmIdentifier algId)
throws NoSuchAlgorithmException, NoSuchProviderException
{
 ASN1ObjectIdentifier algorithm = algId.getAlgorithm();
 String algName = (String)algorithms.get(algorithm);
...

代码示例来源:origin: org.xipki/cmpclient

public boolean isPbmOwfPermitted(AlgorithmIdentifier pbmOwf) {
 ASN1ObjectIdentifier owfOid = pbmOwf.getAlgorithm();
 for (ASN1ObjectIdentifier oid : owfAlgos) {
  if (oid.equals(owfOid)) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-crypto-common

@Override
  public Digest getInstance(byte[] encoded)
  {
    AlgorithmIdentifier algId = AlgorithmIdentifier.getInstance(encoded);

    if (!algId.getAlgorithm().equals(getAlgorithmIdentifier().getAlgorithm())) {
      throw new IllegalArgumentException("Invalid algorithm identifier in encoded data for this digest factory: "
        + algId.getAlgorithm().getId());
    }

    return getInstance();
  }
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

public static PublicKey getPublicKey(SubjectPublicKeyInfo publicKeyInfo)
  throws IOException
{
  AsymmetricKeyInfoConverter converter = getAsymmetricKeyInfoConverter(publicKeyInfo.getAlgorithm().getAlgorithm());
  if (converter == null)
  {
    return null;
  }
  return converter.generatePublic(publicKeyInfo);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

public static PublicKey getPublicKey(SubjectPublicKeyInfo publicKeyInfo)
  throws IOException
{
  AsymmetricKeyInfoConverter converter = getAsymmetricKeyInfoConverter(publicKeyInfo.getAlgorithm().getAlgorithm());
  if (converter == null)
  {
    return null;
  }
  return converter.generatePublic(publicKeyInfo);
}

代码示例来源:origin: org.xwiki.commons/xwiki-commons-crypto-common

@Override
public Digest getInstance(byte[] encoded)
{
  AlgorithmIdentifier algId = AlgorithmIdentifier.getInstance(encoded);
  return getFactory(algId.getAlgorithm()).getInstance();
}

代码示例来源:origin: org.xipki/security

private XiContentSigner createRSAContentSigner(AlgorithmIdentifier signatureAlgId)
  throws XiSecurityException, P11TokenException {
 if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(signatureAlgId.getAlgorithm())) {
  return new P11ContentSigner.RSAPSS(cryptService, identityId, signatureAlgId,
    securityFactory.getRandom4Sign());
 } else {
  return new P11ContentSigner.RSA(cryptService, identityId, signatureAlgId);
 }
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

private void init(SubjectPublicKeyInfo keyInfo)
  throws IOException
{
  XMSSMTKeyParams keyParams = XMSSMTKeyParams.getInstance(keyInfo.getAlgorithm().getParameters());
  this.treeDigest = keyParams.getTreeDigest().getAlgorithm();
  this.keyParams = (XMSSMTPublicKeyParameters)PublicKeyFactory.createKey(keyInfo);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

private void init(SubjectPublicKeyInfo keyInfo)
  throws IOException
{
  this.treeDigest = SPHINCS256KeyParams.getInstance(keyInfo.getAlgorithm().getParameters()).getTreeDigest().getAlgorithm();
  this.params = (SPHINCSPublicKeyParameters)PublicKeyFactory.createKey(keyInfo);
}

代码示例来源:origin: RUB-NDS/TLS-Attacker

public static boolean hasDHParameters(Certificate cert) {
  if (cert.isEmpty()) {
    return false;
  }
  SubjectPublicKeyInfo keyInfo = cert.getCertificateAt(0).getSubjectPublicKeyInfo();
  return keyInfo.getAlgorithm().getAlgorithm().equals(X9ObjectIdentifiers.dhpublicnumber);
}

代码示例来源:origin: RUB-NDS/TLS-Attacker

public static boolean hasGOSTParameters(Certificate cert) {
  if (cert.isEmpty()) {
    return false;
  }
  SubjectPublicKeyInfo keyInfo = cert.getCertificateAt(0).getSubjectPublicKeyInfo();
  return keyInfo.getAlgorithm().getAlgorithm().equals(CryptoProObjectIdentifiers.gostR3410_94);
}

代码示例来源:origin: org.xipki/security

public static boolean isPlainECDSASigAlg(AlgorithmIdentifier algId) {
 ASN1ObjectIdentifier oid = Args.notNull(algId, "algId").getAlgorithm();
 if (BSIObjectIdentifiers.ecdsa_plain_SHA1.equals(oid)
   || BSIObjectIdentifiers.ecdsa_plain_SHA224.equals(oid)
   || BSIObjectIdentifiers.ecdsa_plain_SHA256.equals(oid)
   || BSIObjectIdentifiers.ecdsa_plain_SHA384.equals(oid)
   || BSIObjectIdentifiers.ecdsa_plain_SHA512.equals(oid)) {
  return true;
 }
 return false;
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

private void init(PrivateKeyInfo keyInfo)
  throws IOException
{
  this.attributes = keyInfo.getAttributes();
  XMSSKeyParams keyParams = XMSSKeyParams.getInstance(keyInfo.getPrivateKeyAlgorithm().getParameters());
  this.treeDigest = keyParams.getTreeDigest().getAlgorithm();
  this.keyParams = (XMSSPrivateKeyParameters)PrivateKeyFactory.createKey(keyInfo);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

private void init(PrivateKeyInfo keyInfo)
  throws IOException
{
  this.attributes = keyInfo.getAttributes();
  XMSSMTKeyParams keyParams = XMSSMTKeyParams.getInstance(keyInfo.getPrivateKeyAlgorithm().getParameters());
  this.treeDigest = keyParams.getTreeDigest().getAlgorithm();
  this.keyParams = (XMSSMTPrivateKeyParameters)PrivateKeyFactory.createKey(keyInfo);
}

代码示例来源:origin: RUB-NDS/TLS-Attacker

public static boolean hasGost12EcParameters(Certificate cert) {
  if (cert.isEmpty()) {
    return false;
  }
  SubjectPublicKeyInfo keyInfo = cert.getCertificateAt(0).getSubjectPublicKeyInfo();
  ASN1ObjectIdentifier alg = keyInfo.getAlgorithm().getAlgorithm();
  return alg.equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_256)
      || alg.equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_512);
}

代码示例来源:origin: org.xipki.tk/security

protected Signer createSigner(final AlgorithmIdentifier sigAlgId,
    final AlgorithmIdentifier digAlgId) throws OperatorCreationException {
  if (!AlgorithmUtil.isDSASigAlg(sigAlgId)) {
    throw new OperatorCreationException(
        "the given algorithm is not a valid DSA signature algirthm '"
        + sigAlgId.getAlgorithm().getId() + "'");
  }
  Digest dig = digestProvider.get(digAlgId);
  DSASigner dsaSigner = new DSASigner();
  return plain ? new DSAPlainDigestSigner(dsaSigner, dig)
      : new DSADigestSigner(dsaSigner, dig);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

private void populateFromPubKeyInfo(SubjectPublicKeyInfo keyInfo)
{
  if (EdECObjectIdentifiers.id_X448.equals(keyInfo.getAlgorithm().getAlgorithm()))
  {
    xdhPublicKey = new X448PublicKeyParameters(keyInfo.getPublicKeyData().getOctets(), 0);
  }
  else
  {
    xdhPublicKey = new X25519PublicKeyParameters(keyInfo.getPublicKeyData().getOctets(), 0);
  }
}

相关文章