Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using deprecated bouncycastle apis #4550

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public interface ReactorProject extends IDependencyMetadata {
/**
* Returns the (editable) list of {@link DependencySeed}s for the given project.
*/
@SuppressWarnings("unchecked")
default List<DependencySeed> getDependencySeeds() {
return computeContextValue(TychoConstants.CTX_DEPENDENCY_SEEDS, () -> new CopyOnWriteArrayList<>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.bcpg.CompressionAlgorithmTags;
import org.bouncycastle.bcpg.HashAlgorithmTags;
import org.bouncycastle.bcpg.PublicKeyPacket;
import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags;
import org.bouncycastle.bcpg.sig.KeyFlags;
import org.bouncycastle.crypto.generators.RSAKeyPairGenerator;
Expand Down Expand Up @@ -138,7 +139,8 @@ public SignatureStore generateSignature(File file) throws PGPException, IOExcept
var publicKey = secretKey.getPublicKey();
var signatureGenerator = new PGPSignatureGenerator(
new JcaPGPContentSignerBuilder(publicKey.getAlgorithm(), HashAlgorithmTags.SHA256)
.setProvider(BouncyCastleProvider.PROVIDER_NAME));
.setProvider(BouncyCastleProvider.PROVIDER_NAME),
publicKey);
signatureGenerator.init(PGPSignature.BINARY_DOCUMENT, privateKey);
var subpackets = new PGPSignatureSubpacketGenerator();
subpackets.setIssuerFingerprint(false, publicKey);
Expand Down Expand Up @@ -244,7 +246,8 @@ private void init(String... userIDs) throws PGPException, IOException {
var publicKeyRings = new ArrayList<PGPPublicKeyRing>();
var secretKeyRings = new ArrayList<PGPSecretKeyRing>();
for (var userID : userIDs) {
var signingKeyPair = new BcPGPKeyPair(PGPPublicKey.RSA_SIGN, keyPairGenerator.generateKeyPair(), now);
var signingKeyPair = new BcPGPKeyPair(PublicKeyPacket.VERSION_4, PGPPublicKey.RSA_GENERAL,
keyPairGenerator.generateKeyPair(), now);
var signatureSubpacketGenerator = new PGPSignatureSubpacketGenerator();
signatureSubpacketGenerator.setKeyFlags(false, KeyFlags.SIGN_DATA | KeyFlags.CERTIFY_OTHER);
signatureSubpacketGenerator.setPreferredSymmetricAlgorithms(false,
Expand All @@ -254,15 +257,17 @@ private void init(String... userIDs) throws PGPException, IOException {
signatureSubpacketGenerator.setPreferredCompressionAlgorithms(false,
new int[] { CompressionAlgorithmTags.ZIP, CompressionAlgorithmTags.BZIP2 });

var encryptionKeyPair = new BcPGPKeyPair(PGPPublicKey.RSA_ENCRYPT, keyPairGenerator.generateKeyPair(), now);
var encryptionKeyPair = new BcPGPKeyPair(PublicKeyPacket.VERSION_4, PGPPublicKey.RSA_GENERAL,
keyPairGenerator.generateKeyPair(), now);
var encryptionSubpacketGenerator = new PGPSignatureSubpacketGenerator();
encryptionSubpacketGenerator.setKeyFlags(false, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE);

var digestCalculator = new BcPGPDigestCalculatorProvider().get(HashAlgorithmTags.SHA1);
var signatureSubpacketVector = signatureSubpacketGenerator.generate();
var contentSignerBuilder = new BcPGPContentSignerBuilder(PGPPublicKey.RSA_SIGN, HashAlgorithmTags.SHA256);
var contentSignerBuilder = new BcPGPContentSignerBuilder(PGPPublicKey.RSA_GENERAL,
HashAlgorithmTags.SHA256);
var secretKeyEncryptorBuilder = new BcPBESecretKeyEncryptorBuilder(SymmetricKeyAlgorithmTags.AES_256);
var keyRingGenerator = new PGPKeyRingGenerator(PGPPublicKey.RSA_SIGN, signingKeyPair, userID,
var keyRingGenerator = new PGPKeyRingGenerator(PGPPublicKey.RSA_GENERAL, signingKeyPair, userID,
digestCalculator, signatureSubpacketVector, null, contentSignerBuilder,
secretKeyEncryptorBuilder.build(passphrase.toCharArray()));
keyRingGenerator.addSubKey(encryptionKeyPair, encryptionSubpacketGenerator.generate(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ private FileEntry getFileEntry(final String path, final File file) throws IOExce
return entry;
}

@SuppressWarnings("TextBlockMigration")
private String getFeatResponse() {
return "Extensions supported:\r\n" +
" MDTM\r\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ protected void addArguments(List<String> arguments) throws IOException, Malforme
arguments.add("-source");
arguments.add(getUpdateSiteLocation().getAbsolutePath());
arguments.add("-metadataRepository");
arguments.add(getUpdateSiteLocation().toURL().toExternalForm());
arguments.add(getUpdateSiteLocation().toURI().toString());
arguments.add("-metadataRepositoryName");
arguments.add(metadataRepositoryName);
arguments.add("-artifactRepository");
arguments.add(getUpdateSiteLocation().toURL().toExternalForm());
arguments.add(getUpdateSiteLocation().toURI().toString());
arguments.add("-artifactRepositoryName");
arguments.add(artifactRepositoryName);
arguments.add("-noDefaultIUs");
Expand Down
Loading