From: "cron2 (Code Review)" Date: Sun, 8 Sep 2024 20:06:18 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., selva.nair@...277..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="bYASBNgXcT4="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Protect cached username, password and token on client List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: selvanair Cc: flichtenheld , plaisthos , openvpn-devel --bYASBNgXcT4= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/72= 8?usp=3Demail ) Change subject: Protect cached username, password and token on client ...................................................................... Protect cached username, password and token on client Keep the memory segment containing username and password in "struct user_pass" encrypted. Works only on Windows. Username and auth-token cached by the server are not covered here. v2: Encrypt username and password separately as it looks more robust. We continue to depend on the username and password buffer sizes to be a multiple of CRYPTPROTECTMEMORY_BLOCK_SIZE =3D 16, which is the case now. An error is logged if this is not the case. v3: move up ASSERT in auth_token.c Change-Id: I42e17e09a02f01aedadc2b03f9527967f6e1e8ff Signed-off-by: Selva Nair Acked-by: Frank Lichtenheld Message-Id: <20240906112908.1009-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29= 079.html Signed-off-by: Gert Doering --- M src/openvpn/auth_token.c M src/openvpn/misc.c M src/openvpn/misc.h M src/openvpn/proxy.c M src/openvpn/ssl.c M src/openvpn/ssl_verify.c M src/openvpn/win32.c M src/openvpn/win32.h M tests/unit_tests/openvpn/test_user_pass.c 9 files changed, 153 insertions(+), 8 deletions(-) diff --git a/src/openvpn/auth_token.c b/src/openvpn/auth_token.c index 6787ea7..5de65cb 100644 --- a/src/openvpn/auth_token.c +++ b/src/openvpn/auth_token.c @@ -301,6 +301,7 @@ * Base64 is <=3D input and input is < USER_PASS_LEN, so using USER_PA= SS_LEN * is safe here but a bit overkill */ + ASSERT(up && !up->protected); uint8_t b64decoded[USER_PASS_LEN]; int decoded_len =3D openvpn_base64_decode(up->password + strlen(SESSIO= N_ID_PREFIX), b64decoded, USER_PASS_LEN); diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index 598fbae..ef4ab69 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -223,6 +223,7 @@ bool password_from_stdin =3D false; bool response_from_stdin =3D true; + unprotect_user_pass(up); if (flags & GET_USER_PASS_PREVIOUS_CREDS_FAILED) { msg(M_WARN, "Note: previous '%s' credentials failed", prefix); @@ -479,14 +480,18 @@ secure_memzero(up, sizeof(*up)); up->nocache =3D nocache; } - /* - * don't show warning if the pass has been replaced by a token: this i= s an - * artificial "auth-nocache" - */ - else if (!warn_shown) + else { - msg(M_WARN, "WARNING: this configuration may cache passwords in me= mory -- use the auth-nocache option to prevent this"); - warn_shown =3D true; + protect_user_pass(up); + /* + * don't show warning if the pass has been replaced by a token: th= is is an + * artificial "auth-nocache" + */ + if (!warn_shown) + { + msg(M_WARN, "WARNING: this configuration may cache passwords i= n memory -- use the auth-nocache option to prevent this"); + warn_shown =3D true; + } } } @@ -495,6 +500,7 @@ { if (strlen(token)) { + unprotect_user_pass(tk); strncpynt(tk->password, token, USER_PASS_LEN); tk->token_defined =3D true; @@ -505,6 +511,7 @@ { tk->defined =3D true; } + protect_user_pass(tk); } } @@ -513,6 +520,7 @@ { if (strlen(username)) { + unprotect_user_pass(tk); /* Clear the username before decoding to ensure no old material is= left * and also allow decoding to not use all space to ensure the last= byte is * always 0 */ @@ -523,6 +531,7 @@ { msg(D_PUSH, "Error decoding auth-token-username"); } + protect_user_pass(tk); } } @@ -779,3 +788,43 @@ return combined_path; } + +void +protect_user_pass(struct user_pass *up) +{ + if (up->protected) + { + return; + } +#ifdef _WIN32 + if (protect_buffer_win32(up->username, sizeof(up->username)) + && protect_buffer_win32(up->password, sizeof(up->password))) + { + up->protected =3D true; + } + else + { + purge_user_pass(up, true); + } +#endif +} + +void +unprotect_user_pass(struct user_pass *up) +{ + if (!up->protected) + { + return; + } +#ifdef _WIN32 + if (unprotect_buffer_win32(up->username, sizeof(up->username)) + && unprotect_buffer_win32(up->password, sizeof(up->password))) + { + up->protected =3D false; + } + else + { + purge_user_pass(up, true); + } +#endif +} diff --git a/src/openvpn/misc.h b/src/openvpn/misc.h index 963f3e6..a967ec8 100644 --- a/src/openvpn/misc.h +++ b/src/openvpn/misc.h @@ -60,6 +60,7 @@ * use this second bool to track if the token (password) is defined */ bool token_defined; bool nocache; + bool protected; /* max length of username/password */ #ifdef ENABLE_PKCS11 @@ -207,6 +208,19 @@ struct buffer prepend_dir(const char *dir, const char *path, struct gc_arena *gc); +/** + * Encrypt username and password buffers in user_pass + */ +void +protect_user_pass(struct user_pass *up); + +/** + * Decrypt username and password buffers in user_pass + */ +void +unprotect_user_pass(struct user_pass *up); + + #define _STRINGIFY(S) #S /* *INDENT-OFF* - uncrustify need to ignore this macro */ #define MAC_FMT _STRINGIFY(%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx) diff --git a/src/openvpn/proxy.c b/src/openvpn/proxy.c index eddacc9..404ea08 100644 --- a/src/openvpn/proxy.c +++ b/src/openvpn/proxy.c @@ -291,13 +291,14 @@ UP_TYPE_PROXY, flags); static_proxy_user_pass.nocache =3D p->options.nocache; + protect_user_pass(&static_proxy_user_pass); } /* * Using cached credentials */ p->queried_creds =3D true; - p->up =3D static_proxy_user_pass; + p->up =3D static_proxy_user_pass; /* this is a copy of protected memor= y */ } #if 0 @@ -668,6 +669,7 @@ { clear_user_pass_http(); } + unprotect_user_pass(&p->up); } /* are we being called again after getting the digest server nonce in = the previous transaction? */ diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 14c38cf..c2c9c29 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -243,6 +243,7 @@ void pem_password_setup(const char *auth_file) { + unprotect_user_pass(&passbuf); if (!strlen(passbuf.password)) { get_user_pass(&passbuf, auth_file, UP_TYPE_PRIVATE_KEY, GET_USER_P= ASS_MANAGEMENT|GET_USER_PASS_PASSWORD_ONLY); @@ -256,6 +257,7 @@ { /* prompt for password even if --askpass wasn't specified */ pem_password_setup(NULL); + ASSERT(!passbuf.protected); strncpynt(buf, passbuf.password, size); purge_user_pass(&passbuf, false); @@ -295,6 +297,7 @@ if (!auth_user_pass.defined && !auth_token.defined) { + unprotect_user_pass(&auth_user_pass); #ifdef ENABLE_MANAGEMENT if (auth_challenge) /* dynamic challenge/response */ { @@ -2094,6 +2097,7 @@ { up =3D &auth_token; } + unprotect_user_pass(up); if (!write_string(buf, up->username, -1)) { @@ -2106,8 +2110,11 @@ /* save username for auth-token which may get pushed later */ if (session->opt->pull && up !=3D &auth_token) { + unprotect_user_pass(&auth_token); strncpynt(auth_token.username, up->username, USER_PASS_LEN); + protect_user_pass(&auth_token); } + protect_user_pass(up); /* respect auth-nocache */ purge_user_pass(&auth_user_pass, false); } diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 0b0e2c3..74b2775 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -1594,6 +1594,8 @@ { struct key_state *ks =3D &session->key[KS_PRIMARY]; /* primary ke= y */ + ASSERT(up && !up->protected); + #ifdef ENABLE_MANAGEMENT int man_def_auth =3D KMDA_UNDEF; diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index 72496fa..86556a8 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -1658,4 +1658,40 @@ return wcsnicmp(system_dir, plugin_path, wcslen(system_dir)) =3D=3D 0; } +bool +protect_buffer_win32(char *buf, size_t len) +{ + bool ret; + if (len % CRYPTPROTECTMEMORY_BLOCK_SIZE) + { + msg(M_NONFATAL, "Error: Unable to encrypt memory: buffer size not = a multiple of %d", + CRYPTPROTECTMEMORY_BLOCK_SIZE); + return false; + } + ret =3D CryptProtectMemory(buf, len, CRYPTPROTECTMEMORY_SAME_PROCESS); + if (!ret) + { + msg(M_NONFATAL | M_ERRNO, "Failed to encrypt memory."); + } + return ret; +} + +bool +unprotect_buffer_win32(char *buf, size_t len) +{ + bool ret; + if (len % CRYPTPROTECTMEMORY_BLOCK_SIZE) + { + msg(M_NONFATAL, "Error: Unable to decrypt memory: buffer size not = a multiple of %d", + CRYPTPROTECTMEMORY_BLOCK_SIZE); + return false; + } + ret =3D CryptUnprotectMemory(buf, len, CRYPTPROTECTMEMORY_SAME_PROCESS= ); + if (!ret) + { + msg(M_FATAL | M_ERRNO, "Failed to decrypt memory."); + } + return ret; +} + #endif /* ifdef _WIN32 */ diff --git a/src/openvpn/win32.h b/src/openvpn/win32.h index ffad6d9..081beeb 100644 --- a/src/openvpn/win32.h +++ b/src/openvpn/win32.h @@ -351,5 +351,27 @@ bool plugin_in_trusted_dir(const WCHAR *plugin_path); +/** + * Encrypt a region of memory using CryptProtectMemory() + * with access restricted to the current process. + * + * - buf pointer to the memory + * - len number of bytes to encrypt -- must be a multiple of + * CRYPTPROTECTMEMORY_BLOCK_SIZE =3D 16 + */ +bool +protect_buffer_win32(char *buf, size_t len); + +/** + * Decrypt a previously encrypted region of memory using CryptUnProtectMem= ory() + * with access restricted to the current process. + * + * - buf pointer to the memory + * - len number of bytes to encrypt -- must be a multiple of + * CRYPTPROTECTMEMORY_BLOCK_SIZE =3D 16 + */ +bool +unprotect_buffer_win32(char *buf, size_t len); + #endif /* ifndef OPENVPN_WIN32_H */ #endif /* ifdef _WIN32 */ diff --git a/tests/unit_tests/openvpn/test_user_pass.c b/tests/unit_tests/o= penvpn/test_user_pass.c index de60291..4dc4b83 100644 --- a/tests/unit_tests/openvpn/test_user_pass.c +++ b/tests/unit_tests/openvpn/test_user_pass.c @@ -83,6 +83,18 @@ return 0; } +bool +protect_buffer_win32(char *buf, size_t len) +{ + return true; +} + +bool +unprotect_buffer_win32(char *buf, size_t len) +{ + return true; +} + /* tooling */ static void reset_user_pass(struct user_pass *up) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/728?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I42e17e09a02f01aedadc2b03f9527967f6e1e8ff Gerrit-Change-Number: 728 Gerrit-PatchSet: 4 Gerrit-Owner: selvanair Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --bYASBNgXcT4= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Protect cached username, password and token on=
 client

Keep the memory segment containing username and password in<= br>"struct user_pass" encrypted. Works only on Windows.

Us= ername and auth-token cached by the server are not covered
here.

= v2: Encrypt username and password separately as it looks more
robust. We= continue to depend on the username and password buffer
sizes to be a mu= ltiple of CRYPTPROTECTMEMORY_BLOCK_SIZE =3D 16,
which is the case now. A= n error is logged if this is not the case.

v3: move up ASSERT in aut= h_token.c

Change-Id: I42e17e09a02f01aedadc2b03f9527967f6e1e8ff
Si= gned-off-by: Selva Nair <selva.nair@...277...>
Acked-by: Frank Lic= htenheld <frank@...2641...>
Message-Id: <20240906112908.1009-1-= gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1514...= s.sourceforge.net/msg29079.html
Signed-off-by: Gert Doering <gert@...493...= 1296...>
---
M src/openvpn/auth_token.c
M src/openvpn/misc.cM src/openvpn/misc.h
M src/openvpn/proxy.c
M src/openvpn/ssl.c
M = src/openvpn/ssl_verify.c
M src/openvpn/win32.c
M src/openvpn/win32.h<= br>M tests/unit_tests/openvpn/test_user_pass.c
9 files changed, 153 inse= rtions(+), 8 deletions(-)

diff --git a/src/openvpn/auth_token.c b/src/openvpn/auth_token.c<=
br>index 6787ea7..5de65cb 100644
--- a/src/openvpn/au= th_token.c
+++ b/src/openvpn/auth_token.c
@= @ -301,6 +301,7 @@
* Base64 is <=3D input and inpu= t is < USER_PASS_LEN, so using USER_PASS_LEN
* is = safe here but a bit overkill
*/
+ ASSERT(up && !up->protecte= d);
uint8_t b64decoded[USER_PASS_LEN];
int decoded_len =3D openvpn_base64_decode(up->password + strlen(SE= SSION_ID_PREFIX),
= b64decoded, USER_PASS_LEN);
diff --git a/src/openvpn/mi= sc.c b/src/openvpn/misc.c
index 598fbae..ef4ab69 100644

--- a/src/openvpn/misc.c
+++ b/src/openvpn/mis= c.c
@@ -223,6 +223,7 @@
bool passw= ord_from_stdin =3D false;
bool response_from_stdin= =3D true;

+ unprotect_user_pass(up);
if (flag= s & GET_USER_PASS_PREVIOUS_CREDS_FAILED)
{
msg(M_WARN, "Note: previous '%s' cre= dentials failed", prefix);
@@ -479,14 +480,18 @@
secure_memzero(up, sizeof(*up));
= up->nocache =3D nocache;
}
- /*
- * don't show warning if the pass has been replace= d by a token: this is an
- */
- else if (!warn_shown)
+ else
{
- msg(M_WARN, "WARNING: this configura= tion may cache passwords in memory -- use the auth-nocache option to preven= t this");
- = warn_shown =3D true;
+ protect_user_pass(up);
+ /*
+ * don't show warning if the pass has been replaced by a to= ken: this is an
+ = * artificial "auth-nocache"
+ */
+ if (!warn_shown)
+ {
+ msg(M_WARN, "WARNING: this configuration may cac= he passwords in memory -- use the auth-nocache option to prevent this"= );
+ warn_= shown =3D true;
+ = }
}
}
@@ -495,6 +500,7 @@
{
if (strl= en(token))
{
+ unprotect_user_pass(tk);
str= ncpynt(tk->password, token, USER_PASS_LEN);
tk-= >token_defined =3D true;

@@ -505,6 +51= 1,7 @@
{
tk->defin= ed =3D true;
}
+ protect_user_pass(tk);
}
}

