• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PGPPublicKey类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.spongycastle.openpgp.PGPPublicKey的典型用法代码示例。如果您正苦于以下问题:Java PGPPublicKey类的具体用法?Java PGPPublicKey怎么用?Java PGPPublicKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PGPPublicKey类属于org.spongycastle.openpgp包,在下文中一共展示了PGPPublicKey类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: fillKeyDetails

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
private void fillKeyDetails() {
    if(!SharedData.KEYS_GENERATED){
        Snackbar.make(findViewById(R.id.key_details_keyid_textview),"Keys not generated.",Snackbar.LENGTH_SHORT).show();
        return;
    }
    try {
        PGPPublicKey key=MyPGPUtil.readPublicKey(getFilesDir()+"/"+"pub.asc");
        ((TextView)findViewById(R.id.key_details_keyid_textview)).setText(""+key.getKeyID());
        ((TextView)findViewById(R.id.key_details_keysize_textview)).setText(""+key.getBitStrength());
        if(key.getValidSeconds()==0){
            ((TextView)findViewById(R.id.key_details_keyalgo_textview)).setText("Key does not expire");
        }else{
            ((TextView)findViewById(R.id.key_details_keyalgo_textview)).setText(""+key.getValidSeconds());
        }
        ((TextView)findViewById(R.id.key_details_keytime_textview)).setText(""+key.getCreationTime());
    } catch (IOException | PGPException e) {
        e.printStackTrace();
    }
}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:20,代码来源:KeyDetailsActivity.java


示例2: generateKeyRingGenerator

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
public final static PGPKeyRingGenerator generateKeyRingGenerator (String keyId, char[] pass) throws PGPException{
    RSAKeyPairGenerator kpg = new RSAKeyPairGenerator();
    kpg.init(new RSAKeyGenerationParameters(BigInteger.valueOf(0x10001), new SecureRandom(), 4096, 12));
    PGPKeyPair rsakp_sign = new BcPGPKeyPair(PGPPublicKey.RSA_SIGN, kpg.generateKeyPair(), new Date());
    PGPKeyPair rsakp_enc = new BcPGPKeyPair(PGPPublicKey.RSA_ENCRYPT, kpg.generateKeyPair(), new Date());
    PGPSignatureSubpacketGenerator signhashgen = new PGPSignatureSubpacketGenerator();
    signhashgen.setKeyFlags(false, KeyFlags.SIGN_DATA|KeyFlags.CERTIFY_OTHER|KeyFlags.SHARED);
    signhashgen.setPreferredSymmetricAlgorithms(false, new int[]{SymmetricKeyAlgorithmTags.AES_256, SymmetricKeyAlgorithmTags.AES_192, SymmetricKeyAlgorithmTags.AES_128});
    signhashgen.setPreferredHashAlgorithms(false, new int[]{HashAlgorithmTags.SHA256, HashAlgorithmTags.SHA1, HashAlgorithmTags.SHA384, HashAlgorithmTags.SHA512, HashAlgorithmTags.SHA224});
    signhashgen.setFeature(false, Features.FEATURE_MODIFICATION_DETECTION);
    PGPSignatureSubpacketGenerator enchashgen = new PGPSignatureSubpacketGenerator();
    enchashgen.setKeyFlags(false, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE);
    PGPDigestCalculator sha1Calc = new BcPGPDigestCalculatorProvider().get(HashAlgorithmTags.SHA1);
    PGPDigestCalculator sha256Calc = new BcPGPDigestCalculatorProvider().get(HashAlgorithmTags.SHA256);
    PBESecretKeyEncryptor pske = (new BcPBESecretKeyEncryptorBuilder(PGPEncryptedData.AES_256, sha256Calc, 0xc0)).build(pass);
    PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator (PGPSignature.POSITIVE_CERTIFICATION, rsakp_sign,
            keyId, sha1Calc, signhashgen.generate(), null, new BcPGPContentSignerBuilder(rsakp_sign.getPublicKey().getAlgorithm(),
            HashAlgorithmTags.SHA1), pske);
    keyRingGen.addSubKey(rsakp_enc, enchashgen.generate(), null);
    return keyRingGen;
}
 
