minimal pseudo code for encrypting message to multiple recipients

Werner Koch wk at gnupg.org
Thu Jul 25 21:28:34 CEST 2013


On Thu, 25 Jul 2013 18:32, timprepscius at gmail.com said:

> I'm actually looking for pseudo code for a minimal implementation of pgp-mime.

You may want to look at gnupg/tools/gpgparsemail.c for a parser.
Building messages is actually more trivial; maybe gpgol/src/mimemaker.c
is of some help.  Well, not pseudo code.  For pseudo code you should
just read RFC-3156 which has a lot of good examples.

> And that perhaps a full implementation is the *only* implementation.

Creating PGP/MIME is really simple.

> A minimal pgp-mime.
>
> 1. Canonicalize message.
> 2. Write a "encrypted/pgp-mime" mime-part.
> 3. Within mime-part write b64(encrypt(canon-message)).

Depends on whether you want to sign or encrypt.  Encrypt is easy; really
easy I mean.  It is just a fixed block.

> Where encrypt is "rsa(aes-256-key) + aes-256(message) +
> sha-256(previously written bytes)"

Nope: That is more complicated, you need to read the OpenPGP standard.
Don't even try to come up with your own encryption protocol.

> Some indicator of encryption version used.  And my public key.

Sending the public key is not common with OpenPGP - You send it out of
band.  Only S/MIME resorts to this kludged due to the non-standardized
way of looking up keys (Oh well, unless you use the global X.500
directory ;-)



Shalom-Salam,

   Werner


-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.




More information about the Gnupg-devel mailing list