@@ -513,6 +520,7 @@
{
if (strlen(username))
= {
+ unpro= tect_user_pass(tk);
/* Clear the username before d= ecoding to ensure no old material is left
* and a= lso allow decoding to not use all space to ensure the last byte is * always 0 */
@@ -523,6 +531,7 @@<= br> {
msg(D_PUSH, "Error de= coding auth-token-username");
}
+ protect_user_pass(tk);
}
}

@= @ -779,3 +788,43 @@

return combined_= path;
}
+
+void+protect_user_pass(struct user= _pass *up)
+{<= br>+ if (up->protected)
+ {
+ return;

+ }
+#ifdef _WIN32
+ if (protect_buffer_win32(up->username, sizeof(up->= ;username))
+ = && protect_buffer_win32(up->password, sizeof(up->password)))<= /span>
+ {
+ up->protected =3D true;=

+ }
+ else

+ {
+ purge_user_pass(up, true);
+ }
+#endif
+}
+
= +void
+unprotect_user_pass(struct user_pass *up)
+{
+ if (!up->protected)
+ {

+ return;
+ }
+#ifdef _WIN32
+ && = unprotect_buffer_win32(up->password, sizeof(up->password)))+ {
+ up->protected =3D false;
+ }
+ else
+ {
+ purge_user_pass(up, true);
+ }
+#endif
+}=
diff --git a/src/openvpn/misc.h b/src/openvpn/misc.h
index 963f3e6..a967ec8 100644
--- a/src/openvpn/= misc.h
+++ b/src/openvpn/misc.h
@@ -60,6 +6= 0,7 @@
* use this second bool to track if the token (= password) is defined */
bool token_defined;
= bool nocache;
+ bool protected;