开发者ID:guardianproject,项目名称:proofmode,代码行数:22,代码来源:PgpUtils.java


示例3: PGPPubkeyEncryptionUtil

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
public PGPPubkeyEncryptionUtil(String pubkeyBlock){
    InputStream in = new ByteArrayInputStream(pubkeyBlock.getBytes());
    publicKey = null;
    try {
        in = PGPUtil.getDecoderStream(in);
        JcaPGPPublicKeyRingCollection pgpPub = new JcaPGPPublicKeyRingCollection(in);
        in.close();
        Iterator<PGPPublicKeyRing> rIt = pgpPub.getKeyRings();
        while (publicKey == null && rIt.hasNext()) {
            PGPPublicKeyRing keyRing = rIt.next();
            Iterator<PGPPublicKey> kIt = keyRing.getPublicKeys();
            while (publicKey == null && kIt.hasNext()) {
                PGPPublicKey k = kIt.next();
                if (k.isEncryptionKey()) {
                    publicKey = k;
                }
            }
        }
    } catch (Exception e){
        Log.e(LOGCATTAG, e.toString());
    }
}
 
开发者ID:TpmKranz,项目名称:SMS-Forward,代码行数:23,代码来源:PGPPubkeyEncryptionUtil.java


示例4: readPublicKeyFromCol

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
public static PGPPublicKey readPublicKeyFromCol(InputStream in) throws IOException, PGPException {
    in = PGPUtil.getDecoderStream(in);
    PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(in, new BcKeyFingerprintCalculator());
    PGPPublicKey key = null;
    Iterator<PGPPublicKeyRing> keyRings = pgpPub.getKeyRings();
    while (key == null && keyRings.hasNext()) {
        PGPPublicKeyRing keyRing = keyRings.next();
        Iterator<PGPPublicKey> keys = keyRing.getPublicKeys();
        while (keys.hasNext()) {
            PGPPublicKey k = keys.next();
            if (k.isEncryptionKey()) {
                key = k;
                break;
            }
        }
    }
    if (key == null)
        throw new PGPException("Can't find a valid encryption key in key ring.");

    return key;
}
 
开发者ID:PassableShots,项目名称:PassableShots,代码行数:22,代码来源:EncryptionSystem.java


