Example usage for org.bouncycastle.bcpg PublicKeyAlgorithmTags ELGAMAL_GENERAL

List of usage examples for org.bouncycastle.bcpg PublicKeyAlgorithmTags ELGAMAL_GENERAL

Introduction

In this page you can find the example usage for org.bouncycastle.bcpg PublicKeyAlgorithmTags ELGAMAL_GENERAL.

Prototype

int ELGAMAL_GENERAL

To view the source code for org.bouncycastle.bcpg PublicKeyAlgorithmTags ELGAMAL_GENERAL.

Click Source Link

Usage

From source file:divconq.pgp.PGPUtil.java

License:Open Source License

public static String getSignatureName(int keyAlgorithm, int hashAlgorithm) throws PGPException {
    String encAlg;/*from w  w w . j  a v  a  2 s  .c o m*/

    switch (keyAlgorithm) {
    case PublicKeyAlgorithmTags.RSA_GENERAL:
    case PublicKeyAlgorithmTags.RSA_SIGN:
        encAlg = "RSA";
        break;
    case PublicKeyAlgorithmTags.DSA:
        encAlg = "DSA";
        break;
    case PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT: // in some malformed cases.
    case PublicKeyAlgorithmTags.ELGAMAL_GENERAL:
        encAlg = "ElGamal";
        break;
    default:
        throw new PGPException("unknown algorithm tag in signature:" + keyAlgorithm);
    }

    return getDigestName(hashAlgorithm) + "with" + encAlg;
}

From source file:org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.java

License:Open Source License

/**
 * Based on <a href="http://tools.ietf.org/html/rfc2440#section-9.1">OpenPGP Message Format</a>
 *//*from  ww  w.  j a  v a2  s  .  c  o  m*/
public static String getAlgorithmInfo(Context context, int algorithm, Integer keySize, String oid) {
    String algorithmStr;

    switch (algorithm) {
    case PublicKeyAlgorithmTags.RSA_GENERAL:
    case PublicKeyAlgorithmTags.RSA_ENCRYPT:
    case PublicKeyAlgorithmTags.RSA_SIGN: {
        algorithmStr = "RSA";
        break;
    }
    case PublicKeyAlgorithmTags.DSA: {
        algorithmStr = "DSA";
        break;
    }

    case PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT:
    case PublicKeyAlgorithmTags.ELGAMAL_GENERAL: {
        algorithmStr = "ElGamal";
        break;
    }

    case PublicKeyAlgorithmTags.ECDSA: {
        if (oid == null) {
            return "ECDSA";
        }
        String oidName = KeyFormattingUtils.getCurveInfo(context, oid);
        return "ECDSA (" + oidName + ")";
    }
    case PublicKeyAlgorithmTags.ECDH: {
        if (oid == null) {
            return "ECDH";
        }
        String oidName = KeyFormattingUtils.getCurveInfo(context, oid);
        return "ECDH (" + oidName + ")";
    }

    default: {
        if (context != null) {
            algorithmStr = context.getResources().getString(R.string.unknown_algorithm);
        } else {
            algorithmStr = "unknown";
        }
        break;
    }
    }
    if (keySize != null && keySize > 0)
        return algorithmStr + ", " + keySize + " bit";
    else
        return algorithmStr;
}