summaryrefslogtreecommitdiff
path: root/lib/x509_b64.h
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2003-03-26 23:05:16 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2003-03-26 23:05:16 +0000
commit3f3cf746c5ef57126a32459e498177d13269c210 (patch)
tree643fb8969a54c7fedbcebf1a56d89f35445a4a4c /lib/x509_b64.h
parent999c63be7e102ff11e39a42f8ad10d10ebdbf2a4 (diff)
downloadgnutls-3f3cf746c5ef57126a32459e498177d13269c210.tar.gz
Several fixes to allow exporting the PKCS #7 structures.
Diffstat (limited to 'lib/x509_b64.h')
-rw-r--r--lib/x509_b64.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/x509_b64.h b/lib/x509_b64.h
index 6c7b014707..9317fd5f47 100644
--- a/lib/x509_b64.h
+++ b/lib/x509_b64.h
@@ -4,3 +4,16 @@ int _gnutls_fbase64_encode(const char *msg, const uint8 * data, int data_size,
int _gnutls_base64_decode(const uint8 * data, size_t data_size, uint8 ** result);
int _gnutls_fbase64_decode( const opaque* header, const uint8 * data, size_t data_size,
uint8 ** result);
+
+#define B64SIZE( data_size) ((data_size%3==0)?((data_size/3)*4):(4+((data_size/3)*4)))
+
+/* The size for B64 encoding + newlines plus header
+ */
+
+#define HEADSIZE( hsize) \
+ sizeof("-----BEGIN")-1+sizeof("-----\n")-1+ \
+ sizeof("\n-----END ")-1+sizeof("-----\n")-1+hsize+hsize
+
+#define B64FSIZE( hsize, dsize) \
+ (B64SIZE(dsize) + HEADSIZE(hsize) + /*newlines*/ \
+ B64SIZE(dsize)/64 + (B64SIZE(dsize) % 64 > 0 ? 1 : 0))