Re: "key" argument of BcPublicKeyDataDecryptorFactory.createDataDecryptor()

Florian Best <[email protected]> Fri, 19 Oct 2018 17:19:08 +0200
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <[email protected]>
Oh, P.S.:

What I so far reverse engineerd is that depending on the encAlgorithm,
the key needs to be e.g. 16 bytes long.
A fingerprint is usually 16 bytes long when represented in hex.

I would expect that the required arguments for createDataFactory() are
encoded in a PGP message and there is a method in BC which creates the
values automatically.

e.g. I have the following message:
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1

hIwDflL96+nAPR4BBACE01frfm8pAS8zHRCx4uwNfw73d8kga3SJcQXy0xgSLer1
17uE1ReliasREtaIFJY6GuJo5v9F5xippE0sifTDZDZOKwxua1Qbricfsi+fJfCB
w3u7X/CfRp7W5H3Yikfr9jAPuq4wIBuQsWb60rdpjulRcuSFbnLgcy/t9xachIUB
DgNbW9sp0lgyuhAD/1Z/sIt8AGUW4LjVdx4bGSldW0RNCDmKRGQ+x4835oMhilma
h3VbM2dMJlW4OQCejjI1MMFzGtFp2hQnXwc2DJe6TpIfLpnOsVUNSQ707AvMBB27
e1FzDSWPa3j2Y3dzBFCAVvJaQchvdZzxM9kXyvXkSlXEBU5G6XG94tvsYEMeA/4j
uyiTHJKQXn8DFCkjsbgMs6U5/z3ZglkrCLZlo2yl9dTpM3zBR+Y4eDVmflkDm2+v
AD0EvbdOotnHoMtOs+D5lx7gLYjpO4ckldzReQC7cv5LSXgbdWj+ZNWmJTu4BJCZ
jKOcFrV4EzlgmxyOJGlyoNJK1YAb2u18xH/ncFUYYMkrR2KxsQXvYD197a5LYB+3
uTe5byntXP877DZ55R5+PtTJEnmma8MWY7NMRw==
=GSrn
-----END PGP MESSAGE-----

When base64 decode this, it starts with
"\x84\x8c\x03~R\xfd\xeb\xe9\xc0=\x1e" which is basically 2 bytes (I
still have to find out it's meaning, probably it contains the
encAlgorithm), version=3, and the fingerprint 0x7E52FDEBE9C03D1E of the
used public key in big-endian unsigned long long format. I guess the
rest of the message is the encrypted data?

Thanks for helping!
Florian
(Now I continue reading https://tools.ietf.org/html/rfc4880)...

Am 19.10.2018 um 16:56 schrieb Florian Best:
> Hi folks!
>
> As I found no clear information on my problem, neither in the API docs
> nor in the source code itself, I have to ask here:
>
> I don't understand the argument "key" of
> BcPublicKeyDataDecryptorFactory.createDataDecryptor()
> https://www.bouncycastle.org/docs/pgdocs1.5on/org/bouncycastle/openpgp/operator/bc/BcPublicKeyDataDecryptorFactory.html#createDataDecryptor-boolean-int-byte:A-
>
> public PGPDataDecryptor
> <https://www.bouncycastle.org/docs/pgdocs1.5on/org/bouncycastle/openpgp/operator/PGPDataDecryptor.html> createDataDecryptor(boolean withIntegrityPacket,
>                                             int encAlgorithm,
>                                             byte[] key)
>
> |key| - the bytes of the key for the cipher.
>
> Is "key" the public key, private key, fingerprint or key-id or even
> something else?
> I tried all the combinations but cannot decrypt a message.
>
> I hope someone can help me there!
>
> Best regards
> Florian