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

Unified Diff: crypto_pkcs11.h

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 | « base_policy/policy-utils.js ('k') | crypto_pkcs11.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto_pkcs11.h
diff --git a/crypto_pkcs11.h b/crypto_pkcs11.h
index 5032f4a42d04647cf4002d14412bcda0e06b4aac..0dd48207b16155295f23c298d3c4c4e2541ce2b4 100644
--- a/crypto_pkcs11.h
+++ b/crypto_pkcs11.h
@@ -125,8 +125,10 @@ class Pkcs11 : public Scriptable<Pkcs11> {
return "entd.crypto.Pkcs11.Session";
};
- Session() : session_handle_(0) {}
+ Session() : session_handle_(0), logged_in_(false) {}
~Session() {
+ if (logged_in_)
+ C_Logout(session_handle_);
if (session_handle_)
C_CloseSession(session_handle_);
}
@@ -152,12 +154,16 @@ class Pkcs11 : public Scriptable<Pkcs11> {
v8::Handle<v8::Value> CreateObject(const v8::Arguments& args);
v8::Handle<v8::Value> GenerateKeyPair(const v8::Arguments& args);
+ // Helper functions.
+ v8::Handle<v8::Value> LogoutAndClose(const v8::Arguments& args);
+
// Invoke the 'bool Refresh()' method from script.
v8::Handle<v8::Value> CallRefresh(const v8::Arguments& args);
private:
CK_SLOT_ID slot_id_;
CK_SESSION_HANDLE session_handle_;
+ bool logged_in_;
};
class Object : public Scriptable<Object> {
« no previous file with comments | « base_policy/policy-utils.js ('k') | crypto_pkcs11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698