~ubuntu-branches/ubuntu/vivid/wpasupplicant/vivid

« back to all changes in this revision

Viewing changes to tls_schannel.c

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2006-10-05 08:04:01 UTC
  • mfrom: (1.1.5 upstream) (3 etch)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20061005080401-r8lqlix4390yos7b
Tags: 0.5.5-2
* Update madwifi headers to latest SVN. (Closes: #388316)
* Remove failed attempt at action locking. [debian/functions.sh,
  debian/wpa_action.sh]
* Add hysteresis checking functions, to avoid "event loops" while
  using wpa-roam. [debian/functions.sh, debian/wpa_action.sh]
* Change of co-maintainer email address.
* Add ishex() function to functions.sh to determine wpa-psk value type in
  plaintext or hex. This effectively eliminates the need for the bogus and
  somewhat confusing wpa-passphrase contruct specific to our scripts and
  allows wpa-psk to work with either a 8 to 63 character long plaintext
  string or 64 character long hex string.
* Adjust README.modes to not refer to the redundant wpa-passphrase stuff.
* Add big fat NOTE about acceptable wpa-psk's to top of example gallery.
* Strip surrounding quotes from wpa-ssid if present, instead of just whining
  about them.
* Update email address in copyright blurb of functions.sh, ifupdown.sh and
  wpa_action.sh.  

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
{
56
56
        INIT_SECURITY_INTERFACE pInitSecurityInterface;
57
57
 
58
 
        global->hsecurity = LoadLibrary("Secur32.dll");
 
58
        global->hsecurity = LoadLibrary(TEXT("Secur32.dll"));
59
59
        if (global->hsecurity == NULL) {
60
60
                wpa_printf(MSG_ERROR, "%s: Could not load Secur32.dll - 0x%x",
61
61
                           __func__, (unsigned int) GetLastError());
241
241
        outbuf.pBuffers = outbufs;
242
242
        outbuf.ulVersion = SECBUFFER_VERSION;
243
243
 
 
244
#ifdef UNICODE
 
245
        status = global->sspi->InitializeSecurityContextW(
 
246
                &conn->creds, NULL, NULL /* server name */, sspi_flags, 0,
 
247
                SECURITY_NATIVE_DREP, NULL, 0, &conn->context,
 
248
                &outbuf, &sspi_flags_out, &ts_expiry);
 
249
#else /* UNICODE */
244
250
        status = global->sspi->InitializeSecurityContextA(
245
251
                &conn->creds, NULL, NULL /* server name */, sspi_flags, 0,
246
252
                SECURITY_NATIVE_DREP, NULL, 0, &conn->context,
247
253
                &outbuf, &sspi_flags_out, &ts_expiry);
 
254
#endif /* UNICODE */
248
255
        if (status != SEC_I_CONTINUE_NEEDED) {
249
256
                wpa_printf(MSG_ERROR, "%s: InitializeSecurityContextA "
250
257
                           "failed - 0x%x",
305
312
 
306
313
        memcpy(conn->eap_tls_prf, kb.rgbKeys, sizeof(kb.rgbKeys));
307
314
        conn->eap_tls_prf_set = 1;
 
315
        return 0;
308
316
}
309
317
 
310
318
 
311
319
u8 * tls_connection_handshake(void *ssl_ctx, struct tls_connection *conn,
312
320
                              const u8 *in_data, size_t in_len,
313
 
                              size_t *out_len)
 
321
                              size_t *out_len, u8 **appl_data,
 
322
                              size_t *appl_data_len)
314
323
{
315
324
        struct tls_global *global = ssl_ctx;
316
325
        DWORD sspi_flags, sspi_flags_out;
320
329
        TimeStamp ts_expiry;
321
330
        u8 *out_buf = NULL;
322
331
 
 
332
        if (appl_data)
 
333
                *appl_data = NULL;
 
334
 
323
335
        if (conn->start) {
324
336
                return tls_conn_hs_clienthello(global, conn, out_len);
325
337
        }
356
368
        outbuf.pBuffers = outbufs;
357
369
        outbuf.ulVersion = SECBUFFER_VERSION;
358
370
 
 
371
#ifdef UNICODE
 
372
        status = global->sspi->InitializeSecurityContextW(
 
373
                &conn->creds, &conn->context, NULL, sspi_flags, 0,
 
374
                SECURITY_NATIVE_DREP, &inbuf, 0, NULL,
 
375
                &outbuf, &sspi_flags_out, &ts_expiry);
 
376
#else /* UNICODE */
359
377
        status = global->sspi->InitializeSecurityContextA(
360
378
                &conn->creds, &conn->context, NULL, sspi_flags, 0,
361
379
                SECURITY_NATIVE_DREP, &inbuf, 0, NULL,
362
380
                &outbuf, &sspi_flags_out, &ts_expiry);
 
381
#endif /* UNICODE */
363
382
 
364
 
        wpa_printf(MSG_MSGDUMP, "Schannel: InitializeSecurityContextA -> "
 
383
        wpa_printf(MSG_MSGDUMP, "Schannel: InitializeSecurityContext -> "
365
384
                   "status=%d inlen[0]=%d intype[0]=%d inlen[1]=%d "
366
385
                   "intype[1]=%d outlen[0]=%d",
367
386
                   (int) status, (int) inbufs[0].cbBuffer,
375
394
                                    outbufs[0].pvBuffer, outbufs[0].cbBuffer);
376
395
                        *out_len = outbufs[0].cbBuffer;
377
396
                        out_buf = malloc(*out_len);
 
397
                        if (out_buf)
 
398
                                memcpy(out_buf, outbufs[0].pvBuffer, *out_len);
 
399
                        global->sspi->FreeContextBuffer(outbufs[0].pvBuffer);
 
400
                        outbufs[0].pvBuffer = NULL;
378
401
                        if (out_buf == NULL)
379
402
                                return NULL;
380
 
                        memcpy(out_buf, outbufs[0].pvBuffer, *out_len);
381
 
                        global->sspi->FreeContextBuffer(outbufs[0].pvBuffer);
382
 
                        outbufs[0].pvBuffer = NULL;
383
403
                }
384
404
        }
385
405
 
405
425
                        wpa_hexdump(MSG_MSGDUMP, "SChannel - Encrypted "
406
426
                                    "application data",
407
427
                                    inbufs[1].pvBuffer, inbufs[1].cbBuffer);
408
 
                        /* FIX: need to fix TLS API to allow this data to be
409
 
                         * passed to the caller */
 
428
                        if (appl_data) {
 
429
                                *appl_data_len = outbufs[1].cbBuffer;
 
430
                                appl_data = malloc(*appl_data_len);
 
431
                                if (appl_data)
 
432
                                        memcpy(appl_data, outbufs[1].pvBuffer,
 
433
                                               *appl_data_len);
 
434
                        }
410
435
                        global->sspi->FreeContextBuffer(inbufs[1].pvBuffer);
411
436
                        inbufs[1].pvBuffer = NULL;
412
437
                }
634
659
}
635
660
 
636
661
 
637
 
int tls_connection_set_anon_dh(void *ssl_ctx, struct tls_connection *conn)
 
662
int tls_connection_set_cipher_list(void *tls_ctx, struct tls_connection *conn,
 
663
                                   u8 *ciphers)
638
664
{
639
665
        return -1;
640
666
}
698
724
                return -1;
699
725
 
700
726
        if (global->my_cert_store == NULL &&
701
 
            (global->my_cert_store = CertOpenSystemStore(0, "MY")) == NULL) {
 
727
            (global->my_cert_store = CertOpenSystemStore(0, TEXT("MY"))) ==
 
728
            NULL) {
702
729
                wpa_printf(MSG_ERROR, "%s: CertOpenSystemStore failed - 0x%x",
703
730
                           __func__, (unsigned int) GetLastError());
704
731
                return -1;
711
738
        conn->schannel_cred.cSupportedAlgs = 1;
712
739
        conn->schannel_cred.palgSupportedAlgs = algs;
713
740
        conn->schannel_cred.dwFlags |= SCH_CRED_NO_DEFAULT_CREDS;
 
741
#ifdef UNICODE
 
742
        status = global->sspi->AcquireCredentialsHandleW(
 
743
                NULL, UNISP_NAME_W, SECPKG_CRED_OUTBOUND, NULL,
 
744
                &conn->schannel_cred, NULL, NULL, &conn->creds, &ts_expiry);
 
745
#else /* UNICODE */
714
746
        status = global->sspi->AcquireCredentialsHandleA(
715
747
                NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND, NULL,
716
748
                &conn->schannel_cred, NULL, NULL, &conn->creds, &ts_expiry);
 
749
#endif /* UNICODE */
717
750
        if (status != SEC_E_OK) {
718
751
                wpa_printf(MSG_DEBUG, "%s: AcquireCredentialsHandleA failed - "
719
752
                           "0x%x", __func__, (unsigned int) status);