Blame SOURCES/nss-softokn-basicutil-dependency.patch

60ce18
# HG changeset patch
60ce18
# User Daiki Ueno <dueno@redhat.com>
60ce18
# Date 1483701049 -3600
60ce18
#      Fri Jan 06 12:10:49 2017 +0100
60ce18
# Node ID 85673cf4a82728084850deb2f05bda2778480341
60ce18
# Parent  697aaeda536948589fb6759e235f7e1486b524b3
60ce18
Move SSLNamedGroup references from basicutil.h to secutil.h
60ce18
60ce18
diff --git a/cmd/lib/basicutil.c b/cmd/lib/basicutil.c
60ce18
--- a/cmd/lib/basicutil.c
60ce18
+++ b/cmd/lib/basicutil.c
60ce18
@@ -25,7 +25,6 @@
60ce18
 #endif
60ce18
 
60ce18
 #include "secoid.h"
60ce18
-#include "sslt.h"
60ce18
 
60ce18
 extern long DER_GetInteger(const SECItem *src);
60ce18
 
60ce18
@@ -732,98 +731,3 @@ SECU_SECItemHexStringToBinary(SECItem *s
60ce18
     srcdest->len /= 2;
60ce18
     return SECSuccess;
60ce18
 }
60ce18
-
60ce18
-SSLNamedGroup
60ce18
-groupNameToNamedGroup(char *name)
60ce18
-{
60ce18
-    if (PL_strlen(name) == 4) {
60ce18
-        if (!strncmp(name, "P256", 4)) {
60ce18
-            return ssl_grp_ec_secp256r1;
60ce18
-        }
60ce18
-        if (!strncmp(name, "P384", 4)) {
60ce18
-            return ssl_grp_ec_secp384r1;
60ce18
-        }
60ce18
-        if (!strncmp(name, "P521", 4)) {
60ce18
-            return ssl_grp_ec_secp521r1;
60ce18
-        }
60ce18
-    }
60ce18
-    if (PL_strlen(name) == 6) {
60ce18
-        if (!strncmp(name, "x25519", 6)) {
60ce18
-            return ssl_grp_ec_curve25519;
60ce18
-        }
60ce18
-        if (!strncmp(name, "FF2048", 6)) {
60ce18
-            return ssl_grp_ffdhe_2048;
60ce18
-        }
60ce18
-        if (!strncmp(name, "FF3072", 6)) {
60ce18
-            return ssl_grp_ffdhe_3072;
60ce18
-        }
60ce18
-        if (!strncmp(name, "FF4096", 6)) {
60ce18
-            return ssl_grp_ffdhe_4096;
60ce18
-        }
60ce18
-        if (!strncmp(name, "FF6144", 6)) {
60ce18
-            return ssl_grp_ffdhe_6144;
60ce18
-        }
60ce18
-        if (!strncmp(name, "FF8192", 6)) {
60ce18
-            return ssl_grp_ffdhe_8192;
60ce18
-        }
60ce18
-    }
60ce18
-
60ce18
-    return ssl_grp_none;
60ce18
-}
60ce18
-
60ce18
-SECStatus
60ce18
-parseGroupList(const char *arg, SSLNamedGroup **enabledGroups,
60ce18
-               unsigned int *enabledGroupsCount)
60ce18
-{
60ce18
-    SSLNamedGroup *groups;
60ce18
-    char *str;
60ce18
-    char *p;
60ce18
-    unsigned int numValues = 0;
60ce18
-    unsigned int count = 0;
60ce18
-
60ce18
-    /* Count the number of groups. */
60ce18
-    str = PORT_Strdup(arg);
60ce18
-    if (!str) {
60ce18
-        return SECFailure;
60ce18
-    }
60ce18
-    p = strtok(str, ",");
60ce18
-    while (p) {
60ce18
-        ++numValues;
60ce18
-        p = strtok(NULL, ",");
60ce18
-    }
60ce18
-    PORT_Free(str);
60ce18
-    str = NULL;
60ce18
-    groups = PORT_ZNewArray(SSLNamedGroup, numValues);
60ce18
-    if (!groups) {
60ce18
-        goto done;
60ce18
-    }
60ce18
-
60ce18
-    /* Get group names. */
60ce18
-    str = PORT_Strdup(arg);
60ce18
-    if (!str) {
60ce18
-        goto done;
60ce18
-    }
60ce18
-    p = strtok(str, ",");
60ce18
-    while (p) {
60ce18
-        SSLNamedGroup group = groupNameToNamedGroup(p);
60ce18
-        if (group == ssl_grp_none) {
60ce18
-            count = 0;
60ce18
-            goto done;
60ce18
-        }
60ce18
-        groups[count++] = group;
60ce18
-        p = strtok(NULL, ",");
60ce18
-    }
60ce18
-
60ce18
-done:
60ce18
-    if (str) {
60ce18
-        PORT_Free(str);
60ce18
-    }
60ce18
-    if (!count) {
60ce18
-        PORT_Free(groups);
60ce18
-        return SECFailure;
60ce18
-    }
60ce18
-
60ce18
-    *enabledGroupsCount = count;
60ce18
-    *enabledGroups = groups;
60ce18
-    return SECSuccess;
60ce18
-}
60ce18
diff --git a/cmd/lib/basicutil.h b/cmd/lib/basicutil.h
60ce18
--- a/cmd/lib/basicutil.h
60ce18
+++ b/cmd/lib/basicutil.h
60ce18
@@ -13,7 +13,6 @@
60ce18
 #include "base64.h"
