List of usage examples for org.bouncycastle.bcpg S2K GNU_PROTECTION_MODE_NO_PRIVATE_KEY
int GNU_PROTECTION_MODE_NO_PRIVATE_KEY
To view the source code for org.bouncycastle.bcpg S2K GNU_PROTECTION_MODE_NO_PRIVATE_KEY.
Click Source Link
From source file:org.sufficientlysecure.keychain.pgp.PgpKeyOperationTest.java
License:Open Source License
@Test public void testRestrictedStrip() throws Exception { long keyId = KeyringTestingHelper.getSubkeyId(ring, 1); UncachedKeyRing modified;/* w w w. ja v a2 s . co m*/ { // we should be able to change the stripped status of subkeys without passphrase parcel.reset(); parcel.mChangeSubKeys.add(new SubkeyChange(keyId, true, false)); modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB, new CryptoInputParcel()); Assert.assertEquals("one extra packet in modified", 1, onlyB.size()); Packet p = new BCPGInputStream(new ByteArrayInputStream(onlyB.get(0).buf)).readPacket(); Assert.assertEquals("new packet should have GNU_DUMMY S2K type", S2K.GNU_DUMMY_S2K, ((SecretKeyPacket) p).getS2K().getType()); Assert.assertEquals("new packet should have GNU_DUMMY protection mode stripped", S2K.GNU_PROTECTION_MODE_NO_PRIVATE_KEY, ((SecretKeyPacket) p).getS2K().getProtectionMode()); } { // trying to edit a subkey with signing capability should fail parcel.reset(); parcel.mChangeSubKeys.add(new SubkeyChange(keyId, true)); assertModifyFailure("subkey modification for signing-enabled but stripped subkey should fail", modified, parcel, LogType.MSG_MF_ERROR_SUB_STRIPPED); } }