File tree Expand file tree Collapse file tree 6 files changed +21
-17
lines changed
main/java/org/bouncycastle/bcpg
test/java/org/bouncycastle/openpgp/test Expand file tree Collapse file tree 6 files changed +21
-17
lines changed Original file line number Diff line number Diff line change 2424public class ArmoredInputStream
2525 extends InputStream
2626{
27- /*
27+ /**
2828 * set up the decoding table.
2929 */
3030 private static final byte [] decodingTable ;
Original file line number Diff line number Diff line change @@ -323,6 +323,22 @@ public void writePacket(
323323 p .encode (this );
324324 }
325325
326+ void writeShort (short n )
327+ throws IOException
328+ {
329+ out .write ((byte )(n >> 8 ));
330+ out .write ((byte )n );
331+ }
332+
333+ void writeInt (int n )
334+ throws IOException
335+ {
336+ out .write (n >> 24 );
337+ out .write (n >> 16 );
338+ out .write (n >> 8 );
339+ out .write (n );
340+ }
341+
326342 void writePacket (
327343 int tag ,
328344 byte [] body )
Original file line number Diff line number Diff line change @@ -43,10 +43,7 @@ public void encode(
4343 BCPGOutputStream out )
4444 throws IOException
4545 {
46- int length = value .bitLength ();
47-
48- out .write (length >> 8 );
49- out .write (length );
46+ out .writeShort ((short )value .bitLength ());
5047
5148 byte [] bytes = value .toByteArray ();
5249
Original file line number Diff line number Diff line change @@ -162,19 +162,14 @@ public byte[] getEncodedContents()
162162
163163 if (version <= VERSION_3 )
164164 {
165- pOut .write ((byte )(validDays >> 8 ));
166- pOut .write ((byte )validDays );
165+ pOut .writeShort ((short )validDays );
167166 }
168167
169168 pOut .write (algorithm );
170169
171170 if (version == VERSION_6 )
172171 {
173- int keyOctets = key .getEncoded ().length ;
174- pOut .write (keyOctets >> 24 );
175- pOut .write (keyOctets >> 16 );
176- pOut .write (keyOctets >> 8 );
177- pOut .write (keyOctets );
172+ pOut .writeInt (key .getEncoded ().length );
178173 }
179174
180175 pOut .writeObject ((BCPGObject )key );
Original file line number Diff line number Diff line change @@ -109,10 +109,7 @@ static long readKeyID(BCPGInputStream in)
109109 static void writeTime (BCPGOutputStream pOut , long time )
110110 throws IOException
111111 {
112- pOut .write ((byte )(time >> 24 ));
113- pOut .write ((byte )(time >> 16 ));
114- pOut .write ((byte )(time >> 8 ));
115- pOut .write ((byte )time );
112+ pOut .writeInt ((int ) time );
116113 }
117114
118115 static long readTime (BCPGInputStream in )
Original file line number Diff line number Diff line change @@ -3211,7 +3211,6 @@ private void doTestNoExportPrivateKey(PGPKeyPair keyPair)
32113211 public void testNullEncryption ()
32123212 throws Exception
32133213 {
3214- char [] passPhrase = "fred" .toCharArray ();
32153214 KeyPairGenerator bareGenerator = KeyPairGenerator .getInstance ("RSA" , new BouncyCastleProvider ());
32163215 bareGenerator .initialize (2048 );
32173216 KeyPair rsaPair = bareGenerator .generateKeyPair ();
You can’t perform that action at this time.
0 commit comments