60ce18
 #include "secasn1.h"
60ce18
 #include "secder.h"
60ce18
-#include "sslt.h"
60ce18
 #include <stdio.h>
60ce18
 
60ce18
 #ifdef SECUTIL_NEW
60ce18
@@ -113,10 +112,6 @@ SECU_ParseCommandLine(int argc, char **a
60ce18
 char *
60ce18
 SECU_GetOptionArg(const secuCommand *cmd, int optionNum);
60ce18
 
60ce18
-SECStatus parseGroupList(const char *arg, SSLNamedGroup **enabledGroups,
60ce18
-                         unsigned int *enabledGroupsCount);
60ce18
-SSLNamedGroup groupNameToNamedGroup(char *name);
60ce18
-
60ce18
 /*
60ce18
  *
60ce18
  *  Error messaging
60ce18
diff --git a/cmd/lib/secutil.c b/cmd/lib/secutil.c
60ce18
--- a/cmd/lib/secutil.c
60ce18
+++ b/cmd/lib/secutil.c
60ce18
@@ -3875,3 +3875,98 @@ SECU_HexString2SECItem(PLArenaPool *aren
60ce18
 
60ce18
     return item;
60ce18
 }
60ce18
+
60ce18
+SSLNamedGroup
60ce18
+groupNameToNamedGroup(char *name)
60ce18
+{
60ce18
+    if (PL_strlen(name) == 4) {
60ce18
+        if (!strncmp(name, "P256", 4)) {
60ce18
+            return ssl_grp_ec_secp256r1;
60ce18
+        }
60ce18
+        if (!strncmp(name, "P384", 4)) {
60ce18
+            return ssl_grp_ec_secp384r1;
60ce18
+        }
60ce18
+        if (!strncmp(name, "P521", 4)) {
60ce18
+            return ssl_grp_ec_secp521r1;
60ce18
+        }
60ce18
+    }
60ce18
+    if (PL_strlen(name) == 6) {
60ce18
+        if (!strncmp(name, "x25519", 6)) {
60ce18
+            return ssl_grp_ec_curve25519;
60ce18
+        }
60ce18
+        if (!strncmp(name, "FF2048", 6)) {
60ce18
+            return ssl_grp_ffdhe_2048;
60ce18
+        }
60ce18
+        if (!strncmp(name, "FF3072", 6)) {
60ce18
+            return ssl_grp_ffdhe_3072;
60ce18
+        }
60ce18
+        if (!strncmp(name, "FF4096", 6)) {
60ce18
+            return ssl_grp_ffdhe_4096;
60ce18
+        }
60ce18
+        if (!strncmp(name, "FF6144", 6)) {
60ce18
+            return ssl_grp_ffdhe_6144;
60ce18
+        }
60ce18
+        if (!strncmp(name, "FF8192", 6)) {
60ce18
+            return ssl_grp_ffdhe_8192;
60ce18
+        }
60ce18
+    }
60ce18
+
60ce18
+    return ssl_grp_none;
60ce18
+}
60ce18
+
60ce18
+SECStatus
60ce18
+parseGroupList(const char *arg, SSLNamedGroup **enabledGroups,
60ce18
+               unsigned int *enabledGroupsCount)
60ce18
+{
60ce18
+    SSLNamedGroup *groups;
60ce18
+    char *str;
60ce18
+    char *p;
60ce18
+    unsigned int numValues = 0;
60ce18
+    unsigned int count = 0;
60ce18
+
60ce18
+    /* Count the number of groups. */
60ce18
+    str = PORT_Strdup(arg);
60ce18
+    if (!str) {
60ce18
+        return SECFailure;
60ce18
+    }
60ce18
+    p = strtok(str, ",");
60ce18
+    while (p) {
60ce18
+        ++numValues;
60ce18
+        p = strtok(NULL, ",");
60ce18
+    }
60ce18
+    PORT_Free(str);
60ce18
+    str = NULL;
60ce18
+    groups = PORT_ZNewArray(SSLNamedGroup, numValues);
60ce18
+    if (!groups) {
60ce18
+        goto done;
60ce18
+    }
60ce18
+
60ce18
+    /* Get group names. */
60ce18
+    str = PORT_Strdup(arg);
60ce18
+    if (!str) {
60ce18
+        goto done;
60ce18
+    }
60ce18
+    p = strtok(str, ",");
60ce18
+    while (p) {
60ce18
+        SSLNamedGroup group = groupNameToNamedGroup(p);
60ce18
+        if (group == ssl_grp_none) {
60ce18
+            count = 0;
60ce18
+            goto done;
60ce18
+        }
60ce18
+        groups[count++] = group;
60ce18
+        p = strtok(NULL, ",");
60ce18
+    }
60ce18
+
60ce18
+done:
60ce18
+    if (str) {
60ce18
+        PORT_Free(str);
60ce18
+    }
60ce18
+    if (!count) {
60ce18
+        PORT_Free(groups);
60ce18
+        return SECFailure;
60ce18
+    }
60ce18
+
60ce18
+    *enabledGroupsCount = count;
60ce18
+    *enabledGroups = groups;
60ce18
+    return SECSuccess;
60ce18
+}
60ce18
diff --git a/cmd/lib/secutil.h b/cmd/lib/secutil.h
60ce18
--- a/cmd/lib/secutil.h
60ce18
+++ b/cmd/lib/secutil.h
60ce18
@@ -408,6 +408,10 @@ SECU_ParseSSLVersionRangeString(const ch
60ce18
 extern SECItem *SECU_HexString2SECItem(PLArenaPool *arena, SECItem *item,
60ce18
                                        const char *str);
60ce18
 
60ce18
+SECStatus parseGroupList(const char *arg, SSLNamedGroup **enabledGroups,
60ce18
+                         unsigned int *enabledGroupsCount);
60ce18
+SSLNamedGroup groupNameToNamedGroup(char *name);
60ce18
+
60ce18
 /*
60ce18
  *
60ce18
  *  Error messaging
60ce18
# HG changeset patch
60ce18
# User Daiki Ueno <dueno@redhat.com>
60ce18
# Date 1483695727 -3600
60ce18
#      Fri Jan 06 10:42:07 2017 +0100
60ce18
# Node ID 93a3a5494fad25ba55c2133453c3300719216b18
60ce18
# Parent  85673cf4a82728084850deb2f05bda2778480341
60ce18
Move SECU_HexString2SECItem to basicutil.c
60ce18
60ce18
Also add the stub declaration in basicutil.h, and remove unnecesary
60ce18
#include for secutil.h in some files.
60ce18
60ce18
diff --git a/cmd/ecperf/ecperf.c b/cmd/ecperf/ecperf.c
60ce18
--- a/cmd/ecperf/ecperf.c
60ce18
+++ b/cmd/ecperf/ecperf.c
60ce18
@@ -9,7 +9,6 @@
60ce18
 #include "basicutil.h"
60ce18
 #include "pkcs11.h"
60ce18
 #include "nspr.h"
60ce18
-#include "secutil.h"
60ce18
 #include <stdio.h>
60ce18
 
60ce18
 #define __PASTE(x, y) x##y
60ce18
@@ -106,6 +105,8 @@ typedef struct ThreadDataStr {
60ce18
     int isSign;
60ce18
 } ThreadData;
60ce18
 
60ce18
+typedef SECItem SECKEYECParams;
60ce18
+
60ce18
 void
60ce18
 PKCS11Thread(void *data)
60ce18
 {
60ce18
diff --git a/cmd/fbectest/fbectest.c b/cmd/fbectest/fbectest.c
60ce18
--- a/cmd/fbectest/fbectest.c
60ce18
+++ b/cmd/fbectest/fbectest.c
60ce18
@@ -9,7 +9,6 @@
60ce18
 #include "basicutil.h"
60ce18
 #include "secder.h"
60ce18
 #include "secitem.h"
60ce18
-#include "secutil.h"
60ce18
 #include "nspr.h"
60ce18
 #include <stdio.h>
60ce18
 
60ce18
diff --git a/cmd/lib/basicutil.c b/cmd/lib/basicutil.c
60ce18
--- a/cmd/lib/basicutil.c
60ce18
+++ b/cmd/lib/basicutil.c
60ce18
@@ -731,3 +731,46 @@ SECU_SECItemHexStringToBinary(SECItem *s
60ce18
     srcdest->len /= 2;
60ce18
     return SECSuccess;
60ce18
 }
60ce18
+
60ce18
+SECItem *
60ce18
+SECU_HexString2SECItem(PLArenaPool *arena, SECItem *item, const char *str)
60ce18
+{
60ce18
+    int i = 0;
60ce18
+    int byteval = 0;
60ce18
+    int tmp = PORT_Strlen(str);
60ce18
+
60ce18
+    PORT_Assert(arena);
60ce18
+    PORT_Assert(item);
60ce18
+
60ce18
+    if ((tmp % 2) != 0) {
60ce18
+        PORT_SetError(SEC_ERROR_INVALID_ARGS);
60ce18
+        return NULL;
60ce18
+    }
60ce18
+
60ce18
+    item = SECITEM_AllocItem(arena, item, tmp / 2);
60ce18
+    if (item == NULL) {
60ce18
+        return NULL;
60ce18
+    }
60ce18
+
60ce18
+    while (str[i]) {
60ce18
+        if ((str[i] >= '0') && (str[i] <= '9')) {
60ce18
+            tmp = str[i] - '0';
60ce18
+        } else if ((str[i] >= 'a') && (str[i] <= 'f')) {
60ce18
+            tmp = str[i] - 'a' + 10;
60ce18
+        } else if ((str[i] >= 'A') && (str[i] <= 'F')) {
60ce18
+            tmp = str[i] - 'A' + 10;
60ce18
+        } else {
60ce18
+            /* item is in arena and gets freed by the caller */
60ce18
+            return NULL;
60ce18
+        }
60ce18
+
60ce18
+        byteval = byteval * 16 + tmp;
60ce18
+        if ((i % 2) != 0) {
60ce18
+            item->data[i / 2] = byteval;
60ce18
+            byteval = 0;
60ce18
+        }
60ce18
+        i++;
60ce18
+    }
60ce18
+
60ce18
+    return item;
60ce18
+}
60ce18
diff --git a/cmd/lib/basicutil.h b/cmd/lib/basicutil.h
60ce18
--- a/cmd/lib/basicutil.h
60ce18
+++ b/cmd/lib/basicutil.h
60ce18
@@ -81,6 +81,12 @@ SECStatus
60ce18
 SECU_SECItemHexStringToBinary(SECItem *srcdest);
