Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Unified Diff: crypto_pkcs11.cc

Issue 6338003: Explicitly logging out the token to avoid leaving it in a non-stable state. (Closed) Base URL: http://git.chromium.org/git/entd.git@master
Patch Set: Returning early on logout failure. Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto_pkcs11.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto_pkcs11.cc
diff --git a/crypto_pkcs11.cc b/crypto_pkcs11.cc
index a31aeb940a1e882f3b68478dbf8a4855d09cde42..0f5502b52ac560a1154c65d373d5ef83005ef79d 100644
--- a/crypto_pkcs11.cc
+++ b/crypto_pkcs11.cc
@@ -499,6 +499,8 @@ bool Pkcs11::Session::InitializeTemplate(
BindMethod(instance_t, &Pkcs11::Session::FindObjects, "findObjects");
BindMethod(instance_t, &Pkcs11::Session::CreateObject, "createObject");
+ BindMethod(instance_t, &Pkcs11::Session::LogoutAndClose, "logoutAndClose");
+
return true;
}
@@ -543,6 +545,12 @@ v8::Handle<v8::Value> Pkcs11::Session::Close(const v8::Arguments& args) {
if (!session_handle_)
return ThrowException("Not open");
+ if (logged_in_) {
+ if (!OkOrThrow(C_Logout(session_handle_)))
+ return v8::Undefined();
+ logged_in_ = false;
+ }
+
OkOrThrow(C_CloseSession(session_handle_));
session_handle_ = 0;
return v8::Undefined();
@@ -561,6 +569,8 @@ v8::Handle<v8::Value> Pkcs11::Session::Login(const v8::Arguments& args) {
v8::String::AsciiValue ascii_pin(args[1]);
+ logged_in_ = false;
+
CK_RV rv = C_Login(session_handle_, user_type,
reinterpret_cast<CK_CHAR_PTR>(*ascii_pin),
ascii_pin.length());
@@ -571,11 +581,20 @@ v8::Handle<v8::Value> Pkcs11::Session::Login(const v8::Arguments& args) {
if (!OkOrThrow(rv))
return v8::Undefined();
+ logged_in_ = true;
return v8::True();
}
v8::Handle<v8::Value> Pkcs11::Session::Logout(const v8::Arguments& args) {
OkOrThrow(C_Logout(session_handle_));
+ logged_in_ = false;
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> Pkcs11::Session::LogoutAndClose(
+ const v8::Arguments& args) {
+ Logout(args);
+ Close(args);
return v8::Undefined();
}
« no previous file with comments | « crypto_pkcs11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698