org.bouncycastle.asn1.ASN1ObjectIdentifier.getEncoded()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(145)

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

ASN1ObjectIdentifier.getEncoded介绍

暂无

代码示例

代码示例来源:origin: horrorho/InflatableDonkey

public static byte[] formatOid(ASN1ObjectIdentifier oid) {
    try {
      byte[] encodedOid = oid.getEncoded();
      byte[] formattedOid = new byte[encodedOid.length - 1];
      System.arraycopy(encodedOid, 1, formattedOid, 0, formattedOid.length);
      return formattedOid;

    } catch (IOException ex) {
      throw new IllegalArgumentException("format OID failed", ex);
    }
  }
}

代码示例来源:origin: redfish64/TinyTravelTracker

void encode(ASN1OutputStream out)
  throws IOException
{
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  if (directReference != null)
  {
    baos.write(directReference.getEncoded(ASN1Encoding.DER));
  }
  if (indirectReference != null)
  {
    baos.write(indirectReference.getEncoded(ASN1Encoding.DER));
  }
  if (dataValueDescriptor != null)
  {
    baos.write(dataValueDescriptor.getEncoded(ASN1Encoding.DER));
  }
  DERTaggedObject obj = new DERTaggedObject(true, encoding, externalContent);
  baos.write(obj.getEncoded(ASN1Encoding.DER));
  out.writeEncoded(BERTags.CONSTRUCTED, BERTags.EXTERNAL, baos.toByteArray());
}

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

void encode(ASN1OutputStream out)
    throws IOException
  {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    if (directReference != null)
    {
      baos.write(directReference.getEncoded(ASN1Encoding.DL));
    }
    if (indirectReference != null)
    {
      baos.write(indirectReference.getEncoded(ASN1Encoding.DL));
    }
    if (dataValueDescriptor != null)
    {
      baos.write(dataValueDescriptor.getEncoded(ASN1Encoding.DL));
    }
    DERTaggedObject obj = new DERTaggedObject(true, encoding, externalContent);
    baos.write(obj.getEncoded(ASN1Encoding.DL));
    out.writeEncoded(BERTags.CONSTRUCTED, BERTags.EXTERNAL, baos.toByteArray());
  }
}

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

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

代码示例来源: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.bouncycastle/bcprov-debug-jdk15on

void encode(ASN1OutputStream out)
    throws IOException
  {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    if (directReference != null)
    {
      baos.write(directReference.getEncoded(ASN1Encoding.DER));
    }
    if (indirectReference != null)
    {
      baos.write(indirectReference.getEncoded(ASN1Encoding.DER));
    }
    if (dataValueDescriptor != null)
    {
      baos.write(dataValueDescriptor.getEncoded(ASN1Encoding.DER));
    }
    DERTaggedObject obj = new DERTaggedObject(true, encoding, externalContent);
    baos.write(obj.getEncoded(ASN1Encoding.DER));
    out.writeEncoded(BERTags.CONSTRUCTED, BERTags.EXTERNAL, baos.toByteArray());
  }
}

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

try {
 if (namedCurveSupported) {
  encodedParams = curveOid.getEncoded();
 } else {
  encodedParams = ECNamedCurveTable.getByOID(curveOid).getEncoded();

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

try {
  if (namedCurveSupported) {
    encodedParams = curveOid.getEncoded();
  } else {
    encodedParams = ECNamedCurveTable.getByOID(curveOid).getEncoded();

代码示例来源:origin: poreid/poreid

private OCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws CertificateEncodingException, OperatorCreationException, OCSPException, IOException {
  Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
  OCSPReqBuilder gen = new OCSPReqBuilder();
  gen.addRequest(new JcaCertificateID(new JcaDigestCalculatorProviderBuilder().setProvider("BC").build().get(CertificateID.HASH_SHA1), issuerCert, serialNumber));
  BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());
  Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, true, new DEROctetString(nonce.toByteArray()));
  gen.setRequestExtensions(new Extensions(new Extension[]{ext}));
  sentNonce = ext.getExtnId().getEncoded();
  return gen.build();
}

代码示例来源:origin: arhs/sd-dss

/**
 * 1) The SignedData.encapContentInfo.eContentType.
 *
 * @param cmsSignedData
 * @return cmsSignedData.getSignedContentTypeOID() as DER encoded
 */
private byte[] getEncodedContentType(final CMSSignedData cmsSignedData) {
  final ContentInfo contentInfo = cmsSignedData.toASN1Structure();
  final SignedData signedData = SignedData.getInstance(contentInfo.getContent());
  try {
    return signedData.getEncapContentInfo().getContentType().getEncoded(ASN1Encoding.DER);
  } catch (IOException e) {
    throw new DSSException(e);
  }
}

代码示例来源:origin: airlift/airlift

@Test
  public void test()
      throws Exception
  {
    for (Entry<String, SignatureAlgorithmIdentifier> entry : SignatureAlgorithmIdentifier.getAllSignatureAlgorithmIdentifiers().entrySet()) {
      SignatureAlgorithmIdentifier signatureAlgorithmIdentifier = entry.getValue();
      assertEquals(signatureAlgorithmIdentifier.getName(), entry.getKey());

      AlgorithmIdentifier algorithmIdentifier = new DefaultSignatureAlgorithmIdentifierFinder().find(entry.getKey());
      assertEquals(
          signatureAlgorithmIdentifier.getOid(),
          algorithmIdentifier.getAlgorithm().getId());
      assertEquals(
          base16().encode(signatureAlgorithmIdentifier.getEncoded()),
          base16().encode(algorithmIdentifier.getAlgorithm().getEncoded("DER")));
      assertEquals(algorithmIdentifier, algorithmIdentifier);
      assertEquals(algorithmIdentifier.hashCode(), algorithmIdentifier.hashCode());
    }
  }
}

代码示例来源:origin: io.airlift/security

@Test
  public void test()
      throws Exception
  {
    for (Entry<String, SignatureAlgorithmIdentifier> entry : SignatureAlgorithmIdentifier.getAllSignatureAlgorithmIdentifiers().entrySet()) {
      SignatureAlgorithmIdentifier signatureAlgorithmIdentifier = entry.getValue();
      assertEquals(signatureAlgorithmIdentifier.getName(), entry.getKey());

      AlgorithmIdentifier algorithmIdentifier = new DefaultSignatureAlgorithmIdentifierFinder().find(entry.getKey());
      assertEquals(
          signatureAlgorithmIdentifier.getOid(),
          algorithmIdentifier.getAlgorithm().getId());
      assertEquals(
          base16().encode(signatureAlgorithmIdentifier.getEncoded()),
          base16().encode(algorithmIdentifier.getAlgorithm().getEncoded("DER")));
      assertEquals(algorithmIdentifier, algorithmIdentifier);
      assertEquals(algorithmIdentifier.hashCode(), algorithmIdentifier.hashCode());
    }
  }
}

代码示例来源:origin: poreid/poreid

BasicOCSPResp basicResponse = (BasicOCSPResp) ocspResponse.getResponseObject();                        
byte[] receivedNonce = basicResponse.getExtension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce).getExtnId().getEncoded();
if (!Arrays.equals(receivedNonce, sentNonce)) {
  throw new OCSPValidationException("Nonce na resposta ocsp não coincide com nonce do pedido ocsp");

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

@Override
protected P11Identity generateECKeypair0(final ASN1ObjectIdentifier curveId,
    final String label, P11NewKeyControl control) throws P11TokenException {
  ECDSAPrivateKey privateKey = new ECDSAPrivateKey();
  ECDSAPublicKey publicKey = new ECDSAPublicKey();
  setKeyAttributes(label, PKCS11Constants.CKK_EC, control, publicKey, privateKey);
  byte[] encodedCurveId;
  try {
    encodedCurveId = curveId.getEncoded();
  } catch (IOException ex) {
    throw new P11TokenException(ex.getMessage(), ex);
  }
  try {
    publicKey.getEcdsaParams().setByteArrayValue(encodedCurveId);
    return generateKeyPair(PKCS11Constants.CKM_EC_KEY_PAIR_GEN, privateKey, publicKey);
  } catch (P11TokenException ex) {
    X9ECParameters ecParams = ECNamedCurveTable.getByOID(curveId);
    if (ecParams == null) {
      throw new IllegalArgumentException("could not get X9ECParameters for curve "
          + curveId.getId());
    }
    try {
      publicKey.getEcdsaParams().setByteArrayValue(ecParams.getEncoded());
    } catch (IOException ex2) {
      throw new P11TokenException(ex.getMessage(), ex);
    }
    return generateKeyPair(PKCS11Constants.CKM_EC_KEY_PAIR_GEN, privateKey, publicKey);
  }
}

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

byte[] encodedCurveId;
try {
 encodedCurveId = curveId.getEncoded();
} catch (IOException ex) {
 throw new P11TokenException(ex.getMessage(), ex);

相关文章