summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2010-01-27 13:12:47 +0100
committerSamuel Lidén Borell <samuel@slbdata.se>2010-01-27 13:12:47 +0100
commit646ce3ff7b95622921243850cc414f7bc42113c9 (patch)
treebeaf9c0c74a93c194b7d5532cf10357e17ab9a78
parentae856f8eb2971fca9a6cc3b3c039cb376ce8d27d (diff)
downloadfribid-646ce3ff7b95622921243850cc414f7bc42113c9.tar.gz
fribid-646ce3ff7b95622921243850cc414f7bc42113c9.tar.bz2
fribid-646ce3ff7b95622921243850cc414f7bc42113c9.zip
Made the subject filter optional and a common parameter
Now it can be used in authentication objects too.
-rw-r--r--client/main.c17
-rw-r--r--common/defines.h1
-rw-r--r--common/pipe.c13
-rw-r--r--common/pipe.h2
-rw-r--r--plugin/ipc.c7
-rw-r--r--plugin/plugin.c3
-rw-r--r--plugin/plugin.h4
7 files changed, 33 insertions, 14 deletions
diff --git a/client/main.c b/client/main.c
index 5e75260..afad275 100644
--- a/client/main.c
+++ b/client/main.c
@@ -47,16 +47,14 @@ void pipeData() {
case PMC_Authenticate:
case PMC_Sign: {
char *challenge = pipe_readString(stdin);
- free(pipe_readString(stdin)); // Just ignore the policies list for now
+ free(pipe_readOptionalString(stdin)); // Just ignore the policies list for now
+ char *subjectFilter = pipe_readOptionalString(stdin);
char *url = pipe_readString(stdin);
char *hostname = pipe_readString(stdin);
char *ip = pipe_readString(stdin);
-
char *message = NULL;
- char *subjectFilter = NULL;
if (command == PMC_Sign) {
message = pipe_readString(stdin);
- subjectFilter = pipe_readString(stdin);
}
// Validate input
@@ -67,9 +65,9 @@ void pipeData() {
} else if (!is_canonical_base64(challenge) ||
!is_valid_hostname(hostname) ||
!is_valid_ip_address(ip) ||
+ (subjectFilter && !is_canonical_base64(subjectFilter)) ||
(command == PMC_Sign && (
- !is_canonical_base64(message) ||
- !is_canonical_base64(subjectFilter)
+ !is_canonical_base64(message)
))) {
error = BIDERR_InternalError;
}
@@ -184,8 +182,13 @@ int main(int argc, char **argv) {
bankid_init();
for (int i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "--internal--ipc")) {
+ if (!strcmp(argv[i], "--internal--ipc=" IPCVERSION)) {
ipc = true;
+ } else if (!strncmp(argv[i], "--internal--ipc", 15)) {
+ fprintf(stderr, BINNAME ": Version mismatch. "
+ "Plugin version: %s, Signer version: " IPCVERSION "\n",
+ (argv[i][15] != '\0' ? &argv[i][16] : "1"));
+ error = true;
} else if (!strcmp(argv[i], "--internal--window-id")) {
i++;
if (i == argc) {
diff --git a/common/defines.h b/common/defines.h
index cc2e65c..d281208 100644
--- a/common/defines.h
+++ b/common/defines.h
@@ -32,6 +32,7 @@
#define BINNAME "fribid"
#define RELEASE_TIME 1264525958
+#define IPCVERSION "2"
#define EMULATED_VERSION "4.10.2.16"
#define DNSVERSION "1"
diff --git a/common/pipe.c b/common/pipe.c
index 481b0c1..81d37b8 100644
--- a/common/pipe.c
+++ b/common/pipe.c
@@ -126,6 +126,15 @@ char *pipe_readString(FILE *in) {
}
}
+char *pipe_readOptionalString(FILE *in) {
+ char *str = pipe_readString(in);
+ if (str && str[0] == '\0') {
+ free(str);
+ return NULL;
+ }
+ return str;
+}
+
int pipe_readInt(FILE *in) {
int value = -1;
if (fscanf(in, "%d;", &value) != 1) {
@@ -145,6 +154,10 @@ void pipe_sendString(FILE *out, const char *str) {
pipe_sendData(out, str, strlen(str));
}
+void pipe_sendOptionalString(FILE *out, const char *str) {
+ pipe_sendString(out, str ? str : "");
+}
+
void pipe_sendInt(FILE *out, int value) {
fprintf(out, "%d;", value);
}
diff --git a/common/pipe.h b/common/pipe.h
index 16a29f5..7df48b5 100644
--- a/common/pipe.h
+++ b/common/pipe.h
@@ -42,10 +42,12 @@ void pipe_waitData(FILE *file);
void pipe_readData(FILE *in, char **data, int *length);
char *pipe_readString(FILE *in);
+char *pipe_readOptionalString(FILE *in);
int pipe_readInt(FILE *in);
void pipe_sendData(FILE *out, const char *data, int length);
void pipe_sendString(FILE *out, const char *str);
+void pipe_sendOptionalString(FILE *out, const char *str);
void pipe_sendInt(FILE *out, int value);
#endif
diff --git a/plugin/ipc.c b/plugin/ipc.c
index e2acdfe..f23e51a 100644
--- a/plugin/ipc.c
+++ b/plugin/ipc.c
@@ -38,7 +38,7 @@
static const char mainBinary[] = SIGNING_EXECUTABLE;
static const char versionOption[] = "--internal--bankid-version-string";
-static const char ipcOption[] = "--internal--ipc";
+static const char ipcOption[] = "--internal--ipc=" IPCVERSION;
static const char windowIdOption[] = "--internal--window-id";
#define PIPE_READ_END 0
@@ -125,8 +125,8 @@ char *version_getVersion(Plugin *plugin) {
static void sendSignCommon(PipeInfo pipeinfo, Plugin *plugin) {
pipe_sendString(pipeinfo.out, plugin->info.auth.challenge);
- pipe_sendString(pipeinfo.out, (plugin->info.auth.policys != NULL ?
- plugin->info.auth.policys : ""));
+ pipe_sendOptionalString(pipeinfo.out, plugin->info.auth.policys);
+ pipe_sendOptionalString(pipeinfo.out, plugin->info.auth.subjectFilter);
pipe_sendString(pipeinfo.out, plugin->url);
pipe_sendString(pipeinfo.out, plugin->hostname);
pipe_sendString(pipeinfo.out, plugin->ip);
@@ -157,7 +157,6 @@ int sign_performAction_Sign(Plugin *plugin) {
sendSignCommon(pipeinfo, plugin);
pipe_sendString(pipeinfo.out, plugin->info.sign.message);
- pipe_sendString(pipeinfo.out, plugin->info.sign.subjectFilter);
pipe_finishCommand(pipeinfo.out);
diff --git a/plugin/plugin.c b/plugin/plugin.c
index 52c85eb..4fd3d97 100644
--- a/plugin/plugin.c
+++ b/plugin/plugin.c
@@ -60,6 +60,7 @@ void plugin_free(Plugin *plugin) {
case PT_Authentication:
free(plugin->info.auth.challenge);
free(plugin->info.auth.policys);
+ free(plugin->info.sign.subjectFilter);
free(plugin->info.auth.signature);
break;
case PT_Signer:
@@ -110,6 +111,7 @@ static void unlockURL(const char *url) {
static char **getCommonParamPointer(Plugin *plugin, const char *name) {
if (!strcmp(name, "Policys")) return &plugin->info.auth.policys;
if (!strcmp(name, "Signature")) return &plugin->info.auth.signature;
+ if (!strcmp(name, "Subjects")) return &plugin->info.sign.subjectFilter;
return NULL;
}
@@ -120,7 +122,6 @@ static char **getParamPointer(Plugin *plugin, const char *name) {
return getCommonParamPointer(plugin, name);
case PT_Signer:
if (!strcmp(name, "Nonce")) return &plugin->info.sign.challenge;
- if (!strcmp(name, "Subjects")) return &plugin->info.sign.subjectFilter;
if (!strcmp(name, "TextToBeSigned")) return &plugin->info.sign.message;
return getCommonParamPointer(plugin, name);
default:
diff --git a/plugin/plugin.h b/plugin/plugin.h
index 3fbfe51..3fd1d9e 100644
--- a/plugin/plugin.h
+++ b/plugin/plugin.h
@@ -50,8 +50,8 @@ typedef struct {
/* Input parameters */
char *challenge;
char *policys;
- void *dummy1; // To be compatible with .sign below
- void *dummy0;
+ char *subjectFilter;
+ void *dummy0; // To be compatible with .sign below
/* Output parameters */
char *signature;
} auth;