Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1034 lines
27 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. digesta.cxx
  5. Abstract:
  6. sspi ansi interface for digest package.
  7. Author:
  8. Adriaan Canter (adriaanc) 01-Aug-1998
  9. --*/
  10. #include "include.hxx"
  11. static SecurityFunctionTableA
  12. SecTableA =
  13. {
  14. SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION,
  15. EnumerateSecurityPackagesA,
  16. NULL, // QueryCredentialsAttributesA
  17. AcquireCredentialsHandleA,
  18. FreeCredentialsHandle,
  19. NULL, // SspiLogonUserA
  20. InitializeSecurityContextA,
  21. AcceptSecurityContext,
  22. CompleteAuthToken,
  23. DeleteSecurityContext,
  24. ApplyControlToken,
  25. QueryContextAttributesA,
  26. ImpersonateSecurityContext,
  27. RevertSecurityContext,
  28. MakeSignature,
  29. VerifySignature,
  30. FreeContextBuffer,
  31. QuerySecurityPackageInfoA,
  32. NULL, // Reserved3
  33. NULL, // Reserved4
  34. NULL, // ExportSecurityContext
  35. NULL, // ImportSecurityContextA
  36. NULL, // Reserved7
  37. NULL, // Reserved8
  38. NULL, // QuerySecurityContextToken
  39. NULL, // EncryptMessage
  40. NULL // DecryptMessage
  41. };
  42. //--------------------------------------------------------------------------
  43. //
  44. // Function: InitSecurityInterfaceA
  45. //
  46. // Synopsis:
  47. //
  48. // Effects:
  49. //
  50. // Arguments:
  51. //
  52. // Requires:
  53. //
  54. // Returns:
  55. //
  56. // Notes:
  57. //
  58. //
  59. //--------------------------------------------------------------------------
  60. extern "C" PSecurityFunctionTableA SEC_ENTRY
  61. InitSecurityInterfaceA(VOID)
  62. {
  63. PSecurityFunctionTableA pSecTableA = &SecTableA;
  64. return pSecTableA;
  65. }
  66. //--------------------------------------------------------------------------
  67. //
  68. // Function: AcquireCredentialsHandleA
  69. //
  70. // Synopsis:
  71. //
  72. // Effects:
  73. //
  74. // Arguments:
  75. //
  76. // Requires:
  77. //
  78. // Returns:
  79. //
  80. // Notes:
  81. //
  82. // HEINOUS SSPI HACK here: AcquireCredentialsHandle is called with the package
  83. // name ("Digest") as the package identifier. When AcquireCredentialsHandle returns
  84. // to the caller PCredHandle->dwLower is set by security.dll to be the index of
  85. // the package returned. EnumerateSecurityPackages. This is how SSPI resolves the
  86. // correct provider dll when subsequent calls are made through the dispatch table
  87. // (PSecurityFunctionTale). Any credential *or* context handle handed out by the
  88. // package must have the dwLower member set to this index so that subsequent calls
  89. // can resolve the dll from the handle.
  90. //
  91. //--------------------------------------------------------------------------
  92. extern "C" SECURITY_STATUS SEC_ENTRY
  93. AcquireCredentialsHandleA(
  94. LPSTR pszPrincipal, // Name of principal
  95. LPSTR pszPackageName, // Name of package
  96. DWORD dwCredentialUse, // Flags indicating use
  97. VOID SEC_FAR * pvLogonId, // Pointer to logon ID
  98. VOID SEC_FAR * pAuthData, // Package specific data
  99. SEC_GET_KEY_FN pGetKeyFn, // Pointer to GetKey() func
  100. VOID SEC_FAR * pvGetKeyArgument, // Value to pass to GetKey()
  101. PCredHandle phCredential, // (out) Cred Handle
  102. PTimeStamp ptsExpiry // (out) Lifetime (optional)
  103. )
  104. {
  105. if (!InitGlobals())
  106. return SEC_E_INTERNAL_ERROR;
  107. SECURITY_STATUS ssResult;
  108. // Outbound credentials only.
  109. if (!(dwCredentialUse & SECPKG_CRED_OUTBOUND)
  110. || (dwCredentialUse & SECPKG_CRED_INBOUND))
  111. {
  112. DIGEST_ASSERT(FALSE);
  113. ssResult = SEC_E_UNKNOWN_CREDENTIALS;
  114. goto exit;
  115. }
  116. // Logon to cache.
  117. // Logon to the cache and get the session context.
  118. CSess *pSess;
  119. PSEC_WINNT_AUTH_IDENTITY_EXA pSecIdExA;
  120. PSEC_WINNT_AUTH_IDENTITY pSecId;
  121. // HTTP clients will pass in this structure.
  122. pSecIdExA = (PSEC_WINNT_AUTH_IDENTITY_EXA) pAuthData;
  123. // Non-HTTP clients (OE4, OE5) will pass in this structure.
  124. pSecId = (PSEC_WINNT_AUTH_IDENTITY) pAuthData;
  125. // Check for HTTP client application logon.
  126. if (pAuthData
  127. && (pSecIdExA->Version == sizeof(SEC_WINNT_AUTH_IDENTITY_EXA))
  128. && pSecIdExA->User
  129. && pSecIdExA->UserLength == sizeof(DIGEST_PKG_DATA))
  130. {
  131. DIGEST_PKG_DATA *pPkgData;
  132. pPkgData = (DIGEST_PKG_DATA*) pSecIdExA->User;
  133. pSess = g_pCache->LogOnToCache(pPkgData->szAppCtx,
  134. pPkgData->szUserCtx, TRUE);
  135. }
  136. // Check for non-HTTP client application logon.
  137. else
  138. {
  139. // Find or create the single non-HTTP session.
  140. pSess = g_pCache->LogOnToCache(NULL, NULL, FALSE);
  141. // If user+pass+realm (domain) is passed in, create and
  142. // attach a matching credential to this session.
  143. if (pAuthData
  144. && pSecId->User
  145. && pSecId->UserLength
  146. && pSecId->Domain
  147. && pSecId->DomainLength
  148. && pSecId->Password
  149. && pSecId->PasswordLength)
  150. {
  151. // Create a credential with the information passed in.
  152. CCred *pCred;
  153. CCredInfo *pInfo;
  154. pInfo = new CCredInfo(NULL, (LPSTR) pSecId->Domain,
  155. (LPSTR) pSecId->User, (LPSTR) pSecId->Password, NULL, NULL);
  156. if (pInfo)
  157. {
  158. pCred = g_pCache->CreateCred(pSess, pInfo);
  159. delete pInfo;
  160. }
  161. }
  162. }
  163. // BUGBUG - return better error codes.
  164. if (!pSess)
  165. {
  166. DIGEST_ASSERT(FALSE);
  167. ssResult = SEC_E_INTERNAL_ERROR;
  168. goto exit;
  169. }
  170. // Hand out the session handle.
  171. phCredential->dwUpper = g_pCache->MapSessionToHandle(pSess);
  172. // ***** phCredential->dwLower will be set by security.dll *****
  173. ssResult = SEC_E_OK;
  174. exit:
  175. return ssResult;
  176. }
  177. //--------------------------------------------------------------------------
  178. //
  179. // Function: FreeCredentialsHandle
  180. //
  181. // Synopsis:
  182. //
  183. // Effects:
  184. //
  185. // Arguments:
  186. //
  187. // Requires:
  188. //
  189. // Returns:
  190. //
  191. // Notes:
  192. //
  193. //
  194. //--------------------------------------------------------------------------
  195. extern "C" SECURITY_STATUS SEC_ENTRY
  196. FreeCredentialsHandle(PCredHandle phCredential)
  197. {
  198. // bugbug - asserted.
  199. if (!InitGlobals())
  200. return SEC_E_INTERNAL_ERROR;
  201. SECURITY_STATUS ssResult;
  202. // Get the session context from the handle.
  203. CSess *pSess;
  204. pSess = g_pCache->MapHandleToSession(phCredential->dwUpper);
  205. if (!pSess)
  206. {
  207. DIGEST_ASSERT(FALSE);
  208. ssResult = SEC_E_UNKNOWN_CREDENTIALS;
  209. goto exit;
  210. }
  211. // Logoff from the cache.
  212. if (g_pCache->LogOffFromCache(pSess) != ERROR_SUCCESS)
  213. {
  214. DIGEST_ASSERT(FALSE);
  215. ssResult = SEC_E_INTERNAL_ERROR;
  216. goto exit;
  217. }
  218. ssResult = SEC_E_OK;
  219. exit:
  220. return ssResult;
  221. }
  222. //--------------------------------------------------------------------------
  223. //
  224. // Function: InitializeSecurityContextA
  225. //
  226. // Synopsis:
  227. //
  228. // Effects:
  229. //
  230. // Arguments:
  231. //
  232. // Requires:
  233. //
  234. // Returns:
  235. //
  236. // Notes:
  237. //
  238. //--------------------------------------------------------------------------
  239. extern "C" SECURITY_STATUS SEC_ENTRY
  240. InitializeSecurityContextA(
  241. PCredHandle phCredential, // Cred to base context
  242. PCtxtHandle phContext, // Existing context (OPT)
  243. LPSTR pszTargetName, // Name of target
  244. DWORD fContextReq, // Context Requirements
  245. DWORD Reserved1, // Reserved, MBZ
  246. DWORD TargetDataRep, // Data rep of target
  247. PSecBufferDesc pInput, // Input Buffers
  248. DWORD Reserved2, // Reserved, MBZ
  249. PCtxtHandle phNewContext, // (out) New Context handle
  250. PSecBufferDesc pOutput, // (inout) Output Buffers
  251. DWORD SEC_FAR * pfContextAttr, // (out) Context attrs
  252. PTimeStamp ptsExpiry // (out) Life span (OPT)
  253. )
  254. {
  255. if (!InitGlobals())
  256. return SEC_E_INTERNAL_ERROR;
  257. LPSTR szHost, szRealm, szUser, szPass, szNonce;
  258. DWORD cbHost, cbRealm, cbUser, cbPass, cbNonce;
  259. LPSTR szCtx = NULL;
  260. SECURITY_STATUS ssResult = SEC_E_OK;
  261. // Client nonce NULL except for md5-sess.
  262. LPSTR szCNonce = NULL;
  263. CSess *pSess;
  264. CCred *pCred;
  265. CParams *pParams = NULL;
  266. CCredInfo *pInfo = NULL;
  267. // Rude credential flush for all apps.
  268. if (!phCredential && (fContextReq & ISC_REQ_NULL_SESSION))
  269. {
  270. g_pCache->FlushCreds(NULL, NULL);
  271. ssResult = SEC_E_OK;
  272. goto exit;
  273. }
  274. // Get the session pointer from the handle.
  275. pSess = g_pCache->MapHandleToSession(phCredential->dwUpper);
  276. if (!pSess)
  277. {
  278. DIGEST_ASSERT(FALSE);
  279. ssResult = SEC_E_UNKNOWN_CREDENTIALS;
  280. goto exit;
  281. }
  282. // Legacy conn. oriented client may require a continue
  283. // message on null buffer input.
  284. if (!pSess->fHTTP && !pInput && pOutput)
  285. {
  286. *((LPDWORD) (pOutput->pBuffers[0].pvBuffer)) = 0;
  287. pOutput->pBuffers[0].cbBuffer = sizeof(DWORD);
  288. ssResult = SEC_I_CONTINUE_NEEDED;
  289. goto exit;
  290. }
  291. // Flush creds for indicated session.
  292. if (fContextReq & ISC_REQ_NULL_SESSION)
  293. {
  294. g_pCache->FlushCreds(pSess, NULL);
  295. ssResult = SEC_E_OK;
  296. goto exit;
  297. }
  298. DIGEST_ASSERT(phCredential && pInput && pOutput);
  299. // Parse the challenge to a params object.
  300. if (CDigest::ParseChallenge(pSess, pInput,
  301. &pParams, fContextReq) != ERROR_SUCCESS)
  302. {
  303. // DIGEST_ASSERT(FALSE);
  304. ssResult = SEC_E_INVALID_TOKEN;
  305. goto exit;
  306. }
  307. // Get host, realm (required) and any nonce, user & pass.
  308. pParams->GetParam(CParams::HOST, &szHost, &cbHost);
  309. pParams->GetParam(CParams::REALM, &szRealm, &cbRealm);
  310. pParams->GetParam(CParams::NONCE, &szNonce, &cbNonce);
  311. pParams->GetParam(CParams::USER, &szUser, &cbUser);
  312. pParams->GetParam(CParams::PASS, &szPass, &cbPass);
  313. // If prompting UI is indicated.
  314. if (fContextReq & ISC_REQ_PROMPT_FOR_CREDS)
  315. {
  316. CCredInfo *pInfoIn, *pInfoOut;
  317. // Attempt to get one or more cred infos
  318. pInfoIn = g_pCache->FindCred(pSess, szHost, szRealm,
  319. szUser, NULL, NULL, FIND_CRED_UI);
  320. // Get the persistence key from pSess
  321. szCtx = CSess::GetCtx(pSess);
  322. DIGEST_ASSERT(szCtx);
  323. // If this is prompting for UI specifying md5-sess,
  324. // create a client nonce to associate with cred.
  325. if (pParams->IsMd5Sess())
  326. szCNonce = CDigest::MakeCNonce();
  327. pParams->GetParam(CParams::HOST, &szHost, &cbHost);
  328. // Prompt with authentication dialog.
  329. if (DigestErrorDlg(szCtx, szHost, szRealm,
  330. szUser, szNonce, szCNonce,
  331. pInfoIn, &pInfoOut, pParams->GetHwnd()) == ERROR_SUCCESS)
  332. {
  333. DIGEST_ASSERT(pInfoOut);
  334. // Create the credential.
  335. pCred = g_pCache->CreateCred(pSess, pInfoOut);
  336. // Record that the host is trusted.
  337. if (pSess->fHTTP)
  338. CCredCache::SetTrustedHostInfo(szCtx, pParams);
  339. }
  340. else
  341. {
  342. ssResult = SEC_E_NO_CREDENTIALS;
  343. goto exit;
  344. }
  345. // Retrieve the credentials just created.
  346. pInfo = g_pCache->FindCred(pSess, szHost, szRealm,
  347. pInfoOut->szUser, szNonce, szCNonce, FIND_CRED_AUTH);
  348. // Clean up one or more cred infos.
  349. // BUGBUG - null out pointers after freeing.
  350. while (pInfoIn)
  351. {
  352. CCredInfo *pNext;
  353. pNext = pInfoIn->pNext;
  354. delete pInfoIn;
  355. pInfoIn = pNext;
  356. }
  357. if (pInfoOut)
  358. delete pInfoOut;
  359. if (szCNonce)
  360. delete szCNonce;
  361. if (!pInfo)
  362. {
  363. ssResult = SEC_E_NO_CREDENTIALS;
  364. goto exit;
  365. }
  366. }
  367. // Otherwise we are attempting to authenticate. We may be either
  368. // authenticating in response to a challenge or pre-authenticating.
  369. else
  370. {
  371. // Get the persistence key from pSess
  372. szCtx = CSess::GetCtx(pSess);
  373. DIGEST_ASSERT(szCtx);
  374. // For HTTP sessions we check the trusted host list unless
  375. // 1) credentials are supplied, or 2) a context has been passed
  376. // in which specifically instructs to ignore the host list.
  377. if (pSess->fHTTP && !pParams->IsPreAuth() && !pParams->AreCredsSupplied())
  378. {
  379. if (!phContext || !(phContext->dwUpper & DIGEST_PKG_FLAGS_IGNORE_TRUSTED_HOST_LIST))
  380. {
  381. if (!CCredCache::IsTrustedHost(szCtx, szHost))
  382. {
  383. ssResult = SEC_E_NO_CREDENTIALS;
  384. goto exit;
  385. }
  386. }
  387. }
  388. // If preauthenticating.
  389. if (pParams->IsPreAuth())
  390. {
  391. // If using supplied credentials.
  392. if (pParams->AreCredsSupplied())
  393. {
  394. // Create a cred info using supplied values. Include passed-in NC.
  395. pInfo = new CCredInfo(szHost, szRealm, szUser, szPass, szNonce, szCNonce);
  396. pInfo->cCount = pParams->GetNC();
  397. if (!(pInfo && pInfo->dwStatus == ERROR_SUCCESS))
  398. {
  399. DIGEST_ASSERT(FALSE);
  400. ssResult = SEC_E_INTERNAL_ERROR;
  401. goto exit;
  402. }
  403. }
  404. // Otherwise attempt to find cred info in cache.
  405. else
  406. {
  407. // Attempt to find the credentials from realm and any user.
  408. pInfo = g_pCache->FindCred(pSess, szHost, szRealm,
  409. szUser, NULL, NULL, FIND_CRED_PREAUTH);
  410. }
  411. // Return if no credentials exist.
  412. if (!pInfo)
  413. {
  414. ssResult = SEC_E_NO_CREDENTIALS;
  415. goto exit;
  416. }
  417. }
  418. // Otherwise auth in response to challenge.
  419. else
  420. {
  421. // Check if logoff is requested.
  422. CHAR* szLogoff;
  423. szLogoff = pParams->GetParam(CParams::LOGOFF);
  424. if (szLogoff && !lstrcmpi(szLogoff, "TRUE"))
  425. {
  426. g_pCache->FlushCreds(NULL, szRealm);
  427. ssResult = SEC_E_CONTEXT_EXPIRED;
  428. goto exit;
  429. }
  430. // If a context is passed in examine the stale header unless specifically
  431. // directed not to.
  432. if (pSess->fHTTP
  433. && phContext
  434. && !pParams->AreCredsSupplied()
  435. && !(phContext->dwUpper & DIGEST_PKG_FLAGS_IGNORE_STALE_HEADER))
  436. {
  437. CHAR* szStale;
  438. DWORD cbStale;
  439. pParams->GetParam(CParams::STALE, &szStale, &cbStale);
  440. if (!szStale || !lstrcmpi(szStale, "FALSE"))
  441. {
  442. ssResult = SEC_E_NO_CREDENTIALS;
  443. goto exit;
  444. }
  445. }
  446. // If this is authenticating specifying md5-sess,
  447. // create a client nonce to associate with cred.
  448. if (pParams->IsMd5Sess())
  449. szCNonce = CDigest::MakeCNonce();
  450. // If credentials are supplied, create an entry in
  451. // the credential cache. We search as usual subsequently.
  452. if (pParams->AreCredsSupplied())
  453. {
  454. // Create a cred info using supplied values.
  455. pInfo = new CCredInfo(szHost, szRealm, szUser, szPass, szNonce, szCNonce);
  456. if (!(pInfo && pInfo->dwStatus == ERROR_SUCCESS))
  457. {
  458. DIGEST_ASSERT(FALSE);
  459. ssResult = SEC_E_INTERNAL_ERROR;
  460. goto exit;
  461. }
  462. pCred = g_pCache->CreateCred(pSess, pInfo);
  463. delete pInfo;
  464. }
  465. // Attempt to find the credentials from realm and any user.
  466. pInfo = g_pCache->FindCred(pSess, szHost, szRealm,
  467. szUser, szNonce, szCNonce, FIND_CRED_AUTH);
  468. // Return if no credentials exist.
  469. if (!pInfo)
  470. {
  471. ssResult = SEC_E_NO_CREDENTIALS;
  472. goto exit;
  473. }
  474. }
  475. }
  476. // We should now have the appropriate cred info. Generate the response.
  477. DIGEST_ASSERT(pInfo);
  478. if (CDigest::GenerateResponse(pSess, pParams,
  479. pInfo, pOutput) != ERROR_SUCCESS)
  480. {
  481. DIGEST_ASSERT(FALSE);
  482. ssResult = SEC_E_INTERNAL_ERROR;
  483. goto exit;
  484. }
  485. // Delete cred info if allocated.
  486. // bugbug - move further down.
  487. if (pInfo)
  488. delete pInfo;
  489. ssResult = SEC_E_OK;
  490. exit:
  491. if ((ssResult != SEC_E_OK) &&
  492. (ssResult != SEC_I_CONTINUE_NEEDED))
  493. pOutput->pBuffers[0].cbBuffer = 0;
  494. // BUGBUG - delete pInfo if not NULL.
  495. // Delete persistence key if allocated.
  496. if (szCtx)
  497. delete szCtx;
  498. // Identify the new context.
  499. if (phNewContext && phCredential)
  500. phNewContext->dwLower = phCredential->dwLower;
  501. // Delete the params object.
  502. if (pParams)
  503. delete pParams;
  504. return ssResult;
  505. }
  506. //--------------------------------------------------------------------------
  507. //
  508. // Function: AcceptSecurityContext
  509. //
  510. // Synopsis:
  511. //
  512. // Effects:
  513. //
  514. // Arguments:
  515. //
  516. // Requires:
  517. //
  518. // Returns:
  519. //
  520. // Notes:
  521. //
  522. //
  523. //--------------------------------------------------------------------------
  524. extern "C" SECURITY_STATUS SEC_ENTRY
  525. AcceptSecurityContext(
  526. PCredHandle phCredential, // Cred to base context
  527. PCtxtHandle phContext, // Existing context (OPT)
  528. PSecBufferDesc pInput, // Input buffer
  529. unsigned long fContextReq, // Context Requirements
  530. unsigned long TargetDataRep, // Target Data Rep
  531. PCtxtHandle phNewContext, // (out) New context handle
  532. PSecBufferDesc pOutput, // (inout) Output buffers
  533. unsigned long SEC_FAR * pfContextAttr, // (out) Context attributes
  534. PTimeStamp ptsExpiry // (out) Life span (OPT)
  535. )
  536. {
  537. // BUGBUG - don't need initglobals.
  538. if (!InitGlobals())
  539. return SEC_E_INTERNAL_ERROR;
  540. return(SEC_E_UNSUPPORTED_FUNCTION);
  541. }
  542. //--------------------------------------------------------------------------
  543. //
  544. // Function: DeleteSecurityContext
  545. //
  546. // Synopsis:
  547. //
  548. // Effects:
  549. //
  550. // Arguments:
  551. //
  552. // Requires:
  553. //
  554. // Returns:
  555. //
  556. // Notes:
  557. //
  558. //
  559. //--------------------------------------------------------------------------
  560. extern "C" SECURITY_STATUS SEC_ENTRY
  561. DeleteSecurityContext(
  562. PCtxtHandle phContext // Context to delete
  563. )
  564. {
  565. if (!InitGlobals())
  566. return SEC_E_INTERNAL_ERROR;
  567. return SEC_E_UNSUPPORTED_FUNCTION;
  568. }
  569. //--------------------------------------------------------------------------
  570. //
  571. // Function: ApplyControlToken
  572. //
  573. // Synopsis:
  574. //
  575. // Effects:
  576. //
  577. // Arguments:
  578. //
  579. // Requires:
  580. //
  581. // Returns:
  582. //
  583. // Notes:
  584. //
  585. //
  586. //--------------------------------------------------------------------------
  587. extern "C" SECURITY_STATUS SEC_ENTRY
  588. ApplyControlToken(
  589. PCtxtHandle phContext, // Context to modify
  590. PSecBufferDesc pInput // Input token to apply
  591. )
  592. {
  593. if (!InitGlobals())
  594. return SEC_E_INTERNAL_ERROR;
  595. SECURITY_STATUS ssResult;
  596. // Current flags used are
  597. // DIGEST_PKG_FLAG_IGNORE_TRUSTED_HOST_LIST
  598. // DIGEST_PKG_FLAG_IGNORE_STALE_HEADER
  599. phContext->dwUpper |= *((LPDWORD) (pInput->pBuffers[0].pvBuffer));
  600. ssResult = SEC_E_OK;
  601. return ssResult;
  602. }
  603. //--------------------------------------------------------------------------
  604. //
  605. // Function: EnumerateSecurityPackagesA
  606. //
  607. // Synopsis:
  608. //
  609. // Effects:
  610. //
  611. // Arguments:
  612. //
  613. // Requires:
  614. //
  615. // Returns:
  616. //
  617. // Notes:
  618. //
  619. //
  620. //--------------------------------------------------------------------------
  621. SECURITY_STATUS SEC_ENTRY
  622. EnumerateSecurityPackagesA(DWORD SEC_FAR *pcPackages,
  623. PSecPkgInfoA SEC_FAR *ppSecPkgInfo)
  624. {
  625. SECURITY_STATUS ssResult;
  626. // BUGBUG - ALLOW ASSERTS?
  627. ssResult = QuerySecurityPackageInfoA(PACKAGE_NAME, ppSecPkgInfo);
  628. if (ssResult == SEC_E_OK)
  629. {
  630. *pcPackages = 1;
  631. }
  632. return ssResult;
  633. }
  634. //--------------------------------------------------------------------------
  635. //
  636. // Function: QuerySecurityPackageInfoA
  637. //
  638. // Synopsis:
  639. //
  640. // Effects:
  641. //
  642. // Arguments:
  643. //
  644. // Requires:
  645. //
  646. // Returns:
  647. //
  648. // Notes:
  649. //
  650. //
  651. //--------------------------------------------------------------------------
  652. SECURITY_STATUS SEC_ENTRY
  653. QuerySecurityPackageInfoA(LPSTR szPackageName,
  654. PSecPkgInfoA SEC_FAR *ppSecPkgInfo)
  655. {
  656. // BUGBUG - ALLOW ASSERTS?
  657. PSecPkgInfoA pSecPkgInfo;
  658. DWORD cbSecPkgInfo;
  659. SECURITY_STATUS ssResult;
  660. LPSTR pCur;
  661. if (strcmp(szPackageName, PACKAGE_NAME))
  662. {
  663. ssResult = SEC_E_SECPKG_NOT_FOUND;
  664. goto exit;
  665. }
  666. cbSecPkgInfo = sizeof(SecPkgInfoA)
  667. + sizeof(PACKAGE_NAME)
  668. + sizeof(PACKAGE_COMMENT);
  669. pSecPkgInfo = (PSecPkgInfoA) LocalAlloc(0,cbSecPkgInfo);
  670. if (!pSecPkgInfo)
  671. {
  672. ssResult = SEC_E_INSUFFICIENT_MEMORY;
  673. goto exit;
  674. }
  675. pSecPkgInfo->fCapabilities = PACKAGE_CAPABILITIES;
  676. pSecPkgInfo->wVersion = PACKAGE_VERSION;
  677. pSecPkgInfo->wRPCID = PACKAGE_RPCID;
  678. pSecPkgInfo->cbMaxToken = PACKAGE_MAXTOKEN;
  679. pCur = (LPSTR) (pSecPkgInfo) + sizeof(SecPkgInfoA);
  680. pSecPkgInfo->Name = pCur;
  681. memcpy(pSecPkgInfo->Name, PACKAGE_NAME, sizeof(PACKAGE_NAME));
  682. pCur += sizeof(PACKAGE_NAME);
  683. pSecPkgInfo->Comment = pCur;
  684. memcpy(pSecPkgInfo->Comment, PACKAGE_COMMENT, sizeof(PACKAGE_COMMENT));
  685. *ppSecPkgInfo = pSecPkgInfo;
  686. ssResult = SEC_E_OK;
  687. exit:
  688. return ssResult;
  689. }
  690. //--------------------------------------------------------------------------
  691. //
  692. // Function: FreeContextBuffer
  693. //
  694. // Synopsis:
  695. //
  696. // Effects:
  697. //
  698. // Arguments:
  699. //
  700. // Requires:
  701. //
  702. // Returns:
  703. //
  704. // Notes:
  705. //
  706. //
  707. //--------------------------------------------------------------------------
  708. extern "C" SECURITY_STATUS SEC_ENTRY
  709. FreeContextBuffer(void SEC_FAR *pvContextBuffer)
  710. {
  711. if (!InitGlobals())
  712. return SEC_E_INTERNAL_ERROR;
  713. LocalFree(pvContextBuffer);
  714. return SEC_E_OK;
  715. }
  716. //--------------------------------------------------------------------------
  717. //
  718. // Function: CompleteAuthToken
  719. //
  720. // Synopsis:
  721. //
  722. // Effects:
  723. //
  724. // Arguments:
  725. //
  726. // Requires:
  727. //
  728. // Returns:
  729. //
  730. // Notes:
  731. //
  732. //
  733. //--------------------------------------------------------------------------
  734. extern "C" SECURITY_STATUS SEC_ENTRY
  735. CompleteAuthToken(
  736. PCtxtHandle phContext, // Context to complete
  737. PSecBufferDesc pToken // Token to complete
  738. )
  739. {
  740. if (!InitGlobals())
  741. return SEC_E_INTERNAL_ERROR;
  742. return SEC_E_UNSUPPORTED_FUNCTION;
  743. }
  744. //--------------------------------------------------------------------------
  745. //
  746. // Function: ImpersonateSecurityContext
  747. //
  748. // Synopsis:
  749. //
  750. // Effects:
  751. //
  752. // Arguments:
  753. //
  754. // Requires:
  755. //
  756. // Returns:
  757. //
  758. // Notes:
  759. //
  760. //
  761. //--------------------------------------------------------------------------
  762. extern "C" SECURITY_STATUS SEC_ENTRY
  763. ImpersonateSecurityContext(
  764. PCtxtHandle phContext // Context to impersonate
  765. )
  766. {
  767. if (!InitGlobals())
  768. return SEC_E_INTERNAL_ERROR;
  769. return SEC_E_UNSUPPORTED_FUNCTION;
  770. }
  771. //--------------------------------------------------------------------------
  772. //
  773. // Function: RevertSecurityContext
  774. //
  775. // Synopsis:
  776. //
  777. // Effects:
  778. //
  779. // Arguments:
  780. //
  781. // Requires:
  782. //
  783. // Returns:
  784. //
  785. // Notes:
  786. //
  787. //
  788. //--------------------------------------------------------------------------
  789. extern "C" SECURITY_STATUS SEC_ENTRY
  790. RevertSecurityContext(
  791. PCtxtHandle phContext // Context from which to re
  792. )
  793. {
  794. if (!InitGlobals())
  795. return SEC_E_INTERNAL_ERROR;
  796. return SEC_E_UNSUPPORTED_FUNCTION;
  797. }
  798. //--------------------------------------------------------------------------
  799. //
  800. // Function: QueryContextAttributesA
  801. //
  802. // Synopsis:
  803. //
  804. // Effects:
  805. //
  806. // Arguments:
  807. //
  808. // Requires:
  809. //
  810. // Returns:
  811. //
  812. // Notes:
  813. //
  814. //
  815. //--------------------------------------------------------------------------
  816. extern "C" SECURITY_STATUS SEC_ENTRY
  817. QueryContextAttributesA(
  818. PCtxtHandle phContext, // Context to query
  819. unsigned long ulAttribute, // Attribute to query
  820. void SEC_FAR * pBuffer // Buffer for attributes
  821. )
  822. {
  823. if (!InitGlobals())
  824. return SEC_E_INTERNAL_ERROR;
  825. return SEC_E_UNSUPPORTED_FUNCTION;
  826. }
  827. //--------------------------------------------------------------------------
  828. //
  829. // Function: MakeSignature
  830. //
  831. // Synopsis:
  832. //
  833. // Effects:
  834. //
  835. // Arguments: [phContext] -- context to use
  836. // [fQOP] -- quality of protection to use
  837. // [pMessage] -- message
  838. // [MessageSeqNo] -- sequence number of message
  839. //
  840. // Requires:
  841. //
  842. // Returns:
  843. //
  844. // Notes:
  845. //
  846. //--------------------------------------------------------------------------
  847. extern "C" SECURITY_STATUS SEC_ENTRY
  848. MakeSignature( PCtxtHandle phContext,
  849. ULONG fQOP,
  850. PSecBufferDesc pMessage,
  851. ULONG MessageSeqNo)
  852. {
  853. if (!InitGlobals())
  854. return SEC_E_INTERNAL_ERROR;
  855. return SEC_E_UNSUPPORTED_FUNCTION;
  856. }
  857. //--------------------------------------------------------------------------
  858. //
  859. // Function: VerifySignature
  860. //
  861. // Synopsis:
  862. //
  863. // Effects:
  864. //
  865. // Arguments: [phContext] -- Context performing the unseal
  866. // [pMessage] -- Message to verify
  867. // [MessageSeqNo] -- Sequence number of this message
  868. // [pfQOPUsed] -- quality of protection used
  869. //
  870. // Requires:
  871. //
  872. // Returns:
  873. //
  874. // Notes:
  875. //
  876. //--------------------------------------------------------------------------
  877. extern "C" SECURITY_STATUS SEC_ENTRY
  878. VerifySignature(PCtxtHandle phContext,
  879. PSecBufferDesc pMessage,
  880. ULONG MessageSeqNo,
  881. ULONG * pfQOP)
  882. {
  883. if (!InitGlobals())
  884. return SEC_E_INTERNAL_ERROR;
  885. return SEC_E_UNSUPPORTED_FUNCTION;
  886. }