protected void generateSignatureForFile()

in src/main/java/org/apache/maven/plugins/gpg/BcSigner.java [378:396]


    protected void generateSignatureForFile(File file, File signature) throws MojoExecutionException {
        try (InputStream in = Files.newInputStream(file.toPath());
                OutputStream out = new CachingOutputStream(signature.toPath())) {
            PGPSignatureGenerator sGen = new PGPSignatureGenerator(
                    new BcPGPContentSignerBuilder(secretKey.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA512));
            sGen.init(PGPSignature.BINARY_DOCUMENT, privateKey);
            sGen.setHashedSubpackets(hashSubPackets);
            int len;
            byte[] buffer = new byte[8 * 1024];
            while ((len = in.read(buffer)) >= 0) {
                sGen.update(buffer, 0, len);
            }
            try (BCPGOutputStream bcpgOutputStream = new BCPGOutputStream(new ArmoredOutputStream(out))) {
                sGen.generate().encode(bcpgOutputStream);
            }
        } catch (PGPException | IOException e) {
            throw new MojoExecutionException(e);
        }
    }