示例5: writeKeyPairToParcel

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
private static void writeKeyPairToParcel(PGPKeyPair keypair, Parcel dest) throws IOException {
    // write private key
    PGPPrivateKey priv = keypair.getPrivateKey();
    // key ID
    dest.writeLong(priv.getKeyID());
    // private key data packet
    byte[] privData = priv.getPrivateKeyDataPacket().getEncoded();
    dest.writeInt(privData.length);
    dest.writeByteArray(privData);
    // public key packet
    byte[] privPubKey = priv.getPublicKeyPacket().getEncoded();
    dest.writeInt(privPubKey.length);
    dest.writeByteArray(privPubKey);

    // write public key
    PGPPublicKey pub = keypair.getPublicKey();
    // whole public key
    byte[] pubPacket = pub.getEncoded();
    dest.writeInt(pubPacket.length);
    dest.writeByteArray(pubPacket);
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:22,代码来源:PGP.java


示例6: getEncryptionKey

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
public static PGPPublicKey getEncryptionKey(PGPPublicKeyRing publicKeyring) {
    @SuppressWarnings("unchecked")
    Iterator<PGPPublicKey> iter = publicKeyring.getPublicKeys();
    while (iter.hasNext()) {
        PGPPublicKey pk = iter.next();
        if (!pk.isMasterKey()) {
            int keyFlags = getKeyFlags(pk);
            if ((keyFlags & PGPKeyFlags.CAN_ENCRYPT_COMMS) == PGPKeyFlags.CAN_ENCRYPT_COMMS)
                return pk;

        }
    }

    // legacy key format support
    return getLegacyEncryptionKey(publicKeyring);
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:17,代码来源:PGP.java


示例7: setKey

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
/** Adds/updates a public key. */
public static void setKey(Context context, String jid, byte[] keydata, int trustLevel)
        throws IOException, PGPException {
    PGPPublicKey pk = PGP.getMasterKey(keydata);
    String fingerprint = PGP.getFingerprint(pk);
    Date date = pk.getCreationTime();

    int autoTrustedLevel = getAutoTrustedLevel(context, jid);

    ContentValues values = new ContentValues(3);
    values.put(MyUsers.Keys.PUBLIC_KEY, keydata);
    values.put(MyUsers.Keys.TIMESTAMP, date.getTime());
    if (trustLevel >= 0) {
        values.put(MyUsers.Keys.TRUST_LEVEL, trustLevel);
    }
    else if (autoTrustedLevel >= 0) {
        values.put(MyUsers.Keys.TRUST_LEVEL, autoTrustedLevel);
    }
    context.getContentResolver().insert(MyUsers.Keys.getUri(jid, fingerprint), values);

    if (autoTrustedLevel >= 0) {
        // delete the autotrust entry
        context.getContentResolver().delete(MyUsers.Keys.getUri(jid, VALUE_AUTOTRUST), null, null);
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:26,代码来源:Keyring.java


示例8: fromParcel

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
public static PGPDecryptedKeyPairRing fromParcel(Parcel in) throws PGPException {
    ensureKeyConverter();

    // TODO read byte data
    PrivateKey privSign = (PrivateKey) in.readSerializable();
    PublicKey pubSign = (PublicKey) in.readSerializable();
    int algoSign = in.readInt();
    Date dateSign = new Date(in.readLong());

    PGPPublicKey pubKeySign = sKeyConverter.getPGPPublicKey(algoSign, pubSign, dateSign);
    PGPPrivateKey privKeySign = sKeyConverter.getPGPPrivateKey(pubKeySign, privSign);
    PGPKeyPair signKp = new PGPKeyPair(pubKeySign, privKeySign);

    PrivateKey privEnc = (PrivateKey) in.readSerializable();
    PublicKey pubEnc = (PublicKey) in.readSerializable();
    int algoEnc = in.readInt();
    Date dateEnc = new Date(in.readLong());

    PGPPublicKey pubKeyEnc = sKeyConverter.getPGPPublicKey(algoEnc, pubEnc, dateEnc);
    PGPPrivateKey privKeyEnc = sKeyConverter.getPGPPrivateKey(pubKeyEnc, privEnc);
    PGPKeyPair encryptKp = new PGPKeyPair(pubKeyEnc, privKeyEnc);

    return new PGPDecryptedKeyPairRing(signKp, encryptKp);
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:25,代码来源:PGP.java


示例9: signPublicKey

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
/**
 * Searches for the master (signing) key in the given public keyring and
 * signs it with our master key.
 * @return the same public keyring with the signed key. This is suitable to
 * be imported directly into GnuPG.
 * @see #signPublicKey(PGPPublicKey, String)
 */
@SuppressWarnings("unchecked")
public PGPPublicKeyRing signPublicKey(byte[] publicKeyring, String id)
        throws PGPException, IOException, SignatureException {

    PGPObjectFactory reader = new PGPObjectFactory(publicKeyring);
    Object o = reader.nextObject();
    while (o != null) {
        if (o instanceof PGPPublicKeyRing) {
            PGPPublicKeyRing pubRing = (PGPPublicKeyRing) o;
            Iterator<PGPPublicKey> iter = pubRing.getPublicKeys();
            while (iter.hasNext()) {
                PGPPublicKey pk = iter.next();
                if (pk.isMasterKey()) {
                    PGPPublicKey signed = signPublicKey(pk, id);
                    return PGPPublicKeyRing.insertPublicKey(pubRing, signed);
                }
            }
        }
        o = reader.nextObject();
    }

    throw new PGPException("invalid keyring data.");
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:31,代码来源:PersonalKey.java


示例10: getEncryptCoder

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
/** Returns a {@link Coder} instance for encrypting data. */
public static Coder getEncryptCoder(Context context, EndpointServer server, PersonalKey key, String[] recipients) {
    // get recipients public keys from users database
    PGPPublicKey keys[] = new PGPPublicKey[recipients.length];
    for (int i = 0; i < recipients.length; i++) {
        String rcpt = StringUtils.parseName(recipients[i]);

        PGPPublicKeyRing ring = getPublicKey(context, rcpt);
        if (ring == null)
            throw new IllegalArgumentException("public key not found for user " + rcpt);

        keys[i] = PGP.getEncryptionKey(ring);
        if (keys[i] == null)
            throw new IllegalArgumentException("public key not found for user " + rcpt);
    }

    return new PGPCoder(server, key, keys);
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:19,代码来源:UsersProvider.java


示例11: extractPublicKeyFromBytes

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static PGPPublicKey extractPublicKeyFromBytes(byte[] keyBlock) throws IOException, PGPException {
	PGPPublicKeyRingCollection keyringCol = new PGPPublicKeyRingCollection(PGPUtil.getDecoderStream(new ByteArrayInputStream(Base64.decode(keyBlock, Base64.DEFAULT))));
	PGPPublicKey key = null;
	Iterator<PGPPublicKeyRing> rIt = keyringCol.getKeyRings();
	while(key == null && rIt.hasNext()) {
		PGPPublicKeyRing keyring = (PGPPublicKeyRing) rIt.next();
		Iterator<PGPPublicKey> kIt = keyring.getPublicKeys();
		while(key == null && kIt.hasNext()) {
			PGPPublicKey k = (PGPPublicKey) kIt.next();
			if(k.isEncryptionKey())
				key = k;
		}
	}
	
	if(key == null) {
		throw new IllegalArgumentException("there isn't an encryption key here.");
	}

	return key;
}
 
开发者ID:guardianproject,项目名称:CameraV,代码行数:22,代码来源:KeyUtility.java


示例12: doInBackground

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
@Override
protected Boolean doInBackground(Void... voids) {
    try {
        PGPSecretKey key=MyPGPUtil.readSecretKey(mSecretKeyFilename);
        // if secret key is correct get the public key from it and save it
        publishProgress("Getting public key");
        PGPPublicKey pub=key.getPublicKey();
        //output keys in ascii armored format
        File file                   = new File(getFilesDir(),"pub.asc");
        ArmoredOutputStream pubOut  = new ArmoredOutputStream(new FileOutputStream(file));
        pub.encode(pubOut);
        pubOut.close();

        publishProgress("Setting up database");
        DatabaseHandler db=new DatabaseHandler(KeySelectActivity.this,SharedData.DB_PASSWORD,true);
        ByteArrayOutputStream outputStream  = new ByteArrayOutputStream();
        ArmoredOutputStream secOut          = new ArmoredOutputStream(outputStream);
        key.encode(secOut);
        secOut.close();

        byte[] test=outputStream.toByteArray();
        //call the db methods to store
        db.insertSecKey(SharedData.USERNAME,test);
        //save shared preferences
        SharedPreferences prefs=getSharedPreferences("done", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=prefs.edit();
        editor.putBoolean("keys_gen",true);
        editor.apply();
        editor.commit();
        return true;

    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:37,代码来源:KeySelectActivity.java


示例13: readPublicKey

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
public static PGPPublicKey readPublicKey(String fileName) throws IOException, PGPException
{
    InputStream keyIn   = new BufferedInputStream(new FileInputStream(fileName));
    PGPPublicKey pubKey = readPublicKey(keyIn);
    keyIn.close();
    return pubKey;
}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:8,代码来源:MyPGPUtil.java


示例14: encryptFile

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
public static boolean encryptFile(InputStream in, OutputStream out, File pubKeyFile,
                           boolean integrityCheck, Date fileDate,String filename){
    boolean status;
   try{
       PGPPublicKey encKey=MyPGPUtil.readPublicKey(new FileInputStream(pubKeyFile));
       Security.addProvider(new BouncyCastleProvider());

       PGPEncryptedDataGenerator cPk =
               new PGPEncryptedDataGenerator(
                       new JcePGPDataEncryptorBuilder(PGPEncryptedData.CAST5).
                               setWithIntegrityPacket(integrityCheck).
                               setSecureRandom(
                                       new SecureRandom()
                               )
               );

       cPk.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(encKey));

       OutputStream                cOut = cPk.open(out, new byte[1 << 16]);

       PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(
               PGPCompressedData.UNCOMPRESSED);

       PGPLiteralDataGenerator lData = new PGPLiteralDataGenerator();
       OutputStream pOut = lData.open(comData.open(cOut), PGPLiteralData.BINARY,filename ,fileDate, new byte[1 << 16]);
       PGPUtil.pipeDocumentFileContents(in,pOut, new byte[1 << 16].length);
       comData.close();

       cOut.close();
       Log.d(TAG,"file successfully encrypted");
       status=true;
   }catch (Exception ex){
       Log.d(TAG, "encryptFile: error in encrypting document file");
       ex.printStackTrace();
       status=false;
   }

    return status;
}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:40,代码来源:DocumentFileEncryption.java


示例15: getPublicKey

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
@Override
public PGPPublicKey getPublicKey(File file) throws Exception {
    InputStream input=new FileInputStream(file);
    JcaPGPPublicKeyRingCollection pgpPub = new JcaPGPPublicKeyRingCollection(PGPUtil.getDecoderStream(input));
    PGPPublicKey pubKey = null;

    @SuppressWarnings("unchecked")
    Iterator<PGPPublicKeyRing> keyRingIterator = pgpPub.getKeyRings();
    while (keyRingIterator.hasNext() && pubKey == null) {
        PGPPublicKeyRing keyRing = keyRingIterator.next();

        @SuppressWarnings("unchecked")
        Iterator<PGPPublicKey> keyIterator = keyRing.getPublicKeys();
        while (keyIterator.hasNext()) {
            PGPPublicKey key = keyIterator.next();

            if (key.isEncryptionKey()) {
                pubKey = key;
                break;
            }
        }
    }

    if(pubKey != null) {
        return pubKey;
    }
    else {
        throw new IllegalArgumentException("Can't find encryption key in key ring.");
    }
}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:31,代码来源:KeyManagement.java


示例16: encryptFile

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
@Override
public boolean encryptFile(File outputFile, File inputFile,
                         File pubKeyFile,Boolean integrityCheck
) throws Exception {
    OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile));
    String fileName=inputFile.getPath();
    PGPPublicKey encKey=keyManagement.getPublicKey(pubKeyFile);
    Security.addProvider(new BouncyCastleProvider());

    PGPEncryptedDataGenerator cPk =
            new PGPEncryptedDataGenerator(
                    new JcePGPDataEncryptorBuilder(PGPEncryptedData.CAST5).
                            setWithIntegrityPacket(integrityCheck).
                            setSecureRandom(
                                    new SecureRandom()
                            )
            );

    cPk.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(encKey));

    OutputStream                cOut = cPk.open(out, new byte[1 << 16]);

    PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(
            PGPCompressedData.UNCOMPRESSED);

    PGPUtil.writeFileToLiteralData(comData.open(cOut), PGPLiteralData.BINARY, new File(fileName), new byte[1 << 16]);

    comData.close();

    cOut.close();
    Log.d("encrypt","file successfully encrypted");
    return true;
}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:34,代码来源:EncryptionManagement.java


示例17: getPublicKey

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
private static PGPPublicKey getPublicKey(PGPPublicKeyRing publicKeyRing) {
    Iterator<?> kIt = publicKeyRing.getPublicKeys();
    while (kIt.hasNext()) {
        PGPPublicKey k = (PGPPublicKey) kIt.next();
        if (k.isEncryptionKey()) {
            return k;
        }
    }
    return null;
}
 
开发者ID:guardianproject,项目名称:proofmode,代码行数:11,代码来源:PgpUtils.java


示例18: encrypt

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
public String encrypt(String msgText) throws IOException, PGPException {
    byte[] clearData = msgText.getBytes();
    PGPPublicKey encKey = getPublicKey(pkr);
    ByteArrayOutputStream encOut = new ByteArrayOutputStream();
    OutputStream out = new ArmoredOutputStream(encOut);
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(PGPCompressedDataGenerator.ZIP);
    OutputStream cos = comData.open(bOut);
    PGPLiteralDataGenerator lData = new PGPLiteralDataGenerator();
    OutputStream pOut = lData.open(cos, PGPLiteralData.BINARY, PGPLiteralData.CONSOLE, clearData.length, new Date());
    pOut.write(clearData);
    lData.close();
    comData.close();
    PGPEncryptedDataGenerator encGen =
            new PGPEncryptedDataGenerator(
                    new JcePGPDataEncryptorBuilder(PGPEncryptedData.AES_256).setWithIntegrityPacket(true).setSecureRandom(
                            new SecureRandom()).setProvider(PROVIDER));
    if (encKey != null) {
        encGen.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(encKey).setProvider(PROVIDER));
        byte[] bytes = bOut.toByteArray();
        OutputStream cOut = encGen.open(out, bytes.length);
        cOut.write(bytes);
        cOut.close();
    }
    out.close();
    return new String(encOut.toByteArray());
}
 
开发者ID:guardianproject,项目名称:proofmode,代码行数:28,代码来源:PgpUtils.java


示例19: crossCertify

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
/** Generates a cross-certification for a subkey. */
private static PGPSignature crossCertify(PGPKeyPair signer, PGPPublicKey key) throws PGPException {
    PGPSignatureGenerator sGen = new PGPSignatureGenerator(
        new JcaPGPContentSignerBuilder(signer.getPublicKey().getAlgorithm(),
            PGPUtil.SHA256).setProvider(PROVIDER));
    sGen.init(PGPSignature.PRIMARYKEY_BINDING, signer.getPrivateKey());
    return sGen.generateCertification(key);
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:9,代码来源:PGP.java


示例20: revokeKey

import org.spongycastle.openpgp.PGPPublicKey; //导入依赖的package包/类
/** Revokes the given key. */
public static PGPPublicKey revokeKey(PGPKeyPair secret)
        throws PGPException, IOException, SignatureException {

    PGPPrivateKey pgpPrivKey = secret.getPrivateKey();
    PGPPublicKey pgpPubKey = secret.getPublicKey();

    PGPSignatureGenerator       sGen = new PGPSignatureGenerator(
        new JcaPGPContentSignerBuilder(secret.getPublicKey().getAlgorithm(),
            PGPUtil.SHA256).setProvider(PROVIDER));

    sGen.init(PGPSignature.KEY_REVOCATION, pgpPrivKey);

    return PGPPublicKey.addCertification(pgpPubKey, sGen.generateCertification(pgpPubKey));
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:16,代码来源:PGP.java



注:本文中的org.spongycastle.openpgp.PGPPublicKey类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CytoPanelName类代码示例发布时间:2022-05-22
下一篇:
Java WorldGenSwamp类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap