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

x33g5p2x  于2022-01-16 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(184)

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

ASN1Primitive.fromByteArray介绍

[英]Create a base ASN.1 object from a byte stream.
[中]创建一个基本ASN。字节流中的1个对象。

代码示例

代码示例来源:origin: eu.eu-emi.security/canl

/**
 * Generates a new ProxyACExtension object form the byte array
 * 
 * @param bytes bytes
 * @throws IOException IO exception
 */
public ProxyACExtension(byte[] bytes) throws IOException
{
  ac = (DLSequence) ASN1Primitive.fromByteArray(bytes);
}

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

/**
 * @deprecated use org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils.parseExtensionValue()
 */
public static ASN1Primitive fromExtensionValue(
  byte[]  encodedValue) 
  throws IOException
{
  ASN1OctetString octs = (ASN1OctetString)ASN1Primitive.fromByteArray(encodedValue);
  
  return ASN1Primitive.fromByteArray(octs.getOctets());
}

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

ASN1ObjectIdentifier oid = PKCSObjectIdentifiers.id_aa_signatureTimeStampToken;
ASN1Encodable signatureTimeStamp = new Attribute(oid,
    new DERSet(ASN1Primitive.fromByteArray(token)));

代码示例来源:origin: esig/dss

private ASN1Primitive rebuildASN1Primitive(int tagNo, byte[] array) throws IOException {
  try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
    baos.write(tagNo);
    DERUtil.writeLength(baos, array.length);
    baos.write(array);
    return ASN1Primitive.fromByteArray(baos.toByteArray());
  }
}

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

/**
 * Return the enclosed object assuming explicit tagging.
 *
 * @return  the resulting object
 * @throws IOException if reconstruction fails.
 */
public ASN1Primitive getObject()
  throws IOException 
{
  return ASN1Primitive.fromByteArray(getContents());
}

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

private ASN1Primitive decodeObject(String oValue)
{
  try
  {
    return ASN1Primitive.fromByteArray(Hex.decode(oValue.substring(1)));
  }
  catch (IOException e)
  {
    throw new IllegalStateException("unknown encoding in name: " + e);
  }
}

代码示例来源:origin: org.xipki.pki/ca-certprofile-xml

private static ASN1Primitive asn1PrimitivefromByteArray(final byte[] encoded)
    throws CertprofileException {
  try {
    return ASN1Primitive.fromByteArray(encoded);
  } catch (IOException ex) {
    throw new CertprofileException(ex.getMessage(), ex);
  }
}

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

private ASN1Primitive decodeObject(String oValue)
{
  try
  {
    return ASN1Primitive.fromByteArray(Hex.decode(oValue.substring(1)));
  }
  catch (IOException e)
  {
    throw new IllegalStateException("unknown encoding in name: " + e);
  }
}

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

public ASN1Encodable parsePrivateKey()
  throws IOException
{
  return ASN1Primitive.fromByteArray(privateKey.getOctets());
}

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

private void readObject(
  ObjectInputStream in)
  throws IOException, ClassNotFoundException
{
  byte[] enc = (byte[])in.readObject();
  populateFromPubKeyInfo(SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(enc)));
  this.algorithm = (String)in.readObject();
  this.withCompression = in.readBoolean();
}

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

private String getBitString(byte[] octets) throws IOException {
  if (octets == null) {
    return "";
  }
  DERBitString derBitString = DERBitString.getInstance(ASN1Primitive.fromByteArray(octets));
  byte[] bitStringBytes = derBitString.getBytes();
  return new BigInteger(1, bitStringBytes).toString(2);
}

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

/**
 * Create a private key parameter from a PKCS8 PrivateKeyInfo encoding.
 *
 * @param privateKeyInfoData the PrivateKeyInfo encoding
 * @return a suitable private key parameter
 * @throws IOException on an error decoding the key
 */
public static AsymmetricKeyParameter createKey(byte[] privateKeyInfoData)
  throws IOException
{
  return createKey(PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(privateKeyInfoData)));
}

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

private String getRestrictionStringValue(byte[] octets) throws IOException {
  /*	RestrictionSyntax ::= DirectoryString (SIZE(1..1024)) */
  return DirectoryString.getInstance(ASN1Primitive.fromByteArray(octets)).toString();
}

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

/**
 * Create a public key from a SubjectPublicKeyInfo encoding
 * 
 * @param keyInfoData the SubjectPublicKeyInfo encoding
 * @return the appropriate key parameter
 * @throws IOException on an error decoding the key
 */
public static AsymmetricKeyParameter createKey(byte[] keyInfoData) throws IOException
{
  return createKey(SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(keyInfoData)));
}

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

/**
 * Create a private key parameter from a PKCS8 PrivateKeyInfo encoding.
 * 
 * @param privateKeyInfoData the PrivateKeyInfo encoding
 * @return a suitable private key parameter
 * @throws IOException on an error decoding the key
 */
public static AsymmetricKeyParameter createKey(byte[] privateKeyInfoData) throws IOException
{
  return createKey(PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(privateKeyInfoData)));
}

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

/**
 * Create a public key from a SubjectPublicKeyInfo encoding
 *
 * @param keyInfoData the SubjectPublicKeyInfo encoding
 * @return the appropriate key parameter
 * @throws IOException on an error decoding the key
 */
public static AsymmetricKeyParameter createKey(byte[] keyInfoData)
  throws IOException
{
  return createKey(SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(keyInfoData)));
}

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

/**
 * Create a public key from a SubjectPublicKeyInfo encoding
 *
 * @param keyInfoData the SubjectPublicKeyInfo encoding
 * @return the appropriate key parameter
 * @throws IOException on an error decoding the key
 */
public static AsymmetricKeyParameter createKey(byte[] keyInfoData)
  throws IOException
{
  return createKey(SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(keyInfoData)));
}

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

protected void engineInit(
  byte[] params,
  String format)
  throws IOException
{
  if (this.isASN1FormatString(format))
  {
    engineInit(params);
    return;
  }
  throw new IOException("Unknown parameters format in PBKDF2 parameters object");
}

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

private DERBitString getPublicKeyDetails(JCEECPublicKey   pub)
{
  try
  {
    SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(pub.getEncoded()));
    return info.getPublicKeyData();
  }
  catch (IOException e)
  {   // should never happen
    return null;
  }
}

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

private BigInteger[] derDecode(
    byte[] encoding)
    throws IOException
  {
    ASN1Sequence s = (ASN1Sequence)ASN1Primitive.fromByteArray(encoding);

    return new BigInteger[]
    {
      ((ASN1Integer)s.getObjectAt(0)).getValue(),
      ((ASN1Integer)s.getObjectAt(1)).getValue()
    };
  }
}

相关文章