2021-10-07 15:48:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-01-03 17:01:08 +01:00
|
|
|
package org.pgpainless.key.generation;
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
|
|
2021-12-14 16:55:04 +01:00
|
|
|
import org.junit.jupiter.api.TestTemplate;
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
2021-01-03 17:01:08 +01:00
|
|
|
import org.pgpainless.algorithm.KeyFlag;
|
|
|
|
import org.pgpainless.key.generation.type.KeyType;
|
2024-02-21 14:57:02 +01:00
|
|
|
import org.pgpainless.key.generation.type.eddsa_legacy.EdDSALegacyCurve;
|
2024-02-21 15:19:33 +01:00
|
|
|
import org.pgpainless.key.generation.type.xdh_legacy.XDHLegacySpec;
|
2021-12-14 16:56:29 +01:00
|
|
|
import org.pgpainless.util.TestAllImplementations;
|
2021-01-03 17:01:08 +01:00
|
|
|
|
|
|
|
public class IllegalKeyFlagsTest {
|
|
|
|
|
2021-12-14 16:55:04 +01:00
|
|
|
@TestTemplate
|
2021-12-14 16:56:29 +01:00
|
|
|
@ExtendWith(TestAllImplementations.class)
|
2021-12-14 16:55:04 +01:00
|
|
|
public void testKeyCannotCarryFlagsTest() {
|
2021-09-13 19:20:19 +02:00
|
|
|
assertThrows(IllegalArgumentException.class, () -> KeySpec.getBuilder(
|
2024-02-21 15:19:33 +01:00
|
|
|
KeyType.XDH_LEGACY(XDHLegacySpec._X25519), KeyFlag.SIGN_DATA));
|
2021-09-13 19:20:19 +02:00
|
|
|
|
|
|
|
assertThrows(IllegalArgumentException.class, () -> KeySpec.getBuilder(
|
2024-02-21 15:19:33 +01:00
|
|
|
KeyType.XDH_LEGACY(XDHLegacySpec._X25519), KeyFlag.CERTIFY_OTHER));
|
2021-09-13 19:20:19 +02:00
|
|
|
|
|
|
|
assertThrows(IllegalArgumentException.class, () -> KeySpec.getBuilder(
|
2024-02-21 15:19:33 +01:00
|
|
|
KeyType.XDH_LEGACY(XDHLegacySpec._X25519), KeyFlag.AUTHENTICATION));
|
2021-09-13 19:20:19 +02:00
|
|
|
|
|
|
|
assertThrows(IllegalArgumentException.class, () -> KeySpec.getBuilder(
|
2024-02-21 14:57:02 +01:00
|
|
|
KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), KeyFlag.ENCRYPT_COMMS));
|
2021-09-13 19:20:19 +02:00
|
|
|
|
|
|
|
assertThrows(IllegalArgumentException.class, () -> KeySpec.getBuilder(
|
2024-02-21 14:57:02 +01:00
|
|
|
KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), KeyFlag.ENCRYPT_STORAGE));
|
2021-01-03 17:01:08 +01:00
|
|
|
}
|
|
|
|
}
|