mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
Merge branch 'master' into development
Conflicts: OpenKeychain/src/main/res/values/strings.xml
This commit is contained in:
commit
40703fe961
@ -100,6 +100,14 @@ public class PgpKeyOperationTest {
|
|||||||
|
|
||||||
parcel.mAddUserIds.add("twi");
|
parcel.mAddUserIds.add("twi");
|
||||||
parcel.mAddUserIds.add("pink");
|
parcel.mAddUserIds.add("pink");
|
||||||
|
|
||||||
|
{
|
||||||
|
int type = 42;
|
||||||
|
byte[] data = new byte[] { 0, 1, 2, 3, 4 };
|
||||||
|
WrappedUserAttribute uat = WrappedUserAttribute.fromSubpacket(type, data);
|
||||||
|
parcel.mAddUserAttribute.add(uat);
|
||||||
|
}
|
||||||
|
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
@ -232,6 +240,17 @@ public class PgpKeyOperationTest {
|
|||||||
Assert.assertEquals("number of user ids must be two",
|
Assert.assertEquals("number of user ids must be two",
|
||||||
2, ring.getPublicKey().getUnorderedUserIds().size());
|
2, ring.getPublicKey().getUnorderedUserIds().size());
|
||||||
|
|
||||||
|
ArrayList<WrappedUserAttribute> attributes =
|
||||||
|
ring.getPublicKey().getUnorderedUserAttributes();
|
||||||
|
Assert.assertEquals("number of user attributes must be one",
|
||||||
|
1, attributes.size());
|
||||||
|
Assert.assertEquals("user attribute must be correct type",
|
||||||
|
42, attributes.get(0).getType());
|
||||||
|
Assert.assertEquals("user attribute must have one subpacket",
|
||||||
|
1, attributes.get(0).getSubpackets().length);
|
||||||
|
Assert.assertArrayEquals("user attribute must have correct data",
|
||||||
|
new byte[] { 0, 1, 2, 3, 4 }, attributes.get(0).getSubpackets()[0]);
|
||||||
|
|
||||||
List<UncachedPublicKey> subkeys = KeyringTestingHelper.itToList(ring.getPublicKeys());
|
List<UncachedPublicKey> subkeys = KeyringTestingHelper.itToList(ring.getPublicKeys());
|
||||||
Assert.assertEquals("number of subkeys must be three", 3, subkeys.size());
|
Assert.assertEquals("number of subkeys must be three", 3, subkeys.size());
|
||||||
|
|
||||||
|
@ -618,7 +618,8 @@ public class PgpKeyOperation {
|
|||||||
PGPSignature cert = generateUserAttributeSignature(
|
PGPSignature cert = generateUserAttributeSignature(
|
||||||
getSignatureGenerator(masterSecretKey, cryptoInput),
|
getSignatureGenerator(masterSecretKey, cryptoInput),
|
||||||
cryptoInput.getSignatureTime(),
|
cryptoInput.getSignatureTime(),
|
||||||
masterPrivateKey, masterPublicKey, vector);
|
masterPrivateKey, masterPublicKey, vector,
|
||||||
|
masterKeyFlags, masterKeyExpiry);
|
||||||
modifiedPublicKey = PGPPublicKey.addCertification(modifiedPublicKey, vector, cert);
|
modifiedPublicKey = PGPPublicKey.addCertification(modifiedPublicKey, vector, cert);
|
||||||
} catch (NfcInteractionNeeded e) {
|
} catch (NfcInteractionNeeded e) {
|
||||||
nfcSignOps.addHash(e.hashToSign, e.hashAlgo);
|
nfcSignOps.addHash(e.hashToSign, e.hashAlgo);
|
||||||
@ -1409,11 +1410,9 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PGPSignature generateUserIdSignature(
|
private static PGPSignatureSubpacketGenerator generateHashedSelfSigSubpackets(
|
||||||
PGPSignatureGenerator sGen, Date creationTime,
|
Date creationTime, PGPPublicKey pKey, boolean primary, int flags, long expiry
|
||||||
PGPPrivateKey masterPrivateKey, PGPPublicKey pKey, String userId, boolean primary,
|
) {
|
||||||
int flags, long expiry)
|
|
||||||
throws IOException, PGPException, SignatureException {
|
|
||||||
|
|
||||||
PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator();
|
PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator();
|
||||||
{
|
{
|
||||||
@ -1447,6 +1446,17 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return hashedPacketsGen;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PGPSignature generateUserIdSignature(
|
||||||
|
PGPSignatureGenerator sGen, Date creationTime,
|
||||||
|
PGPPrivateKey masterPrivateKey, PGPPublicKey pKey, String userId, boolean primary,
|
||||||
|
int flags, long expiry)
|
||||||
|
throws IOException, PGPException, SignatureException {
|
||||||
|
|
||||||
|
PGPSignatureSubpacketGenerator hashedPacketsGen =
|
||||||
|
generateHashedSelfSigSubpackets(creationTime, pKey, primary, flags, expiry);
|
||||||
sGen.setHashedSubpackets(hashedPacketsGen.generate());
|
sGen.setHashedSubpackets(hashedPacketsGen.generate());
|
||||||
sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey);
|
sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey);
|
||||||
return sGen.generateCertification(userId, pKey);
|
return sGen.generateCertification(userId, pKey);
|
||||||
@ -1455,15 +1465,12 @@ public class PgpKeyOperation {
|
|||||||
private static PGPSignature generateUserAttributeSignature(
|
private static PGPSignature generateUserAttributeSignature(
|
||||||
PGPSignatureGenerator sGen, Date creationTime,
|
PGPSignatureGenerator sGen, Date creationTime,
|
||||||
PGPPrivateKey masterPrivateKey, PGPPublicKey pKey,
|
PGPPrivateKey masterPrivateKey, PGPPublicKey pKey,
|
||||||
PGPUserAttributeSubpacketVector vector)
|
PGPUserAttributeSubpacketVector vector,
|
||||||
|
int flags, long expiry)
|
||||||
throws IOException, PGPException, SignatureException {
|
throws IOException, PGPException, SignatureException {
|
||||||
|
|
||||||
PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator();
|
PGPSignatureSubpacketGenerator hashedPacketsGen =
|
||||||
{
|
generateHashedSelfSigSubpackets(creationTime, pKey, false, flags, expiry);
|
||||||
/* critical subpackets: we consider those important for a modern pgp implementation */
|
|
||||||
hashedPacketsGen.setSignatureCreationTime(true, creationTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
sGen.setHashedSubpackets(hashedPacketsGen.generate());
|
sGen.setHashedSubpackets(hashedPacketsGen.generate());
|
||||||
sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey);
|
sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey);
|
||||||
return sGen.generateCertification(vector, pKey);
|
return sGen.generateCertification(vector, pKey);
|
||||||
|
Loading…
Reference in New Issue
Block a user