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

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

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

AlgorithmIdentifier.<init>介绍

暂无

代码示例

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

@Override
public AlgorithmIdentifier getAlgorithmIdentifier()
{
  return new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1);
}

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

/**
 * Returns a {@link PEMKeyPair} object with direct access to the public and private keys given a PKCS #8 private key.
 *
 * @param privateKeyInfo the PKCS #8 private key info
 * @return the PKCS #1 public and private key pair
 * @throws IOException if there is an error converting the key pair
 */
private static PEMKeyPair convertPrivateKeyFromPKCS8ToPKCS1(PrivateKeyInfo privateKeyInfo) throws IOException {
  // Parse the key wrapping to determine the internal key structure
  ASN1Encodable asn1PrivateKey = privateKeyInfo.parsePrivateKey();
  // Convert the parsed key to an RSA private key
  RSAPrivateKey keyStruct = RSAPrivateKey.getInstance(asn1PrivateKey);
  // Create the RSA public key from the modulus and exponent
  RSAPublicKey pubSpec = new RSAPublicKey(
    keyStruct.getModulus(), keyStruct.getPublicExponent());
  // Create an algorithm identifier for forming the key pair
  AlgorithmIdentifier algId = new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE);
  if (isVerbose()) {
    logger.info("Converted private key from PKCS #8 to PKCS #1 RSA private key");
  }
  // Create the key pair container
  return new PEMKeyPair(new SubjectPublicKeyInfo(algId, pubSpec), new PrivateKeyInfo(algId, keyStruct));
}

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

DERSet set = new DERSet(new RecipientInfo(recipientInfo));
AlgorithmIdentifier algorithmId = new AlgorithmIdentifier(new ASN1ObjectIdentifier(algorithm), object);
EncryptedContentInfo encryptedInfo = 
    new EncryptedContentInfo(PKCSObjectIdentifiers.data, algorithmId, new DEROctetString(bytes));

代码示例来源:origin: org.xipki/ca-api

public RSAKeypairGenControl(int keysize, BigInteger publicExponent,
  ASN1ObjectIdentifier keyAlgorithmOid) {
 if (keysize < 1024 || keysize % 512 != 0) {
  throw new IllegalArgumentException("invalid keysize " + keysize);
 }
 this.keysize = keysize;
 this.publicExponent = (publicExponent != null) ? publicExponent
   : BigInteger.valueOf(0x10001);
 this.keyAlgorithm = new AlgorithmIdentifier(
   (keyAlgorithmOid != null) ? keyAlgorithmOid : PKCSObjectIdentifiers.rsaEncryption,
   DERNull.INSTANCE);
}

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

private static AlgorithmIdentifier getDSASigAlgId(HashAlgo hashAlgo)
  throws NoSuchAlgorithmException {
 Args.notNull(hashAlgo, "hashAlgo");
 ASN1ObjectIdentifier sigAlgOid  = digestToDSASigAlgMap.get(hashAlgo);
 if (sigAlgOid == null) {
  throw new NoSuchAlgorithmException("unsupported hash " + hashAlgo + " for DSA key");
 }
 return new AlgorithmIdentifier(sigAlgOid);
} // method getDSASigAlgId

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

public static AlgorithmIdentifier buildRSAPSSAlgId(final HashAlgoType digestAlg)
    throws NoSuchAlgorithmException {
  RSASSAPSSparams params = createPSSRSAParams(digestAlg);
  return new AlgorithmIdentifier(PKCSObjectIdentifiers.id_RSASSA_PSS, params);
}

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

@Override
public AlgorithmIdentifier getAlgorithmIdentifier() {
 GCMParameters params = new GCMParameters(nonce, tagByteLen);
 return new AlgorithmIdentifier(oid, params);
}

代码示例来源:origin: org.xipki/ca-api

public ECKeypairGenControl(ASN1ObjectIdentifier curveOid,
  ASN1ObjectIdentifier keyAlgorithmOid) {
 this.curveOid = Args.notNull(curveOid, "curveOid");
 this.keyAlgorithm = new AlgorithmIdentifier(
   (keyAlgorithmOid != null) ? keyAlgorithmOid : X9ObjectIdentifiers.id_ecPublicKey,
    curveOid);
}

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

public AlgorithmIdentifier getHashAlgorithm()
{
  if (null == this.otherHash)
  {
    return new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1);
  }
  return this.otherHash.getHashAlgorithm();
}

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

public static AlgorithmIdentifier getMacAlgId(String macAlgName) throws NoSuchAlgorithmException {
 String algoS = Args.notNull(macAlgName, "macAlgName").toUpperCase();
 algoS = canonicalizeAlgoText(algoS);
 ASN1ObjectIdentifier oid = macAlgNameToOidMap.get(algoS);
 if (oid == null) {
  throw new NoSuchAlgorithmException("unsupported MAC algorithm " + algoS);
 }
 return new AlgorithmIdentifier(oid, DERNull.INSTANCE);
} // method getMacAlgId

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

