handle unknown key algorithms using opaque keys
This commit is contained in:
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Vincent Breitmoser <v.breitmoser@mugenguild.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.pgp;
|
||||||
|
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.shadows.ShadowLog;
|
||||||
|
import org.sufficientlysecure.keychain.KeychainTestRunner;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
|
import org.sufficientlysecure.keychain.support.TestDataUtil;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
@RunWith(KeychainTestRunner.class)
|
||||||
|
public class OpaqueKeyTest {
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpOnce() throws Exception {
|
||||||
|
ShadowLog.stream = System.out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOpaqueSubKey__canonicalize__shouldFail() throws Exception {
|
||||||
|
// key from GnuPG's test suite, sample msg generated using GnuPG v2.1.18
|
||||||
|
// TODO use for actual tests once eddsa is supported!
|
||||||
|
UncachedKeyRing ring = readRingFromResource("/test-keys/eddsa-sample-1-pub.asc");
|
||||||
|
|
||||||
|
OperationLog log = new OperationLog();
|
||||||
|
ring.canonicalize(log, 0);
|
||||||
|
|
||||||
|
assertTrue(log.containsType(LogType.MSG_KC_ERROR_MASTER_ALGO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOpaqueSubKey__canonicalize__shouldStrip() throws Exception {
|
||||||
|
UncachedKeyRing ring = readRingFromResource("/test-keys/eddsa-subkey.pub.asc");
|
||||||
|
|
||||||
|
OperationLog log = new OperationLog();
|
||||||
|
CanonicalizedKeyRing canonicalizedKeyRing = ring.canonicalize(log, 0);
|
||||||
|
|
||||||
|
assertNotNull(canonicalizedKeyRing);
|
||||||
|
assertTrue(log.containsType(LogType.MSG_KC_SUB_UNKNOWN_ALGO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOpaqueSubKey__reencode__shouldBeIdentical() throws Exception {
|
||||||
|
byte[] rawKeyData = TestDataUtil.readFully(
|
||||||
|
OpaqueKeyTest.class.getResourceAsStream("/test-keys/eddsa-subkey.pub.asc"));
|
||||||
|
|
||||||
|
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(rawKeyData);
|
||||||
|
|
||||||
|
assertArrayEquals(rawKeyData, ring.getEncoded());
|
||||||
|
}
|
||||||
|
|
||||||
|
UncachedKeyRing readRingFromResource(String name) throws Exception {
|
||||||
|
return UncachedKeyRing.fromStream(OpaqueKeyTest.class.getResourceAsStream(name)).next();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
pub ed25519/97965A9A 2014-08-19
|
||||||
|
Key fingerprint = C959 BDBA FA32 A2F8 9A15 3B67 8CFD E121 9796 5A9A
|
||||||
|
Keygrip = 0DD40284FF992CD24DC4AAC367037E066FCEE26A
|
||||||
|
uid [ unknown] EdDSA sample key 1 (draft-koch-eddsa-for-openpgp-00)
|
||||||
|
|
||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG v2
|
||||||
|
|
||||||
|
mDMEU/NfCxYJKwYBBAHaRw8BAQdAPwmJlL3ZFu1AUxl5NOSofIBzOhKA1i+AEJku
|
||||||
|
Q+47JAa0NEVkRFNBIHNhbXBsZSBrZXkgMSAoZHJhZnQta29jaC1lZGRzYS1mb3It
|
||||||
|
b3BlbnBncC0wMCmIeQQTFggAIQUCU/NfCwIbAwULCQgHAgYVCAkKCwIEFgIDAQIe
|
||||||
|
AQIXgAAKCRCM/eEhl5ZamnNOAP9pKn5wz3jPsgy9p65zxz1+xJEr/cczFQx/tYkk
|
||||||
|
49tkeAD+P9jJE4SFD2lVofxn1e22H7YLvcVyHDOA9gpYWTNXiAU=
|
||||||
|
=Jbi7
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
BIN
OpenKeychain/src/test/resources/test-keys/eddsa-subkey.pub.asc
Normal file
BIN
OpenKeychain/src/test/resources/test-keys/eddsa-subkey.pub.asc
Normal file
Binary file not shown.
BIN
OpenKeychain/src/test/resources/test-keys/eddsa-subkey.sec.asc
Normal file
BIN
OpenKeychain/src/test/resources/test-keys/eddsa-subkey.sec.asc
Normal file
Binary file not shown.
2
extern/bouncycastle
vendored
2
extern/bouncycastle
vendored
Submodule extern/bouncycastle updated: 0e2e96778b...3153790edf
Reference in New Issue
Block a user