/* max length o= f username/password */
#ifdef ENABLE_PKCS11
@@ -207,6 +208,19 @@

struct buffer
prep= end_dir(const char *dir, const char *path, struct gc_arena *gc);
=
+/**+ * Encrypt username and pass= word buffers in user_pass
+ */
+void
+protect_user_pass(struct = user_pass *up);
+
+/**
+ * Decrypt username and password buffer= s in user_pass
+ */
+void
+unprotect_user_pass(struct user_pass= *up);
+
+

#define _STRIN= GIFY(S) #S
/* *INDENT-OFF* - uncrustify need to ignore thi= s macro */
#define MAC_FMT _STRINGIFY(%02hhx:%02hhx:%02hhx= :%02hhx:%02hhx:%02hhx)
diff --git a/src/openvpn/proxy.c b/s= rc/openvpn/proxy.c
index eddacc9..404ea08 100644
= --- a/src/openvpn/proxy.c
+++ b/src/openvpn/proxy.c
@@ -291,13 +291,14 @@
= UP_TYPE_PROXY,
flags);
static_proxy_user_pass.nocache =3D p->options.nocache;
+ protect_user_pas= s(&static_proxy_user_pass);
}

/*
* Using cached credentials
*/
p->queried_creds =3D true;
- p->up =3D static_p= roxy_user_pass;
+ = p->up =3D static_proxy_user_pass; /* this is a copy of protected memory = */
}

#if 0
@@ -668,6 +669,7 @@

{
= clear_user_pass_http();
}
+ unprotect_user_pass(&p->= up);
}

/* are w= e being called again after getting the digest server nonce in the previous = transaction? */
diff --git a/src/openvpn/ssl.c b/src/openvp= n/ssl.c
index 14c38cf..c2c9c29 100644
--- a= /src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
= @@ -243,6 +243,7 @@
void
pem_password_set= up(const char *auth_file)
{
+ unprotect_user_pass(&passbuf);
<= span> if (!strlen(passbuf.password))

{
<= span> get_user_pass(&passbuf, auth_file, UP_TYPE_PRIVATE_KEY, G= ET_USER_PASS_MANAGEMENT|GET_USER_PASS_PASSWORD_ONLY);

@@ -2= 56,6 +257,7 @@
{
/* prompt fo= r password even if --askpass wasn't specified */
= pem_password_setup(NULL);
+ ASSERT(!passbuf.protected);
strnc= pynt(buf, passbuf.password, size);
purge_user_pass= (&passbuf, false);

@@ -295,6 +297,7 @= @

if (!auth_user_pass.defined &&= amp; !auth_token.defined)
{
+ unprotect_user_pass(&auth_user_pas= s);
#ifdef ENABLE_MANAGEMENT
if (= auth_challenge) /* dynamic challenge/response */
{=
@@ -2094,6 +2097,7 @@
{ up =3D &auth_token;
}
+ unprotect_user_p= ass(up);

if (!write_string(buf, = up->username, -1))
{
@@ -2106,8= +2110,11 @@
/* save username for auth-token which= may get pushed later */
if (session->opt->p= ull && up !=3D &auth_token)
{+ unprotect_user_p= ass(&auth_token);
strncpynt(auth_token.use= rname, up->username, USER_PASS_LEN);
+ protect_user_pass(&auth_token);<= br> }
+= protect_user_pass(up);
/* respect auth-noc= ache */
purge_user_pass(&auth_user_pass, false= );
}
diff --git a/src/openvpn/ssl_veri= fy.c b/src/openvpn/ssl_verify.c
index 0b0e2c3..74b2775 1006= 44
--- a/src/openvpn/ssl_verify.c
+++ b/src= /openvpn/ssl_verify.c
@@ -1594,6 +1594,8 @@
{

struct key_state *ks =3D &session->key[KS_P= RIMARY]; /* primary key */

+ ASSERT(up && !up->protected);<= /span>
+
#i= fdef ENABLE_MANAGEMENT
int man_def_auth =3D KMDA_UNDEF= ;

diff --git a/src/openvpn/win32.c b/src/= openvpn/win32.c
index 72496fa..86556a8 100644
--- a/src/openvpn/win32.c

+++ b/src/openvpn/win32.c
@@ -1658,4 +1658,40 @@
return wcsnicmp(sys= tem_dir, plugin_path, wcslen(system_dir)) =3D=3D 0;
}

+bool
+protect_buffer_win32(= char *buf, size_t len)
+ bool ret;
+ if (len % CRYPTPR= OTECTMEMORY_BLOCK_SIZE)
+ {
+ ms= g(M_NONFATAL, "Error: Unable to encrypt memory: buffer size not a mult= iple of %d",
+ = CRYPTPROTECTMEMORY_BLOCK_SIZE);
+ return false;
+ }
+ ret =3D CryptProtectMemory(buf, len, CRYPTPROTECTMEMORY_SAME_= PROCESS);
+ if (!r= et)
+ {
= + msg(M_NONFATAL | M_ERR= NO, "Failed to encrypt memory.");
+ }
+ return ret;
+}
+
<= span style=3D"color: hsl(120, 100%, 40%);">+bool

+unprotect_buffer_win32(char *buf, size_t len)<= /span>
+{
+ bool ret;
+ if (len % CRYPTPROTECTMEMORY_BLOCK_SIZE)=
+ {
+ msg(M_NONFATAL, "Err= or: Unable to decrypt memory: buffer size not a multiple of %d",
+ CRYPTPROTECTM= EMORY_BLOCK_SIZE);
+ = return false;
= + }
+ ret =3D C= ryptUnprotectMemory(buf, len, CRYPTPROTECTMEMORY_SAME_PROCESS);
<= span style=3D"color: hsl(120, 100%, 40%);">+ if (!ret)

+ {
+ msg(M_FATAL | M_ERRNO, "Failed to decr= ypt memory.");
+= }
+ return ret= ;
+}
+
#endif /* ifdef _W= IN32 */
diff --git a/src/openvpn/win32.h b/src/openvpn/win3= 2.h
index ffad6d9..081beeb 100644
--- a/src= /openvpn/win32.h
+++ b/src/openvpn/win32.h
= @@ -351,5 +351,27 @@
bool
plugin_in_trust= ed_dir(const WCHAR *plugin_path);

+/**
+ * Encrypt a region of memory using CryptProtectMemory()<= /span>
+ * with access restr= icted to the current process.
+ *
+ * - bu= f pointer to the memory
+ * - len number of bytes to encrypt -- must be a multiple of=
+ * CRYPTPROTECTMEM= ORY_BLOCK_SIZE =3D 16
+ */
+bool+protect_buffer_win32(char *bu= f, size_t len);
+
+/**
+ * Decrypt a previously encrypted regio= n of memory using CryptUnProtectMemory()
+ * with access restricted to the current process.
+ *
+ * - buf pointer to the memory+ * - len number of bytes t= o encrypt -- must be a multiple of
+ * CRYPTPROTECTMEMORY_BLOCK_SIZE =3D 16
+ */

+bool
+unprotect_buffer_win32(char *buf, size_t len);
+
#endif /* ifndef O= PENVPN_WIN32_H */
#endif /* ifdef _WIN32 */
diff --git a/tests/unit_tests/openvpn/test_user_pass.c b/tests/unit_tests= /openvpn/test_user_pass.c

index de60291..4dc4b83 100644
--- a/tests/unit_tests/openvpn/test_user_pass.c
+++ b/tests/unit_tests/openvpn/test_user_pass.c

@@ -83,6 = +83,18 @@
return 0;
}

+bool
+protect_buffer_win32(char *buf, = size_t len)

+{=
+ return true;+}
+
+bool
+unprot= ect_buffer_win32(char *buf, size_t len)
+{
+ return true;
+}=
+
/= * tooling */
static void
reset_user_pass(= struct user_pass *up)

To view, visit change 728<= /a>. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I42e17e09a02f01aedadc2b03f95= 27967f6e1e8ff
Gerrit-Change-Number: 728
Gerrit-PatchSet: 4
Gerrit-Owner: selvanair <selva.nair@...1354...= ..>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--bYASBNgXcT4=--