# Cipher.getOutputSize()

Morten Helles (mhelles@post6.tele.dk)
Fri, 23 Oct 1998 15:55:24 +0200

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Jan Luehe: "Re: Cipher.getOutputSize()"
- Previous message: FARM@aol.com: "Hey baby!"
- Next in thread: Jan Luehe: "Re: Cipher.getOutputSize()"

Hi!

I am having some problems with the JCE 1.2
Cipher.getOutputSize()-method... I believe it returns a wrong padding
size!

For DES (where the block size is 8 bytes), the method returns:

Cipher.getOutputSize(0) => 8
Cipher.getOutputSize(1) => 8
Cipher.getOutputSize(2) => 8
Cipher.getOutputSize(3) => 8
Cipher.getOutputSize(4) => 8
Cipher.getOutputSize(5) => 8
Cipher.getOutputSize(6) => 8
Cipher.getOutputSize(7) => 8
Cipher.getOutputSize(8) => 16
Cipher.getOutputSize(9) => 16
...

This can hardly be correct: An empty byte array is padded to 8 bytes,
and 8 bytes is padded to 16 bytes! Why? I mean, why pad 8 bytes when
they already fit nicely into a single 8-byte block?

I believe the following would be correct:

Cipher.getOutputSize(0) => 0
Cipher.getOutputSize(1) => 8
Cipher.getOutputSize(2) => 8
Cipher.getOutputSize(3) => 8
Cipher.getOutputSize(4) => 8
Cipher.getOutputSize(5) => 8
Cipher.getOutputSize(6) => 8
Cipher.getOutputSize(7) => 8
Cipher.getOutputSize(8) => 8
Cipher.getOutputSize(9) => 16
...

Kind regards,

Morten Helles

- Next message: Jan Luehe: "Re: Cipher.getOutputSize()"
- Previous message: FARM@aol.com: "Hey baby!"
- Next in thread: Jan Luehe: "Re: Cipher.getOutputSize()"