本文整理汇总了Java中org.bouncycastle.openpgp.PGPPublicKey.getAlgorithm方法的典型用法代码示例。如果您正苦于以下问题:Java PGPPublicKey.getAlgorithm方法的具体用法?Java PGPPublicKey.getAlgorithm怎么用?Java PGPPublicKey.getAlgorithm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.openpgp.PGPPublicKey
的用法示例。
在下文中一共展示了PGPPublicKey.getAlgorithm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PublicKeyKeyEncryptionMethodGenerator
import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
protected PublicKeyKeyEncryptionMethodGenerator(
PGPPublicKey pubKey)
{
this.pubKey = pubKey;
switch (pubKey.getAlgorithm())
{
case PGPPublicKey.RSA_ENCRYPT:
case PGPPublicKey.RSA_GENERAL:
break;
case PGPPublicKey.RSA_SIGN:
throw new IllegalArgumentException("Can't use an RSA_SIGN key for encryption.");
case PGPPublicKey.ELGAMAL_ENCRYPT:
case PGPPublicKey.ELGAMAL_GENERAL:
break;
case PGPPublicKey.ECDH:
break;
case PGPPublicKey.DSA:
throw new IllegalArgumentException("Can't use DSA for encryption.");
case PGPPublicKey.ECDSA:
throw new IllegalArgumentException("Can't use ECDSA for encryption.");
default:
throw new IllegalArgumentException("unknown asymmetric algorithm: " + pubKey.getAlgorithm());
}
}
示例2: isForEncryption
import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
/**
* Can public key be used for encryption
* @param key - Public key
* @return true if public key has required type of subkeys for encryption else false
*/
private boolean isForEncryption(PGPPublicKey key){
if (key.getAlgorithm() == PublicKeyAlgorithmTags.RSA_SIGN
|| key.getAlgorithm() == PublicKeyAlgorithmTags.DSA
|| key.getAlgorithm() == PublicKeyAlgorithmTags.ECDSA){
return false;
}
return hasKeyFlags(key, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE);
}
示例3: isSigningKey
import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
/** Returns {@code true} if this key can be used for signing. */
public static boolean isSigningKey(PGPPublicKey key) {
switch (key.getAlgorithm()) {
case RSA_GENERAL:
case RSA_SIGN:
case DSA:
case ELGAMAL_GENERAL:
return true;
default:
return false;
}
}
示例4: isSignatureKey
import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
private static boolean isSignatureKey(PGPPublicKey key) {
int algorithm = key.getAlgorithm();
return algorithm == RSA_GENERAL || algorithm == RSA_SIGN || algorithm == DSA || algorithm == ECDSA || algorithm == ELGAMAL_GENERAL;
}