[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU Emacs-libnettle-libhogweed integration patch v1
From: |
Eli Zaretskii |
Subject: |
Re: GNU Emacs-libnettle-libhogweed integration patch v1 |
Date: |
Sun, 06 Oct 2013 19:09:41 +0300 |
> From: Ted Zlatanov <address@hidden>
> Date: Sun, 06 Oct 2013 05:15:09 -0400
> Cc: address@hidden
>
> This is the first cut of the Nettle integration for your review.
Thanks.
> +DEFUN ("nettle-available-p", Fnettle_available_p, Snettle_available_p, 0, 0,
> 0,
> + doc: /* Return t if libnettle+libhogweed are available in this
> instance of Emacs. */)
> + (void)
> +{
> + return Qt;
> +}
For the record: this will have to be changed for MS-Windows, to
support dynamic loading, like we do, e.g., in decompress.c.
> +DEFUN ("nettle-hmac", Fnettle_hmac, Snettle_hmac, 3, 3, 0,
> + doc: /* Hash INPUT string with HASH-METHOD and KEY into a unibyte
> string according to HMAC (RFC 2104).
The first line of the doc string is too long. (There are others with
similar problems.)
> + digest = xzalloc (length);
> + hmac_digest (outer_ctx, inner_ctx, state_ctx, alg, length, digest);
> +
> + ret = make_unibyte_string (digest, length);
Instead of xzalloc, then make_unibyte_string, I think you should be
able to allocate a string first, and then work on its SDATA. This
will save you from at least one allocation.
> + free (digest);
> + free (state_ctx);
> + free (outer_ctx);
> + free (inner_ctx);
We tend to use xfree, not free.
> + sha1_mode = 0 == strcmp (SDATA (hash_method), "sha1");
> + sha256_mode = 0 == strcmp (SDATA (hash_method), "sha256");
Perhaps using Fstring_equal is better here, not sure.
> + uint8_t *digest = xzalloc (outlength);
^^^^^^^
Why not 'unsigned char'?
> + if (!rsa_keypair_from_der (&key, NULL, 0, SCHARS (public_key), SDATA
> (public_key)) &&
> + !rsa_keypair_from_sexp (&key, NULL, 0, SCHARS (public_key), SDATA
> (public_key)))
The && should be at the beginning of a line, not at the end.
- GNU Emacs-libnettle-libhogweed integration patch v1, Ted Zlatanov, 2013/10/06
- bignum support in Emacs with libgmp (was: GNU Emacs-libnettle-libhogweed integration patch v1), Ted Zlatanov, 2013/10/06
- Re: GNU Emacs-libnettle-libhogweed integration patch v1,
Eli Zaretskii <=
- Re: GNU Emacs-libnettle-libhogweed integration patch v1, Stefan Monnier, 2013/10/06
- Re: GNU Emacs-libnettle-libhogweed integration patch v1, Eli Zaretskii, 2013/10/06
- Re: GNU Emacs-libnettle-libhogweed integration patch v1, Ted Zlatanov, 2013/10/06
- Re: GNU Emacs-libnettle-libhogweed integration patch v1, Stefan Monnier, 2013/10/07
- Re: GNU Emacs-libnettle-libhogweed integration patch v1, Ted Zlatanov, 2013/10/07
- Re: GNU Emacs-libnettle-libhogweed integration patch v1, Ted Zlatanov, 2013/10/07
- Re: GNU Emacs-libnettle-libhogweed integration patch v1, Stefan Monnier, 2013/10/07
- Emacs crypto use cases (was: GNU Emacs-libnettle-libhogweed integration patch v1), Ted Zlatanov, 2013/10/07
- Re: Emacs crypto use cases, Stefan Monnier, 2013/10/07