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

Java PGPException类代码示例

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

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



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

示例1: findSecretKey

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
public static PGPPrivateKey findSecretKey(PGPSecretKeyRingCollection pgpSec, long keyID, char[] pass)
        throws PGPException, NoSuchProviderException
{
    PGPSecretKey pgpSecKey = pgpSec.getSecretKey(keyID);
    PGPPrivateKey x;
    if (pgpSecKey == null)
    {
        return null;
    }

    try{
        Log.d("decrypt", "findSecretKey: fixing something");
       x =pgpSecKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(pass));
    }catch (Exception ex){
        ex.printStackTrace();
        return null;
    }
    return x;
}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:20,代码来源:KeyManagement.java


示例2: fillKeyDetails

import org.spongycastle.openpgp.PGPException; //导入依赖的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


示例3: generateKeyRingGenerator

import org.spongycastle.openpgp.PGPException; //导入依赖的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


示例4: verifySignature

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
public static boolean verifySignature(
        String fileName,
        String inputFileName,
        String keyFileName)
        throws GeneralSecurityException, IOException, PGPException
{
    InputStream in = new BufferedInputStream(new FileInputStream(inputFileName));
    InputStream keyIn = new BufferedInputStream(new FileInputStream(keyFileName));

    boolean result = verifySignature(fileName, in, keyIn);

    keyIn.close();
    in.close();

    return result;
}
 
开发者ID:guardianproject,项目名称:proofmode,代码行数:17,代码来源:DetachedSignatureProcessor.java


示例5: encrypt

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
public String encrypt(String plainText) throws NoSuchAlgorithmException, IOException, PGPException {
    byte[] rawText = plainText.getBytes();
    //This needs, like, three metric fucktons of explanation and/or cleaning up
    ByteArrayOutputStream encOut = new ByteArrayOutputStream();
    OutputStream out = new ArmoredOutputStream(encOut);
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(PGPCompressedData.ZIP);
    OutputStream cos = comData.open(bOut);
    PGPLiteralDataGenerator lData = new PGPLiteralDataGenerator();
    OutputStream pOut = lData.open(cos, PGPLiteralData.BINARY, PGPLiteralData.CONSOLE, rawText.length, new Date());
    pOut.write(rawText);
    lData.close();
    comData.close();
    BcPGPDataEncryptorBuilder builder = new BcPGPDataEncryptorBuilder(PGPEncryptedData.AES_256);
    builder.setWithIntegrityPacket(true);
    builder.setSecureRandom(new SecureRandom());
    PGPEncryptedDataGenerator cpk = new PGPEncryptedDataGenerator(builder);
    cpk.addMethod(new BcPublicKeyKeyEncryptionMethodGenerator(publicKey));
    byte[] bytes = bOut.toByteArray();
    OutputStream cOut = cpk.open(out, bytes.length);
    cOut.write(bytes);
    cOut.close();
    out.close();
    return new String(encOut.toByteArray(), Charset.forName("UTF-8"));
}
 
开发者ID:TpmKranz,项目名称:SMS-Forward,代码行数:26,代码来源:PGPPubkeyEncryptionUtil.java


示例6: readPublicKeyFromCol

import org.spongycastle.openpgp.PGPException; //导入依赖的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


