//
void MacContext::activate()
{
- if (!mActive)
- {
- check(CSSM_CSP_CreateMacContext(attachment()->handle(), mAlgorithm,
- mKey, &mHandle));
- mActive = true;
- if (cred())
- cred(cred()); // install explicitly
- }
+ {
+ StLock<Mutex> _(mActivateMutex);
+ if (!mActive)
+ {
+ check(CSSM_CSP_CreateMacContext(attachment()->handle(), mAlgorithm,
+ mKey, &mHandle));
+ mActive = true;
+ }
+ }
+
+ if (cred())
+ cred(cred()); // install explicitly
}