1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-22 19:08:00 +01:00

Require UTF8 for KeyRingBuilder.addUserId(byte[])

This commit is contained in:
Paul Schaub 2023-07-12 16:49:38 +02:00
parent 0fa62991ec
commit f46790be00
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -6,7 +6,6 @@ package org.pgpainless.key.generation;
import java.io.IOException;
import java.nio.charset.Charset;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@ -36,6 +35,7 @@ import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor;
import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder;
import org.bouncycastle.openpgp.operator.PGPDigestCalculator;
import org.bouncycastle.util.Strings;
import org.pgpainless.PGPainless;
import org.pgpainless.algorithm.HashAlgorithm;
import org.pgpainless.algorithm.KeyFlag;
@ -56,9 +56,6 @@ public class KeyRingBuilder implements KeyRingBuilderInterface<KeyRingBuilder> {
private static final long YEAR_IN_SECONDS = 1000L * 60 * 60 * 24 * 365;
@SuppressWarnings("CharsetObjectCanBeUsed")
private final Charset UTF8 = Charset.forName("UTF-8");
private KeySpec primaryKeySpec;
private final List<KeySpec> subkeySpecs = new ArrayList<>();
private final Map<String, SelfSignatureSubpackets.Callback> userIds = new LinkedHashMap<>();
@ -95,7 +92,7 @@ public class KeyRingBuilder implements KeyRingBuilderInterface<KeyRingBuilder> {
@Override
public KeyRingBuilder addUserId(@Nonnull byte[] userId) {
return addUserId(new String(userId, UTF8));
return addUserId(Strings.fromUTF8ByteArray(userId));
}
@Override