private static AlgorithmIdentifier getRSASigAlgId(HashAlgo hashAlgo, boolean mgf1)
  throws NoSuchAlgorithmException {
 Args.notNull(hashAlgo, "hashAlgo");
 if (mgf1) {
  return buildRSAPSSAlgId(hashAlgo);
 }
 ASN1ObjectIdentifier sigAlgOid = digestToRSASigAlgMap.get(hashAlgo);
 if (sigAlgOid == null) {
  throw new NoSuchAlgorithmException("unsupported hash " + hashAlgo + " for RSA key");
 }
 return new AlgorithmIdentifier(sigAlgOid, DERNull.INSTANCE);
} // method getRSASigAlgId

代码示例来源:origin: org.apache.camel/camel-crypto-cms

private AlgorithmIdentifier determineKeyEncryptionAlgorithmIdentifier(String keyEncryptionAlgorithm, TransRecipientInfo keyTransRecipient) throws CryptoCmsException {

    if (keyEncryptionAlgorithm == null) {
      throw new CryptoCmsException("Key encryption algorithm  of recipient info '" + keyTransRecipient + "' is missing");
    }
    if ("RSA".equals(keyEncryptionAlgorithm)) {
      return new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption);
    }
    throw new CryptoCmsException("Key encryption algorithm '" + keyEncryptionAlgorithm + "' of recipient info '" + keyTransRecipient + "' is not supported");
  }
}

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

private KeyPairWithSubjectPublicKeyInfo genRSAKeypair(final int keysize,
    final BigInteger publicExponent, final SecureRandom random) throws Exception {
  KeyPair kp = KeyUtil.generateRSAKeypair(keysize, publicExponent, random);
  java.security.interfaces.RSAPublicKey rsaPubKey =
      (java.security.interfaces.RSAPublicKey) kp.getPublic();
  SubjectPublicKeyInfo spki = new SubjectPublicKeyInfo(
      new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE),
      new RSAPublicKey(rsaPubKey.getModulus(), rsaPubKey.getPublicExponent()));
  return new KeyPairWithSubjectPublicKeyInfo(kp, spki);
}

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

private static RSASSAPSSparams createPSSRSAParams(HashAlgo digestAlg)
  throws NoSuchAlgorithmException {
 int saltSize = Args.notNull(digestAlg, "digestAlg").getLength();
 AlgorithmIdentifier digAlgId = new AlgorithmIdentifier(digestAlg.getOid(), DERNull.INSTANCE);
 return new RSASSAPSSparams(digAlgId,
   new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, digAlgId),
   new ASN1Integer(saltSize), RSASSAPSSparams.DEFAULT_TRAILER_FIELD);
} // method createPSSRSAParams

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

private HashAlgo(int length, AlgorithmCode algorithmCode, String oid, String name) {
 this.length = length;
 this.algorithmCode = algorithmCode;
 this.oid = new ASN1ObjectIdentifier(oid).intern();
 this.algId = new AlgorithmIdentifier(this.oid, DERNull.INSTANCE);
 this.name = name;
 try {
  this.encoded = new ASN1ObjectIdentifier(oid).getEncoded();
 } catch (IOException ex) {
  throw new IllegalArgumentException("invalid oid: " + oid);
 }
}

代码示例来源:origin: org.xipki/ca-api

public DSAKeypairGenControl(BigInteger p, BigInteger q, BigInteger g,
  ASN1ObjectIdentifier keyAlgorithmOid) {
 this.parameterSpec = new DSAParameterSpec(p, q, g);
 this.keyAlgorithm = new AlgorithmIdentifier(
   (keyAlgorithmOid != null) ? keyAlgorithmOid : X9ObjectIdentifiers.id_dsa,
   new DSAParameter(p, q, g));
}

代码示例来源:origin: itext/itext7

static CertificateID generateCertificateId(X509Certificate issuerCert, BigInteger serialNumber, ASN1ObjectIdentifier identifier) throws OperatorCreationException, CertificateEncodingException, OCSPException {
  return new CertificateID(
      new JcaDigestCalculatorProviderBuilder().build().get(new AlgorithmIdentifier(identifier, DERNull.INSTANCE)),
      new JcaX509CertificateHolder(issuerCert), serialNumber);
}

代码示例来源:origin: com.itextpdf/sign

static CertificateID generateCertificateId(X509Certificate issuerCert, BigInteger serialNumber, ASN1ObjectIdentifier identifier) throws OperatorCreationException, CertificateEncodingException, OCSPException {
  return new CertificateID(
      new JcaDigestCalculatorProviderBuilder().build().get(new AlgorithmIdentifier(identifier, DERNull.INSTANCE)),
      new JcaX509CertificateHolder(issuerCert), serialNumber);
}

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

/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
  return KeyUtil.getEncodedPrivateKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG())), new ASN1Integer(getX()));
}

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

/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
  return KeyUtil.getEncodedPrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPrivateKey(getModulus(), getPublicExponent(), getPrivateExponent(), getPrimeP(), getPrimeQ(), getPrimeExponentP(), getPrimeExponentQ(), getCrtCoefficient()));
}

相关文章