RFR 8214262: SunEC native code does not compile with debug on

Weijun Wang weijun.wang at oracle.com
Fri Nov 23 14:31:12 UTC 2018


I was curious in some SunEC internals and turned EC_DEBUG on, and found out the library cannot be built. It looks like back when we switched to warnings-as-errors some codes are not updated. Here is the patch:

diff --git a/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c b/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c
--- a/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c
+++ b/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c
@@ -109,16 +109,16 @@
     printf("\n");
 
         if (k1 != NULL) {
-                mp_tohex(k1, mpstr);
+                mp_tohex((mp_int*)k1, mpstr);
                 printf("ec_points_mul: scalar k1: %s\n", mpstr);
-                mp_todecimal(k1, mpstr);
+                mp_todecimal((mp_int*)k1, mpstr);
                 printf("ec_points_mul: scalar k1: %s (dec)\n", mpstr);
         }
 
         if (k2 != NULL) {
-                mp_tohex(k2, mpstr);
+                mp_tohex((mp_int*)k2, mpstr);
                 printf("ec_points_mul: scalar k2: %s\n", mpstr);
-                mp_todecimal(k2, mpstr);
+                mp_todecimal((mp_int*)k2, mpstr);
                 printf("ec_points_mul: scalar k2: %s (dec)\n", mpstr);
         }
 
diff --git a/src/jdk.crypto.ec/share/native/libsunec/impl/ecdecode.c b/src/jdk.crypto.ec/share/native/libsunec/impl/ecdecode.c
--- a/src/jdk.crypto.ec/share/native/libsunec/impl/ecdecode.c
+++ b/src/jdk.crypto.ec/share/native/libsunec/impl/ecdecode.c
@@ -55,6 +55,9 @@
 #include "ecl-curve.h"
 #include "ecc_impl.h"
 
+#if EC_DEBUG
+#include <stdio.h>
+#endif
 #define MAX_ECKEY_LEN           72
 #define SEC_ASN1_OBJECT_ID      0x06

In the first file, k1 and k2 are defined as const mp_int * but mp_tohex accepts a mp_int* as its 1st argument.

In the second file, there is a printf call in a EC_DEBUG block.

Noreg-cleanup.

Thanks
Max

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/security-dev/attachments/20181123/9e2e0855/attachment.htm>


More information about the security-dev mailing list