001// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org> 002// 003// SPDX-License-Identifier: Apache-2.0 004 005package org.pgpainless.key.generation; 006 007import javax.annotation.Nonnull; 008 009import org.bouncycastle.openpgp.PGPSignatureSubpacketVector; 010import org.pgpainless.algorithm.KeyFlag; 011import org.pgpainless.key.generation.type.KeyType; 012import org.pgpainless.signature.subpackets.SignatureSubpackets; 013import org.pgpainless.signature.subpackets.SignatureSubpacketsHelper; 014 015public class KeySpec { 016 017 private final KeyType keyType; 018 private final SignatureSubpackets subpacketGenerator; 019 private final boolean inheritedSubPackets; 020 021 KeySpec(@Nonnull KeyType type, 022 @Nonnull SignatureSubpackets subpacketGenerator, 023 boolean inheritedSubPackets) { 024 this.keyType = type; 025 this.subpacketGenerator = subpacketGenerator; 026 this.inheritedSubPackets = inheritedSubPackets; 027 } 028 029 @Nonnull 030 public KeyType getKeyType() { 031 return keyType; 032 } 033 034 @Nonnull 035 public PGPSignatureSubpacketVector getSubpackets() { 036 return SignatureSubpacketsHelper.toVector(subpacketGenerator); 037 } 038 039 @Nonnull 040 public SignatureSubpackets getSubpacketGenerator() { 041 return subpacketGenerator; 042 } 043 044 boolean isInheritedSubPackets() { 045 return inheritedSubPackets; 046 } 047 048 public static KeySpecBuilder getBuilder(KeyType type, KeyFlag flag, KeyFlag... flags) { 049 return new KeySpecBuilder(type, flag, flags); 050 } 051}