summaryrefslogtreecommitdiffstats
path: root/PICA_id.c
diff options
context:
space:
mode:
authorme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2013-08-21 20:23:02 +0000
committerme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2013-08-21 20:23:02 +0000
commitba711be9bdce4b3d0ced9bff5e2399aa3442e611 (patch)
tree4df741cec37f41efecd95ced338f18e4f367875f /PICA_id.c
parent9bfb9d9ed22bfbfec2ff49c73cb1994b2ea5981a (diff)
downloadpica-pica-ba711be9bdce4b3d0ced9bff5e2399aa3442e611.tar.gz
pica-pica-ba711be9bdce4b3d0ced9bff5e2399aa3442e611.zip
updated test_client, fixed found bugs
git-svn-id: svn://localhost/project_picapica/trunk@264 fb96df88-216d-11de-830c-f3023f12d8ac
Diffstat (limited to 'PICA_id.c')
-rw-r--r--PICA_id.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/PICA_id.c b/PICA_id.c
index aeb6b74..1e7309a 100644
--- a/PICA_id.c
+++ b/PICA_id.c
@@ -24,7 +24,27 @@ return 1;
unsigned char *PICA_id_from_base64(const unsigned char *buf, unsigned char *id)
{
+BIO *biomem, *b64;
+static char localidbuf[PICA_ID_SIZE];
+int inlen, bread = 0;
+unsigned char *idbuf = id;
+
+b64 = BIO_new(BIO_f_base64());
+BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
+biomem = BIO_new_mem_buf(buf, -1);
+biomem = BIO_push(b64, biomem);
+
+if (idbuf == NULL)
+ idbuf = localidbuf;
+bread = BIO_read(biomem, idbuf, PICA_ID_SIZE);
+
+if (bread != PICA_ID_SIZE)
+ idbuf = NULL;
+
+BIO_free_all(biomem);
+
+return idbuf;
}
char *PICA_id_to_base64(const unsigned char *id, char *buf)
@@ -48,7 +68,10 @@ if (outputbuf == NULL)
memcpy(outputbuf, sourcebuf, b64len);
+*strchr(outputbuf, '\n')='\0';
outputbuf[b64len] = '\0';
BIO_free_all(biomem);
+
+return outputbuf;
}