diff options
| author | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2013-08-21 17:08:57 +0000 |
|---|---|---|
| committer | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2013-08-21 17:08:57 +0000 |
| commit | 9bfb9d9ed22bfbfec2ff49c73cb1994b2ea5981a (patch) | |
| tree | 862034cc30fef482378e6d8447ba5521885352eb /PICA_id.c | |
| parent | 255f83d5109d7ddeab1c9a343292f2cfbcf10651 (diff) | |
| download | pica-pica-9bfb9d9ed22bfbfec2ff49c73cb1994b2ea5981a.tar.gz pica-pica-9bfb9d9ed22bfbfec2ff49c73cb1994b2ea5981a.zip | |
pica-node modified to handle new id format, new files PICA_id.c PICA_id.h containing functions for working with id
git-svn-id: svn://localhost/project_picapica/trunk@263 fb96df88-216d-11de-830c-f3023f12d8ac
Diffstat (limited to 'PICA_id.c')
| -rw-r--r-- | PICA_id.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/PICA_id.c b/PICA_id.c new file mode 100644 index 0000000..aeb6b74 --- /dev/null +++ b/PICA_id.c @@ -0,0 +1,54 @@ + +#include "PICA_id.h" +#include <openssl/bio.h> +#include <string.h> + +int PICA_id_from_X509(X509 *x, unsigned char *id) +{ +unsigned char *der = NULL; +int len; + +len = i2d_X509(x, &der); + +if (len <= 0) +{ + return 0; +} + +SHA224(der, len, id); + +OPENSSL_free(der); + +return 1; +} + +unsigned char *PICA_id_from_base64(const unsigned char *buf, unsigned char *id) +{ + +} + +char *PICA_id_to_base64(const unsigned char *id, char *buf) +{ +BIO *biomem, *b64; +static char localbuf[PICA_ID_SIZE*2]; + +char *sourcebuf, *outputbuf = buf; +long b64len; + +b64 = BIO_new(BIO_f_base64()); +biomem = BIO_new(BIO_s_mem()); +biomem = BIO_push(b64, biomem); +BIO_write(biomem, id, PICA_ID_SIZE); +BIO_flush(biomem); + +b64len = BIO_get_mem_data(biomem, &sourcebuf); + +if (outputbuf == NULL) + outputbuf = localbuf; + +memcpy(outputbuf, sourcebuf, b64len); + +outputbuf[b64len] = '\0'; + +BIO_free_all(biomem); +} |
