本文整理汇总了Java中org.bouncycastle.asn1.x509.AlgorithmIdentifier类的典型用法代码示例。如果您正苦于以下问题:Java AlgorithmIdentifier类的具体用法?Java AlgorithmIdentifier怎么用?Java AlgorithmIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AlgorithmIdentifier类属于org.bouncycastle.asn1.x509包,在下文中一共展示了AlgorithmIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: determineKeyEncAlg
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
static AlgorithmIdentifier determineKeyEncAlg(KeyParameter key)
{
int length = key.getKey().length * 8;
ASN1ObjectIdentifier wrapOid;
if (length == 128)
{
wrapOid = NISTObjectIdentifiers.id_aes128_wrap;
}
else if (length == 192)
{
wrapOid = NISTObjectIdentifiers.id_aes192_wrap;
}
else if (length == 256)
{
wrapOid = NISTObjectIdentifiers.id_aes256_wrap;
}
else
{
throw new IllegalArgumentException("illegal keysize in AES");
}
return new AlgorithmIdentifier(wrapOid); // parameters absent
}
示例2: getAlgorithmIdentifier
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
protected static AlgorithmIdentifier getAlgorithmIdentifier(
PublicKey key)
throws CertPathValidatorException
{
try
{
ASN1InputStream aIn = new ASN1InputStream(key.getEncoded());
SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(aIn.readObject());
return info.getAlgorithmId();
}
catch (Exception e)
{
throw new ExtCertPathValidatorException("Subject public key cannot be decoded.", e);
}
}
示例3: getPublicKey
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
public PublicKey getPublicKey(String provider)
throws NoSuchAlgorithmException, NoSuchProviderException,
InvalidKeyException
{
SubjectPublicKeyInfo subjectPKInfo = pkac.getSubjectPublicKeyInfo();
try
{
DERBitString bStr = new DERBitString(subjectPKInfo);
X509EncodedKeySpec xspec = new X509EncodedKeySpec(bStr.getBytes());
AlgorithmIdentifier keyAlg = subjectPKInfo.getAlgorithm();
KeyFactory factory =
KeyFactory.getInstance(keyAlg.getAlgorithm().getId(),provider);
return factory.generatePublic(xspec);
}
catch (Exception e)
{
throw new InvalidKeyException("error encoding public key");
}
}
示例4: getSignatureName
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
static String getSignatureName(
AlgorithmIdentifier sigAlgId)
{
ASN1Encodable params = sigAlgId.getParameters();
if (params != null && !DERNull.INSTANCE.equals(params))
{
if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
{
RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1";
}
}
return sigAlgId.getObjectId().getId();
}
示例5: getEncoded
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
/**
* Return the keyData to encode in the SubjectPublicKeyInfo structure.
* <p/>
* The ASN.1 definition of the key structure is
* <p/>
* <pre>
* McEliecePublicKey ::= SEQUENCE {
* n Integer -- length of the code
* t Integer -- error correcting capability
* matrixG OctetString -- generator matrix as octet string
* }
* </pre>
*
* @return the keyData to encode in the SubjectPublicKeyInfo structure
*/
public byte[] getEncoded()
{
McEliecePublicKey key = new McEliecePublicKey(new ASN1ObjectIdentifier(oid), n, t, g);
AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(this.getOID(), DERNull.INSTANCE);
try
{
SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(algorithmIdentifier, key);
return subjectPublicKeyInfo.getEncoded();
}
catch (IOException e)
{
return null;
}
}
示例6: getSigOrMacAlgoCode
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
public static AlgorithmCode getSigOrMacAlgoCode(AlgorithmIdentifier algId)
throws NoSuchAlgorithmException {
ASN1ObjectIdentifier oid = algId.getAlgorithm();
AlgorithmCode code = algOidToCodeMap.get(oid);
if (code != null) {
return code;
}
if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(oid)) {
RSASSAPSSparams param = RSASSAPSSparams.getInstance(algId.getParameters());
ASN1ObjectIdentifier digestAlgOid = param.getHashAlgorithm().getAlgorithm();
code = digestToMgf1AlgCodeMap.get(digestAlgOid);
if (code == null) {
throw new NoSuchAlgorithmException("unsupported digest algorithm " + digestAlgOid);
}
return code;
} else {
throw new NoSuchAlgorithmException("unsupported signature algorithm "
+ oid.getId());
}
}
示例7: getValueDecryptor
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
public InputDecryptor getValueDecryptor(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey)
throws CRMFException
{
Key secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);
final Cipher dataCipher = helper.createContentCipher(secretKey, contentEncryptionAlgorithm);
return new InputDecryptor()
{
public AlgorithmIdentifier getAlgorithmIdentifier()
{
return contentEncryptionAlgorithm;
}
public InputStream getInputStream(InputStream dataIn)
{
return new CipherInputStream(dataIn, dataCipher);
}
};
}
示例8: P11DSAContentSigner
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
P11DSAContentSigner(P11CryptService cryptService, P11EntityIdentifier identityId,
AlgorithmIdentifier signatureAlgId, boolean plain)
throws XiSecurityException, P11TokenException {
this.identityId = ParamUtil.requireNonNull("identityId", identityId);
this.cryptService = ParamUtil.requireNonNull("cryptService", cryptService);
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);
}
P11SlotIdentifier slotId = identityId.slotId();
P11Slot slot = cryptService.getSlot(slotId);
if (slot.supportsMechanism(PKCS11Constants.CKM_DSA)) {
this.mechanism = PKCS11Constants.CKM_DSA;
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();
}
}
示例9: getAlgorithmIdentifier
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
AlgorithmIdentifier getAlgorithmIdentifier(ASN1ObjectIdentifier encryptionOID, AlgorithmParameters params)
throws CMSException
{
ASN1Encodable asn1Params;
if (params != null)
{
try
{
asn1Params = ASN1Primitive.fromByteArray(params.getEncoded("ASN.1"));
}
catch (IOException e)
{
throw new CMSException("cannot encode parameters: " + e.getMessage(), e);
}
}
else
{
asn1Params = DERNull.INSTANCE;
}
return new AlgorithmIdentifier(
encryptionOID,
asn1Params);
}
示例10: getAlgorithmIdentifier
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
protected AlgorithmIdentifier getAlgorithmIdentifier(String encryptionOID, AlgorithmParameters params) throws IOException
{
ASN1Encodable asn1Params;
if (params != null)
{
asn1Params = ASN1Primitive.fromByteArray(params.getEncoded("ASN.1"));
}
else
{
asn1Params = DERNull.INSTANCE;
}
return new AlgorithmIdentifier(
new ASN1ObjectIdentifier(encryptionOID),
asn1Params);
}
示例11: HmacContentSigner
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
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();
}
示例12: KeyAgreeRecipientInfo
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
public KeyAgreeRecipientInfo(
ASN1Sequence seq)
{
int index = 0;
version = (ASN1Integer)seq.getObjectAt(index++);
originator = OriginatorIdentifierOrKey.getInstance(
(ASN1TaggedObject)seq.getObjectAt(index++), true);
if (seq.getObjectAt(index) instanceof ASN1TaggedObject)
{
ukm = ASN1OctetString.getInstance(
(ASN1TaggedObject)seq.getObjectAt(index++), true);
}
keyEncryptionAlgorithm = AlgorithmIdentifier.getInstance(
seq.getObjectAt(index++));
recipientEncryptedKeys = (ASN1Sequence)seq.getObjectAt(index++);
}
示例13: getSignatureAlgoName
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
public static String getSignatureAlgoName(AlgorithmIdentifier sigAlgId)
throws NoSuchAlgorithmException {
ParamUtil.requireNonNull("sigAlgId", sigAlgId);
ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm();
String name = null;
if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
RSASSAPSSparams param = RSASSAPSSparams.getInstance(sigAlgId.getParameters());
ASN1ObjectIdentifier digestAlgOid = param.getHashAlgorithm().getAlgorithm();
name = digestOidToMgf1SigNameMap.get(digestAlgOid);
if (name == null) {
throw new NoSuchAlgorithmException("unsupported digest algorithm " + digestAlgOid);
}
} else {
name = sigAlgOidToNameMap.get(algOid);
}
if (name == null) {
throw new NoSuchAlgorithmException("unsupported signature algorithm " + algOid.getId());
}
return name;
}
示例14: SignerInfo
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
public SignerInfo(
SignerIdentifier sid,
AlgorithmIdentifier digAlgorithm,
Attributes authenticatedAttributes,
AlgorithmIdentifier digEncryptionAlgorithm,
ASN1OctetString encryptedDigest,
Attributes unauthenticatedAttributes)
{
if (sid.isTagged())
{
this.version = new ASN1Integer(3);
}
else
{
this.version = new ASN1Integer(1);
}
this.sid = sid;
this.digAlgorithm = digAlgorithm;
this.authenticatedAttributes = ASN1Set.getInstance(authenticatedAttributes);
this.digEncryptionAlgorithm = digEncryptionAlgorithm;
this.encryptedDigest = encryptedDigest;
this.unauthenticatedAttributes = ASN1Set.getInstance(unauthenticatedAttributes);
}
示例15: SignerInfo
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; //导入依赖的package包/类
public SignerInfo(
ASN1Integer version,
IssuerAndSerialNumber issuerAndSerialNumber,
AlgorithmIdentifier digAlgorithm,
ASN1Set authenticatedAttributes,
AlgorithmIdentifier digEncryptionAlgorithm,
ASN1OctetString encryptedDigest,
ASN1Set unauthenticatedAttributes)
{
this.version = version;
this.issuerAndSerialNumber = issuerAndSerialNumber;
this.digAlgorithm = digAlgorithm;
this.authenticatedAttributes = authenticatedAttributes;
this.digEncryptionAlgorithm = digEncryptionAlgorithm;
this.encryptedDigest = encryptedDigest;
this.unauthenticatedAttributes = unauthenticatedAttributes;
}