Index: /trunk/include/iprt/base64.h
===================================================================
--- /trunk/include/iprt/base64.h	(revision 84209)
+++ /trunk/include/iprt/base64.h	(revision 84210)
@@ -53,5 +53,9 @@
  * The size of the end-of-line marker is that that of the host platform.
  */
-#define RTBASE64_FLAGS_NO_LINE_BREAKS RT_BIT_32(0)
+#define RTBASE64_FLAGS_EOL_NATIVE       UINT32_C(0) /**< Use native newlines. */
+#define RTBASE64_FLAGS_NO_LINE_BREAKS   UINT32_C(1) /**< No newlines.  */
+#define RTBASE64_FLAGS_EOL_LF           UINT32_C(2) /**< Use UNIX-style newlines. */
+#define RTBASE64_FLAGS_EOL_CRLF         UINT32_C(3) /**< Use DOS-style newlines. */
+#define RTBASE64_FLAGS_EOL_STYLE_MASK   UINT32_C(3) /**< End-of-line style mask. */
 /** @} */
 
Index: /trunk/src/VBox/Runtime/common/string/base64.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/string/base64.cpp	(revision 84209)
+++ /trunk/src/VBox/Runtime/common/string/base64.cpp	(revision 84210)
@@ -83,4 +83,23 @@
 static const char       g_szValToChar[64+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
+/** The end-of-line lengths (indexed by style flag value). */
+static const size_t     g_acchEolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1] =
+{
+    /*[RTBASE64_FLAGS_EOL_NATIVE    ]:*/ RTBASE64_EOL_SIZE,
+    /*[RTBASE64_FLAGS_NO_LINE_BREAKS]:*/ 0,
+    /*[RTBASE64_FLAGS_EOL_LF        ]:*/ 1,
+    /*[RTBASE64_FLAGS_EOL_CRLF      ]:*/ 2
+};
+
+/** The end-of-line characters (zero, one or two). */
+static const char       g_aachEolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1][2] =
+{
+    /*[RTBASE64_FLAGS_EOL_NATIVE    ]:*/ { RTBASE64_EOL_SIZE == 1 ? '\n' : '\n', RTBASE64_EOL_SIZE == 1 ? '\n' : '\0', },
+    /*[RTBASE64_FLAGS_NO_LINE_BREAKS]:*/ { '\0', '\0' },
+    /*[RTBASE64_FLAGS_EOL_LF        ]:*/ { '\n', '\0' },
+    /*[RTBASE64_FLAGS_EOL_CRLF      ]:*/ { '\r', '\n' },
+};
+
+
 
 #ifdef RT_STRICT
@@ -421,4 +440,6 @@
 RTDECL(size_t) RTBase64EncodedLengthEx(size_t cbData, uint32_t fFlags)
 {
+    size_t const cchEol = g_acchEolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK];
+
     if (cbData * 8 / 8 != cbData)
     {
@@ -428,7 +449,5 @@
             cch += 8;
         cch /= 6;
-
-        if ((fFlags & RTBASE64_FLAGS_NO_LINE_BREAKS) == 0) /* add EOLs? */
-            cch += ((cch - 1) / RTBASE64_LINE_LEN) * RTBASE64_EOL_SIZE;
+        cch += ((cch - 1) / RTBASE64_LINE_LEN) * cchEol;
         return cch;
     }
@@ -438,7 +457,5 @@
         cch += 8;
     cch /= 6;
-
-    if ((fFlags & RTBASE64_FLAGS_NO_LINE_BREAKS) == 0) /* add EOLs? */
-        cch += ((cch - 1) / RTBASE64_LINE_LEN) * RTBASE64_EOL_SIZE;
+    cch += ((cch - 1) / RTBASE64_LINE_LEN) * cchEol;
     return cch;
 }
@@ -486,4 +503,9 @@
                              char *pszBuf, size_t cbBuf, size_t *pcchActual)
 {
+    /* Expand the EOL style flags: */
+    size_t const    cchEol = g_acchEolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK];
+    char const      chEol0 = g_aachEolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][0];
+    char const      chEol1 = g_aachEolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][1];
+
     /*
      * Process whole "trios" of input data.
@@ -515,15 +537,15 @@
         pbSrc  += 3;
 
-        if ((fFlags & RTBASE64_FLAGS_NO_LINE_BREAKS) == 0) /* add EOLs? */
+        if (cchEol > 0)
         {
             /* deal out end-of-line */
             if (cbBuf == cbLineFeed && cbData)
             {
-                if (cbBuf < RTBASE64_EOL_SIZE + 1)
+                if (cbBuf < cchEol + 1)
                     return VERR_BUFFER_OVERFLOW;
-                cbBuf -= RTBASE64_EOL_SIZE;
-                if (RTBASE64_EOL_SIZE == 2)
-                    *pchDst++ = '\r';
-                *pchDst++ = '\n';
+                cbBuf -= cchEol;
+                *pchDst++ = chEol0;
+                if (chEol1)
+                    *pchDst++ = chEol1;
                 cbLineFeed = cbBuf - RTBASE64_LINE_LEN;
             }
