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

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

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

AlgorithmIdentifier.getEncoded介绍

暂无

代码示例

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

@Override
public byte[] getEncoded() throws IOException {
  return super.getEncoded();
}

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

private void writeObject(
    ObjectOutputStream out)
    throws IOException
  {
    out.defaultWriteObject();

    if (!algorithmIdentifier.equals(DEFAULT_ALGORITHM_IDENTIFIER))
    {
      out.writeObject(algorithmIdentifier.getEncoded());
    }
  }
}

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

@Override
public byte[] getEncodedAlgorithmIdentifier() {
 if (encodedAlgorithmIdentifier != null) {
  return encodedAlgorithmIdentifier;
 }
 try {
  return signer.getAlgorithmIdentifier().getEncoded();
 } catch (IOException ex) {
  throw new IllegalStateException("error encoding AlgorithmIdentifier", ex);
 }
}

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

@Override
public byte[] getEncodedAlgorithmIdentifier() {
  if (encodedAlgorithmIdentifier != null) {
    return encodedAlgorithmIdentifier;
  }
  try {
    return signer.getAlgorithmIdentifier().getEncoded();
  } catch (IOException ex) {
    throw new RuntimeException("error encoding AlgorithmIdentifier", ex);
  }
}

代码示例来源:origin: org.xwiki.commons/xwiki-commons-crypto-common

@Override
  public byte[] getEncoded() throws IOException
  {
    return getAlgorithmIdentifier().getEncoded();
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-crypto-common

@Override
  public byte[] getEncoded() throws IOException
  {
    return getAlgorithmIdentifier().getEncoded();
  }
}

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

public static byte[] getEncoded(final AlgorithmIdentifier algorithmIdentifier) throws DSSException {
  try {
    return algorithmIdentifier.getEncoded(ASN1Encoding.DER);
  } catch (IOException e) {
    throw new DSSException(e);
  }
}

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

public XiWrappedContentSigner(ContentSigner signer, boolean fixedAlgorithmIdentifier)
  throws XiSecurityException {
 this.signer = Args.notNull(signer, "signer");
 if (fixedAlgorithmIdentifier) {
  try {
   this.encodedAlgorithmIdentifier = signer.getAlgorithmIdentifier().getEncoded();
  } catch (IOException ex) {
   throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
  }
 }
}

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

public XiWrappedContentSigner(ContentSigner signer, boolean fixedAlgorithmIdentifier)
    throws XiSecurityException {
  this.signer = ParamUtil.requireNonNull("signer",signer);
  if (fixedAlgorithmIdentifier) {
    try {
      this.encodedAlgorithmIdentifier = signer.getAlgorithmIdentifier().getEncoded();
    } catch (IOException ex) {
      throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
    }
  }
}

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

public SignatureSigner(final AlgorithmIdentifier sigAlgId, final Signature signer,
    final PrivateKey key) throws XiSecurityException {
  this.sigAlgId = ParamUtil.requireNonNull("sigAlgId", sigAlgId);
  this.signer = ParamUtil.requireNonNull("signer", signer);
  this.key = ParamUtil.requireNonNull("key", key);
  try {
    this.encodedSigAlgId = sigAlgId.getEncoded();
  } catch (IOException ex) {
    throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
  }
}

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

P11ContentSigner(P11CryptService cryptService, P11IdentityId identityId,
  AlgorithmIdentifier signatureAlgId)
  throws XiSecurityException, P11TokenException {
 this.identityId = Args.notNull(identityId, "identityId");
 this.cryptService = Args.notNull(cryptService, "cryptService");
 this.algorithmIdentifier = Args.notNull(signatureAlgId, "signatureAlgId");
 try {
  this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
 } catch (IOException ex) {
  throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
 }
}

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

public SignatureSigner(AlgorithmIdentifier sigAlgId, Signature signer, PrivateKey key)
  throws XiSecurityException {
 this.sigAlgId = Args.notNull(sigAlgId, "sigAlgId");
 this.signer = Args.notNull(signer, "signer");
 this.key = Args.notNull(key, "key");
 try {
  this.encodedSigAlgId = sigAlgId.getEncoded();
 } catch (IOException ex) {
  throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
 }
}

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

this.algorithmIdentifier = ParamUtil.requireNonNull("signatureAlgId", signatureAlgId);
try {
 this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
} catch (IOException ex) {
 throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);

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

P11ECDSAContentSigner(final P11CryptService cryptService, final P11EntityIdentifier identityId,
    final AlgorithmIdentifier signatureAlgId, final boolean plain)
    throws XiSecurityException, P11TokenException {
  this.cryptService = ParamUtil.requireNonNull("cryptService", cryptService);
  this.identityId = ParamUtil.requireNonNull("identityId", identityId);
  this.algorithmIdentifier = ParamUtil.requireNonNull("signatureAlgId", signatureAlgId);
  try {
    this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
  } catch (IOException ex) {
    throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
  }
  this.plain = plain;
  String algOid = signatureAlgId.getAlgorithm().getId();
  HashAlgoType hashAlgo = sigAlgHashMap.get(algOid);
  if (hashAlgo == null) {
    throw new XiSecurityException("unsupported signature algorithm " + algOid);
  }
  P11Slot slot = cryptService.getSlot(identityId.slotId());
  if (slot.supportsMechanism(PKCS11Constants.CKM_ECDSA)) {
    this.mechanism = PKCS11Constants.CKM_ECDSA;
    Digest digest = SignerUtil.getDigest(hashAlgo);
    this.outputStream = new DigestOutputStream(digest);
  } else {
    this.mechanism = hashMechMap.get(hashAlgo).longValue();
    if (!slot.supportsMechanism(this.mechanism)) {
      throw new XiSecurityException("unsupported signature algorithm " + algOid);
    }
    this.outputStream = new ByteArrayOutputStream();
  }
}

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