60ce18
 
60ce18
 /*
60ce18
+** Read a hex string into a SecItem.
60ce18
+*/
60ce18
+extern SECItem *SECU_HexString2SECItem(PLArenaPool *arena, SECItem *item,
60ce18
+                                       const char *str);
60ce18
+
60ce18
+/*
60ce18
  *
60ce18
  *  Utilities for parsing security tools command lines
60ce18
  *
60ce18
diff --git a/cmd/lib/secutil.c b/cmd/lib/secutil.c
60ce18
--- a/cmd/lib/secutil.c
60ce18
+++ b/cmd/lib/secutil.c
60ce18
@@ -3833,49 +3833,6 @@ SECU_ParseSSLVersionRangeString(const ch
60ce18
     return SECSuccess;
60ce18
 }
60ce18
 
60ce18
-SECItem *
60ce18
-SECU_HexString2SECItem(PLArenaPool *arena, SECItem *item, const char *str)
60ce18
-{
60ce18
-    int i = 0;
60ce18
-    int byteval = 0;
60ce18
-    int tmp = PORT_Strlen(str);
60ce18
-
60ce18
-    PORT_Assert(arena);
60ce18
-    PORT_Assert(item);
60ce18
-
60ce18
-    if ((tmp % 2) != 0) {
60ce18
-        PORT_SetError(SEC_ERROR_INVALID_ARGS);
60ce18
-        return NULL;
60ce18
-    }
60ce18
-
60ce18
-    item = SECITEM_AllocItem(arena, item, tmp / 2);
60ce18
-    if (item == NULL) {
60ce18
-        return NULL;
60ce18
-    }
60ce18
-
60ce18
-    while (str[i]) {
60ce18
-        if ((str[i] >= '0') && (str[i] <= '9')) {
60ce18
-            tmp = str[i] - '0';
60ce18
-        } else if ((str[i] >= 'a') && (str[i] <= 'f')) {
60ce18
-            tmp = str[i] - 'a' + 10;
60ce18
-        } else if ((str[i] >= 'A') && (str[i] <= 'F')) {
60ce18
-            tmp = str[i] - 'A' + 10;
60ce18
-        } else {
60ce18
-            /* item is in arena and gets freed by the caller */
60ce18
-            return NULL;
60ce18
-        }
60ce18
-
60ce18
-        byteval = byteval * 16 + tmp;
60ce18
-        if ((i % 2) != 0) {
60ce18
-            item->data[i / 2] = byteval;
60ce18
-            byteval = 0;
60ce18
-        }
60ce18
-        i++;
60ce18
-    }
60ce18
-
60ce18
-    return item;
60ce18
-}
60ce18
-
60ce18
 SSLNamedGroup
60ce18
 groupNameToNamedGroup(char *name)
60ce18
 {