summaryrefslogtreecommitdiff
path: root/client/bankid.c
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2011-01-03 19:38:06 +0100
committerSamuel Lidén Borell <samuel@slbdata.se>2011-01-03 19:38:06 +0100
commit1ed980511f92220068e54b645c5ac03f994b8cb2 (patch)
tree9fcb4b6d97dcab88fa70487c6a48ba135740a71a /client/bankid.c
parent8f8b39868e88920c61ae369d096eca93d97fa96d (diff)
downloadfribid-1ed980511f92220068e54b645c5ac03f994b8cb2.tar.gz
fribid-1ed980511f92220068e54b645c5ac03f994b8cb2.tar.bz2
fribid-1ed980511f92220068e54b645c5ac03f994b8cb2.zip
Add certificate request creation to the interface for the backends
Diffstat (limited to 'client/bankid.c')
-rw-r--r--client/bankid.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/client/bankid.c b/client/bankid.c
index ecb2c65..bd06c02 100644
--- a/client/bankid.c
+++ b/client/bankid.c
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2009-2010 Samuel Lidén Borell <samuel@slbdata.se>
+ Copyright (c) 2009-2011 Samuel Lidén Borell <samuel@slbdata.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -339,3 +339,27 @@ BankIDError bankid_sign(Token *token,
return error;
}
+/**
+ * Generates a new key pair and creates a certificate request.
+ *
+ * @param params Parameters (from SetParam/InitRequest calls).
+ * @param password A password or PIN entered on the keyboard.
+ * @param request The certificate request, Base64 encoded.
+ */
+BankIDError bankid_createRequest(const RegutilInfo *params,
+ const char *password,
+ char **request) {
+ *request = NULL;
+
+ char *binaryRequest;
+ size_t brlen;
+ TokenError error = backend_createRequest(params, password,
+ &binaryRequest, &brlen);
+ if (error) return BIDERR_InternalError;
+
+ // Encode with Base64
+ *request = base64_encode(binaryRequest, brlen);
+ free(binaryRequest);
+ return (*request ? BIDERR_OK : BIDERR_InternalError);
+}
+