csexpr parsing problem

munga dr.munga at gmail.com
Mon Dec 11 20:51:32 CET 2017


[ I've already sent this message a few times, but never made it
trough. I hope this is the good one]

Hi all,

I'm new here in town. I've started playing with gpg-agent recently and
I'm writing a small client to talk assuan . I've this strange problem.

When asking for "genkey" I receive a string like :

(10:public-key(3:rsa(1:n513: ... that is a csexpr.

I've noticed that the numbers 10, 3, 1 and 513, that are supposedly
the number of bytes to follow, are always the same. BUT the size of the
entire csexpr is sometimes different. The server itself tells me the
number of bytes sent and I get for example :

2017-12-08 16:21:36 gpg-agent[17137] DBG: returning public key
2017-12-08 16:21:36 gpg-agent[17137] DBG: chan_10 -> [ 44 20 28 31 30
3a 70 75 62 6c 69 63 2d 6b
+65 79 ...(550 byte(s) skipped) ]
2017-12-08 16:21:36 gpg-agent[17137] DBG: chan_10 -> OK
2017-12-08 16:21:36 gpg-agent[17137] DBG: chan_10 <- [eof]

2017-12-08 16:10:41 gpg-agent[17137] DBG: returning public key
2017-12-08 16:10:41 gpg-agent[17137] DBG: chan_10 -> [ 44 20 28 31 30
3a 70 75 62 6c 69 63 2d 6b
+65 79 ...(552 byte(s) skipped) ]
2017-12-08 16:10:41 gpg-agent[17137] DBG: chan_10 -> OK
2017-12-08 16:10:41 gpg-agent[17137] DBG: chan_10 <- [eof]

notice that once it says : (550 byte(s) and the next (552 byte(s)
skipped)  ...

Moreover when I try to read 513 bytes representing the pubkey, this
number is always short of a few bytes (between 14 and 16 ...), and I
truly don't understand why.

Attached you can find the dump of the csexpr as I receive it from the agent
and a small python parser... Any insight would be greatly appreciate.

Specifically :
- is the answer sent back by the server of a fixed size or not ?
- are the size in the cexpr (513:...) to be interpreted as "read 513 bytes from
  here" ?

I could use libaussan directly, but to avoid this C dependency in my
OCaml code, I'd rather avoid it.

A bit lost
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gpg.dump
Type: application/octet-stream
Size: 580 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20171211/2c82305c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parse.py
Type: text/x-python
Size: 309 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20171211/2c82305c/attachment.py>


More information about the Gnupg-devel mailing list