mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-22 22:03:45 -05:00
support addition of user attributes
This commit is contained in:
parent
9fe701c866
commit
ea72b29f2d
@ -495,6 +495,8 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_MF_UID_PRIMARY (LogLevel.INFO, R.string.msg_mf_uid_primary),
|
||||
MSG_MF_UID_REVOKE (LogLevel.INFO, R.string.msg_mf_uid_revoke),
|
||||
MSG_MF_UID_ERROR_EMPTY (LogLevel.ERROR, R.string.msg_mf_uid_error_empty),
|
||||
MSG_MF_UAT_ADD_IMAGE (LogLevel.INFO, R.string.msg_mf_uat_add_image),
|
||||
MSG_MF_UAT_ADD_UNKNOWN (LogLevel.INFO, R.string.msg_mf_uat_add_unknown),
|
||||
MSG_MF_UNLOCK_ERROR (LogLevel.ERROR, R.string.msg_mf_unlock_error),
|
||||
MSG_MF_UNLOCK (LogLevel.DEBUG, R.string.msg_mf_unlock),
|
||||
|
||||
|
@ -34,6 +34,7 @@ import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.spongycastle.openpgp.PGPSignature;
|
||||
import org.spongycastle.openpgp.PGPSignatureGenerator;
|
||||
import org.spongycastle.openpgp.PGPSignatureSubpacketGenerator;
|
||||
import org.spongycastle.openpgp.PGPUserAttributeSubpacketVector;
|
||||
import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor;
|
||||
import org.spongycastle.openpgp.operator.PBESecretKeyEncryptor;
|
||||
import org.spongycastle.openpgp.operator.PGPContentSignerBuilder;
|
||||
@ -478,7 +479,7 @@ public class PgpKeyOperation {
|
||||
PGPPublicKey modifiedPublicKey = masterPublicKey;
|
||||
|
||||
// 2a. Add certificates for new user ids
|
||||
subProgressPush(15, 25);
|
||||
subProgressPush(15, 23);
|
||||
for (int i = 0; i < saveParcel.mAddUserIds.size(); i++) {
|
||||
|
||||
progress(R.string.progress_modify_adduid, (i - 1) * (100 / saveParcel.mAddUserIds.size()));
|
||||
@ -522,8 +523,33 @@ public class PgpKeyOperation {
|
||||
}
|
||||
subProgressPop();
|
||||
|
||||
// 2b. Add revocations for revoked user ids
|
||||
subProgressPush(25, 40);
|
||||
// 2b. Add certificates for new user ids
|
||||
subProgressPush(23, 32);
|
||||
for (int i = 0; i < saveParcel.mAddUserAttribute.size(); i++) {
|
||||
|
||||
progress(R.string.progress_modify_adduat, (i - 1) * (100 / saveParcel.mAddUserAttribute.size()));
|
||||
WrappedUserAttribute attribute = saveParcel.mAddUserAttribute.get(i);
|
||||
|
||||
switch (attribute.getType()) {
|
||||
case WrappedUserAttribute.UAT_UNKNOWN:
|
||||
log.add(LogType.MSG_MF_UAT_ADD_UNKNOWN, indent);
|
||||
break;
|
||||
case WrappedUserAttribute.UAT_IMAGE:
|
||||
log.add(LogType.MSG_MF_UAT_ADD_IMAGE, indent);
|
||||
break;
|
||||
}
|
||||
|
||||
PGPUserAttributeSubpacketVector vector = attribute.getVector();
|
||||
|
||||
// generate and add new certificate
|
||||
PGPSignature cert = generateUserAttributeSignature(masterPrivateKey,
|
||||
masterPublicKey, vector);
|
||||
modifiedPublicKey = PGPPublicKey.addCertification(modifiedPublicKey, vector, cert);
|
||||
}
|
||||
subProgressPop();
|
||||
|
||||
// 2c. Add revocations for revoked user ids
|
||||
subProgressPush(32, 40);
|
||||
for (int i = 0; i < saveParcel.mRevokeUserIds.size(); i++) {
|
||||
|
||||
progress(R.string.progress_modify_revokeuid, (i - 1) * (100 / saveParcel.mRevokeUserIds.size()));
|
||||
@ -1174,6 +1200,26 @@ public class PgpKeyOperation {
|
||||
return sGen.generateCertification(userId, pKey);
|
||||
}
|
||||
|
||||
private static PGPSignature generateUserAttributeSignature(
|
||||
PGPPrivateKey masterPrivateKey, PGPPublicKey pKey,
|
||||
PGPUserAttributeSubpacketVector vector)
|
||||
throws IOException, PGPException, SignatureException {
|
||||
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
|
||||
masterPrivateKey.getPublicKeyPacket().getAlgorithm(), HashAlgorithmTags.SHA512)
|
||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
||||
PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder);
|
||||
|
||||
PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator();
|
||||
{
|
||||
/* critical subpackets: we consider those important for a modern pgp implementation */
|
||||
hashedPacketsGen.setSignatureCreationTime(true, new Date());
|
||||
}
|
||||
|
||||
sGen.setHashedSubpackets(hashedPacketsGen.generate());
|
||||
sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey);
|
||||
return sGen.generateCertification(vector, pKey);
|
||||
}
|
||||
|
||||
private static PGPSignature generateRevocationSignature(
|
||||
PGPPrivateKey masterPrivateKey, PGPPublicKey pKey, String userId)
|
||||
throws IOException, PGPException, SignatureException {
|
||||
|
@ -21,6 +21,7 @@ package org.sufficientlysecure.keychain.service;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
||||
import org.sufficientlysecure.keychain.pgp.affirmation.LinkedIdentity;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -51,7 +52,7 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
public ChangeUnlockParcel mNewUnlock;
|
||||
|
||||
public ArrayList<String> mAddUserIds;
|
||||
public ArrayList<LinkedIdentity> mAddLinkedIdentity;
|
||||
public ArrayList<WrappedUserAttribute> mAddUserAttribute;
|
||||
public ArrayList<SubkeyAdd> mAddSubKeys;
|
||||
|
||||
public ArrayList<SubkeyChange> mChangeSubKeys;
|
||||
@ -74,7 +75,7 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
public void reset() {
|
||||
mNewUnlock = null;
|
||||
mAddUserIds = new ArrayList<String>();
|
||||
mAddLinkedIdentity = new ArrayList<LinkedIdentity>();
|
||||
mAddUserAttribute = new ArrayList<WrappedUserAttribute>();
|
||||
mAddSubKeys = new ArrayList<SubkeyAdd>();
|
||||
mChangePrimaryUserId = null;
|
||||
mChangeSubKeys = new ArrayList<SubkeyChange>();
|
||||
@ -166,7 +167,7 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
mNewUnlock = source.readParcelable(getClass().getClassLoader());
|
||||
|
||||
mAddUserIds = source.createStringArrayList();
|
||||
mAddLinkedIdentity = (ArrayList<LinkedIdentity>) source.readSerializable();
|
||||
mAddUserAttribute = (ArrayList<WrappedUserAttribute>) source.readSerializable();
|
||||
mAddSubKeys = (ArrayList<SubkeyAdd>) source.readSerializable();
|
||||
|
||||
mChangeSubKeys = (ArrayList<SubkeyChange>) source.readSerializable();
|
||||
@ -189,7 +190,7 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
destination.writeParcelable(mNewUnlock, 0);
|
||||
|
||||
destination.writeStringList(mAddUserIds);
|
||||
destination.writeSerializable(mAddLinkedIdentity);
|
||||
destination.writeSerializable(mAddUserAttribute);
|
||||
destination.writeSerializable(mAddSubKeys);
|
||||
|
||||
destination.writeSerializable(mChangeSubKeys);
|
||||
@ -220,7 +221,7 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
String out = "mMasterKeyId: " + mMasterKeyId + "\n";
|
||||
out += "mNewUnlock: " + mNewUnlock + "\n";
|
||||
out += "mAddUserIds: " + mAddUserIds + "\n";
|
||||
out += "mAddLinkedIdentity: " + mAddLinkedIdentity + "\n";
|
||||
out += "mAddUserAttribute: " + mAddUserAttribute + "\n";
|
||||
out += "mAddSubKeys: " + mAddSubKeys + "\n";
|
||||
out += "mChangeSubKeys: " + mChangeSubKeys + "\n";
|
||||
out += "mChangePrimaryUserId: " + mChangePrimaryUserId + "\n";
|
||||
|
@ -310,6 +310,7 @@
|
||||
|
||||
<string name="progress_modify_unlock">"unlocking keyring…"</string>
|
||||
<string name="progress_modify_adduid">"adding user IDs…"</string>
|
||||
<string name="progress_modify_adduat">"adding user attributes…"</string>
|
||||
<string name="progress_modify_revokeuid">"revoking user IDs…"</string>
|
||||
<string name="progress_modify_primaryuid">"changing primary user ID…"</string>
|
||||
<string name="progress_modify_subkeychange">"modifying subkeys…"</string>
|
||||
@ -840,6 +841,8 @@
|
||||
<string name="msg_mf_uid_primary">"Changing primary user ID to %s"</string>
|
||||
<string name="msg_mf_uid_revoke">"Revoking user ID %s"</string>
|
||||
<string name="msg_mf_uid_error_empty">"User ID must not be empty!"</string>
|
||||
<string name="msg_mf_uat_add_image">"Adding user attribute of type image"</string>
|
||||
<string name="msg_mf_uat_add_unknown">"Adding user attribute of unknown type"</string>
|
||||
<string name="msg_mf_unlock_error">"Error unlocking keyring!"</string>
|
||||
<string name="msg_mf_unlock">"Unlocking keyring"</string>
|
||||
|
||||
@ -1138,7 +1141,7 @@
|
||||
<string name="aff_create_https_2_1">"A proof file for this URI has been created:"</string>
|
||||
<string name="aff_create_https_2_2">"For the next step, you should save and upload this file."</string>
|
||||
<string name="aff_create_https_2_3">"Make sure the file is reachable at the correct URI, then verify your setup."</string>
|
||||
<string name="aff_create_https_2_4">"After verification is successful, hit next to finish the process."</string>
|
||||
<string name="aff_create_https_2_4">"After verification is successful, hit next to add the linked identity to your keyring and finish the process."</string>
|
||||
<string name="linked_id_generic_text">"This file claims ownership of the OpenPGP key with long id %2$s.\n\nCookie for proof:\n%1$s"</string>
|
||||
<string name="linked_verifying">Verifying…</string>
|
||||
<string name="linked_verify_success">Verification successful!</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user