Skip to content

Commit

Permalink
refactored use of writePacket with oldFormat == true into a single me…
Browse files Browse the repository at this point in the history
…thod. Relates to github bcgit#1010
  • Loading branch information
dghgit committed Sep 3, 2021
1 parent 5f6b620 commit 94e8b9c
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 17 deletions.
11 changes: 10 additions & 1 deletion pg/src/main/java/org/bouncycastle/bcpg/BCPGOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,16 @@ public void writePacket(
{
p.encode(this);
}


void writePacket(
int tag,
byte[] body)
throws IOException
{
this.writeHeader(tag, true, false, body.length);
this.write(body);
}

void writePacket(
int tag,
byte[] body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public void encode(
BCPGOutputStream out)
throws IOException
{
out.writePacket(tag, contents, true);
out.writePacket(tag, contents);
}
}
2 changes: 1 addition & 1 deletion pg/src/main/java/org/bouncycastle/bcpg/MarkerPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public void encode(
BCPGOutputStream out)
throws IOException
{
out.writePacket(MARKER, marker, true);
out.writePacket(MARKER, marker);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bouncycastle.bcpg;

import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
* generic signature object
Expand Down Expand Up @@ -112,6 +113,6 @@ public void encode(

pOut.close();

out.writePacket(ONE_PASS_SIGNATURE, bOut.toByteArray(), true);
out.writePacket(ONE_PASS_SIGNATURE, bOut.toByteArray());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ public void encode(

pOut.close();

out.writePacket(PUBLIC_KEY_ENC_SESSION , bOut.toByteArray(), true);
out.writePacket(PUBLIC_KEY_ENC_SESSION , bOut.toByteArray());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ public void encode(
BCPGOutputStream out)
throws IOException
{
out.writePacket(PUBLIC_KEY, getEncodedContents(), true);
out.writePacket(PUBLIC_KEY, getEncodedContents());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.bouncycastle.bcpg;

import java.io.*;
import java.io.IOException;
import java.util.Date;

/**
Expand Down Expand Up @@ -35,6 +35,6 @@ public void encode(
BCPGOutputStream out)
throws IOException
{
out.writePacket(PUBLIC_SUBKEY, getEncodedContents(), true);
out.writePacket(PUBLIC_SUBKEY, getEncodedContents());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,6 @@ public void encode(
BCPGOutputStream out)
throws IOException
{
out.writePacket(SECRET_KEY, getEncodedContents(), true);
out.writePacket(SECRET_KEY, getEncodedContents());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.bouncycastle.bcpg;

import java.io.*;
import java.io.IOException;

/**
* basic packet for a PGP secret key
Expand Down Expand Up @@ -53,6 +53,6 @@ public void encode(
BCPGOutputStream out)
throws IOException
{
out.writePacket(SECRET_SUBKEY, getEncodedContents(), true);
out.writePacket(SECRET_SUBKEY, getEncodedContents());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ else if (version == 4)

pOut.close();

out.writePacket(SIGNATURE, bOut.toByteArray(), true);
out.writePacket(SIGNATURE, bOut.toByteArray());
}

private void setCreationTime()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;

/**
* Basic type for a symmetric encrypted session key packet
Expand Down Expand Up @@ -88,6 +87,6 @@ public void encode(

pOut.close();

out.writePacket(SYMMETRIC_KEY_ENC_SESSION, bOut.toByteArray(), true);
out.writePacket(SYMMETRIC_KEY_ENC_SESSION, bOut.toByteArray());
}
}
2 changes: 1 addition & 1 deletion pg/src/main/java/org/bouncycastle/bcpg/TrustPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public void encode(
BCPGOutputStream out)
throws IOException
{
out.writePacket(TRUST, levelAndTrustAmount, true);
out.writePacket(TRUST, levelAndTrustAmount);
}
}
2 changes: 1 addition & 1 deletion pg/src/main/java/org/bouncycastle/bcpg/UserIDPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ public void encode(
BCPGOutputStream out)
throws IOException
{
out.writePacket(USER_ID, idData, true);
out.writePacket(USER_ID, idData);
}
}

0 comments on commit 94e8b9c

Please sign in to comment.