本文整理汇总了Java中org.bouncycastle.asn1.x9.X9ObjectIdentifiers类的典型用法代码示例。如果您正苦于以下问题:Java X9ObjectIdentifiers类的具体用法?Java X9ObjectIdentifiers怎么用?Java X9ObjectIdentifiers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
X9ObjectIdentifiers类属于org.bouncycastle.asn1.x9包,在下文中一共展示了X9ObjectIdentifiers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEncoded
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public byte[] getEncoded()
{
try
{
if (dsaSpec == null)
{
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
}
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
}
catch (IOException e)
{
return null;
}
}
示例2: getSignatureName
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
static String getSignatureName(
AlgorithmIdentifier sigAlgId)
{
ASN1Encodable params = sigAlgId.getParameters();
if (params != null && !derNull.equals(params))
{
if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
{
RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1";
}
if (sigAlgId.getObjectId().equals(X9ObjectIdentifiers.ecdsa_with_SHA2))
{
ASN1Sequence ecDsaParams = ASN1Sequence.getInstance(params);
return getDigestAlgName((DERObjectIdentifier)ecDsaParams.getObjectAt(0)) + "withECDSA";
}
}
return sigAlgId.getObjectId().getId();
}
示例3: getSignatureName
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
static String getSignatureName(
AlgorithmIdentifier sigAlgId)
{
ASN1Encodable params = sigAlgId.getParameters();
if (params != null && !derNull.equals(params))
{
if (sigAlgId.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
{
RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
return getDigestAlgName(rsaParams.getHashAlgorithm().getAlgorithm()) + "withRSAandMGF1";
}
if (sigAlgId.getAlgorithm().equals(X9ObjectIdentifiers.ecdsa_with_SHA2))
{
ASN1Sequence ecDsaParams = ASN1Sequence.getInstance(params);
return getDigestAlgName((DERObjectIdentifier)ecDsaParams.getObjectAt(0)) + "withECDSA";
}
}
return sigAlgId.getAlgorithm().getId();
}
示例4: generatePrivate
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public PrivateKey generatePrivate(PrivateKeyInfo keyInfo)
throws IOException
{
ASN1ObjectIdentifier algOid = keyInfo.getPrivateKeyAlgorithm().getAlgorithm();
if (algOid.equals(PKCSObjectIdentifiers.dhKeyAgreement))
{
return new BCDHPrivateKey(keyInfo);
}
else if (algOid.equals(X9ObjectIdentifiers.dhpublicnumber))
{
return new BCDHPrivateKey(keyInfo);
}
else
{
throw new IOException("algorithm identifier " + algOid + " in key not recognised");
}
}
示例5: generatePublic
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public PublicKey generatePublic(SubjectPublicKeyInfo keyInfo)
throws IOException
{
ASN1ObjectIdentifier algOid = keyInfo.getAlgorithm().getAlgorithm();
if (algOid.equals(PKCSObjectIdentifiers.dhKeyAgreement))
{
return new BCDHPublicKey(keyInfo);
}
else if (algOid.equals(X9ObjectIdentifiers.dhpublicnumber))
{
return new BCDHPublicKey(keyInfo);
}
else
{
throw new IOException("algorithm identifier " + algOid + " in key not recognised");
}
}
示例6: generatePrivate
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public PrivateKey generatePrivate(PrivateKeyInfo info)
throws IOException
{
ASN1ObjectIdentifier algOid = info.getPrivateKeyAlgorithm().getAlgorithm();
if (algOid.equals(PKCSObjectIdentifiers.dhKeyAgreement))
{
return new BCElGamalPrivateKey(info);
}
else if (algOid.equals(X9ObjectIdentifiers.dhpublicnumber))
{
return new BCElGamalPrivateKey(info);
}
else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
{
return new BCElGamalPrivateKey(info);
}
else
{
throw new IOException("algorithm identifier " + algOid + " in key not recognised");
}
}
示例7: generatePublic
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public PublicKey generatePublic(SubjectPublicKeyInfo info)
throws IOException
{
ASN1ObjectIdentifier algOid = info.getAlgorithm().getAlgorithm();
if (algOid.equals(PKCSObjectIdentifiers.dhKeyAgreement))
{
return new BCElGamalPublicKey(info);
}
else if (algOid.equals(X9ObjectIdentifiers.dhpublicnumber))
{
return new BCElGamalPublicKey(info);
}
else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
{
return new BCElGamalPublicKey(info);
}
else
{
throw new IOException("algorithm identifier " + algOid + " in key not recognised");
}
}
示例8: getKeyPair
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public KeyPair getKeyPair(PEMKeyPair keyPair)
throws PEMException
{
try
{
String algorithm = keyPair.getPrivateKeyInfo().getPrivateKeyAlgorithm().getAlgorithm().getId();
if (X9ObjectIdentifiers.id_ecPublicKey.getId().equals(algorithm))
{
algorithm = "ECDSA";
}
KeyFactory keyFactory = helper.createKeyFactory(algorithm);
return new KeyPair(keyFactory.generatePublic(new X509EncodedKeySpec(keyPair.getPublicKeyInfo().getEncoded())),
keyFactory.generatePrivate(new PKCS8EncodedKeySpec(keyPair.getPrivateKeyInfo().getEncoded())));
}
catch (Exception e)
{
throw new PEMException("unable to convert key pair: " + e.getMessage(), e);
}
}
示例9: getPublicKey
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public PublicKey getPublicKey(SubjectPublicKeyInfo publicKeyInfo)
throws PEMException
{
try
{
String algorithm = publicKeyInfo.getAlgorithm().getAlgorithm().getId();
if (X9ObjectIdentifiers.id_ecPublicKey.getId().equals(algorithm))
{
algorithm = "ECDSA";
}
KeyFactory keyFactory = helper.createKeyFactory(algorithm);
return keyFactory.generatePublic(new X509EncodedKeySpec(publicKeyInfo.getEncoded()));
}
catch (Exception e)
{
throw new PEMException("unable to convert key pair: " + e.getMessage(), e);
}
}
示例10: getPrivateKey
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public PrivateKey getPrivateKey(PrivateKeyInfo privateKeyInfo)
throws PEMException
{
try
{
String algorithm = privateKeyInfo.getPrivateKeyAlgorithm().getAlgorithm().getId();
if (X9ObjectIdentifiers.id_ecPublicKey.getId().equals(algorithm))
{
algorithm = "ECDSA";
}
KeyFactory keyFactory = helper.createKeyFactory(algorithm);
return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKeyInfo.getEncoded()));
}
catch (Exception e)
{
throw new PEMException("unable to convert key pair: " + e.getMessage(), e);
}
}
示例11: isECDSASigAlg
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
private static boolean isECDSASigAlg(AlgorithmIdentifier algId) {
ParamUtil.requireNonNull("algId", algId);
ASN1ObjectIdentifier oid = algId.getAlgorithm();
if (X9ObjectIdentifiers.ecdsa_with_SHA1.equals(oid)
|| X9ObjectIdentifiers.ecdsa_with_SHA224.equals(oid)
|| X9ObjectIdentifiers.ecdsa_with_SHA256.equals(oid)
|| X9ObjectIdentifiers.ecdsa_with_SHA384.equals(oid)
|| X9ObjectIdentifiers.ecdsa_with_SHA512.equals(oid)
|| NISTObjectIdentifiers.id_ecdsa_with_sha3_224.equals(oid)
|| NISTObjectIdentifiers.id_ecdsa_with_sha3_256.equals(oid)
|| NISTObjectIdentifiers.id_ecdsa_with_sha3_384.equals(oid)
|| NISTObjectIdentifiers.id_ecdsa_with_sha3_512.equals(oid)) {
return true;
}
return false;
}
示例12: isDSASigAlg
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public static boolean isDSASigAlg(AlgorithmIdentifier algId) {
ParamUtil.requireNonNull("algId", algId);
ASN1ObjectIdentifier oid = algId.getAlgorithm();
if (X9ObjectIdentifiers.id_dsa_with_sha1.equals(oid)
|| NISTObjectIdentifiers.dsa_with_sha224.equals(oid)
|| NISTObjectIdentifiers.dsa_with_sha256.equals(oid)
|| NISTObjectIdentifiers.dsa_with_sha384.equals(oid)
|| NISTObjectIdentifiers.dsa_with_sha512.equals(oid)
|| NISTObjectIdentifiers.id_dsa_with_sha3_224.equals(oid)
|| NISTObjectIdentifiers.id_dsa_with_sha3_256.equals(oid)
|| NISTObjectIdentifiers.id_dsa_with_sha3_384.equals(oid)
|| NISTObjectIdentifiers.id_dsa_with_sha3_512.equals(oid)) {
return true;
}
return false;
}
示例13: createPublicKeyFromPublicKeyInfo
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
static PublicKey createPublicKeyFromPublicKeyInfo(
SubjectPublicKeyInfo info)
{
AlgorithmIdentifier algId = info.getAlgorithmId();
if (algId.getObjectId().equals(PKCSObjectIdentifiers.rsaEncryption)
|| algId.getObjectId().equals(X509ObjectIdentifiers.id_ea_rsa))
{
return new JCERSAPublicKey(info);
}
else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_ecPublicKey))
{
return new JCEECPublicKey(info);
}
else
{
throw new RuntimeException("algorithm identifier in key not recognised");
}
}
示例14: getEncoded
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
public byte[] getEncoded()
{
try
{
if (dsaSpec == null)
{
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y)).getEncoded(ASN1Encoding.DER);
}
return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new ASN1Integer(y)).getEncoded(ASN1Encoding.DER);
}
catch (IOException e)
{
return null;
}
}
示例15: getSignatureName
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; //导入依赖的package包/类
static String getSignatureName(
AlgorithmIdentifier sigAlgId)
{
ASN1Encodable params = sigAlgId.getParameters();
if (params != null && !derNull.equals(params))
{
if (sigAlgId.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
{
RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
return getDigestAlgName(rsaParams.getHashAlgorithm().getAlgorithm()) + "withRSAandMGF1";
}
if (sigAlgId.getAlgorithm().equals(X9ObjectIdentifiers.ecdsa_with_SHA2))
{
ASN1Sequence ecDsaParams = ASN1Sequence.getInstance(params);
return getDigestAlgName(ASN1ObjectIdentifier.getInstance(ecDsaParams.getObjectAt(0))) + "withECDSA";
}
}
return sigAlgId.getAlgorithm().getId();
}