示例7: loadDefaultPersonalKey

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
public static PersonalKey loadDefaultPersonalKey(Context ctx, String passphrase)
        throws PGPException, IOException, CertificateException, NoSuchProviderException {
    AccountManager m = AccountManager.get(ctx);
    Account acc = getDefaultAccount(m);

    String privKeyData = m.getUserData(acc, DATA_PRIVATEKEY);
    String pubKeyData = m.getUserData(acc, DATA_PUBLICKEY);
    String bridgeCertData = m.getUserData(acc, DATA_BRIDGECERT);

    if (privKeyData != null && pubKeyData != null && bridgeCertData != null)
        return PersonalKey
            .load(Base64.decode(privKeyData, Base64.DEFAULT),
                  Base64.decode(pubKeyData, Base64.DEFAULT),
                  passphrase,
                  Base64.decode(bridgeCertData, Base64.DEFAULT)
            );

    else
        return null;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:21,代码来源:Authenticator.java


示例8: exportDefaultPersonalKey

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
public static void exportDefaultPersonalKey(Context ctx, OutputStream dest, String passphrase, String exportPassphrase, boolean bridgeCertificate)
        throws CertificateException, NoSuchProviderException, PGPException,
            IOException, KeyStoreException, NoSuchAlgorithmException {

    AccountManager m = AccountManager.get(ctx);
    Account acc = getDefaultAccount(m);

    String privKeyData = m.getUserData(acc, DATA_PRIVATEKEY);
    byte[] privateKey = Base64.decode(privKeyData, Base64.DEFAULT);
    byte[] bridgeCert = null;

    if (bridgeCertificate) {
        // bridge certificate is just plain data
        String bridgeCertData = m.getUserData(acc, DATA_BRIDGECERT);
        bridgeCert = Base64.decode(bridgeCertData, Base64.DEFAULT);
    }

    String pubKeyData = m.getUserData(acc, DATA_PUBLICKEY);
    byte[] publicKey = Base64.decode(pubKeyData, Base64.DEFAULT);

    // trusted keys
    Map<String, Keyring.TrustedFingerprint> trustedKeys = Keyring.getTrustedKeys(ctx);

    PersonalKeyExporter exp = new PersonalKeyExporter();
    exp.save(privateKey, publicKey, dest, passphrase, exportPassphrase, bridgeCert, trustedKeys, acc.name);
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:27,代码来源:Authenticator.java


示例9: initConnection

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
private void initConnection() throws XMPPException, SmackException,
        PGPException, KeyStoreException, NoSuchProviderException,
        NoSuchAlgorithmException, CertificateException,
        IOException, InterruptedException {

    if (!mConnector.isConnected() || mConnector.isServerDirty()) {
        mConnector.setListener(this);
        PersonalKey key = null;
        if (mImportedPrivateKey != null && mImportedPublicKey != null) {
            PGPKeyPairRing ring;
            try {
                ring = PGPKeyPairRing.loadArmored(mImportedPrivateKey, mImportedPublicKey);
            }
            catch (IOException e) {
                // try not armored
                ring = PGPKeyPairRing.load(mImportedPrivateKey, mImportedPublicKey);
            }
            key = PersonalKey.load(ring.secretKey, ring.publicKey, mPassphrase, mBridgeCert);
        }
        else if (mKey != null) {
            key = mKey.copy(mBridgeCert);
        }

        mConnector.connectOnce(key, mStep == STEP_LOGIN_TEST);
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:27,代码来源:NumberValidator.java


示例10: convertPrivateKey

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static PrivateKey convertPrivateKey(byte[] privateKeyData, String passphrase)
        throws PGPException, IOException {

    PGPDigestCalculatorProvider digestCalc = new JcaPGPDigestCalculatorProviderBuilder().build();
    PBESecretKeyDecryptor decryptor = new JcePBESecretKeyDecryptorBuilder(digestCalc)
        .setProvider(PGP.PROVIDER)
        .build(passphrase.toCharArray());

    // load the secret key ring
    PGPSecretKeyRing secRing = new PGPSecretKeyRing(privateKeyData, sFingerprintCalculator);

    // search and decrypt the master (signing key)
    // secret keys
    Iterator<PGPSecretKey> skeys = secRing.getSecretKeys();
    while (skeys.hasNext()) {
        PGPSecretKey key = skeys.next();
        PGPSecretKey sec = secRing.getSecretKey();

        if (key.isMasterKey())
            return convertPrivateKey(sec.extractPrivateKey(decryptor));
    }

    throw new PGPException("no suitable private key found.");
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:26,代码来源:PGP.java


示例11: createCertificate

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
public static X509Certificate createCertificate(byte[] privateKeyData, byte[] publicKeyData, String passphrase)
    throws PGPException, IOException, InvalidKeyException, IllegalStateException,
    NoSuchAlgorithmException, SignatureException, CertificateException, NoSuchProviderException, OperatorCreationException {

    PGPSecretKeyRing secRing = new PGPSecretKeyRing(privateKeyData, sFingerprintCalculator);
    PGPPublicKeyRing pubRing = new PGPPublicKeyRing(publicKeyData, sFingerprintCalculator);

    PGPDigestCalculatorProvider sha1Calc = new JcaPGPDigestCalculatorProviderBuilder().build();
    PBESecretKeyDecryptor decryptor = new JcePBESecretKeyDecryptorBuilder(sha1Calc)
        .setProvider(PGP.PROVIDER)
        .build(passphrase.toCharArray());

    // secret key
    PGPSecretKey secKey = secRing.getSecretKey();

    return createCertificate(pubRing, secKey.extractPrivateKey(decryptor));
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:18,代码来源:X509Bridge.java


示例12: updateAccountManager

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
/** Stores the public keyring to the system {@link AccountManager}. */
public void updateAccountManager(Context context)
        throws IOException, CertificateEncodingException, InvalidKeyException,
        IllegalStateException, NoSuchAlgorithmException, SignatureException,
        CertificateException, NoSuchProviderException, PGPException {

    AccountManager am = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
    Account account = Authenticator.getDefaultAccount(am);

    if (account != null) {
        PGPPublicKeyRing pubRing = getPublicKeyRing();

        // regenerate bridge certificate
        byte[] bridgeCertData = X509Bridge.createCertificate(pubRing,
                mPair.signKey.getPrivateKey(), null).getEncoded();
        byte[] publicKeyData = pubRing.getEncoded();

        am.setUserData(account, Authenticator.DATA_PUBLICKEY,
            Base64.encodeToString(publicKeyData, Base64.NO_WRAP));
        am.setUserData(account, Authenticator.DATA_BRIDGECERT,
                Base64.encodeToString(bridgeCertData, Base64.NO_WRAP));
    }
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:24,代码来源:PersonalKey.java


示例13: updateAccountManager

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
/** Stores the public keyring to the system {@link AccountManager}. */
public void updateAccountManager(Context context)
    throws IOException, InvalidKeyException,
    IllegalStateException, NoSuchAlgorithmException, SignatureException,
    CertificateException, NoSuchProviderException, PGPException, OperatorCreationException {

    AccountManager am = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
    Account account = Authenticator.getDefaultAccount(am);

    if (account != null) {
        PGPPublicKeyRing pubRing = getPublicKeyRing();

        // regenerate bridge certificate
        byte[] bridgeCertData = X509Bridge.createCertificate(pubRing,
                mPair.authKey.getPrivateKey()).getEncoded();
        byte[] publicKeyData = pubRing.getEncoded();

        am.setUserData(account, Authenticator.DATA_PUBLICKEY,
            Base64.encodeToString(publicKeyData, Base64.NO_WRAP));
        am.setUserData(account, Authenticator.DATA_BRIDGECERT,
                Base64.encodeToString(bridgeCertData, Base64.NO_WRAP));
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:24,代码来源:PersonalKey.java


示例14: signPublicKey

import org.spongycastle.openpgp.PGPException; //导入依赖的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


示例15: setKey

import org.spongycastle.openpgp.PGPException; //导入依赖的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


示例16: store

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
/** Creates public and secret keyring for a given keypair. */
public static PGPKeyPairRing store(PGPDecryptedKeyPairRing pair,
        String id,
        String passphrase)
            throws PGPException {

    PGPDigestCalculator sha1Calc = new JcaPGPDigestCalculatorProviderBuilder().build().get(HashAlgorithmTags.SHA1);
    PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, pair.signKey,
        id, sha1Calc, null, null,
        new JcaPGPContentSignerBuilder(pair.signKey.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1),
        new JcePBESecretKeyEncryptorBuilder(PGPEncryptedData.AES_256, sha1Calc)
            .setProvider(PROVIDER).build(passphrase.toCharArray()));

    keyRingGen.addSubKey(pair.encryptKey);

    PGPSecretKeyRing secRing = keyRingGen.generateSecretKeyRing();
    PGPPublicKeyRing pubRing = keyRingGen.generatePublicKeyRing();

    return new PGPKeyPairRing(pubRing, secRing);
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:21,代码来源:PGP.java


示例17: fromParcel

import org.spongycastle.openpgp.PGPException; //导入依赖的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


示例18: toParcel

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
public static void toParcel(PGPDecryptedKeyPairRing pair, Parcel dest)
        throws NoSuchProviderException, PGPException {

    PrivateKey privSign = convertPrivateKey(pair.signKey.getPrivateKey());
    PublicKey pubSign = convertPublicKey(pair.signKey.getPublicKey());
    int algoSign = pair.signKey.getPrivateKey().getPublicKeyPacket().getAlgorithm();
    Date dateSign = pair.signKey.getPrivateKey().getPublicKeyPacket().getTime();

    PrivateKey privEnc = convertPrivateKey(pair.encryptKey.getPrivateKey());
    PublicKey pubEnc = convertPublicKey(pair.encryptKey.getPublicKey());
    int algoEnc = pair.encryptKey.getPrivateKey().getPublicKeyPacket().getAlgorithm();
    Date dateEnc = pair.encryptKey.getPrivateKey().getPublicKeyPacket().getTime();

    dest.writeSerializable(privSign);
    dest.writeSerializable(pubSign);
    dest.writeInt(algoSign);
    dest.writeLong(dateSign.getTime());

    dest.writeSerializable(privEnc);
    dest.writeSerializable(pubEnc);
    dest.writeInt(algoEnc);
    dest.writeLong(dateEnc.getTime());

}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:25,代码来源:PGP.java


示例19: store

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
public PGPKeyPairRing store(String name, String email, String comment, String passphrase) throws PGPException {
    // name[ (comment)] <[email]>
    StringBuilder userid = new StringBuilder(name);

    if (comment != null) userid
        .append(" (")
        .append(comment)
        .append(')');

    userid.append(" <");
    if (email != null)
        userid.append(email);
    userid.append('>');

    return PGP.store(mPair, userid.toString(), passphrase);
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:17,代码来源:PersonalKey.java


示例20: convertPrivateKey

import org.spongycastle.openpgp.PGPException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static PrivateKey convertPrivateKey(byte[] privateKeyData, String passphrase)
        throws PGPException, IOException {

    PGPDigestCalculatorProvider sha1Calc = new JcaPGPDigestCalculatorProviderBuilder().build();
    PBESecretKeyDecryptor decryptor = new JcePBESecretKeyDecryptorBuilder(sha1Calc)
        .setProvider(PGP.PROVIDER)
        .build(passphrase.toCharArray());

    // load the secret key ring
    KeyFingerPrintCalculator fpr = new BcKeyFingerprintCalculator();
    PGPSecretKeyRing secRing = new PGPSecretKeyRing(privateKeyData, fpr);

    // search and decrypt the master (signing key)
    // secret keys
    Iterator<PGPSecretKey> skeys = secRing.getSecretKeys();
    while (skeys.hasNext()) {
        PGPSecretKey key = skeys.next();
        PGPSecretKey sec = secRing.getSecretKey();

        if (key.isMasterKey())
            return convertPrivateKey(sec.extractPrivateKey(decryptor));
    }

    throw new PGPException("no suitable private key found.");
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:27,代码来源:PGP.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java CanSetDropBehind类代码示例发布时间:2022-05-22
下一篇:
Java FacebookException类代码示例发布时间: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