[xmlsec] Adding configurable Base64 line length
- From: Aleksey Sanin <aleksey src gnome org>
- To: svn-commits-list gnome org
- Subject: [xmlsec] Adding configurable Base64 line length
- Date: Tue, 9 Jun 2009 19:29:05 -0400 (EDT)
commit 5aa34ff3ddc739bc21e060517a2e2790f33911b1
Author: Aleksey Sanin <aleksey aleksey com>
Date: Tue Jun 9 16:27:59 2009 -0700
Adding configurable Base64 line length
---
include/xmlsec/base64.h | 4 ++++
src/base64.c | 27 ++++++++++++++++++++++++++-
src/bn.c | 2 +-
src/keyinfo.c | 2 +-
src/nss/bignum.c | 2 +-
src/openssl/bn.c | 2 +-
6 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/include/xmlsec/base64.h b/include/xmlsec/base64.h
index 3cdcbb9..444a566 100644
--- a/include/xmlsec/base64.h
+++ b/include/xmlsec/base64.h
@@ -27,6 +27,10 @@ extern "C" {
*/
#define XMLSEC_BASE64_LINESIZE 64
+XMLSEC_EXPORT int xmlSecBase64GetDefaultLineSize ();
+XMLSEC_EXPORT void xmlSecBase64SetDefaultLineSize (int columns);
+
+
/**
* Base64 Context
*/
diff --git a/src/base64.c b/src/base64.c
index dc5aa8e..fbe307f 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -108,6 +108,31 @@ static int xmlSecBase64CtxDecode (xmlSecBase64CtxPtr ctx,
xmlSecSize* outBufResSize);
static int xmlSecBase64CtxDecodeIsFinished (xmlSecBase64CtxPtr ctx);
+
+static int g_xmlsec_base64_default_line_size = XMLSEC_BASE64_LINESIZE;
+
+/**
+ * xmlSecBase64GetDefaultLineSize:
+ *
+ * Returns the current default line size.
+ */
+int
+xmlSecBase64GetDefaultLineSize()
+{
+ return g_xmlsec_base64_default_line_size;
+}
+
+/**
+ * xmlSecBase64SetDefaultLineSize:
+ *
+ * Sets the current default line size.
+ */
+void
+xmlSecBase64SetDefaultLineSize(int columns)
+{
+ g_xmlsec_base64_default_line_size = columns;
+}
+
/**
* xmlSecBase64CtxCreate:
* @encode: the encode/decode flag (1 - encode, 0 - decode)
@@ -843,7 +868,7 @@ xmlSecBase64Initialize(xmlSecTransformPtr transform) {
xmlSecAssert2(ctx != NULL, -1);
transform->operation = xmlSecTransformOperationDecode;
- ret = xmlSecBase64CtxInitialize(ctx, 0, XMLSEC_BASE64_LINESIZE);
+ ret = xmlSecBase64CtxInitialize(ctx, 0, xmlSecBase64GetDefaultLineSize());
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
diff --git a/src/bn.c b/src/bn.c
index 8c16ba3..c8d0762 100644
--- a/src/bn.c
+++ b/src/bn.c
@@ -949,7 +949,7 @@ xmlSecBnSetNodeValue(xmlSecBnPtr bn, xmlNodePtr cur, xmlSecBnFormat format, int
switch(format) {
case xmlSecBnBase64:
- ret = xmlSecBufferBase64NodeContentWrite(bn, cur, XMLSEC_BASE64_LINESIZE);
+ ret = xmlSecBufferBase64NodeContentWrite(bn, cur, xmlSecBase64GetDefaultLineSize());
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
diff --git a/src/keyinfo.c b/src/keyinfo.c
index e274375..6d0962a 100644
--- a/src/keyinfo.c
+++ b/src/keyinfo.c
@@ -277,7 +277,7 @@ xmlSecKeyInfoCtxInitialize(xmlSecKeyInfoCtxPtr keyInfoCtx, xmlSecKeysMngrPtr key
memset(keyInfoCtx, 0, sizeof(xmlSecKeyInfoCtx));
keyInfoCtx->keysMngr = keysMngr;
- keyInfoCtx->base64LineSize = XMLSEC_BASE64_LINESIZE;
+ keyInfoCtx->base64LineSize = xmlSecBase64GetDefaultLineSize();
ret = xmlSecPtrListInitialize(&(keyInfoCtx->enabledKeyData), xmlSecKeyDataIdListId);
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
diff --git a/src/nss/bignum.c b/src/nss/bignum.c
index b9e0d6b..e0bbc38 100644
--- a/src/nss/bignum.c
+++ b/src/nss/bignum.c
@@ -142,7 +142,7 @@ xmlSecNssNodeSetBigNumValue(xmlNodePtr cur, const SECItem *a, int addLineBreaks)
xmlNodeSetContent(cur, xmlSecStringEmpty);
}
- ret = xmlSecBufferBase64NodeContentWrite(&buf, cur, XMLSEC_BASE64_LINESIZE);
+ ret = xmlSecBufferBase64NodeContentWrite(&buf, cur, xmlSecBase64GetDefaultLineSize());
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
diff --git a/src/openssl/bn.c b/src/openssl/bn.c
index 2613b0e..3fd2001 100644
--- a/src/openssl/bn.c
+++ b/src/openssl/bn.c
@@ -142,7 +142,7 @@ xmlSecOpenSSLNodeSetBNValue(xmlNodePtr cur, const BIGNUM *a, int addLineBreaks)
xmlNodeSetContent(cur, xmlSecStringEmpty);
}
- ret = xmlSecBufferBase64NodeContentWrite(&buf, cur, XMLSEC_BASE64_LINESIZE);
+ ret = xmlSecBufferBase64NodeContentWrite(&buf, cur, xmlSecBase64GetDefaultLineSize());
if(ret < 0) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]