[svn] gcry - r1390 - trunk/tests
svn author wk
cvs at cvs.gnupg.org
Fri Feb 13 19:47:56 CET 2009
Author: wk
Date: 2009-02-13 19:47:56 +0100 (Fri, 13 Feb 2009)
New Revision: 1390
Modified:
trunk/tests/ChangeLog
trunk/tests/rsacvt.c
Log:
Add OpenPGP opeion and fix non openpgp calculation.
Modified: trunk/tests/ChangeLog
===================================================================
--- trunk/tests/ChangeLog 2009-02-11 11:53:54 UTC (rev 1389)
+++ trunk/tests/ChangeLog 2009-02-13 18:47:56 UTC (rev 1390)
@@ -1,3 +1,9 @@
+2009-02-13 Werner Koch <wk at g10code.com>
+
+ * rsacvt.c (compute_missing): Fix dqm1 computation. Take care of
+ openpgp flag.
+ (main): Add option --openpgp.
+
2009-02-11 Werner Koch <wk at g10code.com>
* rsacvt.c: New.
Modified: trunk/tests/rsacvt.c
===================================================================
--- trunk/tests/rsacvt.c 2009-02-11 11:53:54 UTC (rev 1389)
+++ trunk/tests/rsacvt.c 2009-02-13 18:47:56 UTC (rev 1390)
@@ -83,7 +83,11 @@
/* Do not suppress leading zeroes. */
static int keep_lz;
+/* Create parameters as specified by OpenPGP (rfc4880). That is we
+ don't store dmp1 and dmp1 but d and make sure that p is less than q. */
+static int openpgp_mode;
+
/* Print a error message and exit the process with an error code. */
static void
die (const char *format, ...)
@@ -227,7 +231,7 @@
tmp_g = gcry_mpi_new (0);
/* Check that p < q; if not swap p and q. */
- if (gcry_mpi_cmp (rsa_p, rsa_q) > 0)
+ if (openpgp_mode && gcry_mpi_cmp (rsa_p, rsa_q) > 0)
{
fprintf (stderr, PGM ": swapping p and q\n");
gcry_mpi_swap (rsa_p, rsa_q);
@@ -253,10 +257,14 @@
/* Compute the CRT helpers: d mod (p-1), d mod (q-1) */
gcry_mpi_mod (rsa_pm1, rsa_d, rsa_pm1);
- gcry_mpi_mod (rsa_qm1, rsa_d, rsa_pm1);
+ gcry_mpi_mod (rsa_qm1, rsa_d, rsa_qm1);
- /* Compute the CRT value: u = p^{-1} mod q */
- gcry_mpi_invm (rsa_u, rsa_p, rsa_q);
+ /* Compute the CRT value: OpenPGP: u = p^{-1} mod q
+ Standard: iqmp = q^{-1} mod p */
+ if (openpgp_mode)
+ gcry_mpi_invm (rsa_u, rsa_p, rsa_q);
+ else
+ gcry_mpi_invm (rsa_u, rsa_q, rsa_p);
gcry_mpi_release (phi);
gcry_mpi_release (tmp_f);
@@ -265,12 +273,18 @@
/* Print everything. */
print_mpi_line ("n", rsa_n);
print_mpi_line ("e", rsa_e);
- print_mpi_line ("d", rsa_d);
+ if (openpgp_mode)
+ print_mpi_line ("d", rsa_d);
print_mpi_line ("p", rsa_p);
print_mpi_line ("q", rsa_q);
- print_mpi_line ("dmp1", rsa_pm1);
- print_mpi_line ("dmq1", rsa_qm1);
- print_mpi_line ("u", rsa_u);
+ if (openpgp_mode)
+ print_mpi_line ("u", rsa_u);
+ else
+ {
+ print_mpi_line ("dmp1", rsa_pm1);
+ print_mpi_line ("dmq1", rsa_qm1);
+ print_mpi_line ("iqmp", rsa_u);
+ }
gcry_mpi_release (rsa_n);
gcry_mpi_release (rsa_d);
@@ -294,10 +308,11 @@
("Usage: " PGM " [OPTIONS] [FILE]\n"
"Take RSA parameters p, n, e and compute missing parameters.\n"
"OPTIONS:\n"
- " --version Print version information\n"
- " --verbose Print additional information\n"
+ " --openpgp Compute as specified by RFC4880\n"
" --labels Prefix output with labels\n"
" --keep-lz Keep all leading zeroes in the output\n"
+ " --verbose Print additional information\n"
+ " --version Print version information\n"
" --help Print this text\n"
"With no FILE, or if FILE is -, read standard input.\n"
"Report bugs to " PACKAGE_BUGREPORT ".\n" , stdout);
@@ -350,6 +365,11 @@
keep_lz = 1;
argc--; argv++;
}
+ else if (!strcmp (*argv, "--openpgp"))
+ {
+ openpgp_mode = 1;
+ argc--; argv++;
+ }
}
if (argc > 1)
More information about the Gnupg-commits
mailing list