/*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
DWORD cbOut = 0;
DWORD cbIn = 0;
ntlm_challenge * challenge;
- const char * encoded = NULL;
if (NTLM_asServer.fHaveCtxtHandle)
_DeleteSecurityContext(&NTLM_asServer.hctxt);
challenge = (ntlm_challenge *) fResult;
Use_Unicode = NTLM_NEGOTIATE_UNICODE & challenge->flags;
NTLM_LocalCall = NTLM_NEGOTIATE_THIS_IS_LOCAL_CALL & challenge->flags;
- encoded = base64_encode_bin((char *) fResult, cbOut);
+ struct base64_encode_ctx ctx;
+ base64_encode_init(&ctx);
+ static uint8_t encoded[8192];
+ size_t dstLen = base64_encode_update(&ctx, encoded, cbOut, reinterpret_cast<const uint8_t*>(fResult));
+ assert(dstLen < sizeof(encoded));
+ dstLen += base64_encode_final(&ctx, encoded+dstLen);
+ assert(dstLen < sizeof(encoded));
+ encoded[dstLen] = '\0';
+ return reinterpret_cast<char *>(encoded);
}
- return encoded;
+ return NULL;
}
BOOL WINAPI SSP_ValidateNTLMCredentials(PVOID PAutenticateBuf, int AutenticateLen, char * credentials)
{
DWORD cbOut = 0;
DWORD cbIn = 0;
- const char * encoded = NULL;
if (NTLM_asServer.fHaveCtxtHandle)
_DeleteSecurityContext(&NTLM_asServer.hctxt);
}
*Status = SSP_OK;
} while (0);
- if (pServerBuf != NULL && cbOut > 0)
- encoded = base64_encode_bin((char *) pServerBuf, cbOut);
- return encoded;
+ if (pServerBuf != NULL && cbOut > 0) {
+ struct base64_encode_ctx ctx;
+ base64_encode_init(&ctx);
+ static uint8_t encoded[8192];
+ size_t dstLen = base64_encode_update(&ctx, encoded, cbOut, reinterpret_cast<const uint8_t*>(pServerBuf));
+ assert(dstLen < sizeof(encoded));
+ dstLen += base64_encode_final(&ctx, encoded+dstLen);
+ assert(dstLen < sizeof(encoded));
+ encoded[dstLen] = '\0';
+ return reinterpret_cast<char *>(encoded);
+ }
+ return NULL;
}
const char * WINAPI SSP_ValidateNegotiateCredentials(PVOID PAutenticateBuf, int AutenticateLen, PBOOL fDone, int * Status, char * credentials)
{
DWORD cbOut = 0;
DWORD cbIn = 0;
- const char * encoded = NULL;
memcpy(pClientBuf, PAutenticateBuf, AutenticateLen);
ZeroMemory(pServerBuf, cbMaxToken);
}
*Status = SSP_OK;
} while (0);
- if (pServerBuf != NULL && cbOut > 0)
- encoded = base64_encode_bin((char *) pServerBuf, cbOut);
- return encoded;
+ if (pServerBuf != NULL && cbOut > 0) {
+ struct base64_encode_ctx ctx;
+ base64_encode_init(&ctx);
+ static uint8_t encoded[8192];
+ size_t dstLen = base64_encode_update(&ctx, encoded, cbOut, reinterpret_cast<const uint8_t*>(pServerBuf));
+ assert(dstLen < sizeof(encoded));
+ dstLen += base64_encode_final(&ctx, encoded+dstLen);
+ assert(dstLen < sizeof(encoded));
+ encoded[dstLen] = '\0';
+ return reinterpret_cast<char *>(encoded);
+ }
+ return NULL;
}