2018-06-13 17:26:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Paul Schaub.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2018-07-18 18:23:06 +02:00
|
|
|
package org.pgpainless.key.generation;
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2018-07-31 20:09:16 +02:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2018-06-04 14:50:09 +02:00
|
|
|
import org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator;
|
|
|
|
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
|
2021-09-13 19:20:19 +02:00
|
|
|
import org.pgpainless.algorithm.KeyFlag;
|
2018-07-18 18:23:06 +02:00
|
|
|
import org.pgpainless.key.generation.type.KeyType;
|
2018-06-02 21:21:35 +02:00
|
|
|
|
|
|
|
public class KeySpec {
|
|
|
|
|
|
|
|
private final KeyType keyType;
|
2018-06-04 14:50:09 +02:00
|
|
|
private final PGPSignatureSubpacketGenerator subpacketGenerator;
|
|
|
|
private final boolean inheritedSubPackets;
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2018-07-31 20:09:16 +02:00
|
|
|
KeySpec(@Nonnull KeyType type,
|
|
|
|
@Nullable PGPSignatureSubpacketGenerator subpacketGenerator,
|
2018-06-04 14:50:09 +02:00
|
|
|
boolean inheritedSubPackets) {
|
2018-06-02 21:21:35 +02:00
|
|
|
this.keyType = type;
|
2018-06-04 14:50:09 +02:00
|
|
|
this.subpacketGenerator = subpacketGenerator;
|
|
|
|
this.inheritedSubPackets = inheritedSubPackets;
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|
|
|
|
|
2018-07-31 20:09:16 +02:00
|
|
|
@Nonnull
|
2018-06-02 21:21:35 +02:00
|
|
|
KeyType getKeyType() {
|
|
|
|
return keyType;
|
|
|
|
}
|
|
|
|
|
2018-07-31 20:09:16 +02:00
|
|
|
@Nullable
|
2021-06-24 14:11:18 +02:00
|
|
|
public PGPSignatureSubpacketVector getSubpackets() {
|
2018-07-31 20:09:16 +02:00
|
|
|
return subpacketGenerator != null ? subpacketGenerator.generate() : null;
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|
|
|
|
|
2021-01-29 14:51:24 +01:00
|
|
|
PGPSignatureSubpacketGenerator getSubpacketGenerator() {
|
|
|
|
return subpacketGenerator;
|
|
|
|
}
|
|
|
|
|
2018-06-04 14:50:09 +02:00
|
|
|
boolean isInheritedSubPackets() {
|
|
|
|
return inheritedSubPackets;
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|
|
|
|
|
2021-09-20 11:26:00 +02:00
|
|
|
public static KeySpecBuilder getBuilder(KeyType type, KeyFlag flag, KeyFlag... flags) {
|
|
|
|
return new KeySpecBuilder(type, flag, flags);
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|
|
|
|
}
|