[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lib/opencdk/read-packet.c: read_s2k() implementation

From: Daniel Kahn Gillmor
Subject: Re: lib/opencdk/read-packet.c: read_s2k() implementation
Date: Fri, 27 Jun 2008 11:01:49 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

On Fri 2008-06-27 06:21:12 -0400, Nikos Mavrogiannopoulos wrote:

>  In a few days I'll merge with the new opencdk code in the
> development branch (changes almost all code), thus I'd appreciate if
> you could port your patch there.

It's not clear to me what branch you're specifically talking about.  I
see no branches named anything like "new opencdk" or "development" --
do you mean "gnutls_with_ext_mpi" ?

In my message on the "2.6.x goals" thread [0], i asked if me doing
work on these would be likely to collide with anyone else's work, and
got no response from you.  It would be useful for collaboration if we
can communicate with each other about this sort of thing.  Sorry for
the miscommunication from my end!

If the branch you're referring to *is* gnutls_with_ext_mpi, then it's
not clear to me how to port this properly.  CDK_PKT_SYMKEY_ENC is the
packet type whose parser contained the code i ended up moving into
read_s2k.  But CDK_PKT_SYMKEY_ENC appears to have been removed from
opencdk.h on the gnutls_with_ext_mpi branch, despite being clearly
defined in the standard [1].  Any reason this was removed?  It seems
like a useful packet type for OpenCDK to be able to handle.

I'm attaching an (untested) patch against the gnutls_with_ext_mpi
branch, which at least fleshes out the read_s2k function.

It's untested because when i still don't know how to build from the
git repo.  The developer's site says [2] "Build GnuTLS/libtasn1 by
running 'make' twice (once to run autoreconf and configure and another
time to build the code)", but when i try, even the first make fails:

[0 address@hidden git-gnutls]$ git status
# Not currently on any branch.
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#       modified:   lib/opencdk/read-packet.c
no changes added to commit (use "git add" and/or "git commit -a")
[1 address@hidden git-gnutls]$ make
for f in po/*; do \
                cp $f `echo $f | sed 's/.in//'`; \
mv build-aux/config.rpath build-aux/config.rpath-
test -f ./configure || autoreconf --install
mv build-aux/config.rpath- build-aux/config.rpath
./configure --enable-developer-mode --enable-gtk-doc
configure: error: cannot find install-sh or in build-aux 
make: *** [bootstrap] Error 1
[2 address@hidden git-gnutls]$ ls -l build-aux/
total 44
-rwxr-xr-x 1 dkg dkg 18343 2008-06-27 09:25 config.rpath
-rwxr-xr-x 1 dkg dkg 12050 2008-05-03 11:06
-rwxr-xr-x 1 dkg dkg  4735 2008-04-17 13:46 gnupload
-rw-r--r-- 1 dkg dkg  1292 2008-04-02 14:26 link-warning.h
[0 address@hidden git-gnutls]$ 

Any advice or pointers to better documentation would be welcome!




  (the pipermail archives at are
  giving me a 403 forbidden error)



diff --git a/lib/opencdk/read-packet.c b/lib/opencdk/read-packet.c
index 4e47c63..313ddfb 100644
--- a/lib/opencdk/read-packet.c
+++ b/lib/opencdk/read-packet.c
@@ -78,12 +78,31 @@ read_16 (cdk_stream_t s)
-static int
+/* read about S2K at */
+static cdk_error_t
 read_s2k (cdk_stream_t inp, cdk_s2k_t s2k)
-  return CDK_Not_Implemented;
+  size_t nread;
+  s2k->mode = cdk_stream_getc (inp);
+  s2k->hash_algo = cdk_stream_getc (inp);
+  if (s2k->mode == CDK_S2K_SIMPLE) 
+      return 0;
+  else if (s2k->mode == CDK_S2K_SALTED || s2k->mode == CDK_S2K_ITERSALTED)
+    {
+      if (stream_read (inp, s2k->salt, DIM (s2k->salt), &nread))
+       return CDK_Inv_Packet;
+      if (nread != DIM (s2k->salt))
+       return CDK_Inv_Packet;
+      if (s2k->mode == CDK_S2K_ITERSALTED)
+       s2k->count = cdk_stream_getc (inp);
+    }
+  else
+    return CDK_Not_Implemented;
+  return 0;
 static cdk_error_t
 read_mpi (cdk_stream_t inp, bigint_t *ret_m, int secure)

Attachment: pgpTJYDif3zYZ.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]