P11ECDSAContentSigner(P11CryptService cryptService, P11IdentityId identityId,
  AlgorithmIdentifier signatureAlgId, boolean plain)
  throws XiSecurityException, P11TokenException {
 this.cryptService = ParamUtil.requireNonNull("cryptService", cryptService);
 this.identityId = ParamUtil.requireNonNull("identityId", identityId);
 this.algorithmIdentifier = ParamUtil.requireNonNull("signatureAlgId", signatureAlgId);
 try {
  this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
 } catch (IOException ex) {
  throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
 }
 this.plain = plain;
 String algOid = signatureAlgId.getAlgorithm().getId();
 HashAlgo hashAlgo = sigAlgHashMap.get(algOid);
 if (hashAlgo == null) {
  throw new XiSecurityException("unsupported signature algorithm " + algOid);
 }
 P11Slot slot = cryptService.getSlot(identityId.getSlotId());
 if (slot.supportsMechanism(PKCS11Constants.CKM_ECDSA)) {
  this.mechanism = PKCS11Constants.CKM_ECDSA;
  Digest digest = hashAlgo.createDigest();
  this.outputStream = new DigestOutputStream(digest);
 } else {
  this.mechanism = hashMechMap.get(hashAlgo).longValue();
  if (!slot.supportsMechanism(this.mechanism)) {
   throw new XiSecurityException("unsupported signature algorithm " + algOid);
  }
  this.outputStream = new ByteArrayOutputStream();
 }
}

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

public HmacContentSigner(HashAlgo hashAlgo, AlgorithmIdentifier algorithmIdentifier,
  SecretKey signingKey) throws XiSecurityException {
 this.algorithmIdentifier = Args.notNull(algorithmIdentifier, "algorithmIdentifier");
 Args.notNull(signingKey, "signingKey");
 try {
  this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
 } catch (IOException ex) {
  throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
 }
 if (hashAlgo == null) {
  hashAlgo = AlgorithmUtil.extractHashAlgoFromMacAlg(algorithmIdentifier);
 }
 this.hmac = new HMac(hashAlgo.createDigest());
 byte[] keyBytes = signingKey.getEncoded();
 this.hmac.init(new KeyParameter(keyBytes, 0, keyBytes.length));
 this.outLen = hmac.getMacSize();
 this.outputStream = new HmacOutputStream();
}

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

public HmacContentSigner(HashAlgoType hashAlgo, AlgorithmIdentifier algorithmIdentifier,
    SecretKey signingKey) throws XiSecurityException {
  this.algorithmIdentifier = ParamUtil.requireNonNull("algorithmIdentifier",
      algorithmIdentifier);
  try {
    this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
  } catch (IOException ex) {
    throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);
  }
  ParamUtil.requireNonNull("signingKey", signingKey);
  if (hashAlgo == null) {
    hashAlgo = AlgorithmUtil.extractHashAlgoFromMacAlg(algorithmIdentifier);
  }
  this.hmac = new HMac(hashAlgo.createDigest());
  byte[] keyBytes = signingKey.getEncoded();
  this.hmac.init(new KeyParameter(keyBytes, 0, keyBytes.length));
  this.outLen = hmac.getMacSize();
  this.outputStream = new HmacOutputStream();
}

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

this.algorithmIdentifier = ParamUtil.requireNonNull("signatureAlgId", signatureAlgId);
try {
 this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
} catch (IOException ex) {
 throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);

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

this.algorithmIdentifier = ParamUtil.requireNonNull("macAlgId", macAlgId);
try {
  this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded();
} catch (IOException ex) {
  throw new XiSecurityException("could not encode AlgorithmIdentifier", ex);

代码示例来源:origin: org.xwiki.commons/xwiki-commons-crypto-pkix

@Override
public boolean isSignedBy(PublicKeyParameters publicKey) throws GeneralSecurityException
{
  TBSCertificate tbsCert = this.holder.toASN1Structure().getTBSCertificate();
  if (!BcUtils.isAlgorithlIdentifierEqual(tbsCert.getSignature(), this.holder.getSignatureAlgorithm())) {
    return false;
  }
  Signer signer = null;
  // Optimisation
  if (this.signerFactory instanceof BcSignerFactory) {
    signer = ((BcSignerFactory) this.signerFactory).getInstance(false, publicKey, tbsCert.getSignature());
  } else {
    try {
      signer =
        this.signerFactory.getInstance(false, publicKey, this.holder.getSignatureAlgorithm().getEncoded());
    } catch (IOException e) {
      return false;
    }
  }
  try {
    return BcUtils.updateDEREncodedObject(signer, tbsCert).verify(this.holder.getSignature());
  } catch (IOException e) {
    return false;
  }
}

相关文章