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