diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2006-04-08 22:25:47 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2006-04-08 22:25:47 +0000 |
commit | a9164153d11672b043ca8ed9eb244cf7b3f1e476 (patch) | |
tree | e231dc888a96c6811974fd211cbcd8686c8b0bc6 /apps/apps.c | |
parent | 8795d38906df0612ebdca345befee5bf53d1beef (diff) |
Reformat pkeyutl.c, add support for verify operation but nothing actually
supports it (yet).
Diffstat (limited to 'apps/apps.c')
-rw-r--r-- | apps/apps.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/apps.c b/apps/apps.c index 77ef5df94d..c2afdd142a 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -2267,6 +2267,43 @@ int args_verify(char ***pargs, int *pargc, } +/* Read whole contents of a BIO into an allocated memory buffer and + * return it. + */ + +int bio_to_mem(unsigned char **out, int maxlen, BIO *in) + { + BIO *mem; + int len, ret; + unsigned char tbuf[1024]; + mem = BIO_new(BIO_s_mem()); + if (!mem) + return -1; + for(;;) + { + if ((maxlen != -1) && maxlen < 1024) + len = maxlen; + else + len = 1024; + len = BIO_read(in, tbuf, len); + if (len <= 0) + break; + if (BIO_write(mem, tbuf, len) != len) + { + BIO_free(mem); + return -1; + } + maxlen -= len; + + if (maxlen == 0) + break; + } + ret = BIO_get_mem_data(mem, (char **)out); + BIO_set_flags(mem, BIO_FLAGS_MEM_RDONLY); + BIO_free(mem); + return ret; + } + static void nodes_print(BIO *out, const char *name, STACK_OF(X509_POLICY_NODE) *nodes) { |