[git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-303-g2cf2ca7
by Werner Koch
cvs at cvs.gnupg.org
Thu Jan 28 17:40:23 CET 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".
The branch, master has been updated
via 2cf2ca7bb9741ac86e8aa92d8f03b1c5f5938897 (commit)
from 191c2e4fe2dc0e00f61aa44e011a9596887e6ce1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2cf2ca7bb9741ac86e8aa92d8f03b1c5f5938897
Author: Werner Koch <wk at gnupg.org>
Date: Thu Jan 28 17:33:51 2016 +0100
ecc: New API function gcry_mpi_ec_decode_point.
* mpi/ec.c (_gcry_mpi_ec_decode_point): New.
* cipher/ecc-common.h: Move two prototypes to ...
* src/ec-context.h: here.
* src/gcrypt.h.in (gcry_mpi_ec_decode_point): New.
* src/libgcrypt.def (gcry_mpi_ec_decode_point): New.
* src/libgcrypt.vers (gcry_mpi_ec_decode_point): New.
* src/visibility.c (gcry_mpi_ec_decode_point): New.
* src/visibility.h: Add new function.
--
This new function make the use of the gcry_mpi_ec_curve_point function
possible in many contexts. Here is a code snippet which could be used
in gpg to check a point:
static gpg_error_t
check_point (PKT_public_key *pk, gcry_mpi_t m_point)
{
gpg_error_t err;
char *curve;
gcry_ctx_t gctx = NULL;
gcry_mpi_point_t point = NULL;
/* Get the curve name from the first OpenPGP key parameter. */
curve = openpgp_oid_to_str (pk->pkey[0]);
if (!curve)
{
err = gpg_error_from_syserror ();
goto leave;
}
point = gcry_mpi_point_new (0);
if (!point)
{
err = gpg_error_from_syserror ();
goto leave;
}
err = gcry_mpi_ec_new (&gctx, NULL, curve);
if (err)
goto leave;
err = gcry_mpi_ec_decode_point (point, m_point, gctx);
if (err)
goto leave;
if (!gcry_mpi_ec_curve_point (point, gctx))
err = gpg_error (GPG_ERR_BAD_DATA);
leave:
gcry_ctx_release (gctx);
gcry_mpi_point_release (point);
xfree (curve);
return err;
}
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/NEWS b/NEWS
index 22565ed..79d1931 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,7 @@ Noteworthy changes in version 1.7.0 (unreleased)
gcry_cipher_set_sbox NEW macro.
GCRY_MD_GOSTR3411_CP NEW.
gcry_mpi_ec_sub NEW.
+ gcry_mpi_ec_decode_point NEW.
GCRY_CIPHER_MODE_OCB NEW.
GCRYCTL_SET_TAGLEN NEW.
gcry_cipher_final NEW macro.
diff --git a/cipher/ecc-common.h b/cipher/ecc-common.h
index 4e528af..748e6db 100644
--- a/cipher/ecc-common.h
+++ b/cipher/ecc-common.h
@@ -89,13 +89,10 @@ elliptic_curve_t _gcry_ecc_curve_copy (elliptic_curve_t E);
const char *_gcry_ecc_model2str (enum gcry_mpi_ec_models model);
const char *_gcry_ecc_dialect2str (enum ecc_dialects dialect);
gcry_mpi_t _gcry_ecc_ec2os (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t p);
-gcry_err_code_t _gcry_ecc_os2ec (mpi_point_t result, gcry_mpi_t value);
mpi_point_t _gcry_ecc_compute_public (mpi_point_t Q, mpi_ec_t ec,
mpi_point_t G, gcry_mpi_t d);
-gpg_err_code_t _gcry_ecc_mont_decodepoint (gcry_mpi_t pk, mpi_ec_t ctx,
- mpi_point_t result);
/*-- ecc.c --*/
@@ -116,10 +113,8 @@ gpg_err_code_t _gcry_ecc_eddsa_encodepoint (mpi_point_t point, mpi_ec_t ctx,
unsigned int *r_buflen);
gpg_err_code_t _gcry_ecc_eddsa_ensure_compact (gcry_mpi_t value,
unsigned int nbits);
-gpg_err_code_t _gcry_ecc_eddsa_decodepoint (gcry_mpi_t pk, mpi_ec_t ctx,
- mpi_point_t result,
- unsigned char **r_encpk,
- unsigned int *r_encpklen);
+
+
gpg_err_code_t _gcry_ecc_eddsa_compute_h_d (unsigned char **r_digest,
gcry_mpi_t d, mpi_ec_t ec);
diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi
index 39c7c9f..bbaaac6 100644
--- a/doc/gcrypt.texi
+++ b/doc/gcrypt.texi
@@ -4882,6 +4882,19 @@ Valid names are the point parameters of an elliptic curve
(@pxref{ecc_keyparam}).
@end deftypefun
+ at deftypefun gpg_err_code_t gcry_mpi_ec_decode_point ( @
+ @w{mpi_point_t @var{result}}, @w{gcry_mpi_t @var{value}}, @
+ @w{gcry_ctx_t @var{ctx}})
+
+Decode the point given as an MPI in @var{value} and store at
+ at var{result}. To decide which encoding is used the function takes a
+context @var{ctx} which can be created with @code{gcry_mpi_ec_new}.
+If @code{NULL} is given for the context the function assumes a 0x04
+prefixed uncompressed encoding. On error an error code is returned
+and @var{result} might be changed.
+ at end deftypefun
+
+
@deftypefun int gcry_mpi_ec_get_affine ( @
@w{gcry_mpi_t @var{x}}, @w{gcry_mpi_t @var{y}}, @
@w{gcry_mpi_point_t @var{point}}, @w{gcry_ctx_t @var{ctx}})
diff --git a/mpi/ec.c b/mpi/ec.c
index 40e09be..346e5f1 100644
--- a/mpi/ec.c
+++ b/mpi/ec.c
@@ -589,6 +589,27 @@ _gcry_mpi_ec_set_point (const char *name, gcry_mpi_point_t newvalue,
}
+/* Given an encoded point in the MPI VALUE and a context EC, decode
+ * the point according to the context and store it in RESULT. On
+ * error an error code is return but RESULT might have been changed.
+ * If no context is given the function tries to decode VALUE by
+ * assuming a 0x04 prefixed uncompressed encoding. */
+gpg_err_code_t
+_gcry_mpi_ec_decode_point (mpi_point_t result, gcry_mpi_t value, mpi_ec_t ec)
+{
+ gcry_err_code_t rc;
+
+ if (ec && ec->dialect == ECC_DIALECT_ED25519)
+ rc = _gcry_ecc_eddsa_decodepoint (value, ec, result, NULL, NULL);
+ else if (ec && ec->model == MPI_EC_MONTGOMERY)
+ rc = _gcry_ecc_mont_decodepoint (value, ec, result);
+ else
+ rc = _gcry_ecc_os2ec (result, value);
+
+ return rc;
+}
+
+
/* Compute the affine coordinates from the projective coordinates in
POINT. Set them into X and Y. If one coordinate is not required,
X or Y may be passed as NULL. CTX is the usual context. Returns: 0
diff --git a/src/ec-context.h b/src/ec-context.h
index c8f2ad0..d74fb69 100644
--- a/src/ec-context.h
+++ b/src/ec-context.h
@@ -81,5 +81,17 @@ gpg_err_code_t _gcry_ecc_set_mpi (const char *name,
gpg_err_code_t _gcry_ecc_set_point (const char *name,
gcry_mpi_point_t newvalue, mpi_ec_t ec);
+/*-- cipher/ecc-misc.c --*/
+gcry_err_code_t _gcry_ecc_os2ec (mpi_point_t result, gcry_mpi_t value);
+gpg_err_code_t _gcry_ecc_mont_decodepoint (gcry_mpi_t pk, mpi_ec_t ctx,
+ mpi_point_t result);
+
+/*-- cipher/ecc-eddsa.c --*/
+gpg_err_code_t _gcry_ecc_eddsa_decodepoint (gcry_mpi_t pk, mpi_ec_t ctx,
+ mpi_point_t result,
+ unsigned char **r_encpk,
+ unsigned int *r_encpklen);
+
+
#endif /*GCRY_EC_CONTEXT_H*/
diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in
index 93b1f43..f48f04f 100644
--- a/src/gcrypt.h.in
+++ b/src/gcrypt.h.in
@@ -694,6 +694,10 @@ gpg_error_t gcry_mpi_ec_set_mpi (const char *name, gcry_mpi_t newvalue,
gpg_error_t gcry_mpi_ec_set_point (const char *name, gcry_mpi_point_t newvalue,
gcry_ctx_t ctx);
+/* Decode and store VALUE into RESULT. */
+gpg_error_t gcry_mpi_ec_decode_point (gcry_mpi_point_t result,
+ gcry_mpi_t value, gcry_ctx_t ctx);
+
/* Store the affine coordinates of POINT into X and Y. */
int gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_point_t point,
gcry_ctx_t ctx);
diff --git a/src/libgcrypt.def b/src/libgcrypt.def
index f3e074b..067cb84 100644
--- a/src/libgcrypt.def
+++ b/src/libgcrypt.def
@@ -280,4 +280,6 @@ EXPORTS
gcry_md_extract @245
+ gcry_mpi_ec_decode_point @246
+
;; end of file with public symbols for Windows.
diff --git a/src/libgcrypt.vers b/src/libgcrypt.vers
index 5b3d419..785b8ed 100644
--- a/src/libgcrypt.vers
+++ b/src/libgcrypt.vers
@@ -106,7 +106,7 @@ GCRYPT_1.6 {
gcry_mpi_ec_set_mpi; gcry_mpi_ec_set_point;
gcry_mpi_ec_get_affine;
gcry_mpi_ec_dup; gcry_mpi_ec_add; gcry_mpi_ec_sub; gcry_mpi_ec_mul;
- gcry_mpi_ec_curve_point;
+ gcry_mpi_ec_curve_point; gcry_mpi_ec_decode_point;
gcry_log_debug;
gcry_log_debughex; gcry_log_debugmpi; gcry_log_debugpnt; gcry_log_debugsxp;
diff --git a/src/mpi.h b/src/mpi.h
index 0d19f46..cd539f5 100644
--- a/src/mpi.h
+++ b/src/mpi.h
@@ -307,6 +307,8 @@ gpg_err_code_t _gcry_mpi_ec_set_mpi (const char *name, gcry_mpi_t newvalue,
gpg_err_code_t _gcry_mpi_ec_set_point (const char *name,
gcry_mpi_point_t newvalue,
gcry_ctx_t ctx);
+gpg_err_code_t _gcry_mpi_ec_decode_point (mpi_point_t result,
+ gcry_mpi_t value, mpi_ec_t ec);
/*-- ecc-curves.c --*/
gpg_err_code_t _gcry_mpi_ec_new (gcry_ctx_t *r_ctx,
diff --git a/src/visibility.c b/src/visibility.c
index 23a2705..3abbd37 100644
--- a/src/visibility.c
+++ b/src/visibility.c
@@ -544,6 +544,15 @@ gcry_mpi_ec_set_point (const char *name, gcry_mpi_point_t newvalue,
return gpg_error (_gcry_mpi_ec_set_point (name, newvalue, ctx));
}
+gpg_error_t
+gcry_mpi_ec_decode_point (gcry_mpi_point_t result, gcry_mpi_t value,
+ gcry_ctx_t ctx)
+{
+ return gpg_error (_gcry_mpi_ec_decode_point
+ (result, value,
+ ctx? _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC) : NULL));
+}
+
int
gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_point_t point,
gcry_ctx_t ctx)
diff --git a/src/visibility.h b/src/visibility.h
index bb25de0..7ecd75e 100644
--- a/src/visibility.h
+++ b/src/visibility.h
@@ -222,6 +222,7 @@ MARK_VISIBLEX (gcry_mpi_ec_add)
MARK_VISIBLEX (gcry_mpi_ec_sub)
MARK_VISIBLEX (gcry_mpi_ec_curve_point)
MARK_VISIBLEX (gcry_mpi_ec_dup)
+MARK_VISIBLEX (gcry_mpi_ec_decode_point)
MARK_VISIBLEX (gcry_mpi_ec_get_affine)
MARK_VISIBLEX (gcry_mpi_ec_mul)
MARK_VISIBLEX (gcry_mpi_ec_new)
@@ -492,6 +493,7 @@ MARK_VISIBLEX (_gcry_mpi_get_const)
#define gcry_mpi_ec_sub _gcry_USE_THE_UNDERSCORED_FUNCTION
#define gcry_mpi_ec_curve_point _gcry_USE_THE_UNDERSCORED_FUNCTION
#define gcry_mpi_ec_dup _gcry_USE_THE_UNDERSCORED_FUNCTION
+#define gcry_mpi_ec_decode_point _gcry_USE_THE_UNDERSCORED_FUNCTION
#define gcry_mpi_ec_get_affine _gcry_USE_THE_UNDERSCORED_FUNCTION
#define gcry_mpi_ec_get_mpi _gcry_USE_THE_UNDERSCORED_FUNCTION
#define gcry_mpi_ec_get_point _gcry_USE_THE_UNDERSCORED_FUNCTION
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
cipher/ecc-common.h | 9 ++-------
doc/gcrypt.texi | 13 +++++++++++++
mpi/ec.c | 21 +++++++++++++++++++++
src/ec-context.h | 12 ++++++++++++
src/gcrypt.h.in | 4 ++++
src/libgcrypt.def | 2 ++
src/libgcrypt.vers | 2 +-
src/mpi.h | 2 ++
src/visibility.c | 9 +++++++++
src/visibility.h | 2 ++
11 files changed, 69 insertions(+), 8 deletions(-)
hooks/post-receive
--
The GNU crypto library
http://git.gnupg.org
_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits
More information about the Gcrypt-devel
mailing list