org.spongycastle.asn1.ASN1Integer类的使用及代码示例

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

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

ASN1Integer介绍

[英]Class representing the ASN.1 INTEGER type.
[中]表示ASN的类。1整数类型。

代码示例

代码示例来源:origin: ethereum/ethereumj

public static ECDSASignature decodeFromDER(byte[] bytes) {
  ASN1InputStream decoder = null;
  try {
    decoder = new ASN1InputStream(bytes);
    DLSequence seq = (DLSequence) decoder.readObject();
    if (seq == null)
      throw new RuntimeException("Reached past end of ASN.1 stream.");
    ASN1Integer r, s;
    try {
      r = (ASN1Integer) seq.getObjectAt(0);
      s = (ASN1Integer) seq.getObjectAt(1);
    } catch (ClassCastException e) {
      throw new IllegalArgumentException(e);
    }
    // OpenSSL deviates from the DER spec by interpreting these values as unsigned, though they should not be
    // Thus, we always use the positive versions. See: http://r6.ca/blog/20111119T211504Z.html
    return new ECDSASignature(r.getPositiveValue(), s.getPositiveValue());
  } catch (IOException e) {
    throw new RuntimeException(e);
  } finally {
    if (decoder != null)
      try { decoder.close(); } catch (IOException x) {}
  }
}

代码示例来源:origin: com.madgag.spongycastle/core

public KeyAgreeRecipientInfo(
  OriginatorIdentifierOrKey   originator,
  ASN1OctetString             ukm,
  AlgorithmIdentifier         keyEncryptionAlgorithm,
  ASN1Sequence                recipientEncryptedKeys)
{
  this.version = new ASN1Integer(3);
  this.originator = originator;
  this.ukm = ukm;
  this.keyEncryptionAlgorithm = keyEncryptionAlgorithm;
  this.recipientEncryptedKeys = recipientEncryptedKeys;
}

代码示例来源:origin: com.madgag.spongycastle/core

public BigInteger getAuthorityCertSerialNumber()
{
  if (certserno != null)
  {
    return certserno.getValue();
  }
  
  return null;
}

代码示例来源:origin: com.madgag.spongycastle/core

/**
 * @return notYoungerThan if that's what we are, -1 otherwise
 */
public int notYoungerThan()
{
  if (declaration.getTagNo() != 0)
  {
    return -1;
  }
  return ASN1Integer.getInstance(declaration, false).getValue().intValue();
}

代码示例来源:origin: com.madgag.spongycastle/core

private RSAPublicKey(
  ASN1Sequence seq)
{
  if (seq.size() != 2)
  {
    throw new IllegalArgumentException("Bad sequence size: "
        + seq.size());
  }
  Enumeration e = seq.getObjects();
  modulus = ASN1Integer.getInstance(e.nextElement()).getPositiveValue();
  publicExponent = ASN1Integer.getInstance(e.nextElement()).getPositiveValue();
}

代码示例来源:origin: com.madgag/sc-light-jdk15on

public AuthEnvelopedDataParser(ASN1SequenceParser seq) throws IOException
{
  this.seq = seq;
  // TODO
  // "It MUST be set to 0."
  this.version = ASN1Integer.getInstance(seq.readObject());
}

代码示例来源:origin: com.madgag.spongycastle/core

public AuthEnvelopedDataParser(ASN1SequenceParser seq) throws IOException
{
  this.seq = seq;
  // "It MUST be set to 0."
  this.version = ASN1Integer.getInstance(seq.readObject());
  if (this.version.getValue().intValue() != 0)
  {
    throw new ASN1ParsingException("AuthEnvelopedData version number must be 0");
  }
}

代码示例来源:origin: com.madgag.spongycastle/core

public RSAPublicKeyStructure(
  ASN1Sequence  seq)
{
  if (seq.size() != 2)
  {
    throw new IllegalArgumentException("Bad sequence size: "
        + seq.size());
  }
  Enumeration e = seq.getObjects();
  modulus = ASN1Integer.getInstance(e.nextElement()).getPositiveValue();
  publicExponent = ASN1Integer.getInstance(e.nextElement()).getPositiveValue();
}

代码示例来源:origin: com.madgag.spongycastle/core

/**
 * @param status
 */
public PKIStatusInfo(PKIStatus status)
{
  this.status = ASN1Integer.getInstance(status.toASN1Primitive());
}

代码示例来源:origin: com.madgag.spongycastle/core

public SPHINCS256KeyParams(AlgorithmIdentifier treeDigest)
{
  this.version = new ASN1Integer(0);
  this.treeDigest = treeDigest;
}

代码示例来源:origin: com.madgag.spongycastle/core

/**
 * Return the public value Y for the key.
 *
 * @return the Y value.
 */
public BigInteger getY()
{
  return this.y.getPositiveValue();
}

代码示例来源:origin: com.madgag.spongycastle/core

public BigInteger getMinimum()
{
  if (minimum == null)
  {
    return ZERO;
  }
  return minimum.getValue();
}

代码示例来源:origin: com.madgag.spongycastle/core

private XMSSMTKeyParams(ASN1Sequence sequence)
{
  this.version = ASN1Integer.getInstance(sequence.getObjectAt(0));
  this.height = ASN1Integer.getInstance(sequence.getObjectAt(1)).getValue().intValue();
  this.layers = ASN1Integer.getInstance(sequence.getObjectAt(2)).getValue().intValue();
  this.treeDigest = AlgorithmIdentifier.getInstance(sequence.getObjectAt(3));
}

代码示例来源:origin: com.madgag/sc-light-jdk15on

private RSAPublicKey(
  ASN1Sequence seq)
{
  if (seq.size() != 2)
  {
    throw new IllegalArgumentException("Bad sequence size: "
        + seq.size());
  }
  Enumeration e = seq.getObjects();
  modulus = ASN1Integer.getInstance(e.nextElement()).getPositiveValue();
  publicExponent = ASN1Integer.getInstance(e.nextElement()).getPositiveValue();
}

代码示例来源:origin: com.madgag.spongycastle/core

private DSAParameter(
  ASN1Sequence  seq)
{
  if (seq.size() != 3)
  {
    throw new IllegalArgumentException("Bad sequence size: " + seq.size());
  }
  
  Enumeration     e = seq.getObjects();
  p = ASN1Integer.getInstance(e.nextElement());
  q = ASN1Integer.getInstance(e.nextElement());
  g = ASN1Integer.getInstance(e.nextElement());
}

代码示例来源:origin: com.madgag.spongycastle/core

public CertRequest(
  ASN1Integer certReqId,
  CertTemplate certTemplate,
  Controls controls)
{
  this.certReqId = certReqId;
  this.certTemplate = certTemplate;
  this.controls = controls;
}

代码示例来源:origin: com.madgag.spongycastle/core

/**
 * Return q, the prime factor of p - 1
 *
 * @return q value
 */
public BigInteger getQ()
{
  return this.q.getPositiveValue();
}

代码示例来源:origin: com.madgag/sc-light-jdk15on

public BigInteger getAuthorityCertSerialNumber()
{
  if (certserno != null)
  {
    return certserno.getValue();
  }
  
  return null;
}

代码示例来源:origin: com.madgag.spongycastle/core

private XMSSKeyParams(ASN1Sequence sequence)
{
  this.version = ASN1Integer.getInstance(sequence.getObjectAt(0));
  this.height = ASN1Integer.getInstance(sequence.getObjectAt(1)).getValue().intValue();
  this.treeDigest = AlgorithmIdentifier.getInstance(sequence.getObjectAt(2));
}

代码示例来源:origin: com.madgag.spongycastle/core

public AuthenticatedDataParser(
  ASN1SequenceParser seq)
  throws IOException
{
  this.seq = seq;
  this.version = ASN1Integer.getInstance(seq.readObject());
}

相关文章