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

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

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

ASN1OctetString.getInstance介绍

[英]return an Octet String from the given object.
[中]从给定对象返回八位字节字符串。

代码示例

代码示例来源:origin: hyperledger/fabric-sdk-java

private AuthorityKeyIdentifier getAKI() throws HFCACertificateException {
    if (x509Cert == null) {
      throw new HFCACertificateException("Certificate is null");
    }
    byte[] fullExtValue = x509Cert.getExtensionValue(Extension.authorityKeyIdentifier.getId());
    byte[] extValue = ASN1OctetString.getInstance(fullExtValue).getOctets();
    return AuthorityKeyIdentifier.getInstance(extValue);
  }
}

代码示例来源:origin: hyperledger/fabric-sdk-java

ASN1OctetString akiOc = ASN1OctetString.getInstance(extensionValue);
String aki = DatatypeConverter.printHexBinary(AuthorityKeyIdentifier.getInstance(akiOc.getOctets()).getKeyIdentifier());

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

/**
 * Gets a String from an ASN1Primitive
 * @param names    the ASN1Primitive
 * @return    a human-readable String
 * @throws IOException
 */
private static String getStringFromGeneralName(ASN1Primitive names) throws IOException {
  ASN1TaggedObject taggedObject = (ASN1TaggedObject) names ;
  return new String(ASN1OctetString.getInstance(taggedObject, false).getOctets(), "ISO-8859-1");
}

代码示例来源:origin: com.github.librepdf/openpdf

private static String getStringFromGeneralName(ASN1Primitive names)
  throws IOException {
 DERTaggedObject taggedObject = (DERTaggedObject) names;
 return new String(ASN1OctetString.getInstance(taggedObject, false)
   .getOctets(), StandardCharsets.ISO_8859_1);
}

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

/**
 * Gets a String from an ASN1Primitive
 * @param names    the ASN1Primitive
 * @return    a human-readable String
 * @throws IOException
 */
private static String getStringFromGeneralName(ASN1Primitive names) throws IOException {
  ASN1TaggedObject taggedObject = (ASN1TaggedObject) names ;
  return new String(ASN1OctetString.getInstance(taggedObject, false).getOctets(), "ISO-8859-1");
}

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

public static ContentIdentifier getInstance(Object o)
{
  if (o instanceof ContentIdentifier)
  {
    return (ContentIdentifier) o;
  }
  else if (o != null)
  {
    return new ContentIdentifier(ASN1OctetString.getInstance(o));
  }
  return null;
}

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

private static byte[] getRawKey(PrivateKeyInfo keyInfo, int expectedSize)
    throws IOException
  {
    byte[] result = ASN1OctetString.getInstance(keyInfo.parsePrivateKey()).getOctets();
    if (expectedSize != result.length)
    {
      throw new RuntimeException("private key encoding has incorrect length");
    }
    return result;
  }
}

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

private UnsignedInteger(ASN1TaggedObject obj)
{
  this.tagNo = obj.getTagNo();
  this.value = new BigInteger(1, ASN1OctetString.getInstance(obj, false).getOctets());
}

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

public ASN1OctetString getMac()
  throws IOException
{
  if (nextObject == null)
  {
    nextObject = seq.readObject();
  }
  ASN1Encodable o = nextObject;
  nextObject = null;
  return ASN1OctetString.getInstance(o.toASN1Primitive());
}

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

public ASN1OctetString getMac()
  throws IOException
{
  if (nextObject == null)
  {
    nextObject = seq.readObject();
  }
  ASN1Encodable o = nextObject;
  nextObject = null;
  return ASN1OctetString.getInstance(o.toASN1Primitive());
}

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

private SecretKeyData(ASN1Sequence seq)
{
  this.keyAlgorithm = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0));
  this.keyBytes = ASN1OctetString.getInstance(seq.getObjectAt(1));
}

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

private EncryptedSecretKeyData(ASN1Sequence seq)
{
  this.keyEncryptionAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(0));
  this.encryptedKeyData = ASN1OctetString.getInstance(seq.getObjectAt(1));
}

代码示例来源:origin: kaikramer/keystore-explorer

private ASN1Encodable getExtensionValue(X509Extension extensions, String oid) throws CryptoException {
    byte[] octets = ASN1OctetString.getInstance(extensions.getExtensionValue(oid)).getOctets();
    try (ASN1InputStream ais = new ASN1InputStream(octets)) {
      return ais.readObject();
    } catch (IOException ex) {
      throw new CryptoException(res.getString("CertificateGenFailed.exception.message"), ex);
    }
  }
}

代码示例来源:origin: be.fedict.eid-applet/eid-applet-service-signer

private byte[] getSubjectKeyId(X509Certificate cert) throws IOException {
  byte[] extvalue = cert.getExtensionValue(X509Extensions.SubjectKeyIdentifier.getId());
  if (extvalue == null) {
    return null;
  }
  ASN1OctetString str = ASN1OctetString
      .getInstance(new ASN1InputStream(new ByteArrayInputStream(extvalue)).readObject());
  SubjectKeyIdentifier keyId = SubjectKeyIdentifier
      .getInstance(new ASN1InputStream(new ByteArrayInputStream(str.getOctets())).readObject());
  return keyId.getKeyIdentifier();
}

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

public static byte[] getSubjectKeyIdentifierBytes(X509Certificate cert) {
  byte[] extensionValue = cert.getExtensionValue("2.5.29.14"); //NOPMD
  if (extensionValue != null) {
    byte[] subjectOctets =
      ASN1OctetString.getInstance(extensionValue).getOctets();
    SubjectKeyIdentifier subjectKeyIdentifier =
      SubjectKeyIdentifier.getInstance(subjectOctets);
    return subjectKeyIdentifier.getKeyIdentifier();
  }
  return null;
}

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

private MessageImprint(
  ASN1Sequence seq)
{
  this.hashAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(0));
  this.hashedMessage = ASN1OctetString.getInstance(seq.getObjectAt(1)).getOctets();
}

代码示例来源:origin: org.xipki.p11proxy/p11proxy-common

private Asn1ImportSecretKeyParams(ASN1Sequence seq) throws BadAsn1ObjectException {
 Asn1Util.requireRange(seq, 4, 4);
 int idx = 0;
 slotId = Asn1P11SlotIdentifier.getInstance(seq.getObjectAt(idx++)).getValue();
 control = Asn1NewKeyControl.getInstance(seq.getObjectAt(idx++)).getControl();
 keyType = Asn1Util.getInteger(seq.getObjectAt(idx++)).longValue();
 keyValue = ASN1OctetString.getInstance(seq.getObjectAt(idx++)).getOctets();
}

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

private EncryptedPOP(ASN1Sequence seq)
{
  if (seq.size() != 5)
  {
    throw new IllegalArgumentException("incorrect sequence size");
  }
  this.request = TaggedRequest.getInstance(seq.getObjectAt(0));
  this.cms = ContentInfo.getInstance(seq.getObjectAt(1));
  this.thePOPAlgID = AlgorithmIdentifier.getInstance(seq.getObjectAt(2));
  this.witnessAlgID = AlgorithmIdentifier.getInstance(seq.getObjectAt(3));
  this.witness = Arrays.clone(ASN1OctetString.getInstance(seq.getObjectAt(4)).getOctets());
}

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

public byte[] getEncoded()
{
  ASN1Encodable   params = ECUtils.getDomainParametersFromName(ecSpec, withCompression);
  ASN1OctetString p = ASN1OctetString.getInstance(new X9ECPoint(ecPublicKey.getQ(), withCompression).toASN1Primitive());
  // stored curve is null if ImplicitlyCa
  SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, params), p.getOctets());
  return KeyUtil.getEncodedSubjectPublicKeyInfo(info);
}

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

private ObjectData(ASN1Sequence seq)
{
  this.type = ASN1Integer.getInstance(seq.getObjectAt(0)).getValue();
  this.identifier = DERUTF8String.getInstance(seq.getObjectAt(1)).getString();
  this.creationDate = ASN1GeneralizedTime.getInstance(seq.getObjectAt(2));
  this.lastModifiedDate = ASN1GeneralizedTime.getInstance(seq.getObjectAt(3));
  this.data = ASN1OctetString.getInstance(seq.getObjectAt(4));
  this.comment = (seq.size() == 6) ? DERUTF8String.getInstance(seq.getObjectAt(5)).getString() : null;